Added custom environment variables and rules to locate and load
files (from uSD card) in order to boot Linux.

Signed-off-by: Purna Chandra Mandal <[email protected]>
---

Changes in v2: None

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

diff --git a/arch/mips/dts/pic32mzda.dtsi b/arch/mips/dts/pic32mzda.dtsi
index f518ba8..bdddb93 100644
--- a/arch/mips/dts/pic32mzda.dtsi
+++ b/arch/mips/dts/pic32mzda.dtsi
@@ -61,4 +61,17 @@
                      <0x1f801500 0x200>; /* out */
                status = "disabled";
        };
+
+       sdhci: sdhci@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";
+               bus-width = <4>;
+               cap-sd-highspeed;
+               clock-freq-min-max = <25000000>,<25000000>;
+               clock-irq-pins = <1>,<1>;
+               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 13760e6..d11eddd 100644
--- a/configs/pic32mzdask_defconfig
+++ b/configs/pic32mzdask_defconfig
@@ -19,3 +19,5 @@ CONFIG_CLK=y
 CONFIG_PINCTRL=y
 # CONFIG_PINCTRL_FULL is not set
 CONFIG_PIC32_PINCTRL=y
+CONFIG_DM_MMC=y
+CONFIG_PIC32_SDHCI=y
\ No newline at end of file
diff --git a/include/configs/pic32mzdask.h b/include/configs/pic32mzdask.h
index 3624107..52e53e9 100644
--- a/include/configs/pic32mzdask.h
+++ b/include/configs/pic32mzdask.h
@@ -84,6 +84,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
  */
@@ -97,4 +124,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


_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to