Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 1 | /* |
Marek Vasut | 3cb457d | 2017-04-05 13:31:02 +0200 | [diff] [blame] | 2 | * Aries M53 module |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2012-2013 Marek Vasut <marex@denx.de> |
| 5 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 6 | * SPDX-License-Identifier: GPL-2.0+ |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
| 10 | #include <asm/io.h> |
| 11 | #include <asm/arch/imx-regs.h> |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 12 | #include <asm/arch/sys_proto.h> |
| 13 | #include <asm/arch/crm_regs.h> |
| 14 | #include <asm/arch/clock.h> |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 15 | #include <asm/arch/iomux-mx53.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 16 | #include <asm/mach-imx/mx5_video.h> |
Masahiro Yamada | 7472656 | 2014-04-23 21:20:43 +0900 | [diff] [blame] | 17 | #include <asm/spl.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 18 | #include <linux/errno.h> |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 19 | #include <netdev.h> |
| 20 | #include <i2c.h> |
| 21 | #include <mmc.h> |
| 22 | #include <spl.h> |
| 23 | #include <fsl_esdhc.h> |
| 24 | #include <asm/gpio.h> |
Mateusz Kulikowski | 3add69e | 2016-03-31 23:12:23 +0200 | [diff] [blame] | 25 | #include <usb/ehci-ci.h> |
Marek Vasut | fb59a78 | 2013-12-02 17:01:42 +0100 | [diff] [blame] | 26 | #include <linux/fb.h> |
| 27 | #include <ipu_pixfmt.h> |
| 28 | |
| 29 | /* Special MXCFB sync flags are here. */ |
| 30 | #include "../drivers/video/mxcfb.h" |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 31 | |
| 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 34 | static void setup_iomux_uart(void) |
| 35 | { |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 36 | static const iomux_v3_cfg_t uart_pads[] = { |
| 37 | MX53_PAD_PATA_BUFFER_EN__UART2_RXD_MUX, |
| 38 | MX53_PAD_PATA_DMARQ__UART2_TXD_MUX, |
| 39 | }; |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 40 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 41 | imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads)); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | #ifdef CONFIG_USB_EHCI_MX5 |
| 45 | int board_ehci_hcd_init(int port) |
| 46 | { |
| 47 | if (port == 0) { |
| 48 | /* USB OTG PWRON */ |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 49 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX53_PAD_GPIO_4__GPIO1_4, |
| 50 | PAD_CTL_PKE | PAD_CTL_DSE_HIGH)); |
| 51 | gpio_direction_output(IMX_GPIO_NR(1, 4), 0); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 52 | |
| 53 | /* USB OTG Over Current */ |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 54 | imx_iomux_v3_setup_pad(MX53_PAD_GPIO_18__GPIO7_13); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 55 | } else if (port == 1) { |
| 56 | /* USB Host PWRON */ |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 57 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX53_PAD_GPIO_2__GPIO1_2, |
| 58 | PAD_CTL_PKE | PAD_CTL_DSE_HIGH)); |
| 59 | gpio_direction_output(IMX_GPIO_NR(1, 2), 0); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 60 | |
| 61 | /* USB Host Over Current */ |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 62 | imx_iomux_v3_setup_pad(MX53_PAD_GPIO_3__USBOH3_USBH1_OC); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | #endif |
| 68 | |
| 69 | static void setup_iomux_fec(void) |
| 70 | { |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 71 | static const iomux_v3_cfg_t fec_pads[] = { |
| 72 | /* MDIO pads */ |
| 73 | NEW_PAD_CTRL(MX53_PAD_FEC_MDIO__FEC_MDIO, PAD_CTL_HYS | |
| 74 | PAD_CTL_DSE_HIGH | PAD_CTL_PUS_22K_UP | PAD_CTL_ODE), |
| 75 | NEW_PAD_CTRL(MX53_PAD_FEC_MDC__FEC_MDC, PAD_CTL_DSE_HIGH), |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 76 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 77 | /* FEC 0 pads */ |
| 78 | NEW_PAD_CTRL(MX53_PAD_FEC_CRS_DV__FEC_RX_DV, |
| 79 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 80 | NEW_PAD_CTRL(MX53_PAD_FEC_REF_CLK__FEC_TX_CLK, |
| 81 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 82 | NEW_PAD_CTRL(MX53_PAD_FEC_RX_ER__FEC_RX_ER, |
| 83 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 84 | NEW_PAD_CTRL(MX53_PAD_FEC_TX_EN__FEC_TX_EN, PAD_CTL_DSE_HIGH), |
| 85 | NEW_PAD_CTRL(MX53_PAD_FEC_RXD0__FEC_RDATA_0, |
| 86 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 87 | NEW_PAD_CTRL(MX53_PAD_FEC_RXD1__FEC_RDATA_1, |
| 88 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 89 | NEW_PAD_CTRL(MX53_PAD_FEC_TXD0__FEC_TDATA_0, PAD_CTL_DSE_HIGH), |
| 90 | NEW_PAD_CTRL(MX53_PAD_FEC_TXD1__FEC_TDATA_1, PAD_CTL_DSE_HIGH), |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 91 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 92 | /* FEC 1 pads */ |
| 93 | NEW_PAD_CTRL(MX53_PAD_KEY_COL0__FEC_RDATA_3, |
| 94 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 95 | NEW_PAD_CTRL(MX53_PAD_KEY_ROW0__FEC_TX_ER, |
| 96 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 97 | NEW_PAD_CTRL(MX53_PAD_KEY_COL1__FEC_RX_CLK, |
| 98 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 99 | NEW_PAD_CTRL(MX53_PAD_KEY_ROW1__FEC_COL, |
| 100 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 101 | NEW_PAD_CTRL(MX53_PAD_KEY_COL2__FEC_RDATA_2, |
| 102 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 103 | NEW_PAD_CTRL(MX53_PAD_KEY_ROW2__FEC_TDATA_2, PAD_CTL_DSE_HIGH), |
| 104 | NEW_PAD_CTRL(MX53_PAD_KEY_COL3__FEC_CRS, |
| 105 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 106 | NEW_PAD_CTRL(MX53_PAD_GPIO_19__FEC_TDATA_3, PAD_CTL_DSE_HIGH), |
| 107 | }; |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 108 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 109 | imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads)); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | #ifdef CONFIG_FSL_ESDHC |
| 113 | struct fsl_esdhc_cfg esdhc_cfg = { |
| 114 | MMC_SDHC1_BASE_ADDR, |
| 115 | }; |
| 116 | |
| 117 | int board_mmc_getcd(struct mmc *mmc) |
| 118 | { |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 119 | imx_iomux_v3_setup_pad(MX53_PAD_GPIO_1__GPIO1_1); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 120 | gpio_direction_input(IMX_GPIO_NR(1, 1)); |
| 121 | |
| 122 | return !gpio_get_value(IMX_GPIO_NR(1, 1)); |
| 123 | } |
| 124 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 125 | #define SD_CMD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \ |
| 126 | PAD_CTL_PUS_100K_UP) |
| 127 | #define SD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | \ |
| 128 | PAD_CTL_DSE_HIGH) |
| 129 | |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 130 | int board_mmc_init(bd_t *bis) |
| 131 | { |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 132 | static const iomux_v3_cfg_t sd1_pads[] = { |
| 133 | NEW_PAD_CTRL(MX53_PAD_SD1_CMD__ESDHC1_CMD, SD_CMD_PAD_CTRL), |
| 134 | NEW_PAD_CTRL(MX53_PAD_SD1_CLK__ESDHC1_CLK, SD_PAD_CTRL), |
| 135 | NEW_PAD_CTRL(MX53_PAD_SD1_DATA0__ESDHC1_DAT0, SD_PAD_CTRL), |
| 136 | NEW_PAD_CTRL(MX53_PAD_SD1_DATA1__ESDHC1_DAT1, SD_PAD_CTRL), |
| 137 | NEW_PAD_CTRL(MX53_PAD_SD1_DATA2__ESDHC1_DAT2, SD_PAD_CTRL), |
| 138 | NEW_PAD_CTRL(MX53_PAD_SD1_DATA3__ESDHC1_DAT3, SD_PAD_CTRL), |
| 139 | MX53_PAD_EIM_DA13__GPIO3_13, |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 140 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 141 | MX53_PAD_EIM_EB3__GPIO2_31, /* SD power */ |
| 142 | }; |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 143 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 144 | esdhc_cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); |
| 145 | |
| 146 | imx_iomux_v3_setup_multiple_pads(sd1_pads, ARRAY_SIZE(sd1_pads)); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 147 | |
| 148 | /* GPIO 2_31 is SD power */ |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 149 | gpio_direction_output(IMX_GPIO_NR(2, 31), 0); |
| 150 | |
| 151 | return fsl_esdhc_initialize(bis, &esdhc_cfg); |
| 152 | } |
| 153 | #endif |
| 154 | |
Marek Vasut | fb59a78 | 2013-12-02 17:01:42 +0100 | [diff] [blame] | 155 | #ifdef CONFIG_VIDEO |
| 156 | static struct fb_videomode const ampire_wvga = { |
| 157 | .name = "Ampire", |
| 158 | .refresh = 60, |
| 159 | .xres = 800, |
| 160 | .yres = 480, |
| 161 | .pixclock = 29851, /* picosecond (33.5 MHz) */ |
| 162 | .left_margin = 89, |
| 163 | .right_margin = 164, |
| 164 | .upper_margin = 23, |
| 165 | .lower_margin = 10, |
| 166 | .hsync_len = 10, |
| 167 | .vsync_len = 10, |
| 168 | .sync = FB_SYNC_CLK_LAT_FALL, |
| 169 | }; |
| 170 | |
| 171 | int board_video_skip(void) |
| 172 | { |
| 173 | int ret; |
| 174 | ret = ipuv3_fb_init(&ire_wvga, 1, IPU_PIX_FMT_RGB666); |
| 175 | if (ret) |
| 176 | printf("Ampire LCD cannot be configured: %d\n", ret); |
| 177 | return ret; |
| 178 | } |
| 179 | #endif |
| 180 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 181 | #define I2C_PAD_CTRL (PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | \ |
| 182 | PAD_CTL_PUS_100K_UP | PAD_CTL_ODE) |
| 183 | |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 184 | static void setup_iomux_i2c(void) |
| 185 | { |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 186 | static const iomux_v3_cfg_t i2c_pads[] = { |
| 187 | NEW_PAD_CTRL(MX53_PAD_EIM_D16__I2C2_SDA, I2C_PAD_CTRL), |
| 188 | NEW_PAD_CTRL(MX53_PAD_EIM_EB2__I2C2_SCL, I2C_PAD_CTRL), |
| 189 | }; |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 190 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 191 | imx_iomux_v3_setup_multiple_pads(i2c_pads, ARRAY_SIZE(i2c_pads)); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Marek Vasut | fb59a78 | 2013-12-02 17:01:42 +0100 | [diff] [blame] | 194 | static void setup_iomux_video(void) |
| 195 | { |
| 196 | static const iomux_v3_cfg_t lcd_pads[] = { |
| 197 | MX53_PAD_EIM_DA9__IPU_DISP1_DAT_0, |
| 198 | MX53_PAD_EIM_DA8__IPU_DISP1_DAT_1, |
| 199 | MX53_PAD_EIM_DA7__IPU_DISP1_DAT_2, |
| 200 | MX53_PAD_EIM_DA6__IPU_DISP1_DAT_3, |
| 201 | MX53_PAD_EIM_DA5__IPU_DISP1_DAT_4, |
| 202 | MX53_PAD_EIM_DA4__IPU_DISP1_DAT_5, |
| 203 | MX53_PAD_EIM_DA3__IPU_DISP1_DAT_6, |
| 204 | MX53_PAD_EIM_DA2__IPU_DISP1_DAT_7, |
| 205 | MX53_PAD_EIM_DA1__IPU_DISP1_DAT_8, |
| 206 | MX53_PAD_EIM_DA0__IPU_DISP1_DAT_9, |
| 207 | MX53_PAD_EIM_EB1__IPU_DISP1_DAT_10, |
| 208 | MX53_PAD_EIM_EB0__IPU_DISP1_DAT_11, |
| 209 | MX53_PAD_EIM_A17__IPU_DISP1_DAT_12, |
| 210 | MX53_PAD_EIM_A18__IPU_DISP1_DAT_13, |
| 211 | MX53_PAD_EIM_A19__IPU_DISP1_DAT_14, |
| 212 | MX53_PAD_EIM_A20__IPU_DISP1_DAT_15, |
| 213 | MX53_PAD_EIM_A21__IPU_DISP1_DAT_16, |
| 214 | MX53_PAD_EIM_A22__IPU_DISP1_DAT_17, |
| 215 | MX53_PAD_EIM_A23__IPU_DISP1_DAT_18, |
| 216 | MX53_PAD_EIM_A24__IPU_DISP1_DAT_19, |
| 217 | MX53_PAD_EIM_D31__IPU_DISP1_DAT_20, |
| 218 | MX53_PAD_EIM_D30__IPU_DISP1_DAT_21, |
| 219 | MX53_PAD_EIM_D26__IPU_DISP1_DAT_22, |
| 220 | MX53_PAD_EIM_D27__IPU_DISP1_DAT_23, |
| 221 | MX53_PAD_EIM_A16__IPU_DI1_DISP_CLK, |
| 222 | MX53_PAD_EIM_DA13__IPU_DI1_D0_CS, |
| 223 | MX53_PAD_EIM_DA14__IPU_DI1_D1_CS, |
| 224 | MX53_PAD_EIM_DA15__IPU_DI1_PIN1, |
| 225 | MX53_PAD_EIM_DA11__IPU_DI1_PIN2, |
| 226 | MX53_PAD_EIM_DA12__IPU_DI1_PIN3, |
| 227 | MX53_PAD_EIM_A25__IPU_DI1_PIN12, |
| 228 | MX53_PAD_EIM_DA10__IPU_DI1_PIN15, |
| 229 | }; |
| 230 | |
| 231 | imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads)); |
| 232 | } |
| 233 | |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 234 | static void setup_iomux_nand(void) |
| 235 | { |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 236 | static const iomux_v3_cfg_t nand_pads[] = { |
| 237 | NEW_PAD_CTRL(MX53_PAD_NANDF_WE_B__EMI_NANDF_WE_B, |
| 238 | PAD_CTL_DSE_HIGH), |
| 239 | NEW_PAD_CTRL(MX53_PAD_NANDF_RE_B__EMI_NANDF_RE_B, |
| 240 | PAD_CTL_DSE_HIGH), |
| 241 | NEW_PAD_CTRL(MX53_PAD_NANDF_CLE__EMI_NANDF_CLE, |
| 242 | PAD_CTL_DSE_HIGH), |
| 243 | NEW_PAD_CTRL(MX53_PAD_NANDF_ALE__EMI_NANDF_ALE, |
| 244 | PAD_CTL_DSE_HIGH), |
| 245 | NEW_PAD_CTRL(MX53_PAD_NANDF_WP_B__EMI_NANDF_WP_B, |
| 246 | PAD_CTL_PUS_100K_UP), |
| 247 | NEW_PAD_CTRL(MX53_PAD_NANDF_RB0__EMI_NANDF_RB_0, |
| 248 | PAD_CTL_PUS_100K_UP), |
| 249 | NEW_PAD_CTRL(MX53_PAD_NANDF_CS0__EMI_NANDF_CS_0, |
| 250 | PAD_CTL_DSE_HIGH), |
| 251 | NEW_PAD_CTRL(MX53_PAD_PATA_DATA0__EMI_NANDF_D_0, |
| 252 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE), |
| 253 | NEW_PAD_CTRL(MX53_PAD_PATA_DATA1__EMI_NANDF_D_1, |
| 254 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE), |
| 255 | NEW_PAD_CTRL(MX53_PAD_PATA_DATA2__EMI_NANDF_D_2, |
| 256 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE), |
| 257 | NEW_PAD_CTRL(MX53_PAD_PATA_DATA3__EMI_NANDF_D_3, |
| 258 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE), |
| 259 | NEW_PAD_CTRL(MX53_PAD_PATA_DATA4__EMI_NANDF_D_4, |
| 260 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE), |
| 261 | NEW_PAD_CTRL(MX53_PAD_PATA_DATA5__EMI_NANDF_D_5, |
| 262 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE), |
| 263 | NEW_PAD_CTRL(MX53_PAD_PATA_DATA6__EMI_NANDF_D_6, |
| 264 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE), |
| 265 | NEW_PAD_CTRL(MX53_PAD_PATA_DATA7__EMI_NANDF_D_7, |
| 266 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE), |
| 267 | }; |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 268 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 269 | imx_iomux_v3_setup_multiple_pads(nand_pads, ARRAY_SIZE(nand_pads)); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | static void m53_set_clock(void) |
| 273 | { |
| 274 | int ret; |
| 275 | const uint32_t ref_clk = MXC_HCLK; |
| 276 | const uint32_t dramclk = 400; |
| 277 | uint32_t cpuclk; |
| 278 | |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 279 | imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX53_PAD_GPIO_10__GPIO4_0, |
| 280 | PAD_CTL_DSE_HIGH | PAD_CTL_PKE)); |
| 281 | gpio_direction_input(IMX_GPIO_NR(4, 0)); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 282 | |
| 283 | /* GPIO10 selects modules' CPU speed, 1 = 1200MHz ; 0 = 800MHz */ |
Benoît Thébaudeau | 56b978e | 2013-05-03 10:32:36 +0000 | [diff] [blame] | 284 | cpuclk = gpio_get_value(IMX_GPIO_NR(4, 0)) ? 1200 : 800; |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 285 | |
| 286 | ret = mxc_set_clock(ref_clk, cpuclk, MXC_ARM_CLK); |
| 287 | if (ret) |
| 288 | printf("CPU: Switch CPU clock to %dMHz failed\n", cpuclk); |
| 289 | |
| 290 | ret = mxc_set_clock(ref_clk, dramclk, MXC_PERIPH_CLK); |
| 291 | if (ret) { |
| 292 | printf("CPU: Switch peripheral clock to %dMHz failed\n", |
| 293 | dramclk); |
| 294 | } |
| 295 | |
| 296 | ret = mxc_set_clock(ref_clk, dramclk, MXC_DDR_CLK); |
| 297 | if (ret) |
| 298 | printf("CPU: Switch DDR clock to %dMHz failed\n", dramclk); |
| 299 | } |
| 300 | |
| 301 | static void m53_set_nand(void) |
| 302 | { |
| 303 | u32 i; |
| 304 | |
| 305 | /* NAND flash is muxed on ATA pins */ |
| 306 | setbits_le32(M4IF_BASE_ADDR + 0xc, M4IF_GENP_WEIM_MM_MASK); |
| 307 | |
| 308 | /* Wait for Grant/Ack sequence (see EIM_CSnGCR2:MUX16_BYP_GRANT) */ |
| 309 | for (i = 0x4; i < 0x94; i += 0x18) { |
| 310 | clrbits_le32(WEIM_BASE_ADDR + i, |
| 311 | WEIM_GCR2_MUX16_BYP_GRANT_MASK); |
| 312 | } |
| 313 | |
| 314 | mxc_set_clock(0, 33, MXC_NFC_CLK); |
| 315 | enable_nfc_clk(1); |
| 316 | } |
| 317 | |
| 318 | int board_early_init_f(void) |
| 319 | { |
| 320 | setup_iomux_uart(); |
| 321 | setup_iomux_fec(); |
| 322 | setup_iomux_i2c(); |
| 323 | setup_iomux_nand(); |
Marek Vasut | fb59a78 | 2013-12-02 17:01:42 +0100 | [diff] [blame] | 324 | setup_iomux_video(); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 325 | |
| 326 | m53_set_clock(); |
| 327 | |
| 328 | mxc_set_sata_internal_clock(); |
| 329 | |
| 330 | /* NAND clock @ 33MHz */ |
| 331 | m53_set_nand(); |
| 332 | |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | int board_init(void) |
| 337 | { |
| 338 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 339 | |
| 340 | return 0; |
| 341 | } |
| 342 | |
| 343 | int checkboard(void) |
| 344 | { |
Marek Vasut | 3cb457d | 2017-04-05 13:31:02 +0200 | [diff] [blame] | 345 | puts("Board: Aries M53EVK\n"); |
Marek Vasut | 2e8edf5 | 2013-04-25 10:16:03 +0000 | [diff] [blame] | 346 | |
| 347 | return 0; |
| 348 | } |
| 349 | |
| 350 | /* |
| 351 | * NAND SPL |
| 352 | */ |
| 353 | #ifdef CONFIG_SPL_BUILD |
| 354 | void spl_board_init(void) |
| 355 | { |
| 356 | setup_iomux_nand(); |
| 357 | m53_set_clock(); |
| 358 | m53_set_nand(); |
| 359 | } |
| 360 | |
| 361 | u32 spl_boot_device(void) |
| 362 | { |
| 363 | return BOOT_DEVICE_NAND; |
| 364 | } |
| 365 | #endif |