[ARM] 4187/1: iop: unify time implementation across iop32x, iop33x, and iop13xx
[firewire-audio.git] / arch / arm / mach-iop32x / glantank.c
blob45f4f13ae11bc38d4634cd265e2d8a14435c1562
1 /*
2 * arch/arm/mach-iop32x/glantank.c
4 * Board support code for the GLAN Tank.
6 * Copyright (C) 2006 Martin Michlmayr <tbm@cyrius.com>
7 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
15 #include <linux/mm.h>
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/pci.h>
19 #include <linux/string.h>
20 #include <linux/slab.h>
21 #include <linux/serial_core.h>
22 #include <linux/serial_8250.h>
23 #include <linux/mtd/physmap.h>
24 #include <linux/platform_device.h>
25 #include <asm/hardware.h>
26 #include <asm/io.h>
27 #include <asm/irq.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/pci.h>
31 #include <asm/mach/time.h>
32 #include <asm/mach-types.h>
33 #include <asm/page.h>
34 #include <asm/arch/time.h>
37 * GLAN Tank timer tick configuration.
39 static void __init glantank_timer_init(void)
41 /* 33.333 MHz crystal. */
42 iop_init_time(200000000);
45 static struct sys_timer glantank_timer = {
46 .init = glantank_timer_init,
47 .offset = iop_gettimeoffset,
52 * GLAN Tank I/O.
54 static struct map_desc glantank_io_desc[] __initdata = {
55 { /* on-board devices */
56 .virtual = GLANTANK_UART,
57 .pfn = __phys_to_pfn(GLANTANK_UART),
58 .length = 0x00100000,
59 .type = MT_DEVICE
63 void __init glantank_map_io(void)
65 iop3xx_map_io();
66 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
71 * GLAN Tank PCI.
73 #define INTA IRQ_IOP32X_XINT0
74 #define INTB IRQ_IOP32X_XINT1
75 #define INTC IRQ_IOP32X_XINT2
76 #define INTD IRQ_IOP32X_XINT3
78 static inline int __init
79 glantank_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
81 static int pci_irq_table[][4] = {
83 * PCI IDSEL/INTPIN->INTLINE
84 * A B C D
86 {INTD, INTD, INTD, INTD}, /* UART (8250) */
87 {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
88 {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
89 {INTC, INTC, INTC, INTC}, /* USB (NEC) */
92 BUG_ON(pin < 1 || pin > 4);
94 return pci_irq_table[slot % 4][pin - 1];
97 static struct hw_pci glantank_pci __initdata = {
98 .swizzle = pci_std_swizzle,
99 .nr_controllers = 1,
100 .setup = iop3xx_pci_setup,
101 .preinit = iop3xx_pci_preinit,
102 .scan = iop3xx_pci_scan_bus,
103 .map_irq = glantank_pci_map_irq,
106 static int __init glantank_pci_init(void)
108 if (machine_is_glantank())
109 pci_common_init(&glantank_pci);
111 return 0;
114 subsys_initcall(glantank_pci_init);
118 * GLAN Tank machine initialization.
120 static struct physmap_flash_data glantank_flash_data = {
121 .width = 1,
124 static struct resource glantank_flash_resource = {
125 .start = 0xf0000000,
126 .end = 0xf007ffff,
127 .flags = IORESOURCE_MEM,
130 static struct platform_device glantank_flash_device = {
131 .name = "physmap-flash",
132 .id = 0,
133 .dev = {
134 .platform_data = &glantank_flash_data,
136 .num_resources = 1,
137 .resource = &glantank_flash_resource,
140 static struct plat_serial8250_port glantank_serial_port[] = {
142 .mapbase = GLANTANK_UART,
143 .membase = (char *)GLANTANK_UART,
144 .irq = IRQ_IOP32X_XINT3,
145 .flags = UPF_SKIP_TEST,
146 .iotype = UPIO_MEM,
147 .regshift = 0,
148 .uartclk = 1843200,
150 { },
153 static struct resource glantank_uart_resource = {
154 .start = GLANTANK_UART,
155 .end = GLANTANK_UART + 7,
156 .flags = IORESOURCE_MEM,
159 static struct platform_device glantank_serial_device = {
160 .name = "serial8250",
161 .id = PLAT8250_DEV_PLATFORM,
162 .dev = {
163 .platform_data = glantank_serial_port,
165 .num_resources = 1,
166 .resource = &glantank_uart_resource,
169 static void glantank_power_off(void)
171 __raw_writeb(0x01, 0xfe8d0004);
173 while (1)
177 static void __init glantank_init_machine(void)
179 platform_device_register(&iop3xx_i2c0_device);
180 platform_device_register(&iop3xx_i2c1_device);
181 platform_device_register(&glantank_flash_device);
182 platform_device_register(&glantank_serial_device);
184 pm_power_off = glantank_power_off;
187 MACHINE_START(GLANTANK, "GLAN Tank")
188 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
189 .phys_io = GLANTANK_UART,
190 .io_pg_offst = ((GLANTANK_UART) >> 18) & 0xfffc,
191 .boot_params = 0xa0000100,
192 .map_io = glantank_map_io,
193 .init_irq = iop32x_init_irq,
194 .timer = &glantank_timer,
195 .init_machine = glantank_init_machine,
196 MACHINE_END