Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 1 | /* |
| 2 | * mux.c |
| 3 | * |
| 4 | * Pinmux Setting for B&R LEIT Board(s) |
| 5 | * |
| 6 | * Copyright (C) 2013 Hannes Petermaier <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 uart0_pin_mux[] = { |
| 20 | /* UART0_CTS */ |
| 21 | {OFFSET(uart0_ctsn), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 22 | /* UART0_RXD */ |
| 23 | {OFFSET(uart0_rxd), (MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 24 | /* UART0_TXD */ |
| 25 | {OFFSET(uart0_txd), (MODE(0) | PULLUDEN)}, |
| 26 | {-1}, |
| 27 | }; |
Hannes Petermaier | a6ec579 | 2015-02-03 13:22:33 +0100 | [diff] [blame] | 28 | static struct module_pin_mux uart1_pin_mux[] = { |
| 29 | /* UART0_RXD */ |
| 30 | {OFFSET(uart1_rxd), (MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 31 | /* UART0_TXD */ |
| 32 | {OFFSET(uart1_txd), (MODE(0) | PULLUDEN)}, |
| 33 | {-1}, |
| 34 | }; |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 35 | #ifdef CONFIG_MMC |
| 36 | static struct module_pin_mux mmc1_pin_mux[] = { |
Hannes Petermaier | 9a1063e | 2014-06-04 10:25:32 +0200 | [diff] [blame] | 37 | {OFFSET(gpmc_ad7), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT7 */ |
| 38 | {OFFSET(gpmc_ad6), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT6 */ |
| 39 | {OFFSET(gpmc_ad5), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT5 */ |
| 40 | {OFFSET(gpmc_ad4), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT4 */ |
| 41 | |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 42 | {OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT3 */ |
| 43 | {OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT2 */ |
| 44 | {OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT1 */ |
| 45 | {OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT0 */ |
| 46 | {OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CLK */ |
| 47 | {OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CMD */ |
| 48 | {OFFSET(gpmc_csn0), (MODE(7) | RXACTIVE | PULLUP_EN)}, /* MMC1_WP */ |
| 49 | {OFFSET(gpmc_advn_ale), (MODE(7) | RXACTIVE | PULLUP_EN)},/* MMC1_CD */ |
| 50 | {-1}, |
| 51 | }; |
| 52 | #endif |
| 53 | static struct module_pin_mux i2c0_pin_mux[] = { |
| 54 | /* I2C_DATA */ |
| 55 | {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)}, |
| 56 | /* I2C_SCLK */ |
| 57 | {OFFSET(i2c0_scl), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)}, |
| 58 | {-1}, |
| 59 | }; |
| 60 | |
| 61 | static struct module_pin_mux spi0_pin_mux[] = { |
| 62 | /* SPI0_SCLK */ |
| 63 | {OFFSET(spi0_sclk), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 64 | /* SPI0_D0 */ |
| 65 | {OFFSET(spi0_d0), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 66 | /* SPI0_D1 */ |
| 67 | {OFFSET(spi0_d1), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 68 | /* SPI0_CS0 */ |
| 69 | {OFFSET(spi0_cs0), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 70 | {-1}, |
| 71 | }; |
| 72 | |
| 73 | static struct module_pin_mux mii1_pin_mux[] = { |
Hannes Petermaier | 207828e | 2014-10-03 07:30:15 +0200 | [diff] [blame] | 74 | {OFFSET(mii1_crs), MODE(0) | RXACTIVE}, /* MII1_CRS */ |
| 75 | {OFFSET(mii1_col), MODE(0) | RXACTIVE}, /* MII1_COL */ |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 76 | {OFFSET(mii1_rxerr), MODE(0) | RXACTIVE}, /* MII1_RXERR */ |
| 77 | {OFFSET(mii1_txen), MODE(0)}, /* MII1_TXEN */ |
| 78 | {OFFSET(mii1_rxdv), MODE(0) | RXACTIVE}, /* MII1_RXDV */ |
| 79 | {OFFSET(mii1_txd3), MODE(0)}, /* MII1_TXD3 */ |
| 80 | {OFFSET(mii1_txd2), MODE(0)}, /* MII1_TXD2 */ |
| 81 | {OFFSET(mii1_txd1), MODE(0)}, /* MII1_TXD1 */ |
| 82 | {OFFSET(mii1_txd0), MODE(0)}, /* MII1_TXD0 */ |
| 83 | {OFFSET(mii1_txclk), MODE(0) | RXACTIVE}, /* MII1_TXCLK */ |
| 84 | {OFFSET(mii1_rxclk), MODE(0) | RXACTIVE}, /* MII1_RXCLK */ |
| 85 | {OFFSET(mii1_rxd3), MODE(0) | RXACTIVE}, /* MII1_RXD3 */ |
| 86 | {OFFSET(mii1_rxd2), MODE(0) | RXACTIVE}, /* MII1_RXD2 */ |
| 87 | {OFFSET(mii1_rxd1), MODE(0) | RXACTIVE}, /* MII1_RXD1 */ |
| 88 | {OFFSET(mii1_rxd0), MODE(0) | RXACTIVE}, /* MII1_RXD0 */ |
| 89 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */ |
| 90 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
| 91 | {-1}, |
| 92 | }; |
| 93 | |
| 94 | static struct module_pin_mux mii2_pin_mux[] = { |
| 95 | {OFFSET(gpmc_a0), MODE(1)}, /* MII2_TXEN */ |
| 96 | {OFFSET(gpmc_a1), MODE(1) | RXACTIVE}, /* MII2_RXDV */ |
| 97 | {OFFSET(gpmc_a2), MODE(1)}, /* MII2_TXD3 */ |
| 98 | {OFFSET(gpmc_a3), MODE(1)}, /* MII2_TXD2 */ |
| 99 | {OFFSET(gpmc_a4), MODE(1)}, /* MII2_TXD1 */ |
| 100 | {OFFSET(gpmc_a5), MODE(1)}, /* MII2_TXD0 */ |
| 101 | {OFFSET(gpmc_a6), MODE(1) | RXACTIVE}, /* MII2_TXCLK */ |
| 102 | {OFFSET(gpmc_a7), MODE(1) | RXACTIVE}, /* MII2_RXCLK */ |
| 103 | {OFFSET(gpmc_a8), MODE(1) | RXACTIVE}, /* MII2_RXD3 */ |
| 104 | {OFFSET(gpmc_a9), MODE(1) | RXACTIVE}, /* MII2_RXD2 */ |
| 105 | {OFFSET(gpmc_a10), MODE(1) | RXACTIVE}, /* MII2_RXD1 */ |
| 106 | {OFFSET(gpmc_a11), MODE(1) | RXACTIVE}, /* MII2_RXD0 */ |
| 107 | {OFFSET(gpmc_wpn), (MODE(1) | RXACTIVE)},/* MII2_RXERR */ |
Hannes Petermaier | 207828e | 2014-10-03 07:30:15 +0200 | [diff] [blame] | 108 | {OFFSET(gpmc_wait0), (MODE(1) | RXACTIVE | PULLUP_EN)}, |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 109 | /* |
| 110 | * MII2_CRS is shared with |
| 111 | * NAND_WAIT0 |
| 112 | */ |
| 113 | {OFFSET(gpmc_be1n), (MODE(1) | RXACTIVE)},/* MII1_COL */ |
| 114 | {-1}, |
| 115 | }; |
| 116 | #ifdef CONFIG_NAND |
| 117 | static struct module_pin_mux nand_pin_mux[] = { |
| 118 | {OFFSET(gpmc_ad0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD0 */ |
| 119 | {OFFSET(gpmc_ad1), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD1 */ |
| 120 | {OFFSET(gpmc_ad2), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD2 */ |
| 121 | {OFFSET(gpmc_ad3), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD3 */ |
| 122 | {OFFSET(gpmc_ad4), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD4 */ |
| 123 | {OFFSET(gpmc_ad5), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD5 */ |
| 124 | {OFFSET(gpmc_ad6), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD6 */ |
| 125 | {OFFSET(gpmc_ad7), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD7 */ |
Hannes Petermaier | d79c138 | 2015-04-08 07:38:34 +0200 | [diff] [blame^] | 126 | {OFFSET(gpmc_clk), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */ |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 127 | {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)}, /* NAND_WPN */ |
| 128 | {OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)}, /* NAND_CS0 */ |
| 129 | {OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */ |
| 130 | {OFFSET(gpmc_oen_ren), (MODE(0) | PULLUDEN)}, /* NAND_OE */ |
| 131 | {OFFSET(gpmc_wen), (MODE(0) | PULLUDEN)}, /* NAND_WEN */ |
| 132 | {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLUDEN)}, /* NAND_BE_CLE */ |
| 133 | {-1}, |
| 134 | }; |
| 135 | #endif |
| 136 | static struct module_pin_mux gpIOs[] = { |
| 137 | /* GPIO0_6 (SPI0_CS1) - 3v3_PWR_nEN (Display Power Supply) */ |
| 138 | {OFFSET(spi0_cs1), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 139 | /* TIMER5 (MMC0_DAT3) - TIMER5 (Buzzer) */ |
| 140 | {OFFSET(mmc0_dat3), (MODE(3) | PULLUDEN | RXACTIVE)}, |
Hannes Petermaier | 2f32ea7 | 2015-02-03 13:22:31 +0100 | [diff] [blame] | 141 | /* TIMER6 (MMC0_DAT2) - PWM_BACK_3V3 */ |
| 142 | {OFFSET(mmc0_dat2), (MODE(3) | PULLUDEN | RXACTIVE)}, |
| 143 | /* GPIO2_28 (MMC0_DAT1) - MII_nNAND */ |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 144 | {OFFSET(mmc0_dat1), (MODE(7) | PULLUDEN | RXACTIVE)}, |
| 145 | /* GPIO2_29 (MMC0_DAT0) - NAND_1n0 */ |
| 146 | {OFFSET(mmc0_dat0), (MODE(7) | PULLUDEN | RXACTIVE)}, |
| 147 | /* GPIO2_30 (MMC0_CLK) - nRESET (PHY) */ |
| 148 | {OFFSET(mmc0_clk), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 149 | /* GPIO3_18 (MCASP0_ACLKR) - CPLD JTAG TDI */ |
| 150 | {OFFSET(mcasp0_aclkr), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 151 | /* GPIO3_19 (MCASP0_FSR) - CPLD JTAG TMS */ |
| 152 | {OFFSET(mcasp0_fsr), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 153 | /* GPIO3_20 (MCASP0_AXR1) - CPLD JTAG TCK */ |
| 154 | {OFFSET(mcasp0_axr1), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 155 | /* GPIO3_21 (MCASP0_AHCLKX) - CPLD JTAG TDO */ |
| 156 | {OFFSET(mcasp0_ahclkx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 157 | /* GPIO2_0 (GPMC_nCS3) - DCOK */ |
| 158 | {OFFSET(gpmc_csn3), (MODE(7) | PULLUDDIS | RXACTIVE) }, |
| 159 | /* GPIO0_29 (RMII1_REFCLK) - eMMC nRST */ |
| 160 | {OFFSET(rmii1_refclk), (MODE(7) | PULLUDDIS | RXACTIVE) }, |
| 161 | /* |
| 162 | * GPIO0_7 (PWW0 OUT) |
| 163 | * DISPLAY_ONOFF (Backlight Enable at LVDS Versions) |
| 164 | */ |
| 165 | {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN | RXACTIVE)}, |
Hannes Petermaier | 1ab6f61 | 2014-06-04 10:37:12 +0200 | [diff] [blame] | 166 | /* GPIO0_19 (DMA_INTR0) - DISPLAY_MODE (CPLD) */ |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 167 | {OFFSET(xdma_event_intr0), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 168 | /* GPIO0_20 (DMA_INTR1) - REP-Switch */ |
| 169 | {OFFSET(xdma_event_intr1), (MODE(7) | PULLUP_EN | RXACTIVE)}, |
| 170 | /* GPIO3_14 (MCASP0_ACLKX) - frei / PP709 */ |
| 171 | {OFFSET(mcasp0_aclkx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE) }, |
| 172 | /* GPIO3_15 (MCASP0_FSX) - PMIC_nRESET */ |
| 173 | {OFFSET(mcasp0_fsx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE) }, |
| 174 | /* GPIO3_16 (MCASP0_AXR0) - ETH1_LEDY */ |
| 175 | {OFFSET(mcasp0_axr0), (MODE(7) | PULLUDDIS) }, |
| 176 | /* GPIO3_17 (MCASP0_AHCLKR) - ETH2_LEDY */ |
| 177 | {OFFSET(mcasp0_ahclkr), (MODE(7) | PULLUDDIS) }, |
Hannes Petermaier | 71d75d1 | 2015-02-03 13:22:32 +0100 | [diff] [blame] | 178 | #ifndef CONFIG_NAND |
| 179 | /* GPIO2_3 - NAND_OE */ |
| 180 | {OFFSET(gpmc_oen_ren), (MODE(7) | PULLDOWN_EN | RXACTIVE)}, |
| 181 | /* GPIO2_4 - NAND_WEN */ |
| 182 | {OFFSET(gpmc_wen), (MODE(7) | PULLDOWN_EN | RXACTIVE)}, |
| 183 | /* GPIO2_5 - NAND_BE_CLE */ |
| 184 | {OFFSET(gpmc_be0n_cle), (MODE(7) | PULLDOWN_EN | RXACTIVE)}, |
| 185 | #endif |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 186 | {-1}, |
| 187 | }; |
| 188 | |
| 189 | static struct module_pin_mux lcd_pin_mux[] = { |
| 190 | {OFFSET(lcd_data0), (MODE(0) | PULLUDDIS)}, /* LCD-Data(0) */ |
| 191 | {OFFSET(lcd_data1), (MODE(0) | PULLUDDIS)}, /* LCD-Data(1) */ |
| 192 | {OFFSET(lcd_data2), (MODE(0) | PULLUDDIS)}, /* LCD-Data(2) */ |
| 193 | {OFFSET(lcd_data3), (MODE(0) | PULLUDDIS)}, /* LCD-Data(3) */ |
| 194 | {OFFSET(lcd_data4), (MODE(0) | PULLUDDIS)}, /* LCD-Data(4) */ |
| 195 | {OFFSET(lcd_data5), (MODE(0) | PULLUDDIS)}, /* LCD-Data(5) */ |
| 196 | {OFFSET(lcd_data6), (MODE(0) | PULLUDDIS)}, /* LCD-Data(6) */ |
| 197 | {OFFSET(lcd_data7), (MODE(0) | PULLUDDIS)}, /* LCD-Data(7) */ |
| 198 | {OFFSET(lcd_data8), (MODE(0) | PULLUDDIS)}, /* LCD-Data(8) */ |
| 199 | {OFFSET(lcd_data9), (MODE(0) | PULLUDDIS)}, /* LCD-Data(9) */ |
| 200 | {OFFSET(lcd_data10), (MODE(0) | PULLUDDIS)}, /* LCD-Data(10) */ |
| 201 | {OFFSET(lcd_data11), (MODE(0) | PULLUDDIS)}, /* LCD-Data(11) */ |
| 202 | {OFFSET(lcd_data12), (MODE(0) | PULLUDDIS)}, /* LCD-Data(12) */ |
| 203 | {OFFSET(lcd_data13), (MODE(0) | PULLUDDIS)}, /* LCD-Data(13) */ |
| 204 | {OFFSET(lcd_data14), (MODE(0) | PULLUDDIS)}, /* LCD-Data(14) */ |
| 205 | {OFFSET(lcd_data15), (MODE(0) | PULLUDDIS)}, /* LCD-Data(15) */ |
| 206 | |
| 207 | {OFFSET(gpmc_ad8), (MODE(1) | PULLUDDIS)}, /* LCD-Data(16) */ |
| 208 | {OFFSET(gpmc_ad9), (MODE(1) | PULLUDDIS)}, /* LCD-Data(17) */ |
| 209 | {OFFSET(gpmc_ad10), (MODE(1) | PULLUDDIS)}, /* LCD-Data(18) */ |
| 210 | {OFFSET(gpmc_ad11), (MODE(1) | PULLUDDIS)}, /* LCD-Data(19) */ |
| 211 | {OFFSET(gpmc_ad12), (MODE(1) | PULLUDDIS)}, /* LCD-Data(20) */ |
| 212 | {OFFSET(gpmc_ad13), (MODE(1) | PULLUDDIS)}, /* LCD-Data(21) */ |
| 213 | {OFFSET(gpmc_ad14), (MODE(1) | PULLUDDIS)}, /* LCD-Data(22) */ |
| 214 | {OFFSET(gpmc_ad15), (MODE(1) | PULLUDDIS)}, /* LCD-Data(23) */ |
| 215 | |
| 216 | {OFFSET(lcd_vsync), (MODE(0) | PULLUDDIS)}, /* LCD-VSync */ |
| 217 | {OFFSET(lcd_hsync), (MODE(0) | PULLUDDIS)}, /* LCD-HSync */ |
| 218 | {OFFSET(lcd_ac_bias_en), (MODE(0) | PULLUDDIS)},/* LCD-DE */ |
| 219 | {OFFSET(lcd_pclk), (MODE(0) | PULLUDDIS)}, /* LCD-CLK */ |
| 220 | |
| 221 | {-1}, |
| 222 | }; |
| 223 | |
| 224 | void enable_uart0_pin_mux(void) |
| 225 | { |
| 226 | configure_module_pin_mux(uart0_pin_mux); |
| 227 | } |
| 228 | |
Hannes Petermaier | 2b5b2be | 2015-03-19 10:43:15 +0100 | [diff] [blame] | 229 | void enable_i2c_pin_mux(void) |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 230 | { |
| 231 | configure_module_pin_mux(i2c0_pin_mux); |
| 232 | } |
| 233 | |
| 234 | void enable_board_pin_mux(void) |
| 235 | { |
| 236 | configure_module_pin_mux(i2c0_pin_mux); |
| 237 | configure_module_pin_mux(mii1_pin_mux); |
| 238 | configure_module_pin_mux(mii2_pin_mux); |
| 239 | #ifdef CONFIG_NAND |
| 240 | configure_module_pin_mux(nand_pin_mux); |
| 241 | #elif defined(CONFIG_MMC) |
| 242 | configure_module_pin_mux(mmc1_pin_mux); |
| 243 | #endif |
| 244 | configure_module_pin_mux(spi0_pin_mux); |
| 245 | configure_module_pin_mux(lcd_pin_mux); |
Hannes Petermaier | a6ec579 | 2015-02-03 13:22:33 +0100 | [diff] [blame] | 246 | configure_module_pin_mux(uart1_pin_mux); |
Hannes Petermaier | 893c04e | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 247 | configure_module_pin_mux(gpIOs); |
| 248 | } |