Re: [PATCH v6 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, On 2015년 11월 30일 19:59, Jacek Anaszewski wrote: > Hi Ingi, > > On 11/30/2015 03:31 AM, Ingi Kim wrote: >> Hi Jacek, >> >> On 2015년 11월 26일 18:43, Jacek Anaszewski wrote: >>> Hi Ingi, >>> >>> On 11/26/2015 09:02 AM, Ingi Kim wrote: >>> [...] >>>>>> +torch_unlock: >>>>>> +mutex_unlock(&led->lock); >>>>>> +return ret; >>>>>> +} >>>>>> + >>>>>> +static int rt5033_led_flash_brightness_set(struct led_classdev_flash >>>>>> *fled_cdev, >>>>>> + u32 brightness) >>>>>> +{ >>>>>> +struct rt5033_sub_led *sub_led = flcdev_to_sub_led(fled_cdev); >>>>>> +struct rt5033_led *led = sub_led_to_led(sub_led); >>>>>> + >>>>>> +mutex_lock(&led->lock); >>>>>> +sub_led->flash_brightness = brightness; >>>>>> +mutex_unlock(&led->lock); >>>>> >>>>> Mutex protection is redundant in this case. You would need it if device >>>>> state was also changed here. >>>> >>>> Okay, I'll remove it. >>>> >>>>> >>>>> BTW why flash brightness can't be written to the device here? >>>>> >>>> >>>> Flash brightness is only affected when FLED flashed (strobing). >>>> So, I think it is better to be written in rt5033_led_flash_strobe_set >>>> function. >>> >>> strobe_set op should strobe the flash ASAP, and delegating brightness >>> setting there extends a delay between calling strobe_set op >>> and actual flash strobe. If you set the brightness here, then you >>> wouldn't have to do that in the strobe_set op, of course unless the >>> the brightness is altered through the API of the other LED, in two >>> separate LEDs case. >>> >> >> The brightness may be able to change its brightness in two separate LEDs >> case as you see. >> So, I think it would be better to write brightness setting in strobe_op. > > Could you motivate your statement, please? Why would it be better? > >> In consideration of delay, of course, the brightness is set just when it >> would be changed. > > I think that joint iout arrangement will be prevailing - this is the > case for your board, isn't it? With the modification I am proposing > the gain is clear. > You're right, thanks. Did you mean that flash attributes should be written on their ops(flash brightness, flash timeout)? let me update the driver on your suggestion. >>>>>> + >>>>>> +return 0; >>>>>> +} >>>>>> + >>>>>> +static int rt5033_led_flash_timeout_set(struct led_classdev_flash >>>>>> *fled_cdev, >>>>>> +u32 timeout) >>>>>> +{ >>>>>> +struct rt5033_sub_led *sub_led = flcdev_to_sub_led(fled_cdev); >>>>>> +struct rt5033_led *led = sub_led_to_led(sub_led); >>>>>> + >>>>>> +mutex_lock(&led->lock); >>>>>> +sub_led->flash_timeout = timeout; >>>>>> +mutex_unlock(&led->lock); >>>>> >>>>> Ditto. >>>>> >>> >>> Timeout should be also written here. >>> >> >> The timeout may be able to change its flash timeout in two separate LEDs >> case as you see. >> So, I think it would be better to write timeout setting in strobe_op. >> In consideration of delay, of course, the timeout is set just when it would >> be changed. >> >>> If you will add regmap_write in both ops, then mutex protection will >>> have to be preserved, to assure consistency between registers state >>> and sub_led->flash_brightness and sub_led->flash_timeout state. >>> >> >> Thanks, but mutex protection is useless in this case. >> so I try to remove it. >> >>>> >>>>>> +#define RT5033_FLED_CTRL4_VTRREG_MAX0x60 >>>>> >>>>> Rename DEF to MASK. >>> >>> Hmm, here it should be: Rename MAX to MASK. >>> >> >> Oh >> Okay, Thanks :) >> > > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hi, Lee Thanks to the review, I'll carry your Ack when I reflect Jacek's comment. On 2015년 11월 26일 18:11, Lee Jones wrote: > On Wed, 25 Nov 2015, Ingi Kim wrote: > >> This patch adds device driver of Richtek RT5033 PMIC. >> The RT5033 Flash LED Circuit is designed for one or two LEDs driving >> for torch and strobe applications, it provides an I2C software command >> to trigger the torch and strobe operation. >> >> Each of LED outputs can contorl a separate LED sharing their setting, >> and can be connected together for a single connected LED. >> One LED is represented by one child node. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig | 8 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-rt5033.c | 541 >> + >> include/linux/mfd/rt5033-private.h | 51 > > Acked-by: Lee Jones > >> 4 files changed, 601 insertions(+) >> create mode 100644 drivers/leds/leds-rt5033.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index b1ab8bd..f41ac9b 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -345,6 +345,14 @@ config LEDS_PCA963X >>LED driver chip accessed via the I2C bus. Supported >>devices include PCA9633 and PCA9634 >> >> +config LEDS_RT5033 >> +tristate "LED support for RT5033 PMIC" >> +depends on LEDS_CLASS_FLASH && OF >> +depends on MFD_RT5033 >> +help >> + This option enables support for on-chip LED driver on >> + RT5033 PMIC. >> + >> config LEDS_WM831X_STATUS >> tristate "LED support for status LEDs on WM831x PMICs" >> depends on LEDS_CLASS >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index e9d53092..77cfad5 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE) += >> leds-cobalt-qube.o >> obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o >> obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o >> obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o >> +obj-$(CONFIG_LEDS_RT5033) += leds-rt5033.o >> obj-$(CONFIG_LEDS_GPIO_REGISTER)+= leds-gpio-register.o >> obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o >> obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o >> diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c >> new file mode 100644 >> index 000..256df74 >> --- /dev/null >> +++ b/drivers/leds/leds-rt5033.c >> @@ -0,0 +1,541 @@ >> +/* >> + * led driver for RT5033 >> + * >> + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. >> + * Ingi Kim >> + * >> + * 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 >> + >> +#define RT5033_LED_FLASH_TIMEOUT_MIN64000 >> +#define RT5033_LED_FLASH_TIMEOUT_STEP 32000 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MIN 5 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_1CH 60 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_2CH 80 >> +#define RT5033_LED_FLASH_BRIGHTNESS_STEP25000 >> +#define RT5033_LED_TORCH_BRIGHTNESS_MIN 12500 >> +#define RT5033_LED_TORCH_BRIGHTNESS_STEP12500 >> + >> +#define FLED1_IOUT (BIT(0)) >> +#define FLED2_IOUT (BIT(1)) >> + >> +enum rt5033_fled { >> +FLED1, >> +FLED2, >> +}; >> + >> +struct rt5033_sub_led { >> +enum rt5033_fled fled_id; >> +struct led_classdev_flash fled_cdev; >> + >> +u32 flash_brightness; >> +u32 flash_timeout; >> +}; >> + >> +/* RT5033 Flash led platform data */ >> +struct rt5033_led { >> +struct device *dev; >> +struct mutex lock; >> +struct regmap *regmap; >> +struct rt5033_sub_led sub_leds[2]; >> + >> +u32 current_flash_timeout; >> +u32 current_flash_brightness; >> + >> +bool iout_joint; >> +u8 fled_mask; >> +u8 current_iout; >> +}; >> + >> +struct rt5033_led_config_data { >> +const char *label[2]; >> +u32 flash_m
Re: [PATCH v6 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, On 2015년 11월 26일 18:43, Jacek Anaszewski wrote: > Hi Ingi, > > On 11/26/2015 09:02 AM, Ingi Kim wrote: > [...] >>>> +torch_unlock: >>>> +mutex_unlock(&led->lock); >>>> +return ret; >>>> +} >>>> + >>>> +static int rt5033_led_flash_brightness_set(struct led_classdev_flash >>>> *fled_cdev, >>>> + u32 brightness) >>>> +{ >>>> +struct rt5033_sub_led *sub_led = flcdev_to_sub_led(fled_cdev); >>>> +struct rt5033_led *led = sub_led_to_led(sub_led); >>>> + >>>> +mutex_lock(&led->lock); >>>> +sub_led->flash_brightness = brightness; >>>> +mutex_unlock(&led->lock); >>> >>> Mutex protection is redundant in this case. You would need it if device >>> state was also changed here. >> >> Okay, I'll remove it. >> >>> >>> BTW why flash brightness can't be written to the device here? >>> >> >> Flash brightness is only affected when FLED flashed (strobing). >> So, I think it is better to be written in rt5033_led_flash_strobe_set >> function. > > strobe_set op should strobe the flash ASAP, and delegating brightness > setting there extends a delay between calling strobe_set op > and actual flash strobe. If you set the brightness here, then you > wouldn't have to do that in the strobe_set op, of course unless the > the brightness is altered through the API of the other LED, in two > separate LEDs case. > The brightness may be able to change its brightness in two separate LEDs case as you see. So, I think it would be better to write brightness setting in strobe_op. In consideration of delay, of course, the brightness is set just when it would be changed. >>>> + >>>> +return 0; >>>> +} >>>> + >>>> +static int rt5033_led_flash_timeout_set(struct led_classdev_flash >>>> *fled_cdev, >>>> +u32 timeout) >>>> +{ >>>> +struct rt5033_sub_led *sub_led = flcdev_to_sub_led(fled_cdev); >>>> +struct rt5033_led *led = sub_led_to_led(sub_led); >>>> + >>>> +mutex_lock(&led->lock); >>>> +sub_led->flash_timeout = timeout; >>>> +mutex_unlock(&led->lock); >>> >>> Ditto. >>> > > Timeout should be also written here. > The timeout may be able to change its flash timeout in two separate LEDs case as you see. So, I think it would be better to write timeout setting in strobe_op. In consideration of delay, of course, the timeout is set just when it would be changed. > If you will add regmap_write in both ops, then mutex protection will > have to be preserved, to assure consistency between registers state > and sub_led->flash_brightness and sub_led->flash_timeout state. > Thanks, but mutex protection is useless in this case. so I try to remove it. >> >>>> +#define RT5033_FLED_CTRL4_VTRREG_MAX0x60 >>> >>> Rename DEF to MASK. > > Hmm, here it should be: Rename MAX to MASK. > Oh Okay, Thanks :) -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, Thanks for the review. On 2015년 11월 26일 00:13, Jacek Anaszewski wrote: > Hi Ingi, > > Thanks for the update. > > On 11/25/2015 11:22 AM, Ingi Kim wrote: >> This patch adds device driver of Richtek RT5033 PMIC. >> The RT5033 Flash LED Circuit is designed for one or two LEDs driving >> for torch and strobe applications, it provides an I2C software command >> to trigger the torch and strobe operation. >> >> Each of LED outputs can contorl a separate LED sharing their setting, > > s/contorl/control/ > Oh, I see, Thanks >> and can be connected together for a single connected LED. >> One LED is represented by one child node. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig | 8 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-rt5033.c | 541 >> + >> include/linux/mfd/rt5033-private.h | 51 >> 4 files changed, 601 insertions(+) >> create mode 100644 drivers/leds/leds-rt5033.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index b1ab8bd..f41ac9b 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -345,6 +345,14 @@ config LEDS_PCA963X >> LED driver chip accessed via the I2C bus. Supported >> devices include PCA9633 and PCA9634 >> >> +config LEDS_RT5033 >> +tristate "LED support for RT5033 PMIC" >> +depends on LEDS_CLASS_FLASH && OF >> +depends on MFD_RT5033 >> +help >> + This option enables support for on-chip LED driver on >> + RT5033 PMIC. >> + >> config LEDS_WM831X_STATUS >> tristate "LED support for status LEDs on WM831x PMICs" >> depends on LEDS_CLASS >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index e9d53092..77cfad5 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o >> obj-$(CONFIG_LEDS_COBALT_RAQ)+= leds-cobalt-raq.o >> obj-$(CONFIG_LEDS_SUNFIRE)+= leds-sunfire.o >> obj-$(CONFIG_LEDS_PCA9532)+= leds-pca9532.o >> +obj-$(CONFIG_LEDS_RT5033)+= leds-rt5033.o >> obj-$(CONFIG_LEDS_GPIO_REGISTER)+= leds-gpio-register.o >> obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o >> obj-$(CONFIG_LEDS_LP3944)+= leds-lp3944.o >> diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c >> new file mode 100644 >> index 000..256df74 >> --- /dev/null >> +++ b/drivers/leds/leds-rt5033.c >> @@ -0,0 +1,541 @@ >> +/* >> + * led driver for RT5033 >> + * >> + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. >> + * Ingi Kim >> + * >> + * 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 >> + >> +#define RT5033_LED_FLASH_TIMEOUT_MIN64000 >> +#define RT5033_LED_FLASH_TIMEOUT_STEP32000 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_1CH60 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_2CH80 >> +#define RT5033_LED_FLASH_BRIGHTNESS_STEP25000 >> +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 >> +#define RT5033_LED_TORCH_BRIGHTNESS_STEP12500 >> + >> +#define FLED1_IOUT(BIT(0)) >> +#define FLED2_IOUT(BIT(1)) >> + >> +enum rt5033_fled { >> +FLED1, >> +FLED2, >> +}; >> + >> +struct rt5033_sub_led { >> +enum rt5033_fled fled_id; >> +struct led_classdev_flash fled_cdev; >> + >> +u32 flash_brightness; >> +u32 flash_timeout; >> +}; >> + >> +/* RT5033 Flash led platform data */ >> +struct rt5033_led { >> +struct device *dev; >> +struct mutex lock; >> +struct regmap *regmap; >> +struct rt5033_sub_led sub_leds[2]; >> + >> +u32 current_flash_timeout; >> +u32 current_flash_brightness; >> + >> +bool iout_joint; >> +u8 fled_mask; >> +u8 current_iout; >> +}; >> + >> +struct rt5033_led_config_data { >> +const char *label[2]; >> +u32 flash_max_microamp[2]; >> +u32
[PATCH v6 0/2] Add RT5033 Flash LED driver
This is a sixth version of the patch set to support RT5033 Flash Led. It is based on RFC [1] from Jacek's patch set. Changes since v6: - Make functions to convert from LED config data to register value - Add variables to save LED config data in rt5033_led struct - Rename some functions suitably - Change to set register of flash brightness / timeout when it was changed. Changes since v5: - Rebase on Jacek's devel branch git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git - Remove work queue from driver. - Change brightness_set_sync ops to brightness_set_blocking ops. - Remove "iout_torch_max" and "iout_flash_max" values in rt5033_led struct. - Add missed case for distinguishing between setting brightness. for iout_joint case and for individual LEDs. - Add missed mutex_lock. - Remove guard to check dev->of_node. - Change type of value to const __be32 to get return value of of_find_property. Changes since v4: - Use of_node_put() when DT parse miss - Move struct(rt5033_led) from include/linux/mfd/rt5033.h to local driver/leds/leds-rt5033.c - Remove MODULE_DEVICE_TABLE - Add interface to handle two LEDs. Changes since v3: - Use mutex and work queue - Split brightness set func (sync / async) - Add flash API (flash_brightness_set) - Move struct(rt5033_led_config_data) to local area - Code clean Changes since v2: - Split MFC code from rt5033 flash led patch - Fix typo error - Change naming of mfd register back again - Fix compile error Original cover letter: This patch supports flash led of RT5033 PMIC. [1] https://lkml.org/lkml/2015/8/20/426 Ingi Kim (2): leds: rt5033: Add DT binding for RT5033 leds: rt5033: Add RT5033 Flash led device driver .../devicetree/bindings/leds/leds-rt5033.txt | 46 ++ drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 541 + include/linux/mfd/rt5033-private.h | 51 ++ 5 files changed, 647 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt create mode 100644 drivers/leds/leds-rt5033.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v6 2/2] leds: rt5033: Add RT5033 Flash led device driver
This patch adds device driver of Richtek RT5033 PMIC. The RT5033 Flash LED Circuit is designed for one or two LEDs driving for torch and strobe applications, it provides an I2C software command to trigger the torch and strobe operation. Each of LED outputs can contorl a separate LED sharing their setting, and can be connected together for a single connected LED. One LED is represented by one child node. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 541 + include/linux/mfd/rt5033-private.h | 51 4 files changed, 601 insertions(+) create mode 100644 drivers/leds/leds-rt5033.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index b1ab8bd..f41ac9b 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -345,6 +345,14 @@ config LEDS_PCA963X LED driver chip accessed via the I2C bus. Supported devices include PCA9633 and PCA9634 +config LEDS_RT5033 + tristate "LED support for RT5033 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on MFD_RT5033 + help + This option enables support for on-chip LED driver on + RT5033 PMIC. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index e9d53092..77cfad5 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_RT5033) += leds-rt5033.o obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c new file mode 100644 index 000..256df74 --- /dev/null +++ b/drivers/leds/leds-rt5033.c @@ -0,0 +1,541 @@ +/* + * led driver for RT5033 + * + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. + * Ingi Kim + * + * 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 + +#define RT5033_LED_FLASH_TIMEOUT_MIN 64000 +#define RT5033_LED_FLASH_TIMEOUT_STEP 32000 +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_1CH60 +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_2CH80 +#define RT5033_LED_FLASH_BRIGHTNESS_STEP 25000 +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 +#define RT5033_LED_TORCH_BRIGHTNESS_STEP 12500 + +#define FLED1_IOUT (BIT(0)) +#define FLED2_IOUT (BIT(1)) + +enum rt5033_fled { + FLED1, + FLED2, +}; + +struct rt5033_sub_led { + enum rt5033_fled fled_id; + struct led_classdev_flash fled_cdev; + + u32 flash_brightness; + u32 flash_timeout; +}; + +/* RT5033 Flash led platform data */ +struct rt5033_led { + struct device *dev; + struct mutex lock; + struct regmap *regmap; + struct rt5033_sub_led sub_leds[2]; + + u32 current_flash_timeout; + u32 current_flash_brightness; + + bool iout_joint; + u8 fled_mask; + u8 current_iout; +}; + +struct rt5033_led_config_data { + const char *label[2]; + u32 flash_max_microamp[2]; + u32 flash_max_timeout[2]; + u32 torch_max_microamp[2]; + u32 num_leds; +}; + +static u8 rt5033_torch_brightness_to_reg(u32 ua) +{ + return (ua - RT5033_LED_TORCH_BRIGHTNESS_MIN) / + RT5033_LED_TORCH_BRIGHTNESS_STEP; +} + +static u8 rt5033_flash_brightness_to_reg(u32 ua) +{ + return (ua - RT5033_LED_FLASH_BRIGHTNESS_MIN) / + RT5033_LED_FLASH_BRIGHTNESS_STEP; +} + +static u8 rt5033_flash_timeout_to_reg(u32 us) +{ + return (us - RT5033_LED_FLASH_TIMEOUT_MIN) / + RT5033_LED_FLASH_TIMEOUT_STEP; +} + +static struct rt5033_sub_led *flcdev_to_sub_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct rt5033_sub_led, fled_cdev); +} + +static struct rt5033_led *sub_led_to_led(struct rt5033_sub_led *sub_led) +{ + return container_of(sub_led, struct rt5033_led, + sub_leds[sub_led->fled_id]); +} + +static bool rt5033_fled_used(struct rt5033_led *led, enum rt5033_fled fled_id) +{ + u8 fled_bit = (fled_id == FLED1) ? FLED1_IOUT : FLED2_IOUT; + + return led->fle
[PATCH v6 1/2] leds: rt5033: Add DT binding for RT5033
This patch adds the device tree bindings for RT5033 flash LEDs. Signed-off-by: Ingi Kim Acked-by: Rob Herring --- .../devicetree/bindings/leds/leds-rt5033.txt | 46 ++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt diff --git a/Documentation/devicetree/bindings/leds/leds-rt5033.txt b/Documentation/devicetree/bindings/leds/leds-rt5033.txt new file mode 100644 index 000..17159d4 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-rt5033.txt @@ -0,0 +1,46 @@ +* Richtek Technology Corporation - RT5033 Flash LED Driver + +The RT5033 Flash LED Circuit is designed for one or two LEDs driving +for torch and strobe applications, it provides an I2C software command +to trigger the torch and strobe operation. + +There are two LED outputs available - FLED1 and FLED2. Each of them can +control a separate LED or they can be connected together to double +the maximum current for a single connected LED. One LED is represented +by one child node. + +Required properties: +- compatible : Must be "richtek,rt5033-led". + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties for the LED child node: + See Documentation/devicetree/bindings/leds/common.txt +- led-sources : device current output identifiers: 0 - FLED1, 1 - FLED2 +- led-max-microamp : 12.5mA to 200mA, step by 12.5mA. +- flash-max-microamp : + Turn on one LED channel : 50mA to 800mA, step by 25mA. + Turn on two LED channels : 50mA to 600mA, step by 25mA. +- flash-max-timeout-us : 64ms to 1216ms, step by 32ms. + +Optional properties for the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example: + +rt5033 { + compatible = "richtek,rt5033"; + + led { + compatible = "richtek,rt5033-led"; + + flash-led { + label = "rt5033-flash"; + led-sources = <0>, <1>; + led-max-microamp = <20>; + flash-max-microamp = <80>; + flash-max-timeout-us = <1216000>; + }; + }; +} -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, Thanks for the review I'm trying to fix all things what you mentioned. I'll push next version soon. On 2015년 11월 24일 21:16, Jacek Anaszewski wrote: > Hi Ingi, > > On 11/19/2015 11:07 AM, Ingi Kim wrote: >> Hi Jacek, >> >> Thanks for the review. > > You're welcome. > >> I'm trying to reply in detail what you mentioned. >> Please contact me If you need more detail to understand what I replied. >> >> On 2015년 11월 19일 00:46, Jacek Anaszewski wrote: >>> Hi Ingi, >>> >>> Thanks for the update. I have few comments below. >>> >>> On 11/17/2015 10:04 AM, Ingi Kim wrote: >>>> This patch adds device driver of Richtek RT5033 PMIC. >>>> The RT5033 Flash LED Circuit is designed for one or two LEDs driving >>>> for torch and strobe applications, it provides an I2C software command >>>> to trigger the torch and strobe operation. >>>> >>>> Signed-off-by: Ingi Kim >>>> --- >>>>drivers/leds/Kconfig | 8 + >>>>drivers/leds/Makefile | 1 + >>>>drivers/leds/leds-rt5033.c | 522 >>>> + >>>>include/linux/mfd/rt5033-private.h | 51 >>>>4 files changed, 582 insertions(+) >>>>create mode 100644 drivers/leds/leds-rt5033.c >>>> >>>> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >>>> index b1ab8bd..f41ac9b 100644 >>>> --- a/drivers/leds/Kconfig >>>> +++ b/drivers/leds/Kconfig >>>> @@ -345,6 +345,14 @@ config LEDS_PCA963X >>>> LED driver chip accessed via the I2C bus. Supported >>>> devices include PCA9633 and PCA9634 >>>> >>>> +config LEDS_RT5033 >>>> +tristate "LED support for RT5033 PMIC" >>>> +depends on LEDS_CLASS_FLASH && OF >>>> +depends on MFD_RT5033 >>>> +help >>>> + This option enables support for on-chip LED driver on >>>> + RT5033 PMIC. >>>> + >>>>config LEDS_WM831X_STATUS >>>>tristate "LED support for status LEDs on WM831x PMICs" >>>>depends on LEDS_CLASS >>>> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >>>> index e9d53092..77cfad5 100644 >>>> --- a/drivers/leds/Makefile >>>> +++ b/drivers/leds/Makefile >>>> @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= >>>> leds-cobalt-qube.o >>>>obj-$(CONFIG_LEDS_COBALT_RAQ)+= leds-cobalt-raq.o >>>>obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o >>>>obj-$(CONFIG_LEDS_PCA9532)+= leds-pca9532.o >>>> +obj-$(CONFIG_LEDS_RT5033)+= leds-rt5033.o >>>>obj-$(CONFIG_LEDS_GPIO_REGISTER)+= leds-gpio-register.o >>>>obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o >>>>obj-$(CONFIG_LEDS_LP3944)+= leds-lp3944.o >>>> diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c >>>> new file mode 100644 >>>> index 000..a28554a >>>> --- /dev/null >>>> +++ b/drivers/leds/leds-rt5033.c >>>> @@ -0,0 +1,522 @@ >>>> +/* >>>> + * led driver for RT5033 >>>> + * >>>> + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. >>>> + * Ingi Kim >>>> + * >>>> + * 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 >>>> + >>>> +#define RT5033_LED_FLASH_TIMEOUT_MIN64000 >>>> +#define RT5033_LED_FLASH_TIMEOUT_STEP32000 >>>> +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 >>>> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_1CH60 >>>> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_2CH80 >>>> +#define RT5033_LED_FLASH_BRIGHTNESS_STEP25000 >>>> +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 >>>> +#define RT5033_LED_TORCH_BRIGHTNESS_STEP12500 >>>> + >>>> +/* Macro to get offset of rt5033_led_config_data */ >>&g
Re: [PATCH v5 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, Thanks for the review. I'm trying to reply in detail what you mentioned. Please contact me If you need more detail to understand what I replied. On 2015년 11월 19일 00:46, Jacek Anaszewski wrote: > Hi Ingi, > > Thanks for the update. I have few comments below. > > On 11/17/2015 10:04 AM, Ingi Kim wrote: >> This patch adds device driver of Richtek RT5033 PMIC. >> The RT5033 Flash LED Circuit is designed for one or two LEDs driving >> for torch and strobe applications, it provides an I2C software command >> to trigger the torch and strobe operation. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig | 8 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-rt5033.c | 522 >> + >> include/linux/mfd/rt5033-private.h | 51 >> 4 files changed, 582 insertions(+) >> create mode 100644 drivers/leds/leds-rt5033.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index b1ab8bd..f41ac9b 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -345,6 +345,14 @@ config LEDS_PCA963X >> LED driver chip accessed via the I2C bus. Supported >> devices include PCA9633 and PCA9634 >> >> +config LEDS_RT5033 >> +tristate "LED support for RT5033 PMIC" >> +depends on LEDS_CLASS_FLASH && OF >> +depends on MFD_RT5033 >> +help >> + This option enables support for on-chip LED driver on >> + RT5033 PMIC. >> + >> config LEDS_WM831X_STATUS >> tristate "LED support for status LEDs on WM831x PMICs" >> depends on LEDS_CLASS >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index e9d53092..77cfad5 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o >> obj-$(CONFIG_LEDS_COBALT_RAQ)+= leds-cobalt-raq.o >> obj-$(CONFIG_LEDS_SUNFIRE)+= leds-sunfire.o >> obj-$(CONFIG_LEDS_PCA9532)+= leds-pca9532.o >> +obj-$(CONFIG_LEDS_RT5033)+= leds-rt5033.o >> obj-$(CONFIG_LEDS_GPIO_REGISTER)+= leds-gpio-register.o >> obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o >> obj-$(CONFIG_LEDS_LP3944)+= leds-lp3944.o >> diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c >> new file mode 100644 >> index 000..a28554a >> --- /dev/null >> +++ b/drivers/leds/leds-rt5033.c >> @@ -0,0 +1,522 @@ >> +/* >> + * led driver for RT5033 >> + * >> + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. >> + * Ingi Kim >> + * >> + * 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 >> + >> +#define RT5033_LED_FLASH_TIMEOUT_MIN64000 >> +#define RT5033_LED_FLASH_TIMEOUT_STEP32000 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_1CH60 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_2CH80 >> +#define RT5033_LED_FLASH_BRIGHTNESS_STEP25000 >> +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 >> +#define RT5033_LED_TORCH_BRIGHTNESS_STEP12500 >> + >> +/* Macro to get offset of rt5033_led_config_data */ >> +#define RT5033_LED_CONFIG_DATA_OFFSET(val, step, min)(((val) - (min)) \ >> +/ (step)) >> +#define FLED1_IOUT(BIT(0)) >> +#define FLED2_IOUT(BIT(1)) >> + >> +enum rt5033_fled { >> +FLED1, >> +FLED2, >> +}; >> + >> +struct rt5033_sub_led { >> +enum rt5033_fled fled_id; >> +struct led_classdev_flash fled_cdev; >> + >> +u32 torch_brightness; >> +u32 flash_brightness; >> +u32 flash_timeout; >> +}; >> + >> +/* RT5033 Flash led platform data */ >> +struct rt5033_led { >> +struct device *dev; >> +struct mutex lock; >> +struct regmap *regmap; >> +struct rt5033_sub_led sub_leds[2]; >> + >> +bool iout_joint; >> +u8 fled_mask; >> +u8 current_iout; >> +}; >> + >> +struct rt5033_led_config_data { >> +const char *label[2]; >> +u32
[PATCH v5 0/2] Add RT5033 Flash LED driver
This is a fifth version of the patch set to support RT5033 Flash Led. It is based on RFC [1] from Jacek's patch set. Changes since v5: - Rebase on Jacek's devel branch git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git - Remove work queue from driver. - Change brightness_set_sync ops to brightness_set_blocking ops. - Remove "iout_torch_max" and "iout_flash_max" values in rt5033_led struct. - Add missed case for distinguishing between setting brightness. for iout_joint case and for individual LEDs. - Add missed mutex_lock. - Remove guard to check dev->of_node. - Change type of value to const __be32 to get return value of of_find_property. Changes since v4: - Use of_node_put() when DT parse miss - Move struct(rt5033_led) from include/linux/mfd/rt5033.h to local driver/leds/leds-rt5033.c - Remove MODULE_DEVICE_TABLE - Add interface to handle two LEDs. Changes since v3: - Use mutex and work queue - Split brightness set func (sync / async) - Add flash API (flash_brightness_set) - Move struct(rt5033_led_config_data) to local area - Code clean Changes since v2: - Split MFC code from rt5033 flash led patch - Fix typo error - Change naming of mfd register back again - Fix compile error Original cover letter: This patch supports flash led of RT5033 PMIC. [1] https://lkml.org/lkml/2015/8/20/426 Ingi Kim (2): leds: rt5033: Add DT binding for RT5033 leds: rt5033: Add RT5033 Flash led device driver .../devicetree/bindings/leds/leds-rt5033.txt | 46 ++ drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 522 + include/linux/mfd/rt5033-private.h | 51 ++ 5 files changed, 628 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt create mode 100644 drivers/leds/leds-rt5033.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 2/2] leds: rt5033: Add RT5033 Flash led device driver
This patch adds device driver of Richtek RT5033 PMIC. The RT5033 Flash LED Circuit is designed for one or two LEDs driving for torch and strobe applications, it provides an I2C software command to trigger the torch and strobe operation. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 522 + include/linux/mfd/rt5033-private.h | 51 4 files changed, 582 insertions(+) create mode 100644 drivers/leds/leds-rt5033.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index b1ab8bd..f41ac9b 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -345,6 +345,14 @@ config LEDS_PCA963X LED driver chip accessed via the I2C bus. Supported devices include PCA9633 and PCA9634 +config LEDS_RT5033 + tristate "LED support for RT5033 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on MFD_RT5033 + help + This option enables support for on-chip LED driver on + RT5033 PMIC. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index e9d53092..77cfad5 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_RT5033) += leds-rt5033.o obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c new file mode 100644 index 000..a28554a --- /dev/null +++ b/drivers/leds/leds-rt5033.c @@ -0,0 +1,522 @@ +/* + * led driver for RT5033 + * + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. + * Ingi Kim + * + * 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 + +#define RT5033_LED_FLASH_TIMEOUT_MIN 64000 +#define RT5033_LED_FLASH_TIMEOUT_STEP 32000 +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_1CH60 +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_2CH80 +#define RT5033_LED_FLASH_BRIGHTNESS_STEP 25000 +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 +#define RT5033_LED_TORCH_BRIGHTNESS_STEP 12500 + +/* Macro to get offset of rt5033_led_config_data */ +#define RT5033_LED_CONFIG_DATA_OFFSET(val, step, min) (((val) - (min)) \ + / (step)) +#define FLED1_IOUT (BIT(0)) +#define FLED2_IOUT (BIT(1)) + +enum rt5033_fled { + FLED1, + FLED2, +}; + +struct rt5033_sub_led { + enum rt5033_fled fled_id; + struct led_classdev_flash fled_cdev; + + u32 torch_brightness; + u32 flash_brightness; + u32 flash_timeout; +}; + +/* RT5033 Flash led platform data */ +struct rt5033_led { + struct device *dev; + struct mutex lock; + struct regmap *regmap; + struct rt5033_sub_led sub_leds[2]; + + bool iout_joint; + u8 fled_mask; + u8 current_iout; +}; + +struct rt5033_led_config_data { + const char *label[2]; + u32 flash_max_microamp[2]; + u32 flash_max_timeout[2]; + u32 torch_max_microamp[2]; + u32 num_leds; +}; + +static struct rt5033_sub_led *flcdev_to_sub_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct rt5033_sub_led, fled_cdev); +} + +static struct rt5033_led *sub_led_to_led(struct rt5033_sub_led *sub_led) +{ + return container_of(sub_led, struct rt5033_led, + sub_leds[sub_led->fled_id]); +} + +static bool rt5033_fled_used(struct rt5033_led *led, enum rt5033_fled fled_id) +{ + u8 fled_bit = (fled_id == FLED1) ? FLED1_IOUT : FLED2_IOUT; + + return led->fled_mask & fled_bit; +} + +static u8 rt5033_fled_iout_get(struct rt5033_led *led, enum rt5033_fled fled_id) +{ + u8 fled_bit; + + if (led->iout_joint) + fled_bit = led->fled_mask; + else + fled_bit = (fled_id == FLED1) ? FLED1_IOUT : FLED2_IOUT; + + return fled_bit; +} + +static int rt5033_led_iout_set_off(struct rt5033_led *led, + enum rt5033_fled fled_id) +{ + int ret; + u8 fled_bit, value; + +
[PATCH v5 1/2] leds: rt5033: Add DT binding for RT5033
This patch adds the device tree bindings for RT5033 flash LEDs. Signed-off-by: Ingi Kim Acked-by: Rob Herring --- .../devicetree/bindings/leds/leds-rt5033.txt | 46 ++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt diff --git a/Documentation/devicetree/bindings/leds/leds-rt5033.txt b/Documentation/devicetree/bindings/leds/leds-rt5033.txt new file mode 100644 index 000..17159d4 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-rt5033.txt @@ -0,0 +1,46 @@ +* Richtek Technology Corporation - RT5033 Flash LED Driver + +The RT5033 Flash LED Circuit is designed for one or two LEDs driving +for torch and strobe applications, it provides an I2C software command +to trigger the torch and strobe operation. + +There are two LED outputs available - FLED1 and FLED2. Each of them can +control a separate LED or they can be connected together to double +the maximum current for a single connected LED. One LED is represented +by one child node. + +Required properties: +- compatible : Must be "richtek,rt5033-led". + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties for the LED child node: + See Documentation/devicetree/bindings/leds/common.txt +- led-sources : device current output identifiers: 0 - FLED1, 1 - FLED2 +- led-max-microamp : 12.5mA to 200mA, step by 12.5mA. +- flash-max-microamp : + Turn on one LED channel : 50mA to 800mA, step by 25mA. + Turn on two LED channels : 50mA to 600mA, step by 25mA. +- flash-max-timeout-us : 64ms to 1216ms, step by 32ms. + +Optional properties for the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example: + +rt5033 { + compatible = "richtek,rt5033"; + + led { + compatible = "richtek,rt5033-led"; + + flash-led { + label = "rt5033-flash"; + led-sources = <0>, <1>; + led-max-microamp = <20>; + flash-max-microamp = <80>; + flash-max-timeout-us = <1216000>; + }; + }; +} -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, On 2015년 11월 12일 18:21, Jacek Anaszewski wrote: > Hi Ingi, > > On 11/12/2015 08:57 AM, Ingi Kim wrote: > [...] >>>> +regmap_write(led->regmap, RT5033_REG_FLED_FUNCTION1, val); >>>> +} else { >>>> +regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION1, >>>> + RT5033_FLED_FUNC1_MASK, RT5033_FLED_PINCTRL | >>>> + rt5033_fled_used(led, fled_id)); >>>> +regmap_update_bits(led->regmap,RT5033_REG_FLED_CTRL1, >>>> + RT5033_FLED_CTRL1_MASK, >>>> + (brightness - 1) << 4); >>>> +regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION2, >>>> + RT5033_FLED_FUNC2_MASK, RT5033_FLED_ENFLED); >>>> +} >>> >>> How are you distinguishing between setting brightness for iout_joint >>> case and for individual LEDs? Have you tested this use case? >>> Even if you don't have a board with two separate LEDs, >>> you should be able to test two LED class devices with a single >>> connected LED. >>> >> >> Thanks, I missed a iout_joint case :( >> I have tested a board with integrated single LED, >> It looks fine and all feature works well even if it has limitation. > > Please also test two separate LEDs case, by defining two child > nodes in DT, and in a result you will get two LED class devices. > After that you can set brightness separately for each LED class > device, and you'll be able to verify that the driver works properly > by observing the single LED connected to both outputs. > In order to make the testing even more valuable, you can > set triggers for both LEDs > Oh, I ask of you, please do not misconstrue. I'm sorry if my expression is rather misleading. I have verified this driver works properly. It already tested with two child nodes and observed single LED that is connected to both outputs. I just wanted to say that it works properly as you said. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, Thanks for the review. your feedback is highly appreciated :) I'll send next patch set soon. On 2015년 11월 11일 01:30, Jacek Anaszewski wrote: > Hi Ingi, > > Thanks for the update. Please find my comments below. > > On 11/10/2015 03:17 AM, Ingi Kim wrote: >> This patch adds device driver of Richtek RT5033 PMIC. >> The driver supports a current regulated output to drive white LEDs. > > I would add here also the part from leds-rt5033.txt header. > Okay. I will add. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig | 8 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-rt5033.c | 502 >> + >> include/linux/mfd/rt5033-private.h | 51 >> 4 files changed, 562 insertions(+) >> create mode 100644 drivers/leds/leds-rt5033.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index 42990f2..29613e3 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -345,6 +345,14 @@ config LEDS_PCA963X >> LED driver chip accessed via the I2C bus. Supported >> devices include PCA9633 and PCA9634 >> >> +config LEDS_RT5033 >> +tristate "LED support for RT5033 PMIC" >> +depends on LEDS_CLASS_FLASH && OF >> +depends on MFD_RT5033 >> +help >> + This option enables support for on-chip LED driver on >> + RT5033 PMIC. >> + >> config LEDS_WM831X_STATUS >> tristate "LED support for status LEDs on WM831x PMICs" >> depends on LEDS_CLASS >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index b503f92..bcc4d93 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o >> obj-$(CONFIG_LEDS_COBALT_RAQ)+= leds-cobalt-raq.o >> obj-$(CONFIG_LEDS_SUNFIRE)+= leds-sunfire.o >> obj-$(CONFIG_LEDS_PCA9532)+= leds-pca9532.o >> +obj-$(CONFIG_LEDS_RT5033)+= leds-rt5033.o >> obj-$(CONFIG_LEDS_GPIO_REGISTER)+= leds-gpio-register.o >> obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o >> obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o >> diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c >> new file mode 100644 >> index 000..eb89731 >> --- /dev/null >> +++ b/drivers/leds/leds-rt5033.c >> @@ -0,0 +1,502 @@ >> +/* >> + * led driver for RT5033 >> + * >> + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. >> + * Ingi Kim >> + * >> + * 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 >> + >> +#define RT5033_LED_FLASH_TIMEOUT_MIN64000 >> +#define RT5033_LED_FLASH_TIMEOUT_STEP32000 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_1CH60 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_2CH80 >> +#define RT5033_LED_FLASH_BRIGHTNESS_STEP25000 >> +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 >> +#define RT5033_LED_TORCH_BRIGHTNESS_STEP12500 >> + >> +/* Macro to get offset of rt5033_led_config_data */ >> +#define RT5033_LED_CONFIG_DATA_OFFSET(val, step, min)(((val) - (min)) \ >> +/ (step)) >> +#define MIN(a, b)((a) > (b) ? (b) : (a)) > > Please use min() macro from include/linux/kernel.h > Oh, I'll check. >> +#define FLED1_IOUT(BIT(0)) >> +#define FLED2_IOUT(BIT(1)) >> + >> +enum rt5033_fled { >> +FLED1, >> +FLED2, >> +}; >> + >> +struct rt5033_sub_led { >> +enum rt5033_fled fled_id; >> +struct led_classdev_flash fled_cdev; >> +struct work_struct work_brightness_set; >> + >> +u32 torch_brightness; >> +u32 flash_brightness; >> +u32 flash_timeout; >> +}; >> + >> +/* RT5033 Flash led platform data */ >> +struct rt5033_led { >> +struct device *dev; >> +struct mutex lock; >> +struct regmap *regmap; >> +struct rt5033_sub_led sub_leds[2]; >> + >> +u32 iout_torch_max[2]; >> +u32 iout_flash_max[2]; > &
[PATCH v4 1/2] leds: rt5033: Add DT binding for RT5033
This patch adds the device tree bindings for RT5033 flash LEDs. Signed-off-by: Ingi Kim Acked-by: Rob Herring --- .../devicetree/bindings/leds/leds-rt5033.txt | 46 ++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt diff --git a/Documentation/devicetree/bindings/leds/leds-rt5033.txt b/Documentation/devicetree/bindings/leds/leds-rt5033.txt new file mode 100644 index 000..17159d4 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-rt5033.txt @@ -0,0 +1,46 @@ +* Richtek Technology Corporation - RT5033 Flash LED Driver + +The RT5033 Flash LED Circuit is designed for one or two LEDs driving +for torch and strobe applications, it provides an I2C software command +to trigger the torch and strobe operation. + +There are two LED outputs available - FLED1 and FLED2. Each of them can +control a separate LED or they can be connected together to double +the maximum current for a single connected LED. One LED is represented +by one child node. + +Required properties: +- compatible : Must be "richtek,rt5033-led". + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties for the LED child node: + See Documentation/devicetree/bindings/leds/common.txt +- led-sources : device current output identifiers: 0 - FLED1, 1 - FLED2 +- led-max-microamp : 12.5mA to 200mA, step by 12.5mA. +- flash-max-microamp : + Turn on one LED channel : 50mA to 800mA, step by 25mA. + Turn on two LED channels : 50mA to 600mA, step by 25mA. +- flash-max-timeout-us : 64ms to 1216ms, step by 32ms. + +Optional properties for the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example: + +rt5033 { + compatible = "richtek,rt5033"; + + led { + compatible = "richtek,rt5033-led"; + + flash-led { + label = "rt5033-flash"; + led-sources = <0>, <1>; + led-max-microamp = <20>; + flash-max-microamp = <80>; + flash-max-timeout-us = <1216000>; + }; + }; +} -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 2/2] leds: rt5033: Add RT5033 Flash led device driver
This patch adds device driver of Richtek RT5033 PMIC. The driver supports a current regulated output to drive white LEDs. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 502 + include/linux/mfd/rt5033-private.h | 51 4 files changed, 562 insertions(+) create mode 100644 drivers/leds/leds-rt5033.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 42990f2..29613e3 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -345,6 +345,14 @@ config LEDS_PCA963X LED driver chip accessed via the I2C bus. Supported devices include PCA9633 and PCA9634 +config LEDS_RT5033 + tristate "LED support for RT5033 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on MFD_RT5033 + help + This option enables support for on-chip LED driver on + RT5033 PMIC. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index b503f92..bcc4d93 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_RT5033) += leds-rt5033.o obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c new file mode 100644 index 000..eb89731 --- /dev/null +++ b/drivers/leds/leds-rt5033.c @@ -0,0 +1,502 @@ +/* + * led driver for RT5033 + * + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. + * Ingi Kim + * + * 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 + +#define RT5033_LED_FLASH_TIMEOUT_MIN 64000 +#define RT5033_LED_FLASH_TIMEOUT_STEP 32000 +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_1CH60 +#define RT5033_LED_FLASH_BRIGHTNESS_MAX_2CH80 +#define RT5033_LED_FLASH_BRIGHTNESS_STEP 25000 +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 +#define RT5033_LED_TORCH_BRIGHTNESS_STEP 12500 + +/* Macro to get offset of rt5033_led_config_data */ +#define RT5033_LED_CONFIG_DATA_OFFSET(val, step, min) (((val) - (min)) \ + / (step)) +#define MIN(a, b) ((a) > (b) ? (b) : (a)) +#define FLED1_IOUT (BIT(0)) +#define FLED2_IOUT (BIT(1)) + +enum rt5033_fled { + FLED1, + FLED2, +}; + +struct rt5033_sub_led { + enum rt5033_fled fled_id; + struct led_classdev_flash fled_cdev; + struct work_struct work_brightness_set; + + u32 torch_brightness; + u32 flash_brightness; + u32 flash_timeout; +}; + +/* RT5033 Flash led platform data */ +struct rt5033_led { + struct device *dev; + struct mutex lock; + struct regmap *regmap; + struct rt5033_sub_led sub_leds[2]; + + u32 iout_torch_max[2]; + u32 iout_flash_max[2]; + u8 fled_mask; + + /* arrangement of current outputs */ + bool iout_joint; +}; + +struct rt5033_led_config_data { + const char *label[2]; + u32 flash_max_microamp[2]; + u32 flash_max_timeout[2]; + u32 torch_max_microamp[2]; + u32 num_leds; +}; + +static struct rt5033_sub_led *flcdev_to_sub_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct rt5033_sub_led, fled_cdev); +} + +static struct rt5033_led *sub_led_to_led(struct rt5033_sub_led *sub_led) +{ + return container_of(sub_led, struct rt5033_led, + sub_leds[sub_led->fled_id]); +} + +static int rt5033_fled_used(struct rt5033_led *led, enum rt5033_fled fled_id) +{ + u8 fled_bit = (fled_id == FLED1) ? FLED1_IOUT : FLED2_IOUT; + + return led->fled_mask & fled_bit; +} + +static void __rt5033_led_brightness_set(struct rt5033_led *led, + enum rt5033_fled fled_id, + enum led_brightness brightness) +{ + unsigned int val; + + mutex_lock(&led->lock); + + if (!brightness) { + regmap_read(led->regmap, RT5033_REG_FLED_FUNCTION1, &val);
[PATCH v4 0/2] Add RT5033 Flash LED driver
This patch supports flash led of RT5033 PMIC. Changes since v4: - Use of_node_put() when DT parse miss - Move struct(rt5033_led) from include/linux/mfd/rt5033.h to local driver/leds/leds-rt5033.c - Remove MODULE_DEVICE_TABLE - Add interface to handle two LEDs. Changes since v3: - Use mutex and work queue - Split brightness set func (sync / async) - Add flash API (flash_brightness_set) - Move struct(rt5033_led_config_data) to local area - Code clean Changes since v2: - Split MFC code from rt5033 flash led patch - Fix typo error - Change naming of mfd register back again - Fix compile error Ingi Kim (2): leds: rt5033: Add DT binding for RT5033 leds: rt5033: Add RT5033 Flash led device driver .../devicetree/bindings/leds/leds-rt5033.txt | 46 ++ drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 502 + include/linux/mfd/rt5033-private.h | 51 +++ 5 files changed, 608 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt create mode 100644 drivers/leds/leds-rt5033.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/3] leds: rt5033: Add DT binding for RT5033
Hi Jacek, Oh, I see. I'll add. Thanks for the review. On 2015년 10월 26일 19:11, Jacek Anaszewski wrote: > Hi Ingi, > > On 10/23/2015 07:48 AM, Ingi Kim wrote: >> This patch adds the device tree bindings for RT5033 flash LEDs. >> >> Signed-off-by: Ingi Kim >> Acked-by: Rob Herring >> --- >> .../devicetree/bindings/leds/leds-rt5033.txt | 38 >> ++ >> 1 file changed, 38 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt >> >> diff --git a/Documentation/devicetree/bindings/leds/leds-rt5033.txt >> b/Documentation/devicetree/bindings/leds/leds-rt5033.txt >> new file mode 100644 >> index 000..2ef7bdc >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/leds/leds-rt5033.txt >> @@ -0,0 +1,38 @@ >> +* Richtek Technology Corporation - RT5033 Flash LED Driver >> + >> +The RT5033 Flash LED Circuit is designed for one or two LEDs driving > > These bindings don't say how to handle two LEDs case. > >> +for torch and strobe applications, it provides an I2C software command >> +to trigger the torch and strobe operation. >> + >> +Required properties: >> +- compatible : Must be "richtek,rt5033-led". >> + >> +A discrete LED element connected to the device must be represented by a >> child >> +node - see Documentation/devicetree/bindings/leds/common.txt. >> + >> +Required properties of the LED child node: >> + See Documentation/devicetree/bindings/leds/common.txt >> +- led-max-microamp : Minimum Threshold for Timer protection >> + is defined internally (Maximum 200mA). >> +- flash-max-microamp : Flash LED maximum current >> +- flash-max-timeout-us : Flash LED maximum timeout >> + >> +Optional properties of the LED child node: >> +- label : see Documentation/devicetree/bindings/leds/common.txt >> + >> +Example: >> + >> +rt5033 { >> +compatible = "richtek,rt5033"; >> + >> +led { >> +compatible = "richtek,rt5033-led"; >> + >> +flash-led { >> +label = "rt5033-flash"; >> +led-max-microamp = <20>; >> +flash-max-microamp = <80>; >> +flash-max-timeout-us = <1216000>; >> +}; >> +}; >> +} >> > > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 3/3] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, Thanks for the review I can make this code better :) On 2015년 10월 26일 19:10, Jacek Anaszewski wrote: > Hi Ingi, > > Thanks for the update. I've found a few minor issues, please > refer to my comments below. > > On 10/23/2015 07:48 AM, Ingi Kim wrote: >> This patch adds device driver of Richtek RT5033 PMIC. >> The driver supports a current regulated output to drive >> white LEDs for camera flash. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig | 8 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-rt5033.c | 314 >> + >> include/linux/mfd/rt5033-private.h | 49 ++ >> include/linux/mfd/rt5033.h | 13 ++ >> 5 files changed, 385 insertions(+) >> create mode 100644 drivers/leds/leds-rt5033.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index 42990f2..29613e3 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -345,6 +345,14 @@ config LEDS_PCA963X >> LED driver chip accessed via the I2C bus. Supported >> devices include PCA9633 and PCA9634 >> >> +config LEDS_RT5033 >> +tristate "LED support for RT5033 PMIC" >> +depends on LEDS_CLASS_FLASH && OF >> +depends on MFD_RT5033 >> +help >> + This option enables support for on-chip LED driver on >> + RT5033 PMIC. >> + >> config LEDS_WM831X_STATUS >> tristate "LED support for status LEDs on WM831x PMICs" >> depends on LEDS_CLASS >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index b503f92..bcc4d93 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o >> obj-$(CONFIG_LEDS_COBALT_RAQ)+= leds-cobalt-raq.o >> obj-$(CONFIG_LEDS_SUNFIRE)+= leds-sunfire.o >> obj-$(CONFIG_LEDS_PCA9532)+= leds-pca9532.o >> +obj-$(CONFIG_LEDS_RT5033)+= leds-rt5033.o >> obj-$(CONFIG_LEDS_GPIO_REGISTER)+= leds-gpio-register.o >> obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o >> obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o >> diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c >> new file mode 100644 >> index 000..4ba1ec6 >> --- /dev/null >> +++ b/drivers/leds/leds-rt5033.c >> @@ -0,0 +1,314 @@ >> +/* >> + * led driver for RT5033 >> + * >> + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. >> + * Ingi Kim >> + * >> + * 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 >> + >> +#define RT5033_LED_FLASH_TIMEOUT_MIN64000 >> +#define RT5033_LED_FLASH_TIMEOUT_STEP32000 >> +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 >> +#define RT5033_LED_FLASH_BRIGHTNESS_STEP25000 >> +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 >> +#define RT5033_LED_TORCH_BRIGHTNESS_STEP12500 >> + >> +/* Macro to get offset of rt5033_led_config_data */ >> +#define RT5033_LED_CONFIG_DATA_OFFSET(val, step, min)(((val) - (min)) \ >> +/ (step)) >> + >> +struct rt5033_led_config_data { >> +u32 flash_max_microamp; >> +u32 flash_max_timeout; >> +u32 torch_max_microamp; >> +}; >> + >> +static struct rt5033_led *flcdev_to_led( >> +struct led_classdev_flash *fled_cdev) >> +{ >> +return container_of(fled_cdev, struct rt5033_led, fled_cdev); >> +} >> + >> +static void rt5033_brightness_set(struct rt5033_led *led, >> + enum led_brightness brightness) >> +{ >> +mutex_lock(&led->lock); >> + >> +if (!brightness) { >> +regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION2, >> + RT5033_FLED_FUNC2_MASK, 0x0); >> +} else { >> +regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION1, >> + RT5033_FLED_FUNC1_MASK, RT5033_FLED_PINCTRL); >> +regmap_update_bits(led->regmap,RT5033_REG_FLED_CTRL1, >> + RT5033_FLED_CTRL1_MASK, >> + (brightness - 1) << 4);
[PATCH v3 1/3] leds: rt5033: Add DT binding for RT5033
This patch adds the device tree bindings for RT5033 flash LEDs. Signed-off-by: Ingi Kim Acked-by: Rob Herring --- .../devicetree/bindings/leds/leds-rt5033.txt | 38 ++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt diff --git a/Documentation/devicetree/bindings/leds/leds-rt5033.txt b/Documentation/devicetree/bindings/leds/leds-rt5033.txt new file mode 100644 index 000..2ef7bdc --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-rt5033.txt @@ -0,0 +1,38 @@ +* Richtek Technology Corporation - RT5033 Flash LED Driver + +The RT5033 Flash LED Circuit is designed for one or two LEDs driving +for torch and strobe applications, it provides an I2C software command +to trigger the torch and strobe operation. + +Required properties: +- compatible : Must be "richtek,rt5033-led". + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties of the LED child node: + See Documentation/devicetree/bindings/leds/common.txt +- led-max-microamp : Minimum Threshold for Timer protection + is defined internally (Maximum 200mA). +- flash-max-microamp : Flash LED maximum current +- flash-max-timeout-us : Flash LED maximum timeout + +Optional properties of the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example: + +rt5033 { + compatible = "richtek,rt5033"; + + led { + compatible = "richtek,rt5033-led"; + + flash-led { + label = "rt5033-flash"; + led-max-microamp = <20>; + flash-max-microamp = <80>; + flash-max-timeout-us = <1216000>; + }; + }; +} -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 3/3] leds: rt5033: Add RT5033 Flash led device driver
This patch adds device driver of Richtek RT5033 PMIC. The driver supports a current regulated output to drive white LEDs for camera flash. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 314 + include/linux/mfd/rt5033-private.h | 49 ++ include/linux/mfd/rt5033.h | 13 ++ 5 files changed, 385 insertions(+) create mode 100644 drivers/leds/leds-rt5033.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 42990f2..29613e3 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -345,6 +345,14 @@ config LEDS_PCA963X LED driver chip accessed via the I2C bus. Supported devices include PCA9633 and PCA9634 +config LEDS_RT5033 + tristate "LED support for RT5033 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on MFD_RT5033 + help + This option enables support for on-chip LED driver on + RT5033 PMIC. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index b503f92..bcc4d93 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_RT5033) += leds-rt5033.o obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c new file mode 100644 index 000..4ba1ec6 --- /dev/null +++ b/drivers/leds/leds-rt5033.c @@ -0,0 +1,314 @@ +/* + * led driver for RT5033 + * + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. + * Ingi Kim + * + * 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 + +#define RT5033_LED_FLASH_TIMEOUT_MIN 64000 +#define RT5033_LED_FLASH_TIMEOUT_STEP 32000 +#define RT5033_LED_FLASH_BRIGHTNESS_MIN5 +#define RT5033_LED_FLASH_BRIGHTNESS_STEP 25000 +#define RT5033_LED_TORCH_BRIGHTNESS_MIN12500 +#define RT5033_LED_TORCH_BRIGHTNESS_STEP 12500 + +/* Macro to get offset of rt5033_led_config_data */ +#define RT5033_LED_CONFIG_DATA_OFFSET(val, step, min) (((val) - (min)) \ + / (step)) + +struct rt5033_led_config_data { + u32 flash_max_microamp; + u32 flash_max_timeout; + u32 torch_max_microamp; +}; + +static struct rt5033_led *flcdev_to_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct rt5033_led, fled_cdev); +} + +static void rt5033_brightness_set(struct rt5033_led *led, + enum led_brightness brightness) +{ + mutex_lock(&led->lock); + + if (!brightness) { + regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION2, + RT5033_FLED_FUNC2_MASK, 0x0); + } else { + regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION1, + RT5033_FLED_FUNC1_MASK, RT5033_FLED_PINCTRL); + regmap_update_bits(led->regmap, RT5033_REG_FLED_CTRL1, + RT5033_FLED_CTRL1_MASK, + (brightness - 1) << 4); + regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION2, + RT5033_FLED_FUNC2_MASK, RT5033_FLED_ENFLED); + } + + mutex_unlock(&led->lock); +} + +static void rt5033_brightness_set_work(struct work_struct *work) +{ + struct rt5033_led *led = + container_of(work, struct rt5033_led, work_brightness_set); + + rt5033_brightness_set(led, led->torch_brightness); +} + +static void rt5033_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); + struct rt5033_led *led = flcdev_to_led(fled_cdev); + + led->torch_brightness = brightness; + schedule_work(&led->work_brightness_set); +} + +static int rt5033_led_brightness_set_sync(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct
[PATCH v3 0/3] Add RT5033 Flash LED driver
This patch supports flash led of RT5033 PMIC. Changes since v3: - Use mutex and work queue - Split brightness set func (sync / async) - Add flash API (flash_brightness_set) - Move struct(rt5033_led_config_data) to local area - Code clean Changes since v2: - Split MFC code from rt5033 flash led patch - Fix typo error - Change naming of mfd register back again - Fix compile error Ingi Kim (3): leds: rt5033: Add DT binding for RT5033 mfd: rt5033: Add RT5033 Flash led sub device leds: rt5033: Add RT5033 Flash led device driver .../devicetree/bindings/leds/leds-rt5033.txt | 38 +++ drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 314 + drivers/mfd/rt5033.c | 3 + include/linux/mfd/rt5033-private.h | 49 include/linux/mfd/rt5033.h | 13 + 7 files changed, 426 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt create mode 100644 drivers/leds/leds-rt5033.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/3] mfd: rt5033: Add RT5033 Flash led sub device
This patch adds rt5033-led sub device to support it. Signed-off-by: Ingi Kim Acked-by: Lee Jones --- drivers/mfd/rt5033.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c index d60f916..035421c 100644 --- a/drivers/mfd/rt5033.c +++ b/drivers/mfd/rt5033.c @@ -47,6 +47,9 @@ static const struct mfd_cell rt5033_devs[] = { }, { .name = "rt5033-battery", .of_compatible = "richtek,rt5033-battery", + }, { + .name = "rt5033-led", + .of_compatible = "richtek,rt5033-led", }, }; -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] leds: aat1290: Fix property naming of flash-timeout-us
flash-timeout-us property name is changed to flash-max-timeout-us. This patch fixes that name Signed-off-by: Ingi Kim --- Documentation/devicetree/bindings/leds/leds-aat1290.txt | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/leds/leds-aat1290.txt b/Documentation/devicetree/bindings/leds/leds-aat1290.txt index c05ed91..85c0c58 100644 --- a/Documentation/devicetree/bindings/leds/leds-aat1290.txt +++ b/Documentation/devicetree/bindings/leds/leds-aat1290.txt @@ -27,9 +27,9 @@ Required properties of the LED child node: - flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt Maximum flash LED supply current can be calculated using following formula: I = 1A * 162kohm / Rset. -- flash-timeout-us : see Documentation/devicetree/bindings/leds/common.txt - Maximum flash timeout can be calculated using following - formula: T = 8.82 * 10^9 * Ct. +- flash-max-timeout-us : see Documentation/devicetree/bindings/leds/common.txt + Maximum flash timeout can be calculated using following + formula: T = 8.82 * 10^9 * Ct. Optional properties of the LED child node: - label : see Documentation/devicetree/bindings/leds/common.txt @@ -54,7 +54,7 @@ aat1290 { label = "aat1290-flash"; led-max-microamp = <520833>; flash-max-microamp = <1012500>; - flash-timeout-us = <194>; + flash-max-timeout-us = <194>; }; }; -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] leds: aat1290: Fix property naming of flash-timeout-us
flash-timeout-us property name is changed to flash-max-timeout-us. This patch fixes that name Signed-off-by: Ingi Kim --- Documentation/devicetree/bindings/leds/leds-aat1290.txt | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/leds/leds-aat1290.txt b/Documentation/devicetree/bindings/leds/leds-aat1290.txt index c05ed91..85c0c58 100644 --- a/Documentation/devicetree/bindings/leds/leds-aat1290.txt +++ b/Documentation/devicetree/bindings/leds/leds-aat1290.txt @@ -27,9 +27,9 @@ Required properties of the LED child node: - flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt Maximum flash LED supply current can be calculated using following formula: I = 1A * 162kohm / Rset. -- flash-timeout-us : see Documentation/devicetree/bindings/leds/common.txt - Maximum flash timeout can be calculated using following - formula: T = 8.82 * 10^9 * Ct. +- flash-max-timeout-us : see Documentation/devicetree/bindings/leds/common.txt + Maximum flash timeout can be calculated using following + formula: T = 8.82 * 10^9 * Ct. Optional properties of the LED child node: - label : see Documentation/devicetree/bindings/leds/common.txt @@ -54,7 +54,7 @@ aat1290 { label = "aat1290-flash"; led-max-microamp = <520833>; flash-max-microamp = <1012500>; - flash-timeout-us = <194>; + flash-max-timeout-us = <194>; }; }; -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/3] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, Sorry I'm late :( I'll send version3 patch soon On 2015년 10월 13일 17:53, Jacek Anaszewski wrote: > Hi Ingi, > > On 10/13/2015 04:58 AM, Ingi Kim wrote: >> Hi Jacek, >> >> Thanks for your kind comments >> I also append reply below >> >> On 2015년 10월 13일 00:10, Jacek Anaszewski wrote: >>> Hi Ingi, >>> >>> Thanks for the update. Few comments below. >>> >>> On 10/12/2015 03:12 PM, Ingi Kim wrote: >>>> This patch adds device driver of Richtek RT5033 PMIC. >>>> The driver supports a current regulated output to drive >>>> white LEDs for camera flash. >>>> >>>> Signed-off-by: Ingi Kim >>>> --- >>>>drivers/leds/Kconfig | 8 ++ >>>>drivers/leds/Makefile | 1 + >>>>drivers/leds/leds-rt5033.c | 223 >>>> + >>>>include/linux/mfd/rt5033-private.h | 49 >>>>include/linux/mfd/rt5033.h | 22 +++- >>>>5 files changed, 301 insertions(+), 2 deletions(-) >>>>create mode 100644 drivers/leds/leds-rt5033.c >>>> >>>> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >>>> index 42990f2..29613e3 100644 >>>> --- a/drivers/leds/Kconfig >>>> +++ b/drivers/leds/Kconfig >>>> @@ -345,6 +345,14 @@ config LEDS_PCA963X >>>> LED driver chip accessed via the I2C bus. Supported >>>> devices include PCA9633 and PCA9634 >>>> >>>> +config LEDS_RT5033 >>>> +tristate "LED support for RT5033 PMIC" >>>> +depends on LEDS_CLASS_FLASH && OF >>>> +depends on MFD_RT5033 >>>> +help >>>> + This option enables support for on-chip LED driver on >>>> + RT5033 PMIC. >>>> + >>>>config LEDS_WM831X_STATUS >>>>tristate "LED support for status LEDs on WM831x PMICs" >>>>depends on LEDS_CLASS >>>> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >>>> index b503f92..bcc4d93 100644 >>>> --- a/drivers/leds/Makefile >>>> +++ b/drivers/leds/Makefile >>>> @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= >>>> leds-cobalt-qube.o >>>>obj-$(CONFIG_LEDS_COBALT_RAQ)+= leds-cobalt-raq.o >>>>obj-$(CONFIG_LEDS_SUNFIRE)+= leds-sunfire.o >>>>obj-$(CONFIG_LEDS_PCA9532)+= leds-pca9532.o >>>> +obj-$(CONFIG_LEDS_RT5033)+= leds-rt5033.o >>>>obj-$(CONFIG_LEDS_GPIO_REGISTER)+= leds-gpio-register.o >>>>obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o >>>>obj-$(CONFIG_LEDS_LP3944)+= leds-lp3944.o >>>> diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c >>>> new file mode 100644 >>>> index 000..b470c94 >>>> --- /dev/null >>>> +++ b/drivers/leds/leds-rt5033.c >>>> @@ -0,0 +1,223 @@ >>>> +/* >>>> + * led driver for RT5033 >>>> + * >>>> + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. >>>> + * Ingi Kim >>>> + * >>>> + * 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 >>>> + >>>> +#define RT5033_LED_FLASH_TIMEOUT_MIN64000 >>>> +#define RT5033_LED_FLASH_TIMEOUT_STEPS32000 >>>> +#define RT5033_LED_TORCH_CURRENT_LEVEL_MAX16 >>>> + >>>> +/* Macro for getting offset of flash timeout */ >>>> +#define GET_TIMEOUT_OFFSET(tm, step)((tm) / (step) - 2) >>>> + >>>> +static struct rt5033_led *flcdev_to_led( >>>> +struct led_classdev_flash *fled_cdev) >>>> +{ >>>> +return container_of(fled_cdev, struct rt5033_led, fled_cdev); >>>> +} >>>> + >>>> +static int rt5033_led_brightness_set(struct led_classdev *led_cdev, >>>> + enum led_brightness brightness) >>>> +{ >>>> +struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); >>>> +
Re: [PATCH v2 2/3] mfd: rt5033: Add RT5033 Flash led sub device
Hi Lee Jones, Okay, I'm try to remove needless part and resend it Thanks for the review Thank you On 2015년 10월 13일 16:06, Lee Jones wrote: > On Mon, 12 Oct 2015, Ingi Kim wrote: > >> This patch adds rt5033-led sub device to support it. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/mfd/rt5033.c | 6 +- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c >> index d60f916..b7f374b 100644 >> --- a/drivers/mfd/rt5033.c >> +++ b/drivers/mfd/rt5033.c >> @@ -40,13 +40,17 @@ static const struct regmap_irq_chip rt5033_irq_chip = { >> }; >> >> static const struct mfd_cell rt5033_devs[] = { >> -{ .name = "rt5033-regulator", }, >> { >> +.name = "rt5033-regulator", >> +}, { > > There's no need for this change. Please remove it. > >> .name = "rt5033-charger", >> .of_compatible = "richtek,rt5033-charger", >> }, { >> .name = "rt5033-battery", >> .of_compatible = "richtek,rt5033-battery", >> +}, { >> +.name = "rt5033-led", >> +.of_compatible = "richtek,rt5033-led", > > For when you resubmit with the hunk above removed: > > Acked-by: Lee Jones > >> }, >> }; >> > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/3] leds: rt5033: Add RT5033 Flash led device driver
Hi Jacek, Thanks for your kind comments I also append reply below On 2015년 10월 13일 00:10, Jacek Anaszewski wrote: > Hi Ingi, > > Thanks for the update. Few comments below. > > On 10/12/2015 03:12 PM, Ingi Kim wrote: >> This patch adds device driver of Richtek RT5033 PMIC. >> The driver supports a current regulated output to drive >> white LEDs for camera flash. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig | 8 ++ >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-rt5033.c | 223 >> + >> include/linux/mfd/rt5033-private.h | 49 >> include/linux/mfd/rt5033.h | 22 +++- >> 5 files changed, 301 insertions(+), 2 deletions(-) >> create mode 100644 drivers/leds/leds-rt5033.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index 42990f2..29613e3 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -345,6 +345,14 @@ config LEDS_PCA963X >> LED driver chip accessed via the I2C bus. Supported >> devices include PCA9633 and PCA9634 >> >> +config LEDS_RT5033 >> +tristate "LED support for RT5033 PMIC" >> +depends on LEDS_CLASS_FLASH && OF >> +depends on MFD_RT5033 >> +help >> + This option enables support for on-chip LED driver on >> + RT5033 PMIC. >> + >> config LEDS_WM831X_STATUS >> tristate "LED support for status LEDs on WM831x PMICs" >> depends on LEDS_CLASS >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index b503f92..bcc4d93 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o >> obj-$(CONFIG_LEDS_COBALT_RAQ)+= leds-cobalt-raq.o >> obj-$(CONFIG_LEDS_SUNFIRE)+= leds-sunfire.o >> obj-$(CONFIG_LEDS_PCA9532)+= leds-pca9532.o >> +obj-$(CONFIG_LEDS_RT5033)+= leds-rt5033.o >> obj-$(CONFIG_LEDS_GPIO_REGISTER)+= leds-gpio-register.o >> obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o >> obj-$(CONFIG_LEDS_LP3944)+= leds-lp3944.o >> diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c >> new file mode 100644 >> index 000..b470c94 >> --- /dev/null >> +++ b/drivers/leds/leds-rt5033.c >> @@ -0,0 +1,223 @@ >> +/* >> + * led driver for RT5033 >> + * >> + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. >> + * Ingi Kim >> + * >> + * 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 >> + >> +#define RT5033_LED_FLASH_TIMEOUT_MIN64000 >> +#define RT5033_LED_FLASH_TIMEOUT_STEPS32000 >> +#define RT5033_LED_TORCH_CURRENT_LEVEL_MAX16 >> + >> +/* Macro for getting offset of flash timeout */ >> +#define GET_TIMEOUT_OFFSET(tm, step)((tm) / (step) - 2) >> + >> +static struct rt5033_led *flcdev_to_led( >> +struct led_classdev_flash *fled_cdev) >> +{ >> +return container_of(fled_cdev, struct rt5033_led, fled_cdev); >> +} >> + >> +static int rt5033_led_brightness_set(struct led_classdev *led_cdev, >> + enum led_brightness brightness) >> +{ >> +struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); >> +struct rt5033_led *led = flcdev_to_led(fled_cdev); > > I assume that you don't use mutex here deliberately? > Actually I'm not sure why flash driver uses mutex. In consideration of blocking competition, however, I'd be better to use it >> +if (!brightness) { >> +regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION2, >> + RT5033_FLED_CTRL2_MASK, 0x0); >> +} else { >> +regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION1, >> + RT5033_FLED_FUNC1_MASK, RT5033_FLED_PINCTRL); >> +regmap_update_bits(led->regmap,RT5033_REG_FLED_CTRL1, >> + RT5033_FLED_CTRL1_MASK, >> + (brightness - 1) << 4); >> +regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION2, >> + RT5033_FLED_CTRL2_MASK, RT5033_FLED_ENFLED); >> +} >> + >> +
[PATCH v2 2/3] mfd: rt5033: Add RT5033 Flash led sub device
This patch adds rt5033-led sub device to support it. Signed-off-by: Ingi Kim --- drivers/mfd/rt5033.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c index d60f916..b7f374b 100644 --- a/drivers/mfd/rt5033.c +++ b/drivers/mfd/rt5033.c @@ -40,13 +40,17 @@ static const struct regmap_irq_chip rt5033_irq_chip = { }; static const struct mfd_cell rt5033_devs[] = { - { .name = "rt5033-regulator", }, { + .name = "rt5033-regulator", + }, { .name = "rt5033-charger", .of_compatible = "richtek,rt5033-charger", }, { .name = "rt5033-battery", .of_compatible = "richtek,rt5033-battery", + }, { + .name = "rt5033-led", + .of_compatible = "richtek,rt5033-led", }, }; -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/3] Add RT5033 Flash LED driver
This patch supports flash led of RT5033 PMIC. Changes since v2: - Split MFC code from rt5033 flash led patch - Fix typo error - Change naming of mfd register back again - Fix compile error Ingi Kim (3): leds: rt5033: Add DT binding for RT5033 mfd: rt5033: Add RT5033 Flash led sub device leds: rt5033: Add RT5033 Flash led device driver .../devicetree/bindings/leds/leds-rt5033.txt | 38 drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 223 + drivers/mfd/rt5033.c | 6 +- include/linux/mfd/rt5033-private.h | 49 + include/linux/mfd/rt5033.h | 22 +- 7 files changed, 344 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt create mode 100644 drivers/leds/leds-rt5033.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/3] leds: rt5033: Add RT5033 Flash led device driver
This patch adds device driver of Richtek RT5033 PMIC. The driver supports a current regulated output to drive white LEDs for camera flash. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig | 8 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 223 + include/linux/mfd/rt5033-private.h | 49 include/linux/mfd/rt5033.h | 22 +++- 5 files changed, 301 insertions(+), 2 deletions(-) create mode 100644 drivers/leds/leds-rt5033.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 42990f2..29613e3 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -345,6 +345,14 @@ config LEDS_PCA963X LED driver chip accessed via the I2C bus. Supported devices include PCA9633 and PCA9634 +config LEDS_RT5033 + tristate "LED support for RT5033 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on MFD_RT5033 + help + This option enables support for on-chip LED driver on + RT5033 PMIC. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index b503f92..bcc4d93 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_RT5033) += leds-rt5033.o obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c new file mode 100644 index 000..b470c94 --- /dev/null +++ b/drivers/leds/leds-rt5033.c @@ -0,0 +1,223 @@ +/* + * led driver for RT5033 + * + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. + * Ingi Kim + * + * 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 + +#define RT5033_LED_FLASH_TIMEOUT_MIN 64000 +#define RT5033_LED_FLASH_TIMEOUT_STEPS 32000 +#define RT5033_LED_TORCH_CURRENT_LEVEL_MAX 16 + +/* Macro for getting offset of flash timeout */ +#define GET_TIMEOUT_OFFSET(tm, step) ((tm) / (step) - 2) + +static struct rt5033_led *flcdev_to_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct rt5033_led, fled_cdev); +} + +static int rt5033_led_brightness_set(struct led_classdev *led_cdev, +enum led_brightness brightness) +{ + struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); + struct rt5033_led *led = flcdev_to_led(fled_cdev); + + if (!brightness) { + regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION2, + RT5033_FLED_CTRL2_MASK, 0x0); + } else { + regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION1, + RT5033_FLED_FUNC1_MASK, RT5033_FLED_PINCTRL); + regmap_update_bits(led->regmap, RT5033_REG_FLED_CTRL1, + RT5033_FLED_CTRL1_MASK, + (brightness - 1) << 4); + regmap_update_bits(led->regmap, RT5033_REG_FLED_FUNCTION2, + RT5033_FLED_CTRL2_MASK, RT5033_FLED_ENFLED); + } + + return 0; +} + +static void rt5033_init_flash_timeout(struct rt5033_led *led) +{ + struct led_flash_setting *setting; + + setting = &led->fled_cdev.timeout; + setting->min = RT5033_LED_FLASH_TIMEOUT_MIN; + setting->max = led->data->flash_max_timeout; + setting->step = RT5033_LED_FLASH_TIMEOUT_STEPS; + setting->val = led->data->flash_max_timeout; +} + +static int rt5033_led_parse_dt(struct rt5033_led *led, struct device *dev) +{ + struct device_node *np = dev->of_node; + struct device_node *child_node; + struct rt5033_led_config_data *data; + int ret = 0; + + if (!np) + return -ENXIO; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + child_node = of_get_next_available_child(np, NULL); + if (!child_node) { + dev_err(dev, "DT child node isn't found\n"); + return -EINVAL; + } + + led->fled_cdev.led_cdev.name = + of_get_property(child_node, "
[PATCH v2 1/3] leds: rt5033: Add DT binding for RT5033
This patch adds the device tree bindings for RT5033 flash LEDs. Signed-off-by: Ingi Kim Acked-by: Rob Herring --- .../devicetree/bindings/leds/leds-rt5033.txt | 38 ++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt diff --git a/Documentation/devicetree/bindings/leds/leds-rt5033.txt b/Documentation/devicetree/bindings/leds/leds-rt5033.txt new file mode 100644 index 000..2ef7bdc --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-rt5033.txt @@ -0,0 +1,38 @@ +* Richtek Technology Corporation - RT5033 Flash LED Driver + +The RT5033 Flash LED Circuit is designed for one or two LEDs driving +for torch and strobe applications, it provides an I2C software command +to trigger the torch and strobe operation. + +Required properties: +- compatible : Must be "richtek,rt5033-led". + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties of the LED child node: + See Documentation/devicetree/bindings/leds/common.txt +- led-max-microamp : Minimum Threshold for Timer protection + is defined internally (Maximum 200mA). +- flash-max-microamp : Flash LED maximum current +- flash-max-timeout-us : Flash LED maximum timeout + +Optional properties of the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example: + +rt5033 { + compatible = "richtek,rt5033"; + + led { + compatible = "richtek,rt5033-led"; + + flash-led { + label = "rt5033-flash"; + led-max-microamp = <20>; + flash-max-microamp = <80>; + flash-max-timeout-us = <1216000>; + }; + }; +} -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] leds: rt5033: add DT binding for RT5033
Hello, Rob Herring I'll push ver2 patch soon with your acked because other patch has some issues. Thanks for the review. On 2015년 10월 02일 23:31, Rob Herring wrote: > On Fri, Oct 2, 2015 at 4:41 AM, Ingi Kim wrote: >> This patch adds the device tree bindings for RT5033 flash LEDs. >> >> Signed-off-by: Ingi Kim > > Acked-by: Rob Herring > >> --- >> .../devicetree/bindings/leds/leds-rt5033.txt | 38 >> ++ >> 1 file changed, 38 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt >> >> diff --git a/Documentation/devicetree/bindings/leds/leds-rt5033.txt >> b/Documentation/devicetree/bindings/leds/leds-rt5033.txt >> new file mode 100644 >> index 000..2ef7bdc >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/leds/leds-rt5033.txt >> @@ -0,0 +1,38 @@ >> +* Richtek Technology Corporation - RT5033 Flash LED Driver >> + >> +The RT5033 Flash LED Circuit is designed for one or two LEDs driving >> +for torch and strobe applications, it provides an I2C software command >> +to trigger the torch and strobe operation. >> + >> +Required properties: >> +- compatible : Must be "richtek,rt5033-led". >> + >> +A discrete LED element connected to the device must be represented by a >> child >> +node - see Documentation/devicetree/bindings/leds/common.txt. >> + >> +Required properties of the LED child node: >> + See Documentation/devicetree/bindings/leds/common.txt >> +- led-max-microamp : Minimum Threshold for Timer protection >> + is defined internally (Maximum 200mA). >> +- flash-max-microamp : Flash LED maximum current >> +- flash-max-timeout-us : Flash LED maximum timeout >> + >> +Optional properties of the LED child node: >> +- label : see Documentation/devicetree/bindings/leds/common.txt >> + >> +Example: >> + >> +rt5033 { >> + compatible = "richtek,rt5033"; >> + >> + led { >> + compatible = "richtek,rt5033-led"; >> + >> + flash-led { >> + label = "rt5033-flash"; >> + led-max-microamp = <20>; >> + flash-max-microamp = <80>; >> + flash-max-timeout-us = <1216000>; >> + }; >> + }; >> +} >> -- >> 2.0.5 >> > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/2] leds: rt5033: Add RT5033 Flash led device driver
Hello Lee Jones, Thanks for the review. I'll try to divide this patch and change name and comment. Then push ver2 patch soon. On 2015년 10월 05일 16:21, Lee Jones wrote: > On Fri, 02 Oct 2015, Ingi Kim wrote: > >> This patch adds device driver of Richtek RT5033 PMIC. >> The driver supports a current regulated output to drive >> white LEDs for camera flash. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig | 8 ++ >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-rt5033.c | 222 >> + >> drivers/mfd/rt5033.c | 3 + >> include/linux/mfd/rt5033-private.h | 67 +-- >> include/linux/mfd/rt5033.h | 27 - > > Please pull the MFD changes out into to separate patch(es). > >> 6 files changed, 317 insertions(+), 11 deletions(-) >> create mode 100644 drivers/leds/leds-rt5033.c > > [...] > >> diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c >> index d60f916..035421c 100644 >> --- a/drivers/mfd/rt5033.c >> +++ b/drivers/mfd/rt5033.c >> @@ -47,6 +47,9 @@ static const struct mfd_cell rt5033_devs[] = { >> }, { >> .name = "rt5033-battery", >> .of_compatible = "richtek,rt5033-battery", >> +}, { >> +.name = "rt5033-led", >> +.of_compatible = "richtek,rt5033-led", >> }, >> }; > > Needs to be in a patch of its own. > >> diff --git a/include/linux/mfd/rt5033-private.h >> b/include/linux/mfd/rt5033-private.h >> index 1b63fc2..21c3aff 100644 >> --- a/include/linux/mfd/rt5033-private.h >> +++ b/include/linux/mfd/rt5033-private.h >> @@ -25,15 +25,15 @@ enum rt5033_reg { >> /* Reserved 0x09~0x18 */ >> RT5033_REG_RT_CTRL1 = 0x19, >> /* Reserved 0x1A~0x20 */ >> -RT5033_REG_FLED_FUNCTION1 = 0x21, >> -RT5033_REG_FLED_FUNCTION2 = 0x22, >> -RT5033_REG_FLED_STROBE_CTRL1= 0x23, >> -RT5033_REG_FLED_STROBE_CTRL2= 0x24, >> -RT5033_REG_FLED_CTRL1 = 0x25, >> -RT5033_REG_FLED_CTRL2 = 0x26, >> -RT5033_REG_FLED_CTRL3 = 0x27, >> -RT5033_REG_FLED_CTRL4 = 0x28, >> -RT5033_REG_FLED_CTRL5 = 0x29, >> +RT5033_REG_FL_FUNCTION1 = 0x21, >> +RT5033_REG_FL_FUNCTION2 = 0x22, >> +RT5033_REG_FL_STROBE_CTRL1 = 0x23, >> +RT5033_REG_FL_STROBE_CTRL2 = 0x24, >> +RT5033_REG_FL_CTRL1 = 0x25, >> +RT5033_REG_FL_CTRL2 = 0x26, >> +RT5033_REG_FL_CTRL3 = 0x27, >> +RT5033_REG_FL_CTRL4 = 0x28, >> +RT5033_REG_FL_CTRL5 = 0x29, > > Why this change? > > The previous naming convention was better. > >> /* Reserved 0x2A~0x40 */ >> RT5033_REG_CTRL = 0x41, >> RT5033_REG_BUCK_CTRL= 0x42, >> @@ -93,6 +93,55 @@ enum rt5033_reg { >> #define RT5033_RT_CTRL1_UUG_MASK0x02 >> #define RT5033_RT_HZ_MASK 0x01 >> >> +/* RT5033 FLED Function1 register */ >> +#define RT5033_FL_FLED1_MASK0x94 >> +#define RT5033_FL_STROBE_SEL0x04 >> +#define RT5033_FL_PIN_CTRL 0x10 >> +#define RT5033_FL_RESET 0x80 >> + >> +/* RT5033 FLED Function2 register */ >> +#define RT5033_FL_FLED2_MASK0x81 >> +#define RT5033_FL_ENFLED0x01 >> +#define RT5033_FL_SREG_STROBE 0x80 >> + >> +/* RT5033 FLED Strobe Control1 */ >> +#define RT5033_FL_STRBCTRL1_MASK0xFF >> +#define RT5033_FL_STRBCTRL1_TM_CUR_MAX 0xE0 >> +#define RT5033_FL_STRBCTRL1_FL_CUR_DEF 0x0D >> +#define RT5033_FL_STRBCTRL1_FL_CUR_MAX 0x1F >> + >> +/* RT5033 FLED Strobe Control2 */ >> +#define RT5033_FL_STRBCTRL2_MASK0x3F >> +#define RT5033_FL_STRBCTRL2_TM_DEF 0x0F >> +#define RT5033_FL_STRBCTRL2_TM_MAX 0x3F >> + >> +/* RT5033 FLED Control1 */ >> +#define RT5033_FL_CTRL1_MASK0xF7 >> +#define RT5033_FL_CTRL1_TORCH_CUR_DEF 0x20 >> +#define RT5033_FL_CTRL1_TORCH_CUR_MAX 0xF0 >> +#define RT5033_FL_CTRL1_LBP_DEF 0x02 >> +#define RT5033_FL_CTRL1_LBP_MAX 0x07 >> + >> +/* RT5033 FLED Control2 */ >> +#define RT5033_FL_CTRL2_MASK0xFF >> +#define RT5033_FL_CTRL2_VMID_DEF0x37 >> +#define RT5033_FL_CTRL2_VMID_MAX
Re: [PATCH 0/2] Add RT5033 Flash LED driver
Hi, Jacek Thanks for review my patch Oops! old version patch is sent. I should have checked.. I'll send new patch, soon. Thanks Ingi Kim On 2015년 10월 02일 23:59, Jacek Anaszewski wrote: > Hi Ingi, > > Thanks for the patches. Please fix build errors > and resubmit. > > On 10/02/2015 11:41 AM, Ingi Kim wrote: >> This patch adds ktd2692 Flash LED driver with LED Flash class >> >> Ingi Kim (2): >>leds: rt5033: add DT binding for RT5033 >>leds: rt5033: Add RT5033 Flash led device driver >> >> .../devicetree/bindings/leds/leds-rt5033.txt | 38 >> drivers/leds/Kconfig | 8 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-rt5033.c | 222 >> + >> drivers/mfd/rt5033.c | 3 + >> include/linux/mfd/rt5033-private.h | 67 ++- >> include/linux/mfd/rt5033.h | 27 ++- >> 7 files changed, 355 insertions(+), 11 deletions(-) >> create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt >> create mode 100644 drivers/leds/leds-rt5033.c >> > > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] leds: rt5033: Add RT5033 Flash led device driver
This patch adds device driver of Richtek RT5033 PMIC. The driver supports a current regulated output to drive white LEDs for camera flash. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig | 8 ++ drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 222 + drivers/mfd/rt5033.c | 3 + include/linux/mfd/rt5033-private.h | 67 +-- include/linux/mfd/rt5033.h | 27 - 6 files changed, 317 insertions(+), 11 deletions(-) create mode 100644 drivers/leds/leds-rt5033.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 42990f2..29613e3 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -345,6 +345,14 @@ config LEDS_PCA963X LED driver chip accessed via the I2C bus. Supported devices include PCA9633 and PCA9634 +config LEDS_RT5033 + tristate "LED support for RT5033 PMIC" + depends on LEDS_CLASS_FLASH && OF + depends on MFD_RT5033 + help + This option enables support for on-chip LED driver on + RT5033 PMIC. + config LEDS_WM831X_STATUS tristate "LED support for status LEDs on WM831x PMICs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index b503f92..bcc4d93 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_LEDS_COBALT_QUBE)+= leds-cobalt-qube.o obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o +obj-$(CONFIG_LEDS_RT5033) += leds-rt5033.o obj-$(CONFIG_LEDS_GPIO_REGISTER) += leds-gpio-register.o obj-$(CONFIG_LEDS_GPIO)+= leds-gpio.o obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o diff --git a/drivers/leds/leds-rt5033.c b/drivers/leds/leds-rt5033.c new file mode 100644 index 000..b154676 --- /dev/null +++ b/drivers/leds/leds-rt5033.c @@ -0,0 +1,222 @@ +/* + * led driver for RT5033 + * + * Copyright (C) 2015 Samsung Electronics, Co., Ltd. + * Ingi Kim + * + * 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 + +#define RT5033_LED_FLASH_TIMEOUT_MIN 64000 +#define RT5033_LED_FLASH_TIMEOUT_STEPS 32000 +#define RT5033_LED_TORCH_CURRENT_LEVEL_MAX 16 + +/* Macro for getting offset of flash timeout */ +#define GET_TIMEOUT_OFFSET(tm, step) ((tm) / (step) - 2) + +static struct rt5033_led *flcdev_to_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct rt5033_led, fled_cdev); +} + +static int rt5033_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev); + struct rt5033_led *led = flcdev_to_led(fled_cdev); + + if (!brightness) { + regmap_update_bits(led->regmap, RT5033_REG_FL_FUNCTION2, + RT5033_FL_CTRL2_MASK, 0x0); + } else { + regmap_update_bits(led->regmap, RT5033_REG_FL_FUNCTION1, + RT5033_FL_FUNC1_MASK, RT5033_FL_PINCTRL); + regmap_update_bits(led->regmap, RT5033_REG_FL_CTRL1, + RT5033_FL_CTRL1_MASK, (brightness-1) << 4); + regmap_update_bits(led->regmap, RT5033_REG_FL_FUNCTION2, + RT5033_FL_CTRL2_MASK, RT5033_FL_ENFLED); + } + + return 0; +} + +static void rt5033_init_flash_timeout(struct rt5033_led *led) +{ + struct led_flash_setting *setting; + + setting = &led->fled_cdev.timeout; + setting->min = RT5033_LED_FLASH_TIMEOUT_MIN; + setting->max = led->data->flash_max_timeout; + setting->step = RT5033_LED_FLASH_TIMEOUT_STEPS; + setting->val = led->data->flash_max_timeout; +} + +static int rt5033_led_parse_dt(struct rt5033_led *led, struct device *dev) +{ + struct device_node *np = dev->of_node; + struct device_node *child_node; + struct rt5033_led_config_data *data; + int ret = 0; + + if (!np) + return -ENXIO; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + child_node = of_get_next_available_child(np, NULL); + if (!child_node) { + dev_err(dev, "DT child node isn't found\n"); + return -EINVAL; + } + + led->fled_cdev.led_cdev.name = + of_get_property(child_node, "
[PATCH 0/2] Add RT5033 Flash LED driver
This patch adds ktd2692 Flash LED driver with LED Flash class Ingi Kim (2): leds: rt5033: add DT binding for RT5033 leds: rt5033: Add RT5033 Flash led device driver .../devicetree/bindings/leds/leds-rt5033.txt | 38 drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-rt5033.c | 222 + drivers/mfd/rt5033.c | 3 + include/linux/mfd/rt5033-private.h | 67 ++- include/linux/mfd/rt5033.h | 27 ++- 7 files changed, 355 insertions(+), 11 deletions(-) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt create mode 100644 drivers/leds/leds-rt5033.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] leds: rt5033: add DT binding for RT5033
This patch adds the device tree bindings for RT5033 flash LEDs. Signed-off-by: Ingi Kim --- .../devicetree/bindings/leds/leds-rt5033.txt | 38 ++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-rt5033.txt diff --git a/Documentation/devicetree/bindings/leds/leds-rt5033.txt b/Documentation/devicetree/bindings/leds/leds-rt5033.txt new file mode 100644 index 000..2ef7bdc --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-rt5033.txt @@ -0,0 +1,38 @@ +* Richtek Technology Corporation - RT5033 Flash LED Driver + +The RT5033 Flash LED Circuit is designed for one or two LEDs driving +for torch and strobe applications, it provides an I2C software command +to trigger the torch and strobe operation. + +Required properties: +- compatible : Must be "richtek,rt5033-led". + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties of the LED child node: + See Documentation/devicetree/bindings/leds/common.txt +- led-max-microamp : Minimum Threshold for Timer protection + is defined internally (Maximum 200mA). +- flash-max-microamp : Flash LED maximum current +- flash-max-timeout-us : Flash LED maximum timeout + +Optional properties of the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example: + +rt5033 { + compatible = "richtek,rt5033"; + + led { + compatible = "richtek,rt5033-led"; + + flash-led { + label = "rt5033-flash"; + led-max-microamp = <20>; + flash-max-microamp = <80>; + flash-max-timeout-us = <1216000>; + }; + }; +} -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 2/3] leds: ktd2692: add device tree bindings for ktd2692
Hi Jacek, Thanks for the review. On 2015년 04월 24일 22:29, Jacek Anaszewski wrote: > On Thu, 23 Apr 2015 22:18:04 +0900 > Hi Ingi, > > Ingi Kim wrote: > >> This patch adds the device tree bindings for ktd2692 flash LEDs. >> Add Optional properties of child node for Flash LED >> >> Signed-off-by: Ingi Kim >> Acked-by: Seung-Woo Kim >> --- >> .../devicetree/bindings/leds/leds-ktd2692.txt | 47 >> ++ 1 file changed, 47 insertions(+) >> create mode 100644 >> Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> >> diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt new file >> mode 100644 index 000..708f2d4 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> @@ -0,0 +1,47 @@ >> +* Kinetic Technologies - KTD2692 Flash LED Driver >> + >> +KTD2692 is the ideal power solution for high-power flash LEDs. >> +It uses ExpressWire single-wire programming for maximum flexibility. >> + >> +The ExpressWire interface through CTRL pin can control LED on/off and >> +enable/disable the IC, Movie(max 1/3 of Flash current) / Flash mode >> current, +Flash timeout, LVP(low voltage protection). >> + >> +Also, When the AUX pin is pulled high while CTRL pin is high, >> +LED current will be ramped up to the flash-mode current level. >> + >> +Required properties: >> +- compatible: "kinetic,ktd2692" >> +- ctrl-gpio : gpio pin in order control CTRL pin >> +- aux-gpio : gpio pin in order control AUX pin >> + >> +Optional properties: >> +- vin-supply : "vin" LED supply (2.7V to 5.5V) >> + See Documentation/devicetree/bindings/regulator/regulator.txt >> + >> +A discrete LED element connected to the device must be represented >> by a child +node - see >> Documentation/devicetree/bindings/leds/common.txt. + >> +Required properties for flash LED child nodes: >> + See Documentation/devicetree/bindings/leds/common.txt >> +- flash-max-microamp : Flash LED maximum current >> + Formula : I(mA) = 15000 / Rset >> +- flash-max-timeout-us : Flash LED maximum timeout > > Patch [1] makes the led-max-microamp property mandatory for > the LEDs with configurable current for non-flash modes. > > It hasn't been merged yet as we are waiting for ack from DT maintainer. > > Ok, I'll add it. I saw discussion about introduction of new properties for Flash LED, I also hope that patch[1] would be merged as soon as possible :) >> + >> +Optional properties for flash LED child nodes: >> +- label : see Documentation/devicetree/bindings/leds/common.txt >> + >> +Example: >> + >> +ktd2692 { >> +compatible = "kinetic,ktd2692"; >> +ctrl-gpio = <&gpc0 1 0>; >> +aux-gpio = <&gpc0 2 0>; >> +vin-supply = <&vbat>; >> + >> +flash-led { >> +label = "ktd2692-flash"; >> +flash-max-microamp = <150>; >> +flash-max-timeout-us = <1835000>; >> +}; >> +}; > > [1] [PATCH v6] DT: leds: Improve description of flash LEDs related > properties > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 3/3] leds: Add ktd2692 flash LED driver
This patch adds a driver to support the ktd2692 flash LEDs. ktd2692 can control flash current by ExpressWire interface. Signed-off-by: Ingi Kim Acked-by: Seung-Woo Kim --- drivers/leds/Kconfig| 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c | 435 3 files changed, 445 insertions(+) create mode 100644 drivers/leds/leds-ktd2692.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 51059bb..bfbdbd1 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -505,6 +505,15 @@ config LEDS_MENF21BMC This driver can also be built as a module. If so the module will be called leds-menf21bmc. +config LEDS_KTD2692 + tristate "KTD2692 LED flash support" + depends on LEDS_CLASS_FLASH && GPIOLIB && OF + help + This option enables support for KTD2692 LED flash connected + through ExpressWire interface. + + Say Y to enable this driver. + comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" config LEDS_BLINKM diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index a739ae2..ed5ed79 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -59,6 +59,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o +obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c new file mode 100644 index 000..cec5264 --- /dev/null +++ b/drivers/leds/leds-ktd2692.c @@ -0,0 +1,435 @@ +/* + * LED driver : leds-ktd2692.c + * + * Copyright (C) 2015 Samsung Electronics + * Ingi Kim + * + * 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 + +/* Value related the movie mode */ +#define KTD2692_MOVIE_MODE_CURRENT_MAX_MA 30 +#define KTD2692_MOVIE_MODE_CURRENT_LEVELS 16 +#define KTD2692_MM_TO_FL_RATIO (1 / 3) +#define KTD2962_MM_MIN_CURR_THRESHOLD_SCALE8 + +/* Value related the flash mode */ +#define KTD2692_FLASH_MODE_TIMEOUT_LEVELS 8 +#define KTD2692_FLASH_MODE_TIMEOUT_DISABLE 0 +#define KTD2692_FLASH_MODE_CURR_PERCENT(x) (((x) * 16) / 100) + +/* Macro for getting offset of flash timeout */ +#define GET_TIMEOUT_OFFSET(timeout, step) ((timeout) / (step)) + +/* Base register address */ +#define KTD2692_REG_LVP_BASE 0x00 +#define KTD2692_REG_FLASH_TIMEOUT_BASE 0x20 +#define KTD2692_REG_MM_MIN_CURR_THRESHOLD_BASE 0x40 +#define KTD2692_REG_MOVIE_CURRENT_BASE 0x60 +#define KTD2692_REG_FLASH_CURRENT_BASE 0x80 +#define KTD2692_REG_MODE_BASE 0xA0 + +/* Set bit coding time for expresswire interface */ +#define KTD2692_TIME_RESET_US 700 +#define KTD2692_TIME_DATA_START_TIME_US10 +#define KTD2692_TIME_HIGH_END_OF_DATA_US 350 +#define KTD2692_TIME_LOW_END_OF_DATA_US10 +#define KTD2692_TIME_SHORT_BITSET_US 4 +#define KTD2692_TIME_LONG_BITSET_US12 + +/* KTD2692 default length of name */ +#define KTD2692_NAME_LENGTH20 + +enum ktd2692_bitset { + KTD2692_LOW = 0, + KTD2692_HIGH, +}; + +/* Movie / Flash Mode Control */ +enum ktd2692_led_mode { + KTD2692_MODE_DISABLE = 0, /* default */ + KTD2692_MODE_MOVIE, + KTD2692_MODE_FLASH, +}; + +struct ktd2692_led_config_data { + /* maximum LED current in flash mode */ + u32 flash_max_microamp; + /* maximum flash timeout */ + u32 flash_max_timeout; + /* max LED brightness level */ + enum led_brightness max_brightness; +}; + +struct ktd2692_context { + /* Related LED Flash class device */ + struct led_classdev_flash fled_cdev; + + /* secures access to the device */ + struct mutex lock; + struct regulator *regulator; + struct work_struct work_brightness_set; + + struct gpio_desc *aux_gpio; + struct gpio_desc *ctrl_gpio; + + enum ktd2692_led_mode mode; + enum led_brightness torch_brightness; +}; + +static struct ktd2692_context *fled_cdev_to_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct ktd2692_context, fled_cdev); +} + +static void ktd2692_expresswire_start(struct ktd2692_context *led) +{ + gpiod_direction_output(led->ctrl_gpio, KTD2692_HIGH); + udelay(KTD2692_TIME
[PATCH v7 0/3] Add ktd2692 Flash LED driver using LED Flash class
This patch adds ktd2692 Flash LED driver with LED Flash class Change in v7: - Add flash-max-microamp property for Flash LED - Change gpio-legacy interface to gpio consumer interface Change in v6 resend: - Adjust indent using checkpatch.pl script with strict option Change in v6: - Change goto label to if-else - Change DT binding style for LED device binding Change in v5: - Clean up the code - Fix help message of Kconfig - Fix issue related with regulator and mutex usage - Remove tab spaces in bindings Change in v4: - Clean up the code - Modify binding documentation of ktd2692 Change in v3: - Clean up the code - Add aux gpio pin to control Flash LED Change in v2: - Introduction of LED Flash class as Jacek's comment - Supplement of binding documentation - Rename gpio control pin and remove unused pin - Add regulator for the Flash LED Ingi Kim (3): of: Add vendor prefix for Kinetic technologies leds: ktd2692: add device tree bindings for ktd2692 leds: Add ktd2692 flash LED driver .../devicetree/bindings/leds/leds-ktd2692.txt | 47 +++ .../devicetree/bindings/vendor-prefixes.txt| 1 + drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c| 435 + 5 files changed, 493 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt create mode 100644 drivers/leds/leds-ktd2692.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 2/3] leds: ktd2692: add device tree bindings for ktd2692
This patch adds the device tree bindings for ktd2692 flash LEDs. Add Optional properties of child node for Flash LED Signed-off-by: Ingi Kim Acked-by: Seung-Woo Kim --- .../devicetree/bindings/leds/leds-ktd2692.txt | 47 ++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt new file mode 100644 index 000..708f2d4 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt @@ -0,0 +1,47 @@ +* Kinetic Technologies - KTD2692 Flash LED Driver + +KTD2692 is the ideal power solution for high-power flash LEDs. +It uses ExpressWire single-wire programming for maximum flexibility. + +The ExpressWire interface through CTRL pin can control LED on/off and +enable/disable the IC, Movie(max 1/3 of Flash current) / Flash mode current, +Flash timeout, LVP(low voltage protection). + +Also, When the AUX pin is pulled high while CTRL pin is high, +LED current will be ramped up to the flash-mode current level. + +Required properties: +- compatible: "kinetic,ktd2692" +- ctrl-gpio : gpio pin in order control CTRL pin +- aux-gpio : gpio pin in order control AUX pin + +Optional properties: +- vin-supply : "vin" LED supply (2.7V to 5.5V) + See Documentation/devicetree/bindings/regulator/regulator.txt + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties for flash LED child nodes: + See Documentation/devicetree/bindings/leds/common.txt +- flash-max-microamp : Flash LED maximum current + Formula : I(mA) = 15000 / Rset +- flash-max-timeout-us : Flash LED maximum timeout + +Optional properties for flash LED child nodes: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example: + +ktd2692 { + compatible = "kinetic,ktd2692"; + ctrl-gpio = <&gpc0 1 0>; + aux-gpio = <&gpc0 2 0>; + vin-supply = <&vbat>; + + flash-led { + label = "ktd2692-flash"; + flash-max-microamp = <150>; + flash-max-timeout-us = <1835000>; + }; +}; -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v7 1/3] of: Add vendor prefix for Kinetic technologies
This patch adds vendor prefix for Kinetic technologies Signed-off-by: Ingi Kim Acked-by: Rob Herring Acked-by: Seung-Woo Kim --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index fae26d0..90a4be1 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -100,6 +100,7 @@ iseeISEE 2007 S.L. isil Intersil karo Ka-Ro electronics GmbH keymileKeymile GmbH +kinetic Kinetic Technologies lacie LaCie lantiq Lantiq Semiconductor lenovo Lenovo Group Ltd. -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 3/3] leds: Add ktd2692 flash LED driver
This patch adds a driver to support the ktd2692 flash LEDs. ktd2692 can control flash current by ExpressWire interface. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig| 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c | 405 3 files changed, 415 insertions(+) create mode 100644 drivers/leds/leds-ktd2692.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 25b320d..c32e73e 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -498,6 +498,15 @@ config LEDS_MENF21BMC This driver can also be built as a module. If so the module will be called leds-menf21bmc. +config LEDS_KTD2692 + tristate "KTD2692 LED flash support" + depends on LEDS_CLASS_FLASH && GPIOLIB + help + This option enables support for KTD2692 LED flash connected + through ExpressWire interface. + + Say Y to enable this driver. + comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" config LEDS_BLINKM diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index cbba921..289513b 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o +obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c new file mode 100644 index 000..558e2b9 --- /dev/null +++ b/drivers/leds/leds-ktd2692.c @@ -0,0 +1,405 @@ +/* + * LED driver : leds-ktd2692.c + * + * Copyright (C) 2015 Samsung Electronics + * Ingi Kim + * + * 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 + +/* Value related the flash mode */ +#define KTD2692_FLASH_MODE_TIMEOUT_LEVELS 8 +#define KTD2692_FLASH_MODE_TIMEOUT_DISABLE 0 +#define KTD2692_FLASH_MODE_TIMEOUT_DEFAULT_US 1049000 +#define KTD2692_FLASH_MODE_TIMEOUT_MAX_US 1835000 +#define KTD2692_FLASH_MODE_CURR_PERCENT(x) (((x) * 16) / 100) + +/* Macro for getting offset of flash timeout */ +#define GET_TIMEOUT_OFFSET(timeout, step) ((timeout) / (step)) + +/* Adjust a multiple of brightness */ +#define KTD2692_BRIGHTNESS_RANGE_255_TO_16(x) (((x) >> 4) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_8(x) (((x) >> 5) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_4(x) (((x) >> 6) & 0x0F) + +/* Base register address */ +#define KTD2692_REG_LVP_BASE 0x00 +#define KTD2692_REG_FLASH_TIMEOUT_BASE 0x20 +#define KTD2692_REG_MIN_CURRENT_SET_BASE 0x40 +#define KTD2692_REG_MOVIE_CURRENT_BASE 0x60 +#define KTD2692_REG_FLASH_CURRENT_BASE 0x80 +#define KTD2692_REG_MODE_BASE 0xA0 + +/* Set bit coding time for expresswire interface */ +#define KTD2692_TIME_RESET_US 700 +#define KTD2692_TIME_DATA_START_TIME_US10 +#define KTD2692_TIME_HIGH_END_OF_DATA_US 350 +#define KTD2692_TIME_LOW_END_OF_DATA_US10 +#define KTD2692_TIME_SHORT_BITSET_US 4 +#define KTD2692_TIME_LONG_BITSET_US12 + +/* KTD2692 default length of name */ +#define KTD2692_NAME_LENGTH20 + +/* KTD2692 default name */ +#define KTD2692_DEFAULT_NAME "ktd2692" + +enum ktd2692_bitset { + KTD2692_LOW = 0, + KTD2692_HIGH, +}; + +/* Movie / Flash Mode Control */ +enum ktd2692_led_mode { + KTD2692_MODE_DISABLE = 0, /* default */ + KTD2692_MODE_MOVIE, + KTD2692_MODE_FLASH, +}; + +struct ktd2692_context { + /* Related LED Flash class device */ + struct led_classdev_flash fled_cdev; + + struct mutex lock; + struct regulator *regulator; + struct work_struct work_brightness_set; + + int aux_gpio; + int ctrl_gpio; + + enum ktd2692_led_mode mode; + enum led_brightness torch_brightness; +}; + +static struct ktd2692_context *fled_cdev_to_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct ktd2692_context, fled_cdev); +} + +static void ktd2692_expresswire_start(struct ktd2692_context *led) +{ + gpio_set_value(led->ctrl_gpio, KTD2692_HIGH); + udelay(KTD2692_TIME_DATA_START_TIME_US); +} + +static void ktd2692_expresswire_reset(struct ktd2692_context *led) +{ + gpio_set_value(led->ctrl_gpio, KTD2692_LOW); + udela
[PATCH v5 2/3] leds: ktd2692: add device tree bindings for ktd2692
This patch adds the device tree bindings for ktd2692 flash LEDs. Add optional properties 'flash-timeout-us' to control flash timeout and 'vin-supply' for flash-led regulator Signed-off-by: Ingi Kim --- .../devicetree/bindings/leds/leds-ktd2692.txt | 32 ++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt new file mode 100644 index 000..3f121ab --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt @@ -0,0 +1,32 @@ +* Kinetic Technologies - KTD2692 Flash LED Driver + +KTD2692 is the ideal power solution for high-power flash LEDs. +It uses ExpressWire single-wire programming for maximum flexibility. + +The ExpressWire interface through CTRL pin can control LED on/off and +enable/disable the IC, Movie(max 1/3 of Flash current) / Flash mode current, +Flash timeout, LVP(low voltage protection). + +Also, When the AUX pin is pulled high while CTRL pin is high, +LED current will be ramped up to the flash-mode current level. + +Required properties: +- compatible: "kinetic,ktd2692" +- ctrl-gpio : gpio pin in order control CTRL pin +- aux-gpio : gpio pin in order control AUX pin +- vin-supply : "vin" LED supply (2.7V to 5.5V) + See Documentation/devicetree/bindings/regulator/regulator.txt + +Optional property: +- flash-timeout-us : Maximum flash timeout in microseconds. + flash timeout ranges from 0 to 1835000us and default is 1049000us. + +Example: + +flash-led { + compatible = "kinetic,ktd2692"; + ctrl-gpio = <&gpc0 1 0>; + aux-gpio = <&gpc0 2 0>; + flash-timeout-us = <1835000>; + vin-supply = <&vbat>; +}; -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 0/3] Add ktd2692 Flash LED driver using LED Flash class
This patch adds ktd2692 Flash LED driver with LED Flash class Change in v5: - Clean up the code - Fix help message of Kconfig - Fix issue related with regulator and mutex usage - Remove tab spaces in bindings Change in v4: - Clean up the code - Modify binding documentation of ktd2692 Change in v3: - Clean up the code - Add aux gpio pin to control Flash LED Change in v2: - Introduction of LED Flash class as Jacek's comment - Supplement of binding documentation - Rename gpio control pin and remove unused pin - Add regulator for the Flash LED Ingi Kim (3): of: Add vendor prefix for Kinetic technologies leds: ktd2692: add device tree bindings for ktd2692 leds: Add ktd2692 flash LED driver .../devicetree/bindings/leds/leds-ktd2692.txt | 32 ++ .../devicetree/bindings/vendor-prefixes.txt| 1 + drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c| 405 + 5 files changed, 448 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt create mode 100644 drivers/leds/leds-ktd2692.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5 1/3] of: Add vendor prefix for Kinetic technologies
This patch adds vendor prefix for Kinetic technologies Signed-off-by: Ingi Kim Acked-by: Rob Herring --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 389ca13..de9e126 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -98,6 +98,7 @@ isee ISEE 2007 S.L. isil Intersil karo Ka-Ro electronics GmbH keymileKeymile GmbH +kinetic Kinetic Technologies lacie LaCie lantiq Lantiq Semiconductor lenovo Lenovo Group Ltd. -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 3/3] leds: Add ktd2692 flash LED driver
Hi Sakari, Thanks for the review On 2015년 03월 25일 22:53, Sakari Ailus wrote: > Hi Ingi, > > Thank you for the patch. > > On Wed, Mar 25, 2015 at 10:30:44AM +0900, Ingi Kim wrote: >> This patch adds a driver to support the ktd2692 flash LEDs. >> ktd2692 can control flash current by ExpressWire interface. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig| 9 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-ktd2692.c | 412 >> >> 3 files changed, 422 insertions(+) >> create mode 100644 drivers/leds/leds-ktd2692.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index 25b320d..9311cfc4 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -498,6 +498,15 @@ config LEDS_MENF21BMC >>This driver can also be built as a module. If so the module >>will be called leds-menf21bmc. >> >> +config LEDS_KTD2692 >> +tristate "Flash LED support for the KTD2692 Driver" > > Does ktd2692 act as something else as well? If not, how about "KTD2692 LED > flash support"? > Right, KTD2692 driver acts just for flash led. >> +depends on LEDS_CLASS_FLASH && GPIOLIB >> +help >> + This option enables support for the KTD2692 connected through >> + ExpressWire Interface. Say Y to enabled these. >> + It depends on LEDS_CLASS_FLASH for using flash led (strobe) and >> + GPIOLIB for using gpio pin to control Expresswire interface > > The dependencies are shown by make *config, I would drop them from here. > Did you mean help message about dependencies? or config (LEDS_CLASS_FLASH, GPIOLIB) if you mean latter, I don't know exactly what you say. if it wasn't, I should drop superfluous help message >> + >> comment "LED driver for blink(1) USB RGB LED is under Special HID drivers >> (HID_THINGM)" >> >> config LEDS_BLINKM >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index cbba921..289513b 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o >> obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o >> obj-$(CONFIG_LEDS_VERSATILE)+= leds-versatile.o >> obj-$(CONFIG_LEDS_MENF21BMC)+= leds-menf21bmc.o >> +obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o >> >> # LED SPI Drivers >> obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o >> diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c >> new file mode 100644 >> index 000..c31ec9d >> --- /dev/null >> +++ b/drivers/leds/leds-ktd2692.c >> @@ -0,0 +1,412 @@ >> +/* >> + * LED driver : leds-ktd2692.c >> + * >> + * Copyright (C) 2015 Samsung Electronics >> + * Ingi Kim >> + * >> + * 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 >> + >> +#define GET_BIT(bit, val) (((val) >> (bit)) & 0x01) >> + >> +/* Value related the flash mode */ >> +#define KTD2692_FLASH_MODE_TIMEOUT_LEVELS 8 >> +#define KTD2692_FLASH_MODE_TIMEOUT_DISABLE 0 >> +#define KTD2692_FLASH_MODE_TIMEOUT_DEFAULT_US 1049000 >> +#define KTD2692_FLASH_MODE_TIMEOUT_MAX_US 1835000 >> +#define KTD2692_FLASH_MODE_CURR_PERCENT(x) (((x) * 16) / 100) >> + >> +/* Macro for getting offset of flash timeout */ >> +#define GET_TIMEOUT_OFFSET(timeout, step) ((timeout) / (step)) >> + >> +/* Adjust a multiple of brightness */ >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_16(x) (((x) >> 4) & 0x0F) >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_8(x)(((x) >> 5) & 0x0F) >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_4(x)(((x) >> 6) & 0x0F) >> + >> +/* Base register address */ >> +#define KTD2692_REG_LVP_BASE0x00 >> +#define KTD2692_REG_FLASH_TIMEOUT_BASE 0x20 >> +#define KTD2692_REG_MIN_CURRENT_SET_BASE0x40 >> +#define KTD2692_REG_MOVIE_CURRENT_BASE 0x60 >> +#define KTD2692_REG_FLASH_CURRENT_BASE 0x80 >> +#define KT
Re: [PATCH v4 3/3] leds: Add ktd2692 flash LED driver
Hi Varka, On 2015년 03월 25일 12:28, Varka Bhadram wrote: > On 03/25/2015 07:00 AM, Ingi Kim wrote: > >> This patch adds a driver to support the ktd2692 flash LEDs. >> ktd2692 can control flash current by ExpressWire interface. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig| 9 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-ktd2692.c | 412 >> >> 3 files changed, 422 insertions(+) >> create mode 100644 drivers/leds/leds-ktd2692.c >> > (...) > >> +static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, >> +u32 *flash_timeout_us) >> +{ >> +struct device_node *np = dev->of_node; >> + > > Unnecessary one line space.. > Oh, I missed it! Thanks >> +int ret; >> + >> +led->ctrl_gpio = of_get_named_gpio(np, "ctrl-gpio", 0); >> +if (!gpio_is_valid(led->ctrl_gpio)) { >> +dev_err(dev, "no ctrl-gpio property found\n"); >> +return -EINVAL; >> +} >> + >> +led->aux_gpio = of_get_named_gpio(np, "aux-gpio", 0); >> +if (!gpio_is_valid(led->aux_gpio)) { >> +dev_err(dev, "no aux-gpio property found\n"); >> +return -EINVAL; >> +} >> + >> +ret = devm_gpio_request_one(dev, led->ctrl_gpio, >> +GPIOF_OPEN_SOURCE, "ctrl-gpio"); >> +if (ret) { >> +dev_err(dev, "failed to request ctrl-gpio %d error %d\n", >> +led->ctrl_gpio, ret); >> +return ret; >> +} >> + >> +ret = devm_gpio_request_one(dev, led->aux_gpio, >> +GPIOF_OPEN_SOURCE, "aux-gpio"); >> +if (ret) { >> +dev_err(dev, "failed to request aux-gpio %d error %d\n", >> +led->aux_gpio, ret); >> +return ret; >> +} >> + >> +ret = of_property_read_u32(np, "flash-timeout-us", flash_timeout_us); >> +/* default setting */ >> +if (ret) >> +*flash_timeout_us = KTD2692_FLASH_MODE_TIMEOUT_DEFAULT_US; >> + >> +return 0; >> +} >> + >> +static const struct led_flash_ops flash_ops = { >> +.strobe_set = ktd2692_led_flash_strobe_set, >> +.timeout_set = ktd2692_led_flash_timeout_set, >> +}; >> + >> +static int ktd2692_probe(struct platform_device *pdev) >> +{ >> +struct ktd2692_context *led; >> +struct led_classdev *led_cdev; >> +struct led_classdev_flash *fled_cdev; >> +struct led_flash_setting flash_timeout; >> +u32 flash_timeout_us; >> +int ret; >> + >> +led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL); >> +if (!led) >> +return -ENOMEM; >> + >> +if (!pdev->dev.of_node) >> +return -ENXIO; >> + > > Above operation dt related. So if you do that in ktd2692_parse_dt(), it will > be good > Good point! I'll do that >> +fled_cdev = &led->fled_cdev; >> +led_cdev = &fled_cdev->led_cdev; >> + >> +ret = ktd2692_parse_dt(led, &pdev->dev, &flash_timeout_us); >> +if (ret) >> +return ret; >> + >> +led->regulator = devm_regulator_get(&pdev->dev, "vin"); >> +if (IS_ERR(led->regulator)) { >> +dev_err(&pdev->dev, "regulator get failed\n"); >> +return PTR_ERR(led->regulator); >> +} >> + >> +ktd2692_init_flash_timeout(flash_timeout_us, &flash_timeout); >> + >> +fled_cdev->timeout = flash_timeout; >> +fled_cdev->ops = &flash_ops; >> + >> +led_cdev->name = KTD2692_DEFAULT_NAME; >> +led_cdev->brightness_set = ktd2692_led_brightness_set; >> +led_cdev->brightness_set_sync = ktd2692_led_brightness_set_sync; >> +led_cdev->flags |= LED_CORE_SUSPENDRESUME; >> +led_cdev->flags |= LED_DEV_CAP_FLASH; >> + >> +mutex_init(&led->lock); >> +INIT_WORK(&led->work_brightness_set, ktd2692_brightness_set_work); >> + >> +platform_set_drvdata(pdev, led); >> + >> +ret = led_classdev_flash_register(&pdev->dev, fled_cdev); >> +if (ret) { >> +dev_err(&pdev->dev, "can't register LED %s\n", led_cdev->name); >> +cancel_work_sync(&led->work_brightness_set); >
Re: [PATCH v4 2/3] leds: ktd2692: add device tree bindings for ktd2692
Hi Varka, Thanks for the review On 2015년 03월 25일 12:31, Varka Bhadram wrote: > On 03/25/2015 07:00 AM, Ingi Kim wrote: >> This patch adds the device tree bindings for ktd2692 flash LEDs. >> Add optional properties 'flash-timeout-us' to control flash timeout >> and 'vin-supply' for flash-led regulator >> >> Signed-off-by: Ingi Kim >> --- >> .../devicetree/bindings/leds/leds-ktd2692.txt | 33 >> ++ >> 1 file changed, 33 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> >> diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> new file mode 100644 >> index 000..f78512f >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> @@ -0,0 +1,33 @@ >> +* Kinetic Technologies - KTD2692 Flash LED Driver >> + >> +KTD2692 is the ideal power solution for high-power flash LEDs. >> +It uses ExpressWire single-wire programming for maximum flexibility. >> + >> +The ExpressWire interface through CTRL pin can control LED on/off and >> +enable/disable the IC, Movie(max 1/3 of Flash current) / Flash mode current, >> +Flash timeout, LVP(low voltage protection). >> + >> +Also, When the AUX pin is pulled high while CTRL pin is high, >> +LED current will be ramped up to the flash-mode current level. >> + >> +Required properties: >> +- compatible: "kinetic,ktd2692" >> +- ctrl-gpio, aux-gpio : gpio pins in order control ktd2692 flash led. >> +There is an internal 300kOhm pull-down resistor at each pin >> +- vin-supply : "vin" LED supply (2.7V to 5.5V) >> +See Documentation/devicetree/bindings/regulator/regulator.txt >> + > > Above bindings are not that readable to me. Remove the tab spaces before > properties. > Isn't it clear? OK, I'll fix it more >> +Optional property: >> +- flash-timeout-us : Maximum flash timeout in microseconds. >> +flash timeout ranges from 0 to 1835000us and >> +default is 1049000us. >> + >> +Example: >> + >> +flash-led { >> +compatible = "kinetic,ktd2692"; >> +ctrl-gpio = <&gpc0 1 0>; >> +aux-gpio = <&gpc0 2 0>; >> +flash-timeout-us = <1835000>; >> +vin-supply = <&vbat>; >> +}; > > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 0/3] Add ktd2692 Flash LED driver using LED Flash class
This patch adds ktd2692 Flash LED driver with LED Flash class Change in v4: - Clean up the code - Modify binding documentation of ktd2692 Change in v3: - Clean up the code - Add aux gpio pin to control Flash LED Change in v2: - Introduction of LED Flash class as Jacek's comment - Supplement of binding documentation - Rename gpio control pin and remove unused pin - Add regulator for the Flash LED Ingi Kim (3): of: Add vendor prefix for Kinetic technologies leds: ktd2692: add device tree bindings for ktd2692 leds: Add ktd2692 flash LED driver .../devicetree/bindings/leds/leds-ktd2692.txt | 33 ++ .../devicetree/bindings/vendor-prefixes.txt| 1 + drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c| 412 + 5 files changed, 456 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt create mode 100644 drivers/leds/leds-ktd2692.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 2/3] leds: ktd2692: add device tree bindings for ktd2692
This patch adds the device tree bindings for ktd2692 flash LEDs. Add optional properties 'flash-timeout-us' to control flash timeout and 'vin-supply' for flash-led regulator Signed-off-by: Ingi Kim --- .../devicetree/bindings/leds/leds-ktd2692.txt | 33 ++ 1 file changed, 33 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt new file mode 100644 index 000..f78512f --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt @@ -0,0 +1,33 @@ +* Kinetic Technologies - KTD2692 Flash LED Driver + +KTD2692 is the ideal power solution for high-power flash LEDs. +It uses ExpressWire single-wire programming for maximum flexibility. + +The ExpressWire interface through CTRL pin can control LED on/off and +enable/disable the IC, Movie(max 1/3 of Flash current) / Flash mode current, +Flash timeout, LVP(low voltage protection). + +Also, When the AUX pin is pulled high while CTRL pin is high, +LED current will be ramped up to the flash-mode current level. + +Required properties: + - compatible: "kinetic,ktd2692" + - ctrl-gpio, aux-gpio : gpio pins in order control ktd2692 flash led. + There is an internal 300kOhm pull-down resistor at each pin + - vin-supply : "vin" LED supply (2.7V to 5.5V) + See Documentation/devicetree/bindings/regulator/regulator.txt + +Optional property: + - flash-timeout-us : Maximum flash timeout in microseconds. + flash timeout ranges from 0 to 1835000us and + default is 1049000us. + +Example: + +flash-led { + compatible = "kinetic,ktd2692"; + ctrl-gpio = <&gpc0 1 0>; + aux-gpio = <&gpc0 2 0>; + flash-timeout-us = <1835000>; + vin-supply = <&vbat>; +}; -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 1/3] of: Add vendor prefix for Kinetic technologies
This patch adds vendor prefix for Kinetic technologies Signed-off-by: Ingi Kim Acked-by: Rob Herring --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 389ca13..de9e126 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -98,6 +98,7 @@ isee ISEE 2007 S.L. isil Intersil karo Ka-Ro electronics GmbH keymileKeymile GmbH +kinetic Kinetic Technologies lacie LaCie lantiq Lantiq Semiconductor lenovo Lenovo Group Ltd. -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4 3/3] leds: Add ktd2692 flash LED driver
This patch adds a driver to support the ktd2692 flash LEDs. ktd2692 can control flash current by ExpressWire interface. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig| 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c | 412 3 files changed, 422 insertions(+) create mode 100644 drivers/leds/leds-ktd2692.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 25b320d..9311cfc4 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -498,6 +498,15 @@ config LEDS_MENF21BMC This driver can also be built as a module. If so the module will be called leds-menf21bmc. +config LEDS_KTD2692 + tristate "Flash LED support for the KTD2692 Driver" + depends on LEDS_CLASS_FLASH && GPIOLIB + help + This option enables support for the KTD2692 connected through + ExpressWire Interface. Say Y to enabled these. + It depends on LEDS_CLASS_FLASH for using flash led (strobe) and + GPIOLIB for using gpio pin to control Expresswire interface + comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" config LEDS_BLINKM diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index cbba921..289513b 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o +obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c new file mode 100644 index 000..c31ec9d --- /dev/null +++ b/drivers/leds/leds-ktd2692.c @@ -0,0 +1,412 @@ +/* + * LED driver : leds-ktd2692.c + * + * Copyright (C) 2015 Samsung Electronics + * Ingi Kim + * + * 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 + +#define GET_BIT(bit, val) (((val) >> (bit)) & 0x01) + +/* Value related the flash mode */ +#define KTD2692_FLASH_MODE_TIMEOUT_LEVELS 8 +#define KTD2692_FLASH_MODE_TIMEOUT_DISABLE 0 +#define KTD2692_FLASH_MODE_TIMEOUT_DEFAULT_US 1049000 +#define KTD2692_FLASH_MODE_TIMEOUT_MAX_US 1835000 +#define KTD2692_FLASH_MODE_CURR_PERCENT(x) (((x) * 16) / 100) + +/* Macro for getting offset of flash timeout */ +#define GET_TIMEOUT_OFFSET(timeout, step) ((timeout) / (step)) + +/* Adjust a multiple of brightness */ +#define KTD2692_BRIGHTNESS_RANGE_255_TO_16(x) (((x) >> 4) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_8(x) (((x) >> 5) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_4(x) (((x) >> 6) & 0x0F) + +/* Base register address */ +#define KTD2692_REG_LVP_BASE 0x00 +#define KTD2692_REG_FLASH_TIMEOUT_BASE 0x20 +#define KTD2692_REG_MIN_CURRENT_SET_BASE 0x40 +#define KTD2692_REG_MOVIE_CURRENT_BASE 0x60 +#define KTD2692_REG_FLASH_CURRENT_BASE 0x80 +#define KTD2692_REG_MODE_BASE 0xA0 + +/* Set bit coding time for expresswire interface */ +#define KTD2692_TIME_RESET_US 700 +#define KTD2692_TIME_DATA_START_TIME_US10 +#define KTD2692_TIME_HIGH_END_OF_DATA_US 350 +#define KTD2692_TIME_LOW_END_OF_DATA_US10 +#define KTD2692_TIME_SHORT_BITSET_US 4 +#define KTD2692_TIME_LONG_BITSET_US12 + +/* KTD2692 default length of name */ +#define KTD2692_NAME_LENGTH20 + +/* KTD2692 default name */ +#define KTD2692_DEFAULT_NAME "ktd2692" + +enum ktd2692_bitset { + KTD2692_LOW = 0, + KTD2692_HIGH, +}; + +/* Movie / Flash Mode Control */ +enum ktd2692_led_mode { + KTD2692_MODE_DISABLE = 0, /* default */ + KTD2692_MODE_MOVIE, + KTD2692_MODE_FLASH, +}; + +struct ktd2692_context { + /* Related LED Flash class device */ + struct led_classdev_flash fled_cdev; + + struct mutex lock; + struct regulator *regulator; + struct work_struct work_brightness_set; + + int aux_gpio; + int ctrl_gpio; + + enum ktd2692_led_mode mode; + enum led_brightness torch_brightness; +}; + +static struct ktd2692_context *fled_cdev_to_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct ktd2692_context, fled_cdev); +} + +static void ktd2692_led_regulator_enable(struct ktd2692_context *led) +{ + struct led_clas
Re: [PATCH v3 3/3] leds: Add ktd2692 flash LED driver
Hi Jacek, On 2015년 03월 21일 01:26, Jacek Anaszewski wrote: > Hi Ingi, > > Thanks for the update. > > On 03/20/2015 06:31 AM, Ingi Kim wrote: >> This patch adds a driver to support the ktd2692 flash LEDs. >> ktd2692 can control flash current by ExpressWire interface. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig| 9 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-ktd2692.c | 438 >> >> 3 files changed, 448 insertions(+) >> create mode 100644 drivers/leds/leds-ktd2692.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index 25b320d..9311cfc4 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -498,6 +498,15 @@ config LEDS_MENF21BMC >> This driver can also be built as a module. If so the module >> will be called leds-menf21bmc. >> >> +config LEDS_KTD2692 >> +tristate "Flash LED support for the KTD2692 Driver" >> +depends on LEDS_CLASS_FLASH && GPIOLIB >> +help >> + This option enables support for the KTD2692 connected through >> + ExpressWire Interface. Say Y to enabled these. >> + It depends on LEDS_CLASS_FLASH for using flash led (strobe) and >> + GPIOLIB for using gpio pin to control Expresswire interface >> + >> comment "LED driver for blink(1) USB RGB LED is under Special HID drivers >> (HID_THINGM)" >> >> config LEDS_BLINKM >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index cbba921..289513b 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM)+= leds-blinkm.o >> obj-$(CONFIG_LEDS_SYSCON)+= leds-syscon.o >> obj-$(CONFIG_LEDS_VERSATILE)+= leds-versatile.o >> obj-$(CONFIG_LEDS_MENF21BMC)+= leds-menf21bmc.o >> +obj-$(CONFIG_LEDS_KTD2692)+= leds-ktd2692.o >> >> # LED SPI Drivers >> obj-$(CONFIG_LEDS_DAC124S085)+= leds-dac124s085.o >> diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c >> new file mode 100644 >> index 000..38d6145 >> --- /dev/null >> +++ b/drivers/leds/leds-ktd2692.c >> @@ -0,0 +1,438 @@ >> +/* >> + * LED driver : leds-ktd2692.c >> + * >> + * Copyright (C) 2015 Samsung Electronics >> + * Ingi Kim >> + * >> + * 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 >> + >> +#define GET_BIT(bit, val)(((val) >> (bit)) & 0x01) >> + >> +/* Value related the flash mode */ >> +#define KTD2692_FLASH_MODE_TIMEOUT_LEVELS8 >> +#define KTD2692_FLASH_MODE_TIMEOUT_DISABLE0 >> +#define KTD2692_FLASH_MODE_TIMEOUT_DEFAULT_US1049000 >> +#define KTD2692_FLASH_MODE_TIMEOUT_MAX_US1835000 >> +#define KTD2692_FLASH_MODE_CURR_PERCENT(x)(((x) * 16) / 100) >> + >> +/* Macro for getting offset of flash timeout */ >> +#define GET_TIMEOUT_OFFSET(timeout, step)((timeout) / (step)) >> + >> +/* Adjust a multiple of brightness */ >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_16(x)(((x) >> 4) & 0x0F) >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_8(x)(((x) >> 5) & 0x0F) >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_4(x)(((x) >> 6) & 0x0F) >> + >> +/* Base register address */ >> +#define KTD2692_REG_LVP_BASE0x00 >> +#define KTD2692_REG_FLASH_TIMEOUT_BASE0x20 >> +#define KTD2692_REG_MIN_CURRENT_SET_BASE0x40 >> +#define KTD2692_REG_MOVIE_CURRENT_BASE0x60 >> +#define KTD2692_REG_FLASH_CURRENT_BASE0x80 >> +#define KTD2692_REG_MODE_BASE0xA0 >> + >> +/* Set bit coding time for expresswire interface */ >> +#define KTD2692_TIME_RESET_US700 >> +#define KTD2692_TIME_DATA_START_TIME_US10 >> +#define KTD2692_TIME_HIGH_END_OF_DATA_US350 >> +#define KTD2692_TIME_LOW_END_OF_DATA_US10 >> +#define KTD2692_TIME_SHORT_BITSET_US4 >> +#define KTD2692_TIME_LONG_BITSET_US12 >> + >> +/* KTD2692 default length of name */ >> +#define KTD2692_NAME_LENGTH20 >> + >&g
Re: [PATCH v3 2/3] leds: ktd2692: add device tree bindings for ktd2692
Hi, Rob On 2015년 03월 21일 00:49, Rob Herring wrote: > On Fri, Mar 20, 2015 at 12:31 AM, Ingi Kim wrote: >> This patch adds the device tree bindings for ktd2692 flash LEDs. >> Add optional properties 'flash-timeout-us' to control flash timeout >> and 'vin-supply' for flash-led regulator >> >> Signed-off-by: Ingi Kim >> --- >> .../devicetree/bindings/leds/leds-ktd2692.txt | 34 >> ++ >> 1 file changed, 34 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> >> diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> new file mode 100644 >> index 000..75e16f8 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> @@ -0,0 +1,34 @@ >> +* Kinetic Technologies - KTD2692 Flash LED Driver >> + >> +KTD2692 is the ideal power solution for high-power flash LEDs. >> +It uses ExpressWire single-wire programming for maximum flexibility. >> + >> +The ExpressWire interface through CTRL pin can control LED on/off and >> +enable/disable the IC, Movie(max 1/3 of Flash current) / Flash mode current, >> +Flash timeout, LVP(low voltage protection). >> + >> +Also, When the AUX pin is pulled high while CTRL pin is high, >> +LED current will be ramped up to the flash-mode current level. >> + >> +Required properties: >> + - compatible: "kinetic,ktd2692" >> + - ctrl-gpio, aux-gpio : gpio pin in order control ktd2692 flash led. >> + There is an internal 300kOhm pull-down resistor at each pin >> + - supply : "vin" LED supply (2.7V to 5.5V) > > This should be "vin-supply", right? > Yes, You are right. "vin-supply" is more exact than before. I'll fix it Thanks >> + See Documentation/devicetree/bindings/regulator/regulator.txt >> + >> +Optional property: >> + - flash-timeout-us : Maximum flash timeout in microseconds. >> + flash timeout ranges from 0 to 1835000us and >> + default is 1049000us. >> + >> +Example: >> + >> +flash-led { >> + compatible = "kinetic,ktd2692"; >> + ctrl-gpio = <&gpc0 1 0>; >> + aux-gpio = <&gpc0 2 0>; >> + flash-timeout-us = <1835000>; >> + vin-supply = <&vbat>; >> +}; >> + >> -- >> 2.0.5 >> > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 1/3] of: Add vendor prefix for Kinetic technologies
Hi Rob, On 2015년 03월 21일 00:46, Rob Herring wrote: > On Fri, Mar 20, 2015 at 12:31 AM, Ingi Kim wrote: >> This patch adds vendor prefix for Kinetic technologies >> >> Signed-off-by: Ingi Kim > > Acked-by: Rob Herring > Sure, I'll fix Thanks >> --- >> Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt >> b/Documentation/devicetree/bindings/vendor-prefixes.txt >> index fae26d0..90a4be1 100644 >> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt >> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt >> @@ -100,6 +100,7 @@ iseeISEE 2007 S.L. >> isil Intersil >> karo Ka-Ro electronics GmbH >> keymileKeymile GmbH >> +kinetic Kinetic Technologies >> lacie LaCie >> lantiq Lantiq Semiconductor >> lenovo Lenovo Group Ltd. >> -- >> 2.0.5 >> > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/3] leds: ktd2692: add device tree bindings for ktd2692
This patch adds the device tree bindings for ktd2692 flash LEDs. Add optional properties 'flash-timeout-us' to control flash timeout and 'vin-supply' for flash-led regulator Signed-off-by: Ingi Kim --- .../devicetree/bindings/leds/leds-ktd2692.txt | 34 ++ 1 file changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt new file mode 100644 index 000..75e16f8 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt @@ -0,0 +1,34 @@ +* Kinetic Technologies - KTD2692 Flash LED Driver + +KTD2692 is the ideal power solution for high-power flash LEDs. +It uses ExpressWire single-wire programming for maximum flexibility. + +The ExpressWire interface through CTRL pin can control LED on/off and +enable/disable the IC, Movie(max 1/3 of Flash current) / Flash mode current, +Flash timeout, LVP(low voltage protection). + +Also, When the AUX pin is pulled high while CTRL pin is high, +LED current will be ramped up to the flash-mode current level. + +Required properties: + - compatible: "kinetic,ktd2692" + - ctrl-gpio, aux-gpio : gpio pin in order control ktd2692 flash led. + There is an internal 300kOhm pull-down resistor at each pin + - supply : "vin" LED supply (2.7V to 5.5V) + See Documentation/devicetree/bindings/regulator/regulator.txt + +Optional property: + - flash-timeout-us : Maximum flash timeout in microseconds. + flash timeout ranges from 0 to 1835000us and + default is 1049000us. + +Example: + +flash-led { + compatible = "kinetic,ktd2692"; + ctrl-gpio = <&gpc0 1 0>; + aux-gpio = <&gpc0 2 0>; + flash-timeout-us = <1835000>; + vin-supply = <&vbat>; +}; + -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 0/3] Add ktd2692 Flash LED driver using LED Flash class
This patch adds ktd2692 Flash LED driver with LED Flash class Change in v3: - Clean up the code - Add aux gpio pin to control Flash LED Change in v2: - Introduction of LED Flash class as Jacek's comment - Supplement of binding documentation - Rename gpio control pin and remove unused pin - Add regulator for the Flash LED Ingi Kim (3): of: Add vendor prefix for Kinetic technologies leds: ktd2692: add device tree bindings for ktd2692 leds: Add ktd2692 flash LED driver .../devicetree/bindings/leds/leds-ktd2692.txt | 34 ++ .../devicetree/bindings/vendor-prefixes.txt| 1 + drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c| 438 + 5 files changed, 483 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt create mode 100644 drivers/leds/leds-ktd2692.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/3] of: Add vendor prefix for Kinetic technologies
This patch adds vendor prefix for Kinetic technologies Signed-off-by: Ingi Kim --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index fae26d0..90a4be1 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -100,6 +100,7 @@ iseeISEE 2007 S.L. isil Intersil karo Ka-Ro electronics GmbH keymileKeymile GmbH +kinetic Kinetic Technologies lacie LaCie lantiq Lantiq Semiconductor lenovo Lenovo Group Ltd. -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 3/3] leds: Add ktd2692 flash LED driver
This patch adds a driver to support the ktd2692 flash LEDs. ktd2692 can control flash current by ExpressWire interface. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig| 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c | 438 3 files changed, 448 insertions(+) create mode 100644 drivers/leds/leds-ktd2692.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 25b320d..9311cfc4 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -498,6 +498,15 @@ config LEDS_MENF21BMC This driver can also be built as a module. If so the module will be called leds-menf21bmc. +config LEDS_KTD2692 + tristate "Flash LED support for the KTD2692 Driver" + depends on LEDS_CLASS_FLASH && GPIOLIB + help + This option enables support for the KTD2692 connected through + ExpressWire Interface. Say Y to enabled these. + It depends on LEDS_CLASS_FLASH for using flash led (strobe) and + GPIOLIB for using gpio pin to control Expresswire interface + comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" config LEDS_BLINKM diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index cbba921..289513b 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o +obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c new file mode 100644 index 000..38d6145 --- /dev/null +++ b/drivers/leds/leds-ktd2692.c @@ -0,0 +1,438 @@ +/* + * LED driver : leds-ktd2692.c + * + * Copyright (C) 2015 Samsung Electronics + * Ingi Kim + * + * 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 + +#define GET_BIT(bit, val) (((val) >> (bit)) & 0x01) + +/* Value related the flash mode */ +#define KTD2692_FLASH_MODE_TIMEOUT_LEVELS 8 +#define KTD2692_FLASH_MODE_TIMEOUT_DISABLE 0 +#define KTD2692_FLASH_MODE_TIMEOUT_DEFAULT_US 1049000 +#define KTD2692_FLASH_MODE_TIMEOUT_MAX_US 1835000 +#define KTD2692_FLASH_MODE_CURR_PERCENT(x) (((x) * 16) / 100) + +/* Macro for getting offset of flash timeout */ +#define GET_TIMEOUT_OFFSET(timeout, step) ((timeout) / (step)) + +/* Adjust a multiple of brightness */ +#define KTD2692_BRIGHTNESS_RANGE_255_TO_16(x) (((x) >> 4) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_8(x) (((x) >> 5) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_4(x) (((x) >> 6) & 0x0F) + +/* Base register address */ +#define KTD2692_REG_LVP_BASE 0x00 +#define KTD2692_REG_FLASH_TIMEOUT_BASE 0x20 +#define KTD2692_REG_MIN_CURRENT_SET_BASE 0x40 +#define KTD2692_REG_MOVIE_CURRENT_BASE 0x60 +#define KTD2692_REG_FLASH_CURRENT_BASE 0x80 +#define KTD2692_REG_MODE_BASE 0xA0 + +/* Set bit coding time for expresswire interface */ +#define KTD2692_TIME_RESET_US 700 +#define KTD2692_TIME_DATA_START_TIME_US10 +#define KTD2692_TIME_HIGH_END_OF_DATA_US 350 +#define KTD2692_TIME_LOW_END_OF_DATA_US10 +#define KTD2692_TIME_SHORT_BITSET_US 4 +#define KTD2692_TIME_LONG_BITSET_US12 + +/* KTD2692 default length of name */ +#define KTD2692_NAME_LENGTH20 + +/* KTD2692 default name */ +#define KTD2692_DEFAULT_NAME "ktd2692" + +enum ktd2692_bitset { + KTD2692_LOW = 0, + KTD2692_HIGH, +}; + +/* Movie / Flash Mode Control */ +enum ktd2692_led_mode { + KTD2692_MODE_DISABLE = 0, /* default */ + KTD2692_MODE_MOVIE, + KTD2692_MODE_FLASH, +}; + +struct ktd2692_flash_timeout_setting { + struct led_flash_setting flash_timeout; +}; + +struct ktd2692_context { + /* Related LED Flash class device */ + struct led_classdev_flash fled_cdev; + + struct mutex lock; + struct regulator *regulator; + struct work_struct work_brightness_set; + + int aux_gpio; + int ctrl_gpio; + + enum ktd2692_led_mode mode; + enum led_brightness torch_brightness; +}; + +static struct ktd2692_context *fled_cdev_to_led( + struct led_classdev_flash *fled_cdev) +{ + return container_of(fled_cdev, struct ktd2692_context, fled_cdev); +} + +static i
Re: [PATCH v2 3/3] leds: Add ktd2692 flash LED driver
Hi Jacek, On 2015년 03월 18일 18:57, Jacek Anaszewski wrote: > Hi Ingi, > > Thanks for the update. Please find my comments below. > > On 03/17/2015 09:45 AM, Ingi Kim wrote: >> This patch adds a driver to support the ktd2692 flash LEDs. >> ktd2692 can control flash current by ExpressWire interface. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig| 9 + >> drivers/leds/Makefile | 1 + >> drivers/leds/leds-ktd2692.c | 522 >> >> 3 files changed, 532 insertions(+) >> create mode 100644 drivers/leds/leds-ktd2692.c >> >> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig >> index 25b320d..9311cfc4 100644 >> --- a/drivers/leds/Kconfig >> +++ b/drivers/leds/Kconfig >> @@ -498,6 +498,15 @@ config LEDS_MENF21BMC >> This driver can also be built as a module. If so the module >> will be called leds-menf21bmc. >> >> +config LEDS_KTD2692 >> +tristate "Flash LED support for the KTD2692 Driver" >> +depends on LEDS_CLASS_FLASH && GPIOLIB >> +help >> + This option enables support for the KTD2692 connected through >> + ExpressWire Interface. Say Y to enabled these. >> + It depends on LEDS_CLASS_FLASH for using flash led (strobe) and >> + GPIOLIB for using gpio pin to control Expresswire interface >> + >> comment "LED driver for blink(1) USB RGB LED is under Special HID drivers >> (HID_THINGM)" >> >> config LEDS_BLINKM >> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile >> index cbba921..289513b 100644 >> --- a/drivers/leds/Makefile >> +++ b/drivers/leds/Makefile >> @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM)+= leds-blinkm.o >> obj-$(CONFIG_LEDS_SYSCON)+= leds-syscon.o >> obj-$(CONFIG_LEDS_VERSATILE)+= leds-versatile.o >> obj-$(CONFIG_LEDS_MENF21BMC)+= leds-menf21bmc.o >> +obj-$(CONFIG_LEDS_KTD2692)+= leds-ktd2692.o >> >> # LED SPI Drivers >> obj-$(CONFIG_LEDS_DAC124S085)+= leds-dac124s085.o >> diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c >> new file mode 100644 >> index 000..8aa339c >> --- /dev/null >> +++ b/drivers/leds/leds-ktd2692.c >> @@ -0,0 +1,522 @@ >> +/* >> + * LED driver : leds-ktd2692.c >> + * >> + * Copyright (C) 2015 Samsung Electronics >> + * Ingi Kim >> + * >> + * 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 > > Please keep alphabetical order - 'l' is before 'm'. > >> +#include >> +#include >> +#include >> +#include >> + >> +#define GET_BIT(bit, val)(((val) >> (bit)) & 0x01) >> + >> +/* Value related the flash timeout */ >> +#define KTD2692_FLASH_TM_LEVELS8 >> +#define KTD2692_DEFAULT_FLASH_TM_US1049000 >> +#define KTD2692_MAX_FLASH_TM_US1835000 >> + >> +/* Macro for getting offset of flash timeout */ >> +#define GET_TIMEOUT_OFFSET(timeout, step)((timeout) / (step)) >> + >> +/* Adjust a multiple of brightness */ >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_16(x)(((x) >> 4) & 0x0F) >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_8(x)(((x) >> 5) & 0x0F) >> +#define KTD2692_BRIGHTNESS_RANGE_255_TO_4(x)(((x) >> 6) & 0x0F) >> + >> +/* Base register address */ >> +#define KTD2692_REG_LVP_BASE0x00 >> +#define KTD2692_REG_FLASH_TIMEOUT_BASE0x20 >> +#define KTD2692_REG_MIN_CURRENT_SET_BASE0x40 >> +#define KTD2692_REG_MOVIE_CURRENT_BASE0x60 >> +#define KTD2692_REG_FLASH_CURRENT_BASE0x80 >> +#define KTD2692_REG_MODE_BASE0xA0 >> + >> +/* Set bit coding time for expresswire interface */ >> +#define KTD2692_TIME_RESET_US700 >> +#define KTD2692_TIME_DATA_START_TIME_US10 >> +#define KTD2692_TIME_HIGH_END_OF_DATA_US350 >> +#define KTD2692_TIME_LOW_END_OF_DATA_US10 >> +#define KTD2692_TIME_SHORT_BITSET_US4 >> +#define KTD2692_TIME_LONG_BITSET_US12 >> + >> +/* KTD2692 default length of name */ >> +#define KTD2692_NAME_LENGTH20 >> +
Re: [PATCH v2 2/3] leds: ktd2692: add device tree bindings for ktd2692
Hi On 2015년 03월 18일 07:40, Jaehoon Chung wrote: > On 03/17/2015 05:45 PM, Ingi Kim wrote: >> This patch adds the device tree bindings for ktd2692 flash LEDs. >> Add optional properties 'flash-timeout-us' to control flash timeout >> and 'vin-supply' for flash-led regulator >> >> Signed-off-by: Ingi Kim >> --- >> .../devicetree/bindings/leds/leds-ktd2692.txt | 37 >> ++ >> 1 file changed, 37 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> >> diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> new file mode 100644 >> index 000..1b44225 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> @@ -0,0 +1,37 @@ >> +* Kinetic Technologies - KTD2692 Flash LED Driver >> + >> +KTD2692 is the ideal power solution for high-power flash LEDs. >> +It uses ExpressWire single-wire programming for maximum flexibility. >> + >> +The ExpressWire interface through CTRL pin can control LED on/off and >> +enable/disable the IC, Movie/Flash mode current, Flash timeout, >> +LVP(low voltage protection). >> + >> +Required properties: >> +- compatible: "kinetic,ktd2692" >> +- ctrl-gpio : gpio pin in order control ktd2692 flash led. >> +There is an internal 300kOhm pull-down resistor at this pin >> +- supply : "vin" LED supply >> + >> +Optional property: >> +- flash-timeout-us : Maximum flash timeout in microseconds. >> +flash timeout ranges from 0 to 1835000us and >> +default is 1049000us. >> + >> +Example: >> + >> +vbat: fixedregulator@0 { >> +compatible = "regulator-fixed"; >> +regulator-name = "vbat-supply"; >> +regulator-min-microvolt = <500>; >> +regulator-max-microvolt = <500>; >> +gpio = <>; > > gpio = <> ? What do you mean? > And this is described at > Documentation/devicetree/bindings/regulator/fixed-regulator.txt > I'm not sure whether this example really needs. > > Best Regards, > Jaehoon Chung > I just want to show that dummy regulator can be used with flash-led. As you mentioned earlier, remove unnecessary example and add refer comment Thanks, Ingi Kim >> +regulator-always-on; >> +}; >> + >> +flash-led { >> +compatible = "kinetic,ktd2692"; >> +ctrl-gpio = <&gpc0 1 0>; >> +flash-timeout-us = <1835000>; >> +vin-supply = <&vbat>; >> +}; >> > > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/3] of: Add vendor prefix for Kinetic technologies
This patch adds vendor prefix for Kinetic technologies Signed-off-by: Ingi Kim --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 389ca13..de9e126 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -98,6 +98,7 @@ isee ISEE 2007 S.L. isil Intersil karo Ka-Ro electronics GmbH keymileKeymile GmbH +kinetic Kinetic Technologies lacie LaCie lantiq Lantiq Semiconductor lenovo Lenovo Group Ltd. -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/3] leds: ktd2692: add device tree bindings for ktd2692
This patch adds the device tree bindings for ktd2692 flash LEDs. Add optional properties 'flash-timeout-us' to control flash timeout and 'vin-supply' for flash-led regulator Signed-off-by: Ingi Kim --- .../devicetree/bindings/leds/leds-ktd2692.txt | 37 ++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt new file mode 100644 index 000..1b44225 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt @@ -0,0 +1,37 @@ +* Kinetic Technologies - KTD2692 Flash LED Driver + +KTD2692 is the ideal power solution for high-power flash LEDs. +It uses ExpressWire single-wire programming for maximum flexibility. + +The ExpressWire interface through CTRL pin can control LED on/off and +enable/disable the IC, Movie/Flash mode current, Flash timeout, +LVP(low voltage protection). + +Required properties: + - compatible: "kinetic,ktd2692" + - ctrl-gpio : gpio pin in order control ktd2692 flash led. + There is an internal 300kOhm pull-down resistor at this pin + - supply : "vin" LED supply + +Optional property: + - flash-timeout-us : Maximum flash timeout in microseconds. + flash timeout ranges from 0 to 1835000us and + default is 1049000us. + +Example: + +vbat: fixedregulator@0 { + compatible = "regulator-fixed"; + regulator-name = "vbat-supply"; + regulator-min-microvolt = <500>; + regulator-max-microvolt = <500>; + gpio = <>; + regulator-always-on; +}; + +flash-led { + compatible = "kinetic,ktd2692"; + ctrl-gpio = <&gpc0 1 0>; + flash-timeout-us = <1835000>; + vin-supply = <&vbat>; +}; -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/3] leds: Add ktd2692 flash LED driver
This patch adds a driver to support the ktd2692 flash LEDs. ktd2692 can control flash current by ExpressWire interface. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig| 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c | 522 3 files changed, 532 insertions(+) create mode 100644 drivers/leds/leds-ktd2692.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 25b320d..9311cfc4 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -498,6 +498,15 @@ config LEDS_MENF21BMC This driver can also be built as a module. If so the module will be called leds-menf21bmc. +config LEDS_KTD2692 + tristate "Flash LED support for the KTD2692 Driver" + depends on LEDS_CLASS_FLASH && GPIOLIB + help + This option enables support for the KTD2692 connected through + ExpressWire Interface. Say Y to enabled these. + It depends on LEDS_CLASS_FLASH for using flash led (strobe) and + GPIOLIB for using gpio pin to control Expresswire interface + comment "LED driver for blink(1) USB RGB LED is under Special HID drivers (HID_THINGM)" config LEDS_BLINKM diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index cbba921..289513b 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o +obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c new file mode 100644 index 000..8aa339c --- /dev/null +++ b/drivers/leds/leds-ktd2692.c @@ -0,0 +1,522 @@ +/* + * LED driver : leds-ktd2692.c + * + * Copyright (C) 2015 Samsung Electronics + * Ingi Kim + * + * 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 + +#define GET_BIT(bit, val) (((val) >> (bit)) & 0x01) + +/* Value related the flash timeout */ +#define KTD2692_FLASH_TM_LEVELS8 +#define KTD2692_DEFAULT_FLASH_TM_US1049000 +#define KTD2692_MAX_FLASH_TM_US1835000 + +/* Macro for getting offset of flash timeout */ +#define GET_TIMEOUT_OFFSET(timeout, step) ((timeout) / (step)) + +/* Adjust a multiple of brightness */ +#define KTD2692_BRIGHTNESS_RANGE_255_TO_16(x) (((x) >> 4) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_8(x) (((x) >> 5) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_4(x) (((x) >> 6) & 0x0F) + +/* Base register address */ +#define KTD2692_REG_LVP_BASE 0x00 +#define KTD2692_REG_FLASH_TIMEOUT_BASE 0x20 +#define KTD2692_REG_MIN_CURRENT_SET_BASE 0x40 +#define KTD2692_REG_MOVIE_CURRENT_BASE 0x60 +#define KTD2692_REG_FLASH_CURRENT_BASE 0x80 +#define KTD2692_REG_MODE_BASE 0xA0 + +/* Set bit coding time for expresswire interface */ +#define KTD2692_TIME_RESET_US 700 +#define KTD2692_TIME_DATA_START_TIME_US10 +#define KTD2692_TIME_HIGH_END_OF_DATA_US 350 +#define KTD2692_TIME_LOW_END_OF_DATA_US10 +#define KTD2692_TIME_SHORT_BITSET_US 4 +#define KTD2692_TIME_LONG_BITSET_US12 + +/* KTD2692 default length of name */ +#define KTD2692_NAME_LENGTH20 + +/* KTD2692 default name */ +#define KTD2692_DEFAULT_NAME "ktd2692" + +enum ktd2692_bitset { + KTD2692_LOW = 0, + KTD2692_HIGH, +}; + +/* Low Voltage Protection Setting */ +enum ktd2692_lvp_setting { + KTD2692_LVP_DISABLE = 0, + KTD2692_LVP_3_2V, + KTD2692_LVP_3_3V, + KTD2692_LVP_3_4V, /* default */ + KTD2692_LVP_3_5V, + KTD2692_LVP_3_6V, + KTD2692_LVP_3_7V, + KTD2692_LVP_3_8V, +}; + +/* Flash Timeout Setting (msec) */ +enum ktd2692_timeout_setting { + KTD2692_TIMEOUT_DISABLE = 0, + KTD2692_TIMEOUT_262ms, + KTD2692_TIMEOUT_524ms, + KTD2692_TIMEOUT_786ms, + KTD2692_TIMEOUT_1049ms, /* default */ + KTD2692_TIMEOUT_1311ms, + KTD2692_TIMEOUT_1573ms, + KTD2692_TIMEOUT_1835ms, +}; + +/* Minimum Current Setting for Timer Operating */ +enum ktd2692_min_current_setting { + KTD2692_MIN_CURRENT_90mA = 0, + KTD2692_MIN_CURRENT_120mA, + KTD2692_MIN_CURRENT_150mA, + KTD2692_MIN_CURRENT_180mA, + KTD2692_MIN_CURRENT_210mA, + K
[PATCH v2 0/3] Add ktd2692 Flash LED driver using LED Flash class
This patch adds ktd2692 Flash LED driver with LED Flash class Change in v2: - Introduction of LED Flash class as Jacek's comment - Supplement of binding documentation - Rename gpio control pin and remove unused pin - Add regulator for the Flash LED Ingi Kim (3): of: Add vendor prefix for Kinetic technologies leds: ktd2692: add device tree bindings for ktd2692 leds: Add ktd2692 flash LED driver .../devicetree/bindings/leds/leds-ktd2692.txt | 37 ++ .../devicetree/bindings/vendor-prefixes.txt| 1 + drivers/leds/Kconfig | 9 + drivers/leds/Makefile | 1 + drivers/leds/leds-ktd2692.c| 522 + 5 files changed, 570 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt create mode 100644 drivers/leds/leds-ktd2692.c -- 2.0.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/3] Add ktd2692 Flash LED driver
Hi On 2015년 03월 03일 07:03, Sakari Ailus wrote: > Hi Bryan, > > On Mon, Mar 02, 2015 at 12:07:42PM -0800, Bryan Wu wrote: >> On Mon, Mar 2, 2015 at 1:15 AM, Sakari Ailus wrote: >>> H Ingi, >>> >>> On Mon, Mar 02, 2015 at 04:14:39PM +0900, Ingi Kim wrote: >>>> Hi Jacek >>>> >>>> On 2015년 02월 27일 17:42, Jacek Anaszewski wrote: >>>>> Hi Ingi, >>>>> >>>>> On 02/27/2015 02:01 AM, Ingi Kim wrote: >>>>>> This patch supports KTD2692 flash LED driver >>>>>> >>>>>> Ingi Kim (3): >>>>>>of: Add vendor prefix for Kinetic technologies >>>>>>leds: ktd2692: add device tree bindings for ktd2692 >>>>>>leds: Add ktd2692 flash LED driver >>>>>> >>>>>> .../devicetree/bindings/leds/leds-ktd2692.txt | 19 ++ >>>>>> .../devicetree/bindings/vendor-prefixes.txt|1 + >>>>>> drivers/leds/Kconfig |8 + >>>>>> drivers/leds/Makefile |1 + >>>>>> drivers/leds/leds-ktd2692.c| 245 >>>>>> >>>>>> 5 files changed, 274 insertions(+) >>>>>> create mode 100644 >>>>>> Documentation/devicetree/bindings/leds/leds-ktd2692.txt >>>>>> create mode 100644 drivers/leds/leds-ktd2692.c >>>>>> >>>>> >>>>> In your device tree binding documentation there is torch-gpio mentioned, >>>>> but you seem not to use it in the driver. >>>>> >>>>> We have already LED Flash class (/drivers/leds/led-class-flash.c) for >>>>> this type of devices, which handles both torch and flash modes >>>>> (flash_strobe sysfs attribute is provided for strobing the flash). >>>>> >>>>> The reference drivers using LED Flash class are still pending [1], but I >>>>> think that at least leds-aat1290 driver is almost ready for merging. >>>>> It controls very similar device to yours. >>>>> >>>>> Another advantage of using LED Flash class is that it has been designed >>>>> to be compatible with Video for Linux 2 subsystem, which will allow for >>>>> registering LED Flash class devices as a V4L2 sub-devices. >>>>> >>>>> Adding Sakari. >>>>> >>>> >>>> Ok, I'll check LED Flash class, and add torch-gpio >>> >>> Many LED flash chips include a hardware pin for torch control but few really >>> need it. If you don't, i.e. you can implement the torch using the control >>> bus >>> instead, I think I'd probably drop it from the chip's DT bindings. >>> >> >> Ingi, please follow Jacek's advice to use LED Flash class interface. >> I'm reviewing those leds flash drivers and probably merge them soon. >> >> Jacek and Sakari thanks for the review. >> >> Sakari, so what's the control bus your mentioned here? > > I wasn't cc'd in the original patch so I didn't know whether it was I2C or > not. Doesn't appear to be. > Thanks for the review and I'll work to use LED Flash class interface and try adding torch-gpio(flash mode enable) line (I'll rename those gpio lines) Sakari, ktd2692 flash led device is controlled through Expresswire single-wire interface by using the strobe-gpio(control) pin. Adding pin information of the KTD2692. CTRL pin can control LED on/off and Movie/Flash mode current, Flash timeout, LVP(low voltage protection). AUX pin(torch-gpio) allows highest priority ON/OFF flash mode control. -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 0/3] Add ktd2692 Flash LED driver
Hi Jacek On 2015년 02월 27일 17:42, Jacek Anaszewski wrote: > Hi Ingi, > > On 02/27/2015 02:01 AM, Ingi Kim wrote: >> This patch supports KTD2692 flash LED driver >> >> Ingi Kim (3): >>of: Add vendor prefix for Kinetic technologies >>leds: ktd2692: add device tree bindings for ktd2692 >>leds: Add ktd2692 flash LED driver >> >> .../devicetree/bindings/leds/leds-ktd2692.txt | 19 ++ >> .../devicetree/bindings/vendor-prefixes.txt|1 + >> drivers/leds/Kconfig |8 + >> drivers/leds/Makefile |1 + >> drivers/leds/leds-ktd2692.c| 245 >> >> 5 files changed, 274 insertions(+) >> create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt >> create mode 100644 drivers/leds/leds-ktd2692.c >> > > In your device tree binding documentation there is torch-gpio mentioned, > but you seem not to use it in the driver. > > We have already LED Flash class (/drivers/leds/led-class-flash.c) for > this type of devices, which handles both torch and flash modes > (flash_strobe sysfs attribute is provided for strobing the flash). > > The reference drivers using LED Flash class are still pending [1], but I > think that at least leds-aat1290 driver is almost ready for merging. > It controls very similar device to yours. > > Another advantage of using LED Flash class is that it has been designed > to be compatible with Video for Linux 2 subsystem, which will allow for > registering LED Flash class devices as a V4L2 sub-devices. > > Adding Sakari. > Ok, I'll check LED Flash class, and add torch-gpio Thanks, Adding Seung-woo Kim and Inha Song -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] leds: Add ktd2692 flash LED driver
hi On 2015년 02월 27일 12:36, Varka Bhadram wrote: > On 02/27/2015 06:31 AM, Ingi Kim wrote: >> This patch adds a driver to support the ktd2692 flash LEDs. >> ktd2692 can control flash current by ExpressWire interface. >> >> Signed-off-by: Ingi Kim >> --- >> drivers/leds/Kconfig|8 ++ >> drivers/leds/Makefile |1 + >> drivers/leds/leds-ktd2692.c | 245 >> +++ >> 3 files changed, 254 insertions(+) >> create mode 100644 drivers/leds/leds-ktd2692.c >> > (...) > >> +static struct ktd2692_context *ktd2692_parse_dt(struct device *dev) >> +{ >> + struct device_node *np = dev->of_node; >> + struct ktd2692_context *led; >> + >> + led = devm_kzalloc(dev, sizeof(struct ktd2692_context), GFP_KERNEL); >> + if (!led) >> + return ERR_PTR((long)led); > > What about using sizeof(*led) in place of sizeof(struct ktd2692_context)..? > > Also the error return for devm_kzalloc() should be -ENOMEM. > Thanks, I'll check and change sizeof() and error return style. >> + >> + led->strobe_gpio = of_get_named_gpio(np, "strobe-gpio", 0); >> + if (!gpio_is_valid(led->strobe_gpio)) { >> + dev_err(dev, "no strobe_gpio property found\n"); >> + return ERR_PTR(led->strobe_gpio); >> + } >> + >> + return led; >> +} >> + >> +static int ktd2692_probe(struct platform_device *pdev) >> +{ >> + struct device *dev = &pdev->dev; >> + struct ktd2692_context *led; >> + int ret; >> + >> + if (!dev->of_node) >> + return -ENODEV; >> + >> + led = ktd2692_parse_dt(dev); >> + if (IS_ERR(led)) >> + return PTR_ERR(led); >> + >> + led->cdev.name = KTD2692_DEFAULT_NAME; >> + led->cdev.brightness = LED_OFF; >> + led->cdev.max_brightness = LED_FULL; >> + led->cdev.flags |= LED_CORE_SUSPENDRESUME; >> + led->cdev.brightness_set = ktd2692_brightness_set; >> + led->cdev.brightness_get = ktd2692_brightness_get; >> + led->mode = KTD2692_REG_MODE_BASE | KTD2692_MODE_DISABLE; >> + >> + platform_set_drvdata(pdev, led); >> + >> + ret = led_classdev_register(&pdev->dev, &led->cdev); >> + if (ret) { >> + dev_err(dev, "couldn't register LED %s\n", led->cdev.name); >> + return ret; >> + } >> + >> + ret = ktd2692_brightness_set_gpio(led); >> + if (ret) { >> + led_classdev_unregister(&led->cdev); >> + return ret; >> + } >> + >> + ktd2692_expresswire_reset(led); >> + >> + return ret; > > return 0 instead of ret...? > > > I'll check and try Thanks, -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] leds: Add ktd2692 flash LED driver
This patch adds a driver to support the ktd2692 flash LEDs. ktd2692 can control flash current by ExpressWire interface. Signed-off-by: Ingi Kim --- drivers/leds/Kconfig|8 ++ drivers/leds/Makefile |1 + drivers/leds/leds-ktd2692.c | 245 +++ 3 files changed, 254 insertions(+) create mode 100644 drivers/leds/leds-ktd2692.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 25b320d..f8870db 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -526,6 +526,14 @@ config LEDS_VERSATILE This option enabled support for the LEDs on the ARM Versatile and RealView boards. Say Y to enabled these. +config LEDS_KTD2692 + tristate "LED support for the KTD2692 Driver" + depends on LEDS_CLASS + depends on GPIOLIB + help + This option enables support for the KTD2692 connected through + ExpressWire Interface. Say Y to enable these. + comment "LED Triggers" source "drivers/leds/trigger/Kconfig" diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index cbba921..289513b 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_SYSCON) += leds-syscon.o obj-$(CONFIG_LEDS_VERSATILE) += leds-versatile.o obj-$(CONFIG_LEDS_MENF21BMC) += leds-menf21bmc.o +obj-$(CONFIG_LEDS_KTD2692) += leds-ktd2692.o # LED SPI Drivers obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c new file mode 100644 index 000..9c98689 --- /dev/null +++ b/drivers/leds/leds-ktd2692.c @@ -0,0 +1,245 @@ +/* + * Kinetic Technologies KTD2692 Flash LED Driver + * + * Copyright (C) 2015 Samsung Electronics + * Ingi Kim + * + * 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 + +#define GET_BIT(bit, val) (((val) >> (bit)) & 0x01) + +/* Adjust a multiple of brightness */ +#define KTD2692_BRIGHTNESS_RANGE_255_TO_16(x) (((x) >> 4) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_8(x) (((x) >> 5) & 0x0F) +#define KTD2692_BRIGHTNESS_RANGE_255_TO_4(x) (((x) >> 6) & 0x0F) + +/* Base register address */ +#define KTD2692_REG_LVP_BASE 0x00 +#define KTD2692_REG_FLASH_TIMEOUT_BASE 0x20 +#define KTD2692_REG_MIN_CURRENT_SET_BASE 0x40 +#define KTD2692_REG_MOVIE_CURRENT_BASE 0x60 +#define KTD2692_REG_FLASH_CURRENT_BASE 0x80 +#define KTD2692_REG_MODE_BASE 0xA0 + +/* Set bit coding time for expresswire interface */ +#define KTD2692_TIME_RESET_US 700 +#define KTD2692_TIME_DATA_START_TIME_US10 +#define KTD2692_TIME_HIGH_END_OF_DATA_US 350 +#define KTD2692_TIME_LOW_END_OF_DATA_US10 +#define KTD2692_TIME_SHORT_BITSET_US 4 +#define KTD2692_TIME_LONG_BITSET_US12 + +/* KTD2692 default length of name */ +#define KTD2692_NAME_LENGTH20 + +/* KTD2692 default name */ +#define KTD2692_DEFAULT_NAME "ktd2692" + +enum ktd2692_mode { + KTD2692_MODE_DISABLE = 0, + KTD2692_MODE_MOVIE, + KTD2692_MODE_FLASH, +}; + +enum ktd2692_bitset { + KTD2692_LOW = 0, + KTD2692_HIGH, +}; + +struct ktd2692_context { + struct led_classdev cdev; + u8 mode; + int strobe_gpio; +}; + +static int ktd2692_brightness_set_gpio(struct ktd2692_context *led) +{ + int ret; + + ret = devm_gpio_request_one(led->cdev.dev, + led->strobe_gpio, GPIOF_INIT_LOW, "strobe-gpio"); + + if (ret) + dev_err(led->cdev.dev, + "failed to request strobe-gpio %d error %d\n", + led->strobe_gpio, ret); + + return ret; +} + +static void ktd2692_expresswire_start(struct ktd2692_context *led) +{ + gpio_set_value(led->strobe_gpio, KTD2692_HIGH); + udelay(KTD2692_TIME_DATA_START_TIME_US); +} + +static void ktd2692_expresswire_reset(struct ktd2692_context *led) +{ + gpio_set_value(led->strobe_gpio, KTD2692_LOW); + udelay(KTD2692_TIME_RESET_US); +} + +static void ktd2692_expresswire_end(struct ktd2692_context *led) +{ + gpio_set_value(led->strobe_gpio, KTD2692_LOW); + udelay(KTD2692_TIME_LOW_END_OF_DATA_US); + gpio_set_value(led->strobe_gpio, KTD2692_HIGH); + udelay(KTD2692_TIME_HIGH_END_OF_DATA_US); +} + +static void ktd2692_expresswire_set_bit(struct ktd2692_context *led, bool bit) +{ + if (bit) { + gpio_set_value(led->s
[PATCH 0/3] Add ktd2692 Flash LED driver
This patch supports KTD2692 flash LED driver Ingi Kim (3): of: Add vendor prefix for Kinetic technologies leds: ktd2692: add device tree bindings for ktd2692 leds: Add ktd2692 flash LED driver .../devicetree/bindings/leds/leds-ktd2692.txt | 19 ++ .../devicetree/bindings/vendor-prefixes.txt|1 + drivers/leds/Kconfig |8 + drivers/leds/Makefile |1 + drivers/leds/leds-ktd2692.c| 245 5 files changed, 274 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt create mode 100644 drivers/leds/leds-ktd2692.c -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/3] of: Add vendor prefix for Kinetic technologies
This patch adds vendor prefix for Kinetic technologies Signed-off-by: Ingi Kim --- .../devicetree/bindings/vendor-prefixes.txt|1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 389ca13..de9e126 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -98,6 +98,7 @@ isee ISEE 2007 S.L. isil Intersil karo Ka-Ro electronics GmbH keymileKeymile GmbH +kinetic Kinetic Technologies lacie LaCie lantiq Lantiq Semiconductor lenovo Lenovo Group Ltd. -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/3] leds: ktd2692: add device tree bindings for ktd2692
This patch adds the device tree bindings for ktd2692 flash LEDs Signed-off-by: Ingi Kim --- .../devicetree/bindings/leds/leds-ktd2692.txt | 19 +++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-ktd2692.txt diff --git a/Documentation/devicetree/bindings/leds/leds-ktd2692.txt b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt new file mode 100644 index 000..b68faa6 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-ktd2692.txt @@ -0,0 +1,19 @@ +* Kinetic Technologies - KTD2692 Flash LED Driver + +KTD2692 is the ideal power solution for high-power flash LEDs. +It uses ExpressWire single-wire programming for maximum flexibility. + +Required properties: + - compatible: "kinetic,ktd2692" + - strobe-gpio: gpio pin to control movie mode current level. + - torch-gpio: gpio pin to control ON/OFF flash mode +as a higher priority over strobe-gpio. + +Example: + +flash-led { + compatible = "kinetic,ktd2692"; + strobe-gpio = <&gpc0 1 0>; + torch-gpio = <&gpc0 2 0>; + status = "okay"; +}; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html