Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Lokesh Vutla | faa680f | 2013-07-30 11:36:27 +0530 | [diff] [blame] | 2 | /* |
| 3 | * mux.c |
| 4 | * |
Nishanth Menon | eaa39c6 | 2023-11-01 15:56:03 -0500 | [diff] [blame] | 5 | * Copyright (C) 2013 Texas Instruments Incorporated - https://www.ti.com/ |
Lokesh Vutla | faa680f | 2013-07-30 11:36:27 +0530 | [diff] [blame] | 6 | */ |
| 7 | |
Lokesh Vutla | faa680f | 2013-07-30 11:36:27 +0530 | [diff] [blame] | 8 | #include <asm/arch/sys_proto.h> |
| 9 | #include <asm/arch/mux.h> |
Nishanth Menon | 757a9a0 | 2016-02-24 12:30:56 -0600 | [diff] [blame] | 10 | #include "../common/board_detect.h" |
Lokesh Vutla | faa680f | 2013-07-30 11:36:27 +0530 | [diff] [blame] | 11 | #include "board.h" |
| 12 | |
Mugunthan V N | c94f954 | 2014-02-18 07:31:54 -0500 | [diff] [blame] | 13 | static struct module_pin_mux rmii1_pin_mux[] = { |
| 14 | {OFFSET(mii1_txen), MODE(1)}, /* RMII1_TXEN */ |
| 15 | {OFFSET(mii1_txd1), MODE(1)}, /* RMII1_TD1 */ |
| 16 | {OFFSET(mii1_txd0), MODE(1)}, /* RMII1_TD0 */ |
| 17 | {OFFSET(mii1_rxd1), MODE(1) | RXACTIVE}, /* RMII1_RD1 */ |
| 18 | {OFFSET(mii1_rxd0), MODE(1) | RXACTIVE}, /* RMII1_RD0 */ |
| 19 | {OFFSET(mii1_rxdv), MODE(1) | RXACTIVE}, /* RMII1_RXDV */ |
| 20 | {OFFSET(mii1_crs), MODE(1) | RXACTIVE}, /* RMII1_CRS_DV */ |
| 21 | {OFFSET(mii1_rxerr), MODE(1) | RXACTIVE}, /* RMII1_RXERR */ |
| 22 | {OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RMII1_refclk */ |
| 23 | {-1}, |
| 24 | }; |
| 25 | |
| 26 | static struct module_pin_mux rgmii1_pin_mux[] = { |
| 27 | {OFFSET(mii1_txen), MODE(2)}, /* RGMII1_TCTL */ |
| 28 | {OFFSET(mii1_rxdv), MODE(2) | RXACTIVE}, /* RGMII1_RCTL */ |
| 29 | {OFFSET(mii1_txd3), MODE(2)}, /* RGMII1_TD3 */ |
| 30 | {OFFSET(mii1_txd2), MODE(2)}, /* RGMII1_TD2 */ |
| 31 | {OFFSET(mii1_txd1), MODE(2)}, /* RGMII1_TD1 */ |
| 32 | {OFFSET(mii1_txd0), MODE(2)}, /* RGMII1_TD0 */ |
| 33 | {OFFSET(mii1_txclk), MODE(2)}, /* RGMII1_TCLK */ |
| 34 | {OFFSET(mii1_rxclk), MODE(2) | RXACTIVE}, /* RGMII1_RCLK */ |
| 35 | {OFFSET(mii1_rxd3), MODE(2) | RXACTIVE}, /* RGMII1_RD3 */ |
| 36 | {OFFSET(mii1_rxd2), MODE(2) | RXACTIVE}, /* RGMII1_RD2 */ |
| 37 | {OFFSET(mii1_rxd1), MODE(2) | RXACTIVE}, /* RGMII1_RD1 */ |
| 38 | {OFFSET(mii1_rxd0), MODE(2) | RXACTIVE}, /* RGMII1_RD0 */ |
| 39 | {-1}, |
| 40 | }; |
| 41 | |
| 42 | static struct module_pin_mux mdio_pin_mux[] = { |
| 43 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */ |
| 44 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
| 45 | {-1}, |
| 46 | }; |
| 47 | |
Lokesh Vutla | faa680f | 2013-07-30 11:36:27 +0530 | [diff] [blame] | 48 | static struct module_pin_mux uart0_pin_mux[] = { |
Lokesh Vutla | e6bd05e | 2013-12-10 15:02:19 +0530 | [diff] [blame] | 49 | {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)}, |
| 50 | {OFFSET(uart0_txd), (MODE(0) | PULLUDDIS | PULLUP_EN | SLEWCTRL)}, |
Lokesh Vutla | faa680f | 2013-07-30 11:36:27 +0530 | [diff] [blame] | 51 | {-1}, |
| 52 | }; |
| 53 | |
Lokesh Vutla | e6bd05e | 2013-12-10 15:02:19 +0530 | [diff] [blame] | 54 | static struct module_pin_mux mmc0_pin_mux[] = { |
| 55 | {OFFSET(mmc0_clk), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* MMC0_CLK */ |
| 56 | {OFFSET(mmc0_cmd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_CMD */ |
| 57 | {OFFSET(mmc0_dat0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_DAT0 */ |
| 58 | {OFFSET(mmc0_dat1), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_DAT1 */ |
| 59 | {OFFSET(mmc0_dat2), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_DAT2 */ |
| 60 | {OFFSET(mmc0_dat3), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* MMC0_DAT3 */ |
| 61 | {-1}, |
| 62 | }; |
| 63 | |
| 64 | static struct module_pin_mux i2c0_pin_mux[] = { |
| 65 | {OFFSET(i2c0_sda), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)}, |
| 66 | {OFFSET(i2c0_scl), (MODE(0) | PULLUP_EN | RXACTIVE | SLEWCTRL)}, |
| 67 | {-1}, |
| 68 | }; |
| 69 | |
Dave Gerlach | 00822ca | 2014-02-10 11:41:49 -0500 | [diff] [blame] | 70 | static struct module_pin_mux gpio5_7_pin_mux[] = { |
| 71 | {OFFSET(spi0_cs0), (MODE(7) | PULLUP_EN)}, /* GPIO5_7 */ |
Lokesh Vutla | dd0037a | 2013-12-10 15:02:23 +0530 | [diff] [blame] | 72 | {-1}, |
| 73 | }; |
| 74 | |
Miquel Raynal | d093536 | 2019-10-03 19:50:03 +0200 | [diff] [blame] | 75 | #ifdef CONFIG_MTD_RAW_NAND |
pekon gupta | 3eb6f86 | 2014-07-22 16:03:22 +0530 | [diff] [blame] | 76 | static struct module_pin_mux nand_pin_mux[] = { |
| 77 | {OFFSET(gpmc_ad0), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD0 */ |
| 78 | {OFFSET(gpmc_ad1), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD1 */ |
| 79 | {OFFSET(gpmc_ad2), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD2 */ |
| 80 | {OFFSET(gpmc_ad3), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD3 */ |
| 81 | {OFFSET(gpmc_ad4), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD4 */ |
| 82 | {OFFSET(gpmc_ad5), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD5 */ |
| 83 | {OFFSET(gpmc_ad6), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD6 */ |
| 84 | {OFFSET(gpmc_ad7), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD7 */ |
| 85 | #ifdef CONFIG_SYS_NAND_BUSWIDTH_16BIT |
| 86 | {OFFSET(gpmc_ad8), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD8 */ |
| 87 | {OFFSET(gpmc_ad9), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD9 */ |
| 88 | {OFFSET(gpmc_ad10), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD10 */ |
| 89 | {OFFSET(gpmc_ad11), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD11 */ |
| 90 | {OFFSET(gpmc_ad12), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD12 */ |
| 91 | {OFFSET(gpmc_ad13), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD13 */ |
| 92 | {OFFSET(gpmc_ad14), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD14 */ |
| 93 | {OFFSET(gpmc_ad15), (MODE(0) | PULLUDDIS | RXACTIVE)}, /* AD15 */ |
| 94 | #endif |
| 95 | {OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* Wait */ |
| 96 | {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN)}, /* Write Protect */ |
| 97 | {OFFSET(gpmc_csn0), (MODE(0) | PULLUP_EN)}, /* Chip-Select */ |
| 98 | {OFFSET(gpmc_wen), (MODE(0) | PULLDOWN_EN)}, /* Write Enable */ |
| 99 | {OFFSET(gpmc_oen_ren), (MODE(0) | PULLDOWN_EN)}, /* Read Enable */ |
| 100 | {OFFSET(gpmc_advn_ale), (MODE(0) | PULLDOWN_EN)}, /* Addr Latch Enable*/ |
| 101 | {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLDOWN_EN)}, /* Byte Enable */ |
| 102 | {-1}, |
| 103 | }; |
| 104 | #endif |
| 105 | |
| 106 | static __maybe_unused struct module_pin_mux qspi_pin_mux[] = { |
Sourav Poddar | 399f847 | 2013-12-21 12:50:08 +0530 | [diff] [blame] | 107 | {OFFSET(gpmc_csn0), (MODE(3) | PULLUP_EN | RXACTIVE)}, /* QSPI_CS0 */ |
| 108 | {OFFSET(gpmc_csn3), (MODE(2) | PULLUP_EN | RXACTIVE)}, /* QSPI_CLK */ |
| 109 | {OFFSET(gpmc_advn_ale), (MODE(3) | PULLUP_EN | RXACTIVE)}, /* QSPI_D0 */ |
| 110 | {OFFSET(gpmc_oen_ren), (MODE(3) | PULLUP_EN | RXACTIVE)}, /* QSPI_D1 */ |
| 111 | {OFFSET(gpmc_wen), (MODE(3) | PULLUP_EN | RXACTIVE)}, /* QSPI_D2 */ |
| 112 | {OFFSET(gpmc_be0n_cle), (MODE(3) | PULLUP_EN | RXACTIVE)}, /* QSPI_D3 */ |
| 113 | {-1}, |
| 114 | }; |
| 115 | |
Lokesh Vutla | faa680f | 2013-07-30 11:36:27 +0530 | [diff] [blame] | 116 | void enable_uart0_pin_mux(void) |
| 117 | { |
| 118 | configure_module_pin_mux(uart0_pin_mux); |
| 119 | } |
| 120 | |
| 121 | void enable_board_pin_mux(void) |
| 122 | { |
Lokesh Vutla | e6bd05e | 2013-12-10 15:02:19 +0530 | [diff] [blame] | 123 | configure_module_pin_mux(mmc0_pin_mux); |
| 124 | configure_module_pin_mux(i2c0_pin_mux); |
Mugunthan V N | c94f954 | 2014-02-18 07:31:54 -0500 | [diff] [blame] | 125 | configure_module_pin_mux(mdio_pin_mux); |
Lokesh Vutla | dd0037a | 2013-12-10 15:02:23 +0530 | [diff] [blame] | 126 | |
Madan Srinivas | 3623502 | 2016-05-19 19:10:48 -0500 | [diff] [blame] | 127 | if (board_is_evm()) { |
Dave Gerlach | 00822ca | 2014-02-10 11:41:49 -0500 | [diff] [blame] | 128 | configure_module_pin_mux(gpio5_7_pin_mux); |
Mugunthan V N | c94f954 | 2014-02-18 07:31:54 -0500 | [diff] [blame] | 129 | configure_module_pin_mux(rgmii1_pin_mux); |
Miquel Raynal | d093536 | 2019-10-03 19:50:03 +0200 | [diff] [blame] | 130 | #if defined(CONFIG_MTD_RAW_NAND) |
pekon gupta | 3eb6f86 | 2014-07-22 16:03:22 +0530 | [diff] [blame] | 131 | configure_module_pin_mux(nand_pin_mux); |
| 132 | #endif |
Felipe Balbi | 3dcd6d8 | 2014-12-22 16:26:17 -0600 | [diff] [blame] | 133 | } else if (board_is_sk() || board_is_idk()) { |
Felipe Balbi | 6488663 | 2014-06-10 15:01:22 -0500 | [diff] [blame] | 134 | configure_module_pin_mux(rgmii1_pin_mux); |
Miquel Raynal | d093536 | 2019-10-03 19:50:03 +0200 | [diff] [blame] | 135 | #if defined(CONFIG_MTD_RAW_NAND) |
pekon gupta | 3eb6f86 | 2014-07-22 16:03:22 +0530 | [diff] [blame] | 136 | printf("Error: NAND flash not present on this board\n"); |
| 137 | #endif |
Felipe Balbi | 6488663 | 2014-06-10 15:01:22 -0500 | [diff] [blame] | 138 | configure_module_pin_mux(qspi_pin_mux); |
Mugunthan V N | c94f954 | 2014-02-18 07:31:54 -0500 | [diff] [blame] | 139 | } else if (board_is_eposevm()) { |
| 140 | configure_module_pin_mux(rmii1_pin_mux); |
Miquel Raynal | d093536 | 2019-10-03 19:50:03 +0200 | [diff] [blame] | 141 | #if defined(CONFIG_MTD_RAW_NAND) |
pekon gupta | 3eb6f86 | 2014-07-22 16:03:22 +0530 | [diff] [blame] | 142 | configure_module_pin_mux(nand_pin_mux); |
| 143 | #else |
Mugunthan V N | c94f954 | 2014-02-18 07:31:54 -0500 | [diff] [blame] | 144 | configure_module_pin_mux(qspi_pin_mux); |
pekon gupta | 3eb6f86 | 2014-07-22 16:03:22 +0530 | [diff] [blame] | 145 | #endif |
Mugunthan V N | c94f954 | 2014-02-18 07:31:54 -0500 | [diff] [blame] | 146 | } |
Lokesh Vutla | faa680f | 2013-07-30 11:36:27 +0530 | [diff] [blame] | 147 | } |
Lokesh Vutla | 42c213a | 2013-12-10 15:02:20 +0530 | [diff] [blame] | 148 | |
| 149 | void enable_i2c0_pin_mux(void) |
| 150 | { |
| 151 | configure_module_pin_mux(i2c0_pin_mux); |
| 152 | } |