aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@ti.com>2012-11-13 04:35:13 -0500
committerLinus Walleij <linus.walleij@linaro.org>2012-11-17 15:15:33 -0500
commit9859eb99e9212339e2009b98c396b08260276edf (patch)
treee99f468ab38110c6b4e738d2fc9ff48980e846da
parent195812e4b6a631e8eaad4046bf6890db4328ea1f (diff)
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>
-rw-r--r--drivers/gpio/gpio-twl4030.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/drivers/gpio/gpio-twl4030.c b/drivers/gpio/gpio-twl4030.c
index c5f8ca233e1f..d2138b0fd4ca 100644
--- a/drivers/gpio/gpio-twl4030.c
+++ b/drivers/gpio/gpio-twl4030.c
@@ -88,11 +88,15 @@ static inline int gpio_twl4030_write(u8 address, u8 data)
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 * PWMs A and B are dedicated to LEDs A and B, respectively. 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/* LEDEN bits */ 101/* LEDEN bits */
98#define LEDEN_LEDAON BIT(0) 102#define LEDEN_LEDAON BIT(0)
@@ -104,9 +108,6 @@ static inline int gpio_twl4030_write(u8 address, u8 data)
104#define LEDEN_PWM_LENGTHA BIT(6) 108#define LEDEN_PWM_LENGTHA BIT(6)
105#define LEDEN_PWM_LENGTHB BIT(7) 109#define LEDEN_PWM_LENGTHB BIT(7)
106 110
107#define TWL4030_PWMx_PWMxON 0x0
108#define TWL4030_PWMx_PWMxOFF 0x1
109
110#define PWMxON_LENGTH BIT(7) 111#define PWMxON_LENGTH BIT(7)
111 112
112/*----------------------------------------------------------------------*/ 113/*----------------------------------------------------------------------*/
@@ -145,7 +146,7 @@ static void twl4030_led_set_value(int led, int value)
145 else 146 else
146 cached_leden |= mask; 147 cached_leden |= mask;
147 status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden, 148 status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
148 TWL4030_LED_LEDEN); 149 TWL4030_LED_LEDEN_REG);
149 mutex_unlock(&gpio_lock); 150 mutex_unlock(&gpio_lock);
150} 151}
151 152
@@ -216,33 +217,33 @@ static int twl_request(struct gpio_chip *chip, unsigned offset)
216 if (offset >= TWL4030_GPIO_MAX) { 217 if (offset >= TWL4030_GPIO_MAX) {
217 u8 ledclr_mask = LEDEN_LEDAON | LEDEN_LEDAEXT 218 u8 ledclr_mask = LEDEN_LEDAON | LEDEN_LEDAEXT
218 | LEDEN_LEDAPWM | LEDEN_PWM_LENGTHA; 219 | LEDEN_LEDAPWM | LEDEN_PWM_LENGTHA;
219 u8 module = TWL4030_MODULE_PWMA; 220 u8 reg = TWL4030_PWMAON_REG;
220 221
221 offset -= TWL4030_GPIO_MAX; 222 offset -= TWL4030_GPIO_MAX;
222 if (offset) { 223 if (offset) {
223 ledclr_mask <<= 1; 224 ledclr_mask <<= 1;
224 module = TWL4030_MODULE_PWMB; 225 reg = TWL4030_PWMBON_REG;
225 } 226 }
226 227
227 /* initialize PWM to always-drive */ 228 /* initialize PWM to always-drive */
228 status = twl_i2c_write_u8(module, 0x7f, 229 /* Configure PWM OFF register first */
229 TWL4030_PWMx_PWMxOFF); 230 status = twl_i2c_write_u8(TWL4030_MODULE_LED, 0x7f, reg + 1);
230 if (status < 0) 231 if (status < 0)
231 goto done; 232 goto done;
232 status = twl_i2c_write_u8(module, 0x7f, 233
233 TWL4030_PWMx_PWMxON); 234 /* Followed by PWM ON register */
235 status = twl_i2c_write_u8(TWL4030_MODULE_LED, 0x7f, reg);
234 if (status < 0) 236 if (status < 0)
235 goto done; 237 goto done;
236 238
237 /* init LED to not-driven (high) */ 239 /* init LED to not-driven (high) */
238 module = TWL4030_MODULE_LED; 240 status = twl_i2c_read_u8(TWL4030_MODULE_LED, &cached_leden,
239 status = twl_i2c_read_u8(module, &cached_leden, 241 TWL4030_LED_LEDEN_REG);
240 TWL4030_LED_LEDEN);
241 if (status < 0) 242 if (status < 0)
242 goto done; 243 goto done;
243 cached_leden &= ~ledclr_mask; 244 cached_leden &= ~ledclr_mask;
244 status = twl_i2c_write_u8(module, cached_leden, 245 status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden,
245 TWL4030_LED_LEDEN); 246 TWL4030_LED_LEDEN_REG);
246 if (status < 0) 247 if (status < 0)
247 goto done; 248 goto done;
248 249