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> |
Jason Liu | ff9f475 | 2010-10-18 11:09:26 +0800 | [diff] [blame] | 27 | #include <asm/arch/mx5x_pins.h> |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 28 | #include <asm/arch/iomux.h> |
| 29 | #include <asm/errno.h> |
Stefano Babic | e4d3449 | 2010-03-05 17:54:37 +0100 | [diff] [blame] | 30 | #include <asm/arch/sys_proto.h> |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 31 | #include <asm/arch/crm_regs.h> |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 32 | #include <i2c.h> |
| 33 | #include <mmc.h> |
| 34 | #include <fsl_esdhc.h> |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 35 | #include <pmic.h> |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 36 | #include <fsl_pmic.h> |
| 37 | #include <mc13892.h> |
Wolfgang Grandegger | 055d969 | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 38 | #include <usb/ehci-fsl.h> |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 39 | |
| 40 | DECLARE_GLOBAL_DATA_PTR; |
| 41 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 42 | #ifdef CONFIG_FSL_ESDHC |
| 43 | struct fsl_esdhc_cfg esdhc_cfg[2] = { |
Stefano Babic | 68c07a0 | 2010-04-18 20:01:01 +0200 | [diff] [blame] | 44 | {MMC_SDHC1_BASE_ADDR, 1}, |
| 45 | {MMC_SDHC2_BASE_ADDR, 1}, |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 46 | }; |
| 47 | #endif |
| 48 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 49 | int dram_init(void) |
| 50 | { |
Shawn Guo | 1ab027c | 2010-10-28 10:13:15 +0800 | [diff] [blame] | 51 | /* dram_init must store complete ramsize in gd->ram_size */ |
Albert ARIBAUD | a55d23c | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 52 | gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, |
Shawn Guo | 1ab027c | 2010-10-28 10:13:15 +0800 | [diff] [blame] | 53 | PHYS_SDRAM_1_SIZE); |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | static void setup_iomux_uart(void) |
| 58 | { |
| 59 | unsigned int pad = PAD_CTL_HYS_ENABLE | PAD_CTL_PKE_ENABLE | |
| 60 | PAD_CTL_PUE_PULL | PAD_CTL_DRV_HIGH; |
| 61 | |
| 62 | mxc_request_iomux(MX51_PIN_UART1_RXD, IOMUX_CONFIG_ALT0); |
| 63 | mxc_iomux_set_pad(MX51_PIN_UART1_RXD, pad | PAD_CTL_SRE_FAST); |
| 64 | mxc_request_iomux(MX51_PIN_UART1_TXD, IOMUX_CONFIG_ALT0); |
| 65 | mxc_iomux_set_pad(MX51_PIN_UART1_TXD, pad | PAD_CTL_SRE_FAST); |
| 66 | mxc_request_iomux(MX51_PIN_UART1_RTS, IOMUX_CONFIG_ALT0); |
| 67 | mxc_iomux_set_pad(MX51_PIN_UART1_RTS, pad); |
| 68 | mxc_request_iomux(MX51_PIN_UART1_CTS, IOMUX_CONFIG_ALT0); |
| 69 | mxc_iomux_set_pad(MX51_PIN_UART1_CTS, pad); |
| 70 | } |
| 71 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 72 | static void setup_iomux_fec(void) |
| 73 | { |
| 74 | /*FEC_MDIO*/ |
| 75 | mxc_request_iomux(MX51_PIN_EIM_EB2 , IOMUX_CONFIG_ALT3); |
| 76 | mxc_iomux_set_pad(MX51_PIN_EIM_EB2 , 0x1FD); |
| 77 | |
| 78 | /*FEC_MDC*/ |
| 79 | mxc_request_iomux(MX51_PIN_NANDF_CS3, IOMUX_CONFIG_ALT2); |
| 80 | mxc_iomux_set_pad(MX51_PIN_NANDF_CS3, 0x2004); |
| 81 | |
| 82 | /* FEC RDATA[3] */ |
| 83 | mxc_request_iomux(MX51_PIN_EIM_CS3, IOMUX_CONFIG_ALT3); |
| 84 | mxc_iomux_set_pad(MX51_PIN_EIM_CS3, 0x180); |
| 85 | |
| 86 | /* FEC RDATA[2] */ |
| 87 | mxc_request_iomux(MX51_PIN_EIM_CS2, IOMUX_CONFIG_ALT3); |
| 88 | mxc_iomux_set_pad(MX51_PIN_EIM_CS2, 0x180); |
| 89 | |
| 90 | /* FEC RDATA[1] */ |
| 91 | mxc_request_iomux(MX51_PIN_EIM_EB3, IOMUX_CONFIG_ALT3); |
| 92 | mxc_iomux_set_pad(MX51_PIN_EIM_EB3, 0x180); |
| 93 | |
| 94 | /* FEC RDATA[0] */ |
| 95 | mxc_request_iomux(MX51_PIN_NANDF_D9, IOMUX_CONFIG_ALT2); |
| 96 | mxc_iomux_set_pad(MX51_PIN_NANDF_D9, 0x2180); |
| 97 | |
| 98 | /* FEC TDATA[3] */ |
| 99 | mxc_request_iomux(MX51_PIN_NANDF_CS6, IOMUX_CONFIG_ALT2); |
| 100 | mxc_iomux_set_pad(MX51_PIN_NANDF_CS6, 0x2004); |
| 101 | |
| 102 | /* FEC TDATA[2] */ |
| 103 | mxc_request_iomux(MX51_PIN_NANDF_CS5, IOMUX_CONFIG_ALT2); |
| 104 | mxc_iomux_set_pad(MX51_PIN_NANDF_CS5, 0x2004); |
| 105 | |
| 106 | /* FEC TDATA[1] */ |
| 107 | mxc_request_iomux(MX51_PIN_NANDF_CS4, IOMUX_CONFIG_ALT2); |
| 108 | mxc_iomux_set_pad(MX51_PIN_NANDF_CS4, 0x2004); |
| 109 | |
| 110 | /* FEC TDATA[0] */ |
| 111 | mxc_request_iomux(MX51_PIN_NANDF_D8, IOMUX_CONFIG_ALT2); |
| 112 | mxc_iomux_set_pad(MX51_PIN_NANDF_D8, 0x2004); |
| 113 | |
| 114 | /* FEC TX_EN */ |
| 115 | mxc_request_iomux(MX51_PIN_NANDF_CS7, IOMUX_CONFIG_ALT1); |
| 116 | mxc_iomux_set_pad(MX51_PIN_NANDF_CS7, 0x2004); |
| 117 | |
| 118 | /* FEC TX_ER */ |
| 119 | mxc_request_iomux(MX51_PIN_NANDF_CS2, IOMUX_CONFIG_ALT2); |
| 120 | mxc_iomux_set_pad(MX51_PIN_NANDF_CS2, 0x2004); |
| 121 | |
| 122 | /* FEC TX_CLK */ |
| 123 | mxc_request_iomux(MX51_PIN_NANDF_RDY_INT, IOMUX_CONFIG_ALT1); |
| 124 | mxc_iomux_set_pad(MX51_PIN_NANDF_RDY_INT, 0x2180); |
| 125 | |
| 126 | /* FEC TX_COL */ |
| 127 | mxc_request_iomux(MX51_PIN_NANDF_RB2, IOMUX_CONFIG_ALT1); |
| 128 | mxc_iomux_set_pad(MX51_PIN_NANDF_RB2, 0x2180); |
| 129 | |
| 130 | /* FEC RX_CLK */ |
| 131 | mxc_request_iomux(MX51_PIN_NANDF_RB3, IOMUX_CONFIG_ALT1); |
| 132 | mxc_iomux_set_pad(MX51_PIN_NANDF_RB3, 0x2180); |
| 133 | |
| 134 | /* FEC RX_CRS */ |
| 135 | mxc_request_iomux(MX51_PIN_EIM_CS5, IOMUX_CONFIG_ALT3); |
| 136 | mxc_iomux_set_pad(MX51_PIN_EIM_CS5, 0x180); |
| 137 | |
| 138 | /* FEC RX_ER */ |
| 139 | mxc_request_iomux(MX51_PIN_EIM_CS4, IOMUX_CONFIG_ALT3); |
| 140 | mxc_iomux_set_pad(MX51_PIN_EIM_CS4, 0x180); |
| 141 | |
| 142 | /* FEC RX_DV */ |
| 143 | mxc_request_iomux(MX51_PIN_NANDF_D11, IOMUX_CONFIG_ALT2); |
| 144 | mxc_iomux_set_pad(MX51_PIN_NANDF_D11, 0x2180); |
| 145 | } |
| 146 | |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 147 | #ifdef CONFIG_MXC_SPI |
| 148 | static void setup_iomux_spi(void) |
| 149 | { |
| 150 | /* 000: Select mux mode: ALT0 mux port: MOSI of instance: ecspi1 */ |
| 151 | mxc_request_iomux(MX51_PIN_CSPI1_MOSI, IOMUX_CONFIG_ALT0); |
| 152 | mxc_iomux_set_pad(MX51_PIN_CSPI1_MOSI, 0x105); |
| 153 | |
| 154 | /* 000: Select mux mode: ALT0 mux port: MISO of instance: ecspi1. */ |
| 155 | mxc_request_iomux(MX51_PIN_CSPI1_MISO, IOMUX_CONFIG_ALT0); |
| 156 | mxc_iomux_set_pad(MX51_PIN_CSPI1_MISO, 0x105); |
| 157 | |
| 158 | /* de-select SS1 of instance: ecspi1. */ |
| 159 | mxc_request_iomux(MX51_PIN_CSPI1_SS1, IOMUX_CONFIG_ALT3); |
| 160 | mxc_iomux_set_pad(MX51_PIN_CSPI1_SS1, 0x85); |
| 161 | |
| 162 | /* 000: Select mux mode: ALT0 mux port: SS0 ecspi1 */ |
| 163 | mxc_request_iomux(MX51_PIN_CSPI1_SS0, IOMUX_CONFIG_ALT0); |
| 164 | mxc_iomux_set_pad(MX51_PIN_CSPI1_SS0, 0x185); |
| 165 | |
| 166 | /* 000: Select mux mode: ALT0 mux port: RDY of instance: ecspi1. */ |
| 167 | mxc_request_iomux(MX51_PIN_CSPI1_RDY, IOMUX_CONFIG_ALT0); |
| 168 | mxc_iomux_set_pad(MX51_PIN_CSPI1_RDY, 0x180); |
| 169 | |
| 170 | /* 000: Select mux mode: ALT0 mux port: SCLK of instance: ecspi1. */ |
| 171 | mxc_request_iomux(MX51_PIN_CSPI1_SCLK, IOMUX_CONFIG_ALT0); |
| 172 | mxc_iomux_set_pad(MX51_PIN_CSPI1_SCLK, 0x105); |
| 173 | } |
| 174 | #endif |
| 175 | |
Wolfgang Grandegger | 055d969 | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 176 | #ifdef CONFIG_USB_EHCI_MX5 |
| 177 | #define MX51EVK_USBH1_HUB_RST IOMUX_TO_GPIO(MX51_PIN_GPIO1_7) /* GPIO1_7 */ |
| 178 | #define MX51EVK_USBH1_STP IOMUX_TO_GPIO(MX51_PIN_USBH1_STP) /* GPIO1_27 */ |
| 179 | #define MX51EVK_USB_CLK_EN_B IOMUX_TO_GPIO(MX51_PIN_EIM_D18) /* GPIO2_1 */ |
| 180 | #define MX51EVK_USB_PHY_RESET IOMUX_TO_GPIO(MX51_PIN_EIM_D21) /* GPIO2_5 */ |
| 181 | |
| 182 | #define USBH1_PAD (PAD_CTL_SRE_FAST | PAD_CTL_DRV_HIGH | \ |
| 183 | PAD_CTL_100K_PU | PAD_CTL_PUE_PULL | \ |
| 184 | PAD_CTL_PKE_ENABLE | PAD_CTL_HYS_ENABLE) |
| 185 | #define GPIO_PAD (PAD_CTL_DRV_HIGH | PAD_CTL_PKE_ENABLE | \ |
| 186 | PAD_CTL_SRE_FAST) |
| 187 | #define NO_PAD (1 << 16) |
| 188 | |
| 189 | static void setup_usb_h1(void) |
| 190 | { |
| 191 | setup_iomux_usb_h1(); |
| 192 | |
| 193 | /* GPIO_1_7 for USBH1 hub reset */ |
| 194 | mxc_request_iomux(MX51_PIN_GPIO1_7, IOMUX_CONFIG_ALT0); |
| 195 | mxc_iomux_set_pad(MX51_PIN_GPIO1_7, NO_PAD); |
| 196 | |
| 197 | /* GPIO_2_1 */ |
| 198 | mxc_request_iomux(MX51_PIN_EIM_D17, IOMUX_CONFIG_ALT1); |
| 199 | mxc_iomux_set_pad(MX51_PIN_EIM_D17, GPIO_PAD); |
| 200 | |
| 201 | /* GPIO_2_5 for USB PHY reset */ |
| 202 | mxc_request_iomux(MX51_PIN_EIM_D21, IOMUX_CONFIG_ALT1); |
| 203 | mxc_iomux_set_pad(MX51_PIN_EIM_D21, GPIO_PAD); |
| 204 | } |
| 205 | |
Anatolij Gustschin | 60bae5e | 2011-12-12 01:25:46 +0000 | [diff] [blame] | 206 | int board_ehci_hcd_init(int port) |
Wolfgang Grandegger | 055d969 | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 207 | { |
| 208 | /* Set USBH1_STP to GPIO and toggle it */ |
| 209 | mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_GPIO); |
| 210 | mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USBH1_PAD); |
| 211 | |
| 212 | gpio_direction_output(MX51EVK_USBH1_STP, 0); |
| 213 | gpio_direction_output(MX51EVK_USB_PHY_RESET, 0); |
| 214 | mdelay(10); |
| 215 | gpio_set_value(MX51EVK_USBH1_STP, 1); |
| 216 | |
| 217 | /* Set back USBH1_STP to be function */ |
| 218 | mxc_request_iomux(MX51_PIN_USBH1_STP, IOMUX_CONFIG_ALT0); |
| 219 | mxc_iomux_set_pad(MX51_PIN_USBH1_STP, USBH1_PAD); |
| 220 | |
| 221 | /* De-assert USB PHY RESETB */ |
| 222 | gpio_set_value(MX51EVK_USB_PHY_RESET, 1); |
| 223 | |
| 224 | /* Drive USB_CLK_EN_B line low */ |
| 225 | gpio_direction_output(MX51EVK_USB_CLK_EN_B, 0); |
| 226 | |
| 227 | /* Reset USB hub */ |
| 228 | gpio_direction_output(MX51EVK_USBH1_HUB_RST, 0); |
| 229 | mdelay(2); |
| 230 | gpio_set_value(MX51EVK_USBH1_HUB_RST, 1); |
Anatolij Gustschin | 60bae5e | 2011-12-12 01:25:46 +0000 | [diff] [blame] | 231 | return 0; |
Wolfgang Grandegger | 055d969 | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 232 | } |
| 233 | #endif |
| 234 | |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 235 | static void power_init(void) |
| 236 | { |
| 237 | unsigned int val; |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 238 | 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] | 239 | struct pmic *p; |
| 240 | |
| 241 | pmic_init(); |
| 242 | p = get_pmic(); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 243 | |
| 244 | /* Write needed to Power Gate 2 register */ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 245 | pmic_reg_read(p, REG_POWER_MISC, &val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 246 | val &= ~PWGT2SPIEN; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 247 | pmic_reg_write(p, REG_POWER_MISC, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 248 | |
Shawn Guo | 888b4f4 | 2010-10-27 23:36:04 +0800 | [diff] [blame] | 249 | /* Externally powered */ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 250 | pmic_reg_read(p, REG_CHARGE, &val); |
Shawn Guo | 888b4f4 | 2010-10-27 23:36:04 +0800 | [diff] [blame] | 251 | val |= ICHRG0 | ICHRG1 | ICHRG2 | ICHRG3 | CHGAUTOB; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 252 | pmic_reg_write(p, REG_CHARGE, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 253 | |
| 254 | /* power up the system first */ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 255 | pmic_reg_write(p, REG_POWER_MISC, PWUP); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 256 | |
| 257 | /* Set core voltage to 1.1V */ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 258 | pmic_reg_read(p, REG_SW_0, &val); |
Marek Vasut | c4a3c74 | 2011-01-19 04:40:36 +0000 | [diff] [blame] | 259 | val = (val & ~SWx_VOLT_MASK) | SWx_1_100V; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 260 | pmic_reg_write(p, REG_SW_0, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 261 | |
| 262 | /* Setup VCC (SW2) to 1.25 */ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 263 | pmic_reg_read(p, REG_SW_1, &val); |
Marek Vasut | c4a3c74 | 2011-01-19 04:40:36 +0000 | [diff] [blame] | 264 | val = (val & ~SWx_VOLT_MASK) | SWx_1_250V; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 265 | pmic_reg_write(p, REG_SW_1, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 266 | |
| 267 | /* Setup 1V2_DIG1 (SW3) to 1.25 */ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 268 | pmic_reg_read(p, REG_SW_2, &val); |
Marek Vasut | c4a3c74 | 2011-01-19 04:40:36 +0000 | [diff] [blame] | 269 | val = (val & ~SWx_VOLT_MASK) | SWx_1_250V; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 270 | pmic_reg_write(p, REG_SW_2, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 271 | udelay(50); |
| 272 | |
| 273 | /* Raise the core frequency to 800MHz */ |
| 274 | writel(0x0, &mxc_ccm->cacrr); |
| 275 | |
| 276 | /* Set switchers in Auto in NORMAL mode & STANDBY mode */ |
| 277 | /* Setup the switcher mode for SW1 & SW2*/ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 278 | pmic_reg_read(p, REG_SW_4, &val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 279 | val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) | |
| 280 | (SWMODE_MASK << SWMODE2_SHIFT))); |
| 281 | val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) | |
| 282 | (SWMODE_AUTO_AUTO << SWMODE2_SHIFT); |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 283 | pmic_reg_write(p, REG_SW_4, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 284 | |
| 285 | /* Setup the switcher mode for SW3 & SW4 */ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 286 | pmic_reg_read(p, REG_SW_5, &val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 287 | val = (val & ~((SWMODE_MASK << SWMODE3_SHIFT) | |
| 288 | (SWMODE_MASK << SWMODE4_SHIFT))); |
| 289 | val |= (SWMODE_AUTO_AUTO << SWMODE3_SHIFT) | |
| 290 | (SWMODE_AUTO_AUTO << SWMODE4_SHIFT); |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 291 | pmic_reg_write(p, REG_SW_5, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 292 | |
| 293 | /* 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] | 294 | pmic_reg_read(p, REG_SETTING_0, &val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 295 | val &= ~(VCAM_MASK | VGEN3_MASK | VDIG_MASK); |
| 296 | val |= VDIG_1_65 | VGEN3_1_8 | VCAM_2_6; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 297 | pmic_reg_write(p, REG_SETTING_0, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 298 | |
| 299 | /* Set VVIDEO to 2.775V, VAUDIO to 3V, VSD to 3.15V */ |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 300 | pmic_reg_read(p, REG_SETTING_1, &val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 301 | val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK); |
| 302 | val |= VSD_3_15 | VAUDIO_3_0 | VVIDEO_2_775; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 303 | pmic_reg_write(p, REG_SETTING_1, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 304 | |
| 305 | /* Configure VGEN3 and VCAM regulators to use external PNP */ |
| 306 | val = VGEN3CONFIG | VCAMCONFIG; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 307 | pmic_reg_write(p, REG_MODE_1, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 308 | udelay(200); |
| 309 | |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 310 | /* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */ |
| 311 | val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG | |
| 312 | VVIDEOEN | VAUDIOEN | VSDEN; |
Stefano Babic | 5357265 | 2011-10-08 10:59:20 +0200 | [diff] [blame] | 313 | pmic_reg_write(p, REG_MODE_1, val); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 314 | |
Fabio Estevam | d736ebe | 2011-10-25 03:14:00 +0000 | [diff] [blame] | 315 | mxc_request_iomux(MX51_PIN_EIM_A20, IOMUX_CONFIG_ALT1); |
| 316 | gpio_direction_output(46, 0); |
| 317 | |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 318 | udelay(500); |
| 319 | |
Stefano Babic | 753fc2e | 2011-08-21 23:29:52 +0200 | [diff] [blame] | 320 | gpio_set_value(46, 1); |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 321 | } |
| 322 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 323 | #ifdef CONFIG_FSL_ESDHC |
Thierry Reding | 314284b | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 324 | int board_mmc_getcd(struct mmc *mmc) |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 325 | { |
| 326 | struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; |
Thierry Reding | 314284b | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 327 | int ret; |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 328 | |
Fabio Estevam | 58aef72 | 2011-11-15 05:51:33 +0000 | [diff] [blame] | 329 | mxc_request_iomux(MX51_PIN_GPIO1_0, IOMUX_CONFIG_ALT1); |
Fabio Estevam | ed9d216 | 2012-02-08 02:34:45 +0000 | [diff] [blame] | 330 | gpio_direction_input(0); |
Fabio Estevam | 58aef72 | 2011-11-15 05:51:33 +0000 | [diff] [blame] | 331 | mxc_request_iomux(MX51_PIN_GPIO1_6, IOMUX_CONFIG_ALT0); |
Fabio Estevam | ed9d216 | 2012-02-08 02:34:45 +0000 | [diff] [blame] | 332 | gpio_direction_input(6); |
Fabio Estevam | 58aef72 | 2011-11-15 05:51:33 +0000 | [diff] [blame] | 333 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 334 | if (cfg->esdhc_base == MMC_SDHC1_BASE_ADDR) |
Thierry Reding | 314284b | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 335 | ret = !gpio_get_value(0); |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 336 | else |
Thierry Reding | 314284b | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 337 | ret = !gpio_get_value(6); |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 338 | |
Thierry Reding | 314284b | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 339 | return ret; |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | int board_mmc_init(bd_t *bis) |
| 343 | { |
| 344 | u32 index; |
| 345 | s32 status = 0; |
| 346 | |
| 347 | for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; |
| 348 | index++) { |
| 349 | switch (index) { |
| 350 | case 0: |
| 351 | mxc_request_iomux(MX51_PIN_SD1_CMD, |
| 352 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 353 | mxc_request_iomux(MX51_PIN_SD1_CLK, |
| 354 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 355 | mxc_request_iomux(MX51_PIN_SD1_DATA0, |
| 356 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 357 | mxc_request_iomux(MX51_PIN_SD1_DATA1, |
| 358 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 359 | mxc_request_iomux(MX51_PIN_SD1_DATA2, |
| 360 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 361 | mxc_request_iomux(MX51_PIN_SD1_DATA3, |
| 362 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 363 | mxc_iomux_set_pad(MX51_PIN_SD1_CMD, |
| 364 | PAD_CTL_DRV_MAX | PAD_CTL_DRV_VOT_HIGH | |
| 365 | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU | |
| 366 | PAD_CTL_PUE_PULL | |
| 367 | PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST); |
| 368 | mxc_iomux_set_pad(MX51_PIN_SD1_CLK, |
| 369 | PAD_CTL_DRV_MAX | PAD_CTL_DRV_VOT_HIGH | |
| 370 | PAD_CTL_HYS_NONE | PAD_CTL_47K_PU | |
| 371 | PAD_CTL_PUE_PULL | |
| 372 | PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST); |
| 373 | mxc_iomux_set_pad(MX51_PIN_SD1_DATA0, |
| 374 | PAD_CTL_DRV_MAX | PAD_CTL_DRV_VOT_HIGH | |
| 375 | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU | |
| 376 | PAD_CTL_PUE_PULL | |
| 377 | PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST); |
| 378 | mxc_iomux_set_pad(MX51_PIN_SD1_DATA1, |
| 379 | PAD_CTL_DRV_MAX | PAD_CTL_DRV_VOT_HIGH | |
| 380 | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU | |
| 381 | PAD_CTL_PUE_PULL | |
| 382 | PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST); |
| 383 | mxc_iomux_set_pad(MX51_PIN_SD1_DATA2, |
| 384 | PAD_CTL_DRV_MAX | PAD_CTL_DRV_VOT_HIGH | |
| 385 | PAD_CTL_HYS_ENABLE | PAD_CTL_47K_PU | |
| 386 | PAD_CTL_PUE_PULL | |
| 387 | PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST); |
| 388 | mxc_iomux_set_pad(MX51_PIN_SD1_DATA3, |
| 389 | PAD_CTL_DRV_MAX | PAD_CTL_DRV_VOT_HIGH | |
| 390 | PAD_CTL_HYS_ENABLE | PAD_CTL_100K_PD | |
| 391 | PAD_CTL_PUE_PULL | |
| 392 | PAD_CTL_PKE_ENABLE | PAD_CTL_SRE_FAST); |
| 393 | mxc_request_iomux(MX51_PIN_GPIO1_0, |
| 394 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 395 | mxc_iomux_set_pad(MX51_PIN_GPIO1_0, |
| 396 | PAD_CTL_HYS_ENABLE); |
| 397 | mxc_request_iomux(MX51_PIN_GPIO1_1, |
| 398 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 399 | mxc_iomux_set_pad(MX51_PIN_GPIO1_1, |
| 400 | PAD_CTL_HYS_ENABLE); |
| 401 | break; |
| 402 | case 1: |
| 403 | mxc_request_iomux(MX51_PIN_SD2_CMD, |
| 404 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 405 | mxc_request_iomux(MX51_PIN_SD2_CLK, |
| 406 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 407 | mxc_request_iomux(MX51_PIN_SD2_DATA0, |
| 408 | IOMUX_CONFIG_ALT0); |
| 409 | mxc_request_iomux(MX51_PIN_SD2_DATA1, |
| 410 | IOMUX_CONFIG_ALT0); |
| 411 | mxc_request_iomux(MX51_PIN_SD2_DATA2, |
| 412 | IOMUX_CONFIG_ALT0); |
| 413 | mxc_request_iomux(MX51_PIN_SD2_DATA3, |
| 414 | IOMUX_CONFIG_ALT0); |
| 415 | mxc_iomux_set_pad(MX51_PIN_SD2_CMD, |
| 416 | PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | |
| 417 | PAD_CTL_SRE_FAST); |
| 418 | mxc_iomux_set_pad(MX51_PIN_SD2_CLK, |
| 419 | PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | |
| 420 | PAD_CTL_SRE_FAST); |
| 421 | mxc_iomux_set_pad(MX51_PIN_SD2_DATA0, |
| 422 | PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | |
| 423 | PAD_CTL_SRE_FAST); |
| 424 | mxc_iomux_set_pad(MX51_PIN_SD2_DATA1, |
| 425 | PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | |
| 426 | PAD_CTL_SRE_FAST); |
| 427 | mxc_iomux_set_pad(MX51_PIN_SD2_DATA2, |
| 428 | PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | |
| 429 | PAD_CTL_SRE_FAST); |
| 430 | mxc_iomux_set_pad(MX51_PIN_SD2_DATA3, |
| 431 | PAD_CTL_DRV_MAX | PAD_CTL_22K_PU | |
| 432 | PAD_CTL_SRE_FAST); |
| 433 | mxc_request_iomux(MX51_PIN_SD2_CMD, |
| 434 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 435 | mxc_request_iomux(MX51_PIN_GPIO1_6, |
| 436 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 437 | mxc_iomux_set_pad(MX51_PIN_GPIO1_6, |
| 438 | PAD_CTL_HYS_ENABLE); |
| 439 | mxc_request_iomux(MX51_PIN_GPIO1_5, |
| 440 | IOMUX_CONFIG_ALT0 | IOMUX_CONFIG_SION); |
| 441 | mxc_iomux_set_pad(MX51_PIN_GPIO1_5, |
| 442 | PAD_CTL_HYS_ENABLE); |
| 443 | break; |
| 444 | default: |
| 445 | printf("Warning: you configured more ESDHC controller" |
| 446 | "(%d) as supported by the board(2)\n", |
| 447 | CONFIG_SYS_FSL_ESDHC_NUM); |
| 448 | return status; |
| 449 | } |
| 450 | status |= fsl_esdhc_initialize(bis, &esdhc_cfg[index]); |
| 451 | } |
| 452 | return status; |
| 453 | } |
| 454 | #endif |
| 455 | |
Liu Hui-R64343 | 877eb0f | 2010-12-23 01:13:17 +0000 | [diff] [blame] | 456 | int board_early_init_f(void) |
| 457 | { |
| 458 | setup_iomux_uart(); |
| 459 | setup_iomux_fec(); |
Wolfgang Grandegger | 055d969 | 2011-11-11 14:03:38 +0100 | [diff] [blame] | 460 | #ifdef CONFIG_USB_EHCI_MX5 |
| 461 | setup_usb_h1(); |
| 462 | #endif |
Liu Hui-R64343 | 877eb0f | 2010-12-23 01:13:17 +0000 | [diff] [blame] | 463 | |
| 464 | return 0; |
| 465 | } |
| 466 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 467 | int board_init(void) |
| 468 | { |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 469 | /* address of boot parameters */ |
| 470 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 471 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 472 | return 0; |
| 473 | } |
| 474 | |
Helmut Raiger | 9660e44 | 2011-10-20 04:19:47 +0000 | [diff] [blame] | 475 | #ifdef CONFIG_BOARD_LATE_INIT |
Stefano Babic | b4377e1 | 2010-03-16 17:22:21 +0100 | [diff] [blame] | 476 | int board_late_init(void) |
| 477 | { |
| 478 | #ifdef CONFIG_MXC_SPI |
| 479 | setup_iomux_spi(); |
| 480 | power_init(); |
| 481 | #endif |
| 482 | return 0; |
| 483 | } |
| 484 | #endif |
| 485 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 486 | int checkboard(void) |
| 487 | { |
Jason Liu | 5195890 | 2011-04-22 02:55:42 +0000 | [diff] [blame] | 488 | puts("Board: MX51EVK\n"); |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 489 | |
Stefano Babic | c5fb70c | 2010-02-05 15:13:58 +0100 | [diff] [blame] | 490 | return 0; |
| 491 | } |