blob: ea0984a7449e78d5c4780d349ea53759c9f75ab2 [file] [log] [blame]
Lennert Buytenheke60d07b2006-09-21 02:42:12 +01001/*
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>
Riku Voipio9aa69332007-10-16 13:08:57 +030019#include <linux/f75375s.h>
Riku Voipio30be0482008-05-31 14:45:16 +010020#include <linux/leds-pca9532.h>
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010021#include <linux/delay.h>
22#include <linux/kernel.h>
23#include <linux/pci.h>
24#include <linux/pm.h>
25#include <linux/string.h>
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010026#include <linux/serial_core.h>
27#include <linux/serial_8250.h>
28#include <linux/mtd/physmap.h>
Martin Michlmayrc00593f2007-07-17 04:04:57 -070029#include <linux/i2c.h>
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010030#include <linux/platform_device.h>
31#include <linux/reboot.h>
Russell Kingfced80c2008-09-06 12:10:45 +010032#include <linux/io.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/hardware.h>
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010034#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>
Russell Kinga09e64f2008-08-05 16:14:15 +010042#include <mach/time.h>
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010043
44/*
45 * N2100 timer tick configuration.
46 */
47static void __init n2100_timer_init(void)
48{
49 /* 33.000 MHz crystal. */
Dan Williams3668b452007-02-13 17:13:34 +010050 iop_init_time(198000000);
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010051}
52
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010053
54/*
55 * N2100 I/O.
56 */
57static struct map_desc n2100_io_desc[] __initdata = {
58 { /* on-board devices */
59 .virtual = N2100_UART,
60 .pfn = __phys_to_pfn(N2100_UART),
61 .length = 0x00100000,
62 .type = MT_DEVICE
63 },
64};
65
66void __init n2100_map_io(void)
67{
68 iop3xx_map_io();
69 iotable_init(n2100_io_desc, ARRAY_SIZE(n2100_io_desc));
70}
71
72
73/*
74 * N2100 PCI.
75 */
Dan Williamsd73d8012007-05-15 01:03:36 +010076static int __init
Ralf Baechled5341942011-06-10 15:30:21 +010077n2100_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010078{
79 int irq;
80
81 if (PCI_SLOT(dev->devfn) == 1) {
82 /* RTL8110SB #1 */
83 irq = IRQ_IOP32X_XINT0;
84 } else if (PCI_SLOT(dev->devfn) == 2) {
85 /* RTL8110SB #2 */
Lennert Buytenhek811c9a42006-10-29 14:15:10 +010086 irq = IRQ_IOP32X_XINT3;
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010087 } else if (PCI_SLOT(dev->devfn) == 3) {
88 /* Sil3512 */
89 irq = IRQ_IOP32X_XINT2;
90 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 1) {
91 /* VT6212 INTA */
92 irq = IRQ_IOP32X_XINT1;
93 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 2) {
94 /* VT6212 INTB */
95 irq = IRQ_IOP32X_XINT0;
96 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 3) {
97 /* VT6212 INTC */
98 irq = IRQ_IOP32X_XINT2;
99 } else if (PCI_SLOT(dev->devfn) == 5) {
100 /* Mini-PCI slot */
101 irq = IRQ_IOP32X_XINT3;
102 } else {
103 printk(KERN_ERR "n2100_pci_map_irq() called for unknown "
104 "device PCI:%d:%d:%d\n", dev->bus->number,
105 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
106 irq = -1;
107 }
108
109 return irq;
110}
111
112static struct hw_pci n2100_pci __initdata = {
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100113 .nr_controllers = 1,
Russell Kingc23bfc32012-03-10 12:49:16 +0000114 .ops = &iop3xx_ops,
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100115 .setup = iop3xx_pci_setup,
116 .preinit = iop3xx_pci_preinit,
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100117 .map_irq = n2100_pci_map_irq,
118};
119
Lennert Buytenhek66822b22007-02-08 01:03:17 +0100120/*
121 * Both r8169 chips on the n2100 exhibit PCI parity problems. Set
122 * the ->broken_parity_status flag for both ports so that the r8169
123 * driver knows it should ignore error interrupts.
124 */
125static void n2100_fixup_r8169(struct pci_dev *dev)
126{
127 if (dev->bus->number == 0 &&
128 (dev->devfn == PCI_DEVFN(1, 0) ||
129 dev->devfn == PCI_DEVFN(2, 0)))
130 dev->broken_parity_status = 1;
131}
132DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169);
133
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100134static int __init n2100_pci_init(void)
135{
136 if (machine_is_n2100())
137 pci_common_init(&n2100_pci);
138
139 return 0;
140}
141
142subsys_initcall(n2100_pci_init);
143
144
145/*
146 * N2100 machine initialisation.
147 */
148static struct physmap_flash_data n2100_flash_data = {
149 .width = 2,
150};
151
152static struct resource n2100_flash_resource = {
153 .start = 0xf0000000,
154 .end = 0xf0ffffff,
155 .flags = IORESOURCE_MEM,
156};
157
158static struct platform_device n2100_flash_device = {
159 .name = "physmap-flash",
160 .id = 0,
161 .dev = {
162 .platform_data = &n2100_flash_data,
163 },
164 .num_resources = 1,
165 .resource = &n2100_flash_resource,
166};
167
168
169static struct plat_serial8250_port n2100_serial_port[] = {
170 {
171 .mapbase = N2100_UART,
172 .membase = (char *)N2100_UART,
173 .irq = 0,
Aaro Koskinencc761be2010-02-16 22:06:14 +0100174 .flags = UPF_SKIP_TEST | UPF_AUTO_IRQ | UPF_SHARE_IRQ,
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100175 .iotype = UPIO_MEM,
176 .regshift = 0,
177 .uartclk = 1843200,
178 },
179 { },
180};
181
182static struct resource n2100_uart_resource = {
183 .start = N2100_UART,
184 .end = N2100_UART + 7,
185 .flags = IORESOURCE_MEM,
186};
187
188static struct platform_device n2100_serial_device = {
189 .name = "serial8250",
190 .id = PLAT8250_DEV_PLATFORM,
191 .dev = {
192 .platform_data = n2100_serial_port,
193 },
194 .num_resources = 1,
195 .resource = &n2100_uart_resource,
196};
197
Riku Voipio9aa69332007-10-16 13:08:57 +0300198static struct f75375s_platform_data n2100_f75375s = {
199 .pwm = { 255, 255 },
200 .pwm_enable = { 0, 0 },
201};
202
Riku Voipio30be0482008-05-31 14:45:16 +0100203static struct pca9532_platform_data n2100_leds = {
204 .leds = {
205 { .name = "n2100:red:satafail0",
206 .state = PCA9532_OFF,
207 .type = PCA9532_TYPE_LED,
208 },
209 { .name = "n2100:red:satafail1",
210 .state = PCA9532_OFF,
211 .type = PCA9532_TYPE_LED,
212 },
213 { .name = "n2100:blue:usb",
214 .state = PCA9532_OFF,
215 .type = PCA9532_TYPE_LED,
216 },
217 { .type = PCA9532_TYPE_NONE },
218
219 { .type = PCA9532_TYPE_NONE },
220 { .type = PCA9532_TYPE_NONE },
221 { .type = PCA9532_TYPE_NONE },
222 { .name = "n2100:red:usb",
223 .state = PCA9532_OFF,
224 .type = PCA9532_TYPE_LED,
225 },
226
227 { .type = PCA9532_TYPE_NONE }, /* power OFF gpio */
228 { .type = PCA9532_TYPE_NONE }, /* reset gpio */
229 { .type = PCA9532_TYPE_NONE },
230 { .type = PCA9532_TYPE_NONE },
231
232 { .type = PCA9532_TYPE_NONE },
233 { .name = "n2100:orange:system",
234 .state = PCA9532_OFF,
235 .type = PCA9532_TYPE_LED,
236 },
237 { .name = "n2100:red:system",
238 .state = PCA9532_OFF,
239 .type = PCA9532_TYPE_LED,
240 },
241 { .name = "N2100 beeper" ,
242 .state = PCA9532_OFF,
243 .type = PCA9532_TYPE_N2100_BEEP,
244 },
245 },
246 .psc = { 0, 0 },
247 .pwm = { 0, 0 },
248};
249
Martin Michlmayrc00593f2007-07-17 04:04:57 -0700250static struct i2c_board_info __initdata n2100_i2c_devices[] = {
251 {
Jean Delvare3760f732008-04-29 23:11:40 +0200252 I2C_BOARD_INFO("rs5c372b", 0x32),
Martin Michlmayrc00593f2007-07-17 04:04:57 -0700253 },
Riku Voipio9aa69332007-10-16 13:08:57 +0300254 {
255 I2C_BOARD_INFO("f75375", 0x2e),
Riku Voipio9aa69332007-10-16 13:08:57 +0300256 .platform_data = &n2100_f75375s,
257 },
Riku Voipio30be0482008-05-31 14:45:16 +0100258 {
259 I2C_BOARD_INFO("pca9532", 0x60),
260 .platform_data = &n2100_leds,
261 },
Martin Michlmayrc00593f2007-07-17 04:04:57 -0700262};
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100263
264/*
265 * Pull PCA9532 GPIO #8 low to power off the machine.
266 */
267static void n2100_power_off(void)
268{
269 local_irq_disable();
270
271 /* Start condition, I2C address of PCA9532, write transaction. */
272 *IOP3XX_IDBR0 = 0xc0;
273 *IOP3XX_ICR0 = 0xe9;
274 mdelay(1);
275
276 /* Write address 0x08. */
277 *IOP3XX_IDBR0 = 0x08;
278 *IOP3XX_ICR0 = 0xe8;
279 mdelay(1);
280
281 /* Write data 0x01, stop condition. */
282 *IOP3XX_IDBR0 = 0x01;
283 *IOP3XX_ICR0 = 0xea;
284
285 while (1)
286 ;
287}
288
Russell Kingbec92b12011-11-05 11:26:32 +0000289static void n2100_restart(char mode, const char *cmd)
290{
291 gpio_line_set(N2100_HARDWARE_RESET, GPIO_LOW);
292 gpio_line_config(N2100_HARDWARE_RESET, GPIO_OUT);
293 while (1)
294 ;
295}
296
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100297
298static struct timer_list power_button_poll_timer;
299
300static void power_button_poll(unsigned long dummy)
301{
302 if (gpio_line_get(N2100_POWER_BUTTON) == 0) {
303 ctrl_alt_del();
304 return;
305 }
306
307 power_button_poll_timer.expires = jiffies + (HZ / 10);
308 add_timer(&power_button_poll_timer);
309}
310
311
312static void __init n2100_init_machine(void)
313{
314 platform_device_register(&iop3xx_i2c0_device);
315 platform_device_register(&n2100_flash_device);
316 platform_device_register(&n2100_serial_device);
Dan Williams2492c842007-01-02 13:52:31 -0700317 platform_device_register(&iop3xx_dma_0_channel);
318 platform_device_register(&iop3xx_dma_1_channel);
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100319
Martin Michlmayrc00593f2007-07-17 04:04:57 -0700320 i2c_register_board_info(0, n2100_i2c_devices,
321 ARRAY_SIZE(n2100_i2c_devices));
322
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100323 pm_power_off = n2100_power_off;
324
325 init_timer(&power_button_poll_timer);
326 power_button_poll_timer.function = power_button_poll;
327 power_button_poll_timer.expires = jiffies + (HZ / 10);
328 add_timer(&power_button_poll_timer);
329}
330
331MACHINE_START(N2100, "Thecus N2100")
332 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Nicolas Pitre18967462011-07-05 22:38:12 -0400333 .atag_offset = 0x100,
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100334 .map_io = n2100_map_io,
335 .init_irq = iop32x_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700336 .init_time = n2100_timer_init,
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100337 .init_machine = n2100_init_machine,
Russell Kingbec92b12011-11-05 11:26:32 +0000338 .restart = n2100_restart,
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100339MACHINE_END