blob: 41333f93f40dc57fedfcbaec51b93f2aa9446cd9 [file] [log] [blame]
Chandan Nath7d744102011-10-14 02:58:26 +00001/*
2 * mux.c
3 *
4 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation version 2.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
Tom Rini7a247722012-07-31 10:50:01 -070016#include <common.h>
17#include <asm/arch/sys_proto.h>
Chandan Nath7d744102011-10-14 02:58:26 +000018#include <asm/arch/hardware.h>
Peter Korsgaard5d3f6822012-10-18 01:21:11 +000019#include <asm/arch/mux.h>
Chandan Nath7d744102011-10-14 02:58:26 +000020#include <asm/io.h>
Tom Rini184fffa2012-08-08 09:03:07 -070021#include <i2c.h>
Nishanth Menon2afa70d2016-02-24 12:30:55 -060022#include "../common/board_detect.h"
Peter Korsgaard85ec2db2012-10-18 01:21:09 +000023#include "board.h"
Chandan Nath7d744102011-10-14 02:58:26 +000024
Chandan Nath7d744102011-10-14 02:58:26 +000025static struct module_pin_mux uart0_pin_mux[] = {
26 {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART0_RXD */
27 {OFFSET(uart0_txd), (MODE(0) | PULLUDEN)}, /* UART0_TXD */
28 {-1},
29};
30
Andrew Bradford65c51ff2012-10-25 08:21:30 -040031static struct module_pin_mux uart1_pin_mux[] = {
32 {OFFSET(uart1_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART1_RXD */
33 {OFFSET(uart1_txd), (MODE(0) | PULLUDEN)}, /* UART1_TXD */
34 {-1},
35};
36
37static struct module_pin_mux uart2_pin_mux[] = {
38 {OFFSET(spi0_sclk), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART2_RXD */
39 {OFFSET(spi0_d0), (MODE(1) | PULLUDEN)}, /* UART2_TXD */
40 {-1},
41};
42
43static struct module_pin_mux uart3_pin_mux[] = {
44 {OFFSET(spi0_cs1), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART3_RXD */
45 {OFFSET(ecap0_in_pwm0_out), (MODE(1) | PULLUDEN)}, /* UART3_TXD */
46 {-1},
47};
48
49static struct module_pin_mux uart4_pin_mux[] = {
50 {OFFSET(gpmc_wait0), (MODE(6) | PULLUP_EN | RXACTIVE)}, /* UART4_RXD */
51 {OFFSET(gpmc_wpn), (MODE(6) | PULLUDEN)}, /* UART4_TXD */
52 {-1},
53};
54
55static struct module_pin_mux uart5_pin_mux[] = {
56 {OFFSET(lcd_data9), (MODE(4) | PULLUP_EN | RXACTIVE)}, /* UART5_RXD */
57 {OFFSET(lcd_data8), (MODE(4) | PULLUDEN)}, /* UART5_TXD */
58 {-1},
59};
60
Chandan Nathd6e97f82012-01-09 20:38:58 +000061static struct module_pin_mux mmc0_pin_mux[] = {
62 {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */
63 {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */
64 {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */
65 {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */
66 {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */
67 {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */
68 {OFFSET(mcasp0_aclkr), (MODE(4) | RXACTIVE)}, /* MMC0_WP */
Mugunthan V N75bc0032015-10-13 14:02:29 +053069 {OFFSET(spi0_cs1), (MODE(7) | RXACTIVE | PULLUP_EN)}, /* GPIO0_6 */
Chandan Nathd6e97f82012-01-09 20:38:58 +000070 {-1},
71};
Tom Rini7a247722012-07-31 10:50:01 -070072
Matthias Fuchs63ffc5a2012-11-02 03:35:59 +000073static struct module_pin_mux mmc0_no_cd_pin_mux[] = {
74 {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */
75 {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */
76 {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */
77 {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */
78 {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */
79 {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */
80 {OFFSET(mcasp0_aclkr), (MODE(4) | RXACTIVE)}, /* MMC0_WP */
81 {-1},
82};
83
Tom Rini7a247722012-07-31 10:50:01 -070084static struct module_pin_mux mmc0_pin_mux_sk_evm[] = {
85 {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */
86 {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */
87 {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */
88 {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */
89 {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */
90 {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */
91 {OFFSET(spi0_cs1), (MODE(5) | RXACTIVE | PULLUP_EN)}, /* MMC0_CD */
92 {-1},
93};
Chandan Nathd6e97f82012-01-09 20:38:58 +000094
Tom Rini9670a1e2012-08-08 10:32:09 -070095static struct module_pin_mux mmc1_pin_mux[] = {
96 {OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT3 */
97 {OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT2 */
98 {OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT1 */
99 {OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT0 */
100 {OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CLK */
101 {OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CMD */
102 {OFFSET(gpmc_csn0), (MODE(7) | RXACTIVE | PULLUP_EN)}, /* MMC1_WP */
103 {OFFSET(gpmc_advn_ale), (MODE(7) | RXACTIVE | PULLUP_EN)}, /* MMC1_CD */
104 {-1},
105};
106
Patil, Rachna5f70c512012-01-22 23:47:01 +0000107static struct module_pin_mux i2c0_pin_mux[] = {
108 {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE |
109 PULLUDEN | SLEWCTRL)}, /* I2C_DATA */
110 {OFFSET(i2c0_scl), (MODE(0) | RXACTIVE |
111 PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */
112 {-1},
113};
114
Steve Sakoman695b1fe2012-06-22 07:45:57 +0000115static struct module_pin_mux i2c1_pin_mux[] = {
116 {OFFSET(spi0_d1), (MODE(2) | RXACTIVE |
117 PULLUDEN | SLEWCTRL)}, /* I2C_DATA */
118 {OFFSET(spi0_cs0), (MODE(2) | RXACTIVE |
119 PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */
120 {-1},
121};
122
Tom Rini883401e2012-08-08 14:35:55 -0700123static struct module_pin_mux spi0_pin_mux[] = {
124 {OFFSET(spi0_sclk), (MODE(0) | RXACTIVE | PULLUDEN)}, /* SPI0_SCLK */
125 {OFFSET(spi0_d0), (MODE(0) | RXACTIVE |
126 PULLUDEN | PULLUP_EN)}, /* SPI0_D0 */
127 {OFFSET(spi0_d1), (MODE(0) | RXACTIVE | PULLUDEN)}, /* SPI0_D1 */
128 {OFFSET(spi0_cs0), (MODE(0) | RXACTIVE |
129 PULLUDEN | PULLUP_EN)}, /* SPI0_CS0 */
130 {-1},
131};
132
Tom Rini4b302402012-07-31 08:55:01 -0700133static struct module_pin_mux gpio0_7_pin_mux[] = {
134 {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN)}, /* GPIO0_7 */
135 {-1},
136};
137
Lokesh Vutla3112ea22016-05-16 11:47:23 +0530138static struct module_pin_mux gpio0_18_pin_mux[] = {
139 {OFFSET(usb0_drvvbus), (MODE(7) | PULLUDEN)}, /* GPIO0_18 */
140 {-1},
141};
142
Chandan Nathb79a12e2012-07-24 12:22:18 +0000143static struct module_pin_mux rgmii1_pin_mux[] = {
144 {OFFSET(mii1_txen), MODE(2)}, /* RGMII1_TCTL */
145 {OFFSET(mii1_rxdv), MODE(2) | RXACTIVE}, /* RGMII1_RCTL */
146 {OFFSET(mii1_txd3), MODE(2)}, /* RGMII1_TD3 */
147 {OFFSET(mii1_txd2), MODE(2)}, /* RGMII1_TD2 */
148 {OFFSET(mii1_txd1), MODE(2)}, /* RGMII1_TD1 */
149 {OFFSET(mii1_txd0), MODE(2)}, /* RGMII1_TD0 */
150 {OFFSET(mii1_txclk), MODE(2)}, /* RGMII1_TCLK */
151 {OFFSET(mii1_rxclk), MODE(2) | RXACTIVE}, /* RGMII1_RCLK */
152 {OFFSET(mii1_rxd3), MODE(2) | RXACTIVE}, /* RGMII1_RD3 */
153 {OFFSET(mii1_rxd2), MODE(2) | RXACTIVE}, /* RGMII1_RD2 */
154 {OFFSET(mii1_rxd1), MODE(2) | RXACTIVE}, /* RGMII1_RD1 */
155 {OFFSET(mii1_rxd0), MODE(2) | RXACTIVE}, /* RGMII1_RD0 */
156 {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */
157 {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */
158 {-1},
159};
160
161static struct module_pin_mux mii1_pin_mux[] = {
162 {OFFSET(mii1_rxerr), MODE(0) | RXACTIVE}, /* MII1_RXERR */
163 {OFFSET(mii1_txen), MODE(0)}, /* MII1_TXEN */
164 {OFFSET(mii1_rxdv), MODE(0) | RXACTIVE}, /* MII1_RXDV */
165 {OFFSET(mii1_txd3), MODE(0)}, /* MII1_TXD3 */
166 {OFFSET(mii1_txd2), MODE(0)}, /* MII1_TXD2 */
167 {OFFSET(mii1_txd1), MODE(0)}, /* MII1_TXD1 */
168 {OFFSET(mii1_txd0), MODE(0)}, /* MII1_TXD0 */
169 {OFFSET(mii1_txclk), MODE(0) | RXACTIVE}, /* MII1_TXCLK */
170 {OFFSET(mii1_rxclk), MODE(0) | RXACTIVE}, /* MII1_RXCLK */
171 {OFFSET(mii1_rxd3), MODE(0) | RXACTIVE}, /* MII1_RXD3 */
172 {OFFSET(mii1_rxd2), MODE(0) | RXACTIVE}, /* MII1_RXD2 */
173 {OFFSET(mii1_rxd1), MODE(0) | RXACTIVE}, /* MII1_RXD1 */
174 {OFFSET(mii1_rxd0), MODE(0) | RXACTIVE}, /* MII1_RXD0 */
175 {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
176 {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */
Lokesh Vutla3112ea22016-05-16 11:47:23 +0530177 {-1},
178};
179
180static struct module_pin_mux rmii1_pin_mux[] = {
181 {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */
182 {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN}, /* MDIO_DATA */
183 {OFFSET(mii1_crs), MODE(1) | RXACTIVE}, /* MII1_CRS */
184 {OFFSET(mii1_rxerr), MODE(1) | RXACTIVE}, /* MII1_RXERR */
185 {OFFSET(mii1_txen), MODE(1)}, /* MII1_TXEN */
186 {OFFSET(mii1_txd1), MODE(1)}, /* MII1_TXD1 */
187 {OFFSET(mii1_txd0), MODE(1)}, /* MII1_TXD0 */
188 {OFFSET(mii1_rxd1), MODE(1) | RXACTIVE}, /* MII1_RXD1 */
189 {OFFSET(mii1_rxd0), MODE(1) | RXACTIVE}, /* MII1_RXD0 */
190 {OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_REFCLK */
Chandan Nathb79a12e2012-07-24 12:22:18 +0000191 {-1},
192};
193
pekon gupta2badbde2014-07-22 16:03:20 +0530194#ifdef CONFIG_NAND
Ilya Yanokfd056552012-11-06 13:06:29 +0000195static struct module_pin_mux nand_pin_mux[] = {
pekon gupta2badbde2014-07-22 16:03:20 +0530196 {OFFSET(gpmc_ad0), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD0 */
197 {OFFSET(gpmc_ad1), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD1 */
198 {OFFSET(gpmc_ad2), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD2 */
199 {OFFSET(gpmc_ad3), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD3 */
200 {OFFSET(gpmc_ad4), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD4 */
201 {OFFSET(gpmc_ad5), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD5 */
202 {OFFSET(gpmc_ad6), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD6 */
203 {OFFSET(gpmc_ad7), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD7 */
204#ifdef CONFIG_SYS_NAND_BUSWIDTH_16BIT
205 {OFFSET(gpmc_ad8), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD8 */
206 {OFFSET(gpmc_ad9), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD9 */
207 {OFFSET(gpmc_ad10), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD10 */
208 {OFFSET(gpmc_ad11), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD11 */
209 {OFFSET(gpmc_ad12), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD12 */
210 {OFFSET(gpmc_ad13), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD13 */
211 {OFFSET(gpmc_ad14), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD14 */
212 {OFFSET(gpmc_ad15), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD15 */
213#endif
214 {OFFSET(gpmc_wait0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* nWAIT */
215 {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN)}, /* nWP */
216 {OFFSET(gpmc_csn0), (MODE(0) | PULLUP_EN)}, /* nCS */
217 {OFFSET(gpmc_wen), (MODE(0) | PULLDOWN_EN)}, /* WEN */
218 {OFFSET(gpmc_oen_ren), (MODE(0) | PULLDOWN_EN)}, /* OE */
219 {OFFSET(gpmc_advn_ale), (MODE(0) | PULLDOWN_EN)}, /* ADV_ALE */
220 {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLDOWN_EN)}, /* BE_CLE */
Ilya Yanokfd056552012-11-06 13:06:29 +0000221 {-1},
222};
pekon gupta0efbdcf2014-07-22 16:03:21 +0530223#elif defined(CONFIG_NOR)
Steve Kipiszbe9b6f82013-07-18 15:13:03 -0400224static struct module_pin_mux bone_norcape_pin_mux[] = {
pekon gupta0efbdcf2014-07-22 16:03:21 +0530225 {OFFSET(gpmc_a0), MODE(0) | PULLUDDIS}, /* NOR_A0 */
226 {OFFSET(gpmc_a1), MODE(0) | PULLUDDIS}, /* NOR_A1 */
227 {OFFSET(gpmc_a2), MODE(0) | PULLUDDIS}, /* NOR_A2 */
228 {OFFSET(gpmc_a3), MODE(0) | PULLUDDIS}, /* NOR_A3 */
229 {OFFSET(gpmc_a4), MODE(0) | PULLUDDIS}, /* NOR_A4 */
230 {OFFSET(gpmc_a5), MODE(0) | PULLUDDIS}, /* NOR_A5 */
231 {OFFSET(gpmc_a6), MODE(0) | PULLUDDIS}, /* NOR_A6 */
232 {OFFSET(gpmc_a7), MODE(0) | PULLUDDIS}, /* NOR_A7 */
233 {OFFSET(gpmc_ad0), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD0 */
234 {OFFSET(gpmc_ad1), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD1 */
235 {OFFSET(gpmc_ad2), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD2 */
236 {OFFSET(gpmc_ad3), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD3 */
237 {OFFSET(gpmc_ad4), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD4 */
238 {OFFSET(gpmc_ad5), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD5 */
239 {OFFSET(gpmc_ad6), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD6 */
240 {OFFSET(gpmc_ad7), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD7 */
241 {OFFSET(gpmc_ad8), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD8 */
242 {OFFSET(gpmc_ad9), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD9 */
243 {OFFSET(gpmc_ad10), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD10 */
244 {OFFSET(gpmc_ad11), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD11 */
245 {OFFSET(gpmc_ad12), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD12 */
246 {OFFSET(gpmc_ad13), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD13 */
247 {OFFSET(gpmc_ad14), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD14 */
248 {OFFSET(gpmc_ad15), MODE(0) | PULLUDDIS | RXACTIVE}, /* NOR_AD15 */
249 {OFFSET(gpmc_csn0), MODE(0) | PULLUDEN | PULLUP_EN}, /* CE */
250 {OFFSET(gpmc_advn_ale), MODE(0) | PULLUDEN | PULLDOWN_EN}, /* ALE */
251 {OFFSET(gpmc_oen_ren), MODE(0) | PULLUDEN | PULLDOWN_EN},/* OEn_REN */
252 {OFFSET(gpmc_be0n_cle), MODE(0) | PULLUDEN | PULLDOWN_EN},/* unused */
253 {OFFSET(gpmc_wen), MODE(0) | PULLUDEN | PULLDOWN_EN}, /* WEN */
254 {OFFSET(gpmc_wait0), MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE},/*WAIT*/
Steve Kipiszbe9b6f82013-07-18 15:13:03 -0400255 {-1},
256};
257#endif
258
Lokesh Vutla3112ea22016-05-16 11:47:23 +0530259static struct module_pin_mux uart3_icev2_pin_mux[] = {
260 {OFFSET(mii1_rxd3), (MODE(1) | PULLUP_EN | RXACTIVE)}, /* UART3_RXD */
261 {OFFSET(mii1_rxd2), MODE(1) | PULLUDEN}, /* UART3_TXD */
262 {-1},
263};
264
Heiko Schocherb21f2ac2013-07-30 10:48:54 +0530265#if defined(CONFIG_NOR_BOOT)
Heiko Schocherb21f2ac2013-07-30 10:48:54 +0530266void enable_norboot_pin_mux(void)
267{
pekon gupta0efbdcf2014-07-22 16:03:21 +0530268 configure_module_pin_mux(bone_norcape_pin_mux);
Heiko Schocherb21f2ac2013-07-30 10:48:54 +0530269}
270#endif
Steve Kipiszbe9b6f82013-07-18 15:13:03 -0400271
Chandan Nath7d744102011-10-14 02:58:26 +0000272void enable_uart0_pin_mux(void)
273{
274 configure_module_pin_mux(uart0_pin_mux);
275}
Chandan Nathd6e97f82012-01-09 20:38:58 +0000276
Andrew Bradford65c51ff2012-10-25 08:21:30 -0400277void enable_uart1_pin_mux(void)
278{
279 configure_module_pin_mux(uart1_pin_mux);
280}
281
282void enable_uart2_pin_mux(void)
283{
284 configure_module_pin_mux(uart2_pin_mux);
285}
286
287void enable_uart3_pin_mux(void)
288{
289 configure_module_pin_mux(uart3_pin_mux);
290}
291
292void enable_uart4_pin_mux(void)
293{
294 configure_module_pin_mux(uart4_pin_mux);
295}
296
297void enable_uart5_pin_mux(void)
298{
299 configure_module_pin_mux(uart5_pin_mux);
300}
Patil, Rachna5f70c512012-01-22 23:47:01 +0000301
302void enable_i2c0_pin_mux(void)
303{
304 configure_module_pin_mux(i2c0_pin_mux);
305}
Steve Sakoman695b1fe2012-06-22 07:45:57 +0000306
Tom Rini184fffa2012-08-08 09:03:07 -0700307/*
308 * The AM335x GP EVM, if daughter card(s) are connected, can have 8
309 * different profiles. These profiles determine what peripherals are
310 * valid and need pinmux to be configured.
311 */
312#define PROFILE_NONE 0x0
313#define PROFILE_0 (1 << 0)
314#define PROFILE_1 (1 << 1)
315#define PROFILE_2 (1 << 2)
316#define PROFILE_3 (1 << 3)
317#define PROFILE_4 (1 << 4)
318#define PROFILE_5 (1 << 5)
319#define PROFILE_6 (1 << 6)
320#define PROFILE_7 (1 << 7)
321#define PROFILE_MASK 0x7
322#define PROFILE_ALL 0xFF
323
324/* CPLD registers */
325#define I2C_CPLD_ADDR 0x35
326#define CFG_REG 0x10
327
328static unsigned short detect_daughter_board_profile(void)
Steve Sakoman695b1fe2012-06-22 07:45:57 +0000329{
Tom Rini184fffa2012-08-08 09:03:07 -0700330 unsigned short val;
Chandan Nathb79a12e2012-07-24 12:22:18 +0000331
Tom Rini184fffa2012-08-08 09:03:07 -0700332 if (i2c_probe(I2C_CPLD_ADDR))
333 return PROFILE_NONE;
334
335 if (i2c_read(I2C_CPLD_ADDR, CFG_REG, 1, (unsigned char *)(&val), 2))
336 return PROFILE_NONE;
337
338 return (1 << (val & PROFILE_MASK));
339}
340
Nishanth Menon2afa70d2016-02-24 12:30:55 -0600341void enable_board_pin_mux(void)
Tom Rini184fffa2012-08-08 09:03:07 -0700342{
343 /* Do board-specific muxes. */
Nishanth Menon2afa70d2016-02-24 12:30:55 -0600344 if (board_is_bone()) {
Tom Rini7a247722012-07-31 10:50:01 -0700345 /* Beaglebone pinmux */
346 configure_module_pin_mux(mii1_pin_mux);
347 configure_module_pin_mux(mmc0_pin_mux);
pekon gupta2badbde2014-07-22 16:03:20 +0530348#if defined(CONFIG_NAND)
349 configure_module_pin_mux(nand_pin_mux);
pekon gupta0efbdcf2014-07-22 16:03:21 +0530350#elif defined(CONFIG_NOR)
Steve Kipiszbe9b6f82013-07-18 15:13:03 -0400351 configure_module_pin_mux(bone_norcape_pin_mux);
pekon gupta2badbde2014-07-22 16:03:20 +0530352#else
353 configure_module_pin_mux(mmc1_pin_mux);
Steve Kipiszbe9b6f82013-07-18 15:13:03 -0400354#endif
Nishanth Menon2afa70d2016-02-24 12:30:55 -0600355 } else if (board_is_gp_evm()) {
Tom Rini7a247722012-07-31 10:50:01 -0700356 /* General Purpose EVM */
Tom Rini184fffa2012-08-08 09:03:07 -0700357 unsigned short profile = detect_daughter_board_profile();
Tom Rini7a247722012-07-31 10:50:01 -0700358 configure_module_pin_mux(rgmii1_pin_mux);
359 configure_module_pin_mux(mmc0_pin_mux);
Tom Rini184fffa2012-08-08 09:03:07 -0700360 /* In profile #2 i2c1 and spi0 conflict. */
361 if (profile & ~PROFILE_2)
362 configure_module_pin_mux(i2c1_pin_mux);
Ilya Yanokfd056552012-11-06 13:06:29 +0000363 /* Profiles 2 & 3 don't have NAND */
pekon gupta2badbde2014-07-22 16:03:20 +0530364#ifdef CONFIG_NAND
Ilya Yanokfd056552012-11-06 13:06:29 +0000365 if (profile & ~(PROFILE_2 | PROFILE_3))
366 configure_module_pin_mux(nand_pin_mux);
pekon gupta2badbde2014-07-22 16:03:20 +0530367#endif
Tom Rini9670a1e2012-08-08 10:32:09 -0700368 else if (profile == PROFILE_2) {
369 configure_module_pin_mux(mmc1_pin_mux);
Tom Rini883401e2012-08-08 14:35:55 -0700370 configure_module_pin_mux(spi0_pin_mux);
Tom Rini9670a1e2012-08-08 10:32:09 -0700371 }
Nishanth Menon2afa70d2016-02-24 12:30:55 -0600372 } else if (board_is_idk()) {
Tom Rini986d7552014-08-01 09:53:24 -0400373 /* Industrial Motor Control (IDK) */
Matthias Fuchs63ffc5a2012-11-02 03:35:59 +0000374 configure_module_pin_mux(mii1_pin_mux);
375 configure_module_pin_mux(mmc0_no_cd_pin_mux);
Nishanth Menon2afa70d2016-02-24 12:30:55 -0600376 } else if (board_is_evm_sk()) {
Tom Rini7a247722012-07-31 10:50:01 -0700377 /* Starter Kit EVM */
Tom Rini184fffa2012-08-08 09:03:07 -0700378 configure_module_pin_mux(i2c1_pin_mux);
Tom Rini7a247722012-07-31 10:50:01 -0700379 configure_module_pin_mux(gpio0_7_pin_mux);
380 configure_module_pin_mux(rgmii1_pin_mux);
381 configure_module_pin_mux(mmc0_pin_mux_sk_evm);
Nishanth Menon2afa70d2016-02-24 12:30:55 -0600382 } else if (board_is_bone_lt()) {
Koen Kooi8a157862018-07-18 10:13:59 +0200383 if (board_is_bben()) {
384 /* SanCloud Beaglebone LT Enhanced pinmux */
385 configure_module_pin_mux(rgmii1_pin_mux);
386 } else {
387 /* Beaglebone LT pinmux */
388 configure_module_pin_mux(mii1_pin_mux);
389 }
Koen Kooi95e79472012-10-23 01:56:40 +0000390 /* Beaglebone LT pinmux */
Koen Kooi95e79472012-10-23 01:56:40 +0000391 configure_module_pin_mux(mii1_pin_mux);
392 configure_module_pin_mux(mmc0_pin_mux);
Tom Rinief4c4812014-10-08 17:10:27 -0400393#if defined(CONFIG_NAND) && defined(CONFIG_EMMC_BOOT)
pekon gupta2badbde2014-07-22 16:03:20 +0530394 configure_module_pin_mux(nand_pin_mux);
Tom Rinief4c4812014-10-08 17:10:27 -0400395#elif defined(CONFIG_NOR) && defined(CONFIG_EMMC_BOOT)
pekon gupta0efbdcf2014-07-22 16:03:21 +0530396 configure_module_pin_mux(bone_norcape_pin_mux);
pekon gupta2badbde2014-07-22 16:03:20 +0530397#else
Koen Kooi95e79472012-10-23 01:56:40 +0000398 configure_module_pin_mux(mmc1_pin_mux);
pekon gupta2badbde2014-07-22 16:03:20 +0530399#endif
Jason Kridnerb56b5b32018-03-07 05:40:41 -0500400 } else if (board_is_pb()) {
401 configure_module_pin_mux(mii1_pin_mux);
402 configure_module_pin_mux(mmc0_pin_mux);
Lokesh Vutla3112ea22016-05-16 11:47:23 +0530403 } else if (board_is_icev2()) {
404 configure_module_pin_mux(mmc0_pin_mux);
405 configure_module_pin_mux(gpio0_18_pin_mux);
406 configure_module_pin_mux(uart3_icev2_pin_mux);
407 configure_module_pin_mux(rmii1_pin_mux);
408 configure_module_pin_mux(spi0_pin_mux);
Tom Rini7a247722012-07-31 10:50:01 -0700409 } else {
Alex G7c195e62016-11-08 20:48:44 -0800410 /* Unknown board. We might still be able to boot. */
411 puts("Bad EEPROM or unknown board, cannot configure pinmux.");
Tom Rini7a247722012-07-31 10:50:01 -0700412 }
Tom Rini4b302402012-07-31 08:55:01 -0700413}