Merge branch 'for-rmk' of git://git.pengutronix.de/git/ukl/linux-2.6 into devel
[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/platform_device.h>
24
25 #include <mach/regs-wan.h>
26 #include <mach/regs-lan.h>
27 #include <mach/regs-hpna.h>
28 #include <mach/regs-switch.h>
29 #include <mach/regs-misc.h>
30
31
32 /* --------------------------------------------------------------------
33  *  Ethernet
34  * -------------------------------------------------------------------- */
35
36 static u64 eth_dmamask = 0xffffffffUL;
37
38 static struct resource ks8695_wan_resources[] = {
39         [0] = {
40                 .start  = KS8695_WAN_PA,
41                 .end    = KS8695_WAN_PA + 0x00ff,
42                 .flags  = IORESOURCE_MEM,
43         },
44         [1] = {
45                 .name   = "WAN RX",
46                 .start  = KS8695_IRQ_WAN_RX_STATUS,
47                 .end    = KS8695_IRQ_WAN_RX_STATUS,
48                 .flags  = IORESOURCE_IRQ,
49         },
50         [2] = {
51                 .name   = "WAN TX",
52                 .start  = KS8695_IRQ_WAN_TX_STATUS,
53                 .end    = KS8695_IRQ_WAN_TX_STATUS,
54                 .flags  = IORESOURCE_IRQ,
55         },
56         [3] = {
57                 .name   = "WAN Link",
58                 .start  = KS8695_IRQ_WAN_LINK,
59                 .end    = KS8695_IRQ_WAN_LINK,
60                 .flags  = IORESOURCE_IRQ,
61         },
62         [4] = {
63                 .name   = "WAN PHY",
64                 .start  = KS8695_MISC_PA,
65                 .end    = KS8695_MISC_PA + 0x1f,
66                 .flags  = IORESOURCE_MEM,
67         },
68 };
69
70 static struct platform_device ks8695_wan_device = {
71         .name           = "ks8695_ether",
72         .id             = 0,
73         .dev            = {
74                                 .dma_mask               = &eth_dmamask,
75                                 .coherent_dma_mask      = 0xffffffff,
76         },
77         .resource       = ks8695_wan_resources,
78         .num_resources  = ARRAY_SIZE(ks8695_wan_resources),
79 };
80
81
82 static struct resource ks8695_lan_resources[] = {
83         [0] = {
84                 .start  = KS8695_LAN_PA,
85                 .end    = KS8695_LAN_PA + 0x00ff,
86                 .flags  = IORESOURCE_MEM,
87         },
88         [1] = {
89                 .name   = "LAN RX",
90                 .start  = KS8695_IRQ_LAN_RX_STATUS,
91                 .end    = KS8695_IRQ_LAN_RX_STATUS,
92                 .flags  = IORESOURCE_IRQ,
93         },
94         [2] = {
95                 .name   = "LAN TX",
96                 .start  = KS8695_IRQ_LAN_TX_STATUS,
97                 .end    = KS8695_IRQ_LAN_TX_STATUS,
98                 .flags  = IORESOURCE_IRQ,
99         },
100         [3] = {
101                 .name   = "LAN SWITCH",
102                 .start  = KS8695_SWITCH_PA,
103                 .end    = KS8695_SWITCH_PA + 0x4f,
104                 .flags  = IORESOURCE_MEM,
105         },
106 };
107
108 static struct platform_device ks8695_lan_device = {
109         .name           = "ks8695_ether",
110         .id             = 1,
111         .dev            = {
112                                 .dma_mask               = &eth_dmamask,
113                                 .coherent_dma_mask      = 0xffffffff,
114         },
115         .resource       = ks8695_lan_resources,
116         .num_resources  = ARRAY_SIZE(ks8695_lan_resources),
117 };
118
119
120 static struct resource ks8695_hpna_resources[] = {
121         [0] = {
122                 .start  = KS8695_HPNA_PA,
123                 .end    = KS8695_HPNA_PA + 0x00ff,
124                 .flags  = IORESOURCE_MEM,
125         },
126         [1] = {
127                 .name   = "HPNA RX",
128                 .start  = KS8695_IRQ_HPNA_RX_STATUS,
129                 .end    = KS8695_IRQ_HPNA_RX_STATUS,
130                 .flags  = IORESOURCE_IRQ,
131         },
132         [2] = {
133                 .name   = "HPNA TX",
134                 .start  = KS8695_IRQ_HPNA_TX_STATUS,
135                 .end    = KS8695_IRQ_HPNA_TX_STATUS,
136                 .flags  = IORESOURCE_IRQ,
137         },
138 };
139
140 static struct platform_device ks8695_hpna_device = {
141         .name           = "ks8695_ether",
142         .id             = 2,
143         .dev            = {
144                                 .dma_mask               = &eth_dmamask,
145                                 .coherent_dma_mask      = 0xffffffff,
146         },
147         .resource       = ks8695_hpna_resources,
148         .num_resources  = ARRAY_SIZE(ks8695_hpna_resources),
149 };
150
151 void __init ks8695_add_device_wan(void)
152 {
153         platform_device_register(&ks8695_wan_device);
154 }
155
156 void __init ks8695_add_device_lan(void)
157 {
158         platform_device_register(&ks8695_lan_device);
159 }
160
161 void __init ks8696_add_device_hpna(void)
162 {
163         platform_device_register(&ks8695_hpna_device);
164 }
165
166
167 /* --------------------------------------------------------------------
168  *  Watchdog
169  * -------------------------------------------------------------------- */
170
171 static struct platform_device ks8695_wdt_device = {
172         .name           = "ks8695_wdt",
173         .id             = -1,
174         .num_resources  = 0,
175 };
176
177 static void __init ks8695_add_device_watchdog(void)
178 {
179         platform_device_register(&ks8695_wdt_device);
180 }
181
182
183 /* --------------------------------------------------------------------
184  *  LEDs
185  * -------------------------------------------------------------------- */
186
187 #if defined(CONFIG_LEDS)
188 short ks8695_leds_cpu = -1;
189 short ks8695_leds_timer = -1;
190
191 void __init ks8695_init_leds(u8 cpu_led, u8 timer_led)
192 {
193         /* Enable GPIO to access the LEDs */
194         gpio_direction_output(cpu_led, 1);
195         gpio_direction_output(timer_led, 1);
196
197         ks8695_leds_cpu   = cpu_led;
198         ks8695_leds_timer = timer_led;
199 }
200 #else
201 void __init ks8695_init_leds(u8 cpu_led, u8 timer_led) {}
202 #endif
203
204 /* -------------------------------------------------------------------- */
205
206 /*
207  * These devices are always present and don't need any board-specific
208  * setup.
209  */
210 static int __init ks8695_add_standard_devices(void)
211 {
212         ks8695_add_device_watchdog();
213         return 0;
214 }
215
216 arch_initcall(ks8695_add_standard_devices);