linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pwm: lpss: remove dependency on clk framework
@ 2014-05-09  8:35 Heikki Krogerus
  2014-05-12  7:09 ` Mika Westerberg
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Heikki Krogerus @ 2014-05-09  8:35 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Mika Westerberg, Alan Cox, Chew Chiau Ee, linux-pwm, linux-kernel

Unlike other Intel LPSS devices, the PWM does not have the
clock dividers or the gate. All we get from the clock is the
rate. Since PCI case uses the driver data to get the rate,
we can drop the clk and use the same data also in case of
ACPI. The frequency is the same.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/pwm/pwm-lpss.c | 32 ++++++++++----------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
index 44ce6c6..4df994f 100644
--- a/drivers/pwm/pwm-lpss.c
+++ b/drivers/pwm/pwm-lpss.c
@@ -14,7 +14,6 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -37,7 +36,6 @@ static int pci_drv, plat_drv;	/* So we know which drivers registered */
 struct pwm_lpss_chip {
 	struct pwm_chip chip;
 	void __iomem *regs;
-	struct clk *clk;
 	unsigned long clk_rate;
 };
 
@@ -97,11 +95,6 @@ static int pwm_lpss_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
 	struct pwm_lpss_chip *lpwm = to_lpwm(chip);
 	u32 ctrl;
-	int ret;
-
-	ret = clk_prepare_enable(lpwm->clk);
-	if (ret)
-		return ret;
 
 	ctrl = readl(lpwm->regs + PWM);
 	writel(ctrl | PWM_ENABLE, lpwm->regs + PWM);
@@ -116,8 +109,6 @@ static void pwm_lpss_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 
 	ctrl = readl(lpwm->regs + PWM);
 	writel(ctrl & ~PWM_ENABLE, lpwm->regs + PWM);
-
-	clk_disable_unprepare(lpwm->clk);
 }
 
 static const struct pwm_ops pwm_lpss_ops = {
@@ -142,17 +133,7 @@ static struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev,
 	if (IS_ERR(lpwm->regs))
 		return ERR_CAST(lpwm->regs);
 
-	if (info) {
-		lpwm->clk_rate = info->clk_rate;
-	} else {
-		lpwm->clk = devm_clk_get(dev, NULL);
-		if (IS_ERR(lpwm->clk)) {
-			dev_err(dev, "failed to get PWM clock\n");
-			return ERR_CAST(lpwm->clk);
-		}
-		lpwm->clk_rate = clk_get_rate(lpwm->clk);
-	}
-
+	lpwm->clk_rate = info->clk_rate;
 	lpwm->chip.dev = dev;
 	lpwm->chip.ops = &pwm_lpss_ops;
 	lpwm->chip.base = -1;
@@ -221,12 +202,19 @@ static struct pci_driver pwm_lpss_driver_pci = {
 
 static int pwm_lpss_probe_platform(struct platform_device *pdev)
 {
+	const struct pwm_lpss_boardinfo *info;
+	const struct acpi_device_id *id;
 	struct pwm_lpss_chip *lpwm;
 	struct resource *r;
 
+	id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
+	if (!id)
+		return -ENODEV;
+
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-	lpwm = pwm_lpss_probe(&pdev->dev, r, NULL);
+	info = (struct pwm_lpss_boardinfo *)id->driver_data;
+	lpwm = pwm_lpss_probe(&pdev->dev, r, info);
 	if (IS_ERR(lpwm))
 		return PTR_ERR(lpwm);
 
@@ -242,7 +230,7 @@ static int pwm_lpss_remove_platform(struct platform_device *pdev)
 }
 
 static const struct acpi_device_id pwm_lpss_acpi_match[] = {
-	{ "80860F09", 0 },
+	{ "80860F09", (unsigned long)&byt_info },
 	{ },
 };
 MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);
-- 
2.0.0.rc2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: lpss: remove dependency on clk framework
  2014-05-09  8:35 [PATCH] pwm: lpss: remove dependency on clk framework Heikki Krogerus
@ 2014-05-12  7:09 ` Mika Westerberg
  2014-05-14  7:00 ` Chew, Chiau Ee
  2014-08-07 11:19 ` Thierry Reding
  2 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2014-05-12  7:09 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Thierry Reding, Alan Cox, Chew Chiau Ee, linux-pwm, linux-kernel

On Fri, May 09, 2014 at 11:35:21AM +0300, Heikki Krogerus wrote:
> Unlike other Intel LPSS devices, the PWM does not have the
> clock dividers or the gate. All we get from the clock is the
> rate. Since PCI case uses the driver data to get the rate,
> we can drop the clk and use the same data also in case of
> ACPI. The frequency is the same.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

