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