linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] pwm: lpss: Split Tangier configuration
@ 2017-04-06 11:54 Andy Shevchenko
  2017-04-06 11:54 ` [PATCH v3 2/2] pwm: lpss: Set enable-bit before waiting for update-bit to go low Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-04-06 11:54 UTC (permalink / raw)
  To: Hans de Goede, Thierry Reding, linux-pwm, Ilkka Koskinen,
	Mika Westerberg
  Cc: Andy Shevchenko

As a preparation for special treatment for Broxton we split Tangier
configuration.

Fixes: b89b4b7a3d0a ("pwm: lpss: pci: Enable PWM module on Intel Edison")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pwm/pwm-lpss-pci.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c
index 053088b9b66e..073dfb2337e0 100644
--- a/drivers/pwm/pwm-lpss-pci.c
+++ b/drivers/pwm/pwm-lpss-pci.c
@@ -38,6 +38,13 @@ static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
 	.base_unit_bits = 22,
 };
 
+/* Tangier */
+static const struct pwm_lpss_boardinfo pwm_lpss_tng_info = {
+	.clk_rate = 19200000,
+	.npwm = 4,
+	.base_unit_bits = 22,
+};
+
 static int pwm_lpss_probe_pci(struct pci_dev *pdev,
 			      const struct pci_device_id *id)
 {
@@ -97,7 +104,7 @@ static const struct pci_device_id pwm_lpss_pci_ids[] = {
 	{ PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info},
 	{ PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info},
 	{ PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info},
-	{ PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_bxt_info},
+	{ PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_tng_info},
 	{ PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info},
 	{ PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info},
 	{ PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info},
-- 
2.11.0

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

* [PATCH v3 2/2] pwm: lpss: Set enable-bit before waiting for update-bit to go low
  2017-04-06 11:54 [PATCH v3 1/2] pwm: lpss: Split Tangier configuration Andy Shevchenko
@ 2017-04-06 11:54 ` Andy Shevchenko
  2017-04-06 12:14 ` [PATCH v3 1/2] pwm: lpss: Split Tangier configuration Hans de Goede
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-04-06 11:54 UTC (permalink / raw)
  To: Hans de Goede, Thierry Reding, linux-pwm, Ilkka Koskinen,
	Mika Westerberg
  Cc: Andy Shevchenko

From: Hans de Goede <hdegoede@redhat.com>

At least on cherrytrail, the update bit will never go low when the
enabled bit is not set.

This causes the backlight on my cube iwork8 air tablet to never turn on
again after being turned off because in the pwm_lpss_apply enable path
pwm_lpss_update will fail causing an error exit and the enable-bit to
never get set. Any following pwm_lpss_apply calls will fail the
pwm_lpss_is_updating check.

Since the docs say that the update bit should be set before the
enable-bit, split pwm_lpss_update into setting the update-bit and
pwm_lpss_wait_for_update, and move the pwm_lpss_wait_for_update call
in the enable path to after setting the enable-bit.

Fixes: 10d56a4 ("pwm: lpss: Avoid reconfiguring while UPDATE bit...")
Cc: Ilkka Koskinen <ilkka.koskinen@intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pwm/pwm-lpss-pci.c      |  1 +
 drivers/pwm/pwm-lpss-platform.c |  1 +
 drivers/pwm/pwm-lpss.c          | 19 +++++++++++++------
 drivers/pwm/pwm-lpss.h          |  1 +
 4 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c
index 073dfb2337e0..c1527cb645be 100644
--- a/drivers/pwm/pwm-lpss-pci.c
+++ b/drivers/pwm/pwm-lpss-pci.c
@@ -36,6 +36,7 @@ static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
 	.clk_rate = 19200000,
 	.npwm = 4,
 	.base_unit_bits = 22,
+	.bypass = true,
 };
 
 /* Tangier */
diff --git a/drivers/pwm/pwm-lpss-platform.c b/drivers/pwm/pwm-lpss-platform.c
index b22b6fdadb9a..5d6ed1507d29 100644
--- a/drivers/pwm/pwm-lpss-platform.c
+++ b/drivers/pwm/pwm-lpss-platform.c
@@ -37,6 +37,7 @@ static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
 	.clk_rate = 19200000,
 	.npwm = 4,
 	.base_unit_bits = 22,
+	.bypass = true,
 };
 
 static int pwm_lpss_probe_platform(struct platform_device *pdev)
diff --git a/drivers/pwm/pwm-lpss.c b/drivers/pwm/pwm-lpss.c
index 689d2c1cbead..8db0d40ccacd 100644
--- a/drivers/pwm/pwm-lpss.c
+++ b/drivers/pwm/pwm-lpss.c
@@ -57,7 +57,7 @@ static inline void pwm_lpss_write(const struct pwm_device *pwm, u32 value)
 	writel(value, lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM);
 }
 
-static int pwm_lpss_update(struct pwm_device *pwm)
+static int pwm_lpss_wait_for_update(struct pwm_device *pwm)
 {
 	struct pwm_lpss_chip *lpwm = to_lpwm(pwm->chip);
 	const void __iomem *addr = lpwm->regs + pwm->hwpwm * PWM_SIZE + PWM;
@@ -65,8 +65,6 @@ static int pwm_lpss_update(struct pwm_device *pwm)
 	u32 val;
 	int err;
 
-	pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE);
-
 	/*
 	 * PWM Configuration register has SW_UPDATE bit that is set when a new
 	 * configuration is written to the register. The bit is automatically
@@ -122,6 +120,12 @@ static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm,
 	pwm_lpss_write(pwm, ctrl);
 }
 
+static inline void pwm_lpss_cond_enable(struct pwm_device *pwm, bool cond)
+{
+	if (cond)
+		pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_ENABLE);
+}
+
 static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 			  struct pwm_state *state)
 {
@@ -137,18 +141,21 @@ static int pwm_lpss_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 				return ret;
 			}
 			pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period);
-			ret = pwm_lpss_update(pwm);
+			pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE);
+			pwm_lpss_cond_enable(pwm, lpwm->info->bypass == false);
+			ret = pwm_lpss_wait_for_update(pwm);
 			if (ret) {
 				pm_runtime_put(chip->dev);
 				return ret;
 			}
-			pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_ENABLE);
+			pwm_lpss_cond_enable(pwm, lpwm->info->bypass == true);
 		} else {
 			ret = pwm_lpss_is_updating(pwm);
 			if (ret)
 				return ret;
 			pwm_lpss_prepare(lpwm, pwm, state->duty_cycle, state->period);
-			return pwm_lpss_update(pwm);
+			pwm_lpss_write(pwm, pwm_lpss_read(pwm) | PWM_SW_UPDATE);
+			return pwm_lpss_wait_for_update(pwm);
 		}
 	} else if (pwm_is_enabled(pwm)) {
 		pwm_lpss_write(pwm, pwm_lpss_read(pwm) & ~PWM_ENABLE);
diff --git a/drivers/pwm/pwm-lpss.h b/drivers/pwm/pwm-lpss.h
index c94cd7c2695d..98306bb02cfe 100644
--- a/drivers/pwm/pwm-lpss.h
+++ b/drivers/pwm/pwm-lpss.h
@@ -22,6 +22,7 @@ struct pwm_lpss_boardinfo {
 	unsigned long clk_rate;
 	unsigned int npwm;
 	unsigned long base_unit_bits;
+	bool bypass;
 };
 
 struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
-- 
2.11.0

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

* Re: [PATCH v3 1/2] pwm: lpss: Split Tangier configuration
  2017-04-06 11:54 [PATCH v3 1/2] pwm: lpss: Split Tangier configuration Andy Shevchenko
  2017-04-06 11:54 ` [PATCH v3 2/2] pwm: lpss: Set enable-bit before waiting for update-bit to go low Andy Shevchenko
