Commit af2a4093cb141f9c5ea433c41ab06a528a7792a6
Committed by
Stefano Babic
1 parent
d6d94e7360
Exists in
master
and in
54 other branches
mx25pdk: Add esdhc support
mx25pdk has a SD/MMC slot connected to esdhc1. Add support for it and allow the environment variables to be saved into SD/MMC. Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Showing 2 changed files with 68 additions and 1 deletions Side-by-side Diff
board/freescale/mx25pdk/mx25pdk.c
... | ... | @@ -19,12 +19,24 @@ |
19 | 19 | |
20 | 20 | #include <common.h> |
21 | 21 | #include <asm/io.h> |
22 | +#include <asm/gpio.h> | |
22 | 23 | #include <asm/arch/imx-regs.h> |
23 | 24 | #include <asm/arch/imx25-pinmux.h> |
24 | 25 | #include <asm/arch/sys_proto.h> |
26 | +#include <asm/arch/clock.h> | |
27 | +#include <mmc.h> | |
28 | +#include <fsl_esdhc.h> | |
25 | 29 | |
30 | +#define CARD_DETECT IMX_GPIO_NR(2, 1) | |
31 | + | |
26 | 32 | DECLARE_GLOBAL_DATA_PTR; |
27 | 33 | |
34 | +#ifdef CONFIG_FSL_ESDHC | |
35 | +struct fsl_esdhc_cfg esdhc_cfg[1] = { | |
36 | + {IMX_MMC_SDHC1_BASE}, | |
37 | +}; | |
38 | +#endif | |
39 | + | |
28 | 40 | int dram_init(void) |
29 | 41 | { |
30 | 42 | /* dram_init must store complete ramsize in gd->ram_size */ |
... | ... | @@ -47,6 +59,47 @@ |
47 | 59 | |
48 | 60 | return 0; |
49 | 61 | } |
62 | + | |
63 | +#ifdef CONFIG_FSL_ESDHC | |
64 | +int board_mmc_getcd(struct mmc *mmc) | |
65 | +{ | |
66 | + struct iomuxc_mux_ctl *muxctl; | |
67 | + struct iomuxc_pad_ctl *padctl; | |
68 | + u32 gpio_mux_mode = MX25_PIN_MUX_MODE(5); | |
69 | + | |
70 | + /* | |
71 | + * Set up the Card Detect pin. | |
72 | + * | |
73 | + * SD1_GPIO_CD: gpio2_1 is ALT 5 mode of pin A15 | |
74 | + * | |
75 | + */ | |
76 | + muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE; | |
77 | + padctl = (struct iomuxc_pad_ctl *)IMX_IOPADCTL_BASE; | |
78 | + | |
79 | + writel(gpio_mux_mode, &muxctl->pad_a15); | |
80 | + writel(0x0, &padctl->pad_a15); | |
81 | + | |
82 | + gpio_direction_input(CARD_DETECT); | |
83 | + return !gpio_get_value(CARD_DETECT); | |
84 | +} | |
85 | + | |
86 | +int board_mmc_init(bd_t *bis) | |
87 | +{ | |
88 | + struct iomuxc_mux_ctl *muxctl; | |
89 | + u32 sdhc1_mux_mode = MX25_PIN_MUX_MODE(0) | MX25_PIN_MUX_SION; | |
90 | + | |
91 | + muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE; | |
92 | + writel(sdhc1_mux_mode, &muxctl->pad_sd1_cmd); | |
93 | + writel(sdhc1_mux_mode, &muxctl->pad_sd1_clk); | |
94 | + writel(sdhc1_mux_mode, &muxctl->pad_sd1_data0); | |
95 | + writel(sdhc1_mux_mode, &muxctl->pad_sd1_data1); | |
96 | + writel(sdhc1_mux_mode, &muxctl->pad_sd1_data2); | |
97 | + writel(sdhc1_mux_mode, &muxctl->pad_sd1_data3); | |
98 | + | |
99 | + esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC1_CLK); | |
100 | + return fsl_esdhc_initialize(bis, &esdhc_cfg[0]); | |
101 | +} | |
102 | +#endif | |
50 | 103 | |
51 | 104 | int checkboard(void) |
52 | 105 | { |
include/configs/mx25pdk.h
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | #define CONFIG_MX25 |
23 | 23 | #define CONFIG_SYS_HZ 1000 |
24 | 24 | #define CONFIG_SYS_TEXT_BASE 0x81200000 |
25 | +#define CONFIG_MXC_GPIO | |
25 | 26 | |
26 | 27 | #define CONFIG_DISPLAY_CPUINFO |
27 | 28 | #define CONFIG_DISPLAY_BOARDINFO |
28 | 29 | |
... | ... | @@ -65,9 +66,10 @@ |
65 | 66 | /* No NOR flash present */ |
66 | 67 | #define CONFIG_ENV_OFFSET (6 * 64 * 1024) |
67 | 68 | #define CONFIG_ENV_SIZE (8 * 1024) |
68 | -#define CONFIG_ENV_IS_NOWHERE | |
69 | 69 | |
70 | 70 | #define CONFIG_SYS_NO_FLASH |
71 | +#define CONFIG_ENV_IS_IN_MMC | |
72 | +#define CONFIG_SYS_MMC_ENV_DEV 0 | |
71 | 73 | |
72 | 74 | /* U-Boot general configuration */ |
73 | 75 | #define CONFIG_SYS_PROMPT "MX25PDK U-Boot > " |
... | ... | @@ -85,6 +87,9 @@ |
85 | 87 | /* U-Boot commands */ |
86 | 88 | #include <config_cmd_default.h> |
87 | 89 | #define CONFIG_CMD_CACHE |
90 | +#define CONFIG_CMD_MMC | |
91 | +#define CONFIG_CMD_EXT2 | |
92 | +#define CONFIG_CMD_FAT | |
88 | 93 | |
89 | 94 | /* Ethernet */ |
90 | 95 | #define CONFIG_FEC_MXC |
... | ... | @@ -92,6 +97,15 @@ |
92 | 97 | #define CONFIG_MII |
93 | 98 | #define CONFIG_CMD_NET |
94 | 99 | #define CONFIG_ENV_OVERWRITE |
100 | + | |
101 | +/* ESDHC driver */ | |
102 | +#define CONFIG_MMC | |
103 | +#define CONFIG_GENERIC_MMC | |
104 | +#define CONFIG_FSL_ESDHC | |
105 | +#define CONFIG_SYS_FSL_ESDHC_ADDR 0 | |
106 | +#define CONFIG_SYS_FSL_ESDHC_NUM 1 | |
107 | + | |
108 | +#define CONFIG_DOS_PARTITION | |
95 | 109 | |
96 | 110 | #define CONFIG_BOOTDELAY 3 |
97 | 111 |