linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight
@ 2013-01-03 11:49 Peter Ujfalusi
  2013-01-03 11:49 ` [PATCH 1/3] ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight Peter Ujfalusi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2013-01-03 11:49 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

The pwm-leds driver update is going for 3.9:
https://lkml.org/lkml/2012/12/21/99

This series will make sure that in 3.9 we are going to have working LEDs and
backlight on these boards.

As a note: 4430SDP never had working backlight and the charger led did not
worked for couple of releases already due to wrong pwm_id.

On BeagleBoard we will be able to adjust the brighness of pmu_stat LED instead
of full on/off.

Zoom2 will have working keypad light and the backlight will be moved to be
handled by the generic pwm-backlight driver.

This series will also fix a compile error in board-zoom-display.c caused by the
changes in twl-core - which I missed :(

The DT support for these are going to be sent later.

Tony: can you apply this - if it looks OK - so it will hit linux-next before the
second batch of twl-core update?

Regards,
Peter
---
Peter Ujfalusi (3):
  ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight
  ARM: OMAP: omap3beagle: Use the pwm_leds driver to control the PMU_STAT led
  ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlight

 arch/arm/mach-omap2/board-4430sdp.c          | 31 ++++++++++++++-
 arch/arm/mach-omap2/board-omap3beagle.c      | 39 +++++++++++++++----
 arch/arm/mach-omap2/board-zoom-display.c     | 56 ----------------------------
 arch/arm/mach-omap2/board-zoom-peripherals.c | 53 +++++++++++++++++++++++++-
 4 files changed, 113 insertions(+), 66 deletions(-)

-- 
1.8.0.2

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

* [PATCH 1/3] ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight
  2013-01-03 11:49 [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight Peter Ujfalusi
@ 2013-01-03 11:49 ` Peter Ujfalusi
  2013-01-03 11:49 ` [PATCH 2/3] ARM: OMAP: omap3beagle: Use the pwm_leds driver to control the PMU_STAT led Peter Ujfalusi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2013-01-03 11:49 UTC (permalink / raw)
  To: linux-arm-kernel

New PWM drivers are being prepared for twl series which will enable the use
of all PWMs (PWMs and LEDs).
They are implemented as generic PWM drivers to be able to use them for different
purposes.
The current platform code was broken: the leds_pwm driver was not able to pick
up the PWM since the pwm_id was incorrect.

With the other patches we will be able to control the followings:
LCD backlight via pwm-backlight driver
Keypad leds via leds_pwm driver as normal LED
Charging indicator via leds_pwm driver as normal LED

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/mach-omap2/board-4430sdp.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 1cc6696..946b150 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -24,8 +24,10 @@
 #include <linux/gpio_keys.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/fixed.h>
+#include <linux/pwm.h>
 #include <linux/leds.h>
 #include <linux/leds_pwm.h>
+#include <linux/pwm_backlight.h>
 #include <linux/platform_data/omap4-keypad.h>
 #include <linux/usb/musb.h>
 
@@ -256,10 +258,20 @@ static struct gpio_led_platform_data sdp4430_led_data = {
 	.num_leds	= ARRAY_SIZE(sdp4430_gpio_leds),
 };
 
+static struct pwm_lookup sdp4430_pwm_lookup[] = {
+	PWM_LOOKUP("twl-pwm", 0, "leds_pwm", "omap4::keypad"),
+	PWM_LOOKUP("twl-pwm", 1, "pwm-backlight", "backlight"),
+	PWM_LOOKUP("twl-pwmled", 0, "leds_pwm", "omap4:green:chrg"),
+};
+
 static struct led_pwm sdp4430_pwm_leds[] = {
 	{
+		.name		= "omap4::keypad",
+		.max_brightness	= 127,
+		.pwm_period_ns	= 7812500,
+	},
+	{
 		.name		= "omap4:green:chrg",
-		.pwm_id		= 1,
 		.max_brightness	= 255,
 		.pwm_period_ns	= 7812500,
 	},
@@ -278,6 +290,21 @@ static struct platform_device sdp4430_leds_pwm = {
 	},
 };
 
+static struct platform_pwm_backlight_data sdp4430_backlight_data = {
+	.pwm_id = 1,
+	.max_brightness = 127,
+	.dft_brightness = 127,
+	.pwm_period_ns = 7812500,
+};
+
+static struct platform_device sdp4430_backlight_pwm = {
+	.name   = "pwm-backlight",
+	.id     = -1,
+	.dev    = {
+		.platform_data = &sdp4430_backlight_data,
+	},
+};
+
 static int omap_prox_activate(struct device *dev)
 {
 	gpio_set_value(OMAP4_SFH7741_ENABLE_GPIO , 1);
@@ -412,6 +439,7 @@ static struct platform_device *sdp4430_devices[] __initdata = {
 	&sdp4430_gpio_keys_device,
 	&sdp4430_leds_gpio,
 	&sdp4430_leds_pwm,
+	&sdp4430_backlight_pwm,
 	&sdp4430_vbat,
 	&sdp4430_dmic_codec,
 	&sdp4430_abe_audio,
@@ -707,6 +735,7 @@ static void __init omap_4430sdp_init(void)
 				ARRAY_SIZE(sdp4430_spi_board_info));
 	}
 
+	pwm_add_table(sdp4430_pwm_lookup, ARRAY_SIZE(sdp4430_pwm_lookup));
 	status = omap4_keyboard_init(&sdp4430_keypad_data, &keypad_data);
 	if (status)
 		pr_err("Keypad initialization failed: %d\n", status);
-- 
1.8.0.2

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

* [PATCH 2/3] ARM: OMAP: omap3beagle: Use the pwm_leds driver to control the PMU_STAT led
  2013-01-03 11:49 [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight Peter Ujfalusi
  2013-01-03 11:49 ` [PATCH 1/3] ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight Peter Ujfalusi
