Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * mux.c |
| 3 | * |
Nishanth Menon | eaa39c6 | 2023-11-01 15:56:03 -0500 | [diff] [blame] | 4 | * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/ |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation version 2. |
| 9 | * |
| 10 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any |
| 11 | * kind, whether express or implied; without even the implied warranty |
| 12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 16 | #include <asm/arch/sys_proto.h> |
| 17 | #include <asm/arch/hardware.h> |
| 18 | #include <asm/arch/mux.h> |
| 19 | #include <asm/io.h> |
| 20 | #include <i2c.h> |
| 21 | #include "board.h" |
| 22 | |
| 23 | static struct module_pin_mux uart0_pin_mux[] = { |
| 24 | {OFFSET(uart0_rxd), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* UART0_RXD */ |
| 25 | {OFFSET(uart0_txd), (MODE(0) | PULLUDEN)}, /* UART0_TXD */ |
| 26 | {-1}, |
| 27 | }; |
| 28 | |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 29 | static struct module_pin_mux mmc0_pin_mux[] = { |
| 30 | {OFFSET(mmc0_dat3), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT3 */ |
| 31 | {OFFSET(mmc0_dat2), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT2 */ |
| 32 | {OFFSET(mmc0_dat1), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT1 */ |
| 33 | {OFFSET(mmc0_dat0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_DAT0 */ |
| 34 | {OFFSET(mmc0_clk), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CLK */ |
| 35 | {OFFSET(mmc0_cmd), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* MMC0_CMD */ |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 36 | {-1}, |
| 37 | }; |
| 38 | |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 39 | static struct module_pin_mux i2c1_pin_mux[] = { |
| 40 | {OFFSET(spi0_d1), (MODE(2) | RXACTIVE | |
| 41 | PULLUDEN | SLEWCTRL)}, /* I2C_DATA */ |
| 42 | {OFFSET(spi0_cs0), (MODE(2) | RXACTIVE | |
| 43 | PULLUDEN | SLEWCTRL)}, /* I2C_SCLK */ |
| 44 | {-1}, |
| 45 | }; |
| 46 | |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 47 | static struct module_pin_mux rmii1_pin_mux[] = { |
| 48 | {OFFSET(mii1_crs), MODE(1) | RXACTIVE}, /* RGMII1_TCTL */ |
| 49 | {OFFSET(mii1_txen), MODE(1)}, /* RGMII1_TCTL */ |
| 50 | {OFFSET(mii1_txd1), MODE(1)}, /* RGMII1_TCTL */ |
| 51 | {OFFSET(mii1_txd0), MODE(1)}, /* RGMII1_TCTL */ |
| 52 | {OFFSET(mii1_rxd1), MODE(1) | RXACTIVE}, /* RGMII1_TCTL */ |
| 53 | {OFFSET(mii1_rxd0), MODE(1) | RXACTIVE}, /* RGMII1_TCTL */ |
| 54 | {OFFSET(rmii1_refclk), MODE(0) | RXACTIVE}, /* RGMII1_TCTL */ |
| 55 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */ |
| 56 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
| 57 | {-1}, |
| 58 | }; |
| 59 | |
| 60 | static struct module_pin_mux rgmii2_pin_mux[] = { |
| 61 | {OFFSET(gpmc_a0), MODE(2)}, /* RGMII1_TCTL */ |
| 62 | {OFFSET(gpmc_a1), MODE(2) | RXACTIVE}, /* RGMII1_RCTL */ |
| 63 | {OFFSET(gpmc_a2), MODE(2)}, /* RGMII1_TD3 */ |
| 64 | {OFFSET(gpmc_a3), MODE(2)}, /* RGMII1_TD2 */ |
| 65 | {OFFSET(gpmc_a4), MODE(2)}, /* RGMII1_TD1 */ |
| 66 | {OFFSET(gpmc_a5), MODE(2)}, /* RGMII1_TD0 */ |
| 67 | {OFFSET(gpmc_a6), MODE(2)}, /* RGMII1_TCLK */ |
| 68 | {OFFSET(gpmc_a7), MODE(2) | RXACTIVE}, /* RGMII1_RCLK */ |
| 69 | {OFFSET(gpmc_a8), MODE(2) | RXACTIVE}, /* RGMII1_RD3 */ |
| 70 | {OFFSET(gpmc_a9), MODE(2) | RXACTIVE}, /* RGMII1_RD2 */ |
| 71 | {OFFSET(gpmc_a10), MODE(2) | RXACTIVE}, /* RGMII1_RD1 */ |
| 72 | {OFFSET(gpmc_a11), MODE(2) | RXACTIVE}, /* RGMII1_RD0 */ |
| 73 | {OFFSET(mdio_data), MODE(0) | RXACTIVE | PULLUP_EN},/* MDIO_DATA */ |
| 74 | {OFFSET(mdio_clk), MODE(0) | PULLUP_EN}, /* MDIO_CLK */ |
| 75 | {-1}, |
| 76 | }; |
| 77 | |
| 78 | static struct module_pin_mux nand_pin_mux[] = { |
| 79 | {OFFSET(gpmc_ad0), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD0 */ |
| 80 | {OFFSET(gpmc_ad1), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD1 */ |
| 81 | {OFFSET(gpmc_ad2), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD2 */ |
| 82 | {OFFSET(gpmc_ad3), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD3 */ |
| 83 | {OFFSET(gpmc_ad4), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD4 */ |
| 84 | {OFFSET(gpmc_ad5), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD5 */ |
| 85 | {OFFSET(gpmc_ad6), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD6 */ |
| 86 | {OFFSET(gpmc_ad7), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD7 */ |
| 87 | {OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */ |
| 88 | {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)}, /* NAND_WPN */ |
| 89 | {OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)}, /* NAND_CS0 */ |
| 90 | {OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */ |
| 91 | {OFFSET(gpmc_oen_ren), (MODE(0) | PULLUDEN)}, /* NAND_OE */ |
| 92 | {OFFSET(gpmc_wen), (MODE(0) | PULLUDEN)}, /* NAND_WEN */ |
| 93 | {OFFSET(gpmc_be0n_cle), (MODE(0) | PULLUDEN)}, /* NAND_BE_CLE */ |
| 94 | {-1}, |
| 95 | }; |
| 96 | |
| 97 | void enable_uart0_pin_mux(void) |
| 98 | { |
| 99 | configure_module_pin_mux(uart0_pin_mux); |
| 100 | } |
| 101 | |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 102 | void enable_i2c1_pin_mux(void) |
| 103 | { |
| 104 | configure_module_pin_mux(i2c1_pin_mux); |
| 105 | } |
| 106 | |
| 107 | void enable_board_pin_mux() |
| 108 | { |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 109 | configure_module_pin_mux(i2c1_pin_mux); |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 110 | configure_module_pin_mux(rgmii2_pin_mux); |
| 111 | configure_module_pin_mux(rmii1_pin_mux); |
| 112 | configure_module_pin_mux(mmc0_pin_mux); |
| 113 | |
Miquel Raynal | d093536 | 2019-10-03 19:50:03 +0200 | [diff] [blame] | 114 | #if defined(CONFIG_MTD_RAW_NAND) |
Yegor Yefremov | fa8b71b | 2015-05-29 19:27:29 +0200 | [diff] [blame] | 115 | configure_module_pin_mux(nand_pin_mux); |
| 116 | #endif |
| 117 | } |