1 This patch moves initialisation of EHCI/I2C/UART platform devices
2 from the common orion5x_init() into the board support code.
4 The rationale behind this is that only the board support code knows
5 whether certain peripherals have been brought out on the board, and
6 not initialising peripherals that haven't been brought out is
8 - to reduce user confusion (e.g. seeing both 'eth0' and 'eth1'
9 appear while there is only one ethernet port on the board); and
10 - to allow for future power savings (peripherals that have not
11 been brought out can be clock gated off entirely.)
13 Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
15 arch/arm/mach-orion5x/common.c | 226 +++++++++++++++++------------
16 arch/arm/mach-orion5x/common.h | 35 ++---
17 arch/arm/mach-orion5x/db88f5281-setup.c | 39 +++---
18 arch/arm/mach-orion5x/dns323-setup.c | 40 +++---
19 arch/arm/mach-orion5x/kurobox_pro-setup.c | 28 +++--
20 arch/arm/mach-orion5x/rd88f5182-setup.c | 29 ++--
21 arch/arm/mach-orion5x/ts209-setup.c | 38 ++---
22 7 files changed, 240 insertions(+), 195 deletions(-)
24 --- a/arch/arm/mach-orion5x/common.c
25 +++ b/arch/arm/mach-orion5x/common.c
27 iotable_init(orion5x_io_desc, ARRAY_SIZE(orion5x_io_desc));
31 /*****************************************************************************
34 ****************************************************************************/
36 -static struct resource orion5x_uart_resources[] = {
38 - .start = UART0_PHYS_BASE,
39 - .end = UART0_PHYS_BASE + 0xff,
40 - .flags = IORESOURCE_MEM,
42 - .start = IRQ_ORION5X_UART0,
43 - .end = IRQ_ORION5X_UART0,
44 - .flags = IORESOURCE_IRQ,
46 - .start = UART1_PHYS_BASE,
47 - .end = UART1_PHYS_BASE + 0xff,
48 - .flags = IORESOURCE_MEM,
50 - .start = IRQ_ORION5X_UART1,
51 - .end = IRQ_ORION5X_UART1,
52 - .flags = IORESOURCE_IRQ,
56 -static struct plat_serial8250_port orion5x_uart_data[] = {
58 - .mapbase = UART0_PHYS_BASE,
59 - .membase = (char *)UART0_VIRT_BASE,
60 - .irq = IRQ_ORION5X_UART0,
61 - .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
64 - .uartclk = ORION5X_TCLK,
66 - .mapbase = UART1_PHYS_BASE,
67 - .membase = (char *)UART1_VIRT_BASE,
68 - .irq = IRQ_ORION5X_UART1,
69 - .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
72 - .uartclk = ORION5X_TCLK,
75 +static struct orion_ehci_data orion5x_ehci_data = {
76 + .dram = &orion5x_mbus_dram_info,
79 -static struct platform_device orion5x_uart = {
80 - .name = "serial8250",
81 - .id = PLAT8250_DEV_PLATFORM,
83 - .platform_data = orion5x_uart_data,
85 - .resource = orion5x_uart_resources,
86 - .num_resources = ARRAY_SIZE(orion5x_uart_resources),
88 +static u64 ehci_dmamask = 0xffffffffUL;
90 -/*******************************************************************************
91 - * USB Controller - 2 interfaces
92 - ******************************************************************************/
94 +/*****************************************************************************
96 + ****************************************************************************/
97 static struct resource orion5x_ehci0_resources[] = {
99 .start = ORION5X_USB0_PHYS_BASE,
104 -static struct resource orion5x_ehci1_resources[] = {
106 - .start = ORION5X_USB1_PHYS_BASE,
107 - .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
108 - .flags = IORESOURCE_MEM,
110 - .start = IRQ_ORION5X_USB1_CTRL,
111 - .end = IRQ_ORION5X_USB1_CTRL,
112 - .flags = IORESOURCE_IRQ,
116 -static struct orion_ehci_data orion5x_ehci_data = {
117 - .dram = &orion5x_mbus_dram_info,
120 -static u64 ehci_dmamask = 0xffffffffUL;
122 static struct platform_device orion5x_ehci0 = {
123 .name = "orion-ehci",
126 .num_resources = ARRAY_SIZE(orion5x_ehci0_resources),
129 +void __init orion5x_ehci0_init(void)
131 + platform_device_register(&orion5x_ehci0);
135 +/*****************************************************************************
137 + ****************************************************************************/
138 +static struct resource orion5x_ehci1_resources[] = {
140 + .start = ORION5X_USB1_PHYS_BASE,
141 + .end = ORION5X_USB1_PHYS_BASE + SZ_4K - 1,
142 + .flags = IORESOURCE_MEM,
144 + .start = IRQ_ORION5X_USB1_CTRL,
145 + .end = IRQ_ORION5X_USB1_CTRL,
146 + .flags = IORESOURCE_IRQ,
150 static struct platform_device orion5x_ehci1 = {
151 .name = "orion-ehci",
153 @@ -176,11 +134,15 @@
154 .num_resources = ARRAY_SIZE(orion5x_ehci1_resources),
157 +void __init orion5x_ehci1_init(void)
159 + platform_device_register(&orion5x_ehci1);
163 /*****************************************************************************
164 - * Gigabit Ethernet port
165 - * (The Orion and Discovery (MV643xx) families use the same Ethernet driver)
167 ****************************************************************************/
169 struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
170 .dram = &orion5x_mbus_dram_info,
171 .t_clk = ORION5X_TCLK,
172 @@ -229,11 +191,10 @@
173 platform_device_register(&orion5x_eth);
177 /*****************************************************************************
179 - * (The Orion and Discovery (MV643xx) families share the same I2C controller)
181 ****************************************************************************/
183 static struct mv64xxx_i2c_pdata orion5x_i2c_pdata = {
184 .freq_m = 8, /* assumes 166 MHz TCLK */
189 .start = I2C_PHYS_BASE,
190 - .end = I2C_PHYS_BASE + 0x20 -1,
191 + .end = I2C_PHYS_BASE + 0x1f,
192 .flags = IORESOURCE_MEM,
199 +void __init orion5x_i2c_init(void)
201 + platform_device_register(&orion5x_i2c);
205 /*****************************************************************************
208 ****************************************************************************/
209 static struct resource orion5x_sata_resources[] = {
211 @@ -298,10 +265,98 @@
212 platform_device_register(&orion5x_sata);
216 /*****************************************************************************
219 + ****************************************************************************/
220 +static struct plat_serial8250_port orion5x_uart0_data[] = {
222 + .mapbase = UART0_PHYS_BASE,
223 + .membase = (char *)UART0_VIRT_BASE,
224 + .irq = IRQ_ORION5X_UART0,
225 + .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
226 + .iotype = UPIO_MEM,
228 + .uartclk = ORION5X_TCLK,
233 +static struct resource orion5x_uart0_resources[] = {
235 + .start = UART0_PHYS_BASE,
236 + .end = UART0_PHYS_BASE + 0xff,
237 + .flags = IORESOURCE_MEM,
239 + .start = IRQ_ORION5X_UART0,
240 + .end = IRQ_ORION5X_UART0,
241 + .flags = IORESOURCE_IRQ,
245 +static struct platform_device orion5x_uart0 = {
246 + .name = "serial8250",
247 + .id = PLAT8250_DEV_PLATFORM,
249 + .platform_data = orion5x_uart0_data,
251 + .resource = orion5x_uart0_resources,
252 + .num_resources = ARRAY_SIZE(orion5x_uart0_resources),
255 +void __init orion5x_uart0_init(void)
257 + platform_device_register(&orion5x_uart0);
261 +/*****************************************************************************
263 ****************************************************************************/
264 +static struct plat_serial8250_port orion5x_uart1_data[] = {
266 + .mapbase = UART1_PHYS_BASE,
267 + .membase = (char *)UART1_VIRT_BASE,
268 + .irq = IRQ_ORION5X_UART1,
269 + .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
270 + .iotype = UPIO_MEM,
272 + .uartclk = ORION5X_TCLK,
277 +static struct resource orion5x_uart1_resources[] = {
279 + .start = UART1_PHYS_BASE,
280 + .end = UART1_PHYS_BASE + 0xff,
281 + .flags = IORESOURCE_MEM,
283 + .start = IRQ_ORION5X_UART1,
284 + .end = IRQ_ORION5X_UART1,
285 + .flags = IORESOURCE_IRQ,
289 +static struct platform_device orion5x_uart1 = {
290 + .name = "serial8250",
291 + .id = PLAT8250_DEV_PLATFORM1,
293 + .platform_data = orion5x_uart1_data,
295 + .resource = orion5x_uart1_resources,
296 + .num_resources = ARRAY_SIZE(orion5x_uart1_resources),
299 +void __init orion5x_uart1_init(void)
301 + platform_device_register(&orion5x_uart1);
305 +/*****************************************************************************
307 + ****************************************************************************/
308 static void orion5x_timer_init(void)
310 orion_time_init(IRQ_ORION5X_BRIDGE, ORION5X_TCLK);
311 @@ -311,10 +366,10 @@
312 .init = orion5x_timer_init,
316 /*****************************************************************************
318 ****************************************************************************/
321 * Identify device ID and rev from PCIe configuration header space '0'.
324 * Setup Orion address map
326 orion5x_setup_cpu_mbus_bridge();
329 - * Register devices.
331 - platform_device_register(&orion5x_uart);
332 - platform_device_register(&orion5x_ehci0);
333 - if (dev == MV88F5182_DEV_ID)
334 - platform_device_register(&orion5x_ehci1);
335 - platform_device_register(&orion5x_i2c);
339 --- a/arch/arm/mach-orion5x/common.h
340 +++ b/arch/arm/mach-orion5x/common.h
342 #ifndef __ARCH_ORION5X_COMMON_H
343 #define __ARCH_ORION5X_COMMON_H
345 +struct mv643xx_eth_platform_data;
346 +struct mv_sata_platform_data;
349 * Basic Orion init functions used early by machine-setup.
352 void orion5x_map_io(void);
353 void orion5x_init_irq(void);
354 void orion5x_init(void);
356 void orion5x_setup_dev2_win(u32 base, u32 size);
357 void orion5x_setup_pcie_wa_win(u32 base, u32 size);
359 +void orion5x_ehci0_init(void);
360 +void orion5x_ehci1_init(void);
361 +void orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data);
362 +void orion5x_i2c_init(void);
363 +void orion5x_sata_init(struct mv_sata_platform_data *sata_data);
364 +void orion5x_uart0_init(void);
365 +void orion5x_uart1_init(void);
368 - * Shared code used internally by other Orion core functions.
369 - * (/mach-orion/pci.c)
370 + * PCIe/PCI functions.
373 -struct pci_sys_data;
375 +struct pci_sys_data;
377 void orion5x_pcie_id(u32 *dev, u32 *rev);
378 int orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys);
380 * Valid GPIO pins according to MPP setup, used by machine-setup.
381 * (/mach-orion/gpio.c).
384 void orion5x_gpio_set_valid_pins(u32 pins);
385 void gpio_display(void); /* debug */
388 - * Pull in Orion Ethernet platform_data, used by machine-setup
391 -struct mv643xx_eth_platform_data;
393 -void orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data);
396 - * Orion Sata platform_data, used by machine-setup
399 -struct mv_sata_platform_data;
401 -void orion5x_sata_init(struct mv_sata_platform_data *sata_data);
406 --- a/arch/arm/mach-orion5x/db88f5281-setup.c
407 +++ b/arch/arm/mach-orion5x/db88f5281-setup.c
409 /*****************************************************************************
411 ****************************************************************************/
413 -static struct platform_device *db88f5281_devs[] __initdata = {
414 - &db88f5281_boot_flash,
415 - &db88f5281_nor_flash,
416 - &db88f5281_nand_flash,
419 static void __init db88f5281_init(void)
426 - * Setup the CPU address decode windows for our on-board devices
428 - orion5x_setup_dev_boot_win(DB88F5281_NOR_BOOT_BASE,
429 - DB88F5281_NOR_BOOT_SIZE);
430 - orion5x_setup_dev0_win(DB88F5281_7SEG_BASE, DB88F5281_7SEG_SIZE);
431 - orion5x_setup_dev1_win(DB88F5281_NOR_BASE, DB88F5281_NOR_SIZE);
432 - orion5x_setup_dev2_win(DB88F5281_NAND_BASE, DB88F5281_NAND_SIZE);
435 * Setup Multiplexing Pins:
436 * MPP0: GPIO (USB Over Current) MPP1: GPIO (USB Vbat input)
437 * MPP2: PCI_REQn[2] MPP3: PCI_GNTn[2]
440 orion5x_gpio_set_valid_pins(0x00003fc3);
442 - platform_add_devices(db88f5281_devs, ARRAY_SIZE(db88f5281_devs));
443 - i2c_register_board_info(0, &db88f5281_i2c_rtc, 1);
445 + * Configure peripherals.
447 + orion5x_ehci0_init();
448 orion5x_eth_init(&db88f5281_eth_data);
449 + orion5x_i2c_init();
450 + orion5x_uart0_init();
451 + orion5x_uart1_init();
453 + orion5x_setup_dev_boot_win(DB88F5281_NOR_BOOT_BASE,
454 + DB88F5281_NOR_BOOT_SIZE);
455 + platform_device_register(&db88f5281_boot_flash);
457 + orion5x_setup_dev0_win(DB88F5281_7SEG_BASE, DB88F5281_7SEG_SIZE);
459 + orion5x_setup_dev1_win(DB88F5281_NOR_BASE, DB88F5281_NOR_SIZE);
460 + platform_device_register(&db88f5281_nor_flash);
462 + orion5x_setup_dev2_win(DB88F5281_NAND_BASE, DB88F5281_NAND_SIZE);
463 + platform_device_register(&db88f5281_nand_flash);
465 + i2c_register_board_info(0, &db88f5281_i2c_rtc, 1);
468 MACHINE_START(DB88F5281, "Marvell Orion-2 Development Board")
469 --- a/arch/arm/mach-orion5x/dns323-setup.c
470 +++ b/arch/arm/mach-orion5x/dns323-setup.c
475 -static struct platform_device *dns323_plat_devices[] __initdata = {
478 - &dns323_button_device,
482 * On the DNS-323 the following devices are attached via I2C:
485 /* Setup basic Orion functions. Need to be called early. */
488 - /* setup flash mapping
489 - * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
491 - orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE);
493 /* DNS-323 has a Marvell 88X7042 SATA controller attached via PCIe
495 * Open a special address decode windows for the PCIe WA.
496 @@ -294,21 +283,32 @@
498 orion5x_gpio_set_valid_pins(0x07f6);
500 - /* register dns323 specific power-off method */
501 - if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
502 - gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
503 - pr_err("DNS323: failed to setup power-off GPIO\n");
505 + * Configure peripherals.
507 + orion5x_ehci0_init();
508 + orion5x_eth_init(&dns323_eth_data);
509 + orion5x_i2c_init();
510 + orion5x_uart0_init();
512 - pm_power_off = dns323_power_off;
513 + /* setup flash mapping
514 + * CS3 holds a 8 MB Spansion S29GL064M90TFIR4
516 + orion5x_setup_dev_boot_win(DNS323_NOR_BOOT_BASE, DNS323_NOR_BOOT_SIZE);
517 + platform_device_register(&dns323_nor_flash);
519 + platform_device_register(&dns323_gpio_leds);
521 - /* register flash and other platform devices */
522 - platform_add_devices(dns323_plat_devices,
523 - ARRAY_SIZE(dns323_plat_devices));
524 + platform_device_register(&dns323_button_device);
526 i2c_register_board_info(0, dns323_i2c_devices,
527 ARRAY_SIZE(dns323_i2c_devices));
529 - orion5x_eth_init(&dns323_eth_data);
530 + /* register dns323 specific power-off method */
531 + if (gpio_request(DNS323_GPIO_POWER_OFF, "POWEROFF") != 0 ||
532 + gpio_direction_output(DNS323_GPIO_POWER_OFF, 0) != 0)
533 + pr_err("DNS323: failed to setup power-off GPIO\n");
534 + pm_power_off = dns323_power_off;
537 /* Warning: D-Link uses a wrong mach-type (=526) in their bootloader */
538 --- a/arch/arm/mach-orion5x/kurobox_pro-setup.c
539 +++ b/arch/arm/mach-orion5x/kurobox_pro-setup.c
544 - * Setup the CPU address decode windows for our devices
546 - orion5x_setup_dev_boot_win(KUROBOX_PRO_NOR_BOOT_BASE,
547 - KUROBOX_PRO_NOR_BOOT_SIZE);
548 - orion5x_setup_dev0_win(KUROBOX_PRO_NAND_BASE, KUROBOX_PRO_NAND_SIZE);
551 * Open a special address decode windows for the PCIe WA.
553 orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE,
554 @@ -221,12 +214,27 @@
556 orion5x_gpio_set_valid_pins(0x0000000c);
559 + * Configure peripherals.
561 + orion5x_ehci0_init();
562 + orion5x_ehci1_init();
563 + orion5x_eth_init(&kurobox_pro_eth_data);
564 + orion5x_i2c_init();
565 + orion5x_sata_init(&kurobox_pro_sata_data);
566 + orion5x_uart0_init();
568 + orion5x_setup_dev_boot_win(KUROBOX_PRO_NOR_BOOT_BASE,
569 + KUROBOX_PRO_NOR_BOOT_SIZE);
570 platform_device_register(&kurobox_pro_nor_flash);
571 - if (machine_is_kurobox_pro())
573 + if (machine_is_kurobox_pro()) {
574 + orion5x_setup_dev0_win(KUROBOX_PRO_NAND_BASE,
575 + KUROBOX_PRO_NAND_SIZE);
576 platform_device_register(&kurobox_pro_nand_flash);
579 i2c_register_board_info(0, &kurobox_pro_i2c_rtc, 1);
580 - orion5x_eth_init(&kurobox_pro_eth_data);
581 - orion5x_sata_init(&kurobox_pro_sata_data);
584 #ifdef CONFIG_MACH_KUROBOX_PRO
585 --- a/arch/arm/mach-orion5x/rd88f5182-setup.c
586 +++ b/arch/arm/mach-orion5x/rd88f5182-setup.c
588 /*****************************************************************************
590 ****************************************************************************/
592 -static struct platform_device *rd88f5182_devices[] __initdata = {
593 - &rd88f5182_nor_flash,
596 static void __init rd88f5182_init(void)
603 - * Setup the CPU address decode windows for our devices
605 - orion5x_setup_dev_boot_win(RD88F5182_NOR_BOOT_BASE,
606 - RD88F5182_NOR_BOOT_SIZE);
607 - orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE);
610 * Open a special address decode windows for the PCIe WA.
612 orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE,
613 @@ -296,10 +284,23 @@
615 orion5x_gpio_set_valid_pins(0x000000fb);
617 - platform_add_devices(rd88f5182_devices, ARRAY_SIZE(rd88f5182_devices));
618 - i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1);
620 + * Configure peripherals.
622 + orion5x_ehci0_init();
623 + orion5x_ehci1_init();
624 orion5x_eth_init(&rd88f5182_eth_data);
625 + orion5x_i2c_init();
626 orion5x_sata_init(&rd88f5182_sata_data);
627 + orion5x_uart0_init();
629 + orion5x_setup_dev_boot_win(RD88F5182_NOR_BOOT_BASE,
630 + RD88F5182_NOR_BOOT_SIZE);
632 + orion5x_setup_dev1_win(RD88F5182_NOR_BASE, RD88F5182_NOR_SIZE);
633 + platform_device_register(&rd88f5182_nor_flash);
635 + i2c_register_board_info(0, &rd88f5182_i2c_rtc, 1);
638 MACHINE_START(RD88F5182, "Marvell Orion-NAS Reference Design")
639 --- a/arch/arm/mach-orion5x/ts209-setup.c
640 +++ b/arch/arm/mach-orion5x/ts209-setup.c
644 ****************************************************************************/
646 -static struct platform_device *qnap_ts209_devices[] __initdata = {
647 - &qnap_ts209_nor_flash,
648 - &qnap_ts209_button_device,
652 * QNAP TS-[12]09 specific power off method via UART1-attached PIC
655 #define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2))
657 static void qnap_ts209_power_off(void)
662 - * Setup flash mapping
664 - orion5x_setup_dev_boot_win(QNAP_TS209_NOR_BOOT_BASE,
665 - QNAP_TS209_NOR_BOOT_SIZE);
668 * Open a special address decode windows for the PCIe WA.
670 orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE,
671 @@ -411,11 +398,22 @@
672 orion5x_write(MPP_16_19_CTRL, 0x5500);
673 orion5x_gpio_set_valid_pins(0x3cc0fff);
675 - /* register ts209 specific power-off method */
676 - pm_power_off = qnap_ts209_power_off;
678 + * Configure peripherals.
680 + orion5x_ehci0_init();
681 + orion5x_ehci1_init();
682 + ts209_find_mac_addr();
683 + orion5x_eth_init(&qnap_ts209_eth_data);
684 + orion5x_i2c_init();
685 + orion5x_sata_init(&qnap_ts209_sata_data);
686 + orion5x_uart0_init();
688 + orion5x_setup_dev_boot_win(QNAP_TS209_NOR_BOOT_BASE,
689 + QNAP_TS209_NOR_BOOT_SIZE);
690 + platform_device_register(&qnap_ts209_nor_flash);
692 - platform_add_devices(qnap_ts209_devices,
693 - ARRAY_SIZE(qnap_ts209_devices));
694 + platform_device_register(&qnap_ts209_button_device);
696 /* Get RTC IRQ and register the chip */
697 if (gpio_request(TS209_RTC_GPIO, "rtc") == 0) {
699 pr_warning("qnap_ts209_init: failed to get RTC IRQ\n");
700 i2c_register_board_info(0, &qnap_ts209_i2c_rtc, 1);
702 - ts209_find_mac_addr();
703 - orion5x_eth_init(&qnap_ts209_eth_data);
705 - orion5x_sata_init(&qnap_ts209_sata_data);
706 + /* register ts209 specific power-off method */
707 + pm_power_off = qnap_ts209_power_off;
710 MACHINE_START(TS209, "QNAP TS-109/TS-209")