All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/17] ARM: pxa: Use PWM lookup tables
@ 2015-10-05  8:49 Thierry Reding
  2015-10-05  8:49 ` [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table Thierry Reding
                   ` (17 more replies)
  0 siblings, 18 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Back when the PWM framework was introduced the concept of PWM lookup
tables was added to allow board code to register a table of PWM devices
and their association with consumers. The goal is to allow drivers to
use a unified method to request PWM devices. At the same time, since no
boards were exposing these tables, fallback code was kept in drivers to
allow old code to remain functional. Unfortunately I got the numbering
of PWM devices wrong, so all these boards should now be without working
backlight control, though only a few cases have been fixed since, so I
guess most of this hardware is largely unused.

This series aims at finally fixing this up. It converts all PXA boards
that hook up a pwm-backlight device to use the new PWM lookup tables.
All patches have been compile-tested, but I don't have access to any of
these boards, so I couldn't verify that they really work.

Thierry

Thierry Reding (17):
  ARM: pxa: cm-x300: Use PWM lookup table
  ARM: pxa: colibri-pxa270-income: Use PWM lookup table
  ARM: pxa: ezx: Use PWM lookup table
  ARM: pxa: hx4700: Remove unused field initializers
  ARM: pxa: lpd270: Use PWM lookup table
  ARM: pxa: magician: Use PWM lookup table
  ARM: pxa: mainstone: Use PWM lookup table
  ARM: pxa: mioa701: Use PWM lookup table
  ARM: pxa: palm27x: Use PWM lookup table
  ARM: pxa: palmtc: Use PWM lookup table
  ARM: pxa: palmte2: Use PWM lookup table
  ARM: pxa: pcm990: Use PWM lookup table
  ARM: pxa: raumfeld: Use PWM lookup table
  ARM: pxa: tavorevb: Use PWM lookup table
  ARM: pxa: viper: Use PWM lookup table
  ARM: pxa: z2: Use PWM lookup table
  ARM: pxa: zylonite: Use PWM lookup table

 arch/arm/mach-pxa/cm-x300.c               |  9 +++++++--
 arch/arm/mach-pxa/colibri-pxa270-income.c |  9 +++++++--
 arch/arm/mach-pxa/ezx.c                   |  9 +++++++--
 arch/arm/mach-pxa/hx4700.c                |  2 --
 arch/arm/mach-pxa/lpd270.c                |  9 +++++++--
 arch/arm/mach-pxa/magician.c              |  9 +++++++--
 arch/arm/mach-pxa/mainstone.c             | 18 ++++++++++++++----
 arch/arm/mach-pxa/mioa701.c               |  9 +++++++--
 arch/arm/mach-pxa/palm27x.c               |  9 +++++++--
 arch/arm/mach-pxa/palmtc.c                |  9 +++++++--
 arch/arm/mach-pxa/palmte2.c               |  9 +++++++--
 arch/arm/mach-pxa/pcm990-baseboard.c      |  9 +++++++--
 arch/arm/mach-pxa/raumfeld.c              | 11 ++++++++---
 arch/arm/mach-pxa/tavorevb.c              | 13 +++++++++----
 arch/arm/mach-pxa/viper.c                 |  9 +++++++--
 arch/arm/mach-pxa/z2.c                    | 13 +++++++++----
 arch/arm/mach-pxa/zylonite.c              |  9 +++++++--
 17 files changed, 124 insertions(+), 41 deletions(-)

-- 
2.5.0

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

* [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05 20:23   ` Robert Jarzmik
  2015-10-05  8:49 ` [PATCH 02/17] ARM: pxa: colibri-pxa270-income: " Thierry Reding
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/cm-x300.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/cm-x300.c b/arch/arm/mach-pxa/cm-x300.c
index 5851f4c254c1..a7dae60810e8 100644
--- a/arch/arm/mach-pxa/cm-x300.c
+++ b/arch/arm/mach-pxa/cm-x300.c
@@ -26,6 +26,7 @@
 #include <linux/dm9000.h>
 #include <linux/leds.h>
 #include <linux/rtc-v3020.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 
 #include <linux/i2c.h>
@@ -305,11 +306,14 @@ static inline void cm_x300_init_lcd(void) {}
 #endif
 
 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
+static struct pwm_lookup cm_x300_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.0", NULL, 10000,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data cm_x300_backlight_data = {
-	.pwm_id		= 2,
 	.max_brightness	= 100,
 	.dft_brightness	= 100,
-	.pwm_period_ns	= 10000,
 	.enable_gpio	= -1,
 };
 