@ 2013-01-03 11:49 ` Peter Ujfalusi
  2013-01-03 11:49 ` [PATCH 3/3] ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlight Peter Ujfalusi
  2013-01-03 11:56 ` [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight Peter Ujfalusi
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2013-01-03 11:49 UTC (permalink / raw)
  To: linux-arm-kernel

With the PWM backed driver the PMU_STAT led's brighness can be controlled.
This needs the new drivers for the TWL PWM/LED to work.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/mach-omap2/board-omap3beagle.c | 39 ++++++++++++++++++++++++++-------
 1 file changed, 31 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 909e7fa..c5efd51 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -20,6 +20,8 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/leds.h>
+#include <linux/pwm.h>
+#include <linux/leds_pwm.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
@@ -55,6 +57,32 @@
 
 #define	NAND_CS	0
 
+static struct pwm_lookup pwm_lookup[] = {
+	/* LEDB -> PMU_STAT */
+	PWM_LOOKUP("twl-pwmled", 1, "leds_pwm", "beagleboard::pmu_stat"),
+};
+
+static struct led_pwm pwm_leds[] = {
+	{
+		.name		= "beagleboard::pmu_stat",
+		.max_brightness	= 127,
+		.pwm_period_ns	= 333,
+	},
+};
+
+static struct led_pwm_platform_data pwm_data = {
+	.num_leds	= ARRAY_SIZE(pwm_leds),
+	.leds		= pwm_leds,
+};
+
+static struct platform_device leds_pwm = {
+	.name	= "leds_pwm",
+	.id	= -1,
+	.dev	= {
+		.platform_data = &pwm_data,
+	},
+};
+
 /*
  * OMAP3 Beagle revision
  * Run time detection of Beagle revision is done by reading GPIO.
@@ -292,9 +320,6 @@ static int beagle_twl_gpio_setup(struct device *dev,
 	gpio_request_one(gpio + TWL4030_GPIO_MAX, beagle_config.usb_pwr_level,
 			"nEN_USB_PWR");
 
-	/* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
-	gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
-
 	return 0;
 }
 
@@ -376,11 +401,6 @@ static struct gpio_led gpio_leds[] = {
 		.default_trigger	= "mmc0",
 		.gpio			= 149,
 	},
-	{
-		.name			= "beagleboard::pmu_stat",
-		.gpio			= -EINVAL,	/* gets replaced */
-		.active_low		= true,
-	},
 };
 
 static struct gpio_led_platform_data gpio_led_info = {
@@ -428,6 +448,7 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
 	&leds_gpio,
 	&keys_gpio,
 	&madc_hwmon,
+	&leds_pwm,
 };
 
 static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
@@ -532,6 +553,8 @@ static void __init omap3_beagle_init(void)
 	/* Ensure SDRC pins are mux'd for self-refresh */
 	omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
 	omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
+
+	pwm_add_table(pwm_lookup, ARRAY_SIZE(pwm_lookup));
 }
 
 MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
-- 
1.8.0.2

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

* [PATCH 3/3] ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlight
  2013-01-03 11:49 [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight Peter Ujfalusi
  2013-01-03 11:49 ` [PATCH 1/3] ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight Peter Ujfalusi
  2013-01-03 11:49 ` [PATCH 2/3] ARM: OMAP: omap3beagle: Use the pwm_leds driver to control the PMU_STAT led Peter Ujfalusi
@ 2013-01-03 11:49 ` Peter Ujfalusi
  2013-01-03 11:56 ` [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight Peter Ujfalusi
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2013-01-03 11:49 UTC (permalink / raw)
  To: linux-arm-kernel

Use pwm_leds driver for the keyboard light and pwm-backlight for the lcd
backlight control (instead of implementing the PWM driver part in the board
file).

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 arch/arm/mach-omap2/board-zoom-display.c     | 56 ----------------------------
 arch/arm/mach-omap2/board-zoom-peripherals.c | 53 +++++++++++++++++++++++++-
 2 files changed, 52 insertions(+), 57 deletions(-)

diff --git a/arch/arm/mach-omap2/board-zoom-display.c b/arch/arm/mach-omap2/board-zoom-display.c
index 1c7c834..9a7174f 100644
--- a/arch/arm/mach-omap2/board-zoom-display.c
+++ b/arch/arm/mach-omap2/board-zoom-display.c
@@ -12,7 +12,6 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
-#include <linux/i2c/twl.h>
 #include <linux/spi/spi.h>
 #include <linux/platform_data/spi-omap2-mcspi.h>
 #include <video/omapdss.h>
@@ -49,59 +48,6 @@ static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)
 {
 }
 
-/*
- * PWMA/B register offsets (TWL4030_MODULE_PWMA)
- */
-#define TWL_INTBR_PMBR1	0xD
-#define TWL_INTBR_GPBR1	0xC
-#define TWL_LED_PWMON	0x0
-#define TWL_LED_PWMOFF	0x1
-
-static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
-{
-#ifdef CONFIG_TWL4030_CORE
-	unsigned char c;
-	u8 mux_pwm, enb_pwm;
-
-	if (level > 100)
-		return -1;
-
-	twl_i2c_read_u8(TWL4030_MODULE_INTBR, &mux_pwm, TWL_INTBR_PMBR1);
-	twl_i2c_read_u8(TWL4030_MODULE_INTBR, &enb_pwm, TWL_INTBR_GPBR1);
-
-	if (level == 0) {
-		/* disable pwm1 output and clock */
-		enb_pwm = enb_pwm & 0xF5;
-		/* change pwm1 pin to gpio pin */
-		mux_pwm = mux_pwm & 0xCF;
-		twl_i2c_write_u8(TWL4030_MODULE_INTBR,
-					enb_pwm, TWL_INTBR_GPBR1);
-		twl_i2c_write_u8(TWL4030_MODULE_INTBR,
-					mux_pwm, TWL_INTBR_PMBR1);
-		return 0;
-	}
-
-	if (!((enb_pwm & 0xA) && (mux_pwm & 0x30))) {
-		/* change gpio pin to pwm1 pin */
-		mux_pwm = mux_pwm | 0x30;
-		/* enable pwm1 output and clock*/
-		enb_pwm = enb_pwm | 0x0A;
-		twl_i2c_write_u8(TWL4030_MODULE_INTBR,
-					mux_pwm, TWL_INTBR_PMBR1);
-		twl_i2c_write_u8(TWL4030_MODULE_INTBR,
-					enb_pwm, TWL_INTBR_GPBR1);
-	}
-
-	c = ((50 * (100 - level)) / 100) + 1;
-	twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF);
-	twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON);
-#else
-	pr_warn("Backlight not enabled\n");
-#endif
-
-	return 0;
-}
-
 static struct omap_dss_device zoom_lcd_device = {
 	.name			= "lcd",
 	.driver_name		= "NEC_8048_panel",
@@ -109,8 +55,6 @@ static struct omap_dss_device zoom_lcd_device = {
 	.phy.dpi.data_lines	= 24,
 	.platform_enable	= zoom_panel_enable_lcd,
 	.platform_disable	= zoom_panel_disable_lcd,
-	.max_backlight_level	= 100,
-	.set_backlight		= zoom_set_bl_intensity,
 };
 
 static struct omap_dss_device *zoom_dss_devices[] = {
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index 7349bbf..a59c2fc 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -21,6 +21,9 @@
 #include <linux/mmc/host.h>
 #include <linux/platform_data/gpio-omap.h>
 #include <linux/platform_data/omap-twl4030.h>
+#include <linux/pwm.h>
+#include <linux/leds_pwm.h>
+#include <linux/pwm_backlight.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -194,6 +197,53 @@ static struct platform_device omap_vwlan_device = {
 	},
 };
 
+static struct pwm_lookup zoom_pwm_lookup[] = {
+	PWM_LOOKUP("twl-pwm", 0, "leds_pwm", "zoom::keypad"),
+	PWM_LOOKUP("twl-pwm", 1, "pwm-backlight", "backlight"),
+};
+
+static struct led_pwm zoom_pwm_leds[] = {
+	{
+		.name		= "zoom::keypad",
+		.max_brightness	= 127,
+		.pwm_period_ns	= 7812500,
+	},
+};
+
+static struct led_pwm_platform_data zoom_pwm_data = {
+	.num_leds	= ARRAY_SIZE(zoom_pwm_leds),
+	.leds		= zoom_pwm_leds,
+};
+
+static struct platform_device zoom_leds_pwm = {
+	.name	= "leds_pwm",
+	.id	= -1,
+	.dev	= {
+		.platform_data = &zoom_pwm_data,
+	},
+};
+
+static struct platform_pwm_backlight_data zoom_backlight_data = {
+	.pwm_id = 1,
+	.max_brightness = 127,
+	.dft_brightness = 127,
+	.pwm_period_ns = 7812500,
+};
+
+static struct platform_device zoom_backlight_pwm = {
+	.name   = "pwm-backlight",
+	.id     = -1,
+	.dev    = {
+		.platform_data = &zoom_backlight_data,
+	},
+};
+
+static struct platform_device *zoom_devices[] __initdata = {
+	&omap_vwlan_device,
+	&zoom_leds_pwm,
+	&zoom_backlight_pwm,
+};
+
 static struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
 	.board_ref_clock = WL12XX_REFCLOCK_26, /* 26 MHz */
 };
@@ -311,7 +361,8 @@ void __init zoom_peripherals_init(void)
 
 	omap_hsmmc_init(mmc);
 	omap_i2c_init();
-	platform_device_register(&omap_vwlan_device);
+	pwm_add_table(zoom_pwm_lookup, ARRAY_SIZE(zoom_pwm_lookup));
+	platform_add_devices(zoom_devices, ARRAY_SIZE(zoom_devices));
 	usb_musb_init(NULL);
 	enable_board_wakeup_source();
 	omap_serial_init();
-- 
1.8.0.2

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

* [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight
  2013-01-03 11:49 [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight Peter Ujfalusi
                   ` (2 preceding siblings ...)
  2013-01-03 11:49 ` [PATCH 3/3] ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlight Peter Ujfalusi
@ 2013-01-03 11:56 ` Peter Ujfalusi
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Ujfalusi @ 2013-01-03 11:56 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Tony,

On 01/03/2013 12:49 PM, Peter Ujfalusi wrote:
> Hi,
> 
> The pwm-leds driver update is going for 3.9:
> https://lkml.org/lkml/2012/12/21/99
> 
> This series will make sure that in 3.9 we are going to have working LEDs and
> backlight on these boards.
> 
> As a note: 4430SDP never had working backlight and the charger led did not
> worked for couple of releases already due to wrong pwm_id.
> 
> On BeagleBoard we will be able to adjust the brighness of pmu_stat LED instead
> of full on/off.
> 
> Zoom2 will have working keypad light and the backlight will be moved to be
> handled by the generic pwm-backlight driver.
> 
> This series will also fix a compile error in board-zoom-display.c caused by the
> changes in twl-core - which I missed :(
> 
> The DT support for these are going to be sent later.
> 
> Tony: can you apply this - if it looks OK - so it will hit linux-next before the
> second batch of twl-core update?

The series has been generated on top of my previous series for audio support
update of omap-twl4030:
http://www.mail-archive.com/linux-omap at vger.kernel.org/msg82615.html

I can regenerate this without the depending series if you prefer that way.

> 
> Regards,
> Peter
> ---
> Peter Ujfalusi (3):
>   ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight
>   ARM: OMAP: omap3beagle: Use the pwm_leds driver to control the PMU_STAT led
>   ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlight
> 
>  arch/arm/mach-omap2/board-4430sdp.c          | 31 ++++++++++++++-
>  arch/arm/mach-omap2/board-omap3beagle.c      | 39 +++++++++++++++----
>  arch/arm/mach-omap2/board-zoom-display.c     | 56 ----------------------------
>  arch/arm/mach-omap2/board-zoom-peripherals.c | 53 +++++++++++++++++++++++++-
>  4 files changed, 113 insertions(+), 66 deletions(-)
> 


-- 
P?ter

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

end of thread, other threads:[~2013-01-03 11:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-03 11:49 [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight Peter Ujfalusi
2013-01-03 11:49 ` [PATCH 1/3] ARM: OMAP: board-4430sdp: Proper support for TWL6030 PWM LED/Backlight Peter Ujfalusi
2013-01-03 11:49 ` [PATCH 2/3] ARM: OMAP: omap3beagle: Use the pwm_leds driver to control the PMU_STAT led Peter Ujfalusi
2013-01-03 11:49 ` [PATCH 3/3] ARM: OMAP: zoom: Use pwm stack for lcd and keyboard backlight Peter Ujfalusi
2013-01-03 11:56 ` [PATCH 0/3] ARM: OMAP3/4: Correct support for PWM LEDs/backlight Peter Ujfalusi

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