blob: 93370a46b620972a66fc810b18dd71132efc426e [file] [log] [blame]
Lennert Buytenhek0c92e832006-09-21 02:46:03 +01001/*
2 * arch/arm/mach-iop32x/glantank.c
3 *
4 * Board support code for the GLAN Tank.
5 *
Martin Michlmayrbd7b8852007-12-27 14:09:07 +01006 * Copyright (C) 2006, 2007 Martin Michlmayr <tbm@cyrius.com>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +01007 * 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>
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +010017#include <linux/f75375s.h>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010018#include <linux/kernel.h>
19#include <linux/pci.h>
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +010020#include <linux/pm.h>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010021#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>
Martin Michlmayrbd7b8852007-12-27 14:09:07 +010026#include <linux/i2c.h>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010027#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010028#include <linux/io.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/hardware.h>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010030#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>
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/time.h>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010038
39/*
40 * GLAN Tank timer tick configuration.
41 */
42static void __init glantank_timer_init(void)
43{
44 /* 33.333 MHz crystal. */
Dan Williams3668b452007-02-13 17:13:34 +010045 iop_init_time(200000000);
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010046}
47
48static struct sys_timer glantank_timer = {
49 .init = glantank_timer_init,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010050};
51
52
53/*
54 * GLAN Tank I/O.
55 */
56static struct map_desc glantank_io_desc[] __initdata = {
57 { /* on-board devices */
58 .virtual = GLANTANK_UART,
59 .pfn = __phys_to_pfn(GLANTANK_UART),
60 .length = 0x00100000,
61 .type = MT_DEVICE
62 },
63};
64
65void __init glantank_map_io(void)
66{
67 iop3xx_map_io();
68 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
69}
70
71
72/*
73 * GLAN Tank PCI.
74 */
75#define INTA IRQ_IOP32X_XINT0
76#define INTB IRQ_IOP32X_XINT1
77#define INTC IRQ_IOP32X_XINT2
78#define INTD IRQ_IOP32X_XINT3
79
Dan Williamsd73d8012007-05-15 01:03:36 +010080static int __init
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010081glantank_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
82{
83 static int pci_irq_table[][4] = {
84 /*
85 * PCI IDSEL/INTPIN->INTLINE
86 * A B C D
87 */
88 {INTD, INTD, INTD, INTD}, /* UART (8250) */
89 {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
90 {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
91 {INTC, INTC, INTC, INTC}, /* USB (NEC) */
92 };
93
94 BUG_ON(pin < 1 || pin > 4);
95
96 return pci_irq_table[slot % 4][pin - 1];
97}
98
99static struct hw_pci glantank_pci __initdata = {
100 .swizzle = pci_std_swizzle,
101 .nr_controllers = 1,
102 .setup = iop3xx_pci_setup,
103 .preinit = iop3xx_pci_preinit,
104 .scan = iop3xx_pci_scan_bus,
105 .map_irq = glantank_pci_map_irq,
106};
107
108static int __init glantank_pci_init(void)
109{
110 if (machine_is_glantank())
111 pci_common_init(&glantank_pci);
112
113 return 0;
114}
115
116subsys_initcall(glantank_pci_init);
117
118
119/*
120 * GLAN Tank machine initialization.
121 */
122static struct physmap_flash_data glantank_flash_data = {
Gordon Farquharsonb696b6b2008-01-26 08:35:44 +0100123 .width = 2,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100124};
125
126static struct resource glantank_flash_resource = {
127 .start = 0xf0000000,
128 .end = 0xf007ffff,
129 .flags = IORESOURCE_MEM,
130};
131
132static struct platform_device glantank_flash_device = {
133 .name = "physmap-flash",
134 .id = 0,
135 .dev = {
136 .platform_data = &glantank_flash_data,
137 },
138 .num_resources = 1,
139 .resource = &glantank_flash_resource,
140};
141
142static struct plat_serial8250_port glantank_serial_port[] = {
143 {
144 .mapbase = GLANTANK_UART,
145 .membase = (char *)GLANTANK_UART,
146 .irq = IRQ_IOP32X_XINT3,
147 .flags = UPF_SKIP_TEST,
148 .iotype = UPIO_MEM,
149 .regshift = 0,
150 .uartclk = 1843200,
151 },
152 { },
153};
154
155static struct resource glantank_uart_resource = {
156 .start = GLANTANK_UART,
157 .end = GLANTANK_UART + 7,
158 .flags = IORESOURCE_MEM,
159};
160
161static struct platform_device glantank_serial_device = {
162 .name = "serial8250",
163 .id = PLAT8250_DEV_PLATFORM,
164 .dev = {
165 .platform_data = glantank_serial_port,
166 },
167 .num_resources = 1,
168 .resource = &glantank_uart_resource,
169};
170
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100171static struct f75375s_platform_data glantank_f75375s = {
172 .pwm = { 255, 255 },
173 .pwm_enable = { 0, 0 },
174};
175
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100176static struct i2c_board_info __initdata glantank_i2c_devices[] = {
177 {
Jean Delvare3760f732008-04-29 23:11:40 +0200178 I2C_BOARD_INFO("rs5c372a", 0x32),
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100179 },
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100180 {
181 I2C_BOARD_INFO("f75375", 0x2e),
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100182 .platform_data = &glantank_f75375s,
183 },
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100184};
185
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100186static void glantank_power_off(void)
187{
188 __raw_writeb(0x01, 0xfe8d0004);
189
190 while (1)
191 ;
192}
193
194static void __init glantank_init_machine(void)
195{
196 platform_device_register(&iop3xx_i2c0_device);
197 platform_device_register(&iop3xx_i2c1_device);
198 platform_device_register(&glantank_flash_device);
199 platform_device_register(&glantank_serial_device);
Dan Williams2492c842007-01-02 13:52:31 -0700200 platform_device_register(&iop3xx_dma_0_channel);
201 platform_device_register(&iop3xx_dma_1_channel);
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100202
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100203 i2c_register_board_info(0, glantank_i2c_devices,
204 ARRAY_SIZE(glantank_i2c_devices));
205
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100206 pm_power_off = glantank_power_off;
207}
208
209MACHINE_START(GLANTANK, "GLAN Tank")
210 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
211 .phys_io = GLANTANK_UART,
212 .io_pg_offst = ((GLANTANK_UART) >> 18) & 0xfffc,
213 .boot_params = 0xa0000100,
214 .map_io = glantank_map_io,
215 .init_irq = iop32x_init_irq,
216 .timer = &glantank_timer,
217 .init_machine = glantank_init_machine,
218MACHINE_END