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

gpio: twl4030: Use only TWL4030_MODULE_LED for LED configuration

Avoid using the TWL4030_MODULE_PWMA/B as module ID. The LEDEN, PWMA ON/OFF
and PWMB ON/OFF registers are in a continuous range starting from LED base.
This is going to be helpful for further cleanup in the twl stack.

No functional changes.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Peter Ujfalusi and committed by
Linus Walleij
9859eb99 195812e4

+18 -17
+18 -17
drivers/gpio/gpio-twl4030.c
··· 88 88 /*----------------------------------------------------------------------*/ 89 89 90 90 /* 91 - * LED register offsets (use TWL4030_MODULE_{LED,PWMA,PWMB})) 91 + * LED register offsets from TWL_MODULE_LED base 92 92 * PWMs A and B are dedicated to LEDs A and B, respectively. 93 93 */ 94 94 95 - #define TWL4030_LED_LEDEN 0x0 95 + #define TWL4030_LED_LEDEN_REG 0x00 96 + #define TWL4030_PWMAON_REG 0x01 97 + #define TWL4030_PWMAOFF_REG 0x02 98 + #define TWL4030_PWMBON_REG 0x03 99 + #define TWL4030_PWMBOFF_REG 0x04 96 100 97 101 /* LEDEN bits */ 98 102 #define LEDEN_LEDAON BIT(0) ··· 107 103 #define LEDEN_LEDBPWM BIT(5) 108 104 #define LEDEN_PWM_LENGTHA BIT(6) 109 105 #define LEDEN_PWM_LENGTHB BIT(7) 110 - 111 - #define TWL4030_PWMx_PWMxON 0x0 112 - #define TWL4030_PWMx_PWMxOFF 0x1 113 106 114 107 #define PWMxON_LENGTH BIT(7) 115 108 ··· 146 145 else 147 146 cached_leden |= mask; 148 147 status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden, 149 - TWL4030_LED_LEDEN); 148 + TWL4030_LED_LEDEN_REG); 150 149 mutex_unlock(&gpio_lock); 151 150 } 152 151 ··· 217 216 if (offset >= TWL4030_GPIO_MAX) { 218 217 u8 ledclr_mask = LEDEN_LEDAON | LEDEN_LEDAEXT 219 218 | LEDEN_LEDAPWM | LEDEN_PWM_LENGTHA; 220 - u8 module = TWL4030_MODULE_PWMA; 219 + u8 reg = TWL4030_PWMAON_REG; 221 220 222 221 offset -= TWL4030_GPIO_MAX; 223 222 if (offset) { 224 223 ledclr_mask <<= 1; 225 - module = TWL4030_MODULE_PWMB; 224 + reg = TWL4030_PWMBON_REG; 226 225 } 227 226 228 227 /* initialize PWM to always-drive */ 229 - status = twl_i2c_write_u8(module, 0x7f, 230 - TWL4030_PWMx_PWMxOFF); 228 + /* Configure PWM OFF register first */ 229 + status = twl_i2c_write_u8(TWL4030_MODULE_LED, 0x7f, reg + 1); 231 230 if (status < 0) 232 231 goto done; 233 - status = twl_i2c_write_u8(module, 0x7f, 234 - TWL4030_PWMx_PWMxON); 232 + 233 + /* Followed by PWM ON register */ 234 + status = twl_i2c_write_u8(TWL4030_MODULE_LED, 0x7f, reg); 235 235 if (status < 0) 236 236 goto done; 237 237 238 238 /* init LED to not-driven (high) */ 239 - module = TWL4030_MODULE_LED; 240 - status = twl_i2c_read_u8(module, &cached_leden, 241 - TWL4030_LED_LEDEN); 239 + status = twl_i2c_read_u8(TWL4030_MODULE_LED, &cached_leden, 240 + TWL4030_LED_LEDEN_REG); 242 241 if (status < 0) 243 242 goto done; 244 243 cached_leden &= ~ledclr_mask; 245 - status = twl_i2c_write_u8(module, cached_leden, 246 - TWL4030_LED_LEDEN); 244 + status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden, 245 + TWL4030_LED_LEDEN_REG); 247 246 if (status < 0) 248 247 goto done; 249 248