]>
Commit | Line | Data |
---|---|---|
e60d07b6 LB |
1 | /* |
2 | * arch/arm/mach-iop32x/n2100.c | |
3 | * | |
4 | * Board support code for the Thecus N2100 platform. | |
5 | * | |
6 | * Author: Rory Bolt <rorybolt@pacbell.net> | |
7 | * Copyright (C) 2002 Rory Bolt | |
8 | * Copyright 2003 (c) MontaVista, Software, Inc. | |
9 | * Copyright (C) 2004 Intel Corp. | |
10 | * | |
11 | * This program is free software; you can redistribute it and/or modify it | |
12 | * under the terms of the GNU General Public License as published by the | |
13 | * Free Software Foundation; either version 2 of the License, or (at your | |
14 | * option) any later version. | |
15 | */ | |
16 | ||
17 | #include <linux/mm.h> | |
18 | #include <linux/init.h> | |
9aa69338 | 19 | #include <linux/f75375s.h> |
30be0486 | 20 | #include <linux/leds-pca9532.h> |
e60d07b6 LB |
21 | #include <linux/delay.h> |
22 | #include <linux/kernel.h> | |
23 | #include <linux/pci.h> | |
24 | #include <linux/pm.h> | |
25 | #include <linux/string.h> | |
e60d07b6 LB |
26 | #include <linux/serial_core.h> |
27 | #include <linux/serial_8250.h> | |
28 | #include <linux/mtd/physmap.h> | |
c00593f6 | 29 | #include <linux/i2c.h> |
e60d07b6 LB |
30 | #include <linux/platform_device.h> |
31 | #include <linux/reboot.h> | |
fced80c7 | 32 | #include <linux/io.h> |
a09e64fb | 33 | #include <mach/hardware.h> |
e60d07b6 LB |
34 | #include <asm/irq.h> |
35 | #include <asm/mach/arch.h> | |
36 | #include <asm/mach/map.h> | |
37 | #include <asm/mach/pci.h> | |
38 | #include <asm/mach/time.h> | |
39 | #include <asm/mach-types.h> | |
40 | #include <asm/page.h> | |
41 | #include <asm/pgtable.h> | |
a09e64fb | 42 | #include <mach/time.h> |
e60d07b6 LB |
43 | |
44 | /* | |
45 | * N2100 timer tick configuration. | |
46 | */ | |
47 | static void __init n2100_timer_init(void) | |
48 | { | |
49 | /* 33.000 MHz crystal. */ | |
3668b45d | 50 | iop_init_time(198000000); |
e60d07b6 LB |
51 | } |
52 | ||
53 | static struct sys_timer n2100_timer = { | |
54 | .init = n2100_timer_init, | |
e60d07b6 LB |
55 | }; |
56 | ||
57 | ||
58 | /* | |
59 | * N2100 I/O. | |
60 | */ | |
61 | static struct map_desc n2100_io_desc[] __initdata = { | |
62 | { /* on-board devices */ | |
63 | .virtual = N2100_UART, | |
64 | .pfn = __phys_to_pfn(N2100_UART), | |
65 | .length = 0x00100000, | |
66 | .type = MT_DEVICE | |
67 | }, | |
68 | }; | |
69 | ||
70 | void __init n2100_map_io(void) | |
71 | { | |
72 | iop3xx_map_io(); | |
73 | iotable_init(n2100_io_desc, ARRAY_SIZE(n2100_io_desc)); | |
74 | } | |
75 | ||
76 | ||
77 | /* | |
78 | * N2100 PCI. | |
79 | */ | |
d73d8011 | 80 | static int __init |
d5341942 | 81 | n2100_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
e60d07b6 LB |
82 | { |
83 | int irq; | |
84 | ||
85 | if (PCI_SLOT(dev->devfn) == 1) { | |
86 | /* RTL8110SB #1 */ | |
87 | irq = IRQ_IOP32X_XINT0; | |
88 | } else if (PCI_SLOT(dev->devfn) == 2) { | |
89 | /* RTL8110SB #2 */ | |
811c9a4b | 90 | irq = IRQ_IOP32X_XINT3; |
e60d07b6 LB |
91 | } else if (PCI_SLOT(dev->devfn) == 3) { |
92 | /* Sil3512 */ | |
93 | irq = IRQ_IOP32X_XINT2; | |
94 | } else if (PCI_SLOT(dev->devfn) == 4 && pin == 1) { | |
95 | /* VT6212 INTA */ | |
96 | irq = IRQ_IOP32X_XINT1; | |
97 | } else if (PCI_SLOT(dev->devfn) == 4 && pin == 2) { | |
98 | /* VT6212 INTB */ | |
99 | irq = IRQ_IOP32X_XINT0; | |
100 | } else if (PCI_SLOT(dev->devfn) == 4 && pin == 3) { | |
101 | /* VT6212 INTC */ | |
102 | irq = IRQ_IOP32X_XINT2; | |
103 | } else if (PCI_SLOT(dev->devfn) == 5) { | |
104 | /* Mini-PCI slot */ | |
105 | irq = IRQ_IOP32X_XINT3; | |
106 | } else { | |
107 | printk(KERN_ERR "n2100_pci_map_irq() called for unknown " | |
108 | "device PCI:%d:%d:%d\n", dev->bus->number, | |
109 | PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); | |
110 | irq = -1; | |
111 | } | |
112 | ||
113 | return irq; | |
114 | } | |
115 | ||
116 | static struct hw_pci n2100_pci __initdata = { | |
e60d07b6 | 117 | .nr_controllers = 1, |
c23bfc38 | 118 | .ops = &iop3xx_ops, |
e60d07b6 LB |
119 | .setup = iop3xx_pci_setup, |
120 | .preinit = iop3xx_pci_preinit, | |
e60d07b6 LB |
121 | .map_irq = n2100_pci_map_irq, |
122 | }; | |
123 | ||
66822b2e LB |
124 | /* |
125 | * Both r8169 chips on the n2100 exhibit PCI parity problems. Set | |
126 | * the ->broken_parity_status flag for both ports so that the r8169 | |
127 | * driver knows it should ignore error interrupts. | |
128 | */ | |
129 | static void n2100_fixup_r8169(struct pci_dev *dev) | |
130 | { | |
131 | if (dev->bus->number == 0 && | |
132 | (dev->devfn == PCI_DEVFN(1, 0) || | |
133 | dev->devfn == PCI_DEVFN(2, 0))) | |
134 | dev->broken_parity_status = 1; | |
135 | } | |
136 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169); | |
137 | ||
e60d07b6 LB |
138 | static int __init n2100_pci_init(void) |
139 | { | |
140 | if (machine_is_n2100()) | |
141 | pci_common_init(&n2100_pci); | |
142 | ||
143 | return 0; | |
144 | } | |
145 | ||
146 | subsys_initcall(n2100_pci_init); | |
147 | ||
148 | ||
149 | /* | |
150 | * N2100 machine initialisation. | |
151 | */ | |
152 | static struct physmap_flash_data n2100_flash_data = { | |
153 | .width = 2, | |
154 | }; | |
155 | ||
156 | static struct resource n2100_flash_resource = { | |
157 | .start = 0xf0000000, | |
158 | .end = 0xf0ffffff, | |
159 | .flags = IORESOURCE_MEM, | |
160 | }; | |
161 | ||
162 | static struct platform_device n2100_flash_device = { | |
163 | .name = "physmap-flash", | |
164 | .id = 0, | |
165 | .dev = { | |
166 | .platform_data = &n2100_flash_data, | |
167 | }, | |
168 | .num_resources = 1, | |
169 | .resource = &n2100_flash_resource, | |
170 | }; | |
171 | ||
172 | ||
173 | static struct plat_serial8250_port n2100_serial_port[] = { | |
174 | { | |
175 | .mapbase = N2100_UART, | |
176 | .membase = (char *)N2100_UART, | |
177 | .irq = 0, | |
cc761bed | 178 | .flags = UPF_SKIP_TEST | UPF_AUTO_IRQ | UPF_SHARE_IRQ, |
e60d07b6 LB |
179 | .iotype = UPIO_MEM, |
180 | .regshift = 0, | |
181 | .uartclk = 1843200, | |
182 | }, | |
183 | { }, | |
184 | }; | |
185 | ||
186 | static struct resource n2100_uart_resource = { | |
187 | .start = N2100_UART, | |
188 | .end = N2100_UART + 7, | |
189 | .flags = IORESOURCE_MEM, | |
190 | }; | |
191 | ||
192 | static struct platform_device n2100_serial_device = { | |
193 | .name = "serial8250", | |
194 | .id = PLAT8250_DEV_PLATFORM, | |
195 | .dev = { | |
196 | .platform_data = n2100_serial_port, | |
197 | }, | |
198 | .num_resources = 1, | |
199 | .resource = &n2100_uart_resource, | |
200 | }; | |
201 | ||
9aa69338 RV |
202 | static struct f75375s_platform_data n2100_f75375s = { |
203 | .pwm = { 255, 255 }, | |
204 | .pwm_enable = { 0, 0 }, | |
205 | }; | |
206 | ||
30be0486 RV |
207 | static struct pca9532_platform_data n2100_leds = { |
208 | .leds = { | |
209 | { .name = "n2100:red:satafail0", | |
210 | .state = PCA9532_OFF, | |
211 | .type = PCA9532_TYPE_LED, | |
212 | }, | |
213 | { .name = "n2100:red:satafail1", | |
214 | .state = PCA9532_OFF, | |
215 | .type = PCA9532_TYPE_LED, | |
216 | }, | |
217 | { .name = "n2100:blue:usb", | |
218 | .state = PCA9532_OFF, | |
219 | .type = PCA9532_TYPE_LED, | |
220 | }, | |
221 | { .type = PCA9532_TYPE_NONE }, | |
222 | ||
223 | { .type = PCA9532_TYPE_NONE }, | |
224 | { .type = PCA9532_TYPE_NONE }, | |
225 | { .type = PCA9532_TYPE_NONE }, | |
226 | { .name = "n2100:red:usb", | |
227 | .state = PCA9532_OFF, | |
228 | .type = PCA9532_TYPE_LED, | |
229 | }, | |
230 | ||
231 | { .type = PCA9532_TYPE_NONE }, /* power OFF gpio */ | |
232 | { .type = PCA9532_TYPE_NONE }, /* reset gpio */ | |
233 | { .type = PCA9532_TYPE_NONE }, | |
234 | { .type = PCA9532_TYPE_NONE }, | |
235 | ||
236 | { .type = PCA9532_TYPE_NONE }, | |
237 | { .name = "n2100:orange:system", | |
238 | .state = PCA9532_OFF, | |
239 | .type = PCA9532_TYPE_LED, | |
240 | }, | |
241 | { .name = "n2100:red:system", | |
242 | .state = PCA9532_OFF, | |
243 | .type = PCA9532_TYPE_LED, | |
244 | }, | |
245 | { .name = "N2100 beeper" , | |
246 | .state = PCA9532_OFF, | |
247 | .type = PCA9532_TYPE_N2100_BEEP, | |
248 | }, | |
249 | }, | |
250 | .psc = { 0, 0 }, | |
251 | .pwm = { 0, 0 }, | |
252 | }; | |
253 | ||
c00593f6 MM |
254 | static struct i2c_board_info __initdata n2100_i2c_devices[] = { |
255 | { | |
3760f736 | 256 | I2C_BOARD_INFO("rs5c372b", 0x32), |
c00593f6 | 257 | }, |
9aa69338 RV |
258 | { |
259 | I2C_BOARD_INFO("f75375", 0x2e), | |
9aa69338 RV |
260 | .platform_data = &n2100_f75375s, |
261 | }, | |
30be0486 RV |
262 | { |
263 | I2C_BOARD_INFO("pca9532", 0x60), | |
264 | .platform_data = &n2100_leds, | |
265 | }, | |
c00593f6 | 266 | }; |
e60d07b6 LB |
267 | |
268 | /* | |
269 | * Pull PCA9532 GPIO #8 low to power off the machine. | |
270 | */ | |
271 | static void n2100_power_off(void) | |
272 | { | |
273 | local_irq_disable(); | |
274 | ||
275 | /* Start condition, I2C address of PCA9532, write transaction. */ | |
276 | *IOP3XX_IDBR0 = 0xc0; | |
277 | *IOP3XX_ICR0 = 0xe9; | |
278 | mdelay(1); | |
279 | ||
280 | /* Write address 0x08. */ | |
281 | *IOP3XX_IDBR0 = 0x08; | |
282 | *IOP3XX_ICR0 = 0xe8; | |
283 | mdelay(1); | |
284 | ||
285 | /* Write data 0x01, stop condition. */ | |
286 | *IOP3XX_IDBR0 = 0x01; | |
287 | *IOP3XX_ICR0 = 0xea; | |
288 | ||
289 | while (1) | |
290 | ; | |
291 | } | |
292 | ||
bec92b1e RK |
293 | static void n2100_restart(char mode, const char *cmd) |
294 | { | |
295 | gpio_line_set(N2100_HARDWARE_RESET, GPIO_LOW); | |
296 | gpio_line_config(N2100_HARDWARE_RESET, GPIO_OUT); | |
297 | while (1) | |
298 | ; | |
299 | } | |
300 | ||
e60d07b6 LB |
301 | |
302 | static struct timer_list power_button_poll_timer; | |
303 | ||
304 | static void power_button_poll(unsigned long dummy) | |
305 | { | |
306 | if (gpio_line_get(N2100_POWER_BUTTON) == 0) { | |
307 | ctrl_alt_del(); | |
308 | return; | |
309 | } | |
310 | ||
311 | power_button_poll_timer.expires = jiffies + (HZ / 10); | |
312 | add_timer(&power_button_poll_timer); | |
313 | } | |
314 | ||
315 | ||
316 | static void __init n2100_init_machine(void) | |
317 | { | |
318 | platform_device_register(&iop3xx_i2c0_device); | |
319 | platform_device_register(&n2100_flash_device); | |
320 | platform_device_register(&n2100_serial_device); | |
2492c845 DW |
321 | platform_device_register(&iop3xx_dma_0_channel); |
322 | platform_device_register(&iop3xx_dma_1_channel); | |
e60d07b6 | 323 | |
c00593f6 MM |
324 | i2c_register_board_info(0, n2100_i2c_devices, |
325 | ARRAY_SIZE(n2100_i2c_devices)); | |
326 | ||
e60d07b6 LB |
327 | pm_power_off = n2100_power_off; |
328 | ||
329 | init_timer(&power_button_poll_timer); | |
330 | power_button_poll_timer.function = power_button_poll; | |
331 | power_button_poll_timer.expires = jiffies + (HZ / 10); | |
332 | add_timer(&power_button_poll_timer); | |
333 | } | |
334 | ||
335 | MACHINE_START(N2100, "Thecus N2100") | |
336 | /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ | |
1896746d | 337 | .atag_offset = 0x100, |
e60d07b6 LB |
338 | .map_io = n2100_map_io, |
339 | .init_irq = iop32x_init_irq, | |
340 | .timer = &n2100_timer, | |
341 | .init_machine = n2100_init_machine, | |
bec92b1e | 342 | .restart = n2100_restart, |
e60d07b6 | 343 | MACHINE_END |