blob: 1a1a03955bc75655f11d85419ec001671d6a93fe [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Fabio Estevama7b1dc92011-05-13 03:15:11 +00002/*
3 * (C) Copyright 2011 Freescale Semiconductor, Inc.
Fabio Estevama7b1dc92011-05-13 03:15:11 +00004 */
5
6#include <common.h>
7#include <asm/io.h>
8#include <asm/arch/imx-regs.h>
Fabio Estevama7b1dc92011-05-13 03:15:11 +00009#include <asm/arch/sys_proto.h>
10#include <asm/arch/crm_regs.h>
Benoît Thébaudeauc58ff342012-10-01 08:36:25 +000011#include <asm/arch/clock.h>
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000012#include <asm/arch/iomux-mx53.h>
Masahiro Yamada56a931c2016-09-21 11:28:55 +090013#include <linux/errno.h>
Fabio Estevama7b1dc92011-05-13 03:15:11 +000014#include <netdev.h>
15#include <mmc.h>
16#include <fsl_esdhc.h>
Stefano Babic7afafd02011-08-21 10:56:57 +020017#include <asm/gpio.h>
Fabio Estevama7b1dc92011-05-13 03:15:11 +000018
19DECLARE_GLOBAL_DATA_PTR;
20
Fabio Estevama7b1dc92011-05-13 03:15:11 +000021int dram_init(void)
22{
23 u32 size1, size2;
24
Albert ARIBAUDa9606732011-07-03 05:55:33 +000025 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 Estevama7b1dc92011-05-13 03:15:11 +000027
28 gd->ram_size = size1 + size2;
29
30 return 0;
31}
Simon Glass2f949c32017-03-31 08:40:32 -060032int dram_init_banksize(void)
Fabio Estevama7b1dc92011-05-13 03:15:11 +000033{
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 Glass2f949c32017-03-31 08:40:32 -060039
40 return 0;
Fabio Estevama7b1dc92011-05-13 03:15:11 +000041}
42
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000043#define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \
44 PAD_CTL_PUS_100K_UP | PAD_CTL_ODE)
45
Fabio Estevama7b1dc92011-05-13 03:15:11 +000046static void setup_iomux_uart(void)
47{
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000048 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 Estevama7b1dc92011-05-13 03:15:11 +000052
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000053 imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
Fabio Estevama7b1dc92011-05-13 03:15:11 +000054}
55
56static void setup_iomux_fec(void)
57{
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000058 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 Estevama7b1dc92011-05-13 03:15:11 +000076
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000077 imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
Fabio Estevama7b1dc92011-05-13 03:15:11 +000078}
79
80#ifdef CONFIG_FSL_ESDHC
81struct fsl_esdhc_cfg esdhc_cfg[1] = {
Benoît Thébaudeauc08d11c2012-08-13 07:28:16 +000082 {MMC_SDHC1_BASE_ADDR},
Fabio Estevama7b1dc92011-05-13 03:15:11 +000083};
84
Thierry Redingd7aebf42012-01-02 01:15:36 +000085int board_mmc_getcd(struct mmc *mmc)
Fabio Estevama7b1dc92011-05-13 03:15:11 +000086{
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000087 imx_iomux_v3_setup_pad(MX53_PAD_EIM_DA13__GPIO3_13);
Ashok Kumar Reddy7d04bd72012-08-28 07:39:38 +053088 gpio_direction_input(IMX_GPIO_NR(3, 13));
89 return !gpio_get_value(IMX_GPIO_NR(3, 13));
Fabio Estevama7b1dc92011-05-13 03:15:11 +000090}
91
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000092#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 Estevama7b1dc92011-05-13 03:15:11 +000097int board_mmc_init(bd_t *bis)
98{
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +000099 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 Estevama7b1dc92011-05-13 03:15:11 +0000109 u32 index;
Fabio Estevam14d6e4d2014-11-20 16:35:18 -0200110 int ret;
Fabio Estevama7b1dc92011-05-13 03:15:11 +0000111
Benoît Thébaudeauc58ff342012-10-01 08:36:25 +0000112 esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
113
Fabio Estevama7b1dc92011-05-13 03:15:11 +0000114 for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; index++) {
115 switch (index) {
116 case 0:
Benoît Thébaudeau821e30f2013-05-03 10:32:35 +0000117 imx_iomux_v3_setup_multiple_pads(sd1_pads,
118 ARRAY_SIZE(sd1_pads));
Fabio Estevama7b1dc92011-05-13 03:15:11 +0000119 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 Estevam14d6e4d2014-11-20 16:35:18 -0200125 return -EINVAL;
Fabio Estevama7b1dc92011-05-13 03:15:11 +0000126 }
Fabio Estevam14d6e4d2014-11-20 16:35:18 -0200127 ret = fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
128 if (ret)
129 return ret;
Fabio Estevama7b1dc92011-05-13 03:15:11 +0000130 }
131
Fabio Estevam14d6e4d2014-11-20 16:35:18 -0200132 return 0;
Fabio Estevama7b1dc92011-05-13 03:15:11 +0000133}
134#endif
135
136int board_early_init_f(void)
137{
138 setup_iomux_uart();
139 setup_iomux_fec();
140
141 return 0;
142}
143
144int board_init(void)
145{
Fabio Estevama7b1dc92011-05-13 03:15:11 +0000146 /* address of boot parameters */
147 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
148
149 return 0;
150}
151
152int checkboard(void)
153{
154 puts("Board: MX53SMD\n");
155
156 return 0;
157}