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