|
14 | 14 | * |
15 | 15 | */ |
16 | 16 | #include <linux/gpio.h> |
| 17 | +#include <linux/gpio/machine.h> |
17 | 18 | #include <linux/kernel.h> |
18 | 19 | #include <linux/init.h> |
19 | 20 | #include <linux/delay.h> |
@@ -254,37 +255,64 @@ static int __init dns323_read_mac_addr(void) |
254 | 255 | static struct gpio_led dns323ab_leds[] = { |
255 | 256 | { |
256 | 257 | .name = "power:blue", |
257 | | - .gpio = DNS323_GPIO_LED_POWER2, |
258 | 258 | .default_trigger = "default-on", |
259 | 259 | }, { |
260 | 260 | .name = "right:amber", |
261 | | - .gpio = DNS323_GPIO_LED_RIGHT_AMBER, |
262 | | - .active_low = 1, |
263 | 261 | }, { |
264 | 262 | .name = "left:amber", |
265 | | - .gpio = DNS323_GPIO_LED_LEFT_AMBER, |
266 | | - .active_low = 1, |
267 | 263 | }, |
268 | 264 | }; |
269 | 265 |
|
| 266 | +static struct gpiod_lookup_table dns323a1_leds_gpio_table = { |
| 267 | + .dev_id = "leds-gpio", |
| 268 | + .table = { |
| 269 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_POWER2, NULL, |
| 270 | + 0, GPIO_ACTIVE_LOW), |
| 271 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_RIGHT_AMBER, NULL, |
| 272 | + 1, GPIO_ACTIVE_LOW), |
| 273 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_LEFT_AMBER, NULL, |
| 274 | + 2, GPIO_ACTIVE_LOW), |
| 275 | + { }, |
| 276 | + }, |
| 277 | +}; |
| 278 | + |
| 279 | +/* B1 is the same but power LED is active high */ |
| 280 | +static struct gpiod_lookup_table dns323b1_leds_gpio_table = { |
| 281 | + .dev_id = "leds-gpio", |
| 282 | + .table = { |
| 283 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_POWER2, NULL, |
| 284 | + 0, GPIO_ACTIVE_HIGH), |
| 285 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_RIGHT_AMBER, NULL, |
| 286 | + 1, GPIO_ACTIVE_LOW), |
| 287 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323_GPIO_LED_LEFT_AMBER, NULL, |
| 288 | + 2, GPIO_ACTIVE_LOW), |
| 289 | + { }, |
| 290 | + }, |
| 291 | +}; |
270 | 292 |
|
271 | 293 | static struct gpio_led dns323c_leds[] = { |
272 | 294 | { |
273 | 295 | .name = "power:blue", |
274 | | - .gpio = DNS323C_GPIO_LED_POWER, |
275 | 296 | .default_trigger = "timer", |
276 | | - .active_low = 1, |
277 | 297 | }, { |
278 | 298 | .name = "right:amber", |
279 | | - .gpio = DNS323C_GPIO_LED_RIGHT_AMBER, |
280 | | - .active_low = 1, |
281 | 299 | }, { |
282 | 300 | .name = "left:amber", |
283 | | - .gpio = DNS323C_GPIO_LED_LEFT_AMBER, |
284 | | - .active_low = 1, |
285 | 301 | }, |
286 | 302 | }; |
287 | 303 |
|
| 304 | +static struct gpiod_lookup_table dns323c_leds_gpio_table = { |
| 305 | + .dev_id = "leds-gpio", |
| 306 | + .table = { |
| 307 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_POWER, NULL, |
| 308 | + 0, GPIO_ACTIVE_LOW), |
| 309 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_RIGHT_AMBER, NULL, |
| 310 | + 1, GPIO_ACTIVE_LOW), |
| 311 | + GPIO_LOOKUP_IDX("orion_gpio0", DNS323C_GPIO_LED_LEFT_AMBER, NULL, |
| 312 | + 2, GPIO_ACTIVE_LOW), |
| 313 | + { }, |
| 314 | + }, |
| 315 | +}; |
288 | 316 |
|
289 | 317 | static struct gpio_led_platform_data dns323ab_led_data = { |
290 | 318 | .num_leds = ARRAY_SIZE(dns323ab_leds), |
@@ -621,16 +649,21 @@ static void __init dns323_init(void) |
621 | 649 | /* The 5181 power LED is active low and requires |
622 | 650 | * DNS323_GPIO_LED_POWER1 to also be low. |
623 | 651 | */ |
624 | | - dns323ab_leds[0].active_low = 1; |
625 | | - gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable"); |
626 | | - gpio_direction_output(DNS323_GPIO_LED_POWER1, 0); |
627 | | - fallthrough; |
| 652 | + gpiod_add_lookup_table(&dns323a1_leds_gpio_table); |
| 653 | + gpio_request(DNS323_GPIO_LED_POWER1, "Power Led Enable"); |
| 654 | + gpio_direction_output(DNS323_GPIO_LED_POWER1, 0); |
| 655 | + i2c_register_board_info(0, dns323ab_i2c_devices, |
| 656 | + ARRAY_SIZE(dns323ab_i2c_devices)); |
| 657 | + |
| 658 | + break; |
628 | 659 | case DNS323_REV_B1: |
| 660 | + gpiod_add_lookup_table(&dns323b1_leds_gpio_table); |
629 | 661 | i2c_register_board_info(0, dns323ab_i2c_devices, |
630 | 662 | ARRAY_SIZE(dns323ab_i2c_devices)); |
631 | 663 | break; |
632 | 664 | case DNS323_REV_C1: |
633 | 665 | /* Hookup LEDs & Buttons */ |
| 666 | + gpiod_add_lookup_table(&dns323c_leds_gpio_table); |
634 | 667 | dns323_gpio_leds.dev.platform_data = &dns323c_led_data; |
635 | 668 | dns323_button_device.dev.platform_data = &dns323c_button_data; |
636 | 669 |
|
|
0 commit comments