Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy...
[linux-2.6-block.git] / arch / arm / mach-iop32x / glantank.c
CommitLineData
0c92e830
LB
1/*
2 * arch/arm/mach-iop32x/glantank.c
3 *
4 * Board support code for the GLAN Tank.
5 *
bd7b8858 6 * Copyright (C) 2006, 2007 Martin Michlmayr <tbm@cyrius.com>
0c92e830
LB
7 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
8 *
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.
13 */
14
15#include <linux/mm.h>
16#include <linux/init.h>
4e7ffb6a 17#include <linux/f75375s.h>
0c92e830
LB
18#include <linux/kernel.h>
19#include <linux/pci.h>
4e7ffb6a 20#include <linux/pm.h>
0c92e830
LB
21#include <linux/string.h>
22#include <linux/slab.h>
23#include <linux/serial_core.h>
24#include <linux/serial_8250.h>
25#include <linux/mtd/physmap.h>
bd7b8858 26#include <linux/i2c.h>
0c92e830
LB
27#include <linux/platform_device.h>
28#include <asm/hardware.h>
29#include <asm/io.h>
30#include <asm/irq.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33#include <asm/mach/pci.h>
34#include <asm/mach/time.h>
35#include <asm/mach-types.h>
36#include <asm/page.h>
3668b45d 37#include <asm/arch/time.h>
0c92e830
LB
38
39/*
40 * GLAN Tank timer tick configuration.
41 */
42static void __init glantank_timer_init(void)
43{
44 /* 33.333 MHz crystal. */
3668b45d 45 iop_init_time(200000000);
0c92e830
LB
46}
47
48static struct sys_timer glantank_timer = {
49 .init = glantank_timer_init,
3668b45d 50 .offset = iop_gettimeoffset,
0c92e830
LB
51};
52
53
54/*
55 * GLAN Tank I/O.
56 */
57static struct map_desc glantank_io_desc[] __initdata = {
58 { /* on-board devices */
59 .virtual = GLANTANK_UART,
60 .pfn = __phys_to_pfn(GLANTANK_UART),
61 .length = 0x00100000,
62 .type = MT_DEVICE
63 },
64};
65
66void __init glantank_map_io(void)
67{
68 iop3xx_map_io();
69 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
70}
71
72
73/*
74 * GLAN Tank PCI.
75 */
76#define INTA IRQ_IOP32X_XINT0
77#define INTB IRQ_IOP32X_XINT1
78#define INTC IRQ_IOP32X_XINT2
79#define INTD IRQ_IOP32X_XINT3
80
d73d8011 81static int __init
0c92e830
LB
82glantank_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
83{
84 static int pci_irq_table[][4] = {
85 /*
86 * PCI IDSEL/INTPIN->INTLINE
87 * A B C D
88 */
89 {INTD, INTD, INTD, INTD}, /* UART (8250) */
90 {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
91 {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
92 {INTC, INTC, INTC, INTC}, /* USB (NEC) */
93 };
94
95 BUG_ON(pin < 1 || pin > 4);
96
97 return pci_irq_table[slot % 4][pin - 1];
98}
99
100static struct hw_pci glantank_pci __initdata = {
101 .swizzle = pci_std_swizzle,
102 .nr_controllers = 1,
103 .setup = iop3xx_pci_setup,
104 .preinit = iop3xx_pci_preinit,
105 .scan = iop3xx_pci_scan_bus,
106 .map_irq = glantank_pci_map_irq,
107};
108
109static int __init glantank_pci_init(void)
110{
111 if (machine_is_glantank())
112 pci_common_init(&glantank_pci);
113
114 return 0;
115}
116
117subsys_initcall(glantank_pci_init);
118
119
120/*
121 * GLAN Tank machine initialization.
122 */
123static struct physmap_flash_data glantank_flash_data = {
b696b6b4 124 .width = 2,
0c92e830
LB
125};
126
127static struct resource glantank_flash_resource = {
128 .start = 0xf0000000,
129 .end = 0xf007ffff,
130 .flags = IORESOURCE_MEM,
131};
132
133static struct platform_device glantank_flash_device = {
134 .name = "physmap-flash",
135 .id = 0,
136 .dev = {
137 .platform_data = &glantank_flash_data,
138 },
139 .num_resources = 1,
140 .resource = &glantank_flash_resource,
141};
142
143static struct plat_serial8250_port glantank_serial_port[] = {
144 {
145 .mapbase = GLANTANK_UART,
146 .membase = (char *)GLANTANK_UART,
147 .irq = IRQ_IOP32X_XINT3,
148 .flags = UPF_SKIP_TEST,
149 .iotype = UPIO_MEM,
150 .regshift = 0,
151 .uartclk = 1843200,
152 },
153 { },
154};
155
156static struct resource glantank_uart_resource = {
157 .start = GLANTANK_UART,
158 .end = GLANTANK_UART + 7,
159 .flags = IORESOURCE_MEM,
160};
161
162static struct platform_device glantank_serial_device = {
163 .name = "serial8250",
164 .id = PLAT8250_DEV_PLATFORM,
165 .dev = {
166 .platform_data = glantank_serial_port,
167 },
168 .num_resources = 1,
169 .resource = &glantank_uart_resource,
170};
171
4e7ffb6a
GF
172static struct f75375s_platform_data glantank_f75375s = {
173 .pwm = { 255, 255 },
174 .pwm_enable = { 0, 0 },
175};
176
bd7b8858
MM
177static struct i2c_board_info __initdata glantank_i2c_devices[] = {
178 {
179 I2C_BOARD_INFO("rtc-rs5c372", 0x32),
180 .type = "rs5c372a",
181 },
4e7ffb6a
GF
182 {
183 I2C_BOARD_INFO("f75375", 0x2e),
184 .type = "f75375",
185 .platform_data = &glantank_f75375s,
186 },
bd7b8858
MM
187};
188
0c92e830
LB
189static void glantank_power_off(void)
190{
191 __raw_writeb(0x01, 0xfe8d0004);
192
193 while (1)
194 ;
195}
196
197static void __init glantank_init_machine(void)
198{
199 platform_device_register(&iop3xx_i2c0_device);
200 platform_device_register(&iop3xx_i2c1_device);
201 platform_device_register(&glantank_flash_device);
202 platform_device_register(&glantank_serial_device);
2492c845
DW
203 platform_device_register(&iop3xx_dma_0_channel);
204 platform_device_register(&iop3xx_dma_1_channel);
0c92e830 205
bd7b8858
MM
206 i2c_register_board_info(0, glantank_i2c_devices,
207 ARRAY_SIZE(glantank_i2c_devices));
208
0c92e830
LB
209 pm_power_off = glantank_power_off;
210}
211
212MACHINE_START(GLANTANK, "GLAN Tank")
213 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
214 .phys_io = GLANTANK_UART,
215 .io_pg_offst = ((GLANTANK_UART) >> 18) & 0xfffc,
216 .boot_params = 0xa0000100,
217 .map_io = glantank_map_io,
218 .init_irq = iop32x_init_irq,
219 .timer = &glantank_timer,
220 .init_machine = glantank_init_machine,
221MACHINE_END