summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSammy <r62914@freescale.com>2009-07-13 15:05:16 +0800
committerFred Fan <r01011@freescale.com>2009-09-10 17:03:33 +0800
commitabf0610e5250ed69cc542e19f19c8a6812f4914e (patch)
treea6b357c0dd2650e89c724448cde52b95944391cc
parent98ab00fc5434683e5e281156e24d6a52fa17a417 (diff)
downloadu-boot-imx-abf0610e5250ed69cc542e19f19c8a6812f4914e.zip
u-boot-imx-abf0610e5250ed69cc542e19f19c8a6812f4914e.tar.gz
u-boot-imx-abf0610e5250ed69cc542e19f19c8a6812f4914e.tar.bz2
ENGR00114178 Support MMC/SD boot and enable dhcp in uboot on MX25
1. Support MMC/SD boot in uboot, however, it is disabled default and user needs to enable manually by changing mx25_3stack.h; 2. Enable dhcp for network. Signed-off-by: Sammy He <r62914@freescale.com>
-rw-r--r--board/freescale/mx25_3stack/mx25_3stack.c85
-rw-r--r--include/asm-arm/arch-mx25/mmc.h16
-rw-r--r--include/asm-arm/arch-mx25/sdhc.h218
-rw-r--r--include/configs/mx25_3stack.h38
4 files changed, 355 insertions, 2 deletions
diff --git a/board/freescale/mx25_3stack/mx25_3stack.c b/board/freescale/mx25_3stack/mx25_3stack.c
index 22559b6..b33eaa1 100644
--- a/board/freescale/mx25_3stack/mx25_3stack.c
+++ b/board/freescale/mx25_3stack/mx25_3stack.c
@@ -35,6 +35,7 @@
DECLARE_GLOBAL_DATA_PTR;
static u32 system_rev;
+volatile u32 *esdhc_base_pointer;
u32 get_board_rev(void)
{
@@ -53,6 +54,11 @@ static inline void setup_soc_rev(void)
system_rev = 0x25000 + (reg & 0xFF);
}
+inline int is_soc_rev(int rev)
+{
+ return (system_rev & 0xFF) - rev;
+}
+
int dram_init(void)
{
gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
@@ -61,6 +67,85 @@ int dram_init(void)
return 0;
}
+#ifdef CONFIG_FSL_MMC
+
+int sdhc_init(void)
+{
+ u32 interface_esdhc = 0, val = 0;
+
+ interface_esdhc = (readl(CCM_RCSR) & (0x00300000)) >> 20;
+
+ switch (interface_esdhc) {
+ case 0:
+ esdhc_base_pointer = (volatile u32 *)MMC_SDHC1_BASE;
+ /* Pins */
+ writel(0x10, IOMUXC_BASE + 0x190); /* SD1_CMD */
+ writel(0x10, IOMUXC_BASE + 0x194); /* SD1_CLK */
+ writel(0x00, IOMUXC_BASE + 0x198); /* SD1_DATA0 */
+ writel(0x00, IOMUXC_BASE + 0x19c); /* SD1_DATA1 */
+ writel(0x00, IOMUXC_BASE + 0x1a0); /* SD1_DATA2 */
+ writel(0x00, IOMUXC_BASE + 0x1a4); /* SD1_DATA3 */
+ writel(0x06, IOMUXC_BASE + 0x094); /* D12 (SD1_DATA4) */
+ writel(0x06, IOMUXC_BASE + 0x090); /* D13 (SD1_DATA5) */
+ writel(0x06, IOMUXC_BASE + 0x08c); /* D14 (SD1_DATA6) */
+ writel(0x06, IOMUXC_BASE + 0x088); /* D15 (SD1_DATA7) */
+ writel(0x05, IOMUXC_BASE + 0x010); /* A14 (SD1_WP) */
+ writel(0x05, IOMUXC_BASE + 0x014); /* A15 (SD1_DET) */
+
+ /* Pads */
+ writel(0xD1, IOMUXC_BASE + 0x388); /* SD1_CMD */
+ writel(0xD1, IOMUXC_BASE + 0x38c); /* SD1_CLK */
+ writel(0xD1, IOMUXC_BASE + 0x390); /* SD1_DATA0 */
+ writel(0xD1, IOMUXC_BASE + 0x394); /* SD1_DATA1 */
+ writel(0xD1, IOMUXC_BASE + 0x398); /* SD1_DATA2 */
+ writel(0xD1, IOMUXC_BASE + 0x39c); /* SD1_DATA3 */
+ writel(0xD1, IOMUXC_BASE + 0x28c); /* D12 (SD1_DATA4) */
+ writel(0xD1, IOMUXC_BASE + 0x288); /* D13 (SD1_DATA5) */
+ writel(0xD1, IOMUXC_BASE + 0x284); /* D14 (SD1_DATA6) */
+ writel(0xD1, IOMUXC_BASE + 0x280); /* D15 (SD1_DATA7) */
+ writel(0xD1, IOMUXC_BASE + 0x230); /* A14 (SD1_WP) */
+ writel(0xD1, IOMUXC_BASE + 0x234); /* A15 (SD1_DET) */
+
+ /*
+ * Set write protect and card detect gpio as inputs
+ * A14 (SD1_WP) and A15 (SD1_DET)
+ */
+ val = ~(3 << 0) & readl(GPIO1_BASE + GPIO_GDIR);
+ writel(val, GPIO1_BASE + GPIO_GDIR);
+ break;
+ case 1:
+ esdhc_base_pointer = (volatile u32 *)MMC_SDHC2_BASE;
+ /* Pins */
+ writel(0x16, IOMUXC_BASE + 0x0e8); /* LD8 (SD1_CMD) */
+ writel(0x16, IOMUXC_BASE + 0x0ec); /* LD9 (SD1_CLK) */
+ writel(0x06, IOMUXC_BASE + 0x0f0); /* LD10 (SD1_DATA0) */
+ writel(0x06, IOMUXC_BASE + 0x0f4); /* LD11 (SD1_DATA1) */
+ writel(0x06, IOMUXC_BASE + 0x0f8); /* LD12 (SD1_DATA2) */
+ writel(0x06, IOMUXC_BASE + 0x0fc); /* LD13 (SD1_DATA3) */
+ writel(0x02, IOMUXC_BASE + 0x120); /* CSI_D2 (SD1_DATA4) */
+ writel(0x02, IOMUXC_BASE + 0x124); /* CSI_D3 (SD1_DATA5) */
+ writel(0x02, IOMUXC_BASE + 0x128); /* CSI_D4 (SD1_DATA6) */
+ writel(0x02, IOMUXC_BASE + 0x12c); /* CSI_D5 (SD1_DATA7) */
+
+ /* Pads */
+ writel(0xD1, IOMUXC_BASE + 0x2e0); /* LD8 (SD1_CMD) */
+ writel(0xD1, IOMUXC_BASE + 0x2e4); /* LD9 (SD1_CLK) */
+ writel(0xD1, IOMUXC_BASE + 0x2e8); /* LD10 (SD1_DATA0) */
+ writel(0xD1, IOMUXC_BASE + 0x2ec); /* LD11 (SD1_DATA1) */
+ writel(0xD1, IOMUXC_BASE + 0x2f0); /* LD12 (SD1_DATA2) */
+ writel(0xD1, IOMUXC_BASE + 0x2f4); /* LD13 (SD1_DATA3) */
+ writel(0xD1, IOMUXC_BASE + 0x318); /* CSI_D2 (SD1_DATA4) */
+ writel(0xD1, IOMUXC_BASE + 0x31c); /* CSI_D3 (SD1_DATA5) */
+ writel(0xD1, IOMUXC_BASE + 0x320); /* CSI_D4 (SD1_DATA6) */
+ writel(0xD1, IOMUXC_BASE + 0x324); /* CSI_D5 (SD1_DATA7) */
+ break;
+ default:
+ break;
+ }
+ return 0;
+}
+#endif
+
int board_init(void)
{
int pad;
diff --git a/include/asm-arm/arch-mx25/mmc.h b/include/asm-arm/arch-mx25/mmc.h
new file mode 100644
index 0000000..5f12934
--- /dev/null
+++ b/include/asm-arm/arch-mx25/mmc.h
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright 2008-2009 Freescale Semiconductor, Inc.
+ *
+ * linux/drivers/mmc/mmc.h
+ *
+ * Author: Vladimir Shebordaev, Igor Oblakov
+ * Copyright: MontaVista Software Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef __MMC_MX25_3STACK_H__
+#define __MMC_MX25_3STACK_H__
+
+#endif /* __MMC_MX51_3STACK_H__ */
diff --git a/include/asm-arm/arch-mx25/sdhc.h b/include/asm-arm/arch-mx25/sdhc.h
new file mode 100644
index 0000000..5514ad4
--- /dev/null
+++ b/include/asm-arm/arch-mx25/sdhc.h
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2008-2009 Freescale Semiconductor, Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef SDHC_H
+#define SDHC_H
+
+#include <linux/types.h>
+
+#define ESDHC_SOFTWARE_RESET_DATA ((u32)0x04000000)
+#define ESDHC_SOFTWARE_RESET_CMD ((u32)0x02000000)
+#define ESDHC_SOFTWARE_RESET ((u32)0x01000000)
+#define ESDHC_CMD_INHIBIT 0x00000003
+#define ESDHC_SYSCTL_INITA ((u32)0x08000000)
+#define ESDHC_LITTLE_ENDIAN_MODE ((u32)0x00000020)
+#define ESDHC_HW_BIG_ENDIAN_MODE ((u32)0x00000010)
+#define ESDHC_BIG_ENDIAN_MODE ((u32)0x00000000)
+#define ESDHC_ONE_BIT_SUPPORT ((u32)0x00000000)
+#define ESDHC_FOUR_BIT_SUPPORT ((u32)0x00000002)
+#define ESDHC_EIGHT_BIT_SUPPORT ((u32)0x00000004)
+#define ESDHC_CLOCK_ENABLE 0x00000007
+#define ESDHC_FREQ_MASK 0xffff0007
+#define ESDHC_SYSCTL_FREQ_MASK ((u32)0x000FFFF0)
+#define ESDHC_SYSCTL_IDENT_FREQ_TO1 ((u32)0x0000800e)
+#define ESDHC_SYSCTL_OPERT_FREQ_TO1 ((u32)0x00000200)
+#define ESDHC_SYSCTL_IDENT_FREQ_TO2 ((u32)0x00002040)
+#define ESDHC_SYSCTL_OPERT_FREQ_TO2 ((u32)0x00000050)
+#define ESDHC_INTERRUPT_ENABLE ((u32)0x007f0133)
+#define ESDHC_CLEAR_INTERRUPT ((u32)0x117f01ff)
+#define ESDHC_SYSCTL_DTOCV_VAL ((u32)0x000E0000)
+#define ESDHC_IRQSTATEN_DTOESEN ((u32)0x00100000)
+#define ESDHC_ENDIAN_MODE_MASK ((u32)0x00000030)
+#define ESDHC_SYSCTRL_RSTC ((u32)0x02000000)
+#define ESDHC_SYSCTRL_RSTD ((u32)0x04000000)
+#define ESDHC_CONFIG_BLOCK 0x00010200
+#define ESDHC_OPER_TIMEOUT (96 * 100)
+#define ESDHC_ACMD41_TIMEOUT (32000)
+#define ESDHC_CMD1_TIMEOUT (32000)
+#define ESDHC_BLOCK_SHIFT (16)
+#define ESDHC_CARD_INIT_TIMEOUT (64)
+
+#define ESDHC_SYSCTL_SDCLKEN_MASK ((u32)0x00000008)
+#define ESDHC_PRSSTAT_SDSTB_BIT ((u32)0x00000008)
+#define ESDHC_SYSCTL_INPUT_CLOCK_MASK ((u32)0x00000007)
+
+#define ESDHC_BUS_WIDTH_MASK ((u32)0x00000006)
+#define ESDHC_DATA_TRANSFER_SHIFT (4)
+#define ESDHC_RESPONSE_FORMAT_SHIFT (16)
+#define ESDHC_DATA_PRESENT_SHIFT (21)
+#define ESDHC_CRC_CHECK_SHIFT (19)
+#define ESDHC_CMD_INDEX_CHECK_SHIFT (20)
+#define ESDHC_CMD_INDEX_SHIFT (24)
+#define ESDHC_BLOCK_COUNT_ENABLE_SHIFT (1)
+#define ESDHC_MULTI_SINGLE_BLOCK_SELECT_SHIFT (5)
+#define BLK_LEN (512)
+#define ESDHC_READ_WATER_MARK_LEVEL_BL_4 ((u32)0x00000001)
+#define ESDHC_READ_WATER_MARK_LEVEL_BL_8 ((u32)0x00000002)
+#define ESDHC_READ_WATER_MARK_LEVEL_BL_16 ((u32)0x00000004)
+#define ESDHC_READ_WATER_MARK_LEVEL_BL_64 ((u32)0x00000010)
+#define ESDHC_READ_WATER_MARK_LEVEL_BL_512 ((u32)0x00000080)
+
+#define ESDHC_WRITE_WATER_MARK_LEVEL_BL_4 ((u32)0x00010000)
+#define ESDHC_WRITE_WATER_MARK_LEVEL_BL_8 ((u32)0x00020000)
+#define ESDHC_WRITE_WATER_MARK_LEVEL_BL_16 ((u32)0x00040000)
+#define ESDHC_WRITE_WATER_MARK_LEVEL_BL_64 ((u32)0x00100000)
+#define ESDHC_WRITE_WATER_MARK_LEVEL_BL_512 ((u32)0x00800000)
+
+#define WRITE_READ_WATER_MARK_LEVEL 0x00800080
+
+/* Present State register bit masks */
+#define ESDHC_PRESENT_STATE_CIHB ((u32)0x00000001)
+#define ESDHC_PRESENT_STATE_CDIHB ((u32)0x00000002)
+#define ONE (1)
+#define ESDHC_FIFO_SIZE (128)
+
+#define ESDHC_STATUS_END_CMD_RESP_MSK ((u32)0x00000001)
+#define ESDHC_STATUS_END_CMD_RESP_TIME_MSK ((u32)0x000F0001)
+#define ESDHC_STATUS_TIME_OUT_RESP_MSK ((u32)0x00010000)
+#define ESDHC_STATUS_RESP_CRC_ERR_MSK ((u32)0x00020000)
+#define ESDHC_STATUS_RESP_CMD_INDEX_ERR_MSK ((u32)0x00080000)
+#define ESDHC_STATUS_BUF_READ_RDY_MSK ((u32)0x00000020)
+#define ESDHC_STATUS_BUF_WRITE_RDY_MSK ((u32)0x00000010)
+#define ESDHC_STATUS_TRANSFER_COMPLETE_MSK ((u32)0x00000002)
+#define ESDHC_STATUS_DATA_RW_MSK ((u32)0x00700002)
+#define ESDHC_STATUS_TRANSFER_COMPLETE_MSK ((u32)0x00000002)
+#define ESDHC_STATUS_TIME_OUT_READ_MASK ((u32)0x00100000)
+#define ESDHC_STATUS_READ_CRC_ERR_MSK ((u32)0x00200000)
+#define ESDHC_STATUS_RESP_CMD_END_BIT_ERR_MSK ((u32)0x00040000)
+#define ESDHC_STATUS_RW_DATA_END_BIT_ERR_MSK ((u32)0x00400000)
+
+#define ESDHC_STATUS_TIME_OUT_READ (3200)
+#define ESDHC_READ_DATA_TIME_OUT (3200)
+#define ESDHC_WRITE_DATA_TIME_OUT (8000)
+
+#define ESDHC_CONFIG_BLOCK_512 ((u32)0x00000200)
+#define ESDHC_CONFIG_BLOCK_64 ((u32)0x00000040)
+#define ESDHC_CONFIG_BLOCK_8 ((u32)0x00000008)
+#define ESDHC_CONFIG_BLOCK_4 ((u32)0x00000004)
+
+#define ESDHC_MAX_BLOCK_COUNT ((u32)0x0000ffff)
+
+typedef enum {
+ ESDHC1,
+ ESDHC2,
+ ESDHC3
+} esdhc_num_t;
+
+typedef enum {
+ WRITE,
+ READ,
+} xfer_type_t;
+
+typedef enum {
+ RESPONSE_NONE,
+ RESPONSE_136,
+ RESPONSE_48,
+ RESPONSE_48_CHECK_BUSY
+} response_format_t;
+
+
+typedef enum {
+ DATA_PRESENT_NONE,
+ DATA_PRESENT
+} data_present_select;
+
+typedef enum {
+ DISABLE,
+ ENABLE
+} crc_check_enable, cmdindex_check_enable, block_count_enable;
+
+typedef enum {
+ SINGLE,
+ MULTIPLE
+} multi_single_block_select;
+
+typedef struct {
+ u32 command;
+ u32 arg;
+ xfer_type_t data_transfer;
+ response_format_t response_format;
+ data_present_select data_present;
+ crc_check_enable crc_check;
+ cmdindex_check_enable cmdindex_check;
+ block_count_enable block_count_enable_check;
+ multi_single_block_select multi_single_block;
+} esdhc_cmd_t;
+
+typedef struct {
+ response_format_t format;
+ u32 cmd_rsp0;
+ u32 cmd_rsp1;
+ u32 cmd_rsp2;
+ u32 cmd_rsp3;
+} esdhc_resp_t;
+
+typedef enum {
+ BIG_ENDIAN,
+ HALF_WORD_BIG_ENDIAN,
+ LITTLE_ENDIAN
+} endian_mode_t;
+
+typedef enum {
+ OPERATING_FREQ = 20000, /* in kHz */
+ IDENTIFICATION_FREQ = 400 /* in kHz */
+} sdhc_freq_t;
+
+enum esdhc_data_status {
+ ESDHC_DATA_ERR = 3,
+ ESDHC_DATA_OK = 4
+};
+
+enum esdhc_int_cntr_val {
+ ESDHC_INT_CNTR_END_CD_RESP = 0x4,
+ ESDHC_INT_CNTR_BUF_WR_RDY = 0x8
+};
+
+enum esdhc_reset_status {
+ ESDHC_WRONG_RESET = 0,
+ ESDHC_CORRECT_RESET = 1
+};
+
+typedef enum {
+ WEAK = 0,
+ STRONG = 1
+} esdhc_pullup_t;
+
+extern u32 interface_reset(void);
+extern void interface_configure_clock(sdhc_freq_t);
+extern void interface_read_response(esdhc_resp_t *);
+extern u32 interface_send_cmd_wait_resp(esdhc_cmd_t *);
+extern u32 interface_data_read(u32 *, u32);
+extern void interface_config_block_info(u32, u32, u32);
+extern u32 interface_data_write(u32 *, u32);
+extern void interface_clear_interrupt(void);
+extern void interface_initialization_active(void);
+extern void esdhc_set_cmd_pullup(esdhc_pullup_t pull_up);
+extern void esdhc_soft_reset(u32 mask);
+extern u32 interface_set_bus_width(u32 bus_width);
+/*================================================================================================*/
+#endif /* ESDHC_H */
diff --git a/include/configs/mx25_3stack.h b/include/configs/mx25_3stack.h
index 05b3500..5e343ea 100644
--- a/include/configs/mx25_3stack.h
+++ b/include/configs/mx25_3stack.h
@@ -97,6 +97,17 @@
/* #define CONFIG_CMD_DATE */
#define CONFIG_CMD_NAND
+/*
+ * MMC Configs
+ * */
+/*
+#define CONFIG_FSL_MMC
+#define CONFIG_MMC
+#define CONFIG_CMD_MMC
+#define CONFIG_DOS_PARTITION
+#define CONFIG_CMD_FAT
+#define CONFIG_MMC_BASE 0x0 */
+
/* Disabled due to compilation errors in cmd_bootm.c (IMLS seems to require
* that CONFIG_NO_FLASH is undefined).
*/
@@ -122,6 +133,8 @@
#define CONFIG_DRIVER_SMC911X_BASE CS5_BASE*/
/*#define CONFIG_HAS_ETH1*/
+#define CONFIG_CMD_NET
+#define CONFIG_CMD_DHCP
#define CONFIG_NET_MULTI 1
#define CONFIG_MXC_FEC
#define CONFIG_MII
@@ -174,12 +187,33 @@
#else
#define PHYS_SDRAM_1_SIZE (64 * 1024 * 1024)
#endif
+
+/* Monitor at beginning of flash */
+#if defined(CONFIG_FSL_SF)
+ #define CONFIG_FSL_ENV_IN_SF
+#elif defined(CONFIG_FSL_MMC)
+ #define CONFIG_FSL_ENV_IN_MMC
+#elif defined(CONFIG_CMD_NAND)
+ #define CONFIG_FSL_ENV_IN_NAND
+#endif
+
/*-----------------------------------------------------------------------
* FLASH and environment organization
*/
+#if defined(CONFIG_FSL_ENV_IN_NAND)
+ #define CONFIG_ENV_IS_IN_NAND 1
+ #define CONFIG_ENV_OFFSET 0x80000
+#elif defined(CONFIG_FSL_ENV_IN_MMC)
+ #define CONFIG_ENV_IS_IN_MMC 1
+ #define CONFIG_ENV_OFFSET 0x100000
+#elif defined(CONFIG_FSL_ENV_IN_SF)
+ #define CONFIG_ENV_IS_IN_SPI_FLASH 1
+ #define CONFIG_ENV_SPI_CS 1
+ #define CONFIG_ENV_OFFSET 0x100000
+#else
+ #define CONFIG_ENV_IS_NOWHERE 1
+#endif
-#define CONFIG_ENV_IS_IN_NAND 1
-#define CONFIG_ENV_OFFSET 0x80000 /* 2nd block */
#define CONFIG_ENV_SECT_SIZE (256 * 1024)
#define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE