Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2010-2013 Freescale Semiconductor, Inc. |
| 4 | * Copyright (C) 2013, Boundary Devices <info@boundarydevices.com> |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 8 | #include <command.h> |
Simon Glass | c7694dd | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 9 | #include <env.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 11 | #include <net.h> |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 12 | #include <asm/io.h> |
| 13 | #include <asm/arch/clock.h> |
| 14 | #include <asm/arch/imx-regs.h> |
| 15 | #include <asm/arch/iomux.h> |
| 16 | #include <asm/arch/sys_proto.h> |
| 17 | #include <malloc.h> |
| 18 | #include <asm/arch/mx6-pins.h> |
Simon Glass | c05ed00 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 19 | #include <linux/delay.h> |
Masahiro Yamada | 1221ce4 | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 20 | #include <linux/errno.h> |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 21 | #include <asm/gpio.h> |
Stefano Babic | 552a848 | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 22 | #include <asm/mach-imx/iomux-v3.h> |
| 23 | #include <asm/mach-imx/mxc_i2c.h> |
| 24 | #include <asm/mach-imx/sata.h> |
| 25 | #include <asm/mach-imx/spi.h> |
| 26 | #include <asm/mach-imx/boot_mode.h> |
| 27 | #include <asm/mach-imx/video.h> |
Yangbo Lu | e37ac71 | 2019-06-21 11:42:28 +0800 | [diff] [blame] | 28 | #include <fsl_esdhc_imx.h> |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 29 | #include <micrel.h> |
| 30 | #include <miiphy.h> |
| 31 | #include <netdev.h> |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 32 | #include <asm/arch/crm_regs.h> |
| 33 | #include <asm/arch/mxc_hdmi.h> |
| 34 | #include <i2c.h> |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 35 | #include <input.h> |
| 36 | #include <netdev.h> |
Mateusz Kulikowski | e162c6b | 2016-03-31 23:12:23 +0200 | [diff] [blame] | 37 | #include <usb/ehci-ci.h> |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 38 | |
| 39 | DECLARE_GLOBAL_DATA_PTR; |
Troy Kisky | 08ce074 | 2013-09-25 18:41:17 -0700 | [diff] [blame] | 40 | #define GP_USB_OTG_PWR IMX_GPIO_NR(3, 22) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 41 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 42 | #define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 43 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ |
| 44 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 45 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 46 | #define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP | \ |
| 47 | PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \ |
| 48 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 49 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 50 | #define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 51 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 52 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 53 | #define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED | \ |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 54 | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST) |
| 55 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 56 | #define BUTTON_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 57 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 58 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 59 | #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 60 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 61 | PAD_CTL_ODE | PAD_CTL_SRE_FAST) |
| 62 | |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 63 | #define RGB_PAD_CTRL PAD_CTL_DSE_120ohm |
| 64 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 65 | #define WEAK_PULLUP (PAD_CTL_PUS_100K_UP | \ |
| 66 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 67 | PAD_CTL_SRE_SLOW) |
| 68 | |
Benoît Thébaudeau | 7e2173c | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 69 | #define WEAK_PULLDOWN (PAD_CTL_PUS_100K_DOWN | \ |
| 70 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ |
| 71 | PAD_CTL_HYS | PAD_CTL_SRE_SLOW) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 72 | |
| 73 | #define OUTPUT_40OHM (PAD_CTL_SPEED_MED|PAD_CTL_DSE_40ohm) |
| 74 | |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 75 | /* Prevent compiler error if gpio number 08 or 09 is used */ |
| 76 | #define not_octal(gp) ((((0x##gp >> 4) & 0xf) * 10) + ((0x##gp & 0xf))) |
| 77 | |
| 78 | #define _I2C_PADS_INFO_CPU(cpu, i2cnum, scl_pad, scl_bank, scl_gp, \ |
| 79 | sda_pad, sda_bank, sda_gp, pad_ctrl, join_io) { \ |
| 80 | .scl = { \ |
| 81 | .i2c_mode = NEW_PAD_CTRL(cpu##_PAD_##scl_pad##__##i2cnum##_SCL,\ |
| 82 | pad_ctrl), \ |
| 83 | .gpio_mode = NEW_PAD_CTRL( \ |
| 84 | cpu##_PAD_##scl_pad##__GPIO##scl_bank##join_io##scl_gp,\ |
| 85 | pad_ctrl), \ |
| 86 | .gp = IMX_GPIO_NR(scl_bank, not_octal(scl_gp)) \ |
| 87 | }, \ |
| 88 | .sda = { \ |
| 89 | .i2c_mode = NEW_PAD_CTRL(cpu##_PAD_##sda_pad##__##i2cnum##_SDA,\ |
| 90 | pad_ctrl), \ |
| 91 | .gpio_mode = NEW_PAD_CTRL( \ |
| 92 | cpu##_PAD_##sda_pad##__GPIO##sda_bank##join_io##sda_gp,\ |
| 93 | pad_ctrl), \ |
| 94 | .gp = IMX_GPIO_NR(sda_bank, not_octal(sda_gp)) \ |
| 95 | } \ |
| 96 | } |
| 97 | |
| 98 | #define I2C_PADS_INFO_CPU(cpu, i2cnum, scl_pad, scl_bank, scl_gp, \ |
| 99 | sda_pad, sda_bank, sda_gp, pad_ctrl) \ |
| 100 | _I2C_PADS_INFO_CPU(cpu, i2cnum, scl_pad, scl_bank, scl_gp, \ |
| 101 | sda_pad, sda_bank, sda_gp, pad_ctrl, _IO) |
| 102 | |
| 103 | #if defined(CONFIG_MX6QDL) |
| 104 | #define I2C_PADS_INFO_ENTRY(i2cnum, scl_pad, scl_bank, scl_gp, \ |
| 105 | sda_pad, sda_bank, sda_gp, pad_ctrl) \ |
| 106 | I2C_PADS_INFO_CPU(MX6Q, i2cnum, scl_pad, scl_bank, scl_gp, \ |
| 107 | sda_pad, sda_bank, sda_gp, pad_ctrl), \ |
| 108 | I2C_PADS_INFO_CPU(MX6DL, i2cnum, scl_pad, scl_bank, scl_gp, \ |
| 109 | sda_pad, sda_bank, sda_gp, pad_ctrl) |
| 110 | #define I2C_PADS_INFO_ENTRY_SPACING 2 |
| 111 | |
| 112 | #define IOMUX_PAD_CTRL(name, pad_ctrl) \ |
| 113 | NEW_PAD_CTRL(MX6Q_PAD_##name, pad_ctrl), \ |
| 114 | NEW_PAD_CTRL(MX6DL_PAD_##name, pad_ctrl) |
| 115 | #else |
| 116 | #define I2C_PADS_INFO_ENTRY(i2cnum, scl_pad, scl_bank, scl_gp, \ |
| 117 | sda_pad, sda_bank, sda_gp, pad_ctrl) \ |
| 118 | I2C_PADS_INFO_CPU(MX6, i2cnum, scl_pad, scl_bank, scl_gp, \ |
| 119 | sda_pad, sda_bank, sda_gp, pad_ctrl) |
| 120 | #define I2C_PADS_INFO_ENTRY_SPACING 1 |
| 121 | |
| 122 | #define IOMUX_PAD_CTRL(name, pad_ctrl) NEW_PAD_CTRL(MX6_PAD_##name, pad_ctrl) |
| 123 | #endif |
| 124 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 125 | int dram_init(void) |
| 126 | { |
fabio.estevam@freescale.com | 19a0f7f | 2013-03-14 02:32:55 +0000 | [diff] [blame] | 127 | gd->ram_size = ((ulong)CONFIG_DDR_MB * 1024 * 1024); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 128 | |
| 129 | return 0; |
| 130 | } |
| 131 | |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 132 | static iomux_v3_cfg_t const uart1_pads[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 133 | IOMUX_PAD_CTRL(SD3_DAT6__UART1_RX_DATA, UART_PAD_CTRL), |
| 134 | IOMUX_PAD_CTRL(SD3_DAT7__UART1_TX_DATA, UART_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 135 | }; |
| 136 | |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 137 | static iomux_v3_cfg_t const uart2_pads[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 138 | IOMUX_PAD_CTRL(EIM_D26__UART2_TX_DATA, UART_PAD_CTRL), |
| 139 | IOMUX_PAD_CTRL(EIM_D27__UART2_RX_DATA, UART_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 140 | }; |
| 141 | |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 142 | static struct i2c_pads_info i2c_pads[] = { |
| 143 | /* I2C1, SGTL5000 */ |
| 144 | I2C_PADS_INFO_ENTRY(I2C1, EIM_D21, 3, 21, EIM_D28, 3, 28, I2C_PAD_CTRL), |
| 145 | /* I2C2 Camera, MIPI */ |
| 146 | I2C_PADS_INFO_ENTRY(I2C2, KEY_COL3, 4, 12, KEY_ROW3, 4, 13, |
| 147 | I2C_PAD_CTRL), |
| 148 | /* I2C3, J15 - RGB connector */ |
| 149 | I2C_PADS_INFO_ENTRY(I2C3, GPIO_5, 1, 05, GPIO_16, 7, 11, I2C_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 150 | }; |
| 151 | |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 152 | #define I2C_BUS_CNT 3 |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 153 | |
Eric Nelson | 4161247 | 2014-10-02 12:16:24 -0700 | [diff] [blame] | 154 | static iomux_v3_cfg_t const usdhc2_pads[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 155 | IOMUX_PAD_CTRL(SD2_CLK__SD2_CLK, USDHC_PAD_CTRL), |
| 156 | IOMUX_PAD_CTRL(SD2_CMD__SD2_CMD, USDHC_PAD_CTRL), |
| 157 | IOMUX_PAD_CTRL(SD2_DAT0__SD2_DATA0, USDHC_PAD_CTRL), |
| 158 | IOMUX_PAD_CTRL(SD2_DAT1__SD2_DATA1, USDHC_PAD_CTRL), |
| 159 | IOMUX_PAD_CTRL(SD2_DAT2__SD2_DATA2, USDHC_PAD_CTRL), |
| 160 | IOMUX_PAD_CTRL(SD2_DAT3__SD2_DATA3, USDHC_PAD_CTRL), |
Eric Nelson | 4161247 | 2014-10-02 12:16:24 -0700 | [diff] [blame] | 161 | }; |
| 162 | |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 163 | static iomux_v3_cfg_t const enet_pads1[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 164 | IOMUX_PAD_CTRL(ENET_MDIO__ENET_MDIO, ENET_PAD_CTRL), |
| 165 | IOMUX_PAD_CTRL(ENET_MDC__ENET_MDC, ENET_PAD_CTRL), |
| 166 | IOMUX_PAD_CTRL(RGMII_TXC__RGMII_TXC, ENET_PAD_CTRL), |
| 167 | IOMUX_PAD_CTRL(RGMII_TD0__RGMII_TD0, ENET_PAD_CTRL), |
| 168 | IOMUX_PAD_CTRL(RGMII_TD1__RGMII_TD1, ENET_PAD_CTRL), |
| 169 | IOMUX_PAD_CTRL(RGMII_TD2__RGMII_TD2, ENET_PAD_CTRL), |
| 170 | IOMUX_PAD_CTRL(RGMII_TD3__RGMII_TD3, ENET_PAD_CTRL), |
| 171 | IOMUX_PAD_CTRL(RGMII_TX_CTL__RGMII_TX_CTL, ENET_PAD_CTRL), |
| 172 | IOMUX_PAD_CTRL(ENET_REF_CLK__ENET_TX_CLK, ENET_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 173 | /* pin 35 - 1 (PHY_AD2) on reset */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 174 | IOMUX_PAD_CTRL(RGMII_RXC__GPIO6_IO30, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 175 | /* pin 32 - 1 - (MODE0) all */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 176 | IOMUX_PAD_CTRL(RGMII_RD0__GPIO6_IO25, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 177 | /* pin 31 - 1 - (MODE1) all */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 178 | IOMUX_PAD_CTRL(RGMII_RD1__GPIO6_IO27, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 179 | /* pin 28 - 1 - (MODE2) all */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 180 | IOMUX_PAD_CTRL(RGMII_RD2__GPIO6_IO28, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 181 | /* pin 27 - 1 - (MODE3) all */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 182 | IOMUX_PAD_CTRL(RGMII_RD3__GPIO6_IO29, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 183 | /* pin 33 - 1 - (CLK125_EN) 125Mhz clockout enabled */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 184 | IOMUX_PAD_CTRL(RGMII_RX_CTL__GPIO6_IO24, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 185 | /* pin 42 PHY nRST */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 186 | IOMUX_PAD_CTRL(EIM_D23__GPIO3_IO23, NO_PAD_CTRL), |
| 187 | IOMUX_PAD_CTRL(ENET_RXD0__GPIO1_IO27, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 188 | }; |
| 189 | |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 190 | static iomux_v3_cfg_t const enet_pads2[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 191 | IOMUX_PAD_CTRL(RGMII_RXC__RGMII_RXC, ENET_PAD_CTRL), |
| 192 | IOMUX_PAD_CTRL(RGMII_RD0__RGMII_RD0, ENET_PAD_CTRL), |
| 193 | IOMUX_PAD_CTRL(RGMII_RD1__RGMII_RD1, ENET_PAD_CTRL), |
| 194 | IOMUX_PAD_CTRL(RGMII_RD2__RGMII_RD2, ENET_PAD_CTRL), |
| 195 | IOMUX_PAD_CTRL(RGMII_RD3__RGMII_RD3, ENET_PAD_CTRL), |
| 196 | IOMUX_PAD_CTRL(RGMII_RX_CTL__RGMII_RX_CTL, ENET_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 197 | }; |
| 198 | |
Troy Kisky | 08ce074 | 2013-09-25 18:41:17 -0700 | [diff] [blame] | 199 | static iomux_v3_cfg_t const misc_pads[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 200 | IOMUX_PAD_CTRL(GPIO_1__USB_OTG_ID, WEAK_PULLUP), |
| 201 | IOMUX_PAD_CTRL(KEY_COL4__USB_OTG_OC, WEAK_PULLUP), |
| 202 | IOMUX_PAD_CTRL(EIM_D30__USB_H1_OC, WEAK_PULLUP), |
Troy Kisky | 08ce074 | 2013-09-25 18:41:17 -0700 | [diff] [blame] | 203 | /* OTG Power enable */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 204 | IOMUX_PAD_CTRL(EIM_D22__GPIO3_IO22, OUTPUT_40OHM), |
Troy Kisky | 08ce074 | 2013-09-25 18:41:17 -0700 | [diff] [blame] | 205 | }; |
| 206 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 207 | /* wl1271 pads on nitrogen6x */ |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 208 | static iomux_v3_cfg_t const wl12xx_pads[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 209 | IOMUX_PAD_CTRL(NANDF_CS1__GPIO6_IO14, WEAK_PULLDOWN), |
| 210 | IOMUX_PAD_CTRL(NANDF_CS2__GPIO6_IO15, OUTPUT_40OHM), |
| 211 | IOMUX_PAD_CTRL(NANDF_CS3__GPIO6_IO16, OUTPUT_40OHM), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 212 | }; |
| 213 | #define WL12XX_WL_IRQ_GP IMX_GPIO_NR(6, 14) |
| 214 | #define WL12XX_WL_ENABLE_GP IMX_GPIO_NR(6, 15) |
| 215 | #define WL12XX_BT_ENABLE_GP IMX_GPIO_NR(6, 16) |
| 216 | |
| 217 | /* Button assignments for J14 */ |
| 218 | static iomux_v3_cfg_t const button_pads[] = { |
| 219 | /* Menu */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 220 | IOMUX_PAD_CTRL(NANDF_D1__GPIO2_IO01, BUTTON_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 221 | /* Back */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 222 | IOMUX_PAD_CTRL(NANDF_D2__GPIO2_IO02, BUTTON_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 223 | /* Labelled Search (mapped to Power under Android) */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 224 | IOMUX_PAD_CTRL(NANDF_D3__GPIO2_IO03, BUTTON_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 225 | /* Home */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 226 | IOMUX_PAD_CTRL(NANDF_D4__GPIO2_IO04, BUTTON_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 227 | /* Volume Down */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 228 | IOMUX_PAD_CTRL(GPIO_19__GPIO4_IO05, BUTTON_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 229 | /* Volume Up */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 230 | IOMUX_PAD_CTRL(GPIO_18__GPIO7_IO13, BUTTON_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 231 | }; |
| 232 | |
| 233 | static void setup_iomux_enet(void) |
| 234 | { |
| 235 | gpio_direction_output(IMX_GPIO_NR(3, 23), 0); /* SABRE Lite PHY rst */ |
| 236 | gpio_direction_output(IMX_GPIO_NR(1, 27), 0); /* Nitrogen6X PHY rst */ |
| 237 | gpio_direction_output(IMX_GPIO_NR(6, 30), 1); |
| 238 | gpio_direction_output(IMX_GPIO_NR(6, 25), 1); |
| 239 | gpio_direction_output(IMX_GPIO_NR(6, 27), 1); |
| 240 | gpio_direction_output(IMX_GPIO_NR(6, 28), 1); |
| 241 | gpio_direction_output(IMX_GPIO_NR(6, 29), 1); |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 242 | SETUP_IOMUX_PADS(enet_pads1); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 243 | gpio_direction_output(IMX_GPIO_NR(6, 24), 1); |
| 244 | |
| 245 | /* Need delay 10ms according to KSZ9021 spec */ |
| 246 | udelay(1000 * 10); |
| 247 | gpio_set_value(IMX_GPIO_NR(3, 23), 1); /* SABRE Lite PHY reset */ |
| 248 | gpio_set_value(IMX_GPIO_NR(1, 27), 1); /* Nitrogen6X PHY reset */ |
| 249 | |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 250 | SETUP_IOMUX_PADS(enet_pads2); |
Troy Kisky | adc4a2b | 2014-10-02 12:16:29 -0700 | [diff] [blame] | 251 | udelay(100); /* Wait 100 us before using mii interface */ |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 252 | } |
| 253 | |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 254 | static iomux_v3_cfg_t const usb_pads[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 255 | IOMUX_PAD_CTRL(GPIO_17__GPIO7_IO12, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | static void setup_iomux_uart(void) |
| 259 | { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 260 | SETUP_IOMUX_PADS(uart1_pads); |
| 261 | SETUP_IOMUX_PADS(uart2_pads); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | #ifdef CONFIG_USB_EHCI_MX6 |
| 265 | int board_ehci_hcd_init(int port) |
| 266 | { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 267 | SETUP_IOMUX_PADS(usb_pads); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 268 | |
| 269 | /* Reset USB hub */ |
| 270 | gpio_direction_output(IMX_GPIO_NR(7, 12), 0); |
| 271 | mdelay(2); |
| 272 | gpio_set_value(IMX_GPIO_NR(7, 12), 1); |
| 273 | |
| 274 | return 0; |
| 275 | } |
Troy Kisky | 08ce074 | 2013-09-25 18:41:17 -0700 | [diff] [blame] | 276 | |
| 277 | int board_ehci_power(int port, int on) |
| 278 | { |
| 279 | if (port) |
| 280 | return 0; |
| 281 | gpio_set_value(GP_USB_OTG_PWR, on); |
| 282 | return 0; |
| 283 | } |
| 284 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 285 | #endif |
| 286 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 287 | #ifdef CONFIG_MXC_SPI |
Nikita Kiryanov | 155fa9a | 2014-08-20 15:08:50 +0300 | [diff] [blame] | 288 | int board_spi_cs_gpio(unsigned bus, unsigned cs) |
| 289 | { |
| 290 | return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(3, 19)) : -1; |
| 291 | } |
| 292 | |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 293 | static iomux_v3_cfg_t const ecspi1_pads[] = { |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 294 | /* SS1 */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 295 | IOMUX_PAD_CTRL(EIM_D19__GPIO3_IO19, NO_PAD_CTRL), |
| 296 | IOMUX_PAD_CTRL(EIM_D17__ECSPI1_MISO, SPI_PAD_CTRL), |
| 297 | IOMUX_PAD_CTRL(EIM_D18__ECSPI1_MOSI, SPI_PAD_CTRL), |
| 298 | IOMUX_PAD_CTRL(EIM_D16__ECSPI1_SCLK, SPI_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 299 | }; |
| 300 | |
Eric Nelson | 9fc4252 | 2014-10-02 12:16:27 -0700 | [diff] [blame] | 301 | static void setup_spi(void) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 302 | { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 303 | SETUP_IOMUX_PADS(ecspi1_pads); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 304 | } |
| 305 | #endif |
| 306 | |
| 307 | int board_phy_config(struct phy_device *phydev) |
| 308 | { |
| 309 | /* min rx data delay */ |
| 310 | ksz9021_phy_extended_write(phydev, |
| 311 | MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW, 0x0); |
| 312 | /* min tx data delay */ |
| 313 | ksz9021_phy_extended_write(phydev, |
| 314 | MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW, 0x0); |
| 315 | /* max rx/tx clock delay, min rx/tx control */ |
| 316 | ksz9021_phy_extended_write(phydev, |
| 317 | MII_KSZ9021_EXT_RGMII_CLOCK_SKEW, 0xf0f0); |
| 318 | if (phydev->drv->config) |
| 319 | phydev->drv->config(phydev); |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | |
Masahiro Yamada | b75d8dc | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 324 | int board_eth_init(struct bd_info *bis) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 325 | { |
| 326 | uint32_t base = IMX_FEC_BASE; |
| 327 | struct mii_dev *bus = NULL; |
| 328 | struct phy_device *phydev = NULL; |
| 329 | int ret; |
| 330 | |
Troy Kisky | 1b51e5f | 2019-07-29 12:15:56 -0700 | [diff] [blame] | 331 | gpio_request(WL12XX_WL_IRQ_GP, "wifi_irq"); |
| 332 | gpio_request(IMX_GPIO_NR(6, 30), "rgmii_rxc"); |
| 333 | gpio_request(IMX_GPIO_NR(6, 25), "rgmii_rd0"); |
| 334 | gpio_request(IMX_GPIO_NR(6, 27), "rgmii_rd1"); |
| 335 | gpio_request(IMX_GPIO_NR(6, 28), "rgmii_rd2"); |
| 336 | gpio_request(IMX_GPIO_NR(6, 29), "rgmii_rd3"); |
| 337 | gpio_request(IMX_GPIO_NR(6, 24), "rgmii_rx_ctl"); |
| 338 | gpio_request(IMX_GPIO_NR(3, 23), "rgmii_reset_sabrelite"); |
| 339 | gpio_request(IMX_GPIO_NR(1, 27), "rgmii_reset_nitrogen6x"); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 340 | setup_iomux_enet(); |
| 341 | |
| 342 | #ifdef CONFIG_FEC_MXC |
| 343 | bus = fec_get_miibus(base, -1); |
| 344 | if (!bus) |
Fabio Estevam | 747472b | 2015-09-11 00:53:51 -0300 | [diff] [blame] | 345 | return -EINVAL; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 346 | /* scan phy 4,5,6,7 */ |
| 347 | phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII); |
| 348 | if (!phydev) { |
Fabio Estevam | 747472b | 2015-09-11 00:53:51 -0300 | [diff] [blame] | 349 | ret = -EINVAL; |
| 350 | goto free_bus; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 351 | } |
| 352 | printf("using phy at %d\n", phydev->addr); |
| 353 | ret = fec_probe(bis, -1, base, bus, phydev); |
Fabio Estevam | 747472b | 2015-09-11 00:53:51 -0300 | [diff] [blame] | 354 | if (ret) |
| 355 | goto free_phydev; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 356 | #endif |
Troy Kisky | 08ce074 | 2013-09-25 18:41:17 -0700 | [diff] [blame] | 357 | |
Marek Vasut | f016f8c | 2014-02-06 02:43:45 +0100 | [diff] [blame] | 358 | #ifdef CONFIG_CI_UDC |
Troy Kisky | 08ce074 | 2013-09-25 18:41:17 -0700 | [diff] [blame] | 359 | /* For otg ethernet*/ |
| 360 | usb_eth_initialize(bis); |
| 361 | #endif |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 362 | return 0; |
Fabio Estevam | 747472b | 2015-09-11 00:53:51 -0300 | [diff] [blame] | 363 | |
| 364 | free_phydev: |
| 365 | free(phydev); |
| 366 | free_bus: |
| 367 | free(bus); |
| 368 | return ret; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | static void setup_buttons(void) |
| 372 | { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 373 | SETUP_IOMUX_PADS(button_pads); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 374 | } |
| 375 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 376 | #if defined(CONFIG_VIDEO_IPUV3) |
| 377 | |
| 378 | static iomux_v3_cfg_t const backlight_pads[] = { |
| 379 | /* Backlight on RGB connector: J15 */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 380 | IOMUX_PAD_CTRL(SD1_DAT3__GPIO1_IO21, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 381 | #define RGB_BACKLIGHT_GP IMX_GPIO_NR(1, 21) |
| 382 | |
| 383 | /* Backlight on LVDS connector: J6 */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 384 | IOMUX_PAD_CTRL(SD1_CMD__GPIO1_IO18, NO_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 385 | #define LVDS_BACKLIGHT_GP IMX_GPIO_NR(1, 18) |
| 386 | }; |
| 387 | |
| 388 | static iomux_v3_cfg_t const rgb_pads[] = { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 389 | IOMUX_PAD_CTRL(DI0_DISP_CLK__IPU1_DI0_DISP_CLK, RGB_PAD_CTRL), |
| 390 | IOMUX_PAD_CTRL(DI0_PIN15__IPU1_DI0_PIN15, RGB_PAD_CTRL), |
| 391 | IOMUX_PAD_CTRL(DI0_PIN2__IPU1_DI0_PIN02, RGB_PAD_CTRL), |
| 392 | IOMUX_PAD_CTRL(DI0_PIN3__IPU1_DI0_PIN03, RGB_PAD_CTRL), |
| 393 | IOMUX_PAD_CTRL(DI0_PIN4__GPIO4_IO20, RGB_PAD_CTRL), |
| 394 | IOMUX_PAD_CTRL(DISP0_DAT0__IPU1_DISP0_DATA00, RGB_PAD_CTRL), |
| 395 | IOMUX_PAD_CTRL(DISP0_DAT1__IPU1_DISP0_DATA01, RGB_PAD_CTRL), |
| 396 | IOMUX_PAD_CTRL(DISP0_DAT2__IPU1_DISP0_DATA02, RGB_PAD_CTRL), |
| 397 | IOMUX_PAD_CTRL(DISP0_DAT3__IPU1_DISP0_DATA03, RGB_PAD_CTRL), |
| 398 | IOMUX_PAD_CTRL(DISP0_DAT4__IPU1_DISP0_DATA04, RGB_PAD_CTRL), |
| 399 | IOMUX_PAD_CTRL(DISP0_DAT5__IPU1_DISP0_DATA05, RGB_PAD_CTRL), |
| 400 | IOMUX_PAD_CTRL(DISP0_DAT6__IPU1_DISP0_DATA06, RGB_PAD_CTRL), |
| 401 | IOMUX_PAD_CTRL(DISP0_DAT7__IPU1_DISP0_DATA07, RGB_PAD_CTRL), |
| 402 | IOMUX_PAD_CTRL(DISP0_DAT8__IPU1_DISP0_DATA08, RGB_PAD_CTRL), |
| 403 | IOMUX_PAD_CTRL(DISP0_DAT9__IPU1_DISP0_DATA09, RGB_PAD_CTRL), |
| 404 | IOMUX_PAD_CTRL(DISP0_DAT10__IPU1_DISP0_DATA10, RGB_PAD_CTRL), |
| 405 | IOMUX_PAD_CTRL(DISP0_DAT11__IPU1_DISP0_DATA11, RGB_PAD_CTRL), |
| 406 | IOMUX_PAD_CTRL(DISP0_DAT12__IPU1_DISP0_DATA12, RGB_PAD_CTRL), |
| 407 | IOMUX_PAD_CTRL(DISP0_DAT13__IPU1_DISP0_DATA13, RGB_PAD_CTRL), |
| 408 | IOMUX_PAD_CTRL(DISP0_DAT14__IPU1_DISP0_DATA14, RGB_PAD_CTRL), |
| 409 | IOMUX_PAD_CTRL(DISP0_DAT15__IPU1_DISP0_DATA15, RGB_PAD_CTRL), |
| 410 | IOMUX_PAD_CTRL(DISP0_DAT16__IPU1_DISP0_DATA16, RGB_PAD_CTRL), |
| 411 | IOMUX_PAD_CTRL(DISP0_DAT17__IPU1_DISP0_DATA17, RGB_PAD_CTRL), |
| 412 | IOMUX_PAD_CTRL(DISP0_DAT18__IPU1_DISP0_DATA18, RGB_PAD_CTRL), |
| 413 | IOMUX_PAD_CTRL(DISP0_DAT19__IPU1_DISP0_DATA19, RGB_PAD_CTRL), |
| 414 | IOMUX_PAD_CTRL(DISP0_DAT20__IPU1_DISP0_DATA20, RGB_PAD_CTRL), |
| 415 | IOMUX_PAD_CTRL(DISP0_DAT21__IPU1_DISP0_DATA21, RGB_PAD_CTRL), |
| 416 | IOMUX_PAD_CTRL(DISP0_DAT22__IPU1_DISP0_DATA22, RGB_PAD_CTRL), |
| 417 | IOMUX_PAD_CTRL(DISP0_DAT23__IPU1_DISP0_DATA23, RGB_PAD_CTRL), |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 418 | }; |
| 419 | |
Pardeep Kumar Singla | 5ea7f0e | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 420 | static void do_enable_hdmi(struct display_info_t const *dev) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 421 | { |
Pardeep Kumar Singla | 5ea7f0e | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 422 | imx_enable_hdmi_phy(); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 423 | } |
| 424 | |
| 425 | static int detect_i2c(struct display_info_t const *dev) |
| 426 | { |
| 427 | return ((0 == i2c_set_bus_num(dev->bus)) |
| 428 | && |
| 429 | (0 == i2c_probe(dev->addr))); |
| 430 | } |
| 431 | |
| 432 | static void enable_lvds(struct display_info_t const *dev) |
| 433 | { |
| 434 | struct iomuxc *iomux = (struct iomuxc *) |
| 435 | IOMUXC_BASE_ADDR; |
| 436 | u32 reg = readl(&iomux->gpr[2]); |
| 437 | reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT; |
| 438 | writel(reg, &iomux->gpr[2]); |
| 439 | gpio_direction_output(LVDS_BACKLIGHT_GP, 1); |
| 440 | } |
| 441 | |
Robert Winkler | 4328fb0 | 2014-10-02 12:16:31 -0700 | [diff] [blame] | 442 | static void enable_lvds_jeida(struct display_info_t const *dev) |
| 443 | { |
| 444 | struct iomuxc *iomux = (struct iomuxc *) |
| 445 | IOMUXC_BASE_ADDR; |
| 446 | u32 reg = readl(&iomux->gpr[2]); |
| 447 | reg |= IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT |
| 448 | |IOMUXC_GPR2_BIT_MAPPING_CH0_JEIDA; |
| 449 | writel(reg, &iomux->gpr[2]); |
| 450 | gpio_direction_output(LVDS_BACKLIGHT_GP, 1); |
| 451 | } |
| 452 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 453 | static void enable_rgb(struct display_info_t const *dev) |
| 454 | { |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 455 | SETUP_IOMUX_PADS(rgb_pads); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 456 | gpio_direction_output(RGB_BACKLIGHT_GP, 1); |
| 457 | } |
| 458 | |
Eric Benard | a47e449 | 2014-04-04 19:05:53 +0200 | [diff] [blame] | 459 | struct display_info_t const displays[] = {{ |
Eric Nelson | ce9507b | 2014-10-02 12:16:39 -0700 | [diff] [blame] | 460 | .bus = 1, |
| 461 | .addr = 0x50, |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 462 | .pixfmt = IPU_PIX_FMT_RGB24, |
Eric Nelson | ce9507b | 2014-10-02 12:16:39 -0700 | [diff] [blame] | 463 | .detect = detect_i2c, |
Pardeep Kumar Singla | 5ea7f0e | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 464 | .enable = do_enable_hdmi, |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 465 | .mode = { |
| 466 | .name = "HDMI", |
| 467 | .refresh = 60, |
| 468 | .xres = 1024, |
| 469 | .yres = 768, |
| 470 | .pixclock = 15385, |
| 471 | .left_margin = 220, |
| 472 | .right_margin = 40, |
| 473 | .upper_margin = 21, |
| 474 | .lower_margin = 7, |
| 475 | .hsync_len = 60, |
| 476 | .vsync_len = 10, |
| 477 | .sync = FB_SYNC_EXT, |
| 478 | .vmode = FB_VMODE_NONINTERLACED |
| 479 | } }, { |
Robert Winkler | 4328fb0 | 2014-10-02 12:16:31 -0700 | [diff] [blame] | 480 | .bus = 0, |
| 481 | .addr = 0, |
| 482 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 483 | .detect = NULL, |
| 484 | .enable = enable_lvds_jeida, |
| 485 | .mode = { |
| 486 | .name = "LDB-WXGA", |
| 487 | .refresh = 60, |
| 488 | .xres = 1280, |
| 489 | .yres = 800, |
| 490 | .pixclock = 14065, |
| 491 | .left_margin = 40, |
| 492 | .right_margin = 40, |
| 493 | .upper_margin = 3, |
| 494 | .lower_margin = 80, |
| 495 | .hsync_len = 10, |
| 496 | .vsync_len = 10, |
| 497 | .sync = FB_SYNC_EXT, |
| 498 | .vmode = FB_VMODE_NONINTERLACED |
| 499 | } }, { |
Eric Nelson | d6949e3 | 2014-10-02 12:16:34 -0700 | [diff] [blame] | 500 | .bus = 0, |
| 501 | .addr = 0, |
| 502 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 503 | .detect = NULL, |
| 504 | .enable = enable_lvds, |
| 505 | .mode = { |
| 506 | .name = "LDB-WXGA-S", |
| 507 | .refresh = 60, |
| 508 | .xres = 1280, |
| 509 | .yres = 800, |
| 510 | .pixclock = 14065, |
| 511 | .left_margin = 40, |
| 512 | .right_margin = 40, |
| 513 | .upper_margin = 3, |
| 514 | .lower_margin = 80, |
| 515 | .hsync_len = 10, |
| 516 | .vsync_len = 10, |
| 517 | .sync = FB_SYNC_EXT, |
| 518 | .vmode = FB_VMODE_NONINTERLACED |
| 519 | } }, { |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 520 | .bus = 2, |
| 521 | .addr = 0x4, |
| 522 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 523 | .detect = detect_i2c, |
| 524 | .enable = enable_lvds, |
| 525 | .mode = { |
| 526 | .name = "Hannstar-XGA", |
| 527 | .refresh = 60, |
| 528 | .xres = 1024, |
| 529 | .yres = 768, |
| 530 | .pixclock = 15385, |
| 531 | .left_margin = 220, |
| 532 | .right_margin = 40, |
| 533 | .upper_margin = 21, |
| 534 | .lower_margin = 7, |
| 535 | .hsync_len = 60, |
| 536 | .vsync_len = 10, |
| 537 | .sync = FB_SYNC_EXT, |
| 538 | .vmode = FB_VMODE_NONINTERLACED |
| 539 | } }, { |
Eric Nelson | 4adc112 | 2014-10-02 12:16:33 -0700 | [diff] [blame] | 540 | .bus = 0, |
| 541 | .addr = 0, |
| 542 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 543 | .detect = NULL, |
| 544 | .enable = enable_lvds, |
| 545 | .mode = { |
| 546 | .name = "LG-9.7", |
| 547 | .refresh = 60, |
| 548 | .xres = 1024, |
| 549 | .yres = 768, |
| 550 | .pixclock = 15385, /* ~65MHz */ |
| 551 | .left_margin = 480, |
| 552 | .right_margin = 260, |
| 553 | .upper_margin = 16, |
| 554 | .lower_margin = 6, |
| 555 | .hsync_len = 250, |
| 556 | .vsync_len = 10, |
| 557 | .sync = FB_SYNC_EXT, |
| 558 | .vmode = FB_VMODE_NONINTERLACED |
| 559 | } }, { |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 560 | .bus = 2, |
| 561 | .addr = 0x38, |
| 562 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 563 | .detect = detect_i2c, |
| 564 | .enable = enable_lvds, |
| 565 | .mode = { |
| 566 | .name = "wsvga-lvds", |
| 567 | .refresh = 60, |
| 568 | .xres = 1024, |
| 569 | .yres = 600, |
| 570 | .pixclock = 15385, |
| 571 | .left_margin = 220, |
| 572 | .right_margin = 40, |
| 573 | .upper_margin = 21, |
| 574 | .lower_margin = 7, |
| 575 | .hsync_len = 60, |
| 576 | .vsync_len = 10, |
| 577 | .sync = FB_SYNC_EXT, |
| 578 | .vmode = FB_VMODE_NONINTERLACED |
| 579 | } }, { |
| 580 | .bus = 2, |
Eric Nelson | 04edda2 | 2014-10-02 12:16:35 -0700 | [diff] [blame] | 581 | .addr = 0x10, |
| 582 | .pixfmt = IPU_PIX_FMT_RGB666, |
| 583 | .detect = detect_i2c, |
| 584 | .enable = enable_rgb, |
| 585 | .mode = { |
| 586 | .name = "fusion7", |
| 587 | .refresh = 60, |
| 588 | .xres = 800, |
| 589 | .yres = 480, |
| 590 | .pixclock = 33898, |
| 591 | .left_margin = 96, |
| 592 | .right_margin = 24, |
| 593 | .upper_margin = 3, |
| 594 | .lower_margin = 10, |
| 595 | .hsync_len = 72, |
| 596 | .vsync_len = 7, |
| 597 | .sync = 0x40000002, |
| 598 | .vmode = FB_VMODE_NONINTERLACED |
| 599 | } }, { |
Eric Nelson | 1356630 | 2014-10-02 12:16:36 -0700 | [diff] [blame] | 600 | .bus = 0, |
| 601 | .addr = 0, |
| 602 | .pixfmt = IPU_PIX_FMT_RGB666, |
| 603 | .detect = NULL, |
| 604 | .enable = enable_rgb, |
| 605 | .mode = { |
| 606 | .name = "svga", |
| 607 | .refresh = 60, |
| 608 | .xres = 800, |
| 609 | .yres = 600, |
| 610 | .pixclock = 15385, |
| 611 | .left_margin = 220, |
| 612 | .right_margin = 40, |
| 613 | .upper_margin = 21, |
| 614 | .lower_margin = 7, |
| 615 | .hsync_len = 60, |
| 616 | .vsync_len = 10, |
| 617 | .sync = 0, |
| 618 | .vmode = FB_VMODE_NONINTERLACED |
| 619 | } }, { |
Eric Nelson | 04edda2 | 2014-10-02 12:16:35 -0700 | [diff] [blame] | 620 | .bus = 2, |
Eric Nelson | 865aa30 | 2014-10-02 12:16:37 -0700 | [diff] [blame] | 621 | .addr = 0x41, |
| 622 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 623 | .detect = detect_i2c, |
| 624 | .enable = enable_lvds, |
| 625 | .mode = { |
| 626 | .name = "amp1024x600", |
| 627 | .refresh = 60, |
| 628 | .xres = 1024, |
| 629 | .yres = 600, |
| 630 | .pixclock = 15385, |
| 631 | .left_margin = 220, |
| 632 | .right_margin = 40, |
| 633 | .upper_margin = 21, |
| 634 | .lower_margin = 7, |
| 635 | .hsync_len = 60, |
| 636 | .vsync_len = 10, |
| 637 | .sync = FB_SYNC_EXT, |
| 638 | .vmode = FB_VMODE_NONINTERLACED |
| 639 | } }, { |
Eric Nelson | c745de7 | 2014-10-02 12:16:38 -0700 | [diff] [blame] | 640 | .bus = 0, |
| 641 | .addr = 0, |
| 642 | .pixfmt = IPU_PIX_FMT_LVDS666, |
| 643 | .detect = 0, |
| 644 | .enable = enable_lvds, |
| 645 | .mode = { |
| 646 | .name = "wvga-lvds", |
| 647 | .refresh = 57, |
| 648 | .xres = 800, |
| 649 | .yres = 480, |
| 650 | .pixclock = 15385, |
| 651 | .left_margin = 220, |
| 652 | .right_margin = 40, |
| 653 | .upper_margin = 21, |
| 654 | .lower_margin = 7, |
| 655 | .hsync_len = 60, |
| 656 | .vsync_len = 10, |
| 657 | .sync = FB_SYNC_EXT, |
| 658 | .vmode = FB_VMODE_NONINTERLACED |
| 659 | } }, { |
Eric Nelson | 865aa30 | 2014-10-02 12:16:37 -0700 | [diff] [blame] | 660 | .bus = 2, |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 661 | .addr = 0x48, |
| 662 | .pixfmt = IPU_PIX_FMT_RGB666, |
| 663 | .detect = detect_i2c, |
| 664 | .enable = enable_rgb, |
| 665 | .mode = { |
| 666 | .name = "wvga-rgb", |
| 667 | .refresh = 57, |
| 668 | .xres = 800, |
| 669 | .yres = 480, |
| 670 | .pixclock = 37037, |
| 671 | .left_margin = 40, |
| 672 | .right_margin = 60, |
| 673 | .upper_margin = 10, |
| 674 | .lower_margin = 10, |
| 675 | .hsync_len = 20, |
| 676 | .vsync_len = 10, |
| 677 | .sync = 0, |
| 678 | .vmode = FB_VMODE_NONINTERLACED |
Eric Nelson | 443d4d1 | 2014-10-02 12:16:32 -0700 | [diff] [blame] | 679 | } }, { |
| 680 | .bus = 0, |
| 681 | .addr = 0, |
| 682 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 683 | .detect = NULL, |
| 684 | .enable = enable_rgb, |
| 685 | .mode = { |
| 686 | .name = "qvga", |
| 687 | .refresh = 60, |
| 688 | .xres = 320, |
| 689 | .yres = 240, |
| 690 | .pixclock = 37037, |
| 691 | .left_margin = 38, |
| 692 | .right_margin = 37, |
| 693 | .upper_margin = 16, |
| 694 | .lower_margin = 15, |
| 695 | .hsync_len = 30, |
| 696 | .vsync_len = 3, |
| 697 | .sync = 0, |
| 698 | .vmode = FB_VMODE_NONINTERLACED |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 699 | } } }; |
Eric Benard | a47e449 | 2014-04-04 19:05:53 +0200 | [diff] [blame] | 700 | size_t display_count = ARRAY_SIZE(displays); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 701 | |
Eric Nelson | c9c86bd | 2014-10-02 12:16:22 -0700 | [diff] [blame] | 702 | int board_cfb_skip(void) |
| 703 | { |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 704 | return NULL != env_get("novideo"); |
Eric Nelson | c9c86bd | 2014-10-02 12:16:22 -0700 | [diff] [blame] | 705 | } |
| 706 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 707 | static void setup_display(void) |
| 708 | { |
| 709 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 710 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 711 | int reg; |
| 712 | |
Pardeep Kumar Singla | 5ea7f0e | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 713 | enable_ipu_clock(); |
| 714 | imx_setup_hdmi(); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 715 | /* Turn on LDB0,IPU,IPU DI0 clocks */ |
| 716 | reg = __raw_readl(&mxc_ccm->CCGR3); |
Pardeep Kumar Singla | 5ea7f0e | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 717 | reg |= MXC_CCM_CCGR3_LDB_DI0_MASK; |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 718 | writel(reg, &mxc_ccm->CCGR3); |
| 719 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 720 | /* set LDB0, LDB1 clk select to 011/011 */ |
| 721 | reg = readl(&mxc_ccm->cs2cdr); |
| 722 | reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK |
| 723 | |MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK); |
| 724 | reg |= (3<<MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET) |
| 725 | |(3<<MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET); |
| 726 | writel(reg, &mxc_ccm->cs2cdr); |
| 727 | |
| 728 | reg = readl(&mxc_ccm->cscmr2); |
| 729 | reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV; |
| 730 | writel(reg, &mxc_ccm->cscmr2); |
| 731 | |
| 732 | reg = readl(&mxc_ccm->chsccdr); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 733 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
Pardeep Kumar Singla | 5ea7f0e | 2013-07-25 12:12:13 -0500 | [diff] [blame] | 734 | <<MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 735 | writel(reg, &mxc_ccm->chsccdr); |
| 736 | |
| 737 | reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES |
| 738 | |IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH |
| 739 | |IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW |
| 740 | |IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG |
| 741 | |IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT |
| 742 | |IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
| 743 | |IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT |
| 744 | |IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED |
| 745 | |IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0; |
| 746 | writel(reg, &iomux->gpr[2]); |
| 747 | |
| 748 | reg = readl(&iomux->gpr[3]); |
Eric Nelson | 8907c2c | 2013-08-20 11:44:43 -0700 | [diff] [blame] | 749 | reg = (reg & ~(IOMUXC_GPR3_LVDS0_MUX_CTL_MASK |
| 750 | |IOMUXC_GPR3_HDMI_MUX_CTL_MASK)) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 751 | | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 |
| 752 | <<IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET); |
| 753 | writel(reg, &iomux->gpr[3]); |
| 754 | |
| 755 | /* backlights off until needed */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 756 | SETUP_IOMUX_PADS(backlight_pads); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 757 | gpio_direction_input(LVDS_BACKLIGHT_GP); |
| 758 | gpio_direction_input(RGB_BACKLIGHT_GP); |
| 759 | } |
| 760 | #endif |
| 761 | |
Eric Nelson | a3b527a | 2014-10-02 12:16:25 -0700 | [diff] [blame] | 762 | static iomux_v3_cfg_t const init_pads[] = { |
Troy Kisky | 693cccf | 2014-10-02 12:16:26 -0700 | [diff] [blame] | 763 | /* SGTL5000 sys_mclk */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 764 | IOMUX_PAD_CTRL(GPIO_0__CCM_CLKO1, OUTPUT_40OHM), |
Troy Kisky | 693cccf | 2014-10-02 12:16:26 -0700 | [diff] [blame] | 765 | |
| 766 | /* J5 - Camera MCLK */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 767 | IOMUX_PAD_CTRL(GPIO_3__CCM_CLKO2, OUTPUT_40OHM), |
Troy Kisky | 693cccf | 2014-10-02 12:16:26 -0700 | [diff] [blame] | 768 | |
| 769 | /* wl1271 pads on nitrogen6x */ |
Eric Nelson | a3b527a | 2014-10-02 12:16:25 -0700 | [diff] [blame] | 770 | /* WL12XX_WL_IRQ_GP */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 771 | IOMUX_PAD_CTRL(NANDF_CS1__GPIO6_IO14, WEAK_PULLDOWN), |
Eric Nelson | a3b527a | 2014-10-02 12:16:25 -0700 | [diff] [blame] | 772 | /* WL12XX_WL_ENABLE_GP */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 773 | IOMUX_PAD_CTRL(NANDF_CS2__GPIO6_IO15, OUTPUT_40OHM), |
Eric Nelson | a3b527a | 2014-10-02 12:16:25 -0700 | [diff] [blame] | 774 | /* WL12XX_BT_ENABLE_GP */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 775 | IOMUX_PAD_CTRL(NANDF_CS3__GPIO6_IO16, OUTPUT_40OHM), |
Eric Nelson | a3b527a | 2014-10-02 12:16:25 -0700 | [diff] [blame] | 776 | /* USB otg power */ |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 777 | IOMUX_PAD_CTRL(EIM_D22__GPIO3_IO22, OUTPUT_40OHM), |
| 778 | IOMUX_PAD_CTRL(NANDF_D5__GPIO2_IO05, OUTPUT_40OHM), |
| 779 | IOMUX_PAD_CTRL(NANDF_WP_B__GPIO6_IO09, OUTPUT_40OHM), |
| 780 | IOMUX_PAD_CTRL(GPIO_8__GPIO1_IO08, OUTPUT_40OHM), |
| 781 | IOMUX_PAD_CTRL(GPIO_6__GPIO1_IO06, OUTPUT_40OHM), |
Eric Nelson | a3b527a | 2014-10-02 12:16:25 -0700 | [diff] [blame] | 782 | }; |
| 783 | |
| 784 | #define WL12XX_WL_IRQ_GP IMX_GPIO_NR(6, 14) |
| 785 | |
| 786 | static unsigned gpios_out_low[] = { |
| 787 | /* Disable wl1271 */ |
| 788 | IMX_GPIO_NR(6, 15), /* disable wireless */ |
| 789 | IMX_GPIO_NR(6, 16), /* disable bluetooth */ |
| 790 | IMX_GPIO_NR(3, 22), /* disable USB otg power */ |
| 791 | IMX_GPIO_NR(2, 5), /* ov5640 mipi camera reset */ |
| 792 | IMX_GPIO_NR(1, 8), /* ov5642 reset */ |
| 793 | }; |
| 794 | |
| 795 | static unsigned gpios_out_high[] = { |
| 796 | IMX_GPIO_NR(1, 6), /* ov5642 powerdown */ |
| 797 | IMX_GPIO_NR(6, 9), /* ov5640 mipi camera power down */ |
| 798 | }; |
| 799 | |
| 800 | static void set_gpios(unsigned *p, int cnt, int val) |
| 801 | { |
| 802 | int i; |
| 803 | |
| 804 | for (i = 0; i < cnt; i++) |
| 805 | gpio_direction_output(*p++, val); |
| 806 | } |
| 807 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 808 | int board_early_init_f(void) |
| 809 | { |
| 810 | setup_iomux_uart(); |
| 811 | |
Eric Nelson | a3b527a | 2014-10-02 12:16:25 -0700 | [diff] [blame] | 812 | set_gpios(gpios_out_high, ARRAY_SIZE(gpios_out_high), 1); |
| 813 | set_gpios(gpios_out_low, ARRAY_SIZE(gpios_out_low), 0); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 814 | gpio_direction_input(WL12XX_WL_IRQ_GP); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 815 | |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 816 | SETUP_IOMUX_PADS(wl12xx_pads); |
| 817 | SETUP_IOMUX_PADS(init_pads); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 818 | setup_buttons(); |
| 819 | |
| 820 | #if defined(CONFIG_VIDEO_IPUV3) |
| 821 | setup_display(); |
| 822 | #endif |
| 823 | return 0; |
| 824 | } |
| 825 | |
| 826 | /* |
| 827 | * Do not overwrite the console |
| 828 | * Use always serial for U-Boot console |
| 829 | */ |
| 830 | int overwrite_console(void) |
| 831 | { |
| 832 | return 1; |
| 833 | } |
| 834 | |
| 835 | int board_init(void) |
| 836 | { |
Fabio Estevam | 0a11d6f | 2014-07-09 17:59:54 -0300 | [diff] [blame] | 837 | struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR; |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 838 | struct i2c_pads_info *p = i2c_pads; |
| 839 | int i; |
| 840 | int stride = 1; |
Troy Kisky | 7132869 | 2013-09-25 18:41:16 -0700 | [diff] [blame] | 841 | |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 842 | #if defined(CONFIG_MX6QDL) |
| 843 | stride = 2; |
| 844 | if (!is_mx6dq() && !is_mx6dqp()) |
| 845 | p += 1; |
| 846 | #endif |
Troy Kisky | 7132869 | 2013-09-25 18:41:16 -0700 | [diff] [blame] | 847 | clrsetbits_le32(&iomuxc_regs->gpr[1], |
| 848 | IOMUXC_GPR1_OTG_ID_MASK, |
| 849 | IOMUXC_GPR1_OTG_ID_GPIO1); |
| 850 | |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 851 | SETUP_IOMUX_PADS(misc_pads); |
Troy Kisky | 08ce074 | 2013-09-25 18:41:17 -0700 | [diff] [blame] | 852 | |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 853 | /* address of boot parameters */ |
| 854 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 855 | |
| 856 | #ifdef CONFIG_MXC_SPI |
| 857 | setup_spi(); |
| 858 | #endif |
Troy Kisky | c30c360 | 2019-11-03 18:20:04 -0800 | [diff] [blame] | 859 | SETUP_IOMUX_PADS(usdhc2_pads); |
| 860 | for (i = 0; i < I2C_BUS_CNT; i++) { |
| 861 | setup_i2c(i, CONFIG_SYS_I2C_SPEED, 0x7f, p); |
| 862 | p += stride; |
| 863 | } |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 864 | |
Simon Glass | 10e40d5 | 2017-06-14 21:28:25 -0600 | [diff] [blame] | 865 | #ifdef CONFIG_SATA |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 866 | setup_sata(); |
| 867 | #endif |
| 868 | |
| 869 | return 0; |
| 870 | } |
| 871 | |
| 872 | int checkboard(void) |
| 873 | { |
Troy Kisky | 1b51e5f | 2019-07-29 12:15:56 -0700 | [diff] [blame] | 874 | int ret = gpio_get_value(WL12XX_WL_IRQ_GP); |
| 875 | |
| 876 | if (ret < 0) { |
| 877 | /* The gpios have not been probed yet. Read it myself */ |
| 878 | struct gpio_regs *regs = (struct gpio_regs *)GPIO6_BASE_ADDR; |
| 879 | int gpio = WL12XX_WL_IRQ_GP & 0x1f; |
| 880 | |
| 881 | ret = (readl(®s->gpio_psr) >> gpio) & 0x01; |
| 882 | } |
| 883 | if (ret) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 884 | puts("Board: Nitrogen6X\n"); |
| 885 | else |
| 886 | puts("Board: SABRE Lite\n"); |
| 887 | |
| 888 | return 0; |
| 889 | } |
| 890 | |
| 891 | struct button_key { |
| 892 | char const *name; |
| 893 | unsigned gpnum; |
| 894 | char ident; |
| 895 | }; |
| 896 | |
| 897 | static struct button_key const buttons[] = { |
| 898 | {"back", IMX_GPIO_NR(2, 2), 'B'}, |
| 899 | {"home", IMX_GPIO_NR(2, 4), 'H'}, |
| 900 | {"menu", IMX_GPIO_NR(2, 1), 'M'}, |
| 901 | {"search", IMX_GPIO_NR(2, 3), 'S'}, |
| 902 | {"volup", IMX_GPIO_NR(7, 13), 'V'}, |
| 903 | {"voldown", IMX_GPIO_NR(4, 5), 'v'}, |
| 904 | }; |
| 905 | |
| 906 | /* |
| 907 | * generate a null-terminated string containing the buttons pressed |
| 908 | * returns number of keys pressed |
| 909 | */ |
| 910 | static int read_keys(char *buf) |
| 911 | { |
| 912 | int i, numpressed = 0; |
| 913 | for (i = 0; i < ARRAY_SIZE(buttons); i++) { |
| 914 | if (!gpio_get_value(buttons[i].gpnum)) |
| 915 | buf[numpressed++] = buttons[i].ident; |
| 916 | } |
| 917 | buf[numpressed] = '\0'; |
| 918 | return numpressed; |
| 919 | } |
| 920 | |
Simon Glass | 0914011 | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 921 | static int do_kbd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 922 | { |
| 923 | char envvalue[ARRAY_SIZE(buttons)+1]; |
| 924 | int numpressed = read_keys(envvalue); |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 925 | env_set("keybd", envvalue); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 926 | return numpressed == 0; |
| 927 | } |
| 928 | |
| 929 | U_BOOT_CMD( |
| 930 | kbd, 1, 1, do_kbd, |
| 931 | "Tests for keypresses, sets 'keybd' environment variable", |
| 932 | "Returns 0 (true) to shell if key is pressed." |
| 933 | ); |
| 934 | |
| 935 | #ifdef CONFIG_PREBOOT |
| 936 | static char const kbd_magic_prefix[] = "key_magic"; |
| 937 | static char const kbd_command_prefix[] = "key_cmd"; |
| 938 | |
| 939 | static void preboot_keys(void) |
| 940 | { |
| 941 | int numpressed; |
| 942 | char keypress[ARRAY_SIZE(buttons)+1]; |
| 943 | numpressed = read_keys(keypress); |
| 944 | if (numpressed) { |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 945 | char *kbd_magic_keys = env_get("magic_keys"); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 946 | char *suffix; |
| 947 | /* |
| 948 | * loop over all magic keys |
| 949 | */ |
| 950 | for (suffix = kbd_magic_keys; *suffix; ++suffix) { |
| 951 | char *keys; |
| 952 | char magic[sizeof(kbd_magic_prefix) + 1]; |
| 953 | sprintf(magic, "%s%c", kbd_magic_prefix, *suffix); |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 954 | keys = env_get(magic); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 955 | if (keys) { |
| 956 | if (!strcmp(keys, keypress)) |
| 957 | break; |
| 958 | } |
| 959 | } |
| 960 | if (*suffix) { |
| 961 | char cmd_name[sizeof(kbd_command_prefix) + 1]; |
| 962 | char *cmd; |
| 963 | sprintf(cmd_name, "%s%c", kbd_command_prefix, *suffix); |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 964 | cmd = env_get(cmd_name); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 965 | if (cmd) { |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 966 | env_set("preboot", cmd); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 967 | return; |
| 968 | } |
| 969 | } |
| 970 | } |
| 971 | } |
| 972 | #endif |
| 973 | |
| 974 | #ifdef CONFIG_CMD_BMODE |
| 975 | static const struct boot_mode board_boot_modes[] = { |
| 976 | /* 4 bit bus width */ |
| 977 | {"mmc0", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, |
| 978 | {"mmc1", MAKE_CFGVAL(0x40, 0x38, 0x00, 0x00)}, |
| 979 | {NULL, 0}, |
| 980 | }; |
| 981 | #endif |
| 982 | |
| 983 | int misc_init_r(void) |
| 984 | { |
Troy Kisky | 1b51e5f | 2019-07-29 12:15:56 -0700 | [diff] [blame] | 985 | gpio_request(RGB_BACKLIGHT_GP, "lvds backlight"); |
| 986 | gpio_request(LVDS_BACKLIGHT_GP, "lvds backlight"); |
| 987 | gpio_request(GP_USB_OTG_PWR, "usbotg power"); |
| 988 | gpio_request(IMX_GPIO_NR(7, 12), "usbh1 hub reset"); |
| 989 | gpio_request(IMX_GPIO_NR(2, 2), "back"); |
| 990 | gpio_request(IMX_GPIO_NR(2, 4), "home"); |
| 991 | gpio_request(IMX_GPIO_NR(2, 1), "menu"); |
| 992 | gpio_request(IMX_GPIO_NR(2, 3), "search"); |
| 993 | gpio_request(IMX_GPIO_NR(7, 13), "volup"); |
| 994 | gpio_request(IMX_GPIO_NR(4, 5), "voldown"); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 995 | #ifdef CONFIG_PREBOOT |
| 996 | preboot_keys(); |
| 997 | #endif |
| 998 | |
| 999 | #ifdef CONFIG_CMD_BMODE |
| 1000 | add_board_boot_modes(board_boot_modes); |
| 1001 | #endif |
Simon Glass | 018f530 | 2017-08-03 12:22:10 -0600 | [diff] [blame] | 1002 | env_set_hex("reset_cause", get_imx_reset_cause()); |
Eric Nelson | d67b0d9 | 2013-03-11 08:44:53 +0000 | [diff] [blame] | 1003 | return 0; |
| 1004 | } |