Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2011 Freescale Semiconductor, Inc. |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <asm/io.h> |
| 8 | #include <asm/arch/imx-regs.h> |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 9 | #include <asm/arch/sys_proto.h> |
| 10 | #include <asm/arch/crm_regs.h> |
Benoît Thébaudeau | c58ff34 | 2012-10-01 08:36:25 +0000 | [diff] [blame] | 11 | #include <asm/arch/clock.h> |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 12 | #include <asm/arch/iomux-mx53.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 13 | #include <linux/errno.h> |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 14 | #include <netdev.h> |
| 15 | #include <mmc.h> |
| 16 | #include <fsl_esdhc.h> |
Stefano Babic | 7afafd0 | 2011-08-21 10:56:57 +0200 | [diff] [blame] | 17 | #include <asm/gpio.h> |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 18 | |
| 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 21 | int dram_init(void) |
| 22 | { |
| 23 | u32 size1, size2; |
| 24 | |
Albert ARIBAUD | a960673 | 2011-07-03 05:55:33 +0000 | [diff] [blame] | 25 | size1 = get_ram_size((void *)PHYS_SDRAM_1, PHYS_SDRAM_1_SIZE); |
| 26 | size2 = get_ram_size((void *)PHYS_SDRAM_2, PHYS_SDRAM_2_SIZE); |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 27 | |
| 28 | gd->ram_size = size1 + size2; |
| 29 | |
| 30 | return 0; |
| 31 | } |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 32 | int dram_init_banksize(void) |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 33 | { |
| 34 | gd->bd->bi_dram[0].start = PHYS_SDRAM_1; |
| 35 | gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; |
| 36 | |
| 37 | gd->bd->bi_dram[1].start = PHYS_SDRAM_2; |
| 38 | gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE; |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 39 | |
| 40 | return 0; |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 43 | #define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \ |
| 44 | PAD_CTL_PUS_100K_UP | PAD_CTL_ODE) |
| 45 | |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 46 | static void setup_iomux_uart(void) |
| 47 | { |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 48 | static const iomux_v3_cfg_t uart_pads[] = { |
| 49 | NEW_PAD_CTRL(MX53_PAD_CSI0_DAT11__UART1_RXD_MUX, UART_PAD_CTRL), |
| 50 | NEW_PAD_CTRL(MX53_PAD_CSI0_DAT10__UART1_TXD_MUX, UART_PAD_CTRL), |
| 51 | }; |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 52 | |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 53 | imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads)); |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | static void setup_iomux_fec(void) |
| 57 | { |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 58 | static const iomux_v3_cfg_t fec_pads[] = { |
| 59 | NEW_PAD_CTRL(MX53_PAD_FEC_MDIO__FEC_MDIO, PAD_CTL_HYS | |
| 60 | PAD_CTL_DSE_HIGH | PAD_CTL_PUS_22K_UP | PAD_CTL_ODE), |
| 61 | NEW_PAD_CTRL(MX53_PAD_FEC_MDC__FEC_MDC, PAD_CTL_DSE_HIGH), |
| 62 | NEW_PAD_CTRL(MX53_PAD_FEC_RXD1__FEC_RDATA_1, |
| 63 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 64 | NEW_PAD_CTRL(MX53_PAD_FEC_RXD0__FEC_RDATA_0, |
| 65 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 66 | NEW_PAD_CTRL(MX53_PAD_FEC_TXD1__FEC_TDATA_1, PAD_CTL_DSE_HIGH), |
| 67 | NEW_PAD_CTRL(MX53_PAD_FEC_TXD0__FEC_TDATA_0, PAD_CTL_DSE_HIGH), |
| 68 | NEW_PAD_CTRL(MX53_PAD_FEC_TX_EN__FEC_TX_EN, PAD_CTL_DSE_HIGH), |
| 69 | NEW_PAD_CTRL(MX53_PAD_FEC_REF_CLK__FEC_TX_CLK, |
| 70 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 71 | NEW_PAD_CTRL(MX53_PAD_FEC_RX_ER__FEC_RX_ER, |
| 72 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 73 | NEW_PAD_CTRL(MX53_PAD_FEC_CRS_DV__FEC_RX_DV, |
| 74 | PAD_CTL_HYS | PAD_CTL_PKE), |
| 75 | }; |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 76 | |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 77 | imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads)); |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | #ifdef CONFIG_FSL_ESDHC |
| 81 | struct fsl_esdhc_cfg esdhc_cfg[1] = { |
Benoît Thébaudeau | c08d11c | 2012-08-13 07:28:16 +0000 | [diff] [blame] | 82 | {MMC_SDHC1_BASE_ADDR}, |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 83 | }; |
| 84 | |
Thierry Reding | d7aebf4 | 2012-01-02 01:15:36 +0000 | [diff] [blame] | 85 | int board_mmc_getcd(struct mmc *mmc) |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 86 | { |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 87 | imx_iomux_v3_setup_pad(MX53_PAD_EIM_DA13__GPIO3_13); |
Ashok Kumar Reddy | 7d04bd7 | 2012-08-28 07:39:38 +0530 | [diff] [blame] | 88 | gpio_direction_input(IMX_GPIO_NR(3, 13)); |
| 89 | return !gpio_get_value(IMX_GPIO_NR(3, 13)); |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 92 | #define SD_CMD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \ |
| 93 | PAD_CTL_PUS_100K_UP) |
| 94 | #define SD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | \ |
| 95 | PAD_CTL_DSE_HIGH) |
| 96 | |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 97 | int board_mmc_init(bd_t *bis) |
| 98 | { |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 99 | static const iomux_v3_cfg_t sd1_pads[] = { |
| 100 | NEW_PAD_CTRL(MX53_PAD_SD1_CMD__ESDHC1_CMD, SD_CMD_PAD_CTRL), |
| 101 | NEW_PAD_CTRL(MX53_PAD_SD1_CLK__ESDHC1_CLK, SD_PAD_CTRL), |
| 102 | NEW_PAD_CTRL(MX53_PAD_SD1_DATA0__ESDHC1_DAT0, SD_PAD_CTRL), |
| 103 | NEW_PAD_CTRL(MX53_PAD_SD1_DATA1__ESDHC1_DAT1, SD_PAD_CTRL), |
| 104 | NEW_PAD_CTRL(MX53_PAD_SD1_DATA2__ESDHC1_DAT2, SD_PAD_CTRL), |
| 105 | NEW_PAD_CTRL(MX53_PAD_SD1_DATA3__ESDHC1_DAT3, SD_PAD_CTRL), |
| 106 | MX53_PAD_EIM_DA13__GPIO3_13, |
| 107 | }; |
| 108 | |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 109 | u32 index; |
Fabio Estevam | 14d6e4d | 2014-11-20 16:35:18 -0200 | [diff] [blame] | 110 | int ret; |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 111 | |
Benoît Thébaudeau | c58ff34 | 2012-10-01 08:36:25 +0000 | [diff] [blame] | 112 | esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK); |
| 113 | |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 114 | for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; index++) { |
| 115 | switch (index) { |
| 116 | case 0: |
Benoît Thébaudeau | 821e30f | 2013-05-03 10:32:35 +0000 | [diff] [blame] | 117 | imx_iomux_v3_setup_multiple_pads(sd1_pads, |
| 118 | ARRAY_SIZE(sd1_pads)); |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 119 | break; |
| 120 | |
| 121 | default: |
| 122 | printf("Warning: you configured more ESDHC controller" |
| 123 | "(%d) as supported by the board(1)\n", |
| 124 | CONFIG_SYS_FSL_ESDHC_NUM); |
Fabio Estevam | 14d6e4d | 2014-11-20 16:35:18 -0200 | [diff] [blame] | 125 | return -EINVAL; |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 126 | } |
Fabio Estevam | 14d6e4d | 2014-11-20 16:35:18 -0200 | [diff] [blame] | 127 | ret = fsl_esdhc_initialize(bis, &esdhc_cfg[index]); |
| 128 | if (ret) |
| 129 | return ret; |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 130 | } |
| 131 | |
Fabio Estevam | 14d6e4d | 2014-11-20 16:35:18 -0200 | [diff] [blame] | 132 | return 0; |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 133 | } |
| 134 | #endif |
| 135 | |
| 136 | int board_early_init_f(void) |
| 137 | { |
| 138 | setup_iomux_uart(); |
| 139 | setup_iomux_fec(); |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | int board_init(void) |
| 145 | { |
Fabio Estevam | a7b1dc9 | 2011-05-13 03:15:11 +0000 | [diff] [blame] | 146 | /* address of boot parameters */ |
| 147 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 148 | |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | int checkboard(void) |
| 153 | { |
| 154 | puts("Board: MX53SMD\n"); |
| 155 | |
| 156 | return 0; |
| 157 | } |