blob: 36ab0fd3d9b687ace1c166a3d4231262d6dedb12 [file] [log] [blame]
Andrew Victorc53c9cf2007-05-11 21:01:28 +01001/*
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
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/regs-wan.h>
26#include <mach/regs-lan.h>
27#include <mach/regs-hpna.h>
Daniel Silverstonefbd62712008-12-13 20:44:11 +000028#include <mach/regs-switch.h>
29#include <mach/regs-misc.h>
Andrew Victorc53c9cf2007-05-11 21:01:28 +010030
31
32/* --------------------------------------------------------------------
33 * Ethernet
34 * -------------------------------------------------------------------- */
35
Andrew Victorc53c9cf2007-05-11 21:01:28 +010036static u64 eth_dmamask = 0xffffffffUL;
37
38static struct resource ks8695_wan_resources[] = {
39 [0] = {
Daniel Silverstonefbd62712008-12-13 20:44:11 +000040 .start = KS8695_WAN_PA,
41 .end = KS8695_WAN_PA + 0x00ff,
Andrew Victorc53c9cf2007-05-11 21:01:28 +010042 .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 },
Daniel Silverstonefbd62712008-12-13 20:44:11 +000062 [4] = {
63 .name = "WAN PHY",
64 .start = KS8695_MISC_PA,
65 .end = KS8695_MISC_PA + 0x1f,
66 .flags = IORESOURCE_MEM,
67 },
Andrew Victorc53c9cf2007-05-11 21:01:28 +010068};
69
70static 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
82static struct resource ks8695_lan_resources[] = {
83 [0] = {
Daniel Silverstonefbd62712008-12-13 20:44:11 +000084 .start = KS8695_LAN_PA,
85 .end = KS8695_LAN_PA + 0x00ff,
Andrew Victorc53c9cf2007-05-11 21:01:28 +010086 .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 },
Daniel Silverstonefbd62712008-12-13 20:44:11 +0000100 [3] = {
101 .name = "LAN SWITCH",
102 .start = KS8695_SWITCH_PA,
103 .end = KS8695_SWITCH_PA + 0x4f,
104 .flags = IORESOURCE_MEM,
105 },
Andrew Victorc53c9cf2007-05-11 21:01:28 +0100106};
107
108static 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
120static struct resource ks8695_hpna_resources[] = {
121 [0] = {
Daniel Silverstonefbd62712008-12-13 20:44:11 +0000122 .start = KS8695_HPNA_PA,
123 .end = KS8695_HPNA_PA + 0x00ff,
Andrew Victorc53c9cf2007-05-11 21:01:28 +0100124 .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
140static 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
151void __init ks8695_add_device_wan(void)
152{
153 platform_device_register(&ks8695_wan_device);
154}
155
156void __init ks8695_add_device_lan(void)
157{
158 platform_device_register(&ks8695_lan_device);
159}
160
161void __init ks8696_add_device_hpna(void)
162{
163 platform_device_register(&ks8695_hpna_device);
164}
Andrew Victorc53c9cf2007-05-11 21:01:28 +0100165
166
167/* --------------------------------------------------------------------
168 * Watchdog
169 * -------------------------------------------------------------------- */
170
Andrew Victorc53c9cf2007-05-11 21:01:28 +0100171static struct platform_device ks8695_wdt_device = {
172 .name = "ks8695_wdt",
173 .id = -1,
174 .num_resources = 0,
175};
176
177static void __init ks8695_add_device_watchdog(void)
178{
179 platform_device_register(&ks8695_wdt_device);
180}
Andrew Victorc53c9cf2007-05-11 21:01:28 +0100181
182
Andrew Victorfdb72fd2008-04-15 21:13:33 +0100183/* --------------------------------------------------------------------
184 * LEDs
185 * -------------------------------------------------------------------- */
186
187#if defined(CONFIG_LEDS)
188short ks8695_leds_cpu = -1;
189short ks8695_leds_timer = -1;
190
191void __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
Daniel Silverstonefbd62712008-12-13 20:44:11 +0000197 ks8695_leds_cpu = cpu_led;
Andrew Victorfdb72fd2008-04-15 21:13:33 +0100198 ks8695_leds_timer = timer_led;
199}
200#else
201void __init ks8695_init_leds(u8 cpu_led, u8 timer_led) {}
202#endif
203
Andrew Victorc53c9cf2007-05-11 21:01:28 +0100204/* -------------------------------------------------------------------- */
205
206/*
207 * These devices are always present and don't need any board-specific
208 * setup.
209 */
210static int __init ks8695_add_standard_devices(void)
211{
212 ks8695_add_device_watchdog();
213 return 0;
214}
215
216arch_initcall(ks8695_add_standard_devices);