backlight: Add TPS65217 WLED driver
Subsystems (4)
PATCH v2 1/1 backlight: Add TPS65217 WLED driver
The TPS65217 chip contains a boost converter and current sinks which can be used to drive LEDs for use as backlights. Expose this functionality via the backlight API.
Tested on an AM335x based custom board with a single WLED string, using different values for ISEL and FDIM (though it would be hard to tell the difference except for the value in WLEDCTRL1). Both instantiation through the device tree and by passing platform data have been tested. Testing has been done with an Androidized 3.2 kernel from the rowboat project
This patch is based on the mfd tree, it also applies on linux-next (20120809)
Changes since v1:
* addressed review comments
* moved device tree parsing to the backlight driver
--- drivers/mfd/tps65217.c | 32 +++ drivers/video/backlight/Kconfig | 7 + drivers/video/backlight/Makefile | 1 + drivers/video/backlight/tps65217_bl.c | 343 +++++++++++++++++++++++++++++++++ include/linux/mfd/tps65217.h | 25 ++- 5 files changed, 407 insertions(+), 1 deletion(-) create mode 100644 drivers/video/backlight/tps65217_bl.c
drivers/mfd/tps65217.c +32 -0
@@ -174,6 +174,10 @@ static struct tps65217_board *tps65217_parse_dt(struct i2c_client *client) pdata->of_node[i] = reg_matches[i].of_node; } + node =of_find_node_by_name (node,"backlight" ); +if (node) + pdata->of_node[TPS65217_SUBDEV_BL ] = node; +return pdata; }
@@ -250,7 +254,32 @@ static int __devinit tps65217_probe(struct i2c_client *client,platform_device_add (pdev); } +if (pdata->bl_pdata || pdata->of_node[TPS65217_SUBDEV_BL ]) { + tps->bl_pdev =platform_device_alloc ("tps65217-bl" ,0 ); +if (!tps->bl_pdev) { +dev_err (tps->dev,"Cannot create backlight platform device\n" ); + ret = -ENOMEM ; + goto err_alloc_bl_pdev; + } + + tps->bl_pdev->dev.parent = tps->dev; + +if (pdata->bl_pdata) + tps->bl_pdev->dev.platform_data = pdata->bl_pdata; +else + tps->bl_pdev->dev.of_node = + pdata->of_node[TPS65217_SUBDEV_BL ]; + +platform_device_add (tps->bl_pdev); + } +return 0 ; + +err_alloc_bl_pdev: +for (i =0 ; i <TPS65217_NUM_REGULATOR ; i++) +platform_device_unregister (tps->regulator_pdev[i]); + +return ret; } static int __devexit tps65217_remove(struct i2c_client *client)
@@ -258,6 +287,9 @@ static int __devexit tps65217_remove(struct i2c_client *client)struct tps65217 *tps =i2c_get_clientdata (client);int i; +if (tps->bl_pdev) +platform_device_unregister (tps->bl_pdev); +for (i =0 ; i <TPS65217_NUM_REGULATOR ; i++)platform_device_unregister (tps->regulator_pdev[i]);
drivers/video/backlight/Kconfig +7 -0
@@ -373,6 +373,13 @@ config BACKLIGHT_PANDORA If you have a Pandora console, say Y to enable the backlight driver. +config BACKLIGHT_TPS65217 + tristate "Backlight driver for TI TPS65217 using WLED" + depends on BACKLIGHT_CLASS_DEVICE && MFD_TPS65217 + help + If you have a Texas Instruments TPS65217 say Y to enable the + backlight driver. + endif # BACKLIGHT_CLASS_DEVICE endif # BACKLIGHT_LCD_SUPPORT
drivers/video/backlight/Makefile +1 -0
@@ -43,3 +43,4 @@ obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o obj-$(CONFIG_BACKLIGHT_AAT2870) += aat2870_bl.o obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o +obj-$(CONFIG_BACKLIGHT_TPS65217) += tps65217_bl.o
drivers/video/backlight/tps65217_bl.c new file +343 -0
343 lines not on this page · raw message
include/linux/mfd/tps65217.h +24 -1
@@ -209,6 +209,27 @@ enum tps65217_regulator_id {#define TPS65217_NUM_LDO 4/* Number of total regulators available */ #define TPS65217_NUM_REGULATOR (TPS65217_NUM_DCDC + TPS65217_NUM_LDO) +/* Number of subdevices (regulators + backlight) */ +#define TPS65217_NUM_SUBDEVS (TPS65217_NUM_REGULATOR + 1) +/* Index of the backlight subdevice */ +#define TPS65217_SUBDEV_BL TPS65217_NUM_REGULATOR + +enum tps65217_bl_isel { +TPS65217_BL_ISET1 =1 , +TPS65217_BL_ISET2 =2 , +}; + +enum tps65217_bl_fdim { +TPS65217_BL_FDIM_100HZ , +TPS65217_BL_FDIM_200HZ , +TPS65217_BL_FDIM_500HZ , +TPS65217_BL_FDIM_1000HZ , +}; + +struct tps65217_bl_pdata { +enum tps65217_bl_isel isel; +enum tps65217_bl_fdim fdim; +};/** * struct tps65217_board - packages regulator init data
@@ -218,7 +239,8 @@ enum tps65217_regulator_id {*/ struct tps65217_board {struct regulator_init_data *tps65217_init_data[TPS65217_NUM_REGULATOR ]; -struct device_node *of_node[TPS65217_NUM_REGULATOR ]; +struct device_node *of_node[TPS65217_NUM_SUBDEVS ]; +struct tps65217_bl_pdata *bl_pdata; };/**
@@ -255,6 +277,7 @@ struct tps65217 {/* Client devices */ struct platform_device *regulator_pdev[TPS65217_NUM_REGULATOR ]; +struct platform_device *bl_pdev; };static inline struct tps65217 *dev_to_tps65217 (struct device *dev)
Signature · 1 line
1.7.10
Hi Matthias,
Quoted 11 lines · Matthias Kaehlcke
The TPS65217 chip contains a boost converter and current sinks which can be used to drive LEDs for use as backlights. Expose this functionality via the backlight API.
Tested on an AM335x based custom board with a single WLED string, using different values for ISEL and FDIM (though it would be hard to tell the difference except for the value in WLEDCTRL1). Both instantiation through the device tree and by passing platform data have been tested. Testing has been done with an Androidized 3.2 kernel from the rowboat project
This patch is based on the mfd tree, it also applies on linux-next (20120809)
It doesn't seem to apply to my for-next branch.
Also, some comments:
Quoted 24 lines
drivers/mfd/tps65217.c +13
-0@@ -174,6 +174,10 @@ static struct tps65217_board *tps65217_parse_dt(struct i2c_client *client) pdata->of_node[i] = reg_matches[i].of_node; } + node =of_find_node_by_name (node,"backlight" ); +if (node) + pdata->of_node[TPS65217_SUBDEV_BL ] = node; +return pdata; }@@ -250,7 +254,32 @@ static int __devinit tps65217_probe(struct i2c_client *client,platform_device_add (pdev); } +if (pdata->bl_pdata || pdata->of_node[TPS65217_SUBDEV_BL ]) { + tps->bl_pdev =platform_device_alloc ("tps65217-bl" ,0 ); +if (!tps->bl_pdev) { +dev_err (tps->dev,"Cannot create backlight platform device\n" ); + ret = -ENOMEM ; + goto err_alloc_bl_pdev; + } + + tps->bl_pdev->dev.parent = tps->dev;
drivers/mfd/tps65217.c static int __devinit tps65217_probe(struct i2c_client *client, · line 275
Quoted 10 lines
drivers/mfd/tps65217.c +10
-0+ +if (pdata->bl_pdata) + tps->bl_pdev->dev.platform_data = pdata->bl_pdata; +else + tps->bl_pdev->dev.of_node = + pdata->of_node[TPS65217_SUBDEV_BL ]; + +platform_device_add (tps->bl_pdev); + } +
The MFD API probably allows you to do exactly that by defining a specific cell for bl. Could you please try to use this API or otherwise justify not using it?
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Hi Samuel,
El Mon, Sep 17, 2012 at 01:09:36AM +0200 Samuel Ortiz ha dit:
Quoted 5 lines · Matthias Kaehlcke
Quoted 4 lines
The TPS65217 chip contains a boost converter and current sinks which can be used to drive LEDs for use as backlights. Expose this functionality via the backlight API.
Quoted 8 lines
Quoted 7 lines
Tested on an AM335x based custom board with a single WLED string, using different values for ISEL and FDIM (though it would be hard to tell the difference except for the value in WLEDCTRL1). Both instantiation through the device tree and by passing platform data have been tested. Testing has been done with an Androidized 3.2 kernel from the rowboat project
This patch is based on the mfd tree, it also applies on linux-next (20120809)
It doesn't seem to apply to my for-next branch.
i suppose your for-next branch evolved during the last month
Quoted 31 lines
Also, some comments:
Quoted 29 lines
drivers/mfd/tps65217.c +18
-0@@ -174,6 +174,10 @@ static struct tps65217_board *tps65217_parse_dt(struct i2c_client *client) pdata->of_node[i] = reg_matches[i].of_node; } + node =of_find_node_by_name (node,"backlight" ); +if (node) + pdata->of_node[TPS65217_SUBDEV_BL ] = node; +return pdata; }@@ -250,7 +254,32 @@ static int __devinit tps65217_probe(struct i2c_client *client,platform_device_add (pdev); } +if (pdata->bl_pdata || pdata->of_node[TPS65217_SUBDEV_BL ]) { + tps->bl_pdev =platform_device_alloc ("tps65217-bl" ,0 ); +if (!tps->bl_pdev) { +dev_err (tps->dev,"Cannot create backlight platform device\n" ); + ret = -ENOMEM ; + goto err_alloc_bl_pdev; + } + + tps->bl_pdev->dev.parent = tps->dev; + +if (pdata->bl_pdata) + tps->bl_pdev->dev.platform_data = pdata->bl_pdata; +else + tps->bl_pdev->dev.of_node =
Quoted 8 lines
drivers/mfd/tps65217.c static int __devinit tps65217_probe(struct i2c_client *client, · line 275
Quoted 5 lines
drivers/mfd/tps65217.c +5
-0+ pdata->of_node[TPS65217_SUBDEV_BL ]; + +platform_device_add (tps->bl_pdev); + } +The MFD API probably allows you to do exactly that by defining a specific cell for bl. Could you please try to use this API or otherwise justify not using it?
you seem to have missed v3 of the patch which addresses this, it was sent on 22 Aug 2012
in the next days i'll submit v4, with changes based on the comments received for v3
best regards
Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Developer
Amsterdam
Si deseas mantener tu libertad, debes estar preparado para defenderla
(Richard Stallman)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-Hi Matthias,
Quoted 6 lines · Matthias Kaehlcke
Quoted 3 lines
The MFD API probably allows you to do exactly that by defining a specific cell for bl. Could you please try to use this API or otherwise justify not using it?
you seem to have missed v3 of the patch which addresses this, it was sent on 22 Aug 2012
Indeed, I missed it. Looks much better.
Quoted 2 lines
in the next days i'll submit v4, with changes based on the comments received for v3
Sounds good.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/