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