Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2012 Freescale Semiconductor, Inc. |
| 4 | * |
| 5 | * Author: Fabio Estevam <fabio.estevam@freescale.com> |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 8 | #include <asm/arch/clock.h> |
| 9 | #include <asm/arch/imx-regs.h> |
| 10 | #include <asm/arch/iomux.h> |
Pierre Aubert | ec10aed | 2013-06-04 09:00:15 +0200 | [diff] [blame] | 11 | #include <asm/arch/mx6-pins.h> |
Diego Dorta | 5433ebb | 2017-09-27 13:12:38 -0300 | [diff] [blame] | 12 | #include <asm/mach-imx/spi.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 13 | #include <linux/errno.h> |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 14 | #include <asm/gpio.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 15 | #include <asm/mach-imx/mxc_i2c.h> |
| 16 | #include <asm/mach-imx/iomux-v3.h> |
| 17 | #include <asm/mach-imx/boot_mode.h> |
| 18 | #include <asm/mach-imx/video.h> |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 19 | #include <mmc.h> |
| 20 | #include <fsl_esdhc.h> |
| 21 | #include <miiphy.h> |
| 22 | #include <netdev.h> |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 23 | #include <asm/arch/mxc_hdmi.h> |
| 24 | #include <asm/arch/crm_regs.h> |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 25 | #include <asm/io.h> |
| 26 | #include <asm/arch/sys_proto.h> |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 27 | #include <i2c.h> |
Diego Dorta | 2661c9c | 2017-09-22 12:12:18 -0300 | [diff] [blame] | 28 | #include <input.h> |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 29 | #include <power/pmic.h> |
| 30 | #include <power/pfuze100_pmic.h> |
Ye.Li | 75e02f9 | 2014-11-06 16:29:00 +0800 | [diff] [blame] | 31 | #include "../common/pfuze.h" |
Peng Fan | c9498fa | 2014-12-02 09:55:27 +0800 | [diff] [blame] | 32 | #include <usb.h> |
Diego Dorta | de4c661 | 2017-09-27 13:12:40 -0300 | [diff] [blame] | 33 | #include <usb/ehci-ci.h> |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 34 | |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 35 | DECLARE_GLOBAL_DATA_PTR; |
| 36 | |
Benoît Thébaudeau | 2167024 | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 37 | #define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 38 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ |
| 39 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 40 | |
Benoît Thébaudeau | 2167024 | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 41 | #define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP | \ |
| 42 | PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \ |
| 43 | PAD_CTL_SRE_FAST | PAD_CTL_HYS) |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 44 | |
Benoît Thébaudeau | 2167024 | 2013-04-26 01:34:47 +0000 | [diff] [blame] | 45 | #define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 46 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS) |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 47 | |
Fabio Estevam | d82dad4 | 2013-11-08 16:20:54 -0200 | [diff] [blame] | 48 | #define SPI_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_SPEED_MED | \ |
| 49 | PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST) |
| 50 | |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 51 | #define I2C_PAD_CTRL (PAD_CTL_PUS_100K_UP | \ |
| 52 | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \ |
| 53 | PAD_CTL_ODE | PAD_CTL_SRE_FAST) |
| 54 | |
| 55 | #define I2C_PMIC 1 |
| 56 | |
| 57 | #define I2C_PAD MUX_PAD_CTRL(I2C_PAD_CTRL) |
| 58 | |
Fabio Estevam | 0d29cee | 2014-10-21 21:14:53 -0200 | [diff] [blame] | 59 | #define DISP0_PWR_EN IMX_GPIO_NR(1, 21) |
| 60 | |
Diego Dorta | 466016e | 2016-10-11 11:09:27 -0300 | [diff] [blame] | 61 | #define KEY_VOL_UP IMX_GPIO_NR(1, 4) |
| 62 | |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 63 | int dram_init(void) |
| 64 | { |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 65 | gd->ram_size = imx_ddr_size(); |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 66 | return 0; |
| 67 | } |
| 68 | |
Fabio Estevam | f533c2e | 2014-11-06 12:24:25 -0200 | [diff] [blame] | 69 | static iomux_v3_cfg_t const uart1_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 70 | IOMUX_PADS(PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)), |
| 71 | IOMUX_PADS(PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)), |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
Fabio Estevam | f533c2e | 2014-11-06 12:24:25 -0200 | [diff] [blame] | 74 | static iomux_v3_cfg_t const enet_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 75 | IOMUX_PADS(PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 76 | IOMUX_PADS(PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 77 | IOMUX_PADS(PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 78 | IOMUX_PADS(PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 79 | IOMUX_PADS(PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 80 | IOMUX_PADS(PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 81 | IOMUX_PADS(PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 82 | IOMUX_PADS(PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 83 | IOMUX_PADS(PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 84 | IOMUX_PADS(PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 85 | IOMUX_PADS(PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 86 | IOMUX_PADS(PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 87 | IOMUX_PADS(PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 88 | IOMUX_PADS(PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
| 89 | IOMUX_PADS(PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL)), |
Fabio Estevam | 2ebe246 | 2012-09-18 17:24:23 +0000 | [diff] [blame] | 90 | /* AR8031 PHY Reset */ |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 91 | IOMUX_PADS(PAD_ENET_CRS_DV__GPIO1_IO25 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
Fabio Estevam | 2ebe246 | 2012-09-18 17:24:23 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | static void setup_iomux_enet(void) |
| 95 | { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 96 | SETUP_IOMUX_PADS(enet_pads); |
Fabio Estevam | 2ebe246 | 2012-09-18 17:24:23 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Fabio Estevam | f533c2e | 2014-11-06 12:24:25 -0200 | [diff] [blame] | 99 | static iomux_v3_cfg_t const usdhc2_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 100 | IOMUX_PADS(PAD_SD2_CLK__SD2_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 101 | IOMUX_PADS(PAD_SD2_CMD__SD2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 102 | IOMUX_PADS(PAD_SD2_DAT0__SD2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 103 | IOMUX_PADS(PAD_SD2_DAT1__SD2_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 104 | IOMUX_PADS(PAD_SD2_DAT2__SD2_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 105 | IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 106 | IOMUX_PADS(PAD_NANDF_D4__SD2_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 107 | IOMUX_PADS(PAD_NANDF_D5__SD2_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 108 | IOMUX_PADS(PAD_NANDF_D6__SD2_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 109 | IOMUX_PADS(PAD_NANDF_D7__SD2_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 110 | IOMUX_PADS(PAD_NANDF_D2__GPIO2_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL)), /* CD */ |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
Fabio Estevam | f533c2e | 2014-11-06 12:24:25 -0200 | [diff] [blame] | 113 | static iomux_v3_cfg_t const usdhc3_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 114 | IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 115 | IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 116 | IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 117 | IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 118 | IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 119 | IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 120 | IOMUX_PADS(PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 121 | IOMUX_PADS(PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 122 | IOMUX_PADS(PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 123 | IOMUX_PADS(PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 124 | IOMUX_PADS(PAD_NANDF_D0__GPIO2_IO00 | MUX_PAD_CTRL(NO_PAD_CTRL)), /* CD */ |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 125 | }; |
| 126 | |
Fabio Estevam | f533c2e | 2014-11-06 12:24:25 -0200 | [diff] [blame] | 127 | static iomux_v3_cfg_t const usdhc4_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 128 | IOMUX_PADS(PAD_SD4_CLK__SD4_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 129 | IOMUX_PADS(PAD_SD4_CMD__SD4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 130 | IOMUX_PADS(PAD_SD4_DAT0__SD4_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 131 | IOMUX_PADS(PAD_SD4_DAT1__SD4_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 132 | IOMUX_PADS(PAD_SD4_DAT2__SD4_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 133 | IOMUX_PADS(PAD_SD4_DAT3__SD4_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 134 | IOMUX_PADS(PAD_SD4_DAT4__SD4_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 135 | IOMUX_PADS(PAD_SD4_DAT5__SD4_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 136 | IOMUX_PADS(PAD_SD4_DAT6__SD4_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
| 137 | IOMUX_PADS(PAD_SD4_DAT7__SD4_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL)), |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
Fabio Estevam | f533c2e | 2014-11-06 12:24:25 -0200 | [diff] [blame] | 140 | static iomux_v3_cfg_t const ecspi1_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 141 | IOMUX_PADS(PAD_KEY_COL0__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL)), |
| 142 | IOMUX_PADS(PAD_KEY_COL1__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL)), |
| 143 | IOMUX_PADS(PAD_KEY_ROW0__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL)), |
| 144 | IOMUX_PADS(PAD_KEY_ROW1__GPIO4_IO09 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
Fabio Estevam | d82dad4 | 2013-11-08 16:20:54 -0200 | [diff] [blame] | 145 | }; |
| 146 | |
Fabio Estevam | 0d29cee | 2014-10-21 21:14:53 -0200 | [diff] [blame] | 147 | static iomux_v3_cfg_t const rgb_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 148 | IOMUX_PADS(PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 149 | IOMUX_PADS(PAD_DI0_PIN15__IPU1_DI0_PIN15 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 150 | IOMUX_PADS(PAD_DI0_PIN2__IPU1_DI0_PIN02 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 151 | IOMUX_PADS(PAD_DI0_PIN3__IPU1_DI0_PIN03 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 152 | IOMUX_PADS(PAD_DI0_PIN4__IPU1_DI0_PIN04 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 153 | IOMUX_PADS(PAD_DISP0_DAT0__IPU1_DISP0_DATA00 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 154 | IOMUX_PADS(PAD_DISP0_DAT1__IPU1_DISP0_DATA01 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 155 | IOMUX_PADS(PAD_DISP0_DAT2__IPU1_DISP0_DATA02 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 156 | IOMUX_PADS(PAD_DISP0_DAT3__IPU1_DISP0_DATA03 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 157 | IOMUX_PADS(PAD_DISP0_DAT4__IPU1_DISP0_DATA04 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 158 | IOMUX_PADS(PAD_DISP0_DAT5__IPU1_DISP0_DATA05 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 159 | IOMUX_PADS(PAD_DISP0_DAT6__IPU1_DISP0_DATA06 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 160 | IOMUX_PADS(PAD_DISP0_DAT7__IPU1_DISP0_DATA07 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 161 | IOMUX_PADS(PAD_DISP0_DAT8__IPU1_DISP0_DATA08 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 162 | IOMUX_PADS(PAD_DISP0_DAT9__IPU1_DISP0_DATA09 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 163 | IOMUX_PADS(PAD_DISP0_DAT10__IPU1_DISP0_DATA10 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 164 | IOMUX_PADS(PAD_DISP0_DAT11__IPU1_DISP0_DATA11 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 165 | IOMUX_PADS(PAD_DISP0_DAT12__IPU1_DISP0_DATA12 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 166 | IOMUX_PADS(PAD_DISP0_DAT13__IPU1_DISP0_DATA13 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 167 | IOMUX_PADS(PAD_DISP0_DAT14__IPU1_DISP0_DATA14 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 168 | IOMUX_PADS(PAD_DISP0_DAT15__IPU1_DISP0_DATA15 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 169 | IOMUX_PADS(PAD_DISP0_DAT16__IPU1_DISP0_DATA16 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 170 | IOMUX_PADS(PAD_DISP0_DAT17__IPU1_DISP0_DATA17 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 171 | IOMUX_PADS(PAD_DISP0_DAT18__IPU1_DISP0_DATA18 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 172 | IOMUX_PADS(PAD_DISP0_DAT19__IPU1_DISP0_DATA19 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 173 | IOMUX_PADS(PAD_DISP0_DAT20__IPU1_DISP0_DATA20 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 174 | IOMUX_PADS(PAD_DISP0_DAT21__IPU1_DISP0_DATA21 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 175 | IOMUX_PADS(PAD_DISP0_DAT22__IPU1_DISP0_DATA22 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
| 176 | IOMUX_PADS(PAD_DISP0_DAT23__IPU1_DISP0_DATA23 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
Marco Franchi | 029d07f | 2016-06-08 15:05:31 -0300 | [diff] [blame] | 177 | }; |
| 178 | |
| 179 | static iomux_v3_cfg_t const bl_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 180 | IOMUX_PADS(PAD_SD1_DAT3__GPIO1_IO21 | MUX_PAD_CTRL(NO_PAD_CTRL)), |
Fabio Estevam | 0d29cee | 2014-10-21 21:14:53 -0200 | [diff] [blame] | 181 | }; |
| 182 | |
Marco Franchi | 029d07f | 2016-06-08 15:05:31 -0300 | [diff] [blame] | 183 | static void enable_backlight(void) |
| 184 | { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 185 | SETUP_IOMUX_PADS(bl_pads); |
Abel Vesa | 78d974e | 2019-02-01 16:40:19 +0000 | [diff] [blame] | 186 | gpio_request(DISP0_PWR_EN, "Display Power Enable"); |
Marco Franchi | 029d07f | 2016-06-08 15:05:31 -0300 | [diff] [blame] | 187 | gpio_direction_output(DISP0_PWR_EN, 1); |
| 188 | } |
| 189 | |
Fabio Estevam | 0d29cee | 2014-10-21 21:14:53 -0200 | [diff] [blame] | 190 | static void enable_rgb(struct display_info_t const *dev) |
| 191 | { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 192 | SETUP_IOMUX_PADS(rgb_pads); |
Marco Franchi | 029d07f | 2016-06-08 15:05:31 -0300 | [diff] [blame] | 193 | enable_backlight(); |
| 194 | } |
| 195 | |
| 196 | static void enable_lvds(struct display_info_t const *dev) |
| 197 | { |
| 198 | enable_backlight(); |
Fabio Estevam | 0d29cee | 2014-10-21 21:14:53 -0200 | [diff] [blame] | 199 | } |
| 200 | |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 201 | static struct i2c_pads_info mx6q_i2c_pad_info1 = { |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 202 | .scl = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 203 | .i2c_mode = MX6Q_PAD_KEY_COL3__I2C2_SCL | I2C_PAD, |
| 204 | .gpio_mode = MX6Q_PAD_KEY_COL3__GPIO4_IO12 | I2C_PAD, |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 205 | .gp = IMX_GPIO_NR(4, 12) |
| 206 | }, |
| 207 | .sda = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 208 | .i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA | I2C_PAD, |
| 209 | .gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO4_IO13 | I2C_PAD, |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 210 | .gp = IMX_GPIO_NR(4, 13) |
| 211 | } |
| 212 | }; |
| 213 | |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 214 | static struct i2c_pads_info mx6dl_i2c_pad_info1 = { |
| 215 | .scl = { |
| 216 | .i2c_mode = MX6DL_PAD_KEY_COL3__I2C2_SCL | I2C_PAD, |
| 217 | .gpio_mode = MX6DL_PAD_KEY_COL3__GPIO4_IO12 | I2C_PAD, |
| 218 | .gp = IMX_GPIO_NR(4, 12) |
| 219 | }, |
| 220 | .sda = { |
| 221 | .i2c_mode = MX6DL_PAD_KEY_ROW3__I2C2_SDA | I2C_PAD, |
| 222 | .gpio_mode = MX6DL_PAD_KEY_ROW3__GPIO4_IO13 | I2C_PAD, |
| 223 | .gp = IMX_GPIO_NR(4, 13) |
| 224 | } |
| 225 | }; |
| 226 | |
Fabio Estevam | d82dad4 | 2013-11-08 16:20:54 -0200 | [diff] [blame] | 227 | static void setup_spi(void) |
| 228 | { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 229 | SETUP_IOMUX_PADS(ecspi1_pads); |
Fabio Estevam | d82dad4 | 2013-11-08 16:20:54 -0200 | [diff] [blame] | 230 | } |
| 231 | |
Marek Vasut | 0e99f01 | 2014-03-23 22:45:41 +0100 | [diff] [blame] | 232 | iomux_v3_cfg_t const pcie_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 233 | IOMUX_PADS(PAD_EIM_D19__GPIO3_IO19 | MUX_PAD_CTRL(NO_PAD_CTRL)), /* POWER */ |
| 234 | IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | MUX_PAD_CTRL(NO_PAD_CTRL)), /* RESET */ |
Marek Vasut | 0e99f01 | 2014-03-23 22:45:41 +0100 | [diff] [blame] | 235 | }; |
| 236 | |
| 237 | static void setup_pcie(void) |
| 238 | { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 239 | SETUP_IOMUX_PADS(pcie_pads); |
Marek Vasut | 0e99f01 | 2014-03-23 22:45:41 +0100 | [diff] [blame] | 240 | } |
| 241 | |
Fabio Estevam | dee3c84 | 2013-12-04 01:08:16 -0200 | [diff] [blame] | 242 | iomux_v3_cfg_t const di0_pads[] = { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 243 | IOMUX_PADS(PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK), /* DISP0_CLK */ |
| 244 | IOMUX_PADS(PAD_DI0_PIN2__IPU1_DI0_PIN02), /* DISP0_HSYNC */ |
| 245 | IOMUX_PADS(PAD_DI0_PIN3__IPU1_DI0_PIN03), /* DISP0_VSYNC */ |
Fabio Estevam | dee3c84 | 2013-12-04 01:08:16 -0200 | [diff] [blame] | 246 | }; |
| 247 | |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 248 | static void setup_iomux_uart(void) |
| 249 | { |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 250 | SETUP_IOMUX_PADS(uart1_pads); |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | #ifdef CONFIG_FSL_ESDHC |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 254 | struct fsl_esdhc_cfg usdhc_cfg[3] = { |
| 255 | {USDHC2_BASE_ADDR}, |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 256 | {USDHC3_BASE_ADDR}, |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 257 | {USDHC4_BASE_ADDR}, |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 258 | }; |
| 259 | |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 260 | #define USDHC2_CD_GPIO IMX_GPIO_NR(2, 2) |
| 261 | #define USDHC3_CD_GPIO IMX_GPIO_NR(2, 0) |
| 262 | |
Peng Fan | 03a43df | 2016-01-28 16:51:27 +0800 | [diff] [blame] | 263 | int board_mmc_get_env_dev(int devno) |
| 264 | { |
| 265 | return devno - 1; |
| 266 | } |
| 267 | |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 268 | int board_mmc_getcd(struct mmc *mmc) |
| 269 | { |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 270 | struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; |
Otavio Salvador | c2bed64 | 2013-03-16 08:05:06 +0000 | [diff] [blame] | 271 | int ret = 0; |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 272 | |
| 273 | switch (cfg->esdhc_base) { |
| 274 | case USDHC2_BASE_ADDR: |
Otavio Salvador | c2bed64 | 2013-03-16 08:05:06 +0000 | [diff] [blame] | 275 | ret = !gpio_get_value(USDHC2_CD_GPIO); |
| 276 | break; |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 277 | case USDHC3_BASE_ADDR: |
Otavio Salvador | c2bed64 | 2013-03-16 08:05:06 +0000 | [diff] [blame] | 278 | ret = !gpio_get_value(USDHC3_CD_GPIO); |
| 279 | break; |
| 280 | case USDHC4_BASE_ADDR: |
| 281 | ret = 1; /* eMMC/uSDHC4 is always present */ |
| 282 | break; |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 283 | } |
Otavio Salvador | c2bed64 | 2013-03-16 08:05:06 +0000 | [diff] [blame] | 284 | |
| 285 | return ret; |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | int board_mmc_init(bd_t *bis) |
| 289 | { |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 290 | #ifndef CONFIG_SPL_BUILD |
Fabio Estevam | 593d0c8 | 2014-11-06 12:24:24 -0200 | [diff] [blame] | 291 | int ret; |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 292 | int i; |
| 293 | |
Otavio Salvador | a272dbf | 2013-03-16 08:05:05 +0000 | [diff] [blame] | 294 | /* |
| 295 | * According to the board_mmc_init() the following map is done: |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 296 | * (U-Boot device node) (Physical Port) |
Otavio Salvador | a272dbf | 2013-03-16 08:05:05 +0000 | [diff] [blame] | 297 | * mmc0 SD2 |
| 298 | * mmc1 SD3 |
| 299 | * mmc2 eMMC |
| 300 | */ |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 301 | for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) { |
| 302 | switch (i) { |
| 303 | case 0: |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 304 | SETUP_IOMUX_PADS(usdhc2_pads); |
Abel Vesa | 78d974e | 2019-02-01 16:40:19 +0000 | [diff] [blame] | 305 | gpio_request(USDHC2_CD_GPIO, "USDHC2 CD"); |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 306 | gpio_direction_input(USDHC2_CD_GPIO); |
| 307 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK); |
| 308 | break; |
| 309 | case 1: |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 310 | SETUP_IOMUX_PADS(usdhc3_pads); |
Abel Vesa | 78d974e | 2019-02-01 16:40:19 +0000 | [diff] [blame] | 311 | gpio_request(USDHC3_CD_GPIO, "USDHC3 CD"); |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 312 | gpio_direction_input(USDHC3_CD_GPIO); |
| 313 | usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); |
| 314 | break; |
| 315 | case 2: |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 316 | SETUP_IOMUX_PADS(usdhc4_pads); |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 317 | usdhc_cfg[2].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK); |
| 318 | break; |
| 319 | default: |
| 320 | printf("Warning: you configured more USDHC controllers" |
Otavio Salvador | a937e22 | 2013-04-19 03:41:58 +0000 | [diff] [blame] | 321 | "(%d) then supported by the board (%d)\n", |
| 322 | i + 1, CONFIG_SYS_FSL_USDHC_NUM); |
Fabio Estevam | 593d0c8 | 2014-11-06 12:24:24 -0200 | [diff] [blame] | 323 | return -EINVAL; |
Otavio Salvador | a937e22 | 2013-04-19 03:41:58 +0000 | [diff] [blame] | 324 | } |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 325 | |
Fabio Estevam | 593d0c8 | 2014-11-06 12:24:24 -0200 | [diff] [blame] | 326 | ret = fsl_esdhc_initialize(bis, &usdhc_cfg[i]); |
| 327 | if (ret) |
| 328 | return ret; |
Shawn Guo | 7e5e833 | 2012-12-30 14:14:59 +0000 | [diff] [blame] | 329 | } |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 330 | |
Fabio Estevam | 593d0c8 | 2014-11-06 12:24:24 -0200 | [diff] [blame] | 331 | return 0; |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 332 | #else |
Fabio Estevam | 56cf36a | 2014-11-18 11:26:06 -0200 | [diff] [blame] | 333 | struct src *psrc = (struct src *)SRC_BASE_ADDR; |
| 334 | unsigned reg = readl(&psrc->sbmr1) >> 11; |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 335 | /* |
| 336 | * Upon reading BOOT_CFG register the following map is done: |
| 337 | * Bit 11 and 12 of BOOT_CFG register can determine the current |
| 338 | * mmc port |
| 339 | * 0x1 SD1 |
| 340 | * 0x2 SD2 |
| 341 | * 0x3 SD4 |
| 342 | */ |
| 343 | |
| 344 | switch (reg & 0x3) { |
| 345 | case 0x1: |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 346 | SETUP_IOMUX_PADS(usdhc2_pads); |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 347 | usdhc_cfg[0].esdhc_base = USDHC2_BASE_ADDR; |
| 348 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK); |
| 349 | gd->arch.sdhc_clk = usdhc_cfg[0].sdhc_clk; |
| 350 | break; |
| 351 | case 0x2: |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 352 | SETUP_IOMUX_PADS(usdhc3_pads); |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 353 | usdhc_cfg[0].esdhc_base = USDHC3_BASE_ADDR; |
| 354 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); |
| 355 | gd->arch.sdhc_clk = usdhc_cfg[0].sdhc_clk; |
| 356 | break; |
| 357 | case 0x3: |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 358 | SETUP_IOMUX_PADS(usdhc4_pads); |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 359 | usdhc_cfg[0].esdhc_base = USDHC4_BASE_ADDR; |
| 360 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK); |
| 361 | gd->arch.sdhc_clk = usdhc_cfg[0].sdhc_clk; |
| 362 | break; |
| 363 | } |
| 364 | |
| 365 | return fsl_esdhc_initialize(bis, &usdhc_cfg[0]); |
| 366 | #endif |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 367 | } |
| 368 | #endif |
| 369 | |
Fabio Estevam | 509c06f | 2016-10-24 10:22:06 -0200 | [diff] [blame] | 370 | static int ar8031_phy_fixup(struct phy_device *phydev) |
| 371 | { |
| 372 | unsigned short val; |
| 373 | |
| 374 | /* To enable AR8031 ouput a 125MHz clk from CLK_25M */ |
| 375 | phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x7); |
| 376 | phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016); |
| 377 | phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007); |
| 378 | |
| 379 | val = phy_read(phydev, MDIO_DEVAD_NONE, 0xe); |
| 380 | val &= 0xffe3; |
| 381 | val |= 0x18; |
| 382 | phy_write(phydev, MDIO_DEVAD_NONE, 0xe, val); |
| 383 | |
| 384 | /* introduce tx clock delay */ |
| 385 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5); |
| 386 | val = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e); |
| 387 | val |= 0x0100; |
| 388 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, val); |
| 389 | |
| 390 | return 0; |
| 391 | } |
| 392 | |
| 393 | int board_phy_config(struct phy_device *phydev) |
| 394 | { |
| 395 | ar8031_phy_fixup(phydev); |
| 396 | |
| 397 | if (phydev->drv->config) |
| 398 | phydev->drv->config(phydev); |
| 399 | |
| 400 | return 0; |
| 401 | } |
| 402 | |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 403 | #if defined(CONFIG_VIDEO_IPUV3) |
Fabio Estevam | 70f84b5 | 2013-11-25 10:34:26 -0200 | [diff] [blame] | 404 | static void disable_lvds(struct display_info_t const *dev) |
| 405 | { |
| 406 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
| 407 | |
| 408 | int reg = readl(&iomux->gpr[2]); |
| 409 | |
| 410 | reg &= ~(IOMUXC_GPR2_LVDS_CH0_MODE_MASK | |
| 411 | IOMUXC_GPR2_LVDS_CH1_MODE_MASK); |
| 412 | |
| 413 | writel(reg, &iomux->gpr[2]); |
| 414 | } |
| 415 | |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 416 | static void do_enable_hdmi(struct display_info_t const *dev) |
| 417 | { |
Fabio Estevam | 70f84b5 | 2013-11-25 10:34:26 -0200 | [diff] [blame] | 418 | disable_lvds(dev); |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 419 | imx_enable_hdmi_phy(); |
| 420 | } |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 421 | |
Eric Benard | d6cabb2 | 2014-04-04 19:05:54 +0200 | [diff] [blame] | 422 | struct display_info_t const displays[] = {{ |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 423 | .bus = -1, |
| 424 | .addr = 0, |
Fabio Estevam | 7d66d56 | 2013-12-04 01:08:17 -0200 | [diff] [blame] | 425 | .pixfmt = IPU_PIX_FMT_RGB666, |
Fabio Estevam | 70f84b5 | 2013-11-25 10:34:26 -0200 | [diff] [blame] | 426 | .detect = NULL, |
Marco Franchi | 029d07f | 2016-06-08 15:05:31 -0300 | [diff] [blame] | 427 | .enable = enable_lvds, |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 428 | .mode = { |
Fabio Estevam | 70f84b5 | 2013-11-25 10:34:26 -0200 | [diff] [blame] | 429 | .name = "Hannstar-XGA", |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 430 | .refresh = 60, |
| 431 | .xres = 1024, |
| 432 | .yres = 768, |
Fabio Estevam | e2b2003 | 2016-03-16 12:55:03 -0300 | [diff] [blame] | 433 | .pixclock = 15384, |
| 434 | .left_margin = 160, |
| 435 | .right_margin = 24, |
| 436 | .upper_margin = 29, |
| 437 | .lower_margin = 3, |
| 438 | .hsync_len = 136, |
| 439 | .vsync_len = 6, |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 440 | .sync = FB_SYNC_EXT, |
| 441 | .vmode = FB_VMODE_NONINTERLACED |
| 442 | } }, { |
| 443 | .bus = -1, |
| 444 | .addr = 0, |
Fabio Estevam | 70f84b5 | 2013-11-25 10:34:26 -0200 | [diff] [blame] | 445 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 446 | .detect = detect_hdmi, |
| 447 | .enable = do_enable_hdmi, |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 448 | .mode = { |
Fabio Estevam | 70f84b5 | 2013-11-25 10:34:26 -0200 | [diff] [blame] | 449 | .name = "HDMI", |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 450 | .refresh = 60, |
| 451 | .xres = 1024, |
| 452 | .yres = 768, |
Fabio Estevam | e2b2003 | 2016-03-16 12:55:03 -0300 | [diff] [blame] | 453 | .pixclock = 15384, |
| 454 | .left_margin = 160, |
| 455 | .right_margin = 24, |
| 456 | .upper_margin = 29, |
| 457 | .lower_margin = 3, |
| 458 | .hsync_len = 136, |
| 459 | .vsync_len = 6, |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 460 | .sync = FB_SYNC_EXT, |
| 461 | .vmode = FB_VMODE_NONINTERLACED |
Fabio Estevam | 0d29cee | 2014-10-21 21:14:53 -0200 | [diff] [blame] | 462 | } }, { |
| 463 | .bus = 0, |
| 464 | .addr = 0, |
| 465 | .pixfmt = IPU_PIX_FMT_RGB24, |
| 466 | .detect = NULL, |
| 467 | .enable = enable_rgb, |
| 468 | .mode = { |
| 469 | .name = "SEIKO-WVGA", |
| 470 | .refresh = 60, |
| 471 | .xres = 800, |
| 472 | .yres = 480, |
| 473 | .pixclock = 29850, |
| 474 | .left_margin = 89, |
| 475 | .right_margin = 164, |
| 476 | .upper_margin = 23, |
| 477 | .lower_margin = 10, |
| 478 | .hsync_len = 10, |
| 479 | .vsync_len = 10, |
| 480 | .sync = 0, |
| 481 | .vmode = FB_VMODE_NONINTERLACED |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 482 | } } }; |
Eric Benard | d6cabb2 | 2014-04-04 19:05:54 +0200 | [diff] [blame] | 483 | size_t display_count = ARRAY_SIZE(displays); |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 484 | |
| 485 | static void setup_display(void) |
| 486 | { |
| 487 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 488 | struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR; |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 489 | int reg; |
| 490 | |
Fabio Estevam | dee3c84 | 2013-12-04 01:08:16 -0200 | [diff] [blame] | 491 | /* Setup HSYNC, VSYNC, DISP_CLK for debugging purposes */ |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 492 | SETUP_IOMUX_PADS(di0_pads); |
Fabio Estevam | dee3c84 | 2013-12-04 01:08:16 -0200 | [diff] [blame] | 493 | |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 494 | enable_ipu_clock(); |
| 495 | imx_setup_hdmi(); |
| 496 | |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 497 | /* Turn on LDB0, LDB1, IPU,IPU DI0 clocks */ |
Liu Ying | 6f45063 | 2013-11-29 22:38:39 +0800 | [diff] [blame] | 498 | reg = readl(&mxc_ccm->CCGR3); |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 499 | reg |= MXC_CCM_CCGR3_LDB_DI0_MASK | MXC_CCM_CCGR3_LDB_DI1_MASK; |
| 500 | writel(reg, &mxc_ccm->CCGR3); |
| 501 | |
| 502 | /* set LDB0, LDB1 clk select to 011/011 */ |
| 503 | reg = readl(&mxc_ccm->cs2cdr); |
| 504 | reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK |
| 505 | | MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK); |
| 506 | reg |= (3 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET) |
| 507 | | (3 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET); |
| 508 | writel(reg, &mxc_ccm->cs2cdr); |
| 509 | |
| 510 | reg = readl(&mxc_ccm->cscmr2); |
| 511 | reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV | MXC_CCM_CSCMR2_LDB_DI1_IPU_DIV; |
| 512 | writel(reg, &mxc_ccm->cscmr2); |
| 513 | |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 514 | reg = readl(&mxc_ccm->chsccdr); |
| 515 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
| 516 | << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET); |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 517 | reg |= (CHSCCDR_CLK_SEL_LDB_DI0 |
| 518 | << MXC_CCM_CHSCCDR_IPU1_DI1_CLK_SEL_OFFSET); |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 519 | writel(reg, &mxc_ccm->chsccdr); |
Fabio Estevam | 9e642cd | 2013-09-04 15:12:38 -0300 | [diff] [blame] | 520 | |
| 521 | reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES |
| 522 | | IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_LOW |
| 523 | | IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_LOW |
| 524 | | IOMUXC_GPR2_BIT_MAPPING_CH1_SPWG |
| 525 | | IOMUXC_GPR2_DATA_WIDTH_CH1_18BIT |
| 526 | | IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG |
| 527 | | IOMUXC_GPR2_DATA_WIDTH_CH0_18BIT |
| 528 | | IOMUXC_GPR2_LVDS_CH0_MODE_DISABLED |
| 529 | | IOMUXC_GPR2_LVDS_CH1_MODE_ENABLED_DI0; |
| 530 | writel(reg, &iomux->gpr[2]); |
| 531 | |
| 532 | reg = readl(&iomux->gpr[3]); |
| 533 | reg = (reg & ~(IOMUXC_GPR3_LVDS1_MUX_CTL_MASK |
| 534 | | IOMUXC_GPR3_HDMI_MUX_CTL_MASK)) |
| 535 | | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0 |
| 536 | << IOMUXC_GPR3_LVDS1_MUX_CTL_OFFSET); |
| 537 | writel(reg, &iomux->gpr[3]); |
Pardeep Kumar Singla | 0b87ba0 | 2013-07-25 12:12:14 -0500 | [diff] [blame] | 538 | } |
| 539 | #endif /* CONFIG_VIDEO_IPUV3 */ |
| 540 | |
| 541 | /* |
| 542 | * Do not overwrite the console |
| 543 | * Use always serial for U-Boot console |
| 544 | */ |
| 545 | int overwrite_console(void) |
| 546 | { |
| 547 | return 1; |
| 548 | } |
| 549 | |
Fabio Estevam | 2ebe246 | 2012-09-18 17:24:23 +0000 | [diff] [blame] | 550 | int board_eth_init(bd_t *bis) |
| 551 | { |
Fabio Estevam | 2ebe246 | 2012-09-18 17:24:23 +0000 | [diff] [blame] | 552 | setup_iomux_enet(); |
Marek Vasut | 0e99f01 | 2014-03-23 22:45:41 +0100 | [diff] [blame] | 553 | setup_pcie(); |
Fabio Estevam | 2ebe246 | 2012-09-18 17:24:23 +0000 | [diff] [blame] | 554 | |
Fabio Estevam | fa3ae40 | 2014-01-04 17:36:32 -0200 | [diff] [blame] | 555 | return cpu_eth_init(bis); |
Fabio Estevam | 2ebe246 | 2012-09-18 17:24:23 +0000 | [diff] [blame] | 556 | } |
| 557 | |
Peng Fan | c9498fa | 2014-12-02 09:55:27 +0800 | [diff] [blame] | 558 | #ifdef CONFIG_USB_EHCI_MX6 |
Peng Fan | c9498fa | 2014-12-02 09:55:27 +0800 | [diff] [blame] | 559 | static void setup_usb(void) |
| 560 | { |
Peng Fan | c9498fa | 2014-12-02 09:55:27 +0800 | [diff] [blame] | 561 | /* |
| 562 | * set daisy chain for otg_pin_id on 6q. |
| 563 | * for 6dl, this bit is reserved |
| 564 | */ |
| 565 | imx_iomux_set_gpr_register(1, 13, 1, 0); |
Peng Fan | c9498fa | 2014-12-02 09:55:27 +0800 | [diff] [blame] | 566 | } |
| 567 | #endif |
| 568 | |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 569 | int board_early_init_f(void) |
| 570 | { |
| 571 | setup_iomux_uart(); |
| 572 | |
| 573 | return 0; |
| 574 | } |
| 575 | |
| 576 | int board_init(void) |
| 577 | { |
| 578 | /* address of boot parameters */ |
| 579 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 580 | |
Fabio Estevam | d82dad4 | 2013-11-08 16:20:54 -0200 | [diff] [blame] | 581 | #ifdef CONFIG_MXC_SPI |
| 582 | setup_spi(); |
| 583 | #endif |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 584 | if (is_mx6dq() || is_mx6dqp()) |
| 585 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6q_i2c_pad_info1); |
| 586 | else |
| 587 | setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &mx6dl_i2c_pad_info1); |
Fabio Estevam | 6f73a29 | 2017-09-22 23:45:28 -0300 | [diff] [blame] | 588 | #if defined(CONFIG_VIDEO_IPUV3) |
| 589 | setup_display(); |
| 590 | #endif |
Peng Fan | c9498fa | 2014-12-02 09:55:27 +0800 | [diff] [blame] | 591 | #ifdef CONFIG_USB_EHCI_MX6 |
| 592 | setup_usb(); |
| 593 | #endif |
| 594 | |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 595 | return 0; |
| 596 | } |
| 597 | |
Ye.Li | 75e02f9 | 2014-11-06 16:29:00 +0800 | [diff] [blame] | 598 | int power_init_board(void) |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 599 | { |
| 600 | struct pmic *p; |
Fabio Estevam | effbec1 | 2015-07-21 20:02:49 -0300 | [diff] [blame] | 601 | unsigned int reg; |
| 602 | int ret; |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 603 | |
Ye.Li | 75e02f9 | 2014-11-06 16:29:00 +0800 | [diff] [blame] | 604 | p = pfuze_common_init(I2C_PMIC); |
| 605 | if (!p) |
| 606 | return -ENODEV; |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 607 | |
Peng Fan | e5bcd4d | 2015-01-27 10:14:04 +0800 | [diff] [blame] | 608 | ret = pfuze_mode_init(p, APS_PFM); |
| 609 | if (ret < 0) |
| 610 | return ret; |
| 611 | |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 612 | /* Increase VGEN3 from 2.5 to 2.8V */ |
| 613 | pmic_reg_read(p, PFUZE100_VGEN3VOL, ®); |
Ye.Li | 75e02f9 | 2014-11-06 16:29:00 +0800 | [diff] [blame] | 614 | reg &= ~LDO_VOL_MASK; |
| 615 | reg |= LDOB_2_80V; |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 616 | pmic_reg_write(p, PFUZE100_VGEN3VOL, reg); |
| 617 | |
| 618 | /* Increase VGEN5 from 2.8 to 3V */ |
| 619 | pmic_reg_read(p, PFUZE100_VGEN5VOL, ®); |
Ye.Li | 75e02f9 | 2014-11-06 16:29:00 +0800 | [diff] [blame] | 620 | reg &= ~LDO_VOL_MASK; |
| 621 | reg |= LDOB_3_00V; |
Fabio Estevam | ba92ad6 | 2014-05-09 13:15:42 -0300 | [diff] [blame] | 622 | pmic_reg_write(p, PFUZE100_VGEN5VOL, reg); |
| 623 | |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 624 | return 0; |
| 625 | } |
| 626 | |
Nikita Kiryanov | 00cd738 | 2014-08-20 15:08:50 +0300 | [diff] [blame] | 627 | #ifdef CONFIG_MXC_SPI |
| 628 | int board_spi_cs_gpio(unsigned bus, unsigned cs) |
| 629 | { |
| 630 | return (bus == 0 && cs == 0) ? (IMX_GPIO_NR(4, 9)) : -1; |
| 631 | } |
| 632 | #endif |
| 633 | |
Otavio Salvador | 5286337 | 2013-03-16 08:05:07 +0000 | [diff] [blame] | 634 | #ifdef CONFIG_CMD_BMODE |
| 635 | static const struct boot_mode board_boot_modes[] = { |
| 636 | /* 4 bit bus width */ |
| 637 | {"sd2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)}, |
| 638 | {"sd3", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, |
| 639 | /* 8 bit bus width */ |
Ye Li | 4ea4a9b | 2016-01-30 11:53:42 +0800 | [diff] [blame] | 640 | {"emmc", MAKE_CFGVAL(0x60, 0x58, 0x00, 0x00)}, |
Otavio Salvador | 5286337 | 2013-03-16 08:05:07 +0000 | [diff] [blame] | 641 | {NULL, 0}, |
| 642 | }; |
| 643 | #endif |
| 644 | |
| 645 | int board_late_init(void) |
| 646 | { |
| 647 | #ifdef CONFIG_CMD_BMODE |
| 648 | add_board_boot_modes(board_boot_modes); |
| 649 | #endif |
Peng Fan | 04321fc | 2015-07-11 11:38:46 +0800 | [diff] [blame] | 650 | |
| 651 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 652 | env_set("board_name", "SABRESD"); |
Peng Fan | 04321fc | 2015-07-11 11:38:46 +0800 | [diff] [blame] | 653 | |
Peng Fan | e27c4db | 2015-10-15 18:05:59 +0800 | [diff] [blame] | 654 | if (is_mx6dqp()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 655 | env_set("board_rev", "MX6QP"); |
Peng Fan | 4a597d0 | 2016-05-23 18:36:06 +0800 | [diff] [blame] | 656 | else if (is_mx6dq()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 657 | env_set("board_rev", "MX6Q"); |
Peng Fan | 4a597d0 | 2016-05-23 18:36:06 +0800 | [diff] [blame] | 658 | else if (is_mx6sdl()) |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 659 | env_set("board_rev", "MX6DL"); |
Peng Fan | 04321fc | 2015-07-11 11:38:46 +0800 | [diff] [blame] | 660 | #endif |
| 661 | |
Otavio Salvador | 5286337 | 2013-03-16 08:05:07 +0000 | [diff] [blame] | 662 | return 0; |
| 663 | } |
| 664 | |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 665 | int checkboard(void) |
| 666 | { |
Pierre Aubert | ec10aed | 2013-06-04 09:00:15 +0200 | [diff] [blame] | 667 | puts("Board: MX6-SabreSD\n"); |
Fabio Estevam | 77e6289 | 2012-09-13 03:18:20 +0000 | [diff] [blame] | 668 | return 0; |
| 669 | } |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 670 | |
| 671 | #ifdef CONFIG_SPL_BUILD |
Fabio Estevam | c88f167 | 2017-05-12 12:45:23 -0300 | [diff] [blame] | 672 | #include <asm/arch/mx6-ddr.h> |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 673 | #include <spl.h> |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 674 | #include <linux/libfdt.h> |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 675 | |
Diego Dorta | 466016e | 2016-10-11 11:09:27 -0300 | [diff] [blame] | 676 | #ifdef CONFIG_SPL_OS_BOOT |
| 677 | int spl_start_uboot(void) |
| 678 | { |
Abel Vesa | 78d974e | 2019-02-01 16:40:19 +0000 | [diff] [blame] | 679 | gpio_request(KEY_VOL_UP, "KEY Volume UP"); |
Diego Dorta | 466016e | 2016-10-11 11:09:27 -0300 | [diff] [blame] | 680 | gpio_direction_input(KEY_VOL_UP); |
| 681 | |
| 682 | /* Only enter in Falcon mode if KEY_VOL_UP is pressed */ |
| 683 | return gpio_get_value(KEY_VOL_UP); |
| 684 | } |
| 685 | #endif |
| 686 | |
Fabio Estevam | c6ecd0b | 2014-11-14 09:36:59 -0200 | [diff] [blame] | 687 | static void ccgr_init(void) |
| 688 | { |
| 689 | struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; |
| 690 | |
| 691 | writel(0x00C03F3F, &ccm->CCGR0); |
| 692 | writel(0x0030FC03, &ccm->CCGR1); |
| 693 | writel(0x0FFFC000, &ccm->CCGR2); |
| 694 | writel(0x3FF00000, &ccm->CCGR3); |
| 695 | writel(0x00FFF300, &ccm->CCGR4); |
| 696 | writel(0x0F0000C3, &ccm->CCGR5); |
| 697 | writel(0x000003FF, &ccm->CCGR6); |
| 698 | } |
| 699 | |
Fabio Estevam | 9b86c82 | 2016-09-26 09:14:25 -0300 | [diff] [blame] | 700 | static int mx6q_dcd_table[] = { |
| 701 | 0x020e0798, 0x000C0000, |
| 702 | 0x020e0758, 0x00000000, |
| 703 | 0x020e0588, 0x00000030, |
| 704 | 0x020e0594, 0x00000030, |
| 705 | 0x020e056c, 0x00000030, |
| 706 | 0x020e0578, 0x00000030, |
| 707 | 0x020e074c, 0x00000030, |
| 708 | 0x020e057c, 0x00000030, |
| 709 | 0x020e058c, 0x00000000, |
| 710 | 0x020e059c, 0x00000030, |
| 711 | 0x020e05a0, 0x00000030, |
| 712 | 0x020e078c, 0x00000030, |
| 713 | 0x020e0750, 0x00020000, |
| 714 | 0x020e05a8, 0x00000030, |
| 715 | 0x020e05b0, 0x00000030, |
| 716 | 0x020e0524, 0x00000030, |
| 717 | 0x020e051c, 0x00000030, |
| 718 | 0x020e0518, 0x00000030, |
| 719 | 0x020e050c, 0x00000030, |
| 720 | 0x020e05b8, 0x00000030, |
| 721 | 0x020e05c0, 0x00000030, |
| 722 | 0x020e0774, 0x00020000, |
| 723 | 0x020e0784, 0x00000030, |
| 724 | 0x020e0788, 0x00000030, |
| 725 | 0x020e0794, 0x00000030, |
| 726 | 0x020e079c, 0x00000030, |
| 727 | 0x020e07a0, 0x00000030, |
| 728 | 0x020e07a4, 0x00000030, |
| 729 | 0x020e07a8, 0x00000030, |
| 730 | 0x020e0748, 0x00000030, |
| 731 | 0x020e05ac, 0x00000030, |
| 732 | 0x020e05b4, 0x00000030, |
| 733 | 0x020e0528, 0x00000030, |
| 734 | 0x020e0520, 0x00000030, |
| 735 | 0x020e0514, 0x00000030, |
| 736 | 0x020e0510, 0x00000030, |
| 737 | 0x020e05bc, 0x00000030, |
| 738 | 0x020e05c4, 0x00000030, |
| 739 | 0x021b0800, 0xa1390003, |
| 740 | 0x021b080c, 0x001F001F, |
| 741 | 0x021b0810, 0x001F001F, |
| 742 | 0x021b480c, 0x001F001F, |
| 743 | 0x021b4810, 0x001F001F, |
| 744 | 0x021b083c, 0x43270338, |
| 745 | 0x021b0840, 0x03200314, |
| 746 | 0x021b483c, 0x431A032F, |
| 747 | 0x021b4840, 0x03200263, |
| 748 | 0x021b0848, 0x4B434748, |
| 749 | 0x021b4848, 0x4445404C, |
| 750 | 0x021b0850, 0x38444542, |
| 751 | 0x021b4850, 0x4935493A, |
| 752 | 0x021b081c, 0x33333333, |
| 753 | 0x021b0820, 0x33333333, |
| 754 | 0x021b0824, 0x33333333, |
| 755 | 0x021b0828, 0x33333333, |
| 756 | 0x021b481c, 0x33333333, |
| 757 | 0x021b4820, 0x33333333, |
| 758 | 0x021b4824, 0x33333333, |
| 759 | 0x021b4828, 0x33333333, |
| 760 | 0x021b08b8, 0x00000800, |
| 761 | 0x021b48b8, 0x00000800, |
| 762 | 0x021b0004, 0x00020036, |
| 763 | 0x021b0008, 0x09444040, |
| 764 | 0x021b000c, 0x555A7975, |
| 765 | 0x021b0010, 0xFF538F64, |
| 766 | 0x021b0014, 0x01FF00DB, |
| 767 | 0x021b0018, 0x00001740, |
| 768 | 0x021b001c, 0x00008000, |
| 769 | 0x021b002c, 0x000026d2, |
| 770 | 0x021b0030, 0x005A1023, |
| 771 | 0x021b0040, 0x00000027, |
| 772 | 0x021b0000, 0x831A0000, |
| 773 | 0x021b001c, 0x04088032, |
| 774 | 0x021b001c, 0x00008033, |
| 775 | 0x021b001c, 0x00048031, |
| 776 | 0x021b001c, 0x09408030, |
| 777 | 0x021b001c, 0x04008040, |
| 778 | 0x021b0020, 0x00005800, |
| 779 | 0x021b0818, 0x00011117, |
| 780 | 0x021b4818, 0x00011117, |
| 781 | 0x021b0004, 0x00025576, |
| 782 | 0x021b0404, 0x00011006, |
| 783 | 0x021b001c, 0x00000000, |
| 784 | }; |
| 785 | |
| 786 | static int mx6qp_dcd_table[] = { |
| 787 | 0x020e0798, 0x000c0000, |
| 788 | 0x020e0758, 0x00000000, |
| 789 | 0x020e0588, 0x00000030, |
| 790 | 0x020e0594, 0x00000030, |
| 791 | 0x020e056c, 0x00000030, |
| 792 | 0x020e0578, 0x00000030, |
| 793 | 0x020e074c, 0x00000030, |
| 794 | 0x020e057c, 0x00000030, |
| 795 | 0x020e058c, 0x00000000, |
| 796 | 0x020e059c, 0x00000030, |
| 797 | 0x020e05a0, 0x00000030, |
| 798 | 0x020e078c, 0x00000030, |
| 799 | 0x020e0750, 0x00020000, |
| 800 | 0x020e05a8, 0x00000030, |
| 801 | 0x020e05b0, 0x00000030, |
| 802 | 0x020e0524, 0x00000030, |
| 803 | 0x020e051c, 0x00000030, |
| 804 | 0x020e0518, 0x00000030, |
| 805 | 0x020e050c, 0x00000030, |
| 806 | 0x020e05b8, 0x00000030, |
| 807 | 0x020e05c0, 0x00000030, |
| 808 | 0x020e0774, 0x00020000, |
| 809 | 0x020e0784, 0x00000030, |
| 810 | 0x020e0788, 0x00000030, |
| 811 | 0x020e0794, 0x00000030, |
| 812 | 0x020e079c, 0x00000030, |
| 813 | 0x020e07a0, 0x00000030, |
| 814 | 0x020e07a4, 0x00000030, |
| 815 | 0x020e07a8, 0x00000030, |
| 816 | 0x020e0748, 0x00000030, |
| 817 | 0x020e05ac, 0x00000030, |
| 818 | 0x020e05b4, 0x00000030, |
| 819 | 0x020e0528, 0x00000030, |
| 820 | 0x020e0520, 0x00000030, |
| 821 | 0x020e0514, 0x00000030, |
| 822 | 0x020e0510, 0x00000030, |
| 823 | 0x020e05bc, 0x00000030, |
| 824 | 0x020e05c4, 0x00000030, |
| 825 | 0x021b0800, 0xa1390003, |
| 826 | 0x021b080c, 0x001b001e, |
| 827 | 0x021b0810, 0x002e0029, |
| 828 | 0x021b480c, 0x001b002a, |
| 829 | 0x021b4810, 0x0019002c, |
| 830 | 0x021b083c, 0x43240334, |
| 831 | 0x021b0840, 0x0324031a, |
| 832 | 0x021b483c, 0x43340344, |
| 833 | 0x021b4840, 0x03280276, |
| 834 | 0x021b0848, 0x44383A3E, |
| 835 | 0x021b4848, 0x3C3C3846, |
| 836 | 0x021b0850, 0x2e303230, |
| 837 | 0x021b4850, 0x38283E34, |
| 838 | 0x021b081c, 0x33333333, |
| 839 | 0x021b0820, 0x33333333, |
| 840 | 0x021b0824, 0x33333333, |
| 841 | 0x021b0828, 0x33333333, |
| 842 | 0x021b481c, 0x33333333, |
| 843 | 0x021b4820, 0x33333333, |
| 844 | 0x021b4824, 0x33333333, |
| 845 | 0x021b4828, 0x33333333, |
| 846 | 0x021b08c0, 0x24912249, |
| 847 | 0x021b48c0, 0x24914289, |
| 848 | 0x021b08b8, 0x00000800, |
| 849 | 0x021b48b8, 0x00000800, |
| 850 | 0x021b0004, 0x00020036, |
| 851 | 0x021b0008, 0x24444040, |
| 852 | 0x021b000c, 0x555A7955, |
| 853 | 0x021b0010, 0xFF320F64, |
| 854 | 0x021b0014, 0x01ff00db, |
| 855 | 0x021b0018, 0x00001740, |
| 856 | 0x021b001c, 0x00008000, |
| 857 | 0x021b002c, 0x000026d2, |
| 858 | 0x021b0030, 0x005A1023, |
| 859 | 0x021b0040, 0x00000027, |
| 860 | 0x021b0400, 0x14420000, |
| 861 | 0x021b0000, 0x831A0000, |
| 862 | 0x021b0890, 0x00400C58, |
| 863 | 0x00bb0008, 0x00000000, |
| 864 | 0x00bb000c, 0x2891E41A, |
| 865 | 0x00bb0038, 0x00000564, |
| 866 | 0x00bb0014, 0x00000040, |
| 867 | 0x00bb0028, 0x00000020, |
| 868 | 0x00bb002c, 0x00000020, |
| 869 | 0x021b001c, 0x04088032, |
| 870 | 0x021b001c, 0x00008033, |
| 871 | 0x021b001c, 0x00048031, |
| 872 | 0x021b001c, 0x09408030, |
| 873 | 0x021b001c, 0x04008040, |
| 874 | 0x021b0020, 0x00005800, |
| 875 | 0x021b0818, 0x00011117, |
| 876 | 0x021b4818, 0x00011117, |
| 877 | 0x021b0004, 0x00025576, |
| 878 | 0x021b0404, 0x00011006, |
| 879 | 0x021b001c, 0x00000000, |
| 880 | }; |
| 881 | |
Fabio Estevam | 15cb6b1 | 2017-05-12 12:45:24 -0300 | [diff] [blame] | 882 | static int mx6dl_dcd_table[] = { |
| 883 | 0x020e0774, 0x000C0000, |
| 884 | 0x020e0754, 0x00000000, |
| 885 | 0x020e04ac, 0x00000030, |
| 886 | 0x020e04b0, 0x00000030, |
| 887 | 0x020e0464, 0x00000030, |
| 888 | 0x020e0490, 0x00000030, |
| 889 | 0x020e074c, 0x00000030, |
| 890 | 0x020e0494, 0x00000030, |
| 891 | 0x020e04a0, 0x00000000, |
| 892 | 0x020e04b4, 0x00000030, |
| 893 | 0x020e04b8, 0x00000030, |
| 894 | 0x020e076c, 0x00000030, |
| 895 | 0x020e0750, 0x00020000, |
| 896 | 0x020e04bc, 0x00000030, |
| 897 | 0x020e04c0, 0x00000030, |
| 898 | 0x020e04c4, 0x00000030, |
| 899 | 0x020e04c8, 0x00000030, |
| 900 | 0x020e04cc, 0x00000030, |
| 901 | 0x020e04d0, 0x00000030, |
| 902 | 0x020e04d4, 0x00000030, |
| 903 | 0x020e04d8, 0x00000030, |
| 904 | 0x020e0760, 0x00020000, |
| 905 | 0x020e0764, 0x00000030, |
| 906 | 0x020e0770, 0x00000030, |
| 907 | 0x020e0778, 0x00000030, |
| 908 | 0x020e077c, 0x00000030, |
| 909 | 0x020e0780, 0x00000030, |
| 910 | 0x020e0784, 0x00000030, |
| 911 | 0x020e078c, 0x00000030, |
| 912 | 0x020e0748, 0x00000030, |
| 913 | 0x020e0470, 0x00000030, |
| 914 | 0x020e0474, 0x00000030, |
| 915 | 0x020e0478, 0x00000030, |
| 916 | 0x020e047c, 0x00000030, |
| 917 | 0x020e0480, 0x00000030, |
| 918 | 0x020e0484, 0x00000030, |
| 919 | 0x020e0488, 0x00000030, |
| 920 | 0x020e048c, 0x00000030, |
| 921 | 0x021b0800, 0xa1390003, |
| 922 | 0x021b080c, 0x001F001F, |
| 923 | 0x021b0810, 0x001F001F, |
| 924 | 0x021b480c, 0x001F001F, |
| 925 | 0x021b4810, 0x001F001F, |
| 926 | 0x021b083c, 0x4220021F, |
| 927 | 0x021b0840, 0x0207017E, |
| 928 | 0x021b483c, 0x4201020C, |
| 929 | 0x021b4840, 0x01660172, |
| 930 | 0x021b0848, 0x4A4D4E4D, |
| 931 | 0x021b4848, 0x4A4F5049, |
| 932 | 0x021b0850, 0x3F3C3D31, |
| 933 | 0x021b4850, 0x3238372B, |
| 934 | 0x021b081c, 0x33333333, |
| 935 | 0x021b0820, 0x33333333, |
| 936 | 0x021b0824, 0x33333333, |
| 937 | 0x021b0828, 0x33333333, |
| 938 | 0x021b481c, 0x33333333, |
| 939 | 0x021b4820, 0x33333333, |
| 940 | 0x021b4824, 0x33333333, |
| 941 | 0x021b4828, 0x33333333, |
| 942 | 0x021b08b8, 0x00000800, |
| 943 | 0x021b48b8, 0x00000800, |
| 944 | 0x021b0004, 0x0002002D, |
| 945 | 0x021b0008, 0x00333030, |
| 946 | 0x021b000c, 0x3F435313, |
| 947 | 0x021b0010, 0xB66E8B63, |
| 948 | 0x021b0014, 0x01FF00DB, |
| 949 | 0x021b0018, 0x00001740, |
| 950 | 0x021b001c, 0x00008000, |
| 951 | 0x021b002c, 0x000026d2, |
| 952 | 0x021b0030, 0x00431023, |
| 953 | 0x021b0040, 0x00000027, |
| 954 | 0x021b0000, 0x831A0000, |
| 955 | 0x021b001c, 0x04008032, |
| 956 | 0x021b001c, 0x00008033, |
| 957 | 0x021b001c, 0x00048031, |
| 958 | 0x021b001c, 0x05208030, |
| 959 | 0x021b001c, 0x04008040, |
| 960 | 0x021b0020, 0x00005800, |
| 961 | 0x021b0818, 0x00011117, |
| 962 | 0x021b4818, 0x00011117, |
| 963 | 0x021b0004, 0x0002556D, |
| 964 | 0x021b0404, 0x00011006, |
| 965 | 0x021b001c, 0x00000000, |
| 966 | }; |
| 967 | |
Fabio Estevam | 9b86c82 | 2016-09-26 09:14:25 -0300 | [diff] [blame] | 968 | static void ddr_init(int *table, int size) |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 969 | { |
Fabio Estevam | 9b86c82 | 2016-09-26 09:14:25 -0300 | [diff] [blame] | 970 | int i; |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 971 | |
Fabio Estevam | 9b86c82 | 2016-09-26 09:14:25 -0300 | [diff] [blame] | 972 | for (i = 0; i < size / 2 ; i++) |
| 973 | writel(table[2 * i + 1], table[2 * i]); |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 974 | } |
| 975 | |
Fabio Estevam | 9b86c82 | 2016-09-26 09:14:25 -0300 | [diff] [blame] | 976 | static void spl_dram_init(void) |
| 977 | { |
| 978 | if (is_mx6dq()) |
| 979 | ddr_init(mx6q_dcd_table, ARRAY_SIZE(mx6q_dcd_table)); |
| 980 | else if (is_mx6dqp()) |
| 981 | ddr_init(mx6qp_dcd_table, ARRAY_SIZE(mx6qp_dcd_table)); |
Fabio Estevam | 15cb6b1 | 2017-05-12 12:45:24 -0300 | [diff] [blame] | 982 | else if (is_mx6sdl()) |
| 983 | ddr_init(mx6dl_dcd_table, ARRAY_SIZE(mx6dl_dcd_table)); |
Fabio Estevam | 9b86c82 | 2016-09-26 09:14:25 -0300 | [diff] [blame] | 984 | } |
| 985 | |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 986 | void board_init_f(ulong dummy) |
| 987 | { |
Fabio Estevam | 9b86c82 | 2016-09-26 09:14:25 -0300 | [diff] [blame] | 988 | /* DDR initialization */ |
| 989 | spl_dram_init(); |
| 990 | |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 991 | /* setup AIPS and disable watchdog */ |
| 992 | arch_cpu_init(); |
| 993 | |
Fabio Estevam | c6ecd0b | 2014-11-14 09:36:59 -0200 | [diff] [blame] | 994 | ccgr_init(); |
| 995 | gpr_init(); |
| 996 | |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 997 | /* iomux and setup of i2c */ |
| 998 | board_early_init_f(); |
| 999 | |
| 1000 | /* setup GP timer */ |
| 1001 | timer_init(); |
| 1002 | |
| 1003 | /* UART clocks enabled and gd valid - init serial console */ |
| 1004 | preloader_console_init(); |
| 1005 | |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 1006 | /* Clear the BSS. */ |
| 1007 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 1008 | |
| 1009 | /* load/boot image from boot device */ |
| 1010 | board_init_r(NULL, 0); |
| 1011 | } |
John Tobias | 0749155 | 2014-11-12 14:27:45 -0800 | [diff] [blame] | 1012 | #endif |
Abel Vesa | 4f5bd30 | 2019-02-01 16:40:12 +0000 | [diff] [blame] | 1013 | |
| 1014 | #ifdef CONFIG_SPL_LOAD_FIT |
| 1015 | int board_fit_config_name_match(const char *name) |
| 1016 | { |
| 1017 | if (is_mx6dq()) { |
| 1018 | if (!strcmp(name, "imx6q-sabresd")) |
| 1019 | return 0; |
| 1020 | } else if (is_mx6dqp()) { |
| 1021 | if (!strcmp(name, "imx6qp-sabresd")) |
| 1022 | return 0; |
| 1023 | } else if (is_mx6dl()) { |
| 1024 | if (!strcmp(name, "imx6dl-sabresd")) |
| 1025 | return 0; |
| 1026 | } |
| 1027 | |
| 1028 | return -1; |
| 1029 | } |
| 1030 | #endif |