Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/leds/leds-lp5521.c: add 'update_config' in the lp5521_platform_data

The value of CONFIG register(Addr 08h) is configurable. For supporting
this feature, update_config is added in the platform data. If
'update_config' is not defined, the default value is 'LP5521_PWRSAVE_EN |
LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT'.

To define CONFIG register in the platform data, the bit definitions were
mo= ved to the header file.

Documentation updated : description about 'update_config' and example.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Arun MURTHY <arun.murthy@stericsson.com>
Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Kim, Milo and committed by
Linus Torvalds
3b49aacd 5ae4e8a7

+36 -15
+19
Documentation/leds/leds-lp5521.txt
··· 92 92 93 93 If the current is set to 0 in the platform data, that channel is 94 94 disabled and it is not visible in the sysfs. 95 + 96 + The 'update_config' : CONFIG register (ADDR 08h) 97 + This value is platform-specific data. 98 + If update_config is not defined, the CONFIG register is set with 99 + 'LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT'. 100 + (Enable auto-powersave, set charge pump to auto, red to battery) 101 + 102 + example of update_config : 103 + 104 + #define LP5521_CONFIGS (LP5521_PWM_HF | LP5521_PWRSAVE_EN | \ 105 + LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT | \ 106 + LP5521_CLK_INT) 107 + 108 + static struct lp5521_platform_data lp5521_pdata = { 109 + .led_config = lp5521_led_config, 110 + .num_channels = ARRAY_SIZE(lp5521_led_config), 111 + .clock_mode = LP5521_CLOCK_INT, 112 + .update_config = LP5521_CONFIGS, 113 + };
+4 -15
drivers/leds/leds-lp5521.c
··· 82 82 #define LP5521_LOGARITHMIC_PWM 0x80 /* Logarithmic PWM adjustment */ 83 83 #define LP5521_EXEC_RUN 0x2A 84 84 85 - /* Bits in CONFIG register */ 86 - #define LP5521_PWM_HF 0x40 /* PWM: 0 = 256Hz, 1 = 558Hz */ 87 - #define LP5521_PWRSAVE_EN 0x20 /* 1 = Power save mode */ 88 - #define LP5521_CP_MODE_OFF 0 /* Charge pump (CP) off */ 89 - #define LP5521_CP_MODE_BYPASS 8 /* CP forced to bypass mode */ 90 - #define LP5521_CP_MODE_1X5 0x10 /* CP forced to 1.5x mode */ 91 - #define LP5521_CP_MODE_AUTO 0x18 /* Automatic mode selection */ 92 - #define LP5521_R_TO_BATT 4 /* R out: 0 = CP, 1 = Vbat */ 93 - #define LP5521_CLK_SRC_EXT 0 /* Ext-clk source (CLK_32K) */ 94 - #define LP5521_CLK_INT 1 /* Internal clock */ 95 - #define LP5521_CLK_AUTO 2 /* Automatic clock selection */ 96 - 97 85 /* Status */ 98 86 #define LP5521_EXT_CLK_USED 0x08 99 87 ··· 229 241 { 230 242 struct lp5521_chip *chip = i2c_get_clientdata(client); 231 243 int ret; 244 + u8 cfg; 232 245 233 246 lp5521_init_engine(chip); 234 247 235 248 /* Set all PWMs to direct control mode */ 236 249 ret = lp5521_write(client, LP5521_REG_OP_MODE, 0x3F); 237 250 238 - /* Enable auto-powersave, set charge pump to auto, red to battery */ 239 - ret |= lp5521_write(client, LP5521_REG_CONFIG, 240 - LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); 251 + cfg = chip->pdata->update_config ? 252 + : (LP5521_PWRSAVE_EN | LP5521_CP_MODE_AUTO | LP5521_R_TO_BATT); 253 + ret |= lp5521_write(client, LP5521_REG_CONFIG, cfg); 241 254 242 255 /* Initialize all channels PWM to zero -> leds off */ 243 256 ret |= lp5521_write(client, LP5521_REG_R_PWM, 0);
+13
include/linux/leds-lp5521.h
··· 36 36 #define LP5521_CLOCK_INT 1 37 37 #define LP5521_CLOCK_EXT 2 38 38 39 + /* Bits in CONFIG register */ 40 + #define LP5521_PWM_HF 0x40 /* PWM: 0 = 256Hz, 1 = 558Hz */ 41 + #define LP5521_PWRSAVE_EN 0x20 /* 1 = Power save mode */ 42 + #define LP5521_CP_MODE_OFF 0 /* Charge pump (CP) off */ 43 + #define LP5521_CP_MODE_BYPASS 8 /* CP forced to bypass mode */ 44 + #define LP5521_CP_MODE_1X5 0x10 /* CP forced to 1.5x mode */ 45 + #define LP5521_CP_MODE_AUTO 0x18 /* Automatic mode selection */ 46 + #define LP5521_R_TO_BATT 4 /* R out: 0 = CP, 1 = Vbat */ 47 + #define LP5521_CLK_SRC_EXT 0 /* Ext-clk source (CLK_32K) */ 48 + #define LP5521_CLK_INT 1 /* Internal clock */ 49 + #define LP5521_CLK_AUTO 2 /* Automatic clock selection */ 50 + 39 51 struct lp5521_platform_data { 40 52 struct lp5521_led_config *led_config; 41 53 u8 num_channels; ··· 56 44 void (*release_resources)(void); 57 45 void (*enable)(bool state); 58 46 const char *label; 47 + u8 update_config; 59 48 }; 60 49 61 50 #endif /* __LINUX_LP5521_H */