1 // SPDX-License-Identifier: GPL-2.0-only
3 * arch/arm/mach-orion5x/rd88f5182-setup.c
5 * Marvell Orion-NAS Reference Design Setup
7 * Maintainer: Ronen Shitrit <rshitrit@marvell.com>
9 #include <linux/gpio.h>
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/pci.h>
14 #include <linux/irq.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/mv643xx_eth.h>
17 #include <linux/ata_platform.h>
18 #include <linux/i2c.h>
19 #include <linux/leds.h>
20 #include <asm/mach-types.h>
21 #include <asm/mach/arch.h>
22 #include <asm/mach/pci.h>
27 /*****************************************************************************
29 ****************************************************************************/
32 * 512K NOR flash Device bus boot chip select
35 #define RD88F5182_NOR_BOOT_BASE 0xf4000000
36 #define RD88F5182_NOR_BOOT_SIZE SZ_512K
39 * 16M NOR flash on Device bus chip select 1
42 #define RD88F5182_NOR_BASE 0xfc000000
43 #define RD88F5182_NOR_SIZE SZ_16M
49 #define RD88F5182_PCI_SLOT0_OFFS 7
50 #define RD88F5182_PCI_SLOT0_IRQ_A_PIN 7
51 #define RD88F5182_PCI_SLOT0_IRQ_B_PIN 6
53 /*****************************************************************************
54 * 16M NOR Flash on Device bus CS1
55 ****************************************************************************/
57 static struct physmap_flash_data rd88f5182_nor_flash_data = {
61 static struct resource rd88f5182_nor_flash_resource = {
62 .flags = IORESOURCE_MEM,
63 .start = RD88F5182_NOR_BASE,
64 .end = RD88F5182_NOR_BASE + RD88F5182_NOR_SIZE - 1,
67 static struct platform_device rd88f5182_nor_flash = {
68 .name = "physmap-flash",
71 .platform_data = &rd88f5182_nor_flash_data,
74 .resource = &rd88f5182_nor_flash_resource,
77 /*****************************************************************************
78 * Use GPIO LED as CPU active indication
79 ****************************************************************************/
81 #define RD88F5182_GPIO_LED 0
83 static struct gpio_led rd88f5182_gpio_led_pins[] = {
85 .name = "rd88f5182:cpu",
86 .default_trigger = "cpu0",
87 .gpio = RD88F5182_GPIO_LED,
91 static struct gpio_led_platform_data rd88f5182_gpio_led_data = {
92 .leds = rd88f5182_gpio_led_pins,
93 .num_leds = ARRAY_SIZE(rd88f5182_gpio_led_pins),
96 static struct platform_device rd88f5182_gpio_leds = {
100 .platform_data = &rd88f5182_gpio_led_data,
104 /*****************************************************************************
106 ****************************************************************************/
108 static void __init rd88f5182_pci_preinit(void)
113 * Configure PCI GPIO IRQ pins
115 pin = RD88F5182_PCI_SLOT0_IRQ_A_PIN;
116 if (gpio_request(pin, "PCI IntA") == 0) {
117 if (gpio_direction_input(pin) == 0) {
118 irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
120 printk(KERN_ERR "rd88f5182_pci_preinit failed to "
121 "set_irq_type pin %d\n", pin);
125 printk(KERN_ERR "rd88f5182_pci_preinit failed to request gpio %d\n", pin);
128 pin = RD88F5182_PCI_SLOT0_IRQ_B_PIN;
129 if (gpio_request(pin, "PCI IntB") == 0) {
130 if (gpio_direction_input(pin) == 0) {
131 irq_set_irq_type(gpio_to_irq(pin), IRQ_TYPE_LEVEL_LOW);
133 printk(KERN_ERR "rd88f5182_pci_preinit failed to "
134 "set_irq_type pin %d\n", pin);
138 printk(KERN_ERR "rd88f5182_pci_preinit failed to gpio_request %d\n", pin);
142 static int __init rd88f5182_pci_map_irq(const struct pci_dev *dev, u8 slot,
148 * Check for devices with hard-wired IRQs.
150 irq = orion5x_pci_map_irq(dev, slot, pin);
155 * PCI IRQs are connected via GPIOs
157 switch (slot - RD88F5182_PCI_SLOT0_OFFS) {
160 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_A_PIN);
162 return gpio_to_irq(RD88F5182_PCI_SLOT0_IRQ_B_PIN);
168 static struct hw_pci rd88f5182_pci __initdata = {
170 .preinit = rd88f5182_pci_preinit,
171 .setup = orion5x_pci_sys_setup,
172 .scan = orion5x_pci_sys_scan_bus,
173 .map_irq = rd88f5182_pci_map_irq,
176 static int __init rd88f5182_pci_init(void)
178 if (machine_is_rd88f5182())
179 pci_common_init(&rd88f5182_pci);
184 subsys_initcall(rd88f5182_pci_init);
186 /*****************************************************************************
188 ****************************************************************************/
190 static struct mv643xx_eth_platform_data rd88f5182_eth_data = {
191 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
194 /*****************************************************************************
195 * RTC DS1338 on I2C bus
196 ****************************************************************************/
197 static struct i2c_board_info __initdata rd88f5182_i2c_rtc = {
198 I2C_BOARD_INFO("ds1338", 0x68),
201 /*****************************************************************************
203 ****************************************************************************/
204 static struct mv_sata_platform_data rd88f5182_sata_data = {
208 /*****************************************************************************
210 ****************************************************************************/
211 static unsigned int rd88f5182_mpp_modes[] __initdata = {
212 MPP0_GPIO, /* Debug Led */
213 MPP1_GPIO, /* Reset Switch */
215 MPP3_GPIO, /* RTC Int */
218 MPP6_GPIO, /* PCI_intA */
219 MPP7_GPIO, /* PCI_intB */
224 MPP12_SATA_LED, /* SATA 0 presence */
225 MPP13_SATA_LED, /* SATA 1 presence */
226 MPP14_SATA_LED, /* SATA 0 active */
227 MPP15_SATA_LED, /* SATA 1 active */
235 static void __init rd88f5182_init(void)
238 * Setup basic Orion functions. Need to be called early.
242 orion5x_mpp_conf(rd88f5182_mpp_modes);
245 * MPP[20] PCI Clock to MV88F5182
246 * MPP[21] PCI Clock to mini PCI CON11
247 * MPP[22] USB 0 over current indication
248 * MPP[23] USB 1 over current indication
249 * MPP[24] USB 1 over current enable
250 * MPP[25] USB 0 over current enable
254 * Configure peripherals.
256 orion5x_ehci0_init();
257 orion5x_ehci1_init();
258 orion5x_eth_init(&rd88f5182_eth_data);
260 orion5x_sata_init(&rd88f5182_sata_data);
261 orion5x_uart0_init();
264 mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_BOOT_TARGET,
265 ORION_MBUS_DEVBUS_BOOT_ATTR,
266 RD88F5182_NOR_BOOT_BASE,
267 RD88F5182_NOR_BOOT_SIZE);
268 mvebu_mbus_add_window_by_id(ORION_MBUS_DEVBUS_TARGET(1),
269 ORION_MBUS_DEVBUS_ATTR(1),
272 platform_device_register(&rd88f5182_nor_flash);
273 platform_device_register(&rd88f5182_gpio_leds);
275 i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1);
278 MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design")
279 /* Maintainer: Ronen Shitrit <rshitrit@marvell.com> */
280 .atag_offset = 0x100,
281 .nr_irqs = ORION5X_NR_IRQS,
282 .init_machine = rd88f5182_init,
283 .map_io = orion5x_map_io,
284 .init_early = orion5x_init_early,
285 .init_irq = orion5x_init_irq,
286 .init_time = orion5x_timer_init,
287 .restart = orion5x_restart,