Skip to contentSkip to conversation

Back-light class driver support for OMAP

PATCH In review [email protected] 2 participants 2 messages Mar 18, 2009 – Mar 19, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Back-light class driver support for OMAP

From: Vaibhav Hiremath <[email protected]>

Till now OMAPFB driver was handling back-light interface through it's own custom SYSFS entries. Earliear there was a discussion where we decided to add support for OMAP back-light into Generic class driver. Also Sanjeev has submitted patch supporting back-light class driver.

This patch addresses review comments from 'Richard Purdie', and adds support for OMAP3EVM.

NOTE:
I am not sure whether back-light class driver interface still holds this implementation, since not a single platform I could found in kernel tree which follows this implementation.

Since this implementation has been suggested by 'Richard Purdie', and I was readily having this patch so I am submitting it for review.

The next version of patch will be devided into 3 seperate patches
- twl4030 related changes
- OMAPFB related changes
- board-omap3evm.c related changes.

TODO:
- Need to add simillar support for other platforms and development boards.
- Merge it to DSS2 and OMAP2FB

---
 arch/arm/mach-omap2/board-omap3evm.c     |   37 ++++++++++++++++++++
 arch/arm/plat-omap/include/mach/omapfb.h |    4 --
 drivers/video/omap/lcd_omap3evm.c        |   27 ---------------
 drivers/video/omap/omapfb_main.c         |   54 ------------------------------
 include/linux/i2c/twl4030.h              |   14 ++++++++
 5 files changed, 51 insertions(+), 85 deletions(-)
arch/arm/mach-omap2/board-omap3evm.c +37 -0
index 024d7c4..c749604 100644
@@ -20,6 +20,7 @@
 #include <linux/clk.h>
 #include <linux/input.h>
 #include <linux/leds.h>
+#include <linux/backlight.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
@@ -225,6 +226,41 @@ static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
 	.ctrl_name	= "internal",
 };
 
+#define TWL_PWMA_PWMAOFF	0x01
+
+static void omap3_set_bl_intensity(int intensity)
+{
+	unsigned char c;
+
+	if (intensity > 100)
+		return;
+
+	c = ((125 * (100 - intensity)) / 100) + 2;
+
+#if defined(CONFIG_TWL4030_CORE)
+	twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL4030_LED_EN);
+	twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
+#endif
+
+}
+static struct generic_bl_info omap3_bl_platform_data = {
+	.name			= "omap3-bklight",
+	.max_intensity		= 100,
+	.default_intensity	= 70,
+	.limit_mask		= 0,
+	.set_bl_intensity	= omap3_set_bl_intensity,
+	.kick_battery		= NULL,
+};
+
+static struct platform_device omap3_bklight_device = {
+	.name			= "generic-bl",
+	.id			= -1,
+	.dev			= {
+		.parent		= &omap3_evm_lcd_device.dev,
+		.platform_data	= &omap3_bl_platform_data,
+	},
+};
+
 static void ads7846_dev_init(void)
 {
 	if (gpio_request(OMAP3_EVM_TS_GPIO, "ADS7846 pendown") < 0)
@@ -286,6 +322,7 @@ static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
 
 static struct platform_device *omap3_evm_devices[] __initdata = {
 	&omap3_evm_lcd_device,
+	&omap3_bklight_device,
 	&omap3evm_smc911x_device,
 };
 
arch/arm/plat-omap/include/mach/omapfb.h +0 -4
index b226bdf..b87466b 100644
@@ -218,10 +218,6 @@ struct lcd_panel {
 	int		(*enable)	(struct lcd_panel *panel);
 	void		(*disable)	(struct lcd_panel *panel);
 	unsigned long	(*get_caps)	(struct lcd_panel *panel);
-	int		(*set_bklight_level)(struct lcd_panel *panel,
-					     unsigned int level);
-	unsigned int	(*get_bklight_level)(struct lcd_panel *panel);
-	unsigned int	(*get_bklight_max)  (struct lcd_panel *panel);
 	int		(*run_test)	(struct lcd_panel *panel, int test_num);
 };
 
drivers/video/omap/lcd_omap3evm.c +0 -27
index 1c3d814..23238ae 100644
@@ -49,7 +49,6 @@
 #define TWL_PWMA_PWMAON		0x00
 #define TWL_PWMA_PWMAOFF	0x01
 
-static unsigned int bklight_level;
 
 static int omap3evm_panel_init(struct lcd_panel *panel,
 				struct omapfb_device *fbdev)
@@ -69,7 +68,6 @@ static int omap3evm_panel_init(struct lcd_panel *panel,
 	twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL_LED_LEDEN);
 	twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x01, TWL_PWMA_PWMAON);
 	twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, 0x02, TWL_PWMA_PWMAOFF);
