1
2
3
4
5
6
7
8
9
10
11#include <linux/mm.h>
12#include <linux/init.h>
13#include <linux/f75375s.h>
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/pm.h>
17#include <linux/string.h>
18#include <linux/serial_core.h>
19#include <linux/serial_8250.h>
20#include <linux/mtd/physmap.h>
21#include <linux/i2c.h>
22#include <linux/platform_device.h>
23#include <linux/io.h>
24#include <linux/gpio/machine.h>
25#include <mach/hardware.h>
26#include <asm/irq.h>
27#include <asm/mach/arch.h>
28#include <asm/mach/map.h>
29#include <asm/mach/pci.h>
30#include <asm/mach/time.h>
31#include <asm/mach-types.h>
32#include <asm/page.h>
33#include <mach/time.h>
34#include "gpio-iop32x.h"
35
36
37
38
39static void __init glantank_timer_init(void)
40{
41
42 iop_init_time(200000000);
43}
44
45
46
47
48
49static struct map_desc glantank_io_desc[] __initdata = {
50 {
51 .virtual = GLANTANK_UART,
52 .pfn = __phys_to_pfn(GLANTANK_UART),
53 .length = 0x00100000,
54 .type = MT_DEVICE
55 },
56};
57
58void __init glantank_map_io(void)
59{
60 iop3xx_map_io();
61 iotable_init(glantank_io_desc, ARRAY_SIZE(glantank_io_desc));
62}
63
64
65
66
67
68#define INTA IRQ_IOP32X_XINT0
69#define INTB IRQ_IOP32X_XINT1
70#define INTC IRQ_IOP32X_XINT2
71#define INTD IRQ_IOP32X_XINT3
72
73static int __init
74glantank_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
75{
76 static int pci_irq_table[][4] = {
77
78
79
80
81 {INTD, INTD, INTD, INTD},
82 {INTA, INTA, INTA, INTA},
83 {INTB, INTB, INTB, INTB},
84 {INTC, INTC, INTC, INTC},
85 };
86
87 BUG_ON(pin < 1 || pin > 4);
88
89 return pci_irq_table[slot % 4][pin - 1];
90}
91
92static struct hw_pci glantank_pci __initdata = {
93 .nr_controllers = 1,
94 .ops = &iop3xx_ops,
95 .setup = iop3xx_pci_setup,
96 .preinit = iop3xx_pci_preinit,
97 .map_irq = glantank_pci_map_irq,
98};
99
100static int __init glantank_pci_init(void)
101{
102 if (machine_is_glantank())
103 pci_common_init(&glantank_pci);
104
105 return 0;
106}
107
108subsys_initcall(glantank_pci_init);
109
110
111
112
113
114static struct physmap_flash_data glantank_flash_data = {
115 .width = 2,
116};
117
118static struct resource glantank_flash_resource = {
119 .start = 0xf0000000,
120 .end = 0xf007ffff,
121 .flags = IORESOURCE_MEM,
122};
123
124static struct platform_device glantank_flash_device = {
125 .name = "physmap-flash",
126 .id = 0,
127 .dev = {
128 .platform_data = &glantank_flash_data,
129 },
130 .num_resources = 1,
131 .resource = &glantank_flash_resource,
132};
133
134static struct plat_serial8250_port glantank_serial_port[] = {
135 {
136 .mapbase = GLANTANK_UART,
137 .membase = (char *)GLANTANK_UART,
138 .irq = IRQ_IOP32X_XINT3,
139 .flags = UPF_SKIP_TEST,
140 .iotype = UPIO_MEM,
141 .regshift = 0,
142 .uartclk = 1843200,
143 },
144 { },
145};
146
147static struct resource glantank_uart_resource = {
148 .start = GLANTANK_UART,
149 .end = GLANTANK_UART + 7,
150 .flags = IORESOURCE_MEM,
151};
152
153static struct platform_device glantank_serial_device = {
154 .name = "serial8250",
155 .id = PLAT8250_DEV_PLATFORM,
156 .dev = {
157 .platform_data = glantank_serial_port,
158 },
159 .num_resources = 1,
160 .resource = &glantank_uart_resource,
161};
162
163static struct f75375s_platform_data glantank_f75375s = {
164 .pwm = { 255, 255 },
165 .pwm_enable = { 0, 0 },
166};
167
168static struct i2c_board_info __initdata glantank_i2c_devices[] = {
169 {
170 I2C_BOARD_INFO("rs5c372a", 0x32),
171 },
172 {
173 I2C_BOARD_INFO("f75375", 0x2e),
174 .platform_data = &glantank_f75375s,
175 },
176};
177
178static void glantank_power_off(void)
179{
180 __raw_writeb(0x01, IOMEM(0xfe8d0004));
181
182 while (1)
183 ;
184}
185
186static void __init glantank_init_machine(void)
187{
188 register_iop32x_gpio();
189 gpiod_add_lookup_table(&iop3xx_i2c0_gpio_lookup);
190 gpiod_add_lookup_table(&iop3xx_i2c1_gpio_lookup);
191 platform_device_register(&iop3xx_i2c0_device);
192 platform_device_register(&iop3xx_i2c1_device);
193 platform_device_register(&glantank_flash_device);
194 platform_device_register(&glantank_serial_device);
195 platform_device_register(&iop3xx_dma_0_channel);
196 platform_device_register(&iop3xx_dma_1_channel);
197
198 i2c_register_board_info(0, glantank_i2c_devices,
199 ARRAY_SIZE(glantank_i2c_devices));
200
201 pm_power_off = glantank_power_off;
202}
203
204MACHINE_START(GLANTANK, "GLAN Tank")
205
206 .atag_offset = 0x100,
207 .map_io = glantank_map_io,
208 .init_irq = iop32x_init_irq,
209 .init_time = glantank_timer_init,
210 .init_machine = glantank_init_machine,
211 .restart = iop3xx_restart,
212MACHINE_END
213