diff options
| author | Alexander Shiyan <shc_work@mail.ru> | 2013-12-07 01:22:18 -0500 |
|---|---|---|
| committer | Bryan Wu <cooloney@gmail.com> | 2014-01-27 20:28:49 -0500 |
| commit | 01a7a063e8cf4bc09af2c02d28c12f3d72bf9649 (patch) | |
| tree | 203bc7e800afe602eca8ff4edbbab02643f3c4fd | |
| parent | 33ca15325ff371be7f20be7534f5aa5b6a00b558 (diff) | |
leds: leds-mc13783: Remove duplicate field in platform data
LED platform data are overwhelmed by excessive field "max_cur"
which just replicates few bits of "led_control" field.
This patch removes this field and adds a definition for the
current settings in the header.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
| -rw-r--r-- | arch/arm/mach-imx/mach-mx31moboard.c | 16 | ||||
| -rw-r--r-- | drivers/leds/leds-mc13783.c | 76 | ||||
| -rw-r--r-- | include/linux/mfd/mc13xxx.h | 37 |
3 files changed, 36 insertions, 93 deletions
diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c index 6f424eced181..b3738e616f19 100644 --- a/arch/arm/mach-imx/mach-mx31moboard.c +++ b/arch/arm/mach-imx/mach-mx31moboard.c | |||
| @@ -236,32 +236,26 @@ static struct mc13xxx_led_platform_data moboard_led[] = { | |||
| 236 | { | 236 | { |
| 237 | .id = MC13783_LED_R1, | 237 | .id = MC13783_LED_R1, |
| 238 | .name = "coreboard-led-4:red", | 238 | .name = "coreboard-led-4:red", |
| 239 | .max_current = 2, | ||
| 240 | }, | 239 | }, |
| 241 | { | 240 | { |
| 242 | .id = MC13783_LED_G1, | 241 | .id = MC13783_LED_G1, |
| 243 | .name = "coreboard-led-4:green", | 242 | .name = "coreboard-led-4:green", |
| 244 | .max_current = 2, | ||
| 245 | }, | 243 | }, |
| 246 | { | 244 | { |
| 247 | .id = MC13783_LED_B1, | 245 | .id = MC13783_LED_B1, |
| 248 | .name = "coreboard-led-4:blue", | 246 | .name = "coreboard-led-4:blue", |
| 249 | .max_current = 2, | ||
| 250 | }, | 247 | }, |
| 251 | { | 248 | { |
| 252 | .id = MC13783_LED_R2, | 249 | .id = MC13783_LED_R2, |
| 253 | .name = "coreboard-led-5:red", | 250 | .name = "coreboard-led-5:red", |
| 254 | .max_current = 3, | ||
| 255 | }, | 251 | }, |
| 256 | { | 252 | { |
| 257 | .id = MC13783_LED_G2, | 253 | .id = MC13783_LED_G2, |
| 258 | .name = "coreboard-led-5:green", | 254 | .name = "coreboard-led-5:green", |
| 259 | .max_current = 3, | ||
| 260 | }, | 255 | }, |
| 261 | { | 256 | { |
| 262 | .id = MC13783_LED_B2, | 257 | .id = MC13783_LED_B2, |
| 263 | .name = "coreboard-led-5:blue", | 258 | .name = "coreboard-led-5:blue", |
| 264 | .max_current = 3, | ||
| 265 | }, | 259 | }, |
| 266 | }; | 260 | }; |
| 267 | 261 | ||
| @@ -271,8 +265,14 @@ static struct mc13xxx_leds_platform_data moboard_leds = { | |||
| 271 | .led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0), | 265 | .led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0), |
| 272 | .led_control[1] = MC13783_LED_C1_SLEWLIM, | 266 | .led_control[1] = MC13783_LED_C1_SLEWLIM, |
| 273 | .led_control[2] = MC13783_LED_C2_SLEWLIM, | 267 | .led_control[2] = MC13783_LED_C2_SLEWLIM, |
| 274 | .led_control[3] = MC13783_LED_C3_PERIOD(0), | 268 | .led_control[3] = MC13783_LED_C3_PERIOD(0) | |
| 275 | .led_control[4] = MC13783_LED_C3_PERIOD(0), | 269 | MC13783_LED_C3_CURRENT_R1(2) | |
| 270 | MC13783_LED_C3_CURRENT_G1(2) | | ||
| 271 | MC13783_LED_C3_CURRENT_B1(2), | ||
| 272 | .led_control[4] = MC13783_LED_C4_PERIOD(0) | | ||
| 273 | MC13783_LED_C4_CURRENT_R2(3) | | ||
| 274 | MC13783_LED_C4_CURRENT_G2(3) | | ||
| 275 | MC13783_LED_C4_CURRENT_B2(3), | ||
| 276 | }; | 276 | }; |
| 277 | 277 | ||
| 278 | static struct mc13xxx_buttons_platform_data moboard_buttons = { | 278 | static struct mc13xxx_buttons_platform_data moboard_buttons = { |
diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c index fa9b439323bd..ec704f2ab70d 100644 --- a/drivers/leds/leds-mc13783.c +++ b/drivers/leds/leds-mc13783.c | |||
| @@ -132,75 +132,6 @@ static void mc13xxx_led_set(struct led_classdev *led_cdev, | |||
| 132 | schedule_work(&led->work); | 132 | schedule_work(&led->work); |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | static int __init mc13xxx_led_setup(struct mc13xxx_led *led, int max_current) | ||
| 136 | { | ||
| 137 | int shift, mask, reg, ret, bank; | ||
| 138 | |||
| 139 | switch (led->id) { | ||
| 140 | case MC13783_LED_MD: | ||
| 141 | reg = MC13XXX_REG_LED_CONTROL(2); | ||
| 142 | shift = 0; | ||
| 143 | mask = 0x07; | ||
| 144 | break; | ||
| 145 | case MC13783_LED_AD: | ||
| 146 | reg = MC13XXX_REG_LED_CONTROL(2); | ||
| 147 | shift = 3; | ||
| 148 | mask = 0x07; | ||
| 149 | break; | ||
| 150 | case MC13783_LED_KP: | ||
| 151 | reg = MC13XXX_REG_LED_CONTROL(2); | ||
| 152 | shift = 6; | ||
| 153 | mask = 0x07; | ||
| 154 | break; | ||
| 155 | case MC13783_LED_R1: | ||
| 156 | case MC13783_LED_G1: | ||
| 157 | case MC13783_LED_B1: | ||
| 158 | case MC13783_LED_R2: | ||
| 159 | case MC13783_LED_G2: | ||
| 160 | case MC13783_LED_B2: | ||
| 161 | case MC13783_LED_R3: | ||
| 162 | case MC13783_LED_G3: | ||
| 163 | case MC13783_LED_B3: | ||
| 164 | bank = (led->id - MC13783_LED_R1) / 3; | ||
| 165 | reg = MC13XXX_REG_LED_CONTROL(3) + bank; | ||
| 166 | shift = ((led->id - MC13783_LED_R1) - bank * 3) * 2; | ||
| 167 | mask = 0x03; | ||
| 168 | break; | ||
| 169 | case MC13892_LED_MD: | ||
| 170 | reg = MC13XXX_REG_LED_CONTROL(0); | ||
| 171 | shift = 9; | ||
| 172 | mask = 0x07; | ||
| 173 | break; | ||
| 174 | case MC13892_LED_AD: | ||
| 175 | reg = MC13XXX_REG_LED_CONTROL(0); | ||
| 176 | shift = 21; | ||
| 177 | mask = 0x07; | ||
| 178 | break; | ||
| 179 | case MC13892_LED_KP: | ||
| 180 | reg = MC13XXX_REG_LED_CONTROL(1); | ||
| 181 | shift = 9; | ||
| 182 | mask = 0x07; | ||
| 183 | break; | ||
| 184 | case MC13892_LED_R: | ||
| 185 | case MC13892_LED_G: | ||
| 186 | case MC13892_LED_B: | ||
| 187 | bank = (led->id - MC13892_LED_R) / 2; | ||
| 188 | reg = MC13XXX_REG_LED_CONTROL(2) + bank; | ||
| 189 | shift = ((led->id - MC13892_LED_R) - bank * 2) * 12 + 9; | ||
| 190 | mask = 0x07; | ||
| 191 | break; | ||
| 192 | default: | ||
| 193 | BUG(); | ||
| 194 | } | ||
| 195 | |||
| 196 | mc13xxx_lock(led->master); | ||
| 197 | ret = mc13xxx_reg_rmw(led->master, reg, mask << shift, | ||
| 198 | max_current << shift); | ||
| 199 | mc13xxx_unlock(led->master); | ||
| 200 | |||
| 201 | return ret; | ||
| 202 | } | ||
| 203 | |||
| 204 | static int __init mc13xxx_led_probe(struct platform_device *pdev) | 135 | static int __init mc13xxx_led_probe(struct platform_device *pdev) |
| 205 | { | 136 | { |
| 206 | struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); | 137 | struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); |
| @@ -250,14 +181,12 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) | |||
| 250 | 181 | ||
| 251 | for (i = 0; i < num_leds; i++) { | 182 | for (i = 0; i < num_leds; i++) { |
| 252 | const char *name, *trig; | 183 | const char *name, *trig; |
| 253 | char max_current; | ||
| 254 | 184 | ||
| 255 | ret = -EINVAL; | 185 | ret = -EINVAL; |
| 256 | 186 | ||
| 257 | id = pdata->led[i].id; | 187 | id = pdata->led[i].id; |
| 258 | name = pdata->led[i].name; | 188 | name = pdata->led[i].name; |
| 259 | trig = pdata->led[i].default_trigger; | 189 | trig = pdata->led[i].default_trigger; |
| 260 | max_current = pdata->led[i].max_current; | ||
| 261 | 190 | ||
| 262 | if ((id > devtype->led_max) || (id < devtype->led_min)) { | 191 | if ((id > devtype->led_max) || (id < devtype->led_min)) { |
| 263 | dev_err(&pdev->dev, "Invalid ID %i\n", id); | 192 | dev_err(&pdev->dev, "Invalid ID %i\n", id); |
| @@ -280,11 +209,6 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) | |||
| 280 | 209 | ||
| 281 | INIT_WORK(&leds->led[i].work, mc13xxx_led_work); | 210 | INIT_WORK(&leds->led[i].work, mc13xxx_led_work); |
| 282 | 211 | ||
| 283 | ret = mc13xxx_led_setup(&leds->led[i], max_current); | ||
| 284 | if (ret) { | ||
| 285 | dev_err(&pdev->dev, "Unable to setup LED %i\n", id); | ||
| 286 | break; | ||
| 287 | } | ||
| 288 | ret = led_classdev_register(pdev->dev.parent, | 212 | ret = led_classdev_register(pdev->dev.parent, |
| 289 | &leds->led[i].cdev); | 213 | &leds->led[i].cdev); |
| 290 | if (ret) { | 214 | if (ret) { |
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h index 67c17b5a6f44..ac2230561fc8 100644 --- a/include/linux/mfd/mc13xxx.h +++ b/include/linux/mfd/mc13xxx.h | |||
| @@ -112,9 +112,6 @@ struct mc13xxx_led_platform_data { | |||
| 112 | int id; | 112 | int id; |
| 113 | const char *name; | 113 | const char *name; |
| 114 | const char *default_trigger; | 114 | const char *default_trigger; |
| 115 | |||
| 116 | /* Three or two bits current selection depending on the led */ | ||
| 117 | char max_current; | ||
| 118 | }; | 115 | }; |
| 119 | 116 | ||
| 120 | #define MAX_LED_CONTROL_REGS 6 | 117 | #define MAX_LED_CONTROL_REGS 6 |
| @@ -123,7 +120,7 @@ struct mc13xxx_leds_platform_data { | |||
| 123 | struct mc13xxx_led_platform_data *led; | 120 | struct mc13xxx_led_platform_data *led; |
| 124 | int num_leds; | 121 | int num_leds; |
| 125 | 122 | ||
| 126 | /* LED Control 0 */ | 123 | /* MC13783 LED Control 0 */ |
| 127 | #define MC13783_LED_C0_ENABLE (1 << 0) | 124 | #define MC13783_LED_C0_ENABLE (1 << 0) |
| 128 | #define MC13783_LED_C0_TRIODE_MD (1 << 7) | 125 | #define MC13783_LED_C0_TRIODE_MD (1 << 7) |
| 129 | #define MC13783_LED_C0_TRIODE_AD (1 << 8) | 126 | #define MC13783_LED_C0_TRIODE_AD (1 << 8) |
| @@ -131,21 +128,43 @@ struct mc13xxx_leds_platform_data { | |||
| 131 | #define MC13783_LED_C0_BOOST (1 << 10) | 128 | #define MC13783_LED_C0_BOOST (1 << 10) |
| 132 | #define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11) | 129 | #define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11) |
| 133 | #define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14) | 130 | #define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14) |
| 134 | /* LED Control 1 */ | 131 | /* MC13783 LED Control 1 */ |
| 135 | #define MC13783_LED_C1_TC1HALF (1 << 18) | 132 | #define MC13783_LED_C1_TC1HALF (1 << 18) |
| 136 | #define MC13783_LED_C1_SLEWLIM (1 << 23) | 133 | #define MC13783_LED_C1_SLEWLIM (1 << 23) |
| 137 | /* LED Control 2 */ | 134 | /* MC13783 LED Control 2 */ |
| 135 | #define MC13783_LED_C2_CURRENT_MD(x) (((x) & 0x7) << 0) | ||
| 136 | #define MC13783_LED_C2_CURRENT_AD(x) (((x) & 0x7) << 3) | ||
| 137 | #define MC13783_LED_C2_CURRENT_KP(x) (((x) & 0x7) << 6) | ||
| 138 | #define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21) | 138 | #define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21) |
| 139 | #define MC13783_LED_C2_SLEWLIM (1 << 23) | 139 | #define MC13783_LED_C2_SLEWLIM (1 << 23) |
| 140 | /* LED Control 3 */ | 140 | /* MC13783 LED Control 3 */ |
| 141 | #define MC13783_LED_C3_CURRENT_R1(x) (((x) & 0x3) << 0) | ||
| 142 | #define MC13783_LED_C3_CURRENT_G1(x) (((x) & 0x3) << 2) | ||
| 143 | #define MC13783_LED_C3_CURRENT_B1(x) (((x) & 0x3) << 4) | ||
| 141 | #define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21) | 144 | #define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21) |
| 142 | #define MC13783_LED_C3_TRIODE_TC1 (1 << 23) | 145 | #define MC13783_LED_C3_TRIODE_TC1 (1 << 23) |
| 143 | /* LED Control 4 */ | 146 | /* MC13783 LED Control 4 */ |
| 147 | #define MC13783_LED_C4_CURRENT_R2(x) (((x) & 0x3) << 0) | ||
| 148 | #define MC13783_LED_C4_CURRENT_G2(x) (((x) & 0x3) << 2) | ||
| 149 | #define MC13783_LED_C4_CURRENT_B2(x) (((x) & 0x3) << 4) | ||
| 144 | #define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21) | 150 | #define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21) |
| 145 | #define MC13783_LED_C4_TRIODE_TC2 (1 << 23) | 151 | #define MC13783_LED_C4_TRIODE_TC2 (1 << 23) |
| 146 | /* LED Control 5 */ | 152 | /* MC13783 LED Control 5 */ |
| 153 | #define MC13783_LED_C5_CURRENT_R3(x) (((x) & 0x3) << 0) | ||
| 154 | #define MC13783_LED_C5_CURRENT_G3(x) (((x) & 0x3) << 2) | ||
| 155 | #define MC13783_LED_C5_CURRENT_B3(x) (((x) & 0x3) << 4) | ||
| 147 | #define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21) | 156 | #define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21) |
| 148 | #define MC13783_LED_C5_TRIODE_TC3 (1 << 23) | 157 | #define MC13783_LED_C5_TRIODE_TC3 (1 << 23) |
| 158 | /* MC13892 LED Control 0 */ | ||
| 159 | #define MC13892_LED_C0_CURRENT_MD(x) (((x) & 0x7) << 9) | ||
| 160 | #define MC13892_LED_C0_CURRENT_AD(x) (((x) & 0x7) << 21) | ||
| 161 | /* MC13892 LED Control 1 */ | ||
| 162 | #define MC13892_LED_C1_CURRENT_KP(x) (((x) & 0x7) << 9) | ||
| 163 | /* MC13892 LED Control 2 */ | ||
| 164 | #define MC13892_LED_C2_CURRENT_R(x) (((x) & 0x7) << 9) | ||
| 165 | #define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21) | ||
| 166 | /* MC13892 LED Control 3 */ | ||
| 167 | #define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9) | ||
| 149 | u32 led_control[MAX_LED_CONTROL_REGS]; | 168 | u32 led_control[MAX_LED_CONTROL_REGS]; |
| 150 | }; | 169 | }; |
| 151 | 170 | ||
