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/serial_core.h>
27 #include <linux/serial_8250.h>
28 #include <linux/mtd/physmap.h>
29 #include <linux/i2c.h>
30 #include <linux/platform_device.h>
31 #include <linux/reboot.h>
33 #include <mach/hardware.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>
41 #include <asm/pgtable.h>
42 #include <mach/time.h>
45 * N2100 timer tick configuration.
47 static void __init
n2100_timer_init(void)
49 /* 33.000 MHz crystal. */
50 iop_init_time(198000000);
57 static struct map_desc n2100_io_desc
[] __initdata
= {
58 { /* on-board devices */
59 .virtual = N2100_UART
,
60 .pfn
= __phys_to_pfn(N2100_UART
),
66 void __init
n2100_map_io(void)
69 iotable_init(n2100_io_desc
, ARRAY_SIZE(n2100_io_desc
));
77 n2100_pci_map_irq(const struct pci_dev
*dev
, u8 slot
, u8 pin
)
81 if (PCI_SLOT(dev
->devfn
) == 1) {
83 irq
= IRQ_IOP32X_XINT0
;
84 } else if (PCI_SLOT(dev
->devfn
) == 2) {
86 irq
= IRQ_IOP32X_XINT3
;
87 } else if (PCI_SLOT(dev
->devfn
) == 3) {
89 irq
= IRQ_IOP32X_XINT2
;
90 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 1) {
92 irq
= IRQ_IOP32X_XINT1
;
93 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 2) {
95 irq
= IRQ_IOP32X_XINT0
;
96 } else if (PCI_SLOT(dev
->devfn
) == 4 && pin
== 3) {
98 irq
= IRQ_IOP32X_XINT2
;
99 } else if (PCI_SLOT(dev
->devfn
) == 5) {
101 irq
= IRQ_IOP32X_XINT3
;
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
));
112 static struct hw_pci n2100_pci __initdata
= {
115 .setup
= iop3xx_pci_setup
,
116 .preinit
= iop3xx_pci_preinit
,
117 .map_irq
= n2100_pci_map_irq
,
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.
125 static void n2100_fixup_r8169(struct pci_dev
*dev
)
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;
132 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK
, PCI_ANY_ID
, n2100_fixup_r8169
);
134 static int __init
n2100_pci_init(void)
136 if (machine_is_n2100())
137 pci_common_init(&n2100_pci
);
142 subsys_initcall(n2100_pci_init
);
146 * N2100 machine initialisation.
148 static struct physmap_flash_data n2100_flash_data
= {
152 static struct resource n2100_flash_resource
= {
155 .flags
= IORESOURCE_MEM
,
158 static struct platform_device n2100_flash_device
= {
159 .name
= "physmap-flash",
162 .platform_data
= &n2100_flash_data
,
165 .resource
= &n2100_flash_resource
,
169 static struct plat_serial8250_port n2100_serial_port
[] = {
171 .mapbase
= N2100_UART
,
172 .membase
= (char *)N2100_UART
,
174 .flags
= UPF_SKIP_TEST
| UPF_AUTO_IRQ
| UPF_SHARE_IRQ
,
182 static struct resource n2100_uart_resource
= {
184 .end
= N2100_UART
+ 7,
185 .flags
= IORESOURCE_MEM
,
188 static struct platform_device n2100_serial_device
= {
189 .name
= "serial8250",
190 .id
= PLAT8250_DEV_PLATFORM
,
192 .platform_data
= n2100_serial_port
,
195 .resource
= &n2100_uart_resource
,
198 static struct f75375s_platform_data n2100_f75375s
= {
200 .pwm_enable
= { 0, 0 },
203 static struct pca9532_platform_data n2100_leds
= {
205 { .name
= "n2100:red:satafail0",
206 .state
= PCA9532_OFF
,
207 .type
= PCA9532_TYPE_LED
,
209 { .name
= "n2100:red:satafail1",
210 .state
= PCA9532_OFF
,
211 .type
= PCA9532_TYPE_LED
,
213 { .name
= "n2100:blue:usb",
214 .state
= PCA9532_OFF
,
215 .type
= PCA9532_TYPE_LED
,
217 { .type
= PCA9532_TYPE_NONE
},
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
,
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
},
232 { .type
= PCA9532_TYPE_NONE
},
233 { .name
= "n2100:orange:system",
234 .state
= PCA9532_OFF
,
235 .type
= PCA9532_TYPE_LED
,
237 { .name
= "n2100:red:system",
238 .state
= PCA9532_OFF
,
239 .type
= PCA9532_TYPE_LED
,
241 { .name
= "N2100 beeper" ,
242 .state
= PCA9532_OFF
,
243 .type
= PCA9532_TYPE_N2100_BEEP
,
250 static struct i2c_board_info __initdata n2100_i2c_devices
[] = {
252 I2C_BOARD_INFO("rs5c372b", 0x32),
255 I2C_BOARD_INFO("f75375", 0x2e),
256 .platform_data
= &n2100_f75375s
,
259 I2C_BOARD_INFO("pca9532", 0x60),
260 .platform_data
= &n2100_leds
,
265 * Pull PCA9532 GPIO #8 low to power off the machine.
267 static void n2100_power_off(void)
271 /* Start condition, I2C address of PCA9532, write transaction. */
272 *IOP3XX_IDBR0
= 0xc0;
276 /* Write address 0x08. */
277 *IOP3XX_IDBR0
= 0x08;
281 /* Write data 0x01, stop condition. */
282 *IOP3XX_IDBR0
= 0x01;
289 static void n2100_restart(char mode
, const char *cmd
)
291 gpio_line_set(N2100_HARDWARE_RESET
, GPIO_LOW
);
292 gpio_line_config(N2100_HARDWARE_RESET
, GPIO_OUT
);
298 static struct timer_list power_button_poll_timer
;
300 static void power_button_poll(unsigned long dummy
)
302 if (gpio_line_get(N2100_POWER_BUTTON
) == 0) {
307 power_button_poll_timer
.expires
= jiffies
+ (HZ
/ 10);
308 add_timer(&power_button_poll_timer
);
312 static void __init
n2100_init_machine(void)
314 platform_device_register(&iop3xx_i2c0_device
);
315 platform_device_register(&n2100_flash_device
);
316 platform_device_register(&n2100_serial_device
);
317 platform_device_register(&iop3xx_dma_0_channel
);
318 platform_device_register(&iop3xx_dma_1_channel
);
320 i2c_register_board_info(0, n2100_i2c_devices
,
321 ARRAY_SIZE(n2100_i2c_devices
));
323 pm_power_off
= n2100_power_off
;
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
);
331 MACHINE_START(N2100
, "Thecus N2100")
332 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
333 .atag_offset
= 0x100,
334 .map_io
= n2100_map_io
,
335 .init_irq
= iop32x_init_irq
,
336 .init_time
= n2100_timer_init
,
337 .init_machine
= n2100_init_machine
,
338 .restart
= n2100_restart
,