blob: 9807be37c32f6fb61a00c90686599d80f3bf6bc9 [file] [log] [blame]
Florian Fainelli26c288f2007-10-23 18:55:55 +02001/*
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>
Florian Fainelli26c288f2007-10-23 18:55:55 +020022#include <linux/platform_device.h>
23#include <linux/leds.h>
Sergei Shtylyov1ff1a782008-04-30 23:30:12 +040024#include <linux/gpio.h>
Florian Fainellif6ed10a2008-01-07 19:00:46 +010025#include <linux/gpio_keys.h>
26#include <linux/input.h>
Florian Fainelli26c288f2007-10-23 18:55:55 +020027
Florian Fainellif6ed10a2008-01-07 19:00:46 +010028static struct gpio_keys_button mtx1_gpio_button[] = {
29 {
30 .gpio = 207,
31 .code = BTN_0,
32 .desc = "System button",
33 }
34};
35
36static struct gpio_keys_platform_data mtx1_buttons_data = {
37 .buttons = mtx1_gpio_button,
38 .nbuttons = ARRAY_SIZE(mtx1_gpio_button),
39};
40
41static struct platform_device mtx1_button = {
42 .name = "gpio-keys",
43 .id = -1,
44 .dev = {
45 .platform_data = &mtx1_buttons_data,
46 }
47};
48
Florian Fainelli26c288f2007-10-23 18:55:55 +020049static 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
Florian Fainelli26c288f2007-10-23 18:55:55 +020058static 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
65static struct gpio_led default_leds[] = {
66 {
67 .name = "mtx1:green",
68 .gpio = 211,
69 }, {
70 .name = "mtx1:red",
71 .gpio = 212,
72 },
73};
74
75static struct gpio_led_platform_data mtx1_led_data = {
76 .num_leds = ARRAY_SIZE(default_leds),
77 .leds = default_leds,
78};
79
80static struct platform_device mtx1_gpio_leds = {
81 .name = "leds-gpio",
82 .id = -1,
83 .dev = {
84 .platform_data = &mtx1_led_data,
85 }
86};
87
88static struct __initdata platform_device * mtx1_devs[] = {
89 &mtx1_gpio_leds,
Florian Fainellif6ed10a2008-01-07 19:00:46 +010090 &mtx1_wdt,
91 &mtx1_button
Florian Fainelli26c288f2007-10-23 18:55:55 +020092};
93
94static int __init mtx1_register_devices(void)
95{
Florian Fainellif6ed10a2008-01-07 19:00:46 +010096 gpio_direction_input(207);
Florian Fainelli26c288f2007-10-23 18:55:55 +020097 return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
98}
99
100arch_initcall(mtx1_register_devices);