blob: 0edc880205778a22eabc6850a37a4770a7e46a54 [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>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010022#include <linux/serial_core.h>
23#include <linux/serial_8250.h>
24#include <linux/mtd/physmap.h>
Martin Michlmayrbd7b8852007-12-27 14:09:07 +010025#include <linux/i2c.h>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010026#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010027#include <linux/io.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/hardware.h>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010029#include <asm/irq.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/pci.h>
33#include <asm/mach/time.h>
34#include <asm/mach-types.h>
35#include <asm/page.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010036#include <mach/time.h>
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010037
38/*
39 * GLAN Tank timer tick configuration.
40 */
41static void __init glantank_timer_init(void)
42{
43 /* 33.333 MHz crystal. */
Dan Williams3668b452007-02-13 17:13:34 +010044 iop_init_time(200000000);
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010045}
46
47static struct sys_timer glantank_timer = {
48 .init = glantank_timer_init,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010049};
50
51
52/*
53 * GLAN Tank I/O.
54 */
55static struct map_desc glantank_io_desc[] __initdata = {
56 { /* on-board devices */
57 .virtual = GLANTANK_UART,
58 .pfn = __phys_to_pfn(GLANTANK_UART),
59 .length = 0x00100000,
60 .type = MT_DEVICE
61 },
62};
63
64void __init glantank_map_io(void)
65{
66 iop3xx_map_io();
67 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
68}
69
70
71/*
72 * GLAN Tank PCI.
73 */
74#define INTA IRQ_IOP32X_XINT0
75#define INTB IRQ_IOP32X_XINT1
76#define INTC IRQ_IOP32X_XINT2
77#define INTD IRQ_IOP32X_XINT3
78
Dan Williamsd73d8012007-05-15 01:03:36 +010079static int __init
Ralf Baechled5341942011-06-10 15:30:21 +010080glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010081{
82 static int pci_irq_table[][4] = {
83 /*
84 * PCI IDSEL/INTPIN->INTLINE
85 * A B C D
86 */
87 {INTD, INTD, INTD, INTD}, /* UART (8250) */
88 {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
89 {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
90 {INTC, INTC, INTC, INTC}, /* USB (NEC) */
91 };
92
93 BUG_ON(pin < 1 || pin > 4);
94
95 return pci_irq_table[slot % 4][pin - 1];
96}
97
98static struct hw_pci glantank_pci __initdata = {
99 .swizzle = pci_std_swizzle,
100 .nr_controllers = 1,
101 .setup = iop3xx_pci_setup,
102 .preinit = iop3xx_pci_preinit,
103 .scan = iop3xx_pci_scan_bus,
104 .map_irq = glantank_pci_map_irq,
105};
106
107static int __init glantank_pci_init(void)
108{
109 if (machine_is_glantank())
110 pci_common_init(&glantank_pci);
111
112 return 0;
113}
114
115subsys_initcall(glantank_pci_init);
116
117
118/*
119 * GLAN Tank machine initialization.
120 */
121static struct physmap_flash_data glantank_flash_data = {
Gordon Farquharsonb696b6b2008-01-26 08:35:44 +0100122 .width = 2,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100123};
124
125static struct resource glantank_flash_resource = {
126 .start = 0xf0000000,
127 .end = 0xf007ffff,
128 .flags = IORESOURCE_MEM,
129};
130
131static struct platform_device glantank_flash_device = {
132 .name = "physmap-flash",
133 .id = 0,
134 .dev = {
135 .platform_data = &glantank_flash_data,
136 },
137 .num_resources = 1,
138 .resource = &glantank_flash_resource,
139};
140
141static struct plat_serial8250_port glantank_serial_port[] = {
142 {
143 .mapbase = GLANTANK_UART,
144 .membase = (char *)GLANTANK_UART,
145 .irq = IRQ_IOP32X_XINT3,
146 .flags = UPF_SKIP_TEST,
147 .iotype = UPIO_MEM,
148 .regshift = 0,
149 .uartclk = 1843200,
150 },
151 { },
152};
153
154static struct resource glantank_uart_resource = {
155 .start = GLANTANK_UART,
156 .end = GLANTANK_UART + 7,
157 .flags = IORESOURCE_MEM,
158};
159
160static struct platform_device glantank_serial_device = {
161 .name = "serial8250",
162 .id = PLAT8250_DEV_PLATFORM,
163 .dev = {
164 .platform_data = glantank_serial_port,
165 },
166 .num_resources = 1,
167 .resource = &glantank_uart_resource,
168};
169
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100170static struct f75375s_platform_data glantank_f75375s = {
171 .pwm = { 255, 255 },
172 .pwm_enable = { 0, 0 },
173};
174
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100175static struct i2c_board_info __initdata glantank_i2c_devices[] = {
176 {
Jean Delvare3760f732008-04-29 23:11:40 +0200177 I2C_BOARD_INFO("rs5c372a", 0x32),
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100178 },
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100179 {
180 I2C_BOARD_INFO("f75375", 0x2e),
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100181 .platform_data = &glantank_f75375s,
182 },
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100183};
184
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100185static void glantank_power_off(void)
186{
187 __raw_writeb(0x01, 0xfe8d0004);
188
189 while (1)
190 ;
191}
192
193static void __init glantank_init_machine(void)
194{
195 platform_device_register(&iop3xx_i2c0_device);
196 platform_device_register(&iop3xx_i2c1_device);
197 platform_device_register(&glantank_flash_device);
198 platform_device_register(&glantank_serial_device);
Dan Williams2492c842007-01-02 13:52:31 -0700199 platform_device_register(&iop3xx_dma_0_channel);
200 platform_device_register(&iop3xx_dma_1_channel);
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100201
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100202 i2c_register_board_info(0, glantank_i2c_devices,
203 ARRAY_SIZE(glantank_i2c_devices));
204
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100205 pm_power_off = glantank_power_off;
206}
207
208MACHINE_START(GLANTANK, "GLAN Tank")
209 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Nicolas Pitre18967462011-07-05 22:38:12 -0400210 .atag_offset = 0x100,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100211 .map_io = glantank_map_io,
212 .init_irq = iop32x_init_irq,
213 .timer = &glantank_timer,
214 .init_machine = glantank_init_machine,
215MACHINE_END