blob: bc91d6e66bc4ea05e067d3b322b3ed8f1f64ac07 [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>
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010020#include <linux/delay.h>
21#include <linux/kernel.h>
22#include <linux/pci.h>
23#include <linux/pm.h>
24#include <linux/string.h>
25#include <linux/slab.h>
26#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>
32#include <asm/hardware.h>
33#include <asm/io.h>
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>
Dan Williams3668b452007-02-13 17:13:34 +010042#include <asm/arch/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
53static struct sys_timer n2100_timer = {
54 .init = n2100_timer_init,
Dan Williams3668b452007-02-13 17:13:34 +010055 .offset = iop_gettimeoffset,
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010056};
57
58
59/*
60 * N2100 I/O.
61 */
62static struct map_desc n2100_io_desc[] __initdata = {
63 { /* on-board devices */
64 .virtual = N2100_UART,
65 .pfn = __phys_to_pfn(N2100_UART),
66 .length = 0x00100000,
67 .type = MT_DEVICE
68 },
69};
70
71void __init n2100_map_io(void)
72{
73 iop3xx_map_io();
74 iotable_init(n2100_io_desc, ARRAY_SIZE(n2100_io_desc));
75}
76
77
78/*
79 * N2100 PCI.
80 */
Dan Williamsd73d8012007-05-15 01:03:36 +010081static int __init
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010082n2100_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
83{
84 int irq;
85
86 if (PCI_SLOT(dev->devfn) == 1) {
87 /* RTL8110SB #1 */
88 irq = IRQ_IOP32X_XINT0;
89 } else if (PCI_SLOT(dev->devfn) == 2) {
90 /* RTL8110SB #2 */
Lennert Buytenhek811c9a42006-10-29 14:15:10 +010091 irq = IRQ_IOP32X_XINT3;
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010092 } else if (PCI_SLOT(dev->devfn) == 3) {
93 /* Sil3512 */
94 irq = IRQ_IOP32X_XINT2;
95 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 1) {
96 /* VT6212 INTA */
97 irq = IRQ_IOP32X_XINT1;
98 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 2) {
99 /* VT6212 INTB */
100 irq = IRQ_IOP32X_XINT0;
101 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 3) {
102 /* VT6212 INTC */
103 irq = IRQ_IOP32X_XINT2;
104 } else if (PCI_SLOT(dev->devfn) == 5) {
105 /* Mini-PCI slot */
106 irq = IRQ_IOP32X_XINT3;
107 } else {
108 printk(KERN_ERR "n2100_pci_map_irq() called for unknown "
109 "device PCI:%d:%d:%d\n", dev->bus->number,
110 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
111 irq = -1;
112 }
113
114 return irq;
115}
116
117static struct hw_pci n2100_pci __initdata = {
118 .swizzle = pci_std_swizzle,
119 .nr_controllers = 1,
120 .setup = iop3xx_pci_setup,
121 .preinit = iop3xx_pci_preinit,
122 .scan = iop3xx_pci_scan_bus,
123 .map_irq = n2100_pci_map_irq,
124};
125
Lennert Buytenhek66822b22007-02-08 01:03:17 +0100126/*
127 * Both r8169 chips on the n2100 exhibit PCI parity problems. Set
128 * the ->broken_parity_status flag for both ports so that the r8169
129 * driver knows it should ignore error interrupts.
130 */
131static void n2100_fixup_r8169(struct pci_dev *dev)
132{
133 if (dev->bus->number == 0 &&
134 (dev->devfn == PCI_DEVFN(1, 0) ||
135 dev->devfn == PCI_DEVFN(2, 0)))
136 dev->broken_parity_status = 1;
137}
138DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169);
139
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100140static int __init n2100_pci_init(void)
141{
142 if (machine_is_n2100())
143 pci_common_init(&n2100_pci);
144
145 return 0;
146}
147
148subsys_initcall(n2100_pci_init);
149
150
151/*
152 * N2100 machine initialisation.
153 */
154static struct physmap_flash_data n2100_flash_data = {
155 .width = 2,
156};
157
158static struct resource n2100_flash_resource = {
159 .start = 0xf0000000,
160 .end = 0xf0ffffff,
161 .flags = IORESOURCE_MEM,
162};
163
164static struct platform_device n2100_flash_device = {
165 .name = "physmap-flash",
166 .id = 0,
167 .dev = {
168 .platform_data = &n2100_flash_data,
169 },
170 .num_resources = 1,
171 .resource = &n2100_flash_resource,
172};
173
174
175static struct plat_serial8250_port n2100_serial_port[] = {
176 {
177 .mapbase = N2100_UART,
178 .membase = (char *)N2100_UART,
179 .irq = 0,
180 .flags = UPF_SKIP_TEST,
181 .iotype = UPIO_MEM,
182 .regshift = 0,
183 .uartclk = 1843200,
184 },
185 { },
186};
187
188static struct resource n2100_uart_resource = {
189 .start = N2100_UART,
190 .end = N2100_UART + 7,
191 .flags = IORESOURCE_MEM,
192};
193
194static struct platform_device n2100_serial_device = {
195 .name = "serial8250",
196 .id = PLAT8250_DEV_PLATFORM,
197 .dev = {
198 .platform_data = n2100_serial_port,
199 },
200 .num_resources = 1,
201 .resource = &n2100_uart_resource,
202};
203
Riku Voipio9aa69332007-10-16 13:08:57 +0300204static struct f75375s_platform_data n2100_f75375s = {
205 .pwm = { 255, 255 },
206 .pwm_enable = { 0, 0 },
207};
208
Martin Michlmayrc00593f2007-07-17 04:04:57 -0700209static struct i2c_board_info __initdata n2100_i2c_devices[] = {
210 {
211 I2C_BOARD_INFO("rtc-rs5c372", 0x32),
212 .type = "rs5c372b",
213 },
Riku Voipio9aa69332007-10-16 13:08:57 +0300214 {
215 I2C_BOARD_INFO("f75375", 0x2e),
216 .type = "f75375",
217 .platform_data = &n2100_f75375s,
218 },
Martin Michlmayrc00593f2007-07-17 04:04:57 -0700219};
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100220
221/*
222 * Pull PCA9532 GPIO #8 low to power off the machine.
223 */
224static void n2100_power_off(void)
225{
226 local_irq_disable();
227
228 /* Start condition, I2C address of PCA9532, write transaction. */
229 *IOP3XX_IDBR0 = 0xc0;
230 *IOP3XX_ICR0 = 0xe9;
231 mdelay(1);
232
233 /* Write address 0x08. */
234 *IOP3XX_IDBR0 = 0x08;
235 *IOP3XX_ICR0 = 0xe8;
236 mdelay(1);
237
238 /* Write data 0x01, stop condition. */
239 *IOP3XX_IDBR0 = 0x01;
240 *IOP3XX_ICR0 = 0xea;
241
242 while (1)
243 ;
244}
245
246
247static struct timer_list power_button_poll_timer;
248
249static void power_button_poll(unsigned long dummy)
250{
251 if (gpio_line_get(N2100_POWER_BUTTON) == 0) {
252 ctrl_alt_del();
253 return;
254 }
255
256 power_button_poll_timer.expires = jiffies + (HZ / 10);
257 add_timer(&power_button_poll_timer);
258}
259
260
261static void __init n2100_init_machine(void)
262{
263 platform_device_register(&iop3xx_i2c0_device);
264 platform_device_register(&n2100_flash_device);
265 platform_device_register(&n2100_serial_device);
Dan Williams2492c842007-01-02 13:52:31 -0700266 platform_device_register(&iop3xx_dma_0_channel);
267 platform_device_register(&iop3xx_dma_1_channel);
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100268
Martin Michlmayrc00593f2007-07-17 04:04:57 -0700269 i2c_register_board_info(0, n2100_i2c_devices,
270 ARRAY_SIZE(n2100_i2c_devices));
271
Lennert Buytenheke60d07b2006-09-21 02:42:12 +0100272 pm_power_off = n2100_power_off;
273
274 init_timer(&power_button_poll_timer);
275 power_button_poll_timer.function = power_button_poll;
276 power_button_poll_timer.expires = jiffies + (HZ / 10);
277 add_timer(&power_button_poll_timer);
278}
279
280MACHINE_START(N2100, "Thecus N2100")
281 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
282 .phys_io = N2100_UART,
283 .io_pg_offst = ((N2100_UART) >> 18) & 0xfffc,
284 .boot_params = 0xa0000100,
285 .map_io = n2100_map_io,
286 .init_irq = iop32x_init_irq,
287 .timer = &n2100_timer,
288 .init_machine = n2100_init_machine,
289MACHINE_END