2 * board-og.c -- support for the OpenGear KS8695 based boards.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 #include <linux/kernel.h>
10 #include <linux/types.h>
11 #include <linux/interrupt.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/platform_device.h>
15 #include <linux/serial_8250.h>
16 #include <linux/gpio.h>
17 #include <linux/irq.h>
18 #include <asm/mach-types.h>
19 #include <asm/mach/arch.h>
20 #include <asm/mach/map.h>
21 #include <mach/devices.h>
22 #include <mach/regs-gpio.h>
23 #include <mach/gpio-ks8695.h>
26 static int og_pci_map_irq(const struct pci_dev
*dev
, u8 slot
, u8 pin
)
28 if (machine_is_im4004() && (slot
== 8))
29 return KS8695_IRQ_EXTERN1
;
30 return KS8695_IRQ_EXTERN0
;
33 static struct ks8695_pci_cfg __initdata og_pci
= {
34 .mode
= KS8695_MODE_PCI
,
35 .map_irq
= og_pci_map_irq
,
38 static void __init
og_register_pci(void)
40 /* Initialize the GPIO lines for interrupt mode */
41 ks8695_gpio_interrupt(KS8695_GPIO_0
, IRQ_TYPE_LEVEL_LOW
);
44 if (machine_is_im4004())
45 ks8695_gpio_interrupt(KS8695_GPIO_1
, IRQ_TYPE_LEVEL_LOW
);
47 ks8695_init_pci(&og_pci
);
51 * The PCI bus reset is driven by a dedicated GPIO line. Toggle it here
52 * and bring the PCI bus out of reset.
54 static void __init
og_pci_bus_reset(void)
56 unsigned int rstline
= 1;
58 /* Some boards use a different GPIO as the PCI reset line */
59 if (machine_is_im4004())
61 else if (machine_is_im42xx())
64 gpio_request(rstline
, "PCI reset");
65 gpio_direction_output(rstline
, 0);
67 /* Drive a reset on the PCI reset line */
68 gpio_set_value(rstline
, 1);
69 gpio_set_value(rstline
, 0);
71 gpio_set_value(rstline
, 1);
76 * Direct connect serial ports (non-PCI that is).
78 #define S8250_PHYS 0x03800000
79 #define S8250_VIRT 0xf4000000
80 #define S8250_SIZE 0x00100000
82 static struct __initdata map_desc og_io_desc
[] = {
84 .virtual = S8250_VIRT
,
85 .pfn
= __phys_to_pfn(S8250_PHYS
),
91 static struct resource og_uart_resources
[] = {
94 .end
= S8250_VIRT
+ S8250_SIZE
,
95 .flags
= IORESOURCE_MEM
99 static struct plat_serial8250_port og_uart_data
[] = {
101 .mapbase
= S8250_VIRT
,
102 .membase
= (char *) S8250_VIRT
,
104 .flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
,
107 .uartclk
= 115200 * 16,
112 static struct platform_device og_uart
= {
113 .name
= "serial8250",
115 .dev
.platform_data
= og_uart_data
,
117 .resource
= og_uart_resources
120 static struct platform_device
*og_devices
[] __initdata
= {
124 static void __init
og_init(void)
126 ks8695_register_gpios();
128 if (machine_is_cm4002()) {
129 ks8695_gpio_interrupt(KS8695_GPIO_1
, IRQ_TYPE_LEVEL_HIGH
);
130 iotable_init(og_io_desc
, ARRAY_SIZE(og_io_desc
));
131 platform_add_devices(og_devices
, ARRAY_SIZE(og_devices
));
137 ks8695_add_device_lan();
138 ks8695_add_device_wan();
141 #ifdef CONFIG_MACH_CM4002
142 MACHINE_START(CM4002
, "OpenGear/CM4002")
144 .atag_offset
= 0x100,
145 .map_io
= ks8695_map_io
,
146 .init_irq
= ks8695_init_irq
,
147 .init_machine
= og_init
,
148 .init_time
= ks8695_timer_init
,
149 .restart
= ks8695_restart
,
153 #ifdef CONFIG_MACH_CM4008
154 MACHINE_START(CM4008
, "OpenGear/CM4008")
156 .atag_offset
= 0x100,
157 .map_io
= ks8695_map_io
,
158 .init_irq
= ks8695_init_irq
,
159 .init_machine
= og_init
,
160 .init_time
= ks8695_timer_init
,
161 .restart
= ks8695_restart
,
165 #ifdef CONFIG_MACH_CM41xx
166 MACHINE_START(CM41XX
, "OpenGear/CM41xx")
168 .atag_offset
= 0x100,
169 .map_io
= ks8695_map_io
,
170 .init_irq
= ks8695_init_irq
,
171 .init_machine
= og_init
,
172 .init_time
= ks8695_timer_init
,
173 .restart
= ks8695_restart
,
177 #ifdef CONFIG_MACH_IM4004
178 MACHINE_START(IM4004
, "OpenGear/IM4004")
180 .atag_offset
= 0x100,
181 .map_io
= ks8695_map_io
,
182 .init_irq
= ks8695_init_irq
,
183 .init_machine
= og_init
,
184 .init_time
= ks8695_timer_init
,
185 .restart
= ks8695_restart
,
189 #ifdef CONFIG_MACH_IM42xx
190 MACHINE_START(IM42XX
, "OpenGear/IM42xx")
192 .atag_offset
= 0x100,
193 .map_io
= ks8695_map_io
,
194 .init_irq
= ks8695_init_irq
,
195 .init_machine
= og_init
,
196 .init_time
= ks8695_timer_init
,
197 .restart
= ks8695_restart
,