Commit | Line | Data |
---|---|---|
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 | 21 | #include <linux/string.h> |
0c92e830 LB |
22 | #include <linux/serial_core.h> |
23 | #include <linux/serial_8250.h> | |
24 | #include <linux/mtd/physmap.h> | |
bd7b8858 | 25 | #include <linux/i2c.h> |
0c92e830 | 26 | #include <linux/platform_device.h> |
fced80c7 | 27 | #include <linux/io.h> |
a09e64fb | 28 | #include <mach/hardware.h> |
0c92e830 LB |
29 | #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> | |
a09e64fb | 36 | #include <mach/time.h> |
0c92e830 LB |
37 | |
38 | /* | |
39 | * GLAN Tank timer tick configuration. | |
40 | */ | |
41 | static void __init glantank_timer_init(void) | |
42 | { | |
43 | /* 33.333 MHz crystal. */ | |
3668b45d | 44 | iop_init_time(200000000); |
0c92e830 LB |
45 | } |
46 | ||
47 | static struct sys_timer glantank_timer = { | |
48 | .init = glantank_timer_init, | |
0c92e830 LB |
49 | }; |
50 | ||
51 | ||
52 | /* | |
53 | * GLAN Tank I/O. | |
54 | */ | |
55 | static 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 | ||
64 | void __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 | ||
d73d8011 | 79 | static int __init |
d5341942 | 80 | glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
0c92e830 LB |
81 | { |
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 | ||
98 | static struct hw_pci glantank_pci __initdata = { | |
0c92e830 | 99 | .nr_controllers = 1, |
c23bfc38 | 100 | .ops = &iop3xx_ops, |
0c92e830 LB |
101 | .setup = iop3xx_pci_setup, |
102 | .preinit = iop3xx_pci_preinit, | |
0c92e830 LB |
103 | .map_irq = glantank_pci_map_irq, |
104 | }; | |
105 | ||
106 | static int __init glantank_pci_init(void) | |
107 | { | |
108 | if (machine_is_glantank()) | |
109 | pci_common_init(&glantank_pci); | |
110 | ||
111 | return 0; | |
112 | } | |
113 | ||
114 | subsys_initcall(glantank_pci_init); | |
115 | ||
116 | ||
117 | /* | |
118 | * GLAN Tank machine initialization. | |
119 | */ | |
120 | static struct physmap_flash_data glantank_flash_data = { | |
b696b6b4 | 121 | .width = 2, |
0c92e830 LB |
122 | }; |
123 | ||
124 | static struct resource glantank_flash_resource = { | |
125 | .start = 0xf0000000, | |
126 | .end = 0xf007ffff, | |
127 | .flags = IORESOURCE_MEM, | |
128 | }; | |
129 | ||
130 | static struct platform_device glantank_flash_device = { | |
131 | .name = "physmap-flash", | |
132 | .id = 0, | |
133 | .dev = { | |
134 | .platform_data = &glantank_flash_data, | |
135 | }, | |
136 | .num_resources = 1, | |
137 | .resource = &glantank_flash_resource, | |
138 | }; | |
139 | ||
140 | static struct plat_serial8250_port glantank_serial_port[] = { | |
141 | { | |
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, | |
149 | }, | |
150 | { }, | |
151 | }; | |
152 | ||
153 | static struct resource glantank_uart_resource = { | |
154 | .start = GLANTANK_UART, | |
155 | .end = GLANTANK_UART + 7, | |
156 | .flags = IORESOURCE_MEM, | |
157 | }; | |
158 | ||
159 | static struct platform_device glantank_serial_device = { | |
160 | .name = "serial8250", | |
161 | .id = PLAT8250_DEV_PLATFORM, | |
162 | .dev = { | |
163 | .platform_data = glantank_serial_port, | |
164 | }, | |
165 | .num_resources = 1, | |
166 | .resource = &glantank_uart_resource, | |
167 | }; | |
168 | ||
4e7ffb6a GF |
169 | static struct f75375s_platform_data glantank_f75375s = { |
170 | .pwm = { 255, 255 }, | |
171 | .pwm_enable = { 0, 0 }, | |
172 | }; | |
173 | ||
bd7b8858 MM |
174 | static struct i2c_board_info __initdata glantank_i2c_devices[] = { |
175 | { | |
3760f736 | 176 | I2C_BOARD_INFO("rs5c372a", 0x32), |
bd7b8858 | 177 | }, |
4e7ffb6a GF |
178 | { |
179 | I2C_BOARD_INFO("f75375", 0x2e), | |
4e7ffb6a GF |
180 | .platform_data = &glantank_f75375s, |
181 | }, | |
bd7b8858 MM |
182 | }; |
183 | ||
0c92e830 LB |
184 | static void glantank_power_off(void) |
185 | { | |
3c65c6ba | 186 | __raw_writeb(0x01, IOMEM(0xfe8d0004)); |
0c92e830 LB |
187 | |
188 | while (1) | |
189 | ; | |
190 | } | |
191 | ||
192 | static void __init glantank_init_machine(void) | |
193 | { | |
194 | platform_device_register(&iop3xx_i2c0_device); | |
195 | platform_device_register(&iop3xx_i2c1_device); | |
196 | platform_device_register(&glantank_flash_device); | |
197 | platform_device_register(&glantank_serial_device); | |
2492c845 DW |
198 | platform_device_register(&iop3xx_dma_0_channel); |
199 | platform_device_register(&iop3xx_dma_1_channel); | |
0c92e830 | 200 | |
bd7b8858 MM |
201 | i2c_register_board_info(0, glantank_i2c_devices, |
202 | ARRAY_SIZE(glantank_i2c_devices)); | |
203 | ||
0c92e830 LB |
204 | pm_power_off = glantank_power_off; |
205 | } | |
206 | ||
207 | MACHINE_START(GLANTANK, "GLAN Tank") | |
208 | /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ | |
1896746d | 209 | .atag_offset = 0x100, |
0c92e830 LB |
210 | .map_io = glantank_map_io, |
211 | .init_irq = iop32x_init_irq, | |
212 | .timer = &glantank_timer, | |
213 | .init_machine = glantank_init_machine, | |
bec92b1e | 214 | .restart = iop3xx_restart, |
0c92e830 | 215 | MACHINE_END |