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

mfd: dm355evm_msp: Convert LEDs to GPIO descriptor table

This converts the DaVinci DM355EVM LEDs to use GPIO descriptor look-ups.

Cc: Sekhar Nori <nsekhar@ti.com>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Linus Walleij and committed by
Lee Jones
b6d213fb 0f1b1b89

+50 -26
+50 -26
drivers/mfd/dm355evm_msp.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/err.h> 14 14 #include <linux/gpio.h> 15 + #include <linux/gpio/machine.h> 15 16 #include <linux/leds.h> 16 17 #include <linux/i2c.h> 17 18 #include <linux/mfd/dm355evm_msp.h> ··· 115 114 */ 116 115 MSP_GPIO(2, SDMMC), MSP_GPIO(1, SDMMC), /* mmc0 WP, nCD */ 117 116 MSP_GPIO(4, SDMMC), MSP_GPIO(3, SDMMC), /* mmc1 WP, nCD */ 117 + }; 118 + 119 + static struct gpio_led evm_leds[] = { 120 + { .name = "dm355evm::ds14", 121 + .default_trigger = "heartbeat", }, 122 + { .name = "dm355evm::ds15", 123 + .default_trigger = "mmc0", }, 124 + { .name = "dm355evm::ds16", 125 + /* could also be a CE-ATA drive */ 126 + .default_trigger = "mmc1", }, 127 + { .name = "dm355evm::ds17", 128 + .default_trigger = "nand-disk", }, 129 + { .name = "dm355evm::ds18", }, 130 + { .name = "dm355evm::ds19", }, 131 + { .name = "dm355evm::ds20", }, 132 + { .name = "dm355evm::ds21", }, 133 + }; 134 + 135 + static struct gpio_led_platform_data evm_led_data = { 136 + .num_leds = ARRAY_SIZE(evm_leds), 137 + .leds = evm_leds, 138 + }; 139 + 140 + static struct gpiod_lookup_table evm_leds_gpio_table = { 141 + .dev_id = "leds-gpio", 142 + .table = { 143 + /* 144 + * These GPIOs are on the dm355evm_msp 145 + * GPIO chip at index 0..7 146 + */ 147 + GPIO_LOOKUP_IDX("dm355evm_msp", 0, NULL, 148 + 0, GPIO_ACTIVE_LOW), 149 + GPIO_LOOKUP_IDX("dm355evm_msp", 1, NULL, 150 + 1, GPIO_ACTIVE_LOW), 151 + GPIO_LOOKUP_IDX("dm355evm_msp", 2, NULL, 152 + 2, GPIO_ACTIVE_LOW), 153 + GPIO_LOOKUP_IDX("dm355evm_msp", 3, NULL, 154 + 3, GPIO_ACTIVE_LOW), 155 + GPIO_LOOKUP_IDX("dm355evm_msp", 4, NULL, 156 + 4, GPIO_ACTIVE_LOW), 157 + GPIO_LOOKUP_IDX("dm355evm_msp", 5, NULL, 158 + 5, GPIO_ACTIVE_LOW), 159 + GPIO_LOOKUP_IDX("dm355evm_msp", 6, NULL, 160 + 6, GPIO_ACTIVE_LOW), 161 + GPIO_LOOKUP_IDX("dm355evm_msp", 7, NULL, 162 + 7, GPIO_ACTIVE_LOW), 163 + { }, 164 + }, 118 165 }; 119 166 120 167 #define MSP_GPIO_REG(offset) (msp_gpios[(offset)] >> 3) ··· 309 260 310 261 /* LED output */ 311 262 if (msp_has_leds()) { 312 - #define GPIO_LED(l) .name = l, .active_low = true 313 - static struct gpio_led evm_leds[] = { 314 - { GPIO_LED("dm355evm::ds14"), 315 - .default_trigger = "heartbeat", }, 316 - { GPIO_LED("dm355evm::ds15"), 317 - .default_trigger = "mmc0", }, 318 - { GPIO_LED("dm355evm::ds16"), 319 - /* could also be a CE-ATA drive */ 320 - .default_trigger = "mmc1", }, 321 - { GPIO_LED("dm355evm::ds17"), 322 - .default_trigger = "nand-disk", }, 323 - { GPIO_LED("dm355evm::ds18"), }, 324 - { GPIO_LED("dm355evm::ds19"), }, 325 - { GPIO_LED("dm355evm::ds20"), }, 326 - { GPIO_LED("dm355evm::ds21"), }, 327 - }; 328 - #undef GPIO_LED 329 - 330 - struct gpio_led_platform_data evm_led_data = { 331 - .num_leds = ARRAY_SIZE(evm_leds), 332 - .leds = evm_leds, 333 - }; 334 - 335 - for (i = 0; i < ARRAY_SIZE(evm_leds); i++) 336 - evm_leds[i].gpio = i + dm355evm_msp_gpio.base; 337 - 263 + gpiod_add_lookup_table(&evm_leds_gpio_table); 338 264 /* NOTE: these are the only fully programmable LEDs 339 265 * on the board, since GPIO-61/ds22 (and many signals 340 266 * going to DC7) must be used for AEMIF address lines