No objections from me,

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] pwm: lpss: remove dependency on clk framework
  2014-05-09  8:35 [PATCH] pwm: lpss: remove dependency on clk framework Heikki Krogerus
  2014-05-12  7:09 ` Mika Westerberg
@ 2014-05-14  7:00 ` Chew, Chiau Ee
  2014-05-14  8:39   ` Heikki Krogerus
  2014-08-07 11:19 ` Thierry Reding
  2 siblings, 1 reply; 6+ messages in thread
From: Chew, Chiau Ee @ 2014-05-14  7:00 UTC (permalink / raw)
  To: Heikki Krogerus, Thierry Reding
  Cc: Mika Westerberg, Alan Cox, linux-pwm, linux-kernel


> Unlike other Intel LPSS devices, the PWM does not have the clock dividers or
> the gate. All we get from the clock is the rate. Since PCI case uses the driver
> data to get the rate, we can drop the clk and use the same data also in case of
> ACPI. The frequency is the same.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/pwm/pwm-lpss.c | 32 ++++++++++----------------------
>  1 file changed, 10 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c index
> 44ce6c6..4df994f 100644
> --- a/drivers/pwm/pwm-lpss.c
> +++ b/drivers/pwm/pwm-lpss.c
> @@ -14,7 +14,6 @@
>   */
> 
>  #include <linux/acpi.h>
> -#include <linux/clk.h>
>  #include <linux/device.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> @@ -37,7 +36,6 @@ static int pci_drv, plat_drv;	/* So we know which drivers
> registered */
>  struct pwm_lpss_chip {
>  	struct pwm_chip chip;
>  	void __iomem *regs;
> -	struct clk *clk;
>  	unsigned long clk_rate;
>  };
> 
> @@ -97,11 +95,6 @@ static int pwm_lpss_enable(struct pwm_chip *chip,
> struct pwm_device *pwm)  {
>  	struct pwm_lpss_chip *lpwm = to_lpwm(chip);
>  	u32 ctrl;
> -	int ret;
> -
> -	ret = clk_prepare_enable(lpwm->clk);
> -	if (ret)
> -		return ret;
> 
>  	ctrl = readl(lpwm->regs + PWM);
>  	writel(ctrl | PWM_ENABLE, lpwm->regs + PWM); @@ -116,8 +109,6
> @@ static void pwm_lpss_disable(struct pwm_chip *chip, struct pwm_device
> *pwm)
> 
>  	ctrl = readl(lpwm->regs + PWM);
>  	writel(ctrl & ~PWM_ENABLE, lpwm->regs + PWM);
> -
> -	clk_disable_unprepare(lpwm->clk);
>  }
> 
>  static const struct pwm_ops pwm_lpss_ops = { @@ -142,17 +133,7 @@ static
> struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev,
>  	if (IS_ERR(lpwm->regs))
>  		return ERR_CAST(lpwm->regs);
> 
> -	if (info) {
> -		lpwm->clk_rate = info->clk_rate;
> -	} else {
> -		lpwm->clk = devm_clk_get(dev, NULL);
> -		if (IS_ERR(lpwm->clk)) {
> -			dev_err(dev, "failed to get PWM clock\n");
> -			return ERR_CAST(lpwm->clk);
> -		}
> -		lpwm->clk_rate = clk_get_rate(lpwm->clk);
> -	}
> -
> +	lpwm->clk_rate = info->clk_rate;
>  	lpwm->chip.dev = dev;
>  	lpwm->chip.ops = &pwm_lpss_ops;
>  	lpwm->chip.base = -1;
> @@ -221,12 +202,19 @@ static struct pci_driver pwm_lpss_driver_pci = {
> 
>  static int pwm_lpss_probe_platform(struct platform_device *pdev)  {
> +	const struct pwm_lpss_boardinfo *info;
> +	const struct acpi_device_id *id;
>  	struct pwm_lpss_chip *lpwm;
>  	struct resource *r;
> 
> +	id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev-
> >dev);
> +	if (!id)
> +		return -ENODEV;
> +
>  	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> 
> -	lpwm = pwm_lpss_probe(&pdev->dev, r, NULL);
> +	info = (struct pwm_lpss_boardinfo *)id->driver_data;
> +	lpwm = pwm_lpss_probe(&pdev->dev, r, info);
>  	if (IS_ERR(lpwm))
>  		return PTR_ERR(lpwm);
> 
> @@ -242,7 +230,7 @@ static int pwm_lpss_remove_platform(struct
> platform_device *pdev)  }
> 
>  static const struct acpi_device_id pwm_lpss_acpi_match[] = {
> -	{ "80860F09", 0 },
> +	{ "80860F09", (unsigned long)&byt_info },
>  	{ },
>  };

Heikki,
For ACPI mode, the clock rate information for PWM is being setup in the acpi_lpss.c layer.
Thus, only PCI mode depends on the driver_data to pass in the clock rate information.


>  MODULE_DEVICE_TABLE(acpi, pwm_lpss_acpi_match);
> --
> 2.0.0.rc2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: lpss: remove dependency on clk framework
  2014-05-14  7:00 ` Chew, Chiau Ee
@ 2014-05-14  8:39   ` Heikki Krogerus
  2014-05-14  8:54     ` Chew, Chiau Ee
  0 siblings, 1 reply; 6+ messages in thread
From: Heikki Krogerus @ 2014-05-14  8:39 UTC (permalink / raw)
  To: Chew, Chiau Ee
  Cc: Thierry Reding, Mika Westerberg, Alan Cox, linux-pwm, linux-kernel

Hi,

On Wed, May 14, 2014 at 07:00:59AM +0000, Chew, Chiau Ee wrote:
> Heikki,
> For ACPI mode, the clock rate information for PWM is being setup in the acpi_lpss.c layer.
> Thus, only PCI mode depends on the driver_data to pass in the clock rate information.

The goal with this patch is actually to free acpi_lpss.c from
delivering the clock for this driver.

The LPSS PWM does not get it's clock from the LPSS 100Mhz source
clock, which means we have to have the rate of it's clock hard-coded.
Since it's already hard coded also in this driver for PCI mode in any
case, it makes no sense to also have it there.

So this patch will allow us to cleanup acpi_lpss.c. We can now remove
the confusing "shared clock" structure where the hard coded rates are
held. This device is the only one that would need it.


Thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH] pwm: lpss: remove dependency on clk framework
  2014-05-14  8:39   ` Heikki Krogerus
@ 2014-05-14  8:54     ` Chew, Chiau Ee
  0 siblings, 0 replies; 6+ messages in thread
From: Chew, Chiau Ee @ 2014-05-14  8:54 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Thierry Reding, Mika Westerberg, Alan Cox, linux-pwm, linux-kernel

> 
> Hi,
> 
> On Wed, May 14, 2014 at 07:00:59AM +0000, Chew, Chiau Ee wrote:
> > Heikki,
> > For ACPI mode, the clock rate information for PWM is being setup in the
> acpi_lpss.c layer.
> > Thus, only PCI mode depends on the driver_data to pass in the clock rate
> information.
> 
> The goal with this patch is actually to free acpi_lpss.c from delivering the clock
> for this driver.
> 
> The LPSS PWM does not get it's clock from the LPSS 100Mhz source clock,
> which means we have to have the rate of it's clock hard-coded.
> Since it's already hard coded also in this driver for PCI mode in any case, it
> makes no sense to also have it there.
> 
> So this patch will allow us to cleanup acpi_lpss.c. We can now remove the
> confusing "shared clock" structure where the hard coded rates are held. This
> device is the only one that would need it.
> 

Oh ya...you are right. Sorry about that. I have mixed up the context with other I/O components.

Reviewed-by: Chew, Chiau Ee <chiau.ee.chew@intel.com>

> 
> Thanks,
> 
> --
> heikki

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pwm: lpss: remove dependency on clk framework
  2014-05-09  8:35 [PATCH] pwm: lpss: remove dependency on clk framework Heikki Krogerus
  2014-05-12  7:09 ` Mika Westerberg
  2014-05-14  7:00 ` Chew, Chiau Ee
@ 2014-08-07 11:19 ` Thierry Reding
  2 siblings, 0 replies; 6+ messages in thread
From: Thierry Reding @ 2014-08-07 11:19 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Mika Westerberg, Alan Cox, Chew Chiau Ee, linux-pwm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 602 bytes --]

On Fri, May 09, 2014 at 11:35:21AM +0300, Heikki Krogerus wrote:
> Unlike other Intel LPSS devices, the PWM does not have the
> clock dividers or the gate. All we get from the clock is the
> rate. Since PCI case uses the driver data to get the rate,
> we can drop the clk and use the same data also in case of
> ACPI. The frequency is the same.
> 
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/pwm/pwm-lpss.c | 32 ++++++++++----------------------
>  1 file changed, 10 insertions(+), 22 deletions(-)

Sorry for the long delay. Applied now.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-07 11:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-09  8:35 [PATCH] pwm: lpss: remove dependency on clk framework Heikki Krogerus
2014-05-12  7:09 ` Mika Westerberg
2014-05-14  7:00 ` Chew, Chiau Ee
2014-05-14  8:39   ` Heikki Krogerus
2014-05-14  8:54     ` Chew, Chiau Ee
2014-08-07 11:19 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).