@ 2017-04-06 12:14 ` Hans de Goede
  2017-04-06 12:54 ` Thierry Reding
  2017-04-10 18:31 ` Ilkka Koskinen
  3 siblings, 0 replies; 5+ messages in thread
From: Hans de Goede @ 2017-04-06 12:14 UTC (permalink / raw)
  To: Andy Shevchenko, Thierry Reding, linux-pwm, Ilkka Koskinen,
	Mika Westerberg

Hi,

I can confirm that this series fixes the issues I was seeing on
Cherry Trail devices:

Tested-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


On 06-04-17 13:54, Andy Shevchenko wrote:
> As a preparation for special treatment for Broxton we split Tangier
> configuration.
>
> Fixes: b89b4b7a3d0a ("pwm: lpss: pci: Enable PWM module on Intel Edison")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pwm/pwm-lpss-pci.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pwm/pwm-lpss-pci.c b/drivers/pwm/pwm-lpss-pci.c
> index 053088b9b66e..073dfb2337e0 100644
> --- a/drivers/pwm/pwm-lpss-pci.c
> +++ b/drivers/pwm/pwm-lpss-pci.c
> @@ -38,6 +38,13 @@ static const struct pwm_lpss_boardinfo pwm_lpss_bxt_info = {
>  	.base_unit_bits = 22,
>  };
>
> +/* Tangier */
> +static const struct pwm_lpss_boardinfo pwm_lpss_tng_info = {
> +	.clk_rate = 19200000,
> +	.npwm = 4,
> +	.base_unit_bits = 22,
> +};
> +
>  static int pwm_lpss_probe_pci(struct pci_dev *pdev,
>  			      const struct pci_device_id *id)
>  {
> @@ -97,7 +104,7 @@ static const struct pci_device_id pwm_lpss_pci_ids[] = {
>  	{ PCI_VDEVICE(INTEL, 0x0ac8), (unsigned long)&pwm_lpss_bxt_info},
>  	{ PCI_VDEVICE(INTEL, 0x0f08), (unsigned long)&pwm_lpss_byt_info},
>  	{ PCI_VDEVICE(INTEL, 0x0f09), (unsigned long)&pwm_lpss_byt_info},
> -	{ PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_bxt_info},
> +	{ PCI_VDEVICE(INTEL, 0x11a5), (unsigned long)&pwm_lpss_tng_info},
>  	{ PCI_VDEVICE(INTEL, 0x1ac8), (unsigned long)&pwm_lpss_bxt_info},
>  	{ PCI_VDEVICE(INTEL, 0x2288), (unsigned long)&pwm_lpss_bsw_info},
>  	{ PCI_VDEVICE(INTEL, 0x2289), (unsigned long)&pwm_lpss_bsw_info},
>

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

* Re: [PATCH v3 1/2] pwm: lpss: Split Tangier configuration
  2017-04-06 11:54 [PATCH v3 1/2] pwm: lpss: Split Tangier configuration Andy Shevchenko
  2017-04-06 11:54 ` [PATCH v3 2/2] pwm: lpss: Set enable-bit before waiting for update-bit to go low Andy Shevchenko
  2017-04-06 12:14 ` [PATCH v3 1/2] pwm: lpss: Split Tangier configuration Hans de Goede
@ 2017-04-06 12:54 ` Thierry Reding
  2017-04-10 18:31 ` Ilkka Koskinen
  3 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2017-04-06 12:54 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Hans de Goede, linux-pwm, Ilkka Koskinen, Mika Westerberg

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

On Thu, Apr 06, 2017 at 02:54:00PM +0300, Andy Shevchenko wrote:
> As a preparation for special treatment for Broxton we split Tangier
> configuration.
> 
> Fixes: b89b4b7a3d0a ("pwm: lpss: pci: Enable PWM module on Intel Edison")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/pwm/pwm-lpss-pci.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Both patches applied to for-4.11/fixes, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v3 1/2] pwm: lpss: Split Tangier configuration
  2017-04-06 11:54 [PATCH v3 1/2] pwm: lpss: Split Tangier configuration Andy Shevchenko
                   ` (2 preceding siblings ...)
  2017-04-06 12:54 ` Thierry Reding
@ 2017-04-10 18:31 ` Ilkka Koskinen
  3 siblings, 0 replies; 5+ messages in thread
From: Ilkka Koskinen @ 2017-04-10 18:31 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Hans de Goede, Thierry Reding, linux-pwm, Mika Westerberg

On Thu, Apr 06, 2017 at 02:54:00PM +0300, Andy Shevchenko wrote:
> As a preparation for special treatment for Broxton we split Tangier
> configuration.
> 
> Fixes: b89b4b7a3d0a ("pwm: lpss: pci: Enable PWM module on Intel Edison")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks, Andy! Both patches look good to me.

Br, Ilkka

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

end of thread, other threads:[~2017-04-10 18:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-06 11:54 [PATCH v3 1/2] pwm: lpss: Split Tangier configuration Andy Shevchenko
2017-04-06 11:54 ` [PATCH v3 2/2] pwm: lpss: Set enable-bit before waiting for update-bit to go low Andy Shevchenko
2017-04-06 12:14 ` [PATCH v3 1/2] pwm: lpss: Split Tangier configuration Hans de Goede
2017-04-06 12:54 ` Thierry Reding
2017-04-10 18:31 ` Ilkka Koskinen

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).