xref: /linux/arch/arm/mach-mv78xx0/buffalo-wxl-setup.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
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 <linux/gpio.h>
18 #include <linux/gpio_keys.h>
19 #include <linux/input.h>
20 #include <asm/mach-types.h>
21 #include <asm/mach/arch.h>
22 #include "mv78xx0.h"
23 #include "common.h"
24 #include "mpp.h"
25 
26 
27 #define TSWXL_AUTO_SWITCH	15
28 #define TSWXL_USB_POWER1	30
29 #define TSWXL_USB_POWER2	31
30 
31 
32 /* This arch has 2 Giga Ethernet */
33 
34 static struct mv643xx_eth_platform_data db78x00_ge00_data = {
35 	.phy_addr	= MV643XX_ETH_PHY_ADDR(0),
36 };
37 
38 static struct mv643xx_eth_platform_data db78x00_ge01_data = {
39 	.phy_addr	= MV643XX_ETH_PHY_ADDR(8),
40 };
41 
42 
43 /* 2 SATA controller supporting HotPlug */
44 
45 static struct mv_sata_platform_data db78x00_sata_data = {
46 	.n_ports	= 2,
47 };
48 
49 static struct i2c_board_info __initdata db78x00_i2c_rtc = {
50 	I2C_BOARD_INFO("rs5c372a", 0x32),
51 };
52 
53 
54 static unsigned int wxl_mpp_config[] __initdata = {
55 	MPP0_GE1_TXCLK,
56 	MPP1_GE1_TXCTL,
57 	MPP2_GE1_RXCTL,
58 	MPP3_GE1_RXCLK,
59 	MPP4_GE1_TXD0,
60 	MPP5_GE1_TXD1,
61 	MPP6_GE1_TXD2,
62 	MPP7_GE1_TXD3,
63 	MPP8_GE1_RXD0,
64 	MPP9_GE1_RXD1,
65 	MPP10_GE1_RXD2,
66 	MPP11_GE1_RXD3,
67 	MPP12_GPIO,
68 	MPP13_GPIO,
69 	MPP14_GPIO,
70 	MPP15_GPIO,
71 	MPP16_GPIO,
72 	MPP17_GPIO,
73 	MPP18_GPIO,
74 	MPP19_GPIO,
75 	MPP20_GPIO,
76 	MPP21_GPIO,
77 	MPP22_GPIO,
78 	MPP23_GPIO,
79 	MPP24_UA2_TXD,
80 	MPP25_UA2_RXD,
81 	MPP26_UA2_CTSn,
82 	MPP27_UA2_RTSn,
83 	MPP28_GPIO,
84 	MPP29_GPIO,
85 	MPP30_GPIO,
86 	MPP31_GPIO,
87 	MPP32_GPIO,
88 	MPP33_GPIO,
89 	MPP34_GPIO,
90 	MPP35_GPIO,
91 	MPP36_GPIO,
92 	MPP37_GPIO,
93 	MPP38_GPIO,
94 	MPP39_GPIO,
95 	MPP40_GPIO,
96 	MPP41_GPIO,
97 	MPP42_GPIO,
98 	MPP43_GPIO,
99 	MPP44_GPIO,
100 	MPP45_GPIO,
101 	MPP46_GPIO,
102 	MPP47_GPIO,
103 	MPP48_GPIO,
104 	MPP49_GPIO,
105 	0
106 };
107 
108 static struct gpio_keys_button tswxl_buttons[] = {
109 	{
110 		.code	   = KEY_OPTION,
111 		.gpio	   = TSWXL_AUTO_SWITCH,
112 		.desc	   = "Power-auto Switch",
113 		.active_low     = 1,
114 	}
115 };
116 
117 static struct gpio_keys_platform_data tswxl_button_data = {
118 	.buttons	= tswxl_buttons,
119 	.nbuttons       = ARRAY_SIZE(tswxl_buttons),
120 };
121 
122 static struct platform_device tswxl_button_device = {
123 	.name	   = "gpio-keys",
124 	.id	     = -1,
125 	.num_resources  = 0,
126 	.dev	    = {
127 		.platform_data  = &tswxl_button_data,
128 	},
129 };
130 
wxl_init(void)131 static void __init wxl_init(void)
132 {
133 	/*
134 	 * Basic MV78xx0 setup. Needs to be called early.
135 	 */
136 	mv78xx0_init();
137 	mv78xx0_mpp_conf(wxl_mpp_config);
138 
139 	/*
140 	 * Partition on-chip peripherals between the two CPU cores.
141 	 */
142 	mv78xx0_ehci0_init();
143 	mv78xx0_ehci1_init();
144 	mv78xx0_ge00_init(&db78x00_ge00_data);
145 	mv78xx0_ge01_init(&db78x00_ge01_data);
146 	mv78xx0_sata_init(&db78x00_sata_data);
147 	mv78xx0_uart0_init();
148 	mv78xx0_uart1_init();
149 	mv78xx0_uart2_init();
150 	mv78xx0_uart3_init();
151 	mv78xx0_xor_init();
152 	mv78xx0_crypto_init();
153 	mv78xx0_i2c_init();
154 	i2c_register_board_info(0, &db78x00_i2c_rtc, 1);
155 
156 	//enable both usb ports
157 	gpio_direction_output(TSWXL_USB_POWER1, 1);
158 	gpio_direction_output(TSWXL_USB_POWER2, 1);
159 
160 	//enable rear switch
161 	platform_device_register(&tswxl_button_device);
162 }
163 
wxl_pci_init(void)164 static int __init wxl_pci_init(void)
165 {
166 	if (machine_is_terastation_wxl() && mv78xx0_core_index() == 0)
167                 mv78xx0_pcie_init(1, 1);
168 
169 	return 0;
170 }
171 subsys_initcall(wxl_pci_init);
172 
173 MACHINE_START(TERASTATION_WXL, "Buffalo Nas WXL")
174 	/* Maintainer: Sebastien Requiem <sebastien@requiem.fr> */
175 	.atag_offset	= 0x100,
176 	.nr_irqs	= MV78XX0_NR_IRQS,
177 	.init_machine	= wxl_init,
178 	.map_io		= mv78xx0_map_io,
179 	.init_early	= mv78xx0_init_early,
180 	.init_irq	= mv78xx0_init_irq,
181 	.init_time	= mv78xx0_timer_init,
182 	.restart	= mv78xx0_restart,
183 MACHINE_END
184