add .32 patches
[openwrt/staging/mkresin.git] / target / linux / ifxmips / files-2.6.32 / arch / mips / ifxmips / common / devices.c
1 #include <linux/init.h>
2 #include <linux/module.h>
3 #include <linux/types.h>
4 #include <linux/string.h>
5 #include <linux/mtd/physmap.h>
6 #include <linux/kernel.h>
7 #include <linux/reboot.h>
8 #include <linux/platform_device.h>
9 #include <linux/leds.h>
10 #include <linux/etherdevice.h>
11 #include <linux/reboot.h>
12 #include <linux/time.h>
13 #include <linux/io.h>
14 #include <linux/gpio.h>
15 #include <linux/leds.h>
16
17 #include <asm/bootinfo.h>
18 #include <asm/irq.h>
19
20 #include <ifxmips.h>
21 #include <ifxmips_irq.h>
22
23 /* gpiodev */
24 static struct platform_device ifxmips_gpio_dev =
25 {
26 .name = "GPIODEV",
27 .num_resources = 1,
28 };
29
30 void __init
31 ifxmips_register_gpio_dev(void)
32 {
33 platform_device_register(&ifxmips_gpio_dev);
34 }
35
36 /* gpio leds */
37 #ifdef CONFIG_LEDS_GPIO
38 static struct gpio_led_platform_data ifxmips_gpio_led_data;
39
40 static struct platform_device ifxmips_gpio_leds =
41 {
42 .name = "leds-gpio",
43 .dev = {
44 .platform_data = (void *) &ifxmips_gpio_led_data,
45 }
46 };
47
48 void __init
49 ifxmips_register_gpio_leds(struct gpio_led *leds, int cnt)
50 {
51 ifxmips_gpio_led_data.leds = leds;
52 ifxmips_gpio_led_data.num_leds = cnt;
53 platform_device_register(&ifxmips_gpio_leds);
54 }
55 #endif
56
57 /* leds */
58 static struct gpio_led_platform_data ifxmips_led_data;
59
60 static struct platform_device ifxmips_led =
61 {
62 .name = "ifxmips_led",
63 .dev = {
64 .platform_data = (void *) &ifxmips_led_data,
65 }
66 };
67
68 void __init
69 ifxmips_register_leds(struct gpio_led *leds, int cnt)
70 {
71 ifxmips_led_data.leds = leds;
72 ifxmips_led_data.num_leds = cnt;
73 platform_device_register(&ifxmips_led);
74 }
75
76 /* mtd flash */
77 static struct resource ifxmips_mtd_resource =
78 {
79 .start = IFXMIPS_FLASH_START,
80 .end = IFXMIPS_FLASH_START + IFXMIPS_FLASH_MAX - 1,
81 .flags = IORESOURCE_MEM,
82 };
83
84 static struct platform_device ifxmips_mtd =
85 {
86 .name = "ifxmips_mtd",
87 .resource = &ifxmips_mtd_resource,
88 .num_resources = 1,
89 };
90
91 void __init
92 ifxmips_register_mtd(struct physmap_flash_data *pdata)
93 {
94 ifxmips_mtd.dev.platform_data = pdata;
95 platform_device_register(&ifxmips_mtd);
96 }
97
98 /* watchdog */
99 static struct resource ifxmips_wdt_resource =
100 {
101 .start = IFXMIPS_WDT_BASE_ADDR,
102 .end = IFXMIPS_WDT_BASE_ADDR + IFXMIPS_WDT_SIZE - 1,
103 .flags = IORESOURCE_MEM,
104 };
105
106 static struct platform_device ifxmips_wdt =
107 {
108 .name = "ifxmips_wdt",
109 .resource = &ifxmips_wdt_resource,
110 .num_resources = 1,
111 };
112
113 void __init
114 ifxmips_register_wdt(void)
115 {
116 platform_device_register(&ifxmips_wdt);
117 }
118
119 /* gpio */
120 static struct platform_device ifxmips_gpio0 =
121 {
122 .name = "ifxmips_gpio",
123 };
124
125 static struct platform_device ifxmips_gpio1 =
126 {
127 .name = "ifxmips_gpio1",
128 };
129
130 void __init
131 ifxmips_register_gpio(void)
132 {
133 platform_device_register(&ifxmips_gpio0);
134 platform_device_register(&ifxmips_gpio1);
135 }