blob: ac304705fe68956ebae0f85bf2d5c53b2cbf9e37 [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
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010047
48/*
49 * GLAN Tank I/O.
50 */
51static struct map_desc glantank_io_desc[] __initdata = {
52 { /* on-board devices */
53 .virtual = GLANTANK_UART,
54 .pfn = __phys_to_pfn(GLANTANK_UART),
55 .length = 0x00100000,
56 .type = MT_DEVICE
57 },
58};
59
60void __init glantank_map_io(void)
61{
62 iop3xx_map_io();
63 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
64}
65
66
67/*
68 * GLAN Tank PCI.
69 */
70#define INTA IRQ_IOP32X_XINT0
71#define INTB IRQ_IOP32X_XINT1
72#define INTC IRQ_IOP32X_XINT2
73#define INTD IRQ_IOP32X_XINT3
74
Dan Williamsd73d8012007-05-15 01:03:36 +010075static int __init
Ralf Baechled5341942011-06-10 15:30:21 +010076glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010077{
78 static int pci_irq_table[][4] = {
79 /*
80 * PCI IDSEL/INTPIN->INTLINE
81 * A B C D
82 */
83 {INTD, INTD, INTD, INTD}, /* UART (8250) */
84 {INTA, INTA, INTA, INTA}, /* Ethernet (E1000) */
85 {INTB, INTB, INTB, INTB}, /* IDE (AEC6280R) */
86 {INTC, INTC, INTC, INTC}, /* USB (NEC) */
87 };
88
89 BUG_ON(pin < 1 || pin > 4);
90
91 return pci_irq_table[slot % 4][pin - 1];
92}
93
94static struct hw_pci glantank_pci __initdata = {
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010095 .nr_controllers = 1,
Russell Kingc23bfc32012-03-10 12:49:16 +000096 .ops = &iop3xx_ops,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010097 .setup = iop3xx_pci_setup,
98 .preinit = iop3xx_pci_preinit,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010099 .map_irq = glantank_pci_map_irq,
100};
101
102static int __init glantank_pci_init(void)
103{
104 if (machine_is_glantank())
105 pci_common_init(&glantank_pci);
106
107 return 0;
108}
109
110subsys_initcall(glantank_pci_init);
111
112
113/*
114 * GLAN Tank machine initialization.
115 */
116static struct physmap_flash_data glantank_flash_data = {
Gordon Farquharsonb696b6b2008-01-26 08:35:44 +0100117 .width = 2,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100118};
119
120static struct resource glantank_flash_resource = {
121 .start = 0xf0000000,
122 .end = 0xf007ffff,
123 .flags = IORESOURCE_MEM,
124};
125
126static struct platform_device glantank_flash_device = {
127 .name = "physmap-flash",
128 .id = 0,
129 .dev = {
130 .platform_data = &glantank_flash_data,
131 },
132 .num_resources = 1,
133 .resource = &glantank_flash_resource,
134};
135
136static struct plat_serial8250_port glantank_serial_port[] = {
137 {
138 .mapbase = GLANTANK_UART,
139 .membase = (char *)GLANTANK_UART,
140 .irq = IRQ_IOP32X_XINT3,
141 .flags = UPF_SKIP_TEST,
142 .iotype = UPIO_MEM,
143 .regshift = 0,
144 .uartclk = 1843200,
145 },
146 { },
147};
148
149static struct resource glantank_uart_resource = {
150 .start = GLANTANK_UART,
151 .end = GLANTANK_UART + 7,
152 .flags = IORESOURCE_MEM,
153};
154
155static struct platform_device glantank_serial_device = {
156 .name = "serial8250",
157 .id = PLAT8250_DEV_PLATFORM,
158 .dev = {
159 .platform_data = glantank_serial_port,
160 },
161 .num_resources = 1,
162 .resource = &glantank_uart_resource,
163};
164
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100165static struct f75375s_platform_data glantank_f75375s = {
166 .pwm = { 255, 255 },
167 .pwm_enable = { 0, 0 },
168};
169
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100170static struct i2c_board_info __initdata glantank_i2c_devices[] = {
171 {
Jean Delvare3760f732008-04-29 23:11:40 +0200172 I2C_BOARD_INFO("rs5c372a", 0x32),
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100173 },
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100174 {
175 I2C_BOARD_INFO("f75375", 0x2e),
Gordon Farquharson4e7ffb62008-03-14 04:07:46 +0100176 .platform_data = &glantank_f75375s,
177 },
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100178};
179
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100180static void glantank_power_off(void)
181{
Arnd Bergmann3c65c6b2012-09-14 20:19:04 +0000182 __raw_writeb(0x01, IOMEM(0xfe8d0004));
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100183
184 while (1)
185 ;
186}
187
188static void __init glantank_init_machine(void)
189{
190 platform_device_register(&iop3xx_i2c0_device);
191 platform_device_register(&iop3xx_i2c1_device);
192 platform_device_register(&glantank_flash_device);
193 platform_device_register(&glantank_serial_device);
Dan Williams2492c842007-01-02 13:52:31 -0700194 platform_device_register(&iop3xx_dma_0_channel);
195 platform_device_register(&iop3xx_dma_1_channel);
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100196
Martin Michlmayrbd7b8852007-12-27 14:09:07 +0100197 i2c_register_board_info(0, glantank_i2c_devices,
198 ARRAY_SIZE(glantank_i2c_devices));
199
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100200 pm_power_off = glantank_power_off;
201}
202
203MACHINE_START(GLANTANK, "GLAN Tank")
204 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
Nicolas Pitre18967462011-07-05 22:38:12 -0400205 .atag_offset = 0x100,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100206 .map_io = glantank_map_io,
207 .init_irq = iop32x_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700208 .init_time = glantank_timer_init,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100209 .init_machine = glantank_init_machine,
Russell Kingbec92b12011-11-05 11:26:32 +0000210 .restart = iop3xx_restart,
Lennert Buytenhek0c92e832006-09-21 02:46:03 +0100211MACHINE_END