Commit | Line | Data |
---|---|---|
26c288f8 FF |
1 | /* |
2 | * MTX-1 platform devices registration | |
3 | * | |
4 | * Copyright (C) 2007, Florian Fainelli <florian@openwrt.org> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
20 | ||
21 | #include <linux/init.h> | |
26c288f8 FF |
22 | #include <linux/platform_device.h> |
23 | #include <linux/leds.h> | |
1ff1a78c | 24 | #include <linux/gpio.h> |
f6ed10ab FF |
25 | #include <linux/gpio_keys.h> |
26 | #include <linux/input.h> | |
26c288f8 | 27 | |
f6ed10ab FF |
28 | static struct gpio_keys_button mtx1_gpio_button[] = { |
29 | { | |
30 | .gpio = 207, | |
31 | .code = BTN_0, | |
32 | .desc = "System button", | |
33 | } | |
34 | }; | |
35 | ||
36 | static struct gpio_keys_platform_data mtx1_buttons_data = { | |
37 | .buttons = mtx1_gpio_button, | |
38 | .nbuttons = ARRAY_SIZE(mtx1_gpio_button), | |
39 | }; | |
40 | ||
41 | static struct platform_device mtx1_button = { | |
42 | .name = "gpio-keys", | |
43 | .id = -1, | |
44 | .dev = { | |
45 | .platform_data = &mtx1_buttons_data, | |
46 | } | |
47 | }; | |
48 | ||
26c288f8 FF |
49 | static struct resource mtx1_wdt_res[] = { |
50 | [0] = { | |
51 | .start = 15, | |
52 | .end = 15, | |
53 | .name = "mtx1-wdt-gpio", | |
54 | .flags = IORESOURCE_IRQ, | |
55 | } | |
56 | }; | |
57 | ||
26c288f8 FF |
58 | static struct platform_device mtx1_wdt = { |
59 | .name = "mtx1-wdt", | |
60 | .id = 0, | |
61 | .num_resources = ARRAY_SIZE(mtx1_wdt_res), | |
62 | .resource = mtx1_wdt_res, | |
63 | }; | |
64 | ||
65 | static struct gpio_led default_leds[] = { | |
66 | { | |
67 | .name = "mtx1:green", | |
68 | .gpio = 211, | |
69 | }, { | |
70 | .name = "mtx1:red", | |
71 | .gpio = 212, | |
72 | }, | |
73 | }; | |
74 | ||
75 | static struct gpio_led_platform_data mtx1_led_data = { | |
76 | .num_leds = ARRAY_SIZE(default_leds), | |
77 | .leds = default_leds, | |
78 | }; | |
79 | ||
80 | static struct platform_device mtx1_gpio_leds = { | |
81 | .name = "leds-gpio", | |
82 | .id = -1, | |
83 | .dev = { | |
84 | .platform_data = &mtx1_led_data, | |
85 | } | |
86 | }; | |
87 | ||
88 | static struct __initdata platform_device * mtx1_devs[] = { | |
89 | &mtx1_gpio_leds, | |
f6ed10ab FF |
90 | &mtx1_wdt, |
91 | &mtx1_button | |
26c288f8 FF |
92 | }; |
93 | ||
94 | static int __init mtx1_register_devices(void) | |
95 | { | |
f6ed10ab | 96 | gpio_direction_input(207); |
26c288f8 FF |
97 | return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs)); |
98 | } | |
99 | ||
100 | arch_initcall(mtx1_register_devices); |