xref: /openbmc/u-boot/board/BuR/brxre1/mux.c (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2a4d79993SHannes Schmelzer /*
3a4d79993SHannes Schmelzer  * mux.c
4a4d79993SHannes Schmelzer  *
5a4d79993SHannes Schmelzer  * Pinmux Setting for B&R LEIT Board(s)
6a4d79993SHannes Schmelzer  *
7a4d79993SHannes Schmelzer  * Copyright (C) 2013 Hannes Schmelzer <oe5hpm@oevsv.at>
8a4d79993SHannes Schmelzer  * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com
9a4d79993SHannes Schmelzer  */
10a4d79993SHannes Schmelzer 
11a4d79993SHannes Schmelzer #include <common.h>
12a4d79993SHannes Schmelzer #include <asm/arch/sys_proto.h>
13a4d79993SHannes Schmelzer #include <asm/arch/hardware.h>
14a4d79993SHannes Schmelzer #include <asm/arch/mux.h>
15a4d79993SHannes Schmelzer #include <asm/io.h>
16a4d79993SHannes Schmelzer #include <i2c.h>
17a4d79993SHannes Schmelzer 
18a4d79993SHannes Schmelzer static struct module_pin_mux spi0_pin_mux[] = {
19a4d79993SHannes Schmelzer 	/* SPI1_SCLK */
20a4d79993SHannes Schmelzer 	{OFFSET(spi0_sclk),	MODE(0) | PULLUDEN | RXACTIVE},
21a4d79993SHannes Schmelzer 	/* SPI1_D0 */
22a4d79993SHannes Schmelzer 	{OFFSET(spi0_d0),	MODE(0) | PULLUDEN | RXACTIVE},
23a4d79993SHannes Schmelzer 	/* SPI1_D1 */
24a4d79993SHannes Schmelzer 	{OFFSET(spi0_d1),	MODE(0) | PULLUDEN | RXACTIVE},
25a4d79993SHannes Schmelzer 	/* SPI1_CS0 */
26a4d79993SHannes Schmelzer 	{OFFSET(spi0_cs0),	MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE},
27a4d79993SHannes Schmelzer 	/* SPI1_CS1 */
28a4d79993SHannes Schmelzer 	{OFFSET(spi0_cs1),	MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE},
29a4d79993SHannes Schmelzer 	{-1},
30a4d79993SHannes Schmelzer };
31a4d79993SHannes Schmelzer 
32a4d79993SHannes Schmelzer static struct module_pin_mux dcan0_pin_mux[] = {
33a4d79993SHannes Schmelzer 	/* DCAN0 TX */
34a4d79993SHannes Schmelzer 	{OFFSET(uart1_ctsn),   MODE(2) | PULLUDEN | PULLUP_EN},
35a4d79993SHannes Schmelzer 	/* DCAN0 RX */
36a4d79993SHannes Schmelzer 	{OFFSET(uart1_rtsn),   MODE(2) | RXACTIVE},
37a4d79993SHannes Schmelzer 	{-1},
38a4d79993SHannes Schmelzer };
39a4d79993SHannes Schmelzer 
40a4d79993SHannes Schmelzer static struct module_pin_mux dcan1_pin_mux[] = {
41a4d79993SHannes Schmelzer 	/* DCAN1 TX */
42a4d79993SHannes Schmelzer 	{OFFSET(uart1_rxd),   MODE(2) | PULLUDEN | PULLUP_EN},
43a4d79993SHannes Schmelzer 	/* DCAN1 RX */
44a4d79993SHannes Schmelzer 	{OFFSET(uart1_txd),   MODE(2) | RXACTIVE},
45a4d79993SHannes Schmelzer 	{-1},
46a4d79993SHannes Schmelzer };
47a4d79993SHannes Schmelzer 
48a4d79993SHannes Schmelzer static struct module_pin_mux gpios[] = {
49a4d79993SHannes Schmelzer 	/* GPIO0_7  (PWW0 OUT) - CAN TERM */
50a4d79993SHannes Schmelzer 	{OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDDIS | RXACTIVE)},
51a4d79993SHannes Schmelzer 	/* GPIO0_19 (DMA_INTR0) - TA602 */
52a4d79993SHannes Schmelzer 	{OFFSET(xdma_event_intr0), (MODE(7) | PULLUDDIS | RXACTIVE)},
53a4d79993SHannes Schmelzer 	/* GPIO0_20 (DMA_INTR1) - SPI0 nCS1 */
54a4d79993SHannes Schmelzer 	{OFFSET(xdma_event_intr1), (MODE(7) | PULLUDDIS | RXACTIVE)},
55a4d79993SHannes Schmelzer 	/* GPIO0_29 (RMII1_REFCLK) - eMMC nRST */
56a4d79993SHannes Schmelzer 	{OFFSET(rmii1_refclk), (MODE(7) | PULLUDDIS)},
57a4d79993SHannes Schmelzer 	/* GPIO0_30 (GPMC_WAIT0) - TA601 */
58a4d79993SHannes Schmelzer 	{OFFSET(gpmc_wait0), (MODE(7) | PULLUDDIS | RXACTIVE)},
59a4d79993SHannes Schmelzer 	/* GPIO0_31 (GPMC_nWP) - SW601 PushButton */
60a4d79993SHannes Schmelzer 	{OFFSET(gpmc_wpn), (MODE(7) | PULLUDDIS | RXACTIVE)},
61a4d79993SHannes Schmelzer 	/* GPIO1_28 (GPMC_nWE) - FRAM_nWP */
62a4d79993SHannes Schmelzer 	{OFFSET(gpmc_be1n), (MODE(7) | PULLUDDIS)},
63a4d79993SHannes Schmelzer 	/* GPIO1_29 (gpmc_csn0) - MMC nRST */
64a4d79993SHannes Schmelzer 	{OFFSET(gpmc_csn0), (MODE(7) | PULLUDDIS)},
65a4d79993SHannes Schmelzer 	/* GPIO2_0  (GPMC_nCS3)	- VBAT_OK */
66a4d79993SHannes Schmelzer 	{OFFSET(gpmc_csn3), (MODE(7) | PULLUDDIS | RXACTIVE) },
67a4d79993SHannes Schmelzer 	/* GPIO2_2  (GPMC_nADV_ALE) - DCOK */
68a4d79993SHannes Schmelzer 	{OFFSET(gpmc_advn_ale), (MODE(7) | PULLUDDIS | RXACTIVE)},
69a4d79993SHannes Schmelzer 	/* GPIO2_4  (GPMC_nWE) - TST_BAST */
70a4d79993SHannes Schmelzer 	{OFFSET(gpmc_wen), (MODE(7) | PULLUDDIS)},
71a4d79993SHannes Schmelzer 	/* GPIO2_5  (gpmc_be0n_cle) - DISPLAY_ON_OFF */
72a4d79993SHannes Schmelzer 	{OFFSET(gpmc_be0n_cle), (MODE(7) | PULLUDDIS)},
73a4d79993SHannes Schmelzer 	/* GPIO3_16 (mcasp0_axr0) - ETH-LED green */
74a4d79993SHannes Schmelzer 	{OFFSET(mcasp0_axr0), (MODE(7) | PULLUDDIS | RXACTIVE)},
75a4d79993SHannes Schmelzer 	/* GPIO3_17 (mcasp0_ahclkr) - CAN_STB */
76a4d79993SHannes Schmelzer 	{OFFSET(mcasp0_ahclkr), (MODE(7) | PULLUDDIS | RXACTIVE)},
77a4d79993SHannes Schmelzer 	/* GPIO3_18 (MCASP0_ACLKR) - SW601 CNTup, mapped to Counter eQEB0A_in */
78a4d79993SHannes Schmelzer 	{OFFSET(mcasp0_aclkr), (MODE(1) | PULLUDDIS | RXACTIVE)},
79a4d79993SHannes Schmelzer 	/* GPIO3_19 (MCASP0_FSR) - SW601 CNTdown, mapped to Counter eQEB0B_in */
80a4d79993SHannes Schmelzer 	{OFFSET(mcasp0_fsr), (MODE(1) | PULLUDDIS | RXACTIVE)},
81a4d79993SHannes Schmelzer 	/* GPIO3_20 (MCASP0_AXR1) - SW601 CNTdown, map to Counter eQEB0_index */
82a4d79993SHannes Schmelzer 	{OFFSET(mcasp0_axr1), (MODE(1) | PULLUDDIS | RXACTIVE)},
83a4d79993SHannes Schmelzer 	{-1},
84a4d79993SHannes Schmelzer };
85a4d79993SHannes Schmelzer 
86a4d79993SHannes Schmelzer static struct module_pin_mux uart0_pin_mux[] = {
87a4d79993SHannes Schmelzer 	/* UART0_CTS */
88a4d79993SHannes Schmelzer 	{OFFSET(uart0_ctsn), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)},
89a4d79993SHannes Schmelzer 	/* UART0_RXD */
90a4d79993SHannes Schmelzer 	{OFFSET(uart0_rxd), (MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE)},
91a4d79993SHannes Schmelzer 	/* UART0_TXD */
92a4d79993SHannes Schmelzer 	{OFFSET(uart0_txd), (MODE(0) | PULLUDEN)},
93a4d79993SHannes Schmelzer 	{-1},
94a4d79993SHannes Schmelzer };
95a4d79993SHannes Schmelzer 
96a4d79993SHannes Schmelzer static struct module_pin_mux i2c0_pin_mux[] = {
97a4d79993SHannes Schmelzer 	/* I2C_DATA */
98a4d79993SHannes Schmelzer 	{OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)},
99a4d79993SHannes Schmelzer 	/* I2C_SCLK */
100a4d79993SHannes Schmelzer 	{OFFSET(i2c0_scl), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)},
101a4d79993SHannes Schmelzer 	{-1},
102a4d79993SHannes Schmelzer };
103a4d79993SHannes Schmelzer 
104a4d79993SHannes Schmelzer static struct module_pin_mux mii1_pin_mux[] = {
105a4d79993SHannes Schmelzer 	{OFFSET(mii1_crs), MODE(0) | RXACTIVE},		/* MII1_CRS */
106a4d79993SHannes Schmelzer 	{OFFSET(mii1_col), MODE(0) | RXACTIVE},		/* MII1_COL */
107a4d79993SHannes Schmelzer 	{OFFSET(mii1_rxerr), MODE(0) | RXACTIVE},	/* MII1_RXERR */
108a4d79993SHannes Schmelzer 	{OFFSET(mii1_txen), MODE(0)},			/* MII1_TXEN */
109a4d79993SHannes Schmelzer 	{OFFSET(mii1_rxdv), MODE(0) | RXACTIVE},	/* MII1_RXDV */
110a4d79993SHannes Schmelzer 	{OFFSET(mii1_txd3), MODE(0)},			/* MII1_TXD3 */
111a4d79993SHannes Schmelzer 	{OFFSET(mii1_txd2), MODE(0)},			/* MII1_TXD2 */
112a4d79993SHannes Schmelzer 	{OFFSET(mii1_txd1), MODE(0)},			/* MII1_TXD1 */
113a4d79993SHannes Schmelzer 	{OFFSET(mii1_txd0), MODE(0)},			/* MII1_TXD0 */
114a4d79993SHannes Schmelzer 	{OFFSET(mii1_txclk), MODE(0) | RXACTIVE},	/* MII1_TXCLK */
115a4d79993SHannes Schmelzer 	{OFFSET(mii1_rxclk), MODE(0) | RXACTIVE},	/* MII1_RXCLK */
116a4d79993SHannes Schmelzer 	{OFFSET(mii1_rxd3), MODE(0) | RXACTIVE},	/* MII1_RXD3 */
117a4d79993SHannes Schmelzer 	{OFFSET(mii1_rxd2), MODE(0) | RXACTIVE},	/* MII1_RXD2 */
118a4d79993SHannes Schmelzer 	{OFFSET(mii1_rxd1), MODE(0) | RXACTIVE},	/* MII1_RXD1 */
119a4d79993SHannes Schmelzer 	{OFFSET(mii1_rxd0), MODE(0) | RXACTIVE},	/* MII1_RXD0 */
120a4d79993SHannes Schmelzer 	{OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
121a4d79993SHannes Schmelzer 	{OFFSET(mdio_clk), MODE(0) | PULLUP_EN},	/* MDIO_CLK */
122a4d79993SHannes Schmelzer 	{-1},
123a4d79993SHannes Schmelzer };
124a4d79993SHannes Schmelzer 
125a4d79993SHannes Schmelzer static struct module_pin_mux mmc1_pin_mux[] = {
126a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad7), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_DAT7 */
127a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad6), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_DAT6 */
128a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad5), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_DAT5 */
129a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad4), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_DAT4 */
130a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_DAT3 */
131a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_DAT2 */
132a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_DAT1 */
133a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE | PULLUP_EN)},	/* MMC1_DAT0 */
134a4d79993SHannes Schmelzer 	{OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)},	/* MMC1_CLK */
135a4d79993SHannes Schmelzer 	{OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)},	/* MMC1_CMD */
136a4d79993SHannes Schmelzer 	{OFFSET(gpmc_csn0), (MODE(7) | RXACTIVE | PULLUP_EN)},	/* MMC1_WP */
137a4d79993SHannes Schmelzer 	{OFFSET(gpmc_advn_ale), (MODE(7) | RXACTIVE | PULLUP_EN)},/* MMC1_CD */
138a4d79993SHannes Schmelzer 
139a4d79993SHannes Schmelzer 	{-1},
140a4d79993SHannes Schmelzer };
141a4d79993SHannes Schmelzer 
142a4d79993SHannes Schmelzer static struct module_pin_mux lcd_pin_mux[] = {
143a4d79993SHannes Schmelzer 	{OFFSET(lcd_data0), (MODE(0) | PULLUDDIS)},	/* LCD-Data(0) */
144a4d79993SHannes Schmelzer 	{OFFSET(lcd_data1), (MODE(0) | PULLUDDIS)},	/* LCD-Data(1) */
145a4d79993SHannes Schmelzer 	{OFFSET(lcd_data2), (MODE(0) | PULLUDDIS)},	/* LCD-Data(2) */
146a4d79993SHannes Schmelzer 	{OFFSET(lcd_data3), (MODE(0) | PULLUDDIS)},	/* LCD-Data(3) */
147a4d79993SHannes Schmelzer 	{OFFSET(lcd_data4), (MODE(0) | PULLUDDIS)},	/* LCD-Data(4) */
148a4d79993SHannes Schmelzer 	{OFFSET(lcd_data5), (MODE(0) | PULLUDDIS)},	/* LCD-Data(5) */
149a4d79993SHannes Schmelzer 	{OFFSET(lcd_data6), (MODE(0) | PULLUDDIS)},	/* LCD-Data(6) */
150a4d79993SHannes Schmelzer 	{OFFSET(lcd_data7), (MODE(0) | PULLUDDIS)},	/* LCD-Data(7) */
151a4d79993SHannes Schmelzer 	{OFFSET(lcd_data8), (MODE(0) | PULLUDDIS)},	/* LCD-Data(8) */
152a4d79993SHannes Schmelzer 	{OFFSET(lcd_data9), (MODE(0) | PULLUDDIS)},	/* LCD-Data(9) */
153a4d79993SHannes Schmelzer 	{OFFSET(lcd_data10), (MODE(0) | PULLUDDIS)},	/* LCD-Data(10) */
154a4d79993SHannes Schmelzer 	{OFFSET(lcd_data11), (MODE(0) | PULLUDDIS)},	/* LCD-Data(11) */
155a4d79993SHannes Schmelzer 	{OFFSET(lcd_data12), (MODE(0) | PULLUDDIS)},	/* LCD-Data(12) */
156a4d79993SHannes Schmelzer 	{OFFSET(lcd_data13), (MODE(0) | PULLUDDIS)},	/* LCD-Data(13) */
157a4d79993SHannes Schmelzer 	{OFFSET(lcd_data14), (MODE(0) | PULLUDDIS)},	/* LCD-Data(14) */
158a4d79993SHannes Schmelzer 	{OFFSET(lcd_data15), (MODE(0) | PULLUDDIS)},	/* LCD-Data(15) */
159a4d79993SHannes Schmelzer 
160a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad8), (MODE(1) | PULLUDDIS)},	/* LCD-Data(16) */
161a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad9), (MODE(1) | PULLUDDIS)},	/* LCD-Data(17) */
162a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad10), (MODE(1) | PULLUDDIS)},	/* LCD-Data(18) */
163a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad11), (MODE(1) | PULLUDDIS)},	/* LCD-Data(19) */
164a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad12), (MODE(1) | PULLUDDIS)},	/* LCD-Data(20) */
165a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad13), (MODE(1) | PULLUDDIS)},	/* LCD-Data(21) */
166a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad14), (MODE(1) | PULLUDDIS)},	/* LCD-Data(22) */
167a4d79993SHannes Schmelzer 	{OFFSET(gpmc_ad15), (MODE(1) | PULLUDDIS)},	/* LCD-Data(23) */
168a4d79993SHannes Schmelzer 
169a4d79993SHannes Schmelzer 	{OFFSET(lcd_vsync), (MODE(0) | PULLUDDIS)},	/* LCD-VSync */
170a4d79993SHannes Schmelzer 	{OFFSET(lcd_hsync), (MODE(0) | PULLUDDIS)},	/* LCD-HSync */
171a4d79993SHannes Schmelzer 	{OFFSET(lcd_ac_bias_en), (MODE(0) | PULLUDDIS)},/* LCD-DE */
172a4d79993SHannes Schmelzer 	{OFFSET(lcd_pclk), (MODE(0) | PULLUDDIS)},	/* LCD-CLK */
173a4d79993SHannes Schmelzer 
174a4d79993SHannes Schmelzer 	{-1},
175a4d79993SHannes Schmelzer };
176a4d79993SHannes Schmelzer 
enable_uart0_pin_mux(void)177a4d79993SHannes Schmelzer void enable_uart0_pin_mux(void)
178a4d79993SHannes Schmelzer {
179a4d79993SHannes Schmelzer 	configure_module_pin_mux(uart0_pin_mux);
180a4d79993SHannes Schmelzer }
181a4d79993SHannes Schmelzer 
enable_i2c_pin_mux(void)182a4d79993SHannes Schmelzer void enable_i2c_pin_mux(void)
183a4d79993SHannes Schmelzer {
184a4d79993SHannes Schmelzer 	configure_module_pin_mux(i2c0_pin_mux);
185a4d79993SHannes Schmelzer }
186a4d79993SHannes Schmelzer 
enable_board_pin_mux(void)187a4d79993SHannes Schmelzer void enable_board_pin_mux(void)
188a4d79993SHannes Schmelzer {
189a4d79993SHannes Schmelzer 	configure_module_pin_mux(i2c0_pin_mux);
190a4d79993SHannes Schmelzer 	configure_module_pin_mux(mii1_pin_mux);
191a4d79993SHannes Schmelzer 	configure_module_pin_mux(spi0_pin_mux);
192a4d79993SHannes Schmelzer 	configure_module_pin_mux(dcan0_pin_mux);
193a4d79993SHannes Schmelzer 	configure_module_pin_mux(dcan1_pin_mux);
194a4d79993SHannes Schmelzer 	configure_module_pin_mux(mmc1_pin_mux);
195a4d79993SHannes Schmelzer 	configure_module_pin_mux(lcd_pin_mux);
196a4d79993SHannes Schmelzer 	configure_module_pin_mux(gpios);
197a4d79993SHannes Schmelzer }
198