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 <linux/gpio.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>
44 #include "gpio-iop32x.h"
47 * N2100 timer tick configuration.
49 static void __init n2100_timer_init(void)
51 /* 33.000 MHz crystal. */
52 iop_init_time(198000000);
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 int n2100_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
82 if (PCI_SLOT(dev->devfn) == 1) {
84 irq = IRQ_IOP32X_XINT0;
85 } else if (PCI_SLOT(dev->devfn) == 2) {
87 irq = IRQ_IOP32X_XINT3;
88 } else if (PCI_SLOT(dev->devfn) == 3) {
90 irq = IRQ_IOP32X_XINT2;
91 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 1) {
93 irq = IRQ_IOP32X_XINT1;
94 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 2) {
96 irq = IRQ_IOP32X_XINT0;
97 } else if (PCI_SLOT(dev->devfn) == 4 && pin == 3) {
99 irq = IRQ_IOP32X_XINT2;
100 } else if (PCI_SLOT(dev->devfn) == 5) {
102 irq = IRQ_IOP32X_XINT3;
104 printk(KERN_ERR "n2100_pci_map_irq() called for unknown "
105 "device PCI:%d:%d:%d\n", dev->bus->number,
106 PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
113 static struct hw_pci n2100_pci __initdata = {
116 .setup = iop3xx_pci_setup,
117 .preinit = iop3xx_pci_preinit,
118 .map_irq = n2100_pci_map_irq,
122 * Both r8169 chips on the n2100 exhibit PCI parity problems. Set
123 * the ->broken_parity_status flag for both ports so that the r8169
124 * driver knows it should ignore error interrupts.
126 static void n2100_fixup_r8169(struct pci_dev *dev)
128 if (dev->bus->number == 0 &&
129 (dev->devfn == PCI_DEVFN(1, 0) ||
130 dev->devfn == PCI_DEVFN(2, 0)))
131 dev->broken_parity_status = 1;
133 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, PCI_ANY_ID, n2100_fixup_r8169);
135 static int __init n2100_pci_init(void)
137 if (machine_is_n2100())
138 pci_common_init(&n2100_pci);
143 subsys_initcall(n2100_pci_init);
147 * N2100 machine initialisation.
149 static struct physmap_flash_data n2100_flash_data = {
153 static struct resource n2100_flash_resource = {
156 .flags = IORESOURCE_MEM,
159 static struct platform_device n2100_flash_device = {
160 .name = "physmap-flash",
163 .platform_data = &n2100_flash_data,
166 .resource = &n2100_flash_resource,
170 static struct plat_serial8250_port n2100_serial_port[] = {
172 .mapbase = N2100_UART,
173 .membase = (char *)N2100_UART,
175 .flags = UPF_SKIP_TEST | UPF_AUTO_IRQ | UPF_SHARE_IRQ,
183 static struct resource n2100_uart_resource = {
185 .end = N2100_UART + 7,
186 .flags = IORESOURCE_MEM,
189 static struct platform_device n2100_serial_device = {
190 .name = "serial8250",
191 .id = PLAT8250_DEV_PLATFORM,
193 .platform_data = n2100_serial_port,
196 .resource = &n2100_uart_resource,
199 static struct f75375s_platform_data n2100_f75375s = {
201 .pwm_enable = { 0, 0 },
204 static struct pca9532_platform_data n2100_leds = {
206 { .name = "n2100:red:satafail0",
207 .state = PCA9532_OFF,
208 .type = PCA9532_TYPE_LED,
210 { .name = "n2100:red:satafail1",
211 .state = PCA9532_OFF,
212 .type = PCA9532_TYPE_LED,
214 { .name = "n2100:blue:usb",
215 .state = PCA9532_OFF,
216 .type = PCA9532_TYPE_LED,
218 { .type = PCA9532_TYPE_NONE },
220 { .type = PCA9532_TYPE_NONE },
221 { .type = PCA9532_TYPE_NONE },
222 { .type = PCA9532_TYPE_NONE },
223 { .name = "n2100:red:usb",
224 .state = PCA9532_OFF,
225 .type = PCA9532_TYPE_LED,
228 { .type = PCA9532_TYPE_NONE }, /* power OFF gpio */
229 { .type = PCA9532_TYPE_NONE }, /* reset gpio */
230 { .type = PCA9532_TYPE_NONE },
231 { .type = PCA9532_TYPE_NONE },
233 { .type = PCA9532_TYPE_NONE },
234 { .name = "n2100:orange:system",
235 .state = PCA9532_OFF,
236 .type = PCA9532_TYPE_LED,
238 { .name = "n2100:red:system",
239 .state = PCA9532_OFF,
240 .type = PCA9532_TYPE_LED,
242 { .name = "N2100 beeper" ,
243 .state = PCA9532_OFF,
244 .type = PCA9532_TYPE_N2100_BEEP,
251 static struct i2c_board_info __initdata n2100_i2c_devices[] = {
253 I2C_BOARD_INFO("rs5c372b", 0x32),
256 I2C_BOARD_INFO("f75375", 0x2e),
257 .platform_data = &n2100_f75375s,
260 I2C_BOARD_INFO("pca9532", 0x60),
261 .platform_data = &n2100_leds,
266 * Pull PCA9532 GPIO #8 low to power off the machine.
268 static void n2100_power_off(void)
272 /* Start condition, I2C address of PCA9532, write transaction. */
273 *IOP3XX_IDBR0 = 0xc0;
277 /* Write address 0x08. */
278 *IOP3XX_IDBR0 = 0x08;
282 /* Write data 0x01, stop condition. */
283 *IOP3XX_IDBR0 = 0x01;
290 static void n2100_restart(enum reboot_mode mode, const char *cmd)
294 ret = gpio_direction_output(N2100_HARDWARE_RESET, 0);
296 pr_crit("could not drive reset GPIO low\n");
299 /* Wait for reset to happen */
305 static struct timer_list power_button_poll_timer;
307 static void power_button_poll(struct timer_list *unused)
309 if (gpio_get_value(N2100_POWER_BUTTON) == 0) {
314 power_button_poll_timer.expires = jiffies + (HZ / 10);
315 add_timer(&power_button_poll_timer);
318 static int __init n2100_request_gpios(void)
322 if (!machine_is_n2100())
325 ret = gpio_request(N2100_HARDWARE_RESET, "reset");
327 pr_err("could not request reset GPIO\n");
329 ret = gpio_request(N2100_POWER_BUTTON, "power");
331 pr_err("could not request power GPIO\n");
333 ret = gpio_direction_input(N2100_POWER_BUTTON);
335 pr_err("could not set power GPIO as input\n");
337 /* Set up power button poll timer */
338 timer_setup(&power_button_poll_timer, power_button_poll, 0);
339 power_button_poll_timer.expires = jiffies + (HZ / 10);
340 add_timer(&power_button_poll_timer);
343 device_initcall(n2100_request_gpios);
345 static void __init n2100_init_machine(void)
347 register_iop32x_gpio();
348 platform_device_register(&iop3xx_i2c0_device);
349 platform_device_register(&n2100_flash_device);
350 platform_device_register(&n2100_serial_device);
351 platform_device_register(&iop3xx_dma_0_channel);
352 platform_device_register(&iop3xx_dma_1_channel);
354 i2c_register_board_info(0, n2100_i2c_devices,
355 ARRAY_SIZE(n2100_i2c_devices));
357 pm_power_off = n2100_power_off;
360 MACHINE_START(N2100, "Thecus N2100")
361 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
362 .atag_offset = 0x100,
363 .map_io = n2100_map_io,
364 .init_irq = iop32x_init_irq,
365 .init_time = n2100_timer_init,
366 .init_machine = n2100_init_machine,
367 .restart = n2100_restart,