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/platform_device.h>
29 #include <linux/reboot.h>
30 #include <asm/hardware.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
35 #include <asm/mach/pci.h>
36 #include <asm/mach/time.h>
37 #include <asm/mach-types.h>
39 #include <asm/pgtable.h>
42 * N2100 timer tick configuration.
44 static void __init
n2100_timer_init(void)
46 /* 33.000 MHz crystal. */
47 iop3xx_init_time(198000000);
50 static struct sys_timer n2100_timer
= {
51 .init
= n2100_timer_init
,
52 .offset
= iop3xx_gettimeoffset
,
59 static struct map_desc n2100_io_desc
[] __initdata
= {
60 { /* on-board devices */
61 .virtual = N2100_UART
,
62 .pfn
= __phys_to_pfn(N2100_UART
),
68 void __init
n2100_map_io(void)
71 iotable_init(n2100_io_desc
, ARRAY_SIZE(n2100_io_desc
));
78 static inline int __init
79 n2100_pci_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
83 if (PCI_SLOT(dev
->devfn
) == 1) {
85 irq
= IRQ_IOP32X_XINT0
;
86 } else if (PCI_SLOT(dev
->devfn
) == 2) {
88 irq
= IRQ_IOP32X_XINT3
;
89 } else if (PCI_SLOT(dev
->devfn
) == 3) {
91 irq
= IRQ_IOP32X_XINT2
;
92 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 1) {
94 irq
= IRQ_IOP32X_XINT1
;
95 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 2) {
97 irq
= IRQ_IOP32X_XINT0
;
98 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 3) {
100 irq
= IRQ_IOP32X_XINT2
;
101 } else if (PCI_SLOT(dev
->devfn
) == 5) {
103 irq
= IRQ_IOP32X_XINT3
;
105 printk(KERN_ERR
"n2100_pci_map_irq() called for unknown "
106 "device PCI:%d:%d:%d\n", dev
->bus
->number
,
107 PCI_SLOT(dev
->devfn
), PCI_FUNC(dev
->devfn
));
114 static struct hw_pci n2100_pci __initdata
= {
115 .swizzle
= pci_std_swizzle
,
117 .setup
= iop3xx_pci_setup
,
118 .preinit
= iop3xx_pci_preinit
,
119 .scan
= iop3xx_pci_scan_bus
,
120 .map_irq
= n2100_pci_map_irq
,
123 static int __init
n2100_pci_init(void)
125 if (machine_is_n2100())
126 pci_common_init(&n2100_pci
);
131 subsys_initcall(n2100_pci_init
);
135 * N2100 machine initialisation.
137 static struct physmap_flash_data n2100_flash_data
= {
141 static struct resource n2100_flash_resource
= {
144 .flags
= IORESOURCE_MEM
,
147 static struct platform_device n2100_flash_device
= {
148 .name
= "physmap-flash",
151 .platform_data
= &n2100_flash_data
,
154 .resource
= &n2100_flash_resource
,
158 static struct plat_serial8250_port n2100_serial_port
[] = {
160 .mapbase
= N2100_UART
,
161 .membase
= (char *)N2100_UART
,
163 .flags
= UPF_SKIP_TEST
,
171 static struct resource n2100_uart_resource
= {
173 .end
= N2100_UART
+ 7,
174 .flags
= IORESOURCE_MEM
,
177 static struct platform_device n2100_serial_device
= {
178 .name
= "serial8250",
179 .id
= PLAT8250_DEV_PLATFORM
,
181 .platform_data
= n2100_serial_port
,
184 .resource
= &n2100_uart_resource
,
189 * Pull PCA9532 GPIO #8 low to power off the machine.
191 static void n2100_power_off(void)
195 /* Start condition, I2C address of PCA9532, write transaction. */
196 *IOP3XX_IDBR0
= 0xc0;
200 /* Write address 0x08. */
201 *IOP3XX_IDBR0
= 0x08;
205 /* Write data 0x01, stop condition. */
206 *IOP3XX_IDBR0
= 0x01;
214 static struct timer_list power_button_poll_timer
;
216 static void power_button_poll(unsigned long dummy
)
218 if (gpio_line_get(N2100_POWER_BUTTON
) == 0) {
223 power_button_poll_timer
.expires
= jiffies
+ (HZ
/ 10);
224 add_timer(&power_button_poll_timer
);
228 static void __init
n2100_init_machine(void)
230 platform_device_register(&iop3xx_i2c0_device
);
231 platform_device_register(&n2100_flash_device
);
232 platform_device_register(&n2100_serial_device
);
234 pm_power_off
= n2100_power_off
;
236 init_timer(&power_button_poll_timer
);
237 power_button_poll_timer
.function
= power_button_poll
;
238 power_button_poll_timer
.expires
= jiffies
+ (HZ
/ 10);
239 add_timer(&power_button_poll_timer
);
242 MACHINE_START(N2100
, "Thecus N2100")
243 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
244 .phys_io
= N2100_UART
,
245 .io_pg_offst
= ((N2100_UART
) >> 18) & 0xfffc,
246 .boot_params
= 0xa0000100,
247 .map_io
= n2100_map_io
,
248 .init_irq
= iop32x_init_irq
,
249 .timer
= &n2100_timer
,
250 .init_machine
= n2100_init_machine
,