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/f75375s.h>
20 #include <linux/leds-pca9532.h>
21 #include <linux/delay.h>
22 #include <linux/kernel.h>
23 #include <linux/pci.h>
25 #include <linux/string.h>
26 #include <linux/slab.h>
27 #include <linux/serial_core.h>
28 #include <linux/serial_8250.h>
29 #include <linux/mtd/physmap.h>
30 #include <linux/i2c.h>
31 #include <linux/platform_device.h>
32 #include <linux/reboot.h>
34 #include <mach/hardware.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/map.h>
38 #include <asm/mach/pci.h>
39 #include <asm/mach/time.h>
40 #include <asm/mach-types.h>
42 #include <asm/pgtable.h>
43 #include <mach/time.h>
46 * N2100 timer tick configuration.
48 static void __init
n2100_timer_init(void)
50 /* 33.000 MHz crystal. */
51 iop_init_time(198000000);
54 static struct sys_timer n2100_timer
= {
55 .init
= n2100_timer_init
,
62 static struct map_desc n2100_io_desc
[] __initdata
= {
63 { /* on-board devices */
64 .virtual = N2100_UART
,
65 .pfn
= __phys_to_pfn(N2100_UART
),
71 void __init
n2100_map_io(void)
74 iotable_init(n2100_io_desc
, ARRAY_SIZE(n2100_io_desc
));
82 n2100_pci_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
86 if (PCI_SLOT(dev
->devfn
) == 1) {
88 irq
= IRQ_IOP32X_XINT0
;
89 } else if (PCI_SLOT(dev
->devfn
) == 2) {
91 irq
= IRQ_IOP32X_XINT3
;
92 } else if (PCI_SLOT(dev
->devfn
) == 3) {
94 irq
= IRQ_IOP32X_XINT2
;
95 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 1) {
97 irq
= IRQ_IOP32X_XINT1
;
98 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 2) {
100 irq
= IRQ_IOP32X_XINT0
;
101 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 3) {
103 irq
= IRQ_IOP32X_XINT2
;
104 } else if (PCI_SLOT(dev
->devfn
) == 5) {
106 irq
= IRQ_IOP32X_XINT3
;
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
));
117 static struct hw_pci n2100_pci __initdata
= {
118 .swizzle
= pci_std_swizzle
,
120 .setup
= iop3xx_pci_setup
,
121 .preinit
= iop3xx_pci_preinit
,
122 .scan
= iop3xx_pci_scan_bus
,
123 .map_irq
= n2100_pci_map_irq
,
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.
131 static void n2100_fixup_r8169(struct pci_dev
*dev
)
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;
138 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK
, PCI_ANY_ID
, n2100_fixup_r8169
);
140 static int __init
n2100_pci_init(void)
142 if (machine_is_n2100())
143 pci_common_init(&n2100_pci
);
148 subsys_initcall(n2100_pci_init
);
152 * N2100 machine initialisation.
154 static struct physmap_flash_data n2100_flash_data
= {
158 static struct resource n2100_flash_resource
= {
161 .flags
= IORESOURCE_MEM
,
164 static struct platform_device n2100_flash_device
= {
165 .name
= "physmap-flash",
168 .platform_data
= &n2100_flash_data
,
171 .resource
= &n2100_flash_resource
,
175 static struct plat_serial8250_port n2100_serial_port
[] = {
177 .mapbase
= N2100_UART
,
178 .membase
= (char *)N2100_UART
,
180 .flags
= UPF_SKIP_TEST
,
188 static struct resource n2100_uart_resource
= {
190 .end
= N2100_UART
+ 7,
191 .flags
= IORESOURCE_MEM
,
194 static struct platform_device n2100_serial_device
= {
195 .name
= "serial8250",
196 .id
= PLAT8250_DEV_PLATFORM
,
198 .platform_data
= n2100_serial_port
,
201 .resource
= &n2100_uart_resource
,
204 static struct f75375s_platform_data n2100_f75375s
= {
206 .pwm_enable
= { 0, 0 },
209 static struct pca9532_platform_data n2100_leds
= {
211 { .name
= "n2100:red:satafail0",
212 .state
= PCA9532_OFF
,
213 .type
= PCA9532_TYPE_LED
,
215 { .name
= "n2100:red:satafail1",
216 .state
= PCA9532_OFF
,
217 .type
= PCA9532_TYPE_LED
,
219 { .name
= "n2100:blue:usb",
220 .state
= PCA9532_OFF
,
221 .type
= PCA9532_TYPE_LED
,
223 { .type
= PCA9532_TYPE_NONE
},
225 { .type
= PCA9532_TYPE_NONE
},
226 { .type
= PCA9532_TYPE_NONE
},
227 { .type
= PCA9532_TYPE_NONE
},
228 { .name
= "n2100:red:usb",
229 .state
= PCA9532_OFF
,
230 .type
= PCA9532_TYPE_LED
,
233 { .type
= PCA9532_TYPE_NONE
}, /* power OFF gpio */
234 { .type
= PCA9532_TYPE_NONE
}, /* reset gpio */
235 { .type
= PCA9532_TYPE_NONE
},
236 { .type
= PCA9532_TYPE_NONE
},
238 { .type
= PCA9532_TYPE_NONE
},
239 { .name
= "n2100:orange:system",
240 .state
= PCA9532_OFF
,
241 .type
= PCA9532_TYPE_LED
,
243 { .name
= "n2100:red:system",
244 .state
= PCA9532_OFF
,
245 .type
= PCA9532_TYPE_LED
,
247 { .name
= "N2100 beeper" ,
248 .state
= PCA9532_OFF
,
249 .type
= PCA9532_TYPE_N2100_BEEP
,
256 static struct i2c_board_info __initdata n2100_i2c_devices
[] = {
258 I2C_BOARD_INFO("rs5c372b", 0x32),
261 I2C_BOARD_INFO("f75375", 0x2e),
262 .platform_data
= &n2100_f75375s
,
265 I2C_BOARD_INFO("pca9532", 0x60),
266 .platform_data
= &n2100_leds
,
271 * Pull PCA9532 GPIO #8 low to power off the machine.
273 static void n2100_power_off(void)
277 /* Start condition, I2C address of PCA9532, write transaction. */
278 *IOP3XX_IDBR0
= 0xc0;
282 /* Write address 0x08. */
283 *IOP3XX_IDBR0
= 0x08;
287 /* Write data 0x01, stop condition. */
288 *IOP3XX_IDBR0
= 0x01;
296 static struct timer_list power_button_poll_timer
;
298 static void power_button_poll(unsigned long dummy
)
300 if (gpio_line_get(N2100_POWER_BUTTON
) == 0) {
305 power_button_poll_timer
.expires
= jiffies
+ (HZ
/ 10);
306 add_timer(&power_button_poll_timer
);
310 static void __init
n2100_init_machine(void)
312 platform_device_register(&iop3xx_i2c0_device
);
313 platform_device_register(&n2100_flash_device
);
314 platform_device_register(&n2100_serial_device
);
315 platform_device_register(&iop3xx_dma_0_channel
);
316 platform_device_register(&iop3xx_dma_1_channel
);
318 i2c_register_board_info(0, n2100_i2c_devices
,
319 ARRAY_SIZE(n2100_i2c_devices
));
321 pm_power_off
= n2100_power_off
;
323 init_timer(&power_button_poll_timer
);
324 power_button_poll_timer
.function
= power_button_poll
;
325 power_button_poll_timer
.expires
= jiffies
+ (HZ
/ 10);
326 add_timer(&power_button_poll_timer
);
329 MACHINE_START(N2100
, "Thecus N2100")
330 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
331 .phys_io
= N2100_UART
,
332 .io_pg_offst
= ((N2100_UART
) >> 18) & 0xfffc,
333 .boot_params
= 0xa0000100,
334 .map_io
= n2100_map_io
,
335 .init_irq
= iop32x_init_irq
,
336 .timer
= &n2100_timer
,
337 .init_machine
= n2100_init_machine
,