2 * arch/arm/mach-iop32x/n2100.c
4 * Board support code for the Thecus N2100 platform.
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.
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.
18 #include <linux/init.h>
19 #include <linux/delay.h>
20 #include <linux/kernel.h>
21 #include <linux/pci.h>
23 #include <linux/string.h>
24 #include <linux/slab.h>
25 #include <linux/serial_core.h>
26 #include <linux/serial_8250.h>
27 #include <linux/mtd/physmap.h>
28 #include <linux/i2c.h>
29 #include <linux/platform_device.h>
30 #include <linux/reboot.h>
31 #include <asm/hardware.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/map.h>
36 #include <asm/mach/pci.h>
37 #include <asm/mach/time.h>
38 #include <asm/mach-types.h>
40 #include <asm/pgtable.h>
41 #include <asm/arch/time.h>
44 * N2100 timer tick configuration.
46 static void __init
n2100_timer_init(void)
48 /* 33.000 MHz crystal. */
49 iop_init_time(198000000);
52 static struct sys_timer n2100_timer
= {
53 .init
= n2100_timer_init
,
54 .offset
= iop_gettimeoffset
,
61 static struct map_desc n2100_io_desc
[] __initdata
= {
62 { /* on-board devices */
63 .virtual = N2100_UART
,
64 .pfn
= __phys_to_pfn(N2100_UART
),
70 void __init
n2100_map_io(void)
73 iotable_init(n2100_io_desc
, ARRAY_SIZE(n2100_io_desc
));
81 n2100_pci_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
85 if (PCI_SLOT(dev
->devfn
) == 1) {
87 irq
= IRQ_IOP32X_XINT0
;
88 } else if (PCI_SLOT(dev
->devfn
) == 2) {
90 irq
= IRQ_IOP32X_XINT3
;
91 } else if (PCI_SLOT(dev
->devfn
) == 3) {
93 irq
= IRQ_IOP32X_XINT2
;
94 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 1) {
96 irq
= IRQ_IOP32X_XINT1
;
97 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 2) {
99 irq
= IRQ_IOP32X_XINT0
;
100 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 3) {
102 irq
= IRQ_IOP32X_XINT2
;
103 } else if (PCI_SLOT(dev
->devfn
) == 5) {
105 irq
= IRQ_IOP32X_XINT3
;
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
));
116 static struct hw_pci n2100_pci __initdata
= {
117 .swizzle
= pci_std_swizzle
,
119 .setup
= iop3xx_pci_setup
,
120 .preinit
= iop3xx_pci_preinit
,
121 .scan
= iop3xx_pci_scan_bus
,
122 .map_irq
= n2100_pci_map_irq
,
126 * Both r8169 chips on the n2100 exhibit PCI parity problems. Set
127 * the ->broken_parity_status flag for both ports so that the r8169
128 * driver knows it should ignore error interrupts.
130 static void n2100_fixup_r8169(struct pci_dev
*dev
)
132 if (dev
->bus
->number
== 0 &&
133 (dev
->devfn
== PCI_DEVFN(1, 0) ||
134 dev
->devfn
== PCI_DEVFN(2, 0)))
135 dev
->broken_parity_status
= 1;
137 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK
, PCI_ANY_ID
, n2100_fixup_r8169
);
139 static int __init
n2100_pci_init(void)
141 if (machine_is_n2100())
142 pci_common_init(&n2100_pci
);
147 subsys_initcall(n2100_pci_init
);
151 * N2100 machine initialisation.
153 static struct physmap_flash_data n2100_flash_data
= {
157 static struct resource n2100_flash_resource
= {
160 .flags
= IORESOURCE_MEM
,
163 static struct platform_device n2100_flash_device
= {
164 .name
= "physmap-flash",
167 .platform_data
= &n2100_flash_data
,
170 .resource
= &n2100_flash_resource
,
174 static struct plat_serial8250_port n2100_serial_port
[] = {
176 .mapbase
= N2100_UART
,
177 .membase
= (char *)N2100_UART
,
179 .flags
= UPF_SKIP_TEST
,
187 static struct resource n2100_uart_resource
= {
189 .end
= N2100_UART
+ 7,
190 .flags
= IORESOURCE_MEM
,
193 static struct platform_device n2100_serial_device
= {
194 .name
= "serial8250",
195 .id
= PLAT8250_DEV_PLATFORM
,
197 .platform_data
= n2100_serial_port
,
200 .resource
= &n2100_uart_resource
,
203 static struct i2c_board_info __initdata n2100_i2c_devices
[] = {
205 I2C_BOARD_INFO("rtc-rs5c372", 0x32),
211 * Pull PCA9532 GPIO #8 low to power off the machine.
213 static void n2100_power_off(void)
217 /* Start condition, I2C address of PCA9532, write transaction. */
218 *IOP3XX_IDBR0
= 0xc0;
222 /* Write address 0x08. */
223 *IOP3XX_IDBR0
= 0x08;
227 /* Write data 0x01, stop condition. */
228 *IOP3XX_IDBR0
= 0x01;
236 static struct timer_list power_button_poll_timer
;
238 static void power_button_poll(unsigned long dummy
)
240 if (gpio_line_get(N2100_POWER_BUTTON
) == 0) {
245 power_button_poll_timer
.expires
= jiffies
+ (HZ
/ 10);
246 add_timer(&power_button_poll_timer
);
250 static void __init
n2100_init_machine(void)
252 platform_device_register(&iop3xx_i2c0_device
);
253 platform_device_register(&n2100_flash_device
);
254 platform_device_register(&n2100_serial_device
);
255 platform_device_register(&iop3xx_dma_0_channel
);
256 platform_device_register(&iop3xx_dma_1_channel
);
258 i2c_register_board_info(0, n2100_i2c_devices
,
259 ARRAY_SIZE(n2100_i2c_devices
));
261 pm_power_off
= n2100_power_off
;
263 init_timer(&power_button_poll_timer
);
264 power_button_poll_timer
.function
= power_button_poll
;
265 power_button_poll_timer
.expires
= jiffies
+ (HZ
/ 10);
266 add_timer(&power_button_poll_timer
);
269 MACHINE_START(N2100
, "Thecus N2100")
270 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
271 .phys_io
= N2100_UART
,
272 .io_pg_offst
= ((N2100_UART
) >> 18) & 0xfffc,
273 .boot_params
= 0xa0000100,
274 .map_io
= n2100_map_io
,
275 .init_irq
= iop32x_init_irq
,
276 .timer
= &n2100_timer
,
277 .init_machine
= n2100_init_machine
,