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 | }; |
| 28 | #ifdef CONFIG_MMC |
| 29 | static struct module_pin_mux mmc1_pin_mux[] = { |
| 30 | {OFFSET(gpmc_ad3), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT3 */ |
| 31 | {OFFSET(gpmc_ad2), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT2 */ |
| 32 | {OFFSET(gpmc_ad1), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT1 */ |
| 33 | {OFFSET(gpmc_ad0), (MODE(1) | RXACTIVE | PULLUP_EN)}, /* MMC1_DAT0 */ |
| 34 | {OFFSET(gpmc_csn1), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CLK */ |
| 35 | {OFFSET(gpmc_csn2), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* MMC1_CMD */ |
| 36 | {OFFSET(gpmc_csn0), (MODE(7) | RXACTIVE | PULLUP_EN)}, /* MMC1_WP */ |
| 37 | {OFFSET(gpmc_advn_ale), (MODE(7) | RXACTIVE | PULLUP_EN)},/* MMC1_CD */ |
| 38 | {-1}, |
| 39 | }; |
| 40 | #endif |
| 41 | static struct module_pin_mux i2c0_pin_mux[] = { |
| 42 | /* I2C_DATA */ |
| 43 | {OFFSET(i2c0_sda), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)}, |
| 44 | /* I2C_SCLK */ |
| 45 | {OFFSET(i2c0_scl), (MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL)}, |
| 46 | {-1}, |
| 47 | }; |
| 48 | |
| 49 | static struct module_pin_mux spi0_pin_mux[] = { |
| 50 | /* SPI0_SCLK */ |
| 51 | {OFFSET(spi0_sclk), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 52 | /* SPI0_D0 */ |
| 53 | {OFFSET(spi0_d0), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 54 | /* SPI0_D1 */ |
| 55 | {OFFSET(spi0_d1), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 56 | /* SPI0_CS0 */ |
| 57 | {OFFSET(spi0_cs0), (MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN)}, |
| 58 | {-1}, |
| 59 | }; |
| 60 | |
| 61 | static struct module_pin_mux mii1_pin_mux[] = { |
| 62 | {OFFSET(mii1_rxerr), MODE(0) | RXACTIVE}, /* MII1_RXERR */ |
| 63 | {OFFSET(mii1_txen), MODE(0)}, /* MII1_TXEN */ |
| 64 | {OFFSET(mii1_rxdv), MODE(0) | RXACTIVE}, /* MII1_RXDV */ |
| 65 | {OFFSET(mii1_txd3), MODE(0)}, /* MII1_TXD3 */ |
| 66 | {OFFSET(mii1_txd2), MODE(0)}, /* MII1_TXD2 */ |
| 67 | {OFFSET(mii1_txd1), MODE(0)}, /* MII1_TXD1 */ |
| 68 | {OFFSET(mii1_txd0), MODE(0)}, /* MII1_TXD0 */ |
| 69 | {OFFSET(mii1_txclk), MODE(0) | RXACTIVE}, /* MII1_TXCLK */ |
| 70 | {OFFSET(mii1_rxclk), MODE(0) | RXACTIVE}, /* MII1_RXCLK */ |
| 71 | {OFFSET(mii1_rxd3), MODE(0) | RXACTIVE}, /* MII1_RXD3 */ |
| 72 | {OFFSET(mii1_rxd2), MODE(0) | RXACTIVE}, /* MII1_RXD2 */ |
| 73 | {OFFSET(mii1_rxd1), MODE(0) | RXACTIVE}, /* MII1_RXD1 */ |
| 74 | {OFFSET(mii1_rxd0), MODE(0) | RXACTIVE}, /* MII1_RXD0 */ |
| 75 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */ |
| 76 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
| 77 | {-1}, |
| 78 | }; |
| 79 | |
| 80 | static struct module_pin_mux mii2_pin_mux[] = { |
| 81 | {OFFSET(gpmc_a0), MODE(1)}, /* MII2_TXEN */ |
| 82 | {OFFSET(gpmc_a1), MODE(1) | RXACTIVE}, /* MII2_RXDV */ |
| 83 | {OFFSET(gpmc_a2), MODE(1)}, /* MII2_TXD3 */ |
| 84 | {OFFSET(gpmc_a3), MODE(1)}, /* MII2_TXD2 */ |
| 85 | {OFFSET(gpmc_a4), MODE(1)}, /* MII2_TXD1 */ |
| 86 | {OFFSET(gpmc_a5), MODE(1)}, /* MII2_TXD0 */ |
| 87 | {OFFSET(gpmc_a6), MODE(1) | RXACTIVE}, /* MII2_TXCLK */ |
| 88 | {OFFSET(gpmc_a7), MODE(1) | RXACTIVE}, /* MII2_RXCLK */ |
| 89 | {OFFSET(gpmc_a8), MODE(1) | RXACTIVE}, /* MII2_RXD3 */ |
| 90 | {OFFSET(gpmc_a9), MODE(1) | RXACTIVE}, /* MII2_RXD2 */ |
| 91 | {OFFSET(gpmc_a10), MODE(1) | RXACTIVE}, /* MII2_RXD1 */ |
| 92 | {OFFSET(gpmc_a11), MODE(1) | RXACTIVE}, /* MII2_RXD0 */ |
| 93 | {OFFSET(gpmc_wpn), (MODE(1) | RXACTIVE)},/* MII2_RXERR */ |
| 94 | /* |
| 95 | * MII2_CRS is shared with |
| 96 | * NAND_WAIT0 |
| 97 | */ |
| 98 | {OFFSET(gpmc_be1n), (MODE(1) | RXACTIVE)},/* MII1_COL */ |
| 99 | {-1}, |
| 100 | }; |
| 101 | #ifdef CONFIG_NAND |
| 102 | static struct module_pin_mux nand_pin_mux[] = { |
| 103 | {OFFSET(gpmc_ad0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD0 */ |
| 104 | {OFFSET(gpmc_ad1), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD1 */ |
| 105 | {OFFSET(gpmc_ad2), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD2 */ |
| 106 | {OFFSET(gpmc_ad3), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD3 */ |
| 107 | {OFFSET(gpmc_ad4), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD4 */ |
| 108 | {OFFSET(gpmc_ad5), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD5 */ |
| 109 | {OFFSET(gpmc_ad6), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD6 */ |
| 110 | {OFFSET(gpmc_ad7), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD7 */ |
| 111 | {OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */ |
| 112 | {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)}, /* NAND_WPN */ |
| 113 | {OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)}, /* NAND_CS0 */ |
| 114 | {OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */ |
| 115 | {OFFSET(gpmc_oen_ren), (MODE(0) | PULLUDEN)}, /* NAND_OE */ |
| 116 | {OFFSET(gpmc_wen), (MODE(0) | PULLUDEN)}, /* NAND_WEN */ |
| 117 | {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLUDEN)}, /* NAND_BE_CLE */ |
| 118 | {-1}, |
| 119 | }; |
| 120 | #endif |
| 121 | static struct module_pin_mux gpIOs[] = { |
| 122 | /* GPIO0_6 (SPI0_CS1) - 3v3_PWR_nEN (Display Power Supply) */ |
| 123 | {OFFSET(spi0_cs1), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 124 | /* TIMER5 (MMC0_DAT3) - TIMER5 (Buzzer) */ |
| 125 | {OFFSET(mmc0_dat3), (MODE(3) | PULLUDEN | RXACTIVE)}, |
| 126 | /* TIMER6 (MMC0_DAT2) - PWM_BACK_3V3, later used as MODE3 for PWM */ |
| 127 | {OFFSET(mmc0_dat2), (MODE(7) | PULLUDEN | RXACTIVE)}, |
| 128 | /* GPIO2_28 (MMC0_DAT1) - MII_nNAND */ |
| 129 | {OFFSET(mmc0_dat1), (MODE(7) | PULLUDEN | RXACTIVE)}, |
| 130 | /* GPIO2_29 (MMC0_DAT0) - NAND_1n0 */ |
| 131 | {OFFSET(mmc0_dat0), (MODE(7) | PULLUDEN | RXACTIVE)}, |
| 132 | /* GPIO2_30 (MMC0_CLK) - nRESET (PHY) */ |
| 133 | {OFFSET(mmc0_clk), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 134 | /* GPIO3_18 (MCASP0_ACLKR) - CPLD JTAG TDI */ |
| 135 | {OFFSET(mcasp0_aclkr), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 136 | /* GPIO3_19 (MCASP0_FSR) - CPLD JTAG TMS */ |
| 137 | {OFFSET(mcasp0_fsr), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 138 | /* GPIO3_20 (MCASP0_AXR1) - CPLD JTAG TCK */ |
| 139 | {OFFSET(mcasp0_axr1), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 140 | /* GPIO3_21 (MCASP0_AHCLKX) - CPLD JTAG TDO */ |
| 141 | {OFFSET(mcasp0_ahclkx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 142 | /* GPIO2_0 (GPMC_nCS3) - DCOK */ |
| 143 | {OFFSET(gpmc_csn3), (MODE(7) | PULLUDDIS | RXACTIVE) }, |
| 144 | /* GPIO0_29 (RMII1_REFCLK) - eMMC nRST */ |
| 145 | {OFFSET(rmii1_refclk), (MODE(7) | PULLUDDIS | RXACTIVE) }, |
| 146 | /* |
| 147 | * GPIO0_7 (PWW0 OUT) |
| 148 | * DISPLAY_ONOFF (Backlight Enable at LVDS Versions) |
| 149 | */ |
| 150 | {OFFSET(ecap0_in_pwm0_out), (MODE(7) | PULLUDEN | RXACTIVE)}, |
| 151 | /* GPIO0_19 (DMA_INTR0) - ISPLAY_MODE (CPLD) */ |
| 152 | {OFFSET(xdma_event_intr0), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE)}, |
| 153 | /* GPIO0_20 (DMA_INTR1) - REP-Switch */ |
| 154 | {OFFSET(xdma_event_intr1), (MODE(7) | PULLUP_EN | RXACTIVE)}, |
| 155 | /* GPIO3_14 (MCASP0_ACLKX) - frei / PP709 */ |
| 156 | {OFFSET(mcasp0_aclkx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE) }, |
| 157 | /* GPIO3_15 (MCASP0_FSX) - PMIC_nRESET */ |
| 158 | {OFFSET(mcasp0_fsx), (MODE(7) | PULLUDEN | PULLUP_EN | RXACTIVE) }, |
| 159 | /* GPIO3_16 (MCASP0_AXR0) - ETH1_LEDY */ |
| 160 | {OFFSET(mcasp0_axr0), (MODE(7) | PULLUDDIS) }, |
| 161 | /* GPIO3_17 (MCASP0_AHCLKR) - ETH2_LEDY */ |
| 162 | {OFFSET(mcasp0_ahclkr), (MODE(7) | PULLUDDIS) }, |
| 163 | |
| 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 */ |
| 198 | |
| 199 | {-1}, |
| 200 | }; |
| 201 | |
| 202 | void enable_uart0_pin_mux(void) |
| 203 | { |
| 204 | configure_module_pin_mux(uart0_pin_mux); |
| 205 | } |
| 206 | |
| 207 | void enable_i2c0_pin_mux(void) |
| 208 | { |
| 209 | configure_module_pin_mux(i2c0_pin_mux); |
| 210 | } |
| 211 | |
| 212 | void enable_board_pin_mux(void) |
| 213 | { |
| 214 | configure_module_pin_mux(i2c0_pin_mux); |
| 215 | configure_module_pin_mux(mii1_pin_mux); |
| 216 | configure_module_pin_mux(mii2_pin_mux); |
| 217 | #ifdef CONFIG_NAND |
| 218 | configure_module_pin_mux(nand_pin_mux); |
| 219 | #elif defined(CONFIG_MMC) |
| 220 | configure_module_pin_mux(mmc1_pin_mux); |
| 221 | #endif |
| 222 | configure_module_pin_mux(spi0_pin_mux); |
| 223 | configure_module_pin_mux(lcd_pin_mux); |
| 224 | configure_module_pin_mux(gpIOs); |
| 225 | } |