@@ -323,6 +327,7 @@ static struct platform_device cm_x300_backlight_device = {
 
 static void cm_x300_init_bl(void)
 {
+	pwm_add_table(cm_x300_pwm_lookup, ARRAY_SIZE(cm_x300_pwm_lookup));
 	platform_device_register(&cm_x300_backlight_device);
 }
 #else
-- 
2.5.0

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

* [PATCH 02/17] ARM: pxa: colibri-pxa270-income: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
  2015-10-05  8:49 ` [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 03/17] ARM: pxa: ezx: " Thierry Reding
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/colibri-pxa270-income.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/colibri-pxa270-income.c b/arch/arm/mach-pxa/colibri-pxa270-income.c
index 3aa264640c9d..db20d25daaab 100644
--- a/arch/arm/mach-pxa/colibri-pxa270-income.c
+++ b/arch/arm/mach-pxa/colibri-pxa270-income.c
@@ -20,6 +20,7 @@
 #include <linux/ioport.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/i2c/pxa-i2c.h>
 
@@ -184,11 +185,14 @@ static inline void income_lcd_init(void) {}
  * Backlight
  ******************************************************************************/
 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
+static struct pwm_lookup income_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 1000000,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data income_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 0x3ff,
 	.dft_brightness	= 0x1ff,
-	.pwm_period_ns	= 1000000,
 	.enable_gpio	= -1,
 };
 
@@ -202,6 +206,7 @@ static struct platform_device income_backlight = {
 
 static void __init income_pwm_init(void)
 {
+	pwm_add_table(income_pwm_lookup, ARRAY_SIZE(income_pwm_lookup));
 	platform_device_register(&income_backlight);
 }
 #else
-- 
2.5.0

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

* [PATCH 03/17] ARM: pxa: ezx: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
  2015-10-05  8:49 ` [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table Thierry Reding
  2015-10-05  8:49 ` [PATCH 02/17] ARM: pxa: colibri-pxa270-income: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 04/17] ARM: pxa: hx4700: Remove unused field initializers Thierry Reding
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/ezx.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/ezx.c b/arch/arm/mach-pxa/ezx.c
index ab93441e596e..9a9c15bfcd34 100644
--- a/arch/arm/mach-pxa/ezx.c
+++ b/arch/arm/mach-pxa/ezx.c
@@ -15,6 +15,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/input.h>
 #include <linux/gpio.h>
@@ -49,11 +50,14 @@
 #define GPIO19_GEN1_CAM_RST		19
 #define GPIO28_GEN2_CAM_RST		28
 
+static struct pwm_lookup ezx_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78700,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data ezx_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 1023,
 	.dft_brightness	= 1023,
-	.pwm_period_ns	= 78770,
 	.enable_gpio	= -1,
 };
 
@@ -817,6 +821,7 @@ static void __init a780_init(void)
 		platform_device_register(&a780_camera);
 	}
 
+	pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
 	platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
 	platform_add_devices(ARRAY_AND_SIZE(a780_devices));
 }
-- 
2.5.0

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

* [PATCH 04/17] ARM: pxa: hx4700: Remove unused field initializers
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (2 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 03/17] ARM: pxa: ezx: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-06  6:53   ` Philipp Zabel
  2015-10-05  8:49 ` [PATCH 05/17] ARM: pxa: lpd270: Use PWM lookup table Thierry Reding
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

The ID and period for the backlight PWM are obtained from a PWM lookup
table, so the corresponding values don't need to be duplicated into the
platform data.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/hx4700.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index 5fb41ad6e3bc..c10898c283e6 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -557,10 +557,8 @@ static struct platform_device hx4700_lcd = {
  */
 
 static struct platform_pwm_backlight_data backlight_data = {
-	.pwm_id         = -1,	/* Superseded by pwm_lookup */
 	.max_brightness = 200,
 	.dft_brightness = 100,
-	.pwm_period_ns  = 30923,
 	.enable_gpio    = -1,
 };
 
-- 
2.5.0

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

* [PATCH 05/17] ARM: pxa: lpd270: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (3 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 04/17] ARM: pxa: hx4700: Remove unused field initializers Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 06/17] ARM: pxa: magician: " Thierry Reding
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/lpd270.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/lpd270.c b/arch/arm/mach-pxa/lpd270.c
index b070167deef2..ab4e84f4ee0c 100644
--- a/arch/arm/mach-pxa/lpd270.c
+++ b/arch/arm/mach-pxa/lpd270.c
@@ -23,6 +23,7 @@
 #include <linux/ioport.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/smc91x.h>
 
@@ -271,11 +272,14 @@ static struct platform_device lpd270_flash_device[2] = {
 	},
 };
 
+static struct pwm_lookup lpd270_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78770,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data lpd270_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 1,
 	.dft_brightness	= 1,
-	.pwm_period_ns	= 78770,
 	.enable_gpio	= -1,
 };
 
@@ -474,6 +478,7 @@ static void __init lpd270_init(void)
 	 */
 	ARB_CNTRL = ARB_CORE_PARK | 0x234;
 
+	pwm_add_table(lpd270_pwm_lookup, ARRAY_SIZE(lpd270_pwm_lookup));
 	platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
 
 	pxa_set_ac97_info(NULL);
-- 
2.5.0

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

* [PATCH 06/17] ARM: pxa: magician: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (4 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 05/17] ARM: pxa: lpd270: Use PWM lookup table Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-06  6:52   ` Philipp Zabel
  2015-10-05  8:49 ` [PATCH 07/17] ARM: pxa: mainstone: " Thierry Reding
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/magician.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index a9761c293028..240e4c34b226 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -24,6 +24,7 @@
 #include <linux/mfd/htc-pasic3.h>
 #include <linux/mtd/physmap.h>
 #include <linux/pda_power.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/regulator/driver.h>
 #include <linux/regulator/gpio-regulator.h>
@@ -346,6 +347,11 @@ static struct pxafb_mach_info samsung_info = {
  * Backlight
  */
 
+static struct pwm_lookup magician_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 30923,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct gpio magician_bl_gpios[] = {
 	{ EGPIO_MAGICIAN_BL_POWER,  GPIOF_DIR_OUT, "Backlight power" },
 	{ EGPIO_MAGICIAN_BL_POWER2, GPIOF_DIR_OUT, "Backlight power 2" },
@@ -374,10 +380,8 @@ static void magician_backlight_exit(struct device *dev)
 }
 
 static struct platform_pwm_backlight_data backlight_data = {
-	.pwm_id         = 0,
 	.max_brightness = 272,
 	.dft_brightness = 100,
-	.pwm_period_ns  = 30923,
 	.enable_gpio    = -1,
 	.init           = magician_backlight_init,
 	.notify         = magician_backlight_notify,
@@ -743,6 +747,7 @@ static void __init magician_init(void)
 	pxa_set_btuart_info(NULL);
 	pxa_set_stuart_info(NULL);
 
+	pwm_add_table(magician_pwm_lookup, ARRAY_SIZE(magician_pwm_lookup));
 	platform_add_devices(ARRAY_AND_SIZE(devices));
 
 	pxa_set_ficp_info(&magician_ficp_info);
-- 
2.5.0

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

* [PATCH 07/17] ARM: pxa: mainstone: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (5 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 06/17] ARM: pxa: magician: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 08/17] ARM: pxa: mioa701: " Thierry Reding
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/mainstone.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c
index 2c0658cf6be2..4ee9f59d45f5 100644
--- a/arch/arm/mach-pxa/mainstone.c
+++ b/arch/arm/mach-pxa/mainstone.c
@@ -26,6 +26,7 @@
 #include <linux/mtd/partitions.h>
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/smc91x.h>
 #include <linux/i2c/pxa-i2c.h>
@@ -248,11 +249,14 @@ static struct platform_device mst_flash_device[2] = {
 };
 
 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
+static struct pwm_lookup mainstone_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78770,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data mainstone_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 1023,
 	.dft_brightness	= 1023,
-	.pwm_period_ns	= 78770,
 	.enable_gpio	= -1,
 };
 
@@ -266,9 +270,15 @@ static struct platform_device mainstone_backlight_device = {
 
 static void __init mainstone_backlight_register(void)
 {
-	int ret = platform_device_register(&mainstone_backlight_device);
-	if (ret)
+	int ret;
+
+	pwm_add_table(mainstone_pwm_lookup, ARRAY_SIZE(mainstone_pwm_lookup));
+
+	ret = platform_device_register(&mainstone_backlight_device);
+	if (ret) {
 		printk(KERN_ERR "mainstone: failed to register backlight device: %d\n", ret);
+		pwm_remove_table(mainstone_pwm_lookup, ARRAY_SIZE(mainstone_pwm_lookup));
+	}
 }
 #else
 #define mainstone_backlight_register()	do { } while (0)
-- 
2.5.0

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

* [PATCH 08/17] ARM: pxa: mioa701: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (6 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 07/17] ARM: pxa: mainstone: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 09/17] ARM: pxa: palm27x: " Thierry Reding
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/mioa701.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c
index 29997bde277d..039f2601487b 100644
--- a/arch/arm/mach-pxa/mioa701.c
+++ b/arch/arm/mach-pxa/mioa701.c
@@ -26,6 +26,7 @@
 #include <linux/input.h>
 #include <linux/delay.h>
 #include <linux/gpio_keys.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/rtc.h>
 #include <linux/leds.h>
@@ -181,12 +182,15 @@ static unsigned long mioa701_pin_config[] = {
 	MFP_CFG_OUT(GPIO116, AF0, DRIVE_HIGH),
 };
 
+static struct pwm_lookup mioa701_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 4000 * 1024,
+		   PWM_POLARITY_NORMAL),
+};
+
 /* LCD Screen and Backlight */
 static struct platform_pwm_backlight_data mioa701_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 100,
 	.dft_brightness	= 50,
-	.pwm_period_ns	= 4000 * 1024,	/* Fl = 250kHz */
 	.enable_gpio	= -1,
 };
 
@@ -751,6 +755,7 @@ static void __init mioa701_machine_init(void)
 	pxa_set_udc_info(&mioa701_udc_info);
 	pxa_set_ac97_info(&mioa701_ac97_info);
 	pm_power_off = mioa701_poweroff;
+	pwm_add_table(mioa701_pwm_lookup, ARRAY_SIZE(mioa701_pwm_lookup));
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 	gsm_init();
 
-- 
2.5.0

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

* [PATCH 09/17] ARM: pxa: palm27x: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (7 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 08/17] ARM: pxa: mioa701: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 10/17] ARM: pxa: palmtc: " Thierry Reding
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/palm27x.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/palm27x.c b/arch/arm/mach-pxa/palm27x.c
index e54a296fb81f..13eba2b26e0a 100644
--- a/arch/arm/mach-pxa/palm27x.c
+++ b/arch/arm/mach-pxa/palm27x.c
@@ -15,6 +15,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
 #include <linux/pda_power.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
 #include <linux/wm97xx.h>
@@ -270,6 +271,11 @@ void __init palm27x_ac97_init(int minv, int maxv, int jack, int reset)
  * Backlight
  ******************************************************************************/
 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
+static struct pwm_lookup palm27x_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 3500 * 1024,
+		   PWM_POLARITY_NORMAL),
+};
+
 static int palm_bl_power;
 static int palm_lcd_power;
 
@@ -318,10 +324,8 @@ static void palm27x_backlight_exit(struct device *dev)
 }
 
 static struct platform_pwm_backlight_data palm27x_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 0xfe,
 	.dft_brightness	= 0x7e,
-	.pwm_period_ns	= 3500 * 1024,
 	.enable_gpio	= -1,
 	.init		= palm27x_backlight_init,
 	.notify		= palm27x_backlight_notify,
@@ -340,6 +344,7 @@ void __init palm27x_pwm_init(int bl, int lcd)
 {
 	palm_bl_power	= bl;
 	palm_lcd_power	= lcd;
+	pwm_add_lookup(palm27x_pwm_lookup, ARRAY_SIZE(palm27x_pwm_lookup));
 	platform_device_register(&palm27x_backlight);
 }
 #endif
-- 
2.5.0

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

* [PATCH 10/17] ARM: pxa: palmtc: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (8 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 09/17] ARM: pxa: palm27x: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 11/17] ARM: pxa: palmte2: " Thierry Reding
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/palmtc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/palmtc.c b/arch/arm/mach-pxa/palmtc.c
index 7691c974ca4b..aebf6de62468 100644
--- a/arch/arm/mach-pxa/palmtc.c
+++ b/arch/arm/mach-pxa/palmtc.c
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/irq.h>
 #include <linux/input.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
 #include <linux/input/matrix_keypad.h>
@@ -166,11 +167,14 @@ static inline void palmtc_keys_init(void) {}
  * Backlight
  ******************************************************************************/
 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
+static struct pwm_lookup palmtc_pwm_lookup[] = {
+	PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL, PALMTC_PERIOD_NS,
+		   PWM_PERIOD_NORMAL),
+};
+
 static struct platform_pwm_backlight_data palmtc_backlight_data = {
-	.pwm_id		= 1,
 	.max_brightness	= PALMTC_MAX_INTENSITY,
 	.dft_brightness	= PALMTC_MAX_INTENSITY,
-	.pwm_period_ns	= PALMTC_PERIOD_NS,
 	.enable_gpio	= GPIO_NR_PALMTC_BL_POWER,
 };
 
@@ -184,6 +188,7 @@ static struct platform_device palmtc_backlight = {
 
 static void __init palmtc_pwm_init(void)
 {
+	pwm_add_table(palmtc_pwm_lookup, ARRAY_SIZE(palmtc_pwm_lookup));
 	platform_device_register(&palmtc_backlight);
 }
 #else
-- 
2.5.0

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

* [PATCH 11/17] ARM: pxa: palmte2: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (9 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 10/17] ARM: pxa: palmtc: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 12/17] ARM: pxa: pcm990: " Thierry Reding
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/palmte2.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/palmte2.c b/arch/arm/mach-pxa/palmte2.c
index 956fd24ee6fd..e64bb4326e69 100644
--- a/arch/arm/mach-pxa/palmte2.c
+++ b/arch/arm/mach-pxa/palmte2.c
@@ -21,6 +21,7 @@
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
 #include <linux/pda_power.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
 #include <linux/wm97xx.h>
@@ -138,6 +139,11 @@ static struct platform_device palmte2_pxa_keys = {
 /******************************************************************************
  * Backlight
  ******************************************************************************/
+static struct pwm_lookup palmte2_pwm_lookup[] = {
+	PWM_LOOKUP("pxa25x-pwm.0", 0, "pwm-backlight.0", NULL,
+		   PALMTE2_PERIOD_NS, PWM_POLARITY_NORMAL),
+};
+
 static struct gpio palmte_bl_gpios[] = {
 	{ GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
 	{ GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
@@ -161,10 +167,8 @@ static void palmte2_backlight_exit(struct device *dev)
 }
 
 static struct platform_pwm_backlight_data palmte2_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= PALMTE2_MAX_INTENSITY,
 	.dft_brightness	= PALMTE2_MAX_INTENSITY,
-	.pwm_period_ns	= PALMTE2_PERIOD_NS,
 	.enable_gpio	= -1,
 	.init		= palmte2_backlight_init,
 	.notify		= palmte2_backlight_notify,
@@ -355,6 +359,7 @@ static void __init palmte2_init(void)
 	pxa_set_ac97_info(&palmte2_ac97_pdata);
 	pxa_set_ficp_info(&palmte2_ficp_platform_data);
 
+	pwm_add_table(palmte2_pwm_lookup, ARRAY_SIZE(palmte2_pwm_lookup));
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 }
 
-- 
2.5.0

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

* [PATCH 12/17] ARM: pxa: pcm990: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (10 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 11/17] ARM: pxa: palmte2: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 13/17] ARM: pxa: raumfeld: " Thierry Reding
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/pcm990-baseboard.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/pcm990-baseboard.c b/arch/arm/mach-pxa/pcm990-baseboard.c
index 9a0c8affdadb..1453fd95ced5 100644
--- a/arch/arm/mach-pxa/pcm990-baseboard.c
+++ b/arch/arm/mach-pxa/pcm990-baseboard.c
@@ -24,6 +24,7 @@
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pxa-i2c.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 
 #include <media/mt9v022.h>
@@ -148,11 +149,14 @@ static struct pxafb_mach_info pcm990_fbinfo __initdata = {
 };
 #endif
 
+static struct pwm_lookup pcm990_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.0", NULL, 78770,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data pcm990_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 1023,
 	.dft_brightness	= 1023,
-	.pwm_period_ns	= 78770,
 	.enable_gpio	= -1,
 };
 
@@ -542,6 +546,7 @@ void __init pcm990_baseboard_init(void)
 #ifndef CONFIG_PCM990_DISPLAY_NONE
 	pxa_set_fb_info(NULL, &pcm990_fbinfo);
 #endif
+	pwm_add_table(pcm990_pwm_lookup, ARRAY_SIZE(pcm990_pwm_lookup));
 	platform_device_register(&pcm990_backlight_device);
 
 	/* MMC */
-- 
2.5.0

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

* [PATCH 13/17] ARM: pxa: raumfeld: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (11 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 12/17] ARM: pxa: pcm990: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 14/17] ARM: pxa: tavorevb: " Thierry Reding
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/raumfeld.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
index 88f70c37ad0d..adb96d8d5b7a 100644
--- a/arch/arm/mach-pxa/raumfeld.c
+++ b/arch/arm/mach-pxa/raumfeld.c
@@ -29,6 +29,7 @@
 #include <linux/leds.h>
 #include <linux/w1-gpio.h>
 #include <linux/sched.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pxa-i2c.h>
@@ -531,13 +532,15 @@ static void __init raumfeld_w1_init(void)
  * Framebuffer device
  */
 
+static struct pwm_lookup raumfeld_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight", NULL, 10000,
+		   PWM_POLARITY_NORMAL),
+};
+
 /* PWM controlled backlight */
 static struct platform_pwm_backlight_data raumfeld_pwm_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 100,
 	.dft_brightness	= 100,
-	/* 10000 ns = 10 ms ^= 100 kHz */
-	.pwm_period_ns	= 10000,
 	.enable_gpio	= -1,
 };
 
@@ -618,6 +621,8 @@ static void __init raumfeld_lcd_init(void)
 	} else {
 		mfp_cfg_t raumfeld_pwm_pin_config = GPIO17_PWM0_OUT;
 		pxa3xx_mfp_config(&raumfeld_pwm_pin_config, 1);
+		pwm_add_table(raumfeld_pwm_lookup,
+			      ARRAY_SIZE(raumfeld_pwm_lookup));
 		platform_device_register(&raumfeld_pwm_backlight_device);
 	}
 
-- 
2.5.0

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

* [PATCH 14/17] ARM: pxa: tavorevb: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (12 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 13/17] ARM: pxa: raumfeld: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 15/17] ARM: pxa: viper: " Thierry Reding
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/tavorevb.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-pxa/tavorevb.c b/arch/arm/mach-pxa/tavorevb.c
index a71da84e784b..349a13a76215 100644
--- a/arch/arm/mach-pxa/tavorevb.c
+++ b/arch/arm/mach-pxa/tavorevb.c
@@ -18,6 +18,7 @@
 #include <linux/clk.h>
 #include <linux/gpio.h>
 #include <linux/smc91x.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 
 #include <asm/mach-types.h>
@@ -168,21 +169,24 @@ static inline void tavorevb_init_keypad(void) {}
 #endif /* CONFIG_KEYBOARD_PXA27x || CONFIG_KEYBOARD_PXA27x_MODULE */
 
 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
+static struct pwm_lookup tavorevb_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.0", NULL, 100000,
+		   PWM_POLARITY_NORMAL),
+	PWM_LOOKUP("pxa27x-pwm.0", 0, "pwm-backlight.1", NULL, 100000,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data tavorevb_backlight_data[] = {
 	[0] = {
 		/* primary backlight */
-		.pwm_id		= 2,
 		.max_brightness	= 100,
 		.dft_brightness	= 100,
-		.pwm_period_ns	= 100000,
 		.enable_gpio	= -1,
 	},
 	[1] = {
 		/* secondary backlight */
-		.pwm_id		= 0,
 		.max_brightness	= 100,
 		.dft_brightness	= 100,
-		.pwm_period_ns	= 100000,
 		.enable_gpio	= -1,
 	},
 };
@@ -470,6 +474,7 @@ static struct pxafb_mach_info tavorevb_lcd_info = {
 
 static void __init tavorevb_init_lcd(void)
 {
+	pwm_add_table(tavorevb_pwm_lookup, ARRAY_SIZE(tavorevb_pwm_lookup));
 	platform_device_register(&tavorevb_backlight_devices[0]);
 	platform_device_register(&tavorevb_backlight_devices[1]);
 	pxa_set_fb_info(NULL, &tavorevb_lcd_info);
-- 
2.5.0

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

* [PATCH 15/17] ARM: pxa: viper: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (13 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 14/17] ARM: pxa: tavorevb: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 16/17] ARM: pxa: z2: " Thierry Reding
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/viper.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/viper.c b/arch/arm/mach-pxa/viper.c
index 4841d6cefe76..b09e8cadd41f 100644
--- a/arch/arm/mach-pxa/viper.c
+++ b/arch/arm/mach-pxa/viper.c
@@ -39,6 +39,7 @@
 #include <linux/i2c/pxa-i2c.h>
 #include <linux/serial_8250.h>
 #include <linux/smc91x.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/usb/isp116x.h>
 #include <linux/mtd/mtd.h>
@@ -350,6 +351,11 @@ static struct pxafb_mach_info fb_info = {
 	.lcd_conn		= LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
 };
 
+static struct pwm_lookup viper_pwm_lookup[] = {
+	PWM_LOOKUP("pxa25x-pwm.0", 0, "pwm-backlight.0", NULL, 1000000,
+		   PWM_POLARITY_NORMAL),
+};
+
 static int viper_backlight_init(struct device *dev)
 {
 	int ret;
@@ -398,10 +404,8 @@ static void viper_backlight_exit(struct device *dev)
 }
 
 static struct platform_pwm_backlight_data viper_backlight_data = {
-	.pwm_id		= 0,
 	.max_brightness	= 100,
 	.dft_brightness	= 100,
-	.pwm_period_ns	= 1000000,
 	.enable_gpio	= -1,
 	.init		= viper_backlight_init,
 	.notify		= viper_backlight_notify,
@@ -939,6 +943,7 @@ static void __init viper_init(void)
 		smc91x_device.num_resources--;
 
 	pxa_set_i2c_info(NULL);
+	pwm_add_table(viper_pwm_lookup, ARRAY_SIZE(viper_pwm_lookup));
 	platform_add_devices(viper_devs, ARRAY_SIZE(viper_devs));
 
 	viper_init_vcore_gpios();
-- 
2.5.0

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

* [PATCH 16/17] ARM: pxa: z2: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (14 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 15/17] ARM: pxa: viper: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05  8:49 ` [PATCH 17/17] ARM: pxa: zylonite: " Thierry Reding
  2015-10-05 18:48 ` [PATCH 00/17] ARM: pxa: Use PWM lookup tables Robert Jarzmik
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/z2.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-pxa/z2.c b/arch/arm/mach-pxa/z2.c
index 36caac726ea7..9c9c2ebdb422 100644
--- a/arch/arm/mach-pxa/z2.c
+++ b/arch/arm/mach-pxa/z2.c
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/z2_battery.h>
 #include <linux/dma-mapping.h>
@@ -199,21 +200,24 @@ static inline void z2_nor_init(void) {}
  * Backlight
  ******************************************************************************/
 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
+static struct pwm_lookup z2_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight.0", NULL, 1260320,
+		   PWM_POLARITY_NORMAL),
+	PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.1", NULL, 1260320,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data z2_backlight_data[] = {
 	[0] = {
 		/* Keypad Backlight */
-		.pwm_id		= 1,
 		.max_brightness	= 1023,
 		.dft_brightness	= 0,
-		.pwm_period_ns	= 1260320,
 		.enable_gpio	= -1,
 	},
 	[1] = {
 		/* LCD Backlight */
-		.pwm_id		= 2,
 		.max_brightness	= 1023,
 		.dft_brightness	= 512,
-		.pwm_period_ns	= 1260320,
 		.enable_gpio	= -1,
 	},
 };
@@ -236,6 +240,7 @@ static struct platform_device z2_backlight_devices[2] = {
 };
 static void __init z2_pwm_init(void)
 {
+	pwm_add_table(z2_pwm_lookup, ARRAY_SIZE(z2_pwm_lookup));
 	platform_device_register(&z2_backlight_devices[0]);
 	platform_device_register(&z2_backlight_devices[1]);
 }
-- 
2.5.0

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

* [PATCH 17/17] ARM: pxa: zylonite: Use PWM lookup table
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (15 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 16/17] ARM: pxa: z2: " Thierry Reding
@ 2015-10-05  8:49 ` Thierry Reding
  2015-10-05 18:48 ` [PATCH 00/17] ARM: pxa: Use PWM lookup tables Robert Jarzmik
  17 siblings, 0 replies; 24+ messages in thread
From: Thierry Reding @ 2015-10-05  8:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use a PWM lookup table to provide the PWM to the pwm-backlight device.
The driver has a legacy code path that is required only because boards
still use the legacy method of requesting PWMs by global ID. Replacing
these usages allows that legacy fallback to be removed.

Cc: Daniel Mack <daniel@zonque.org>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
 arch/arm/mach-pxa/zylonite.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-pxa/zylonite.c b/arch/arm/mach-pxa/zylonite.c
index 77daea478e88..e20359a7433c 100644
--- a/arch/arm/mach-pxa/zylonite.c
+++ b/arch/arm/mach-pxa/zylonite.c
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/pwm.h>
 #include <linux/pwm_backlight.h>
 #include <linux/smc91x.h>
 
@@ -120,11 +121,14 @@ static inline void zylonite_init_leds(void) {}
 #endif
 
 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
+static struct pwm_lookup zylonite_pwm_lookup[] = {
+	PWM_LOOKUP("pxa27x-pwm.1", 1, "pwm-backlight.0", NULL, 10000,
+		   PWM_POLARITY_NORMAL),
+};
+
 static struct platform_pwm_backlight_data zylonite_backlight_data = {
-	.pwm_id		= 3,
 	.max_brightness	= 100,
 	.dft_brightness	= 100,
-	.pwm_period_ns	= 10000,
 	.enable_gpio	= -1,
 };
 
@@ -206,6 +210,7 @@ static struct pxafb_mach_info zylonite_sharp_lcd_info = {
 
 static void __init zylonite_init_lcd(void)
 {
+	pwm_add_table(zylonite_pwm_lookup, ARRAY_SIZE(zylonite_pwm_lookup));
 	platform_device_register(&zylonite_backlight_device);
 
 	if (lcd_id & 0x20) {
-- 
2.5.0

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

* [PATCH 00/17] ARM: pxa: Use PWM lookup tables
  2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
                   ` (16 preceding siblings ...)
  2015-10-05  8:49 ` [PATCH 17/17] ARM: pxa: zylonite: " Thierry Reding
@ 2015-10-05 18:48 ` Robert Jarzmik
  17 siblings, 0 replies; 24+ messages in thread
From: Robert Jarzmik @ 2015-10-05 18:48 UTC (permalink / raw)
  To: linux-arm-kernel

Thierry Reding <thierry.reding@gmail.com> writes:

> Back when the PWM framework was introduced the concept of PWM lookup
> tables was added to allow board code to register a table of PWM devices
> and their association with consumers. The goal is to allow drivers to
> use a unified method to request PWM devices. At the same time, since no
> boards were exposing these tables, fallback code was kept in drivers to
> allow old code to remain functional. Unfortunately I got the numbering
> of PWM devices wrong, so all these boards should now be without working
> backlight control, though only a few cases have been fixed since, so I
> guess most of this hardware is largely unused.
>
> This series aims at finally fixing this up. It converts all PXA boards
> that hook up a pwm-backlight device to use the new PWM lookup tables.
> All patches have been compile-tested, but I don't have access to any of
> these boards, so I couldn't verify that they really work.

Hi Thierry,

Thanks for this serie. I'll test it in the next days. It looks good to me, at
least the 5 patches I had a look into, so if it works on the 5 boards I have,
I'll queue it up in pxa/for-next.

Cheers.

-- 
Robert

PS: removed all the addresses at openezx.org, don't see to work, or at least
make my MTA very angry.

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

* [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table
  2015-10-05  8:49 ` [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table Thierry Reding
@ 2015-10-05 20:23   ` Robert Jarzmik
  2015-10-06  7:53     ` Thierry Reding
  0 siblings, 1 reply; 24+ messages in thread
From: Robert Jarzmik @ 2015-10-05 20:23 UTC (permalink / raw)
  To: linux-arm-kernel

Thierry Reding <thierry.reding@gmail.com> writes:

> @@ -305,11 +306,14 @@ static inline void cm_x300_init_lcd(void) {}
>  #endif
>  
>  #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
> +static struct pwm_lookup cm_x300_pwm_lookup[] = {
> +	PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.0", NULL, 10000,
> +		   PWM_POLARITY_NORMAL),
> +};
That looks weird. It was pwm_id = 2, and I can't find the "2" in the statement
above. I would gladly fix it myself, but I wonder where that "2" should go ...

> +
>  static struct platform_pwm_backlight_data cm_x300_backlight_data = {
> -	.pwm_id		= 2,
>  	.max_brightness	= 100,
>  	.dft_brightness	= 100,
> -	.pwm_period_ns	= 10000,
>  	.enable_gpio	= -1,
>  };

Cheers.

-- 
Robert

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

* [PATCH 06/17] ARM: pxa: magician: Use PWM lookup table
  2015-10-05  8:49 ` [PATCH 06/17] ARM: pxa: magician: " Thierry Reding
@ 2015-10-06  6:52   ` Philipp Zabel
  0 siblings, 0 replies; 24+ messages in thread
From: Philipp Zabel @ 2015-10-06  6:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 5, 2015 at 10:49 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> Use a PWM lookup table to provide the PWM to the pwm-backlight device.
> The driver has a legacy code path that is required only because boards
> still use the legacy method of requesting PWMs by global ID. Replacing
> these usages allows that legacy fallback to be removed.
>
> Cc: Daniel Mack <daniel@zonque.org>
> Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
> Cc: Robert Jarzmik <robert.jarzmik@free.fr>
> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>

Acked-by: Philipp Zabel <philipp.zabel@gmail.com>

regards
Philipp

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

* [PATCH 04/17] ARM: pxa: hx4700: Remove unused field initializers
  2015-10-05  8:49 ` [PATCH 04/17] ARM: pxa: hx4700: Remove unused field initializers Thierry Reding
@ 2015-10-06  6:53   ` Philipp Zabel
  0 siblings, 0 replies; 24+ messages in thread
From: Philipp Zabel @ 2015-10-06  6:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 5, 2015 at 10:49 AM, Thierry Reding
<thierry.reding@gmail.com> wrote:
> The ID and period for the backlight PWM are obtained from a PWM lookup
> table, so the corresponding values don't need to be duplicated into the
> platform data.
>
> Cc: Daniel Mack <daniel@zonque.org>
> Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
> Cc: Robert Jarzmik <robert.jarzmik@free.fr>
> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>

Acked-by: Philipp Zabel <philipp.zabel@gmail.com>

regards
Philipp

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

* [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table
  2015-10-05 20:23   ` Robert Jarzmik
@ 2015-10-06  7:53     ` Thierry Reding
  2015-10-06 18:49       ` Robert Jarzmik
  0 siblings, 1 reply; 24+ messages in thread
From: Thierry Reding @ 2015-10-06  7:53 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 05, 2015 at 10:23:29PM +0200, Robert Jarzmik wrote:
> Thierry Reding <thierry.reding@gmail.com> writes:
> 
> > @@ -305,11 +306,14 @@ static inline void cm_x300_init_lcd(void) {}
> >  #endif
> >  
> >  #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
> > +static struct pwm_lookup cm_x300_pwm_lookup[] = {
> > +	PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.0", NULL, 10000,
> > +		   PWM_POLARITY_NORMAL),
> > +};
> That looks weird. It was pwm_id = 2, and I can't find the "2" in the statement
> above. I would gladly fix it myself, but I wonder where that "2" should go ...

pwm_id = 2 should be equivalent to the 1 in the second argument of the
PWM_LOOKUP macro (i.e. the PWM index). The rationale for that change is
given in an old commit by Paul Parsons:

	commit 8d6b00f5d639cfc28487ef412589e35b4e6ac7c7
	Author: Paul Parsons <lost.distance@yahoo.com>
	Date:   Fri Oct 19 13:15:30 2012 +0100
	
	    ARM: pxa: hx4700: Fix backlight PWM device number
	
	    Recent changes to PXA PWM support changed the PXA27X PWM device
	    numbering scheme.
	
	    The linux-3.5 PXA PWM driver followed the hardware numbering scheme for
	    the 4 PWMs, while the linux-3.6-rc1 PXA PWM driver has adopted a linear
	    numbering scheme:
	
	    Address             Hardware        3.5 pwm_id      3.6-rc1 pwm_id
	    0x40b00000  PWM0            0               0
	    0x40b00010  PWM2            2               1
	    0x40c00000  PWM1            1               2
	    0x40c00010  PWM3            3               3
	
	    The hx4700 backlight uses PWM1 at 0x40c00000. Consequently the pwm_id
	    must be changed from 1 to 2.
	
	    This patch fixes the backlight PWM device number and at the same time
	    moves from the legacy PWM API (pwm_id) to the new PWM API (pwm_lookup).
	
	    Signed-off-by: Paul Parsons <lost.distance@yahoo.com>
	    Cc: Thierry Reding <thierry.reding@avionic-design.de>
	    Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>

With the lookup tables the situation is somewhat more complicated
because the indices are relative to the provider. The above would
therefore map to something like this:

	Address     Hardware  Device            Index
	0x40b00000  PWM0      pxa2{5,7}x-pwm.0  0
	0x40b00010  PWM2      pxa27x-pwm.0      1
	0x40c00000  PWM1      pxa2{5,7}x-pwm.1  0
	0x40c00010  PWM3      pxa27x-pwm.1      1

Does that clarify the situation?

Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151006/dfb67962/attachment.sig>

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

* [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table
  2015-10-06  7:53     ` Thierry Reding
@ 2015-10-06 18:49       ` Robert Jarzmik
  0 siblings, 0 replies; 24+ messages in thread
From: Robert Jarzmik @ 2015-10-06 18:49 UTC (permalink / raw)
  To: linux-arm-kernel

Thierry Reding <thierry.reding@gmail.com> writes:

> On Mon, Oct 05, 2015 at 10:23:29PM +0200, Robert Jarzmik wrote:
>> Thierry Reding <thierry.reding@gmail.com> writes:
>> 
>> > @@ -305,11 +306,14 @@ static inline void cm_x300_init_lcd(void) {}
>> >  #endif
>> >  
>> >  #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
>> > +static struct pwm_lookup cm_x300_pwm_lookup[] = {
>> > +	PWM_LOOKUP("pxa27x-pwm.0", 1, "pwm-backlight.0", NULL, 10000,
>> > +		   PWM_POLARITY_NORMAL),
>> > +};
>> That looks weird. It was pwm_id = 2, and I can't find the "2" in the statement
>> above. I would gladly fix it myself, but I wonder where that "2" should go ...
>
> pwm_id = 2 should be equivalent to the 1 in the second argument of the
> PWM_LOOKUP macro (i.e. the PWM index). The rationale for that change is
> given in an old commit by Paul Parsons:
> With the lookup tables the situation is somewhat more complicated
> because the indices are relative to the provider. The above would
> therefore map to something like this:
>
> 	Address     Hardware  Device            Index
> 	0x40b00000  PWM0      pxa2{5,7}x-pwm.0  0
> 	0x40b00010  PWM2      pxa27x-pwm.0      1
> 	0x40c00000  PWM1      pxa2{5,7}x-pwm.1  0
> 	0x40c00010  PWM3      pxa27x-pwm.1      1
>
> Does that clarify the situation?
Yes, very much, thanks. That settles the situation for the patches I had not
understood so far, ie. patches 1, 14,16,17.

Therefore, I'll apply the whole serie this week. Thanks for your work.

Cheers.

-- 
Robert

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

end of thread, other threads:[~2015-10-06 18:49 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-05  8:49 [PATCH 00/17] ARM: pxa: Use PWM lookup tables Thierry Reding
2015-10-05  8:49 ` [PATCH 01/17] ARM: pxa: cm-x300: Use PWM lookup table Thierry Reding
2015-10-05 20:23   ` Robert Jarzmik
2015-10-06  7:53     ` Thierry Reding
2015-10-06 18:49       ` Robert Jarzmik
2015-10-05  8:49 ` [PATCH 02/17] ARM: pxa: colibri-pxa270-income: " Thierry Reding
2015-10-05  8:49 ` [PATCH 03/17] ARM: pxa: ezx: " Thierry Reding
2015-10-05  8:49 ` [PATCH 04/17] ARM: pxa: hx4700: Remove unused field initializers Thierry Reding
2015-10-06  6:53   ` Philipp Zabel
2015-10-05  8:49 ` [PATCH 05/17] ARM: pxa: lpd270: Use PWM lookup table Thierry Reding
2015-10-05  8:49 ` [PATCH 06/17] ARM: pxa: magician: " Thierry Reding
2015-10-06  6:52   ` Philipp Zabel
2015-10-05  8:49 ` [PATCH 07/17] ARM: pxa: mainstone: " Thierry Reding
2015-10-05  8:49 ` [PATCH 08/17] ARM: pxa: mioa701: " Thierry Reding
2015-10-05  8:49 ` [PATCH 09/17] ARM: pxa: palm27x: " Thierry Reding
2015-10-05  8:49 ` [PATCH 10/17] ARM: pxa: palmtc: " Thierry Reding
2015-10-05  8:49 ` [PATCH 11/17] ARM: pxa: palmte2: " Thierry Reding
2015-10-05  8:49 ` [PATCH 12/17] ARM: pxa: pcm990: " Thierry Reding
2015-10-05  8:49 ` [PATCH 13/17] ARM: pxa: raumfeld: " Thierry Reding
2015-10-05  8:49 ` [PATCH 14/17] ARM: pxa: tavorevb: " Thierry Reding
2015-10-05  8:49 ` [PATCH 15/17] ARM: pxa: viper: " Thierry Reding
2015-10-05  8:49 ` [PATCH 16/17] ARM: pxa: z2: " Thierry Reding
2015-10-05  8:49 ` [PATCH 17/17] ARM: pxa: zylonite: " Thierry Reding
2015-10-05 18:48 ` [PATCH 00/17] ARM: pxa: Use PWM lookup tables Robert Jarzmik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.