1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #include <linux/gpio/machine.h> #include <linux/platform_device.h> #include "board.h" #include "head.h" struct gpiod_lookup_table gpios_table = { .dev_id = "mydev_gpio", .table = { GPIO_LOOKUP_IDX("gpio.0", 15, "led", 0, GPIO_ACTIVE_HIGH), GPIO_LOOKUP_IDX("gpio.0", 16, "led", 1, GPIO_ACTIVE_HIGH), GPIO_LOOKUP_IDX("gpio.0", 17, "led", 2, GPIO_ACTIVE_HIGH), GPIO_LOOKUP("gpio.0", 1, "power", GPIO_ACTIVE_LOW), { }, }, }; static struct mydev_gpio_platform_data mydev_platform_data = { .name = "mydev", .type = MYDEV_TYPE_FIRST, }; static struct platform_device mydev_device = { .name = "mydev_gpio", .id = -1, .dev = { .platform_data = &mydev_platform_data, }, }; int __init mydev_init(void) { gpiod_add_lookup_table(&gpios_table); platform_device_register(&mydev_device); }
|