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