[U-Boot] [PATCH v3 11/14] board: add SDHCI support for PIC32MZDASK board.

Purna Chandra Mandal purna.mandal at microchip.com
Tue Jan 12 11:18:26 CET 2016


Enable MMC, SDHCI, FAT FS, EXT4 FS support for PIC32MZ[DA] StarterKit.
Also add custom scripts, rules to boot Linux from microSD card.

Signed-off-by: Purna Chandra Mandal <purna.mandal at microchip.com>

---

Changes in v3: None
Changes in v2:
- drop shared bus (shared pin selection) configuration.

 arch/mips/dts/pic32mzda.dtsi   | 11 ++++++++
 arch/mips/dts/pic32mzda_sk.dts |  7 +++++
 configs/pic32mzdask_defconfig  |  6 +++--
 include/configs/pic32mzdask.h  | 61 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/arch/mips/dts/pic32mzda.dtsi b/arch/mips/dts/pic32mzda.dtsi
index fe8b13a..3d62a17 100644
--- a/arch/mips/dts/pic32mzda.dtsi
+++ b/arch/mips/dts/pic32mzda.dtsi
@@ -150,4 +150,15 @@
 			#gpio-cells = <2>;
 		};
 	};
+
+	sdhci: sdhci at 1f8ec000 {
+		compatible = "microchip,pic32mzda-sdhci";
+		reg = <0x1f8ec000 0x100>;
+		interrupts = <191 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clock REF4CLK>, <&clock PB5CLK>;
+		clock-names = "base_clk", "sys_clk";
+		clock-freq-min-max = <25000000>,<25000000>;
+		bus-width = <4>;
+		status = "disabled";
+	};
 };
diff --git a/arch/mips/dts/pic32mzda_sk.dts b/arch/mips/dts/pic32mzda_sk.dts
index 99e7f64..f886a0f 100644
--- a/arch/mips/dts/pic32mzda_sk.dts
+++ b/arch/mips/dts/pic32mzda_sk.dts
@@ -23,6 +23,9 @@
 };
 
 &clock {
+	microchip,refo2-frequency = <50000000>;
+	microchip,refo4-frequency = <25000000>;
+	microchip,refo5-frequency = <40000000>;
 	status = "okay";
 	u-boot,dm-pre-reloc;
 };
@@ -36,3 +39,7 @@
 	status = "okay";
 	u-boot,dm-pre-reloc;
 };
+
+&sdhci {
+	status = "okay";
+};
\ No newline at end of file
diff --git a/configs/pic32mzdask_defconfig b/configs/pic32mzdask_defconfig
index 3483eb0..6981cf7 100644
--- a/configs/pic32mzdask_defconfig
+++ b/configs/pic32mzdask_defconfig
@@ -122,7 +122,7 @@ CONFIG_CMD_XIMG=y
 #
 # Environment commands
 #
-# CONFIG_CMD_EXPORTENV is not set
+CONFIG_CMD_EXPORTENV=y
 CONFIG_CMD_IMPORTENV=y
 CONFIG_CMD_EDITENV=y
 # CONFIG_CMD_SAVEENV is not set
@@ -284,7 +284,9 @@ CONFIG_PIC32_GPIO=y
 #
 # MMC Host controller Support
 #
-# CONFIG_DM_MMC is not set
+CONFIG_DM_MMC=y
+# CONFIG_ROCKCHIP_DWMMC is not set
+CONFIG_PIC32_SDHCI=y
 
 #
 # MTD Support
diff --git a/include/configs/pic32mzdask.h b/include/configs/pic32mzdask.h
index 6552fa2..224b21c 100644
--- a/include/configs/pic32mzdask.h
+++ b/include/configs/pic32mzdask.h
@@ -78,6 +78,33 @@
  */
 #define CONFIG_OF_LIBFDT	1
 
+/*-----------------------------------------------------------------------
+ * SDHC Configuration
+ */
+#define CONFIG_SDHCI
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_CMD_MMC
+
+/*-----------------------------------------------------------------------
+ * File System Configuration
+ */
+/* FAT FS */
+#define CONFIG_DOS_PARTITION
+#define CONFIG_PARTITION_UUIDS
+#define CONFIG_SUPPORT_VFAT
+#define CONFIG_FS_FAT
+#define CONFIG_FAT_WRITE
+#define CONFIG_CMD_FS_GENERIC
+#define CONFIG_CMD_PART
+#define CONFIG_CMD_FAT
+
+/* EXT4 FS */
+#define CONFIG_FS_EXT4
+#define CONFIG_CMD_EXT2
+#define CONFIG_CMD_EXT4
+#define CONFIG_CMD_EXT4_WRITE
+
 /* -------------------------------------------------
  * Environment
  */
@@ -91,4 +118,38 @@
 #define CONFIG_BOOTDELAY	5 /* autoboot after X seconds     */
 #undef	CONFIG_BOOTARGS
 
+#define CONFIG_EXTRA_ENV_SETTINGS				\
+	"loadaddr="__stringify(CONFIG_SYS_LOAD_ADDR)"\0"	\
+	"uenvfile=uEnv.txt\0"					\
+	"uenvaddr="__stringify(CONFIG_SYS_ENV_ADDR)"\0"		\
+	"scriptfile=boot.scr\0"					\
+	"ubootfile=u-boot.bin\0"				\
+	"importbootenv= "					\
+		"env import -t -r ${uenvaddr} ${filesize};\0"	\
+								\
+	"mmcloadenv=fatload mmc 0 ${uenvaddr} ${uenvfile}\0"	\
+	"mmcloadscr=fatload mmc 0 ${uenvaddr} ${scriptfile}\0"	\
+	"mmcloadub=fatload mmc 0 ${loadaddr} ${ubootfile}\0"	\
+								\
+	"loadbootenv=run mmcloadenv\0"				\
+	"loadbootscr=run mmcloadscr\0"				\
+	"bootcmd_root= "					\
+		"if run loadbootenv; then "			\
+			"echo Loaded environment ${uenvfile}; "	\
+			"run importbootenv; "			\
+		"fi; "						\
+		"if test -n \"${bootcmd_uenv}\" ; then "	\
+			"echo Running bootcmd_uenv ...; "	\
+			"run bootcmd_uenv; "			\
+		"fi; "						\
+		"if run loadbootscr; then "			\
+			"echo Jumping to ${scriptfile}; "	\
+			"source ${uenvaddr}; "			\
+		"fi; "						\
+		"echo Custom environment or script not found. "	\
+			"Aborting auto booting...; \0"		\
+	""
+
+#define CONFIG_BOOTCOMMAND		"run bootcmd_root"
+
 #endif	/* __PIC32MZDASK_CONFIG_H */
-- 
1.8.3.1



More information about the U-Boot mailing list