-	bklight_level = 100;
 
 	return 0;
 }
@@ -94,28 +92,6 @@ static unsigned long omap3evm_panel_get_caps(struct lcd_panel *panel)
 	return 0;
 }
 
-static int omap3evm_bklight_setlevel(struct lcd_panel *panel,
-						unsigned int level)
-{
-	u8 c;
-	if ((level >= 0) && (level <= 100)) {
-		c = (125 * (100 - level)) / 100 + 2;
-		twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
-		bklight_level = level;
-	}
-	return 0;
-}
-
-static unsigned int omap3evm_bklight_getlevel(struct lcd_panel *panel)
-{
-	return bklight_level;
-}
-
-static unsigned int omap3evm_bklight_getmaxlevel(struct lcd_panel *panel)
-{
-	return 100;
-}
-
 struct lcd_panel omap3evm_panel = {
 	.name		= "omap3evm",
 	.config		= OMAP_LCDC_PANEL_TFT | OMAP_LCDC_INV_VSYNC |
@@ -139,9 +115,6 @@ struct lcd_panel omap3evm_panel = {
 	.enable		= omap3evm_panel_enable,
 	.disable	= omap3evm_panel_disable,
 	.get_caps	= omap3evm_panel_get_caps,
-	.set_bklight_level      = omap3evm_bklight_setlevel,
-	.get_bklight_level      = omap3evm_bklight_getlevel,
-	.get_bklight_max        = omap3evm_bklight_getmaxlevel,
 };
 
 static int omap3evm_panel_probe(struct platform_device *pdev)
drivers/video/omap/omapfb_main.c +0 -54

65 lines not on this page · raw message

include/linux/i2c/twl4030.h +14 -0
index c89d33b..48063ba 100644
@@ -84,6 +84,20 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes);
 /*----------------------------------------------------------------------*/
 
 /*
+ * LED Module register offsets (use TWL4030_MODULE_LED)
+ */
+#define TWL4030_LED_EN			0x0
+
+/*----------------------------------------------------------------------*/
+
+/*
+ * PWMA/B register offsets (use TWL4030_MODULE_PWMA/TWL4030_MODULE_PWMB)
+ */
+#define TWL4030_LED_PWMON		0x0
+#define TWL4030_LED_PWMOFF		0x1
+
+
+/*
  * NOTE:  at up to 1024 registers, this is a big chip.
  *
  * Avoid putting register declarations in this file, instead of into

--
1.5.6

#1 lore raw

arch/arm/mach-omap2/board-omap3evm.c static struct omap_lcd_config omap3_evm_lcd_config __initdata = { · line 243

Quoted 5 lines · On Wednesday 18 March 2009, [email protected] wrote:
arch/arm/mach-omap2/board-omap3evm.c +5 -0
+
+#if defined(CONFIG_TWL4030_CORE)
+       twl4030_i2c_write_u8(TWL4030_MODULE_LED, 0x11, TWL4030_LED_EN);
+       twl4030_i2c_write_u8(TWL4030_MODULE_PWMA, c, TWL_PWMA_PWMAOFF);
+#endif

Hmm, I think I'm going to have to get off my butt and send in the PWM patches I have ... they work for the PWMs on the two LED outputs, but not yet for the two other PWM-equipped pins (GPIO-6, GPIO-7)

- Dave
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html