Re: [PATCH 1/1] leds: Add LED driver for lm355x chips

2012-08-07 Thread Bryan Wu
On Tue, Aug 7, 2012 at 1:28 PM, GShark Jeong  wrote:
> Hi Bryan.
>
> We can replace lm3556 by lm355x code or add lm355x code leaving lm3556.
> Let me know your opinion which one is better.
>

Sure, I prefer to replace lm3556 by lm355x since your new solution
covers this 2 drivers.

Thanks,
-Bryan

>
> 2012/8/7 Bryan Wu 
>>
>> On Wed, Aug 1, 2012 at 8:05 PM, G.Shark Jeong 
>> wrote:
>> > From: "G.Shark Jeong" 
>> >
>> > LM3554 and LM3556 have similar functions but very different register
>> > map.
>> > This driver is a general version for LM355x,lm3554 and lm3556,led chips
>> > of TI.
>> > lm3556 driver can be replaced by this driver.
>> >
>> > LM3554 :
>> > The LM3554 is a 2 MHz fixed-frequency synchronous boost
>> > converter with 1.2A dual high side led drivers.
>> > Datasheet: www.ti.com/lit/ds/symlink/lm3554.pdf
>> >
>> > LM3556 :
>> > The LM3556 is a 4 MHz fixed-frequency synchronous boost
>> > converter plus 1.5A constant current driver for a high-current white
>> > LED.
>> > Datasheet: www.national.com/ds/LM/LM3556.pdf
>> >
>> > Signed-off-by: G.Shark Jeong 
>> > ---
>>
>> Thanks, I think basically I'm OK for this patch, just some small
>> comments as below.
>>
>> -Bryan
>>
>> >  drivers/leds/Kconfig  |8 +-
>> >  drivers/leds/Makefile |2 +-
>> >  drivers/leds/leds-lm355x.c|  529
>> > +
>> >  include/linux/platform_data/leds-lm355x.h |   66 
>> >  4 files changed, 600 insertions(+), 5 deletions(-)
>> >  create mode 100644 drivers/leds/leds-lm355x.c
>> >  create mode 100644 include/linux/platform_data/leds-lm355x.h
>> >
>> > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
>> > index c96bbaa..4f6ced2 100644
>> > --- a/drivers/leds/Kconfig
>> > +++ b/drivers/leds/Kconfig
>> > @@ -422,13 +422,13 @@ config LEDS_MAX8997
>> >   This option enables support for on-chip LED drivers on
>> >   MAXIM MAX8997 PMIC.
>> >
>> > -config LEDS_LM3556
>> > -   tristate "LED support for LM3556 Chip"
>> > +config LEDS_LM355x
>> > +   tristate "LED support for LM355x Chips, LM3554 and LM3556"
>> > depends on LEDS_CLASS && I2C
>> > select REGMAP_I2C
>> > help
>> > - This option enables support for LEDs connected to LM3556.
>> > - LM3556 includes Torch, Flash and Indicator functions.
>> > + This option enables support for LEDs connected to LM355x.
>> > + LM355x includes Torch, Flash and Indicator functions.
>> >
>> >  config LEDS_OT200
>> > tristate "LED support for the Bachmann OT200"
>> > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
>> > index a4429a9..b57a021 100644
>> > --- a/drivers/leds/Makefile
>> > +++ b/drivers/leds/Makefile
>> > @@ -48,7 +48,7 @@ obj-$(CONFIG_LEDS_NETXBIG)+=
>> > leds-netxbig.o
>> >  obj-$(CONFIG_LEDS_ASIC3)   += leds-asic3.o
>> >  obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
>> >  obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
>> > -obj-$(CONFIG_LEDS_LM3556)  += leds-lm3556.o
>>
>> You removed leds-lm3556.o here, but didn't remove the real C file in
>> this patchset
>>
>> > +obj-$(CONFIG_LEDS_LM355x)  += leds-lm355x.o
>> >  obj-$(CONFIG_LEDS_BLINKM)  += leds-blinkm.o
>> >
>> >  # LED SPI Drivers
>> > diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
>> > new file mode 100644
>> > index 000..5cdbbb4
>> > --- /dev/null
>> > +++ b/drivers/leds/leds-lm355x.c
>> > @@ -0,0 +1,529 @@
>> > +/*
>> > +* Simple driver for Texas Instruments LM355x LED Flash driver chip
>> > +* Copyright (C) 2012 Texas Instruments
>> > +*
>> > +* This program is free software; you can redistribute it and/or modify
>> > +* it under the terms of the GNU General Public License version 2 as
>> > +* published by the Free Software Foundation.
>> > +*/
>> > +
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +#include 
>> > +
>> > +enum lm355x_type {
>> > +   CHIP_LM3554 = 0,
>> > +   CHIP_LM3556,
>> > +};
>> > +
>> > +enum lm355x_regs {
>> > +   REG_FLAG = 0,
>> > +   REG_TORCH_CFG,
>> > +   REG_TORCH_CTRL,
>> > +   REG_STROBE_CFG,
>> > +   REG_FLASH_CTRL,
>> > +   REG_INDI_CFG,
>> > +   REG_INDI_CTRL,
>> > +   REG_OPMODE,
>> > +   REG_MAX,
>> > +};
>> > +
>> > +/* operation mode */
>> > +enum lm355x_mode {
>> > +   MODE_SHDN = 0,
>> > +   MODE_INDIC,
>> > +   MODE_TORCH,
>> > +   MODE_FLASH
>> > +};
>> > +
>> > +/* register map info. */
>> > +struct lm355x_reg_data {
>> > +   u8 regno;
>> > +   u8 mask;
>> > +   u8 shift;
>> > +};
>> > +
>> > +struct lm355x_chip_data {
>> > +   struct device *dev;
>> > +   enum lm355x_type type;
>> > +
>> > +   struct led_classdev cdev_flash;
>> > +   struct led_classdev cdev_torch;
>> > +   struct 

Re: [PATCH 1/1] leds: Add LED driver for lm355x chips

2012-08-07 Thread Bryan Wu
On Tue, Aug 7, 2012 at 1:28 PM, GShark Jeong gshark.je...@gmail.com wrote:
 Hi Bryan.

 We can replace lm3556 by lm355x code or add lm355x code leaving lm3556.
 Let me know your opinion which one is better.


Sure, I prefer to replace lm3556 by lm355x since your new solution
covers this 2 drivers.

Thanks,
-Bryan


 2012/8/7 Bryan Wu bryan...@canonical.com

 On Wed, Aug 1, 2012 at 8:05 PM, G.Shark Jeong gshark.je...@gmail.com
 wrote:
  From: G.Shark Jeong gshark.je...@gmail.com
 
  LM3554 and LM3556 have similar functions but very different register
  map.
  This driver is a general version for LM355x,lm3554 and lm3556,led chips
  of TI.
  lm3556 driver can be replaced by this driver.
 
  LM3554 :
  The LM3554 is a 2 MHz fixed-frequency synchronous boost
  converter with 1.2A dual high side led drivers.
  Datasheet: www.ti.com/lit/ds/symlink/lm3554.pdf
 
  LM3556 :
  The LM3556 is a 4 MHz fixed-frequency synchronous boost
  converter plus 1.5A constant current driver for a high-current white
  LED.
  Datasheet: www.national.com/ds/LM/LM3556.pdf
 
  Signed-off-by: G.Shark Jeong gshark.je...@gmail.com
  ---

 Thanks, I think basically I'm OK for this patch, just some small
 comments as below.

 -Bryan

   drivers/leds/Kconfig  |8 +-
   drivers/leds/Makefile |2 +-
   drivers/leds/leds-lm355x.c|  529
  +
   include/linux/platform_data/leds-lm355x.h |   66 
   4 files changed, 600 insertions(+), 5 deletions(-)
   create mode 100644 drivers/leds/leds-lm355x.c
   create mode 100644 include/linux/platform_data/leds-lm355x.h
 
  diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
  index c96bbaa..4f6ced2 100644
  --- a/drivers/leds/Kconfig
  +++ b/drivers/leds/Kconfig
  @@ -422,13 +422,13 @@ config LEDS_MAX8997
This option enables support for on-chip LED drivers on
MAXIM MAX8997 PMIC.
 
  -config LEDS_LM3556
  -   tristate LED support for LM3556 Chip
  +config LEDS_LM355x
  +   tristate LED support for LM355x Chips, LM3554 and LM3556
  depends on LEDS_CLASS  I2C
  select REGMAP_I2C
  help
  - This option enables support for LEDs connected to LM3556.
  - LM3556 includes Torch, Flash and Indicator functions.
  + This option enables support for LEDs connected to LM355x.
  + LM355x includes Torch, Flash and Indicator functions.
 
   config LEDS_OT200
  tristate LED support for the Bachmann OT200
  diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
  index a4429a9..b57a021 100644
  --- a/drivers/leds/Makefile
  +++ b/drivers/leds/Makefile
  @@ -48,7 +48,7 @@ obj-$(CONFIG_LEDS_NETXBIG)+=
  leds-netxbig.o
   obj-$(CONFIG_LEDS_ASIC3)   += leds-asic3.o
   obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
   obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
  -obj-$(CONFIG_LEDS_LM3556)  += leds-lm3556.o

 You removed leds-lm3556.o here, but didn't remove the real C file in
 this patchset

  +obj-$(CONFIG_LEDS_LM355x)  += leds-lm355x.o
   obj-$(CONFIG_LEDS_BLINKM)  += leds-blinkm.o
 
   # LED SPI Drivers
  diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
  new file mode 100644
  index 000..5cdbbb4
  --- /dev/null
  +++ b/drivers/leds/leds-lm355x.c
  @@ -0,0 +1,529 @@
  +/*
  +* Simple driver for Texas Instruments LM355x LED Flash driver chip
  +* Copyright (C) 2012 Texas Instruments
  +*
  +* This program is free software; you can redistribute it and/or modify
  +* it under the terms of the GNU General Public License version 2 as
  +* published by the Free Software Foundation.
  +*/
  +
  +#include linux/module.h
  +#include linux/delay.h
  +#include linux/i2c.h
  +#include linux/gpio.h
  +#include linux/leds.h
  +#include linux/slab.h
  +#include linux/platform_device.h
  +#include linux/fs.h
  +#include linux/regmap.h
  +#include linux/platform_data/leds-lm355x.h
  +
  +enum lm355x_type {
  +   CHIP_LM3554 = 0,
  +   CHIP_LM3556,
  +};
  +
  +enum lm355x_regs {
  +   REG_FLAG = 0,
  +   REG_TORCH_CFG,
  +   REG_TORCH_CTRL,
  +   REG_STROBE_CFG,
  +   REG_FLASH_CTRL,
  +   REG_INDI_CFG,
  +   REG_INDI_CTRL,
  +   REG_OPMODE,
  +   REG_MAX,
  +};
  +
  +/* operation mode */
  +enum lm355x_mode {
  +   MODE_SHDN = 0,
  +   MODE_INDIC,
  +   MODE_TORCH,
  +   MODE_FLASH
  +};
  +
  +/* register map info. */
  +struct lm355x_reg_data {
  +   u8 regno;
  +   u8 mask;
  +   u8 shift;
  +};
  +
  +struct lm355x_chip_data {
  +   struct device *dev;
  +   enum lm355x_type type;
  +
  +   struct led_classdev cdev_flash;
  +   struct led_classdev cdev_torch;
  +   struct led_classdev cdev_indicator;
  +
  +   struct lm355x_platform_data *pdata;
  +   struct regmap *regmap;
  +   struct mutex lock;
  +
  +   unsigned int 

Re: [PATCH 1/1] leds: Add LED driver for lm355x chips

2012-08-06 Thread Bryan Wu
On Wed, Aug 1, 2012 at 8:05 PM, G.Shark Jeong  wrote:
> From: "G.Shark Jeong" 
>
> LM3554 and LM3556 have similar functions but very different register map.
> This driver is a general version for LM355x,lm3554 and lm3556,led chips of TI.
> lm3556 driver can be replaced by this driver.
>
> LM3554 :
> The LM3554 is a 2 MHz fixed-frequency synchronous boost
> converter with 1.2A dual high side led drivers.
> Datasheet: www.ti.com/lit/ds/symlink/lm3554.pdf
>
> LM3556 :
> The LM3556 is a 4 MHz fixed-frequency synchronous boost
> converter plus 1.5A constant current driver for a high-current white LED.
> Datasheet: www.national.com/ds/LM/LM3556.pdf
>
> Signed-off-by: G.Shark Jeong 
> ---

Thanks, I think basically I'm OK for this patch, just some small
comments as below.

-Bryan

>  drivers/leds/Kconfig  |8 +-
>  drivers/leds/Makefile |2 +-
>  drivers/leds/leds-lm355x.c|  529 
> +
>  include/linux/platform_data/leds-lm355x.h |   66 
>  4 files changed, 600 insertions(+), 5 deletions(-)
>  create mode 100644 drivers/leds/leds-lm355x.c
>  create mode 100644 include/linux/platform_data/leds-lm355x.h
>
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index c96bbaa..4f6ced2 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -422,13 +422,13 @@ config LEDS_MAX8997
>   This option enables support for on-chip LED drivers on
>   MAXIM MAX8997 PMIC.
>
> -config LEDS_LM3556
> -   tristate "LED support for LM3556 Chip"
> +config LEDS_LM355x
> +   tristate "LED support for LM355x Chips, LM3554 and LM3556"
> depends on LEDS_CLASS && I2C
> select REGMAP_I2C
> help
> - This option enables support for LEDs connected to LM3556.
> - LM3556 includes Torch, Flash and Indicator functions.
> + This option enables support for LEDs connected to LM355x.
> + LM355x includes Torch, Flash and Indicator functions.
>
>  config LEDS_OT200
> tristate "LED support for the Bachmann OT200"
> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> index a4429a9..b57a021 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile
> @@ -48,7 +48,7 @@ obj-$(CONFIG_LEDS_NETXBIG)+= leds-netxbig.o
>  obj-$(CONFIG_LEDS_ASIC3)   += leds-asic3.o
>  obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
>  obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
> -obj-$(CONFIG_LEDS_LM3556)  += leds-lm3556.o

You removed leds-lm3556.o here, but didn't remove the real C file in
this patchset

> +obj-$(CONFIG_LEDS_LM355x)  += leds-lm355x.o
>  obj-$(CONFIG_LEDS_BLINKM)  += leds-blinkm.o
>
>  # LED SPI Drivers
> diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
> new file mode 100644
> index 000..5cdbbb4
> --- /dev/null
> +++ b/drivers/leds/leds-lm355x.c
> @@ -0,0 +1,529 @@
> +/*
> +* Simple driver for Texas Instruments LM355x LED Flash driver chip
> +* Copyright (C) 2012 Texas Instruments
> +*
> +* This program is free software; you can redistribute it and/or modify
> +* it under the terms of the GNU General Public License version 2 as
> +* published by the Free Software Foundation.
> +*/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +enum lm355x_type {
> +   CHIP_LM3554 = 0,
> +   CHIP_LM3556,
> +};
> +
> +enum lm355x_regs {
> +   REG_FLAG = 0,
> +   REG_TORCH_CFG,
> +   REG_TORCH_CTRL,
> +   REG_STROBE_CFG,
> +   REG_FLASH_CTRL,
> +   REG_INDI_CFG,
> +   REG_INDI_CTRL,
> +   REG_OPMODE,
> +   REG_MAX,
> +};
> +
> +/* operation mode */
> +enum lm355x_mode {
> +   MODE_SHDN = 0,
> +   MODE_INDIC,
> +   MODE_TORCH,
> +   MODE_FLASH
> +};
> +
> +/* register map info. */
> +struct lm355x_reg_data {
> +   u8 regno;
> +   u8 mask;
> +   u8 shift;
> +};
> +
> +struct lm355x_chip_data {
> +   struct device *dev;
> +   enum lm355x_type type;
> +
> +   struct led_classdev cdev_flash;
> +   struct led_classdev cdev_torch;
> +   struct led_classdev cdev_indicator;
> +
> +   struct lm355x_platform_data *pdata;
> +   struct regmap *regmap;
> +   struct mutex lock;
> +
> +   unsigned int last_flag;
> +   struct lm355x_reg_data *regs;
> +};
> +
> +/* specific indicator function for lm3556 */
> +enum lm3556_indic_pulse_time {
> +   PULSE_TIME_0_MS = 0,
> +   PULSE_TIME_32_MS,
> +   PULSE_TIME_64_MS,
> +   PULSE_TIME_92_MS,
> +   PULSE_TIME_128_MS,
> +   PULSE_TIME_160_MS,
> +   PULSE_TIME_196_MS,
> +   PULSE_TIME_224_MS,
> +   PULSE_TIME_256_MS,
> +   PULSE_TIME_288_MS,
> +   PULSE_TIME_320_MS,
> +   PULSE_TIME_352_MS,
> +   PULSE_TIME_384_MS,
> +   PULSE_TIME_416_MS,
> +   PULSE_TIME_448_MS,
> +   

Re: [PATCH 1/1] leds: Add LED driver for lm355x chips

2012-08-06 Thread Bryan Wu
On Wed, Aug 1, 2012 at 8:05 PM, G.Shark Jeong gshark.je...@gmail.com wrote:
 From: G.Shark Jeong gshark.je...@gmail.com

 LM3554 and LM3556 have similar functions but very different register map.
 This driver is a general version for LM355x,lm3554 and lm3556,led chips of TI.
 lm3556 driver can be replaced by this driver.

 LM3554 :
 The LM3554 is a 2 MHz fixed-frequency synchronous boost
 converter with 1.2A dual high side led drivers.
 Datasheet: www.ti.com/lit/ds/symlink/lm3554.pdf

 LM3556 :
 The LM3556 is a 4 MHz fixed-frequency synchronous boost
 converter plus 1.5A constant current driver for a high-current white LED.
 Datasheet: www.national.com/ds/LM/LM3556.pdf

 Signed-off-by: G.Shark Jeong gshark.je...@gmail.com
 ---

Thanks, I think basically I'm OK for this patch, just some small
comments as below.

-Bryan

  drivers/leds/Kconfig  |8 +-
  drivers/leds/Makefile |2 +-
  drivers/leds/leds-lm355x.c|  529 
 +
  include/linux/platform_data/leds-lm355x.h |   66 
  4 files changed, 600 insertions(+), 5 deletions(-)
  create mode 100644 drivers/leds/leds-lm355x.c
  create mode 100644 include/linux/platform_data/leds-lm355x.h

 diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
 index c96bbaa..4f6ced2 100644
 --- a/drivers/leds/Kconfig
 +++ b/drivers/leds/Kconfig
 @@ -422,13 +422,13 @@ config LEDS_MAX8997
   This option enables support for on-chip LED drivers on
   MAXIM MAX8997 PMIC.

 -config LEDS_LM3556
 -   tristate LED support for LM3556 Chip
 +config LEDS_LM355x
 +   tristate LED support for LM355x Chips, LM3554 and LM3556
 depends on LEDS_CLASS  I2C
 select REGMAP_I2C
 help
 - This option enables support for LEDs connected to LM3556.
 - LM3556 includes Torch, Flash and Indicator functions.
 + This option enables support for LEDs connected to LM355x.
 + LM355x includes Torch, Flash and Indicator functions.

  config LEDS_OT200
 tristate LED support for the Bachmann OT200
 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
 index a4429a9..b57a021 100644
 --- a/drivers/leds/Makefile
 +++ b/drivers/leds/Makefile
 @@ -48,7 +48,7 @@ obj-$(CONFIG_LEDS_NETXBIG)+= leds-netxbig.o
  obj-$(CONFIG_LEDS_ASIC3)   += leds-asic3.o
  obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
  obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
 -obj-$(CONFIG_LEDS_LM3556)  += leds-lm3556.o

You removed leds-lm3556.o here, but didn't remove the real C file in
this patchset

 +obj-$(CONFIG_LEDS_LM355x)  += leds-lm355x.o
  obj-$(CONFIG_LEDS_BLINKM)  += leds-blinkm.o

  # LED SPI Drivers
 diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
 new file mode 100644
 index 000..5cdbbb4
 --- /dev/null
 +++ b/drivers/leds/leds-lm355x.c
 @@ -0,0 +1,529 @@
 +/*
 +* Simple driver for Texas Instruments LM355x LED Flash driver chip
 +* Copyright (C) 2012 Texas Instruments
 +*
 +* This program is free software; you can redistribute it and/or modify
 +* it under the terms of the GNU General Public License version 2 as
 +* published by the Free Software Foundation.
 +*/
 +
 +#include linux/module.h
 +#include linux/delay.h
 +#include linux/i2c.h
 +#include linux/gpio.h
 +#include linux/leds.h
 +#include linux/slab.h
 +#include linux/platform_device.h
 +#include linux/fs.h
 +#include linux/regmap.h
 +#include linux/platform_data/leds-lm355x.h
 +
 +enum lm355x_type {
 +   CHIP_LM3554 = 0,
 +   CHIP_LM3556,
 +};
 +
 +enum lm355x_regs {
 +   REG_FLAG = 0,
 +   REG_TORCH_CFG,
 +   REG_TORCH_CTRL,
 +   REG_STROBE_CFG,
 +   REG_FLASH_CTRL,
 +   REG_INDI_CFG,
 +   REG_INDI_CTRL,
 +   REG_OPMODE,
 +   REG_MAX,
 +};
 +
 +/* operation mode */
 +enum lm355x_mode {
 +   MODE_SHDN = 0,
 +   MODE_INDIC,
 +   MODE_TORCH,
 +   MODE_FLASH
 +};
 +
 +/* register map info. */
 +struct lm355x_reg_data {
 +   u8 regno;
 +   u8 mask;
 +   u8 shift;
 +};
 +
 +struct lm355x_chip_data {
 +   struct device *dev;
 +   enum lm355x_type type;
 +
 +   struct led_classdev cdev_flash;
 +   struct led_classdev cdev_torch;
 +   struct led_classdev cdev_indicator;
 +
 +   struct lm355x_platform_data *pdata;
 +   struct regmap *regmap;
 +   struct mutex lock;
 +
 +   unsigned int last_flag;
 +   struct lm355x_reg_data *regs;
 +};
 +
 +/* specific indicator function for lm3556 */
 +enum lm3556_indic_pulse_time {
 +   PULSE_TIME_0_MS = 0,
 +   PULSE_TIME_32_MS,
 +   PULSE_TIME_64_MS,
 +   PULSE_TIME_92_MS,
 +   PULSE_TIME_128_MS,
 +   PULSE_TIME_160_MS,
 +   PULSE_TIME_196_MS,
 +   PULSE_TIME_224_MS,
 +   PULSE_TIME_256_MS,
 +   PULSE_TIME_288_MS,
 +   PULSE_TIME_320_MS,
 +   PULSE_TIME_352_MS,
 +   PULSE_TIME_384_MS,
 +   

[PATCH 1/1] leds: Add LED driver for lm355x chips

2012-08-01 Thread G.Shark Jeong
From: "G.Shark Jeong" 

LM3554 and LM3556 have similar functions but very different register map.
This driver is a general version for LM355x,lm3554 and lm3556,led chips of TI.
lm3556 driver can be replaced by this driver.

LM3554 :
The LM3554 is a 2 MHz fixed-frequency synchronous boost
converter with 1.2A dual high side led drivers.
Datasheet: www.ti.com/lit/ds/symlink/lm3554.pdf

LM3556 :
The LM3556 is a 4 MHz fixed-frequency synchronous boost
converter plus 1.5A constant current driver for a high-current white LED.
Datasheet: www.national.com/ds/LM/LM3556.pdf

Signed-off-by: G.Shark Jeong 
---
 drivers/leds/Kconfig  |8 +-
 drivers/leds/Makefile |2 +-
 drivers/leds/leds-lm355x.c|  529 +
 include/linux/platform_data/leds-lm355x.h |   66 
 4 files changed, 600 insertions(+), 5 deletions(-)
 create mode 100644 drivers/leds/leds-lm355x.c
 create mode 100644 include/linux/platform_data/leds-lm355x.h

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index c96bbaa..4f6ced2 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -422,13 +422,13 @@ config LEDS_MAX8997
  This option enables support for on-chip LED drivers on
  MAXIM MAX8997 PMIC.
 
-config LEDS_LM3556
-   tristate "LED support for LM3556 Chip"
+config LEDS_LM355x
+   tristate "LED support for LM355x Chips, LM3554 and LM3556"
depends on LEDS_CLASS && I2C
select REGMAP_I2C
help
- This option enables support for LEDs connected to LM3556.
- LM3556 includes Torch, Flash and Indicator functions.
+ This option enables support for LEDs connected to LM355x.
+ LM355x includes Torch, Flash and Indicator functions.
 
 config LEDS_OT200
tristate "LED support for the Bachmann OT200"
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index a4429a9..b57a021 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -48,7 +48,7 @@ obj-$(CONFIG_LEDS_NETXBIG)+= leds-netxbig.o
 obj-$(CONFIG_LEDS_ASIC3)   += leds-asic3.o
 obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
 obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
-obj-$(CONFIG_LEDS_LM3556)  += leds-lm3556.o
+obj-$(CONFIG_LEDS_LM355x)  += leds-lm355x.o
 obj-$(CONFIG_LEDS_BLINKM)  += leds-blinkm.o
 
 # LED SPI Drivers
diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
new file mode 100644
index 000..5cdbbb4
--- /dev/null
+++ b/drivers/leds/leds-lm355x.c
@@ -0,0 +1,529 @@
+/*
+* Simple driver for Texas Instruments LM355x LED Flash driver chip
+* Copyright (C) 2012 Texas Instruments
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+enum lm355x_type {
+   CHIP_LM3554 = 0,
+   CHIP_LM3556,
+};
+
+enum lm355x_regs {
+   REG_FLAG = 0,
+   REG_TORCH_CFG,
+   REG_TORCH_CTRL,
+   REG_STROBE_CFG,
+   REG_FLASH_CTRL,
+   REG_INDI_CFG,
+   REG_INDI_CTRL,
+   REG_OPMODE,
+   REG_MAX,
+};
+
+/* operation mode */
+enum lm355x_mode {
+   MODE_SHDN = 0,
+   MODE_INDIC,
+   MODE_TORCH,
+   MODE_FLASH
+};
+
+/* register map info. */
+struct lm355x_reg_data {
+   u8 regno;
+   u8 mask;
+   u8 shift;
+};
+
+struct lm355x_chip_data {
+   struct device *dev;
+   enum lm355x_type type;
+
+   struct led_classdev cdev_flash;
+   struct led_classdev cdev_torch;
+   struct led_classdev cdev_indicator;
+
+   struct lm355x_platform_data *pdata;
+   struct regmap *regmap;
+   struct mutex lock;
+
+   unsigned int last_flag;
+   struct lm355x_reg_data *regs;
+};
+
+/* specific indicator function for lm3556 */
+enum lm3556_indic_pulse_time {
+   PULSE_TIME_0_MS = 0,
+   PULSE_TIME_32_MS,
+   PULSE_TIME_64_MS,
+   PULSE_TIME_92_MS,
+   PULSE_TIME_128_MS,
+   PULSE_TIME_160_MS,
+   PULSE_TIME_196_MS,
+   PULSE_TIME_224_MS,
+   PULSE_TIME_256_MS,
+   PULSE_TIME_288_MS,
+   PULSE_TIME_320_MS,
+   PULSE_TIME_352_MS,
+   PULSE_TIME_384_MS,
+   PULSE_TIME_416_MS,
+   PULSE_TIME_448_MS,
+   PULSE_TIME_480_MS,
+};
+
+enum lm3556_indic_n_blank {
+   INDIC_N_BLANK_0 = 0,
+   INDIC_N_BLANK_1,
+   INDIC_N_BLANK_2,
+   INDIC_N_BLANK_3,
+   INDIC_N_BLANK_4,
+   INDIC_N_BLANK_5,
+   INDIC_N_BLANK_6,
+   INDIC_N_BLANK_7,
+   INDIC_N_BLANK_8,
+   INDIC_N_BLANK_9,
+   INDIC_N_BLANK_10,
+   INDIC_N_BLANK_11,
+   INDIC_N_BLANK_12,
+   INDIC_N_BLANK_13,
+   INDIC_N_BLANK_14,
+   INDIC_N_BLANK_15,
+};
+
+enum lm3556_indic_period {
+   INDIC_PERIOD_0 = 0,
+   

[PATCH 1/1] leds: Add LED driver for lm355x chips

2012-08-01 Thread G.Shark Jeong
From: G.Shark Jeong gshark.je...@gmail.com

LM3554 and LM3556 have similar functions but very different register map.
This driver is a general version for LM355x,lm3554 and lm3556,led chips of TI.
lm3556 driver can be replaced by this driver.

LM3554 :
The LM3554 is a 2 MHz fixed-frequency synchronous boost
converter with 1.2A dual high side led drivers.
Datasheet: www.ti.com/lit/ds/symlink/lm3554.pdf

LM3556 :
The LM3556 is a 4 MHz fixed-frequency synchronous boost
converter plus 1.5A constant current driver for a high-current white LED.
Datasheet: www.national.com/ds/LM/LM3556.pdf

Signed-off-by: G.Shark Jeong gshark.je...@gmail.com
---
 drivers/leds/Kconfig  |8 +-
 drivers/leds/Makefile |2 +-
 drivers/leds/leds-lm355x.c|  529 +
 include/linux/platform_data/leds-lm355x.h |   66 
 4 files changed, 600 insertions(+), 5 deletions(-)
 create mode 100644 drivers/leds/leds-lm355x.c
 create mode 100644 include/linux/platform_data/leds-lm355x.h

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index c96bbaa..4f6ced2 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -422,13 +422,13 @@ config LEDS_MAX8997
  This option enables support for on-chip LED drivers on
  MAXIM MAX8997 PMIC.
 
-config LEDS_LM3556
-   tristate LED support for LM3556 Chip
+config LEDS_LM355x
+   tristate LED support for LM355x Chips, LM3554 and LM3556
depends on LEDS_CLASS  I2C
select REGMAP_I2C
help
- This option enables support for LEDs connected to LM3556.
- LM3556 includes Torch, Flash and Indicator functions.
+ This option enables support for LEDs connected to LM355x.
+ LM355x includes Torch, Flash and Indicator functions.
 
 config LEDS_OT200
tristate LED support for the Bachmann OT200
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index a4429a9..b57a021 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -48,7 +48,7 @@ obj-$(CONFIG_LEDS_NETXBIG)+= leds-netxbig.o
 obj-$(CONFIG_LEDS_ASIC3)   += leds-asic3.o
 obj-$(CONFIG_LEDS_RENESAS_TPU) += leds-renesas-tpu.o
 obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o
-obj-$(CONFIG_LEDS_LM3556)  += leds-lm3556.o
+obj-$(CONFIG_LEDS_LM355x)  += leds-lm355x.o
 obj-$(CONFIG_LEDS_BLINKM)  += leds-blinkm.o
 
 # LED SPI Drivers
diff --git a/drivers/leds/leds-lm355x.c b/drivers/leds/leds-lm355x.c
new file mode 100644
index 000..5cdbbb4
--- /dev/null
+++ b/drivers/leds/leds-lm355x.c
@@ -0,0 +1,529 @@
+/*
+* Simple driver for Texas Instruments LM355x LED Flash driver chip
+* Copyright (C) 2012 Texas Instruments
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*/
+
+#include linux/module.h
+#include linux/delay.h
+#include linux/i2c.h
+#include linux/gpio.h
+#include linux/leds.h
+#include linux/slab.h
+#include linux/platform_device.h
+#include linux/fs.h
+#include linux/regmap.h
+#include linux/platform_data/leds-lm355x.h
+
+enum lm355x_type {
+   CHIP_LM3554 = 0,
+   CHIP_LM3556,
+};
+
+enum lm355x_regs {
+   REG_FLAG = 0,
+   REG_TORCH_CFG,
+   REG_TORCH_CTRL,
+   REG_STROBE_CFG,
+   REG_FLASH_CTRL,
+   REG_INDI_CFG,
+   REG_INDI_CTRL,
+   REG_OPMODE,
+   REG_MAX,
+};
+
+/* operation mode */
+enum lm355x_mode {
+   MODE_SHDN = 0,
+   MODE_INDIC,
+   MODE_TORCH,
+   MODE_FLASH
+};
+
+/* register map info. */
+struct lm355x_reg_data {
+   u8 regno;
+   u8 mask;
+   u8 shift;
+};
+
+struct lm355x_chip_data {
+   struct device *dev;
+   enum lm355x_type type;
+
+   struct led_classdev cdev_flash;
+   struct led_classdev cdev_torch;
+   struct led_classdev cdev_indicator;
+
+   struct lm355x_platform_data *pdata;
+   struct regmap *regmap;
+   struct mutex lock;
+
+   unsigned int last_flag;
+   struct lm355x_reg_data *regs;
+};
+
+/* specific indicator function for lm3556 */
+enum lm3556_indic_pulse_time {
+   PULSE_TIME_0_MS = 0,
+   PULSE_TIME_32_MS,
+   PULSE_TIME_64_MS,
+   PULSE_TIME_92_MS,
+   PULSE_TIME_128_MS,
+   PULSE_TIME_160_MS,
+   PULSE_TIME_196_MS,
+   PULSE_TIME_224_MS,
+   PULSE_TIME_256_MS,
+   PULSE_TIME_288_MS,
+   PULSE_TIME_320_MS,
+   PULSE_TIME_352_MS,
+   PULSE_TIME_384_MS,
+   PULSE_TIME_416_MS,
+   PULSE_TIME_448_MS,
+   PULSE_TIME_480_MS,
+};
+
+enum lm3556_indic_n_blank {
+   INDIC_N_BLANK_0 = 0,
+   INDIC_N_BLANK_1,
+   INDIC_N_BLANK_2,
+   INDIC_N_BLANK_3,
+   INDIC_N_BLANK_4,
+   INDIC_N_BLANK_5,
+   INDIC_N_BLANK_6,
+   INDIC_N_BLANK_7,
+   INDIC_N_BLANK_8,
+   INDIC_N_BLANK_9,
+   INDIC_N_BLANK_10,
+