Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 2 | /* |
| 3 | * mux.c |
| 4 | * |
Hannes Schmelzer | 20ccb43 | 2016-06-22 12:36:13 +0200 | [diff] [blame] | 5 | * Pinmux Setting for B&R BRPPT1 Board(s) |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 6 | * |
Hannes Schmelzer | 7935f03 | 2015-05-28 15:41:12 +0200 | [diff] [blame] | 7 | * Copyright (C) 2013 Hannes Schmelzer <oe5hpm@oevsv.at> |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 8 | * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 9 | */ |
| 10 | |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 11 | #include <asm/arch/sys_proto.h> |
| 12 | #include <asm/arch/hardware.h> |
| 13 | #include <asm/arch/mux.h> |
| 14 | #include <asm/io.h> |
| 15 | #include <i2c.h> |
| 16 | |
| 17 | static struct module_pin_mux uart0_pin_mux[] = { |
Hannes Petermaier | ec17ed5 | 2015-04-08 07:38:35 +0200 | [diff] [blame] | 18 | /* UART0_RTS */ |
| 19 | {OFFSET(uart0_rtsn), (MODE(0) | PULLUDEN)}, |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 20 | /* UART0_CTS */ |
Hannes Petermaier | ec17ed5 | 2015-04-08 07:38:35 +0200 | [diff] [blame] | 21 | {OFFSET(uart0_ctsn), (MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 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 | }; |
Bernhard Messerklinger | e830ef2 | 2022-08-25 08:54:00 +0200 | [diff] [blame] | 28 | |
Hannes Petermaier | e5f6bb0 | 2015-02-03 13:22:33 +0100 | [diff] [blame] | 29 | static struct module_pin_mux uart1_pin_mux[] = { |
Hannes Petermaier | ec17ed5 | 2015-04-08 07:38:35 +0200 | [diff] [blame] | 30 | /* UART1_RTS as I2C2-SCL */ |
| 31 | {OFFSET(uart1_rtsn), (MODE(3) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 32 | /* UART1_CTS as I2C2-SDA */ |
| 33 | {OFFSET(uart1_ctsn), (MODE(3) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 34 | /* UART1_RXD */ |
Hannes Petermaier | e5f6bb0 | 2015-02-03 13:22:33 +0100 | [diff] [blame] | 35 | {OFFSET(uart1_rxd), (MODE(0) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
Hannes Petermaier | ec17ed5 | 2015-04-08 07:38:35 +0200 | [diff] [blame] | 36 | /* UART1_TXD */ |
Hannes Petermaier | e5f6bb0 | 2015-02-03 13:22:33 +0100 | [diff] [blame] | 37 | {OFFSET(uart1_txd), (MODE(0) | PULLUDEN)}, |
| 38 | {-1}, |
| 39 | }; |
Bernhard Messerklinger | e830ef2 | 2022-08-25 08:54:00 +0200 | [diff] [blame] | 40 | |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 41 | static struct module_pin_mux mmc1_pin_mux[] = { |
Hannes Petermaier | 086b7a0 | 2014-06-04 10:25:32 +0200 | [diff] [blame] | 42 | {OFFSET(gpmc_ad7), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT7 */ |
| 43 | {OFFSET(gpmc_ad6), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT6 */ |
| 44 | {OFFSET(gpmc_ad5), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT5 */ |
| 45 | {OFFSET(gpmc_ad4), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT4 */ |
| 46 | |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 47 | {OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT3 */ |
| 48 | {OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT2 */ |
| 49 | {OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT1 */ |
| 50 | {OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT0 */ |
| 51 | {OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CLK */ |
| 52 | {OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CMD */ |
| 53 | {OFFSET(gpmc_csn0), (MODE(7) | RXACTIVE | PULLUP_EN)}, /* MMC1_WP */ |
| 54 | {OFFSET(gpmc_advn_ale), (MODE(7) | RXACTIVE | PULLUP_EN)},/* MMC1_CD */ |
| 55 | {-1}, |
| 56 | }; |
Bernhard Messerklinger | e830ef2 | 2022-08-25 08:54:00 +0200 | [diff] [blame] | 57 | |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 58 | static struct module_pin_mux i2c0_pin_mux[] = { |
| 59 | /* I2C_DATA */ |
| 60 | {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)}, |
| 61 | /* I2C_SCLK */ |
| 62 | {OFFSET(i2c0_scl), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)}, |
| 63 | {-1}, |
| 64 | }; |
| 65 | |
| 66 | static struct module_pin_mux spi0_pin_mux[] = { |
| 67 | /* SPI0_SCLK */ |
| 68 | {OFFSET(spi0_sclk), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 69 | /* SPI0_D0 */ |
| 70 | {OFFSET(spi0_d0), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 71 | /* SPI0_D1 */ |
| 72 | {OFFSET(spi0_d1), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 73 | /* SPI0_CS0 */ |
| 74 | {OFFSET(spi0_cs0), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 75 | {-1}, |
| 76 | }; |
| 77 | |
| 78 | static struct module_pin_mux mii1_pin_mux[] = { |
Hannes Petermaier | c61633c | 2014-10-03 07:30:15 +0200 | [diff] [blame] | 79 | {OFFSET(mii1_crs), MODE(0) | RXACTIVE}, /* MII1_CRS */ |
| 80 | {OFFSET(mii1_col), MODE(0) | RXACTIVE}, /* MII1_COL */ |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 81 | {OFFSET(mii1_rxerr), MODE(0) | RXACTIVE}, /* MII1_RXERR */ |
| 82 | {OFFSET(mii1_txen), MODE(0)}, /* MII1_TXEN */ |
| 83 | {OFFSET(mii1_rxdv), MODE(0) | RXACTIVE}, /* MII1_RXDV */ |
| 84 | {OFFSET(mii1_txd3), MODE(0)}, /* MII1_TXD3 */ |
| 85 | {OFFSET(mii1_txd2), MODE(0)}, /* MII1_TXD2 */ |
| 86 | {OFFSET(mii1_txd1), MODE(0)}, /* MII1_TXD1 */ |
| 87 | {OFFSET(mii1_txd0), MODE(0)}, /* MII1_TXD0 */ |
| 88 | {OFFSET(mii1_txclk), MODE(0) | RXACTIVE}, /* MII1_TXCLK */ |
| 89 | {OFFSET(mii1_rxclk), MODE(0) | RXACTIVE}, /* MII1_RXCLK */ |
| 90 | {OFFSET(mii1_rxd3), MODE(0) | RXACTIVE}, /* MII1_RXD3 */ |
| 91 | {OFFSET(mii1_rxd2), MODE(0) | RXACTIVE}, /* MII1_RXD2 */ |
| 92 | {OFFSET(mii1_rxd1), MODE(0) | RXACTIVE}, /* MII1_RXD1 */ |
| 93 | {OFFSET(mii1_rxd0), MODE(0) | RXACTIVE}, /* MII1_RXD0 */ |
| 94 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */ |
| 95 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
| 96 | {-1}, |
| 97 | }; |
| 98 | |
| 99 | static struct module_pin_mux mii2_pin_mux[] = { |
| 100 | {OFFSET(gpmc_a0), MODE(1)}, /* MII2_TXEN */ |
| 101 | {OFFSET(gpmc_a1), MODE(1) | RXACTIVE}, /* MII2_RXDV */ |
| 102 | {OFFSET(gpmc_a2), MODE(1)}, /* MII2_TXD3 */ |
| 103 | {OFFSET(gpmc_a3), MODE(1)}, /* MII2_TXD2 */ |
| 104 | {OFFSET(gpmc_a4), MODE(1)}, /* MII2_TXD1 */ |
| 105 | {OFFSET(gpmc_a5), MODE(1)}, /* MII2_TXD0 */ |
| 106 | {OFFSET(gpmc_a6), MODE(1) | RXACTIVE}, /* MII2_TXCLK */ |
| 107 | {OFFSET(gpmc_a7), MODE(1) | RXACTIVE}, /* MII2_RXCLK */ |
| 108 | {OFFSET(gpmc_a8), MODE(1) | RXACTIVE}, /* MII2_RXD3 */ |
| 109 | {OFFSET(gpmc_a9), MODE(1) | RXACTIVE}, /* MII2_RXD2 */ |
| 110 | {OFFSET(gpmc_a10), MODE(1) | RXACTIVE}, /* MII2_RXD1 */ |
| 111 | {OFFSET(gpmc_a11), MODE(1) | RXACTIVE}, /* MII2_RXD0 */ |
| 112 | {OFFSET(gpmc_wpn), (MODE(1) | RXACTIVE)},/* MII2_RXERR */ |
Hannes Petermaier | c61633c | 2014-10-03 07:30:15 +0200 | [diff] [blame] | 113 | {OFFSET(gpmc_wait0), (MODE(1) | RXACTIVE | PULLUP_EN)}, |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 114 | /* |
| 115 | * MII2_CRS is shared with |
| 116 | * NAND_WAIT0 |
| 117 | */ |
| 118 | {OFFSET(gpmc_be1n), (MODE(1) | RXACTIVE)},/* MII1_COL */ |
| 119 | {-1}, |
| 120 | }; |
Bernhard Messerklinger | e830ef2 | 2022-08-25 08:54:00 +0200 | [diff] [blame] | 121 | |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 122 | static struct module_pin_mux gpIOs[] = { |
| 123 | /* GPIO0_6 (SPI0_CS1) - 3v3_PWR_nEN (Display Power Supply) */ |
| 124 | {OFFSET(spi0_cs1), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 125 | /* TIMER5 (MMC0_DAT3) - TIMER5 (Buzzer) */ |
| 126 | {OFFSET(mmc0_dat3), (MODE(3) | PULLUDEN | RXACTIVE)}, |
Hannes Petermaier | e3c3755 | 2015-02-03 13:22:31 +0100 | [diff] [blame] | 127 | /* TIMER6 (MMC0_DAT2) - PWM_BACK_3V3 */ |
| 128 | {OFFSET(mmc0_dat2), (MODE(3) | PULLUDEN | RXACTIVE)}, |
| 129 | /* GPIO2_28 (MMC0_DAT1) - MII_nNAND */ |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 130 | {OFFSET(mmc0_dat1), (MODE(7) | PULLUDEN | RXACTIVE)}, |
| 131 | /* GPIO2_29 (MMC0_DAT0) - NAND_1n0 */ |
| 132 | {OFFSET(mmc0_dat0), (MODE(7) | PULLUDEN | RXACTIVE)}, |
| 133 | /* GPIO2_30 (MMC0_CLK) - nRESET (PHY) */ |
| 134 | {OFFSET(mmc0_clk), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 135 | /* GPIO3_18 (MCASP0_ACLKR) - CPLD JTAG TDI */ |
| 136 | {OFFSET(mcasp0_aclkr), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 137 | /* GPIO3_19 (MCASP0_FSR) - CPLD JTAG TMS */ |
| 138 | {OFFSET(mcasp0_fsr), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 139 | /* GPIO3_20 (MCASP0_AXR1) - CPLD JTAG TCK */ |
| 140 | {OFFSET(mcasp0_axr1), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 141 | /* GPIO3_21 (MCASP0_AHCLKX) - CPLD JTAG TDO */ |
| 142 | {OFFSET(mcasp0_ahclkx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 143 | /* GPIO2_0 (GPMC_nCS3) - DCOK */ |
| 144 | {OFFSET(gpmc_csn3), (MODE(7) | PULLUDDIS | RXACTIVE) }, |
| 145 | /* GPIO0_29 (RMII1_REFCLK) - eMMC nRST */ |
| 146 | {OFFSET(rmii1_refclk), (MODE(7) | PULLUDDIS | RXACTIVE) }, |
| 147 | /* |
| 148 | * GPIO0_7 (PWW0 OUT) |
| 149 | * DISPLAY_ONOFF (Backlight Enable at LVDS Versions) |
| 150 | */ |
| 151 | {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN | RXACTIVE)}, |
Hannes Petermaier | 0b7d3d7 | 2014-06-04 10:37:12 +0200 | [diff] [blame] | 152 | /* GPIO0_19 (DMA_INTR0) - DISPLAY_MODE (CPLD) */ |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 153 | {OFFSET(xdma_event_intr0), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 154 | /* GPIO0_20 (DMA_INTR1) - REP-Switch */ |
| 155 | {OFFSET(xdma_event_intr1), (MODE(7) | PULLUP_EN | RXACTIVE)}, |
| 156 | /* GPIO3_14 (MCASP0_ACLKX) - frei / PP709 */ |
| 157 | {OFFSET(mcasp0_aclkx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE) }, |
| 158 | /* GPIO3_15 (MCASP0_FSX) - PMIC_nRESET */ |
| 159 | {OFFSET(mcasp0_fsx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE) }, |
| 160 | /* GPIO3_16 (MCASP0_AXR0) - ETH1_LEDY */ |
| 161 | {OFFSET(mcasp0_axr0), (MODE(7) | PULLUDDIS) }, |
| 162 | /* GPIO3_17 (MCASP0_AHCLKR) - ETH2_LEDY */ |
| 163 | {OFFSET(mcasp0_ahclkr), (MODE(7) | PULLUDDIS) }, |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 164 | {-1}, |
| 165 | }; |
| 166 | |
| 167 | static struct module_pin_mux lcd_pin_mux[] = { |
| 168 | {OFFSET(lcd_data0), (MODE(0) | PULLUDDIS)}, /* LCD-Data(0) */ |
| 169 | {OFFSET(lcd_data1), (MODE(0) | PULLUDDIS)}, /* LCD-Data(1) */ |
| 170 | {OFFSET(lcd_data2), (MODE(0) | PULLUDDIS)}, /* LCD-Data(2) */ |
| 171 | {OFFSET(lcd_data3), (MODE(0) | PULLUDDIS)}, /* LCD-Data(3) */ |
| 172 | {OFFSET(lcd_data4), (MODE(0) | PULLUDDIS)}, /* LCD-Data(4) */ |
| 173 | {OFFSET(lcd_data5), (MODE(0) | PULLUDDIS)}, /* LCD-Data(5) */ |
| 174 | {OFFSET(lcd_data6), (MODE(0) | PULLUDDIS)}, /* LCD-Data(6) */ |
| 175 | {OFFSET(lcd_data7), (MODE(0) | PULLUDDIS)}, /* LCD-Data(7) */ |
| 176 | {OFFSET(lcd_data8), (MODE(0) | PULLUDDIS)}, /* LCD-Data(8) */ |
| 177 | {OFFSET(lcd_data9), (MODE(0) | PULLUDDIS)}, /* LCD-Data(9) */ |
| 178 | {OFFSET(lcd_data10), (MODE(0) | PULLUDDIS)}, /* LCD-Data(10) */ |
| 179 | {OFFSET(lcd_data11), (MODE(0) | PULLUDDIS)}, /* LCD-Data(11) */ |
| 180 | {OFFSET(lcd_data12), (MODE(0) | PULLUDDIS)}, /* LCD-Data(12) */ |
| 181 | {OFFSET(lcd_data13), (MODE(0) | PULLUDDIS)}, /* LCD-Data(13) */ |
| 182 | {OFFSET(lcd_data14), (MODE(0) | PULLUDDIS)}, /* LCD-Data(14) */ |
| 183 | {OFFSET(lcd_data15), (MODE(0) | PULLUDDIS)}, /* LCD-Data(15) */ |
| 184 | |
| 185 | {OFFSET(gpmc_ad8), (MODE(1) | PULLUDDIS)}, /* LCD-Data(16) */ |
| 186 | {OFFSET(gpmc_ad9), (MODE(1) | PULLUDDIS)}, /* LCD-Data(17) */ |
| 187 | {OFFSET(gpmc_ad10), (MODE(1) | PULLUDDIS)}, /* LCD-Data(18) */ |
| 188 | {OFFSET(gpmc_ad11), (MODE(1) | PULLUDDIS)}, /* LCD-Data(19) */ |
| 189 | {OFFSET(gpmc_ad12), (MODE(1) | PULLUDDIS)}, /* LCD-Data(20) */ |
| 190 | {OFFSET(gpmc_ad13), (MODE(1) | PULLUDDIS)}, /* LCD-Data(21) */ |
| 191 | {OFFSET(gpmc_ad14), (MODE(1) | PULLUDDIS)}, /* LCD-Data(22) */ |
| 192 | {OFFSET(gpmc_ad15), (MODE(1) | PULLUDDIS)}, /* LCD-Data(23) */ |
| 193 | |
| 194 | {OFFSET(lcd_vsync), (MODE(0) | PULLUDDIS)}, /* LCD-VSync */ |
| 195 | {OFFSET(lcd_hsync), (MODE(0) | PULLUDDIS)}, /* LCD-HSync */ |
| 196 | {OFFSET(lcd_ac_bias_en), (MODE(0) | PULLUDDIS)},/* LCD-DE */ |
| 197 | {OFFSET(lcd_pclk), (MODE(0) | PULLUDDIS)}, /* LCD-CLK */ |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 198 | {-1}, |
| 199 | }; |
| 200 | |
| 201 | void enable_uart0_pin_mux(void) |
| 202 | { |
| 203 | configure_module_pin_mux(uart0_pin_mux); |
| 204 | } |
| 205 | |
Hannes Petermaier | 2e68d2b | 2015-03-19 10:43:15 +0100 | [diff] [blame] | 206 | void enable_i2c_pin_mux(void) |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 207 | { |
| 208 | configure_module_pin_mux(i2c0_pin_mux); |
| 209 | } |
| 210 | |
| 211 | void enable_board_pin_mux(void) |
| 212 | { |
| 213 | configure_module_pin_mux(i2c0_pin_mux); |
| 214 | configure_module_pin_mux(mii1_pin_mux); |
| 215 | configure_module_pin_mux(mii2_pin_mux); |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 216 | configure_module_pin_mux(mmc1_pin_mux); |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 217 | configure_module_pin_mux(spi0_pin_mux); |
| 218 | configure_module_pin_mux(lcd_pin_mux); |
Hannes Petermaier | e5f6bb0 | 2015-02-03 13:22:33 +0100 | [diff] [blame] | 219 | configure_module_pin_mux(uart1_pin_mux); |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 220 | configure_module_pin_mux(gpIOs); |
| 221 | } |