1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * arch/arm/mach-mv78xx0/buffalo-wxl-setup.c
4  *
5  * Buffalo WXL (Terastation Duo) Setup routines
6  *
7  * sebastien requiem <sebastien@requiem.fr>
8  */
9 
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/ata_platform.h>
14 #include <linux/mv643xx_eth.h>
15 #include <linux/ethtool.h>
16 #include <linux/i2c.h>
17 #include <asm/mach-types.h>
18 #include <asm/mach/arch.h>
19 #include "mv78xx0.h"
20 #include "common.h"
21 #include "mpp.h"
22 
23 
24 /* This arch has 2 Giga Ethernet */
25 
26 static struct mv643xx_eth_platform_data db78x00_ge00_data = {
27 	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
28 };
29 
30 static struct mv643xx_eth_platform_data db78x00_ge01_data = {
31 	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
32 };
33 
34 
35 /* 2 SATA controller supporting HotPlug */
36 
37 static struct mv_sata_platform_data db78x00_sata_data = {
38 	.n_ports	= 2,
39 };
40 
41 static struct i2c_board_info __initdata db78x00_i2c_rtc = {
42 	I2C_BOARD_INFO("ds1338", 0x68),
43 };
44 
45 
46 static unsigned int wxl_mpp_config[] __initdata = {
47 	MPP0_GE1_TXCLK,
48 	MPP1_GE1_TXCTL,
49 	MPP2_GE1_RXCTL,
50 	MPP3_GE1_RXCLK,
51 	MPP4_GE1_TXD0,
52 	MPP5_GE1_TXD1,
53 	MPP6_GE1_TXD2,
54 	MPP7_GE1_TXD3,
55 	MPP8_GE1_RXD0,
56 	MPP9_GE1_RXD1,
57 	MPP10_GE1_RXD2,
58 	MPP11_GE1_RXD3,
59 	MPP12_GPIO,
60 	MPP13_SYSRST_OUTn,
61 	MPP14_SATA1_ACTn,
62 	MPP15_SATA0_ACTn,
63 	MPP16_GPIO,
64 	MPP17_GPIO,
65 	MPP18_GPIO,
66 	MPP19_GPIO,
67 	MPP20_GPIO,
68 	MPP21_GPIO,
69 	MPP22_GPIO,
70 	MPP23_GPIO,
71 	MPP24_UA2_TXD,
72 	MPP25_UA2_RXD,
73 	MPP26_UA2_CTSn,
74 	MPP27_UA2_RTSn,
75 	MPP28_GPIO,
76 	MPP29_SYSRST_OUTn,
77 	MPP30_GPIO,
78 	MPP31_GPIO,
79 	MPP32_GPIO,
80 	MPP33_GPIO,
81 	MPP34_GPIO,
82 	MPP35_GPIO,
83 	MPP36_GPIO,
84 	MPP37_GPIO,
85 	MPP38_GPIO,
86 	MPP39_GPIO,
87 	MPP40_UNUSED,
88 	MPP41_UNUSED,
89 	MPP42_UNUSED,
90 	MPP43_UNUSED,
91 	MPP44_UNUSED,
92 	MPP45_UNUSED,
93 	MPP46_UNUSED,
94 	MPP47_UNUSED,
95 	MPP48_SATA1_ACTn,
96 	MPP49_SATA0_ACTn,
97 	0
98 };
99 
100 
101 static void __init wxl_init(void)
102 {
103 	/*
104 	 * Basic MV78xx0 setup. Needs to be called early.
105 	 */
106 	mv78xx0_init();
107 	mv78xx0_mpp_conf(wxl_mpp_config);
108 
109 	/*
110 	 * Partition on-chip peripherals between the two CPU cores.
111 	 */
112 	mv78xx0_ehci0_init();
113 	mv78xx0_ehci1_init();
114 	mv78xx0_ehci2_init();
115 	mv78xx0_ge00_init(&db78x00_ge00_data);
116 	mv78xx0_ge01_init(&db78x00_ge01_data);
117 	mv78xx0_sata_init(&db78x00_sata_data);
118 	mv78xx0_uart0_init();
119 	mv78xx0_uart1_init();
120 	mv78xx0_uart2_init();
121 	mv78xx0_uart3_init();
122 	mv78xx0_i2c_init();
123 	i2c_register_board_info(0, &db78x00_i2c_rtc, 1);
124 }
125 
126 static int __init wxl_pci_init(void)
127 {
128 	if (machine_is_terastation_wxl()) {
129 		/*
130 		 * Assign the x16 PCIe slot on the board to CPU core
131 		 * #0, and let CPU core #1 have the four x1 slots.
132 		 */
133 		if (mv78xx0_core_index() == 0)
134 			mv78xx0_pcie_init(0, 1);
135 		else
136 			mv78xx0_pcie_init(1, 0);
137 	}
138 
139 	return 0;
140 }
141 subsys_initcall(wxl_pci_init);
142 
143 MACHINE_START(TERASTATION_WXL, "Buffalo Nas WXL")
144 	/* Maintainer: Sebastien Requiem <sebastien@requiem.fr> */
145 	.atag_offset	= 0x100,
146 	.nr_irqs	= MV78XX0_NR_IRQS,
147 	.init_machine	= wxl_init,
148 	.map_io		= mv78xx0_map_io,
149 	.init_early	= mv78xx0_init_early,
150 	.init_irq	= mv78xx0_init_irq,
151 	.init_time	= mv78xx0_timer_init,
152 	.restart	= mv78xx0_restart,
153 MACHINE_END
154