2 * arch/arm/mach-orion5x/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/ata_platform.h>
21 #include <linux/i2c.h>
22 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/pci.h>
27 #include <mach/orion5x.h>
31 /*****************************************************************************
33 ****************************************************************************/
36 * 512K NOR flash Device bus boot chip select
39 #define RD88F5182_NOR_BOOT_BASE 0xf4000000
40 #define RD88F5182_NOR_BOOT_SIZE SZ_512K
43 * 16M NOR flash on Device bus chip select 1
46 #define RD88F5182_NOR_BASE 0xfc000000
47 #define RD88F5182_NOR_SIZE SZ_16M
53 #define RD88F5182_PCI_SLOT0_OFFS 7
54 #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
55 #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
61 #define RD88F5182_GPIO_DBG_LED 0
63 /*****************************************************************************
64 * 16M NOR Flash on Device bus CS1
65 ****************************************************************************/
67 static struct physmap_flash_data rd88f5182_nor_flash_data
= {
71 static struct resource rd88f5182_nor_flash_resource
= {
72 .flags
= IORESOURCE_MEM
,
73 .start
= RD88F5182_NOR_BASE
,
74 .end
= RD88F5182_NOR_BASE
+ RD88F5182_NOR_SIZE
- 1,
77 static struct platform_device rd88f5182_nor_flash
= {
78 .name
= "physmap-flash",
81 .platform_data
= &rd88f5182_nor_flash_data
,
84 .resource
= &rd88f5182_nor_flash_resource
,
89 /*****************************************************************************
90 * Use GPIO debug led as CPU active indication
91 ****************************************************************************/
93 static void rd88f5182_dbgled_event(led_event_t evt
)
97 if (evt
== led_idle_end
)
99 else if (evt
== led_idle_start
)
104 gpio_set_value(RD88F5182_GPIO_DBG_LED
, val
);
107 static int __init
rd88f5182_dbgled_init(void)
111 if (machine_is_rd88f5182()) {
112 pin
= RD88F5182_GPIO_DBG_LED
;
114 if (gpio_request(pin
, "DBGLED") == 0) {
115 if (gpio_direction_output(pin
, 0) != 0) {
116 printk(KERN_ERR
"rd88f5182_dbgled_init failed "
117 "to set output pin %d\n", pin
);
122 printk(KERN_ERR
"rd88f5182_dbgled_init failed "
123 "to request gpio %d\n", pin
);
127 leds_event
= rd88f5182_dbgled_event
;
133 __initcall(rd88f5182_dbgled_init
);
137 /*****************************************************************************
139 ****************************************************************************/
141 void __init
rd88f5182_pci_preinit(void)
146 * Configure PCI GPIO IRQ pins
148 pin
= RD88F5182_PCI_SLOT0_IRQ_A_PIN
;
149 if (gpio_request(pin
, "PCI IntA") == 0) {
150 if (gpio_direction_input(pin
) == 0) {
151 irq_set_irq_type(gpio_to_irq(pin
), IRQ_TYPE_LEVEL_LOW
);
153 printk(KERN_ERR
"rd88f5182_pci_preinit faield to "
154 "set_irq_type pin %d\n", pin
);
158 printk(KERN_ERR
"rd88f5182_pci_preinit failed to request gpio %d\n", pin
);
161 pin
= RD88F5182_PCI_SLOT0_IRQ_B_PIN
;
162 if (gpio_request(pin
, "PCI IntB") == 0) {
163 if (gpio_direction_input(pin
) == 0) {
164 irq_set_irq_type(gpio_to_irq(pin
), IRQ_TYPE_LEVEL_LOW
);
166 printk(KERN_ERR
"rd88f5182_pci_preinit faield to "
167 "set_irq_type pin %d\n", pin
);
171 printk(KERN_ERR
"rd88f5182_pci_preinit failed to gpio_request %d\n", pin
);
175 static int __init
rd88f5182_pci_map_irq(const struct pci_dev
*dev
, u8 slot
,
181 * Check for devices with hard-wired IRQs.
183 irq
= orion5x_pci_map_irq(dev
, slot
, pin
);
188 * PCI IRQs are connected via GPIOs
190 switch (slot
- RD88F5182_PCI_SLOT0_OFFS
) {
193 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN
);
195 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN
);
201 static struct hw_pci rd88f5182_pci __initdata
= {
203 .preinit
= rd88f5182_pci_preinit
,
204 .swizzle
= pci_std_swizzle
,
205 .setup
= orion5x_pci_sys_setup
,
206 .scan
= orion5x_pci_sys_scan_bus
,
207 .map_irq
= rd88f5182_pci_map_irq
,
210 static int __init
rd88f5182_pci_init(void)
212 if (machine_is_rd88f5182())
213 pci_common_init(&rd88f5182_pci
);
218 subsys_initcall(rd88f5182_pci_init
);
220 /*****************************************************************************
222 ****************************************************************************/
224 static struct mv643xx_eth_platform_data rd88f5182_eth_data
= {
225 .phy_addr
= MV643XX_ETH_PHY_ADDR(8),
228 /*****************************************************************************
229 * RTC DS1338 on I2C bus
230 ****************************************************************************/
231 static struct i2c_board_info __initdata rd88f5182_i2c_rtc
= {
232 I2C_BOARD_INFO("ds1338", 0x68),
235 /*****************************************************************************
237 ****************************************************************************/
238 static struct mv_sata_platform_data rd88f5182_sata_data
= {
242 /*****************************************************************************
244 ****************************************************************************/
245 static unsigned int rd88f5182_mpp_modes
[] __initdata
= {
246 MPP0_GPIO
, /* Debug Led */
247 MPP1_GPIO
, /* Reset Switch */
249 MPP3_GPIO
, /* RTC Int */
252 MPP6_GPIO
, /* PCI_intA */
253 MPP7_GPIO
, /* PCI_intB */
258 MPP12_SATA_LED
, /* SATA 0 presence */
259 MPP13_SATA_LED
, /* SATA 1 presence */
260 MPP14_SATA_LED
, /* SATA 0 active */
261 MPP15_SATA_LED
, /* SATA 1 active */
269 static void __init
rd88f5182_init(void)
272 * Setup basic Orion functions. Need to be called early.
276 orion5x_mpp_conf(rd88f5182_mpp_modes
);
279 * MPP[20] PCI Clock to MV88F5182
280 * MPP[21] PCI Clock to mini PCI CON11
281 * MPP[22] USB 0 over current indication
282 * MPP[23] USB 1 over current indication
283 * MPP[24] USB 1 over current enable
284 * MPP[25] USB 0 over current enable
288 * Configure peripherals.
290 orion5x_ehci0_init();
291 orion5x_ehci1_init();
292 orion5x_eth_init(&rd88f5182_eth_data
);
294 orion5x_sata_init(&rd88f5182_sata_data
);
295 orion5x_uart0_init();
298 orion5x_setup_dev_boot_win(RD88F5182_NOR_BOOT_BASE
,
299 RD88F5182_NOR_BOOT_SIZE
);
301 orion5x_setup_dev1_win(RD88F5182_NOR_BASE
, RD88F5182_NOR_SIZE
);
302 platform_device_register(&rd88f5182_nor_flash
);
304 i2c_register_board_info(0, &rd88f5182_i2c_rtc
, 1);
307 MACHINE_START(RD88F5182
, "Marvell Orion-NAS Reference Design")
308 /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
309 .boot_params
= 0x00000100,
310 .init_machine
= rd88f5182_init
,
311 .map_io
= orion5x_map_io
,
312 .init_early
= orion5x_init_early
,
313 .init_irq
= orion5x_init_irq
,
314 .timer
= &orion5x_timer
,