Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 Freescale Semiconductor, Inc. |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
Stefano Babic | 5700881 | 2011-08-21 23:29:52 +0200 | [diff] [blame] | 9 | #include <asm/gpio.h> |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 10 | #include <asm/arch/imx-regs.h> |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 11 | #include <asm/arch/iomux-mx51.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 12 | #include <linux/errno.h> |
Stefano Babic | ac41d4d | 2010-03-05 17:54:37 +0100 | [diff] [blame] | 13 | #include <asm/arch/sys_proto.h> |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 14 | #include <asm/arch/crm_regs.h> |
Benoît Thébaudeau | c58ff34 | 2012-10-01 08:36:25 +0000 | [diff] [blame] | 15 | #include <asm/arch/clock.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 16 | #include <asm/mach-imx/mx5_video.h> |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 17 | #include <i2c.h> |
Diego Dorta | 2661c9c | 2017-09-22 12:12:18 -0300 | [diff] [blame] | 18 | #include <input.h> |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 19 | #include <mmc.h> |
| 20 | #include <fsl_esdhc.h> |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 21 | #include <power/pmic.h> |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 22 | #include <fsl_pmic.h> |
| 23 | #include <mc13892.h> |
Mateusz Kulikowski | 3add69e | 2016-03-31 23:12:23 +0200 | [diff] [blame] | 24 | #include <usb/ehci-ci.h> |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 25 | |
| 26 | DECLARE_GLOBAL_DATA_PTR; |
| 27 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 28 | #ifdef CONFIG_FSL_ESDHC |
| 29 | struct fsl_esdhc_cfg esdhc_cfg[2] = { |
Benoît Thébaudeau | c08d11c | 2012-08-13 07:28:16 +0000 | [diff] [blame] | 30 | {MMC_SDHC1_BASE_ADDR}, |
| 31 | {MMC_SDHC2_BASE_ADDR}, |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 32 | }; |
| 33 | #endif |
| 34 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 35 | int dram_init(void) |
| 36 | { |
Shawn Guo | bc08e7e | 2010-10-28 10:13:15 +0800 | [diff] [blame] | 37 | /* dram_init must store complete ramsize in gd->ram_size */ |
Albert ARIBAUD | a960673 | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 38 | gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, |
Shawn Guo | bc08e7e | 2010-10-28 10:13:15 +0800 | [diff] [blame] | 39 | PHYS_SDRAM_1_SIZE); |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 40 | return 0; |
| 41 | } |
| 42 | |
Benoît Thébaudeau | 7477d11 | 2012-09-18 04:48:42 +0000 | [diff] [blame] | 43 | u32 get_board_rev(void) |
| 44 | { |
| 45 | u32 rev = get_cpu_rev(); |
| 46 | if (!gpio_get_value(IMX_GPIO_NR(1, 22))) |
| 47 | rev |= BOARD_REV_2_0 << BOARD_VER_OFFSET; |
| 48 | return rev; |
| 49 | } |
| 50 | |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 51 | #define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_DSE_HIGH) |
| 52 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 53 | static void setup_iomux_uart(void) |
| 54 | { |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 55 | static const iomux_v3_cfg_t uart_pads[] = { |
| 56 | MX51_PAD_UART1_RXD__UART1_RXD, |
| 57 | MX51_PAD_UART1_TXD__UART1_TXD, |
| 58 | NEW_PAD_CTRL(MX51_PAD_UART1_RTS__UART1_RTS, UART_PAD_CTRL), |
| 59 | NEW_PAD_CTRL(MX51_PAD_UART1_CTS__UART1_CTS, UART_PAD_CTRL), |
| 60 | }; |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 61 | |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 62 | imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads)); |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 63 | } |
| 64 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 65 | static void setup_iomux_fec(void) |
| 66 | { |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 67 | static const iomux_v3_cfg_t fec_pads[] = { |
| 68 | NEW_PAD_CTRL(MX51_PAD_EIM_EB2__FEC_MDIO, PAD_CTL_HYS | |
| 69 | PAD_CTL_PUS_22K_UP | PAD_CTL_ODE | |
| 70 | PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST), |
| 71 | MX51_PAD_NANDF_CS3__FEC_MDC, |
| 72 | NEW_PAD_CTRL(MX51_PAD_EIM_CS3__FEC_RDATA3, MX51_PAD_CTRL_2), |
| 73 | NEW_PAD_CTRL(MX51_PAD_EIM_CS2__FEC_RDATA2, MX51_PAD_CTRL_2), |
| 74 | NEW_PAD_CTRL(MX51_PAD_EIM_EB3__FEC_RDATA1, MX51_PAD_CTRL_2), |
| 75 | MX51_PAD_NANDF_D9__FEC_RDATA0, |
| 76 | MX51_PAD_NANDF_CS6__FEC_TDATA3, |
| 77 | MX51_PAD_NANDF_CS5__FEC_TDATA2, |
| 78 | MX51_PAD_NANDF_CS4__FEC_TDATA1, |
| 79 | MX51_PAD_NANDF_D8__FEC_TDATA0, |
| 80 | MX51_PAD_NANDF_CS7__FEC_TX_EN, |
| 81 | MX51_PAD_NANDF_CS2__FEC_TX_ER, |
| 82 | MX51_PAD_NANDF_RDY_INT__FEC_TX_CLK, |
| 83 | NEW_PAD_CTRL(MX51_PAD_NANDF_RB2__FEC_COL, MX51_PAD_CTRL_4), |
| 84 | NEW_PAD_CTRL(MX51_PAD_NANDF_RB3__FEC_RX_CLK, MX51_PAD_CTRL_4), |
| 85 | MX51_PAD_EIM_CS5__FEC_CRS, |
| 86 | MX51_PAD_EIM_CS4__FEC_RX_ER, |
| 87 | NEW_PAD_CTRL(MX51_PAD_NANDF_D11__FEC_RX_DV, MX51_PAD_CTRL_4), |
| 88 | }; |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 89 | |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 90 | imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads)); |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 91 | } |
| 92 | |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 93 | #ifdef CONFIG_MXC_SPI |
| 94 | static void setup_iomux_spi(void) |
| 95 | { |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 96 | static const iomux_v3_cfg_t spi_pads[] = { |
| 97 | NEW_PAD_CTRL(MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI, PAD_CTL_HYS | |
| 98 | PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST), |
| 99 | NEW_PAD_CTRL(MX51_PAD_CSPI1_MISO__ECSPI1_MISO, PAD_CTL_HYS | |
| 100 | PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST), |
| 101 | NEW_PAD_CTRL(MX51_PAD_CSPI1_SS1__ECSPI1_SS1, |
| 102 | MX51_GPIO_PAD_CTRL), |
| 103 | MX51_PAD_CSPI1_SS0__ECSPI1_SS0, |
| 104 | NEW_PAD_CTRL(MX51_PAD_CSPI1_RDY__ECSPI1_RDY, MX51_PAD_CTRL_2), |
| 105 | NEW_PAD_CTRL(MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK, PAD_CTL_HYS | |
| 106 | PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST), |
| 107 | }; |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 108 | |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 109 | imx_iomux_v3_setup_multiple_pads(spi_pads, ARRAY_SIZE(spi_pads)); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 110 | } |
| 111 | #endif |
| 112 | |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 113 | #ifdef CONFIG_USB_EHCI_MX5 |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 114 | #define MX51EVK_USBH1_HUB_RST IMX_GPIO_NR(1, 7) |
| 115 | #define MX51EVK_USBH1_STP IMX_GPIO_NR(1, 27) |
Fabio Estevam | a293e19 | 2014-12-12 12:33:32 -0200 | [diff] [blame] | 116 | #define MX51EVK_USB_CLK_EN_B IMX_GPIO_NR(2, 1) |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 117 | #define MX51EVK_USB_PHY_RESET IMX_GPIO_NR(2, 5) |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 118 | |
| 119 | static void setup_usb_h1(void) |
| 120 | { |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 121 | static const iomux_v3_cfg_t usb_h1_pads[] = { |
| 122 | MX51_PAD_USBH1_CLK__USBH1_CLK, |
| 123 | MX51_PAD_USBH1_DIR__USBH1_DIR, |
| 124 | MX51_PAD_USBH1_STP__USBH1_STP, |
| 125 | MX51_PAD_USBH1_NXT__USBH1_NXT, |
| 126 | MX51_PAD_USBH1_DATA0__USBH1_DATA0, |
| 127 | MX51_PAD_USBH1_DATA1__USBH1_DATA1, |
| 128 | MX51_PAD_USBH1_DATA2__USBH1_DATA2, |
| 129 | MX51_PAD_USBH1_DATA3__USBH1_DATA3, |
| 130 | MX51_PAD_USBH1_DATA4__USBH1_DATA4, |
| 131 | MX51_PAD_USBH1_DATA5__USBH1_DATA5, |
| 132 | MX51_PAD_USBH1_DATA6__USBH1_DATA6, |
| 133 | MX51_PAD_USBH1_DATA7__USBH1_DATA7, |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 134 | |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 135 | NEW_PAD_CTRL(MX51_PAD_GPIO1_7__GPIO1_7, 0), /* H1 hub reset */ |
| 136 | MX51_PAD_EIM_D17__GPIO2_1, |
| 137 | MX51_PAD_EIM_D21__GPIO2_5, /* PHY reset */ |
| 138 | }; |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 139 | |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 140 | imx_iomux_v3_setup_multiple_pads(usb_h1_pads, ARRAY_SIZE(usb_h1_pads)); |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 141 | } |
| 142 | |
Anatolij Gustschin | ef2f579 | 2011-12-12 01:25:46 +0000 | [diff] [blame] | 143 | int board_ehci_hcd_init(int port) |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 144 | { |
| 145 | /* Set USBH1_STP to GPIO and toggle it */ |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 146 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_USBH1_STP__GPIO1_27, |
| 147 | MX51_USBH_PAD_CTRL)); |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 148 | |
| 149 | gpio_direction_output(MX51EVK_USBH1_STP, 0); |
| 150 | gpio_direction_output(MX51EVK_USB_PHY_RESET, 0); |
| 151 | mdelay(10); |
| 152 | gpio_set_value(MX51EVK_USBH1_STP, 1); |
| 153 | |
| 154 | /* Set back USBH1_STP to be function */ |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 155 | imx_iomux_v3_setup_pad(MX51_PAD_USBH1_STP__USBH1_STP); |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 156 | |
| 157 | /* De-assert USB PHY RESETB */ |
| 158 | gpio_set_value(MX51EVK_USB_PHY_RESET, 1); |
| 159 | |
| 160 | /* Drive USB_CLK_EN_B line low */ |
| 161 | gpio_direction_output(MX51EVK_USB_CLK_EN_B, 0); |
| 162 | |
| 163 | /* Reset USB hub */ |
| 164 | gpio_direction_output(MX51EVK_USBH1_HUB_RST, 0); |
| 165 | mdelay(2); |
| 166 | gpio_set_value(MX51EVK_USBH1_HUB_RST, 1); |
Anatolij Gustschin | ef2f579 | 2011-12-12 01:25:46 +0000 | [diff] [blame] | 167 | return 0; |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 168 | } |
| 169 | #endif |
| 170 | |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 171 | static void power_init(void) |
| 172 | { |
| 173 | unsigned int val; |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 174 | struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 175 | struct pmic *p; |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 176 | int ret; |
| 177 | |
Fabio Estevam | 21cb23f | 2013-11-20 20:26:03 -0200 | [diff] [blame] | 178 | ret = pmic_init(CONFIG_FSL_PMIC_BUS); |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 179 | if (ret) |
| 180 | return; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 181 | |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 182 | p = pmic_get("FSL_PMIC"); |
| 183 | if (!p) |
| 184 | return; |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 185 | |
| 186 | /* Write needed to Power Gate 2 register */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 187 | pmic_reg_read(p, REG_POWER_MISC, &val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 188 | val &= ~PWGT2SPIEN; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 189 | pmic_reg_write(p, REG_POWER_MISC, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 190 | |
Shawn Guo | 4546eb7 | 2010-10-27 23:36:04 +0800 | [diff] [blame] | 191 | /* Externally powered */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 192 | pmic_reg_read(p, REG_CHARGE, &val); |
Shawn Guo | 4546eb7 | 2010-10-27 23:36:04 +0800 | [diff] [blame] | 193 | val |= ICHRG0 | ICHRG1 | ICHRG2 | ICHRG3 | CHGAUTOB; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 194 | pmic_reg_write(p, REG_CHARGE, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 195 | |
| 196 | /* power up the system first */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 197 | pmic_reg_write(p, REG_POWER_MISC, PWUP); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 198 | |
| 199 | /* Set core voltage to 1.1V */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 200 | pmic_reg_read(p, REG_SW_0, &val); |
Marek Vasut | b043f70 | 2011-01-19 04:40:36 +0000 | [diff] [blame] | 201 | val = (val & ~SWx_VOLT_MASK) | SWx_1_100V; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 202 | pmic_reg_write(p, REG_SW_0, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 203 | |
| 204 | /* Setup VCC (SW2) to 1.25 */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 205 | pmic_reg_read(p, REG_SW_1, &val); |
Marek Vasut | b043f70 | 2011-01-19 04:40:36 +0000 | [diff] [blame] | 206 | val = (val & ~SWx_VOLT_MASK) | SWx_1_250V; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 207 | pmic_reg_write(p, REG_SW_1, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 208 | |
| 209 | /* Setup 1V2_DIG1 (SW3) to 1.25 */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 210 | pmic_reg_read(p, REG_SW_2, &val); |
Marek Vasut | b043f70 | 2011-01-19 04:40:36 +0000 | [diff] [blame] | 211 | val = (val & ~SWx_VOLT_MASK) | SWx_1_250V; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 212 | pmic_reg_write(p, REG_SW_2, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 213 | udelay(50); |
| 214 | |
| 215 | /* Raise the core frequency to 800MHz */ |
| 216 | writel(0x0, &mxc_ccm->cacrr); |
| 217 | |
| 218 | /* Set switchers in Auto in NORMAL mode & STANDBY mode */ |
| 219 | /* Setup the switcher mode for SW1 & SW2*/ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 220 | pmic_reg_read(p, REG_SW_4, &val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 221 | val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) | |
| 222 | (SWMODE_MASK << SWMODE2_SHIFT))); |
| 223 | val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) | |
| 224 | (SWMODE_AUTO_AUTO << SWMODE2_SHIFT); |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 225 | pmic_reg_write(p, REG_SW_4, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 226 | |
| 227 | /* Setup the switcher mode for SW3 & SW4 */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 228 | pmic_reg_read(p, REG_SW_5, &val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 229 | val = (val & ~((SWMODE_MASK << SWMODE3_SHIFT) | |
| 230 | (SWMODE_MASK << SWMODE4_SHIFT))); |
| 231 | val |= (SWMODE_AUTO_AUTO << SWMODE3_SHIFT) | |
| 232 | (SWMODE_AUTO_AUTO << SWMODE4_SHIFT); |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 233 | pmic_reg_write(p, REG_SW_5, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 234 | |
| 235 | /* Set VDIG to 1.65V, VGEN3 to 1.8V, VCAM to 2.6V */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 236 | pmic_reg_read(p, REG_SETTING_0, &val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 237 | val &= ~(VCAM_MASK | VGEN3_MASK | VDIG_MASK); |
| 238 | val |= VDIG_1_65 | VGEN3_1_8 | VCAM_2_6; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 239 | pmic_reg_write(p, REG_SETTING_0, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 240 | |
| 241 | /* Set VVIDEO to 2.775V, VAUDIO to 3V, VSD to 3.15V */ |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 242 | pmic_reg_read(p, REG_SETTING_1, &val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 243 | val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK); |
| 244 | val |= VSD_3_15 | VAUDIO_3_0 | VVIDEO_2_775; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 245 | pmic_reg_write(p, REG_SETTING_1, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 246 | |
| 247 | /* Configure VGEN3 and VCAM regulators to use external PNP */ |
| 248 | val = VGEN3CONFIG | VCAMCONFIG; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 249 | pmic_reg_write(p, REG_MODE_1, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 250 | udelay(200); |
| 251 | |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 252 | /* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */ |
| 253 | val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG | |
| 254 | VVIDEOEN | VAUDIOEN | VSDEN; |
Stefano Babic | dba2efc | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 255 | pmic_reg_write(p, REG_MODE_1, val); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 256 | |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 257 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_EIM_A20__GPIO2_14, |
| 258 | NO_PAD_CTRL)); |
Ashok Kumar Reddy | 7d04bd7 | 2012-08-28 07:39:38 +0530 | [diff] [blame] | 259 | gpio_direction_output(IMX_GPIO_NR(2, 14), 0); |
Fabio Estevam | c38e0d6 | 2011-10-25 03:14:00 +0000 | [diff] [blame] | 260 | |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 261 | udelay(500); |
| 262 | |
Ashok Kumar Reddy | 7d04bd7 | 2012-08-28 07:39:38 +0530 | [diff] [blame] | 263 | gpio_set_value(IMX_GPIO_NR(2, 14), 1); |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 264 | } |
| 265 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 266 | #ifdef CONFIG_FSL_ESDHC |
Thierry Reding | d7aebf4 | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 267 | int board_mmc_getcd(struct mmc *mmc) |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 268 | { |
| 269 | struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; |
Thierry Reding | d7aebf4 | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 270 | int ret; |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 271 | |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 272 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_GPIO1_0__GPIO1_0, |
| 273 | NO_PAD_CTRL)); |
Ashok Kumar Reddy | 7d04bd7 | 2012-08-28 07:39:38 +0530 | [diff] [blame] | 274 | gpio_direction_input(IMX_GPIO_NR(1, 0)); |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 275 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_GPIO1_6__GPIO1_6, |
| 276 | NO_PAD_CTRL)); |
Ashok Kumar Reddy | 7d04bd7 | 2012-08-28 07:39:38 +0530 | [diff] [blame] | 277 | gpio_direction_input(IMX_GPIO_NR(1, 6)); |
Fabio Estevam | 77c0f1b | 2011-11-15 05:51:33 +0000 | [diff] [blame] | 278 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 279 | if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR) |
Ashok Kumar Reddy | 7d04bd7 | 2012-08-28 07:39:38 +0530 | [diff] [blame] | 280 | ret = !gpio_get_value(IMX_GPIO_NR(1, 0)); |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 281 | else |
Ashok Kumar Reddy | 7d04bd7 | 2012-08-28 07:39:38 +0530 | [diff] [blame] | 282 | ret = !gpio_get_value(IMX_GPIO_NR(1, 6)); |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 283 | |
Thierry Reding | d7aebf4 | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 284 | return ret; |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | int board_mmc_init(bd_t *bis) |
| 288 | { |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 289 | static const iomux_v3_cfg_t sd1_pads[] = { |
| 290 | NEW_PAD_CTRL(MX51_PAD_SD1_CMD__SD1_CMD, PAD_CTL_DSE_MAX | |
| 291 | PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST), |
| 292 | NEW_PAD_CTRL(MX51_PAD_SD1_CLK__SD1_CLK, PAD_CTL_DSE_MAX | |
| 293 | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST), |
| 294 | NEW_PAD_CTRL(MX51_PAD_SD1_DATA0__SD1_DATA0, PAD_CTL_DSE_MAX | |
| 295 | PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST), |
| 296 | NEW_PAD_CTRL(MX51_PAD_SD1_DATA1__SD1_DATA1, PAD_CTL_DSE_MAX | |
| 297 | PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST), |
| 298 | NEW_PAD_CTRL(MX51_PAD_SD1_DATA2__SD1_DATA2, PAD_CTL_DSE_MAX | |
| 299 | PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | PAD_CTL_SRE_FAST), |
| 300 | NEW_PAD_CTRL(MX51_PAD_SD1_DATA3__SD1_DATA3, PAD_CTL_DSE_MAX | |
| 301 | PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_SRE_FAST), |
| 302 | NEW_PAD_CTRL(MX51_PAD_GPIO1_0__SD1_CD, PAD_CTL_HYS), |
| 303 | NEW_PAD_CTRL(MX51_PAD_GPIO1_1__SD1_WP, PAD_CTL_HYS), |
| 304 | }; |
| 305 | |
| 306 | static const iomux_v3_cfg_t sd2_pads[] = { |
| 307 | NEW_PAD_CTRL(MX51_PAD_SD2_CMD__SD2_CMD, |
| 308 | PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST), |
| 309 | NEW_PAD_CTRL(MX51_PAD_SD2_CLK__SD2_CLK, |
| 310 | PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST), |
| 311 | NEW_PAD_CTRL(MX51_PAD_SD2_DATA0__SD2_DATA0, |
| 312 | PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST), |
| 313 | NEW_PAD_CTRL(MX51_PAD_SD2_DATA1__SD2_DATA1, |
| 314 | PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST), |
| 315 | NEW_PAD_CTRL(MX51_PAD_SD2_DATA2__SD2_DATA2, |
| 316 | PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST), |
| 317 | NEW_PAD_CTRL(MX51_PAD_SD2_DATA3__SD2_DATA3, |
| 318 | PAD_CTL_DSE_MAX | PAD_CTL_SRE_FAST), |
| 319 | NEW_PAD_CTRL(MX51_PAD_GPIO1_6__GPIO1_6, PAD_CTL_HYS), |
| 320 | NEW_PAD_CTRL(MX51_PAD_GPIO1_5__GPIO1_5, PAD_CTL_HYS), |
| 321 | }; |
| 322 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 323 | u32 index; |
Fabio Estevam | e48f038 | 2014-11-20 16:35:16 -0200 | [diff] [blame] | 324 | int ret; |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 325 | |
Benoît Thébaudeau | c58ff34 | 2012-10-01 08:36:25 +0000 | [diff] [blame] | 326 | esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); |
| 327 | esdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK); |
| 328 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 329 | for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; |
| 330 | index++) { |
| 331 | switch (index) { |
| 332 | case 0: |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 333 | imx_iomux_v3_setup_multiple_pads(sd1_pads, |
| 334 | ARRAY_SIZE(sd1_pads)); |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 335 | break; |
| 336 | case 1: |
Benoît Thébaudeau | 168dc71 | 2013-05-03 10:32:27 +0000 | [diff] [blame] | 337 | imx_iomux_v3_setup_multiple_pads(sd2_pads, |
| 338 | ARRAY_SIZE(sd2_pads)); |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 339 | break; |
| 340 | default: |
| 341 | printf("Warning: you configured more ESDHC controller" |
| 342 | "(%d) as supported by the board(2)\n", |
| 343 | CONFIG_SYS_FSL_ESDHC_NUM); |
Fabio Estevam | e48f038 | 2014-11-20 16:35:16 -0200 | [diff] [blame] | 344 | return -EINVAL; |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 345 | } |
Fabio Estevam | e48f038 | 2014-11-20 16:35:16 -0200 | [diff] [blame] | 346 | ret = fsl_esdhc_initialize(bis, &esdhc_cfg[index]); |
| 347 | if (ret) |
| 348 | return ret; |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 349 | } |
Fabio Estevam | e48f038 | 2014-11-20 16:35:16 -0200 | [diff] [blame] | 350 | return 0; |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 351 | } |
| 352 | #endif |
| 353 | |
Liu Hui-R64343 | 1e929df | 2010-12-23 01:13:17 +0000 | [diff] [blame] | 354 | int board_early_init_f(void) |
| 355 | { |
| 356 | setup_iomux_uart(); |
| 357 | setup_iomux_fec(); |
Wolfgang Grandegger | 2e865da | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 358 | #ifdef CONFIG_USB_EHCI_MX5 |
| 359 | setup_usb_h1(); |
| 360 | #endif |
Vikram Narayanan | 9ddfa24 | 2012-11-10 02:28:52 +0000 | [diff] [blame] | 361 | setup_iomux_lcd(); |
Liu Hui-R64343 | 1e929df | 2010-12-23 01:13:17 +0000 | [diff] [blame] | 362 | |
| 363 | return 0; |
| 364 | } |
| 365 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 366 | int board_init(void) |
| 367 | { |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 368 | /* address of boot parameters */ |
| 369 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 370 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 371 | return 0; |
| 372 | } |
| 373 | |
Helmut Raiger | d5a184b | 2011-10-20 04:19:47 +0000 | [diff] [blame] | 374 | #ifdef CONFIG_BOARD_LATE_INIT |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 375 | int board_late_init(void) |
| 376 | { |
| 377 | #ifdef CONFIG_MXC_SPI |
| 378 | setup_iomux_spi(); |
| 379 | power_init(); |
| 380 | #endif |
Fabio Estevam | 12ba860 | 2012-05-09 06:39:41 +0000 | [diff] [blame] | 381 | |
Stefano Babic | 9665127 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 382 | return 0; |
| 383 | } |
| 384 | #endif |
| 385 | |
Fabio Estevam | 8892058 | 2012-08-05 07:31:33 +0000 | [diff] [blame] | 386 | /* |
| 387 | * Do not overwrite the console |
| 388 | * Use always serial for U-Boot console |
| 389 | */ |
| 390 | int overwrite_console(void) |
| 391 | { |
| 392 | return 1; |
| 393 | } |
| 394 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 395 | int checkboard(void) |
| 396 | { |
Jason Liu | 8b7b69b | 2011-04-22 02:55:42 +0000 | [diff] [blame] | 397 | puts("Board: MX51EVK\n"); |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 398 | |
Stefano Babic | 421834e | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 399 | return 0; |
| 400 | } |