xref: /openbmc/u-boot/board/compulab/cm_t43/mux.c (revision ee7bb5be)
1 /*
2  * Copyright (C) 2015 Compulab, Ltd.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <asm/arch/sys_proto.h>
9 #include <asm/arch/mux.h>
10 #include "board.h"
11 
12 static struct module_pin_mux rgmii1_pin_mux[] = {
13 	{OFFSET(mii1_txen),  MODE(2)},
14 	{OFFSET(mii1_txd3),  MODE(2)},
15 	{OFFSET(mii1_txd2),  MODE(2)},
16 	{OFFSET(mii1_txd1),  MODE(2)},
17 	{OFFSET(mii1_txd0),  MODE(2)},
18 	{OFFSET(mii1_txclk), MODE(2)},
19 	{OFFSET(mii1_rxdv),  MODE(2) | RXACTIVE | PULLDOWN_EN},
20 	{OFFSET(mii1_rxclk), MODE(2) | RXACTIVE | PULLDOWN_EN},
21 	{OFFSET(mii1_rxd3),  MODE(2) | RXACTIVE | PULLDOWN_EN},
22 	{OFFSET(mii1_rxd2),  MODE(2) | RXACTIVE | PULLDOWN_EN},
23 	{OFFSET(mii1_rxd1),  MODE(2) | RXACTIVE | PULLDOWN_EN},
24 	{OFFSET(mii1_rxd0),  MODE(2) | RXACTIVE | PULLDOWN_EN},
25 	{-1},
26 };
27 
28 static struct module_pin_mux rgmii2_pin_mux[] = {
29 	{OFFSET(gpmc_a0),  MODE(2)}, /* txen */
30 	{OFFSET(gpmc_a2),  MODE(2)}, /* txd3 */
31 	{OFFSET(gpmc_a3),  MODE(2)}, /* txd2 */
32 	{OFFSET(gpmc_a4),  MODE(2)}, /* txd1 */
33 	{OFFSET(gpmc_a5),  MODE(2)}, /* txd0 */
34 	{OFFSET(gpmc_a6),  MODE(2)}, /* txclk */
35 	{OFFSET(gpmc_a1),  MODE(2) | RXACTIVE | PULLDOWN_EN}, /* rxvd */
36 	{OFFSET(gpmc_a7),  MODE(2) | RXACTIVE | PULLDOWN_EN}, /* rxclk */
37 	{OFFSET(gpmc_a8),  MODE(2) | RXACTIVE | PULLDOWN_EN}, /* rxd3 */
38 	{OFFSET(gpmc_a9),  MODE(2) | RXACTIVE | PULLDOWN_EN}, /* rxd2 */
39 	{OFFSET(gpmc_a10), MODE(2) | RXACTIVE | PULLDOWN_EN}, /* rxd1 */
40 	{OFFSET(gpmc_a11), MODE(2) | RXACTIVE | PULLUP_EN},   /* rxd0 */
41 	{-1},
42 };
43 
44 static struct module_pin_mux mdio_pin_mux[] = {
45 	{OFFSET(mdio_data), (MODE(0) | PULLUP_EN | RXACTIVE)},
46 	{OFFSET(mdio_clk),  (MODE(0) | PULLUP_EN)},
47 	{-1},
48 };
49 
50 static struct module_pin_mux uart0_pin_mux[] = {
51 	{OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE  | SLEWCTRL)},
52 	{OFFSET(uart0_txd), (MODE(0) | PULLUDDIS | PULLUP_EN | SLEWCTRL)},
53 	{-1},
54 };
55 
56 static struct module_pin_mux mmc0_pin_mux[] = {
57 	{OFFSET(mmc0_clk),  (MODE(0) | PULLUDDIS | RXACTIVE)},
58 	{OFFSET(mmc0_cmd),  (MODE(0) | PULLUP_EN | RXACTIVE)},
59 	{OFFSET(mmc0_dat0), (MODE(0) | PULLUP_EN | RXACTIVE)},
60 	{OFFSET(mmc0_dat1), (MODE(0) | PULLUP_EN | RXACTIVE)},
61 	{OFFSET(mmc0_dat2), (MODE(0) | PULLUP_EN | RXACTIVE)},
62 	{OFFSET(mmc0_dat3), (MODE(0) | PULLUP_EN | RXACTIVE)},
63 	{-1},
64 };
65 
66 static struct module_pin_mux i2c_pin_mux[] = {
67 	{OFFSET(i2c0_sda),  (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
68 	{OFFSET(i2c0_scl),  (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
69 	{OFFSET(spi2_sclk), (MODE(1) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
70 	{OFFSET(spi2_cs0),  (MODE(1) | PULLUP_EN | RXACTIVE | SLEWCTRL)},
71 	{-1},
72 };
73 
74 static struct module_pin_mux nand_pin_mux[] = {
75 	{OFFSET(gpmc_ad0),	(MODE(0) | PULLUDDIS | RXACTIVE)},
76 	{OFFSET(gpmc_ad1),	(MODE(0) | PULLUDDIS | RXACTIVE)},
77 	{OFFSET(gpmc_ad2),	(MODE(0) | PULLUDDIS | RXACTIVE)},
78 	{OFFSET(gpmc_ad3),	(MODE(0) | PULLUDDIS | RXACTIVE)},
79 	{OFFSET(gpmc_ad4),	(MODE(0) | PULLUDDIS | RXACTIVE)},
80 	{OFFSET(gpmc_ad5),	(MODE(0) | PULLUDDIS | RXACTIVE)},
81 	{OFFSET(gpmc_ad6),	(MODE(0) | PULLUDDIS | RXACTIVE)},
82 	{OFFSET(gpmc_ad7),	(MODE(0) | PULLUDDIS | RXACTIVE)},
83 	{OFFSET(gpmc_wait0),	(MODE(0) | PULLUP_EN | RXACTIVE)},
84 	{OFFSET(gpmc_wpn),	(MODE(0) | PULLUP_EN)},
85 	{OFFSET(gpmc_csn0),	(MODE(0) | PULLUP_EN)},
86 	{OFFSET(gpmc_wen),	(MODE(0) | PULLDOWN_EN)},
87 	{OFFSET(gpmc_oen_ren),	(MODE(0) | PULLDOWN_EN)},
88 	{OFFSET(gpmc_advn_ale),	(MODE(0) | PULLDOWN_EN)},
89 	{OFFSET(gpmc_be0n_cle),	(MODE(0) | PULLDOWN_EN)},
90 	{-1},
91 };
92 
93 static struct module_pin_mux emmc_pin_mux[] = {
94 	{OFFSET(gpmc_csn1), (MODE(2) | PULLUDDIS | RXACTIVE)}, /* EMMC_CLK */
95 	{OFFSET(gpmc_csn2), (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_CMD */
96 	{OFFSET(gpmc_ad8),  (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_DAT0 */
97 	{OFFSET(gpmc_ad9),  (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_DAT1 */
98 	{OFFSET(gpmc_ad10), (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_DAT2 */
99 	{OFFSET(gpmc_ad11), (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_DAT3 */
100 	{OFFSET(gpmc_ad12), (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_DAT4 */
101 	{OFFSET(gpmc_ad13), (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_DAT5 */
102 	{OFFSET(gpmc_ad14), (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_DAT6 */
103 	{OFFSET(gpmc_ad15), (MODE(2) | PULLUP_EN | RXACTIVE)}, /* EMMC_DAT7 */
104 	{-1},
105 };
106 
107 static struct module_pin_mux spi_flash_pin_mux[] = {
108 	{OFFSET(spi0_d0),   (MODE(0) | RXACTIVE | PULLUDEN)},
109 	{OFFSET(spi0_d1),   (MODE(0) | RXACTIVE | PULLUDEN)},
110 	{OFFSET(spi0_cs0),  (MODE(0) | RXACTIVE | PULLUDEN)},
111 	{OFFSET(spi0_sclk), (MODE(0) | RXACTIVE | PULLUDEN)},
112 	{-1},
113 };
114 
115 void set_uart_mux_conf(void)
116 {
117 	configure_module_pin_mux(uart0_pin_mux);
118 }
119 
120 void set_mdio_pin_mux(void)
121 {
122 	configure_module_pin_mux(mdio_pin_mux);
123 }
124 
125 void set_rgmii_pin_mux(void)
126 {
127 	configure_module_pin_mux(rgmii1_pin_mux);
128 	configure_module_pin_mux(rgmii2_pin_mux);
129 }
130 
131 void set_mux_conf_regs(void)
132 {
133 	configure_module_pin_mux(mmc0_pin_mux);
134 	configure_module_pin_mux(emmc_pin_mux);
135 	configure_module_pin_mux(i2c_pin_mux);
136 	configure_module_pin_mux(spi_flash_pin_mux);
137 	configure_module_pin_mux(nand_pin_mux);
138 }
139 
140 void set_i2c_pin_mux(void)
141 {
142 	configure_module_pin_mux(i2c_pin_mux);
143 }
144