Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 2 | |
| 3 | #include "pinmux.h" |
| 4 | |
Kyösti Mälkki | 13f6650 | 2019-03-03 08:01:05 +0200 | [diff] [blame] | 5 | #include <device/mmio.h> |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 6 | |
| 7 | static struct am335x_pinmux_regs *regs = |
| 8 | (struct am335x_pinmux_regs *)(uintptr_t)AM335X_PINMUX_REG_ADDR; |
| 9 | |
| 10 | void am335x_pinmux_uart0(void) |
| 11 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 12 | write32(®s->uart0_rxd, MODE(0) | PULLUP_EN | RXACTIVE); |
| 13 | write32(®s->uart0_txd, MODE(0) | PULLUDEN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | void am335x_pinmux_uart1(void) |
| 17 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 18 | write32(®s->uart1_rxd, MODE(0) | PULLUP_EN | RXACTIVE); |
| 19 | write32(®s->uart1_txd, MODE(0) | PULLUDEN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | void am335x_pinmux_uart2(void) |
| 23 | { |
| 24 | // UART2_RXD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 25 | write32(®s->spi0_sclk, MODE(1) | PULLUP_EN | RXACTIVE); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 26 | // UART2_TXD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 27 | write32(®s->spi0_d0, MODE(1) | PULLUDEN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | void am335x_pinmux_uart3(void) |
| 31 | { |
| 32 | // UART3_RXD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 33 | write32(®s->spi0_cs1, MODE(1) | PULLUP_EN | RXACTIVE); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 34 | // UART3_TXD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 35 | write32(®s->ecap0_in_pwm0_out, MODE(1) | PULLUDEN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void am335x_pinmux_uart4(void) |
| 39 | { |
| 40 | // UART4_RXD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 41 | write32(®s->gpmc_wait0, MODE(6) | PULLUP_EN | RXACTIVE); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 42 | // UART4_TXD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 43 | write32(®s->gpmc_wpn, MODE(6) | PULLUDEN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | void am335x_pinmux_uart5(void) |
| 47 | { |
| 48 | // UART5_RXD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 49 | write32(®s->lcd_data9, MODE(4) | PULLUP_EN | RXACTIVE); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 50 | // UART5_TXD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 51 | write32(®s->lcd_data8, MODE(4) | PULLUDEN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | void am335x_pinmux_mmc0(int cd, int sk_evm) |
| 55 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 56 | write32(®s->mmc0_dat0, MODE(0) | RXACTIVE | PULLUP_EN); |
| 57 | write32(®s->mmc0_dat1, MODE(0) | RXACTIVE | PULLUP_EN); |
| 58 | write32(®s->mmc0_dat2, MODE(0) | RXACTIVE | PULLUP_EN); |
| 59 | write32(®s->mmc0_dat3, MODE(0) | RXACTIVE | PULLUP_EN); |
| 60 | write32(®s->mmc0_clk, MODE(0) | RXACTIVE | PULLUP_EN); |
| 61 | write32(®s->mmc0_cmd, MODE(0) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 62 | if (!sk_evm) { |
| 63 | // MMC0_WP |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 64 | write32(®s->mcasp0_aclkr, MODE(4) | RXACTIVE); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 65 | } |
| 66 | if (cd) { |
| 67 | // MMC0_CD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 68 | write32(®s->spi0_cs1, MODE(5) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 69 | } |
| 70 | } |
| 71 | |
| 72 | void am335x_pinmux_mmc1(void) |
| 73 | { |
| 74 | // MMC1_DAT0 |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 75 | write32(®s->gpmc_ad0, MODE(1) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 76 | // MMC1_DAT1 |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 77 | write32(®s->gpmc_ad1, MODE(1) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 78 | // MMC1_DAT2 |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 79 | write32(®s->gpmc_ad2, MODE(1) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 80 | // MMC1_DAT3 |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 81 | write32(®s->gpmc_ad3, MODE(1) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 82 | // MMC1_CLK |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 83 | write32(®s->gpmc_csn1, MODE(2) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 84 | // MMC1_CMD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 85 | write32(®s->gpmc_csn2, MODE(2) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 86 | // MMC1_WP |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 87 | write32(®s->gpmc_csn0, MODE(7) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 88 | // MMC1_CD |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 89 | write32(®s->gpmc_advn_ale, MODE(7) | RXACTIVE | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | void am335x_pinmux_i2c0(void) |
| 93 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 94 | write32(®s->i2c0_sda, MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL); |
| 95 | write32(®s->i2c0_scl, MODE(0) | RXACTIVE | PULLUDEN | SLEWCTRL); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | void am335x_pinmux_i2c1(void) |
| 99 | { |
| 100 | // I2C_DATA |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 101 | write32(®s->spi0_d1, MODE(2) | RXACTIVE | PULLUDEN | SLEWCTRL); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 102 | // I2C_SCLK |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 103 | write32(®s->spi0_cs0, MODE(2) | RXACTIVE | PULLUDEN | SLEWCTRL); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | void am335x_pinmux_spi0(void) |
| 107 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 108 | write32(®s->spi0_sclk, MODE(0) | RXACTIVE | PULLUDEN); |
| 109 | write32(®s->spi0_d0, MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN); |
| 110 | write32(®s->spi0_d1, MODE(0) | RXACTIVE | PULLUDEN); |
| 111 | write32(®s->spi0_cs0, MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | void am335x_pinmux_gpio0_7(void) |
| 115 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 116 | write32(®s->ecap0_in_pwm0_out, MODE(7) | PULLUDEN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | void am335x_pinmux_rgmii1(void) |
| 120 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 121 | write32(®s->mii1_txen, MODE(2)); |
| 122 | write32(®s->mii1_rxdv, MODE(2) | RXACTIVE); |
| 123 | write32(®s->mii1_txd0, MODE(2)); |
| 124 | write32(®s->mii1_txd1, MODE(2)); |
| 125 | write32(®s->mii1_txd2, MODE(2)); |
| 126 | write32(®s->mii1_txd3, MODE(2)); |
| 127 | write32(®s->mii1_txclk, MODE(2)); |
| 128 | write32(®s->mii1_rxclk, MODE(2) | RXACTIVE); |
| 129 | write32(®s->mii1_rxd0, MODE(2) | RXACTIVE); |
| 130 | write32(®s->mii1_rxd1, MODE(2) | RXACTIVE); |
| 131 | write32(®s->mii1_rxd2, MODE(2) | RXACTIVE); |
| 132 | write32(®s->mii1_rxd3, MODE(2) | RXACTIVE); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | void am335x_pinmux_mii1(void) |
| 136 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 137 | write32(®s->mii1_rxerr, MODE(0) | RXACTIVE); |
| 138 | write32(®s->mii1_txen, MODE(0)); |
| 139 | write32(®s->mii1_rxdv, MODE(0) | RXACTIVE); |
| 140 | write32(®s->mii1_txd0, MODE(0)); |
| 141 | write32(®s->mii1_txd1, MODE(0)); |
| 142 | write32(®s->mii1_txd2, MODE(0)); |
| 143 | write32(®s->mii1_txd3, MODE(0)); |
| 144 | write32(®s->mii1_txclk, MODE(0) | RXACTIVE); |
| 145 | write32(®s->mii1_rxclk, MODE(0) | RXACTIVE); |
| 146 | write32(®s->mii1_rxd0, MODE(0) | RXACTIVE); |
| 147 | write32(®s->mii1_rxd1, MODE(0) | RXACTIVE); |
| 148 | write32(®s->mii1_rxd2, MODE(0) | RXACTIVE); |
| 149 | write32(®s->mii1_rxd3, MODE(0) | RXACTIVE); |
| 150 | write32(®s->mdio_data, MODE(0) | RXACTIVE | PULLUP_EN); |
| 151 | write32(®s->mdio_clk, MODE(0) | PULLUP_EN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | void am335x_pinmux_nand(void) |
| 155 | { |
Julius Werner | 2f37bd6 | 2015-02-19 14:51:15 -0800 | [diff] [blame] | 156 | write32(®s->gpmc_ad0, MODE(0) | PULLUP_EN | RXACTIVE); |
| 157 | write32(®s->gpmc_ad1, MODE(0) | PULLUP_EN | RXACTIVE); |
| 158 | write32(®s->gpmc_ad2, MODE(0) | PULLUP_EN | RXACTIVE); |
| 159 | write32(®s->gpmc_ad3, MODE(0) | PULLUP_EN | RXACTIVE); |
| 160 | write32(®s->gpmc_ad4, MODE(0) | PULLUP_EN | RXACTIVE); |
| 161 | write32(®s->gpmc_ad5, MODE(0) | PULLUP_EN | RXACTIVE); |
| 162 | write32(®s->gpmc_ad6, MODE(0) | PULLUP_EN | RXACTIVE); |
| 163 | write32(®s->gpmc_ad7, MODE(0) | PULLUP_EN | RXACTIVE); |
| 164 | write32(®s->gpmc_wait0, MODE(0) | RXACTIVE | PULLUP_EN); |
| 165 | write32(®s->gpmc_wpn, MODE(7) | PULLUP_EN | RXACTIVE); |
| 166 | write32(®s->gpmc_csn0, MODE(0) | PULLUDEN); |
| 167 | write32(®s->gpmc_advn_ale, MODE(0) | PULLUDEN); |
| 168 | write32(®s->gpmc_oen_ren, MODE(0) | PULLUDEN); |
| 169 | write32(®s->gpmc_wen, MODE(0) | PULLUDEN); |
| 170 | write32(®s->gpmc_be0n_cle, MODE(0) | PULLUDEN); |
Gabe Black | 5acc76c | 2013-06-17 01:17:55 -0700 | [diff] [blame] | 171 | } |