Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/hch/vfs...
[pandora-kernel.git] / arch / arm / mach-ks8695 / devices.c
1 /*
2  * arch/arm/mach-ks8695/devices.c
3  *
4  * Copyright (C) 2006 Andrew Victor
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.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include <asm/mach/arch.h>
21 #include <asm/mach/map.h>
22
23 #include <linux/gpio.h>
24 #include <linux/platform_device.h>
25
26 #include <mach/irqs.h>
27 #include <mach/regs-wan.h>
28 #include <mach/regs-lan.h>
29 #include <mach/regs-hpna.h>
30 #include <mach/regs-switch.h>
31 #include <mach/regs-misc.h>
32
33
34 /* --------------------------------------------------------------------
35  *  Ethernet
36  * -------------------------------------------------------------------- */
37
38 static u64 eth_dmamask = 0xffffffffUL;
39
40 static struct resource ks8695_wan_resources[] = {
41         [0] = {
42                 .start  = KS8695_WAN_PA,
43                 .end    = KS8695_WAN_PA + 0x00ff,
44                 .flags  = IORESOURCE_MEM,
45         },
46         [1] = {
47                 .name   = "WAN RX",
48                 .start  = KS8695_IRQ_WAN_RX_STATUS,
49                 .end    = KS8695_IRQ_WAN_RX_STATUS,
50                 .flags  = IORESOURCE_IRQ,
51         },
52         [2] = {
53                 .name   = "WAN TX",
54                 .start  = KS8695_IRQ_WAN_TX_STATUS,
55                 .end    = KS8695_IRQ_WAN_TX_STATUS,
56                 .flags  = IORESOURCE_IRQ,
57         },
58         [3] = {
59                 .name   = "WAN Link",
60                 .start  = KS8695_IRQ_WAN_LINK,
61                 .end    = KS8695_IRQ_WAN_LINK,
62                 .flags  = IORESOURCE_IRQ,
63         },
64         [4] = {
65                 .name   = "WAN PHY",
66                 .start  = KS8695_MISC_PA,
67                 .end    = KS8695_MISC_PA + 0x1f,
68                 .flags  = IORESOURCE_MEM,
69         },
70 };
71
72 static struct platform_device ks8695_wan_device = {
73         .name           = "ks8695_ether",
74         .id             = 0,
75         .dev            = {
76                                 .dma_mask               = &eth_dmamask,
77                                 .coherent_dma_mask      = 0xffffffff,
78         },
79         .resource       = ks8695_wan_resources,
80         .num_resources  = ARRAY_SIZE(ks8695_wan_resources),
81 };
82
83
84 static struct resource ks8695_lan_resources[] = {
85         [0] = {
86                 .start  = KS8695_LAN_PA,
87                 .end    = KS8695_LAN_PA + 0x00ff,
88                 .flags  = IORESOURCE_MEM,
89         },
90         [1] = {
91                 .name   = "LAN RX",
92                 .start  = KS8695_IRQ_LAN_RX_STATUS,
93                 .end    = KS8695_IRQ_LAN_RX_STATUS,
94                 .flags  = IORESOURCE_IRQ,
95         },
96         [2] = {
97                 .name   = "LAN TX",
98                 .start  = KS8695_IRQ_LAN_TX_STATUS,
99                 .end    = KS8695_IRQ_LAN_TX_STATUS,
100                 .flags  = IORESOURCE_IRQ,
101         },
102         [3] = {
103                 .name   = "LAN SWITCH",
104                 .start  = KS8695_SWITCH_PA,
105                 .end    = KS8695_SWITCH_PA + 0x4f,
106                 .flags  = IORESOURCE_MEM,
107         },
108 };
109
110 static struct platform_device ks8695_lan_device = {
111         .name           = "ks8695_ether",
112         .id             = 1,
113         .dev            = {
114                                 .dma_mask               = &eth_dmamask,
115                                 .coherent_dma_mask      = 0xffffffff,
116         },
117         .resource       = ks8695_lan_resources,
118         .num_resources  = ARRAY_SIZE(ks8695_lan_resources),
119 };
120
121
122 static struct resource ks8695_hpna_resources[] = {
123         [0] = {
124                 .start  = KS8695_HPNA_PA,
125                 .end    = KS8695_HPNA_PA + 0x00ff,
126                 .flags  = IORESOURCE_MEM,
127         },
128         [1] = {
129                 .name   = "HPNA RX",
130                 .start  = KS8695_IRQ_HPNA_RX_STATUS,
131                 .end    = KS8695_IRQ_HPNA_RX_STATUS,
132                 .flags  = IORESOURCE_IRQ,
133         },
134         [2] = {
135                 .name   = "HPNA TX",
136                 .start  = KS8695_IRQ_HPNA_TX_STATUS,
137                 .end    = KS8695_IRQ_HPNA_TX_STATUS,
138                 .flags  = IORESOURCE_IRQ,
139         },
140 };
141
142 static struct platform_device ks8695_hpna_device = {
143         .name           = "ks8695_ether",
144         .id             = 2,
145         .dev            = {
146                                 .dma_mask               = &eth_dmamask,
147                                 .coherent_dma_mask      = 0xffffffff,
148         },
149         .resource       = ks8695_hpna_resources,
150         .num_resources  = ARRAY_SIZE(ks8695_hpna_resources),
151 };
152
153 void __init ks8695_add_device_wan(void)
154 {
155         platform_device_register(&ks8695_wan_device);
156 }
157
158 void __init ks8695_add_device_lan(void)
159 {
160         platform_device_register(&ks8695_lan_device);
161 }
162
163 void __init ks8696_add_device_hpna(void)
164 {
165         platform_device_register(&ks8695_hpna_device);
166 }
167
168
169 /* --------------------------------------------------------------------
170  *  Watchdog
171  * -------------------------------------------------------------------- */
172
173 static struct platform_device ks8695_wdt_device = {
174         .name           = "ks8695_wdt",
175         .id             = -1,
176         .num_resources  = 0,
177 };
178
179 static void __init ks8695_add_device_watchdog(void)
180 {
181         platform_device_register(&ks8695_wdt_device);
182 }
183
184
185 /* --------------------------------------------------------------------
186  *  LEDs
187  * -------------------------------------------------------------------- */
188
189 #if defined(CONFIG_LEDS)
190 short ks8695_leds_cpu = -1;
191 short ks8695_leds_timer = -1;
192
193 void __init ks8695_init_leds(u8 cpu_led, u8 timer_led)
194 {
195         /* Enable GPIO to access the LEDs */
196         gpio_direction_output(cpu_led, 1);
197         gpio_direction_output(timer_led, 1);
198
199         ks8695_leds_cpu   = cpu_led;
200         ks8695_leds_timer = timer_led;
201 }
202 #else
203 void __init ks8695_init_leds(u8 cpu_led, u8 timer_led) {}
204 #endif
205
206 /* -------------------------------------------------------------------- */
207
208 /*
209  * These devices are always present and don't need any board-specific
210  * setup.
211  */
212 static int __init ks8695_add_standard_devices(void)
213 {
214         ks8695_add_device_watchdog();
215         return 0;
216 }
217
218 arch_initcall(ks8695_add_standard_devices);