[ifxmips]
[openwrt/svn-archive/archive.git] / target / linux / ifxmips / files-2.6.33 / 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 /* gpio leds */
24 #ifdef CONFIG_LEDS_GPIO
25 static struct gpio_led_platform_data ifxmips_gpio_led_data;
26
27 static struct platform_device ifxmips_gpio_leds =
28 {
29 .name = "leds-gpio",
30 .dev = {
31 .platform_data = (void *) &ifxmips_gpio_led_data,
32 }
33 };
34
35 void __init
36 ifxmips_register_gpio_leds(struct gpio_led *leds, int cnt)
37 {
38 ifxmips_gpio_led_data.leds = leds;
39 ifxmips_gpio_led_data.num_leds = cnt;
40 platform_device_register(&ifxmips_gpio_leds);
41 }
42 #endif
43
44 /* leds */
45 static struct gpio_led_platform_data ifxmips_led_data;
46
47 static struct platform_device ifxmips_led =
48 {
49 .name = "ifxmips_led",
50 .dev = {
51 .platform_data = (void *) &ifxmips_led_data,
52 }
53 };
54
55 void __init
56 ifxmips_register_leds(struct gpio_led *leds, int cnt)
57 {
58 ifxmips_led_data.leds = leds;
59 ifxmips_led_data.num_leds = cnt;
60 platform_device_register(&ifxmips_led);
61 }
62
63 /* mtd flash */
64 static struct resource ifxmips_mtd_resource =
65 {
66 .start = IFXMIPS_FLASH_START,
67 .end = IFXMIPS_FLASH_START + IFXMIPS_FLASH_MAX - 1,
68 .flags = IORESOURCE_MEM,
69 };
70
71 static struct platform_device ifxmips_mtd =
72 {
73 .name = "ifxmips_mtd",
74 .resource = &ifxmips_mtd_resource,
75 .num_resources = 1,
76 };
77
78 void __init
79 ifxmips_register_mtd(struct physmap_flash_data *pdata)
80 {
81 ifxmips_mtd.dev.platform_data = pdata;
82 platform_device_register(&ifxmips_mtd);
83 }
84
85 /* watchdog */
86 static struct resource ifxmips_wdt_resource =
87 {
88 .start = IFXMIPS_WDT_BASE_ADDR,
89 .end = IFXMIPS_WDT_BASE_ADDR + IFXMIPS_WDT_SIZE - 1,
90 .flags = IORESOURCE_MEM,
91 };
92
93 static struct platform_device ifxmips_wdt =
94 {
95 .name = "ifxmips_wdt",
96 .resource = &ifxmips_wdt_resource,
97 .num_resources = 1,
98 };
99
100 void __init
101 ifxmips_register_wdt(void)
102 {
103 platform_device_register(&ifxmips_wdt);
104 }
105
106 /* gpio */
107 static struct platform_device ifxmips_gpio0 =
108 {
109 .name = "ifxmips_gpio",
110 };
111
112 static struct platform_device ifxmips_gpio1 =
113 {
114 .name = "ifxmips_gpio1",
115 };
116
117 void __init
118 ifxmips_register_gpio(void)
119 {
120 platform_device_register(&ifxmips_gpio0);
121 platform_device_register(&ifxmips_gpio1);
122 }