2 * arch/arm/mach-orion/rd88f5182-setup.c
4 * Marvell Orion-NAS Reference Design Setup
6 * Maintainer: Ronen Shitrit <rshitrit@marvell.com>
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/pci.h>
17 #include <linux/irq.h>
18 #include <linux/mtd/physmap.h>
19 #include <linux/mv643xx_eth.h>
20 #include <linux/i2c.h>
21 #include <asm/mach-types.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/pci.h>
26 #include <asm/arch/orion.h>
27 #include <asm/arch/platform.h>
30 /*****************************************************************************
32 ****************************************************************************/
35 * 512K NOR flash Device bus boot chip select
38 #define RD88F5182_NOR_BOOT_BASE 0xf4000000
39 #define RD88F5182_NOR_BOOT_SIZE SZ_512K
42 * 16M NOR flash on Device bus chip select 1
45 #define RD88F5182_NOR_BASE 0xfc000000
46 #define RD88F5182_NOR_SIZE SZ_16M
52 #define RD88F5182_PCI_SLOT0_OFFS 7
53 #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
54 #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
60 #define RD88F5182_GPIO_DBG_LED 0
62 /*****************************************************************************
63 * 16M NOR Flash on Device bus CS1
64 ****************************************************************************/
66 static struct physmap_flash_data rd88f5182_nor_flash_data
= {
70 static struct resource rd88f5182_nor_flash_resource
= {
71 .flags
= IORESOURCE_MEM
,
72 .start
= RD88F5182_NOR_BASE
,
73 .end
= RD88F5182_NOR_BASE
+ RD88F5182_NOR_SIZE
- 1,
76 static struct platform_device rd88f5182_nor_flash
= {
77 .name
= "physmap-flash",
80 .platform_data
= &rd88f5182_nor_flash_data
,
83 .resource
= &rd88f5182_nor_flash_resource
,
88 /*****************************************************************************
89 * Use GPIO debug led as CPU active indication
90 ****************************************************************************/
92 static void rd88f5182_dbgled_event(led_event_t evt
)
96 if (evt
== led_idle_end
)
98 else if (evt
== led_idle_start
)
103 gpio_set_value(RD88F5182_GPIO_DBG_LED
, val
);
106 static int __init
rd88f5182_dbgled_init(void)
110 if (machine_is_rd88f5182()) {
111 pin
= RD88F5182_GPIO_DBG_LED
;
113 if (gpio_request(pin
, "DBGLED") == 0) {
114 if (gpio_direction_output(pin
, 0) != 0) {
115 printk(KERN_ERR
"rd88f5182_dbgled_init failed "
116 "to set output pin %d\n", pin
);
121 printk(KERN_ERR
"rd88f5182_dbgled_init failed "
122 "to request gpio %d\n", pin
);
126 leds_event
= rd88f5182_dbgled_event
;
131 __initcall(rd88f5182_dbgled_init
);
135 /*****************************************************************************
137 ****************************************************************************/
139 void __init
rd88f5182_pci_preinit(void)
144 * Configure PCI GPIO IRQ pins
146 pin
= RD88F5182_PCI_SLOT0_IRQ_A_PIN
;
147 if (gpio_request(pin
, "PCI IntA") == 0) {
148 if (gpio_direction_input(pin
) == 0) {
149 set_irq_type(gpio_to_irq(pin
), IRQT_LOW
);
151 printk(KERN_ERR
"rd88f5182_pci_preinit faield to "
152 "set_irq_type pin %d\n", pin
);
156 printk(KERN_ERR
"rd88f5182_pci_preinit failed to request gpio %d\n", pin
);
159 pin
= RD88F5182_PCI_SLOT0_IRQ_B_PIN
;
160 if (gpio_request(pin
, "PCI IntB") == 0) {
161 if (gpio_direction_input(pin
) == 0) {
162 set_irq_type(gpio_to_irq(pin
), IRQT_LOW
);
164 printk(KERN_ERR
"rd88f5182_pci_preinit faield to "
165 "set_irq_type pin %d\n", pin
);
169 printk(KERN_ERR
"rd88f5182_pci_preinit failed to gpio_request %d\n", pin
);
173 static int __init
rd88f5182_pci_map_irq(struct pci_dev
*dev
, u8 slot
, u8 pin
)
176 * PCI-E isn't used on the RD2
178 if (dev
->bus
->number
== orion_pcie_local_bus_nr())
179 return IRQ_ORION_PCIE0_INT
;
182 * PCI IRQs are connected via GPIOs
184 switch (slot
- RD88F5182_PCI_SLOT0_OFFS
) {
187 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN
);
189 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN
);
195 static struct hw_pci rd88f5182_pci __initdata
= {
197 .preinit
= rd88f5182_pci_preinit
,
198 .swizzle
= pci_std_swizzle
,
199 .setup
= orion_pci_sys_setup
,
200 .scan
= orion_pci_sys_scan_bus
,
201 .map_irq
= rd88f5182_pci_map_irq
,
204 static int __init
rd88f5182_pci_init(void)
206 if (machine_is_rd88f5182())
207 pci_common_init(&rd88f5182_pci
);
212 subsys_initcall(rd88f5182_pci_init
);
214 /*****************************************************************************
216 ****************************************************************************/
218 static struct mv643xx_eth_platform_data rd88f5182_eth_data
= {
223 /*****************************************************************************
224 * RTC DS1338 on I2C bus
225 ****************************************************************************/
226 static struct i2c_board_info __initdata rd88f5182_i2c_rtc
= {
227 .driver_name
= "rtc-ds1307",
232 /*****************************************************************************
234 ****************************************************************************/
236 static struct platform_device
*rd88f5182_devices
[] __initdata
= {
237 &rd88f5182_nor_flash
,
240 static void __init
rd88f5182_init(void)
243 * Setup basic Orion functions. Need to be called early.
248 * Setup the CPU address decode windows for our devices
250 orion_setup_cpu_win(ORION_DEV_BOOT
, RD88F5182_NOR_BOOT_BASE
,
251 RD88F5182_NOR_BOOT_SIZE
, -1);
252 orion_setup_cpu_win(ORION_DEV1
, RD88F5182_NOR_BASE
,
253 RD88F5182_NOR_SIZE
, -1);
256 * Open a special address decode windows for the PCIE WA.
258 orion_write(ORION_REGS_BASE
| 0x20074, ORION_PCIE_WA_BASE
);
259 orion_write(ORION_REGS_BASE
| 0x20070, (0x7941 |
260 (((ORION_PCIE_WA_SIZE
>> 16) - 1)) << 16));
263 * Setup Multiplexing Pins --
264 * MPP[0] Debug Led (GPIO - Out)
265 * MPP[1] Debug Led (GPIO - Out)
267 * MPP[3] RTC_Int (GPIO - In)
270 * MPP[6] PCI_intA (GPIO - In)
271 * MPP[7] PCI_intB (GPIO - In)
273 * MPP[12] SATA 0 presence Indication
274 * MPP[13] SATA 1 presence Indication
275 * MPP[14] SATA 0 active Indication
276 * MPP[15] SATA 1 active indication
277 * MPP[16-19] Not used
278 * MPP[20] PCI Clock to MV88F5182
279 * MPP[21] PCI Clock to mini PCI CON11
280 * MPP[22] USB 0 over current indication
281 * MPP[23] USB 1 over current indication
282 * MPP[24] USB 1 over current enable
283 * MPP[25] USB 0 over current enable
286 orion_write(MPP_0_7_CTRL
, 0x00000003);
287 orion_write(MPP_8_15_CTRL
, 0x55550000);
288 orion_write(MPP_16_19_CTRL
, 0x5555);
290 orion_gpio_set_valid_pins(0x000000fb);
292 platform_add_devices(rd88f5182_devices
, ARRAY_SIZE(rd88f5182_devices
));
293 i2c_register_board_info(0, &rd88f5182_i2c_rtc
, 1);
294 orion_eth_init(&rd88f5182_eth_data
);
297 MACHINE_START(RD88F5182
, "Marvell Orion-NAS Reference Design")
298 /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
299 .phys_io
= ORION_REGS_BASE
,
300 .io_pg_offst
= ((ORION_REGS_BASE
) >> 18) & 0xFFFC,
301 .boot_params
= 0x00000100,
302 .init_machine
= rd88f5182_init
,
303 .map_io
= orion_map_io
,
304 .init_irq
= orion_init_irq
,
305 .timer
= &orion_timer
,