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