This adds ethernet, TFTP support for PIC32MZ[DA] Starter Kit. Also
custom environment variables/scripts are added to help boot from network.

Signed-off-by: Purna Chandra Mandal <purna.man...@microchip.com>

---

Changes in v3: None
Changes in v2:
- replace unbounded loop with wait_for_bit()
- replace register access as readl/writel(base + offset)
- translate (dts provided) physical address to MIPS kseg1 address before use

 arch/mips/dts/pic32mzda.dtsi   | 10 ++++++++++
 arch/mips/dts/pic32mzda_sk.dts | 10 ++++++++++
 configs/pic32mzdask_defconfig  | 26 +++++++++++++++++---------
 include/configs/pic32mzdask.h  | 27 +++++++++++++++++++++++++--
 4 files changed, 62 insertions(+), 11 deletions(-)

diff --git a/arch/mips/dts/pic32mzda.dtsi b/arch/mips/dts/pic32mzda.dtsi
index 3d62a17..57612bc 100644
--- a/arch/mips/dts/pic32mzda.dtsi
+++ b/arch/mips/dts/pic32mzda.dtsi
@@ -161,4 +161,14 @@
                bus-width = <4>;
                status = "disabled";
        };
+
+       ethernet: ethernet@1f882000 {
+               compatible = "microchip,pic32mzda-eth";
+               reg = <0x1f882000 0x1000>;
+               interrupts = <153 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&clock PB5CLK>;
+               status = "disabled";
+               #address-cells = <1>;
+               #size-cells = <0>;
+       };
 };
diff --git a/arch/mips/dts/pic32mzda_sk.dts b/arch/mips/dts/pic32mzda_sk.dts
index f886a0f..e5ce0bd 100644
--- a/arch/mips/dts/pic32mzda_sk.dts
+++ b/arch/mips/dts/pic32mzda_sk.dts
@@ -42,4 +42,14 @@
 
 &sdhci {
        status = "okay";
+};
+
+&ethernet {
+       reset-gpios = <&gpioJ 15 0>;
+       status = "okay";
+       phy-mode = "rmii";
+       phy-handle = <&ethernet_phy>;
+       ethernet_phy: lan8740_phy@0 {
+               reg = <0>;
+       };
 };
\ No newline at end of file
diff --git a/configs/pic32mzdask_defconfig b/configs/pic32mzdask_defconfig
index 6981cf7..5e78e14 100644
--- a/configs/pic32mzdask_defconfig
+++ b/configs/pic32mzdask_defconfig
@@ -165,13 +165,13 @@ CONFIG_CMD_SETEXPR=y
 #
 # Network commands
 #
-# CONFIG_CMD_NET is not set
+CONFIG_CMD_NET=y
 # CONFIG_CMD_TFTPPUT is not set
 # CONFIG_CMD_TFTPSRV is not set
-# CONFIG_CMD_RARP is not set
-# CONFIG_CMD_DHCP is not set
-# CONFIG_CMD_NFS is not set
-# CONFIG_CMD_PING is not set
+CONFIG_CMD_RARP=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_NFS=y
+CONFIG_CMD_PING=y
 # CONFIG_CMD_CDP is not set
 # CONFIG_CMD_SNTP is not set
 # CONFIG_CMD_DNS is not set
@@ -208,7 +208,10 @@ CONFIG_SUPPORT_OF_CONTROL=y
 CONFIG_OF_CONTROL=y
 # CONFIG_OF_SEPARATE is not set
 CONFIG_OF_EMBED=y
-# CONFIG_NET is not set
+CONFIG_NET=y
+CONFIG_NET_RANDOM_ETHADDR=y
+# CONFIG_NETCONSOLE is not set
+CONFIG_NET_TFTP_VARS=y
 
 #
 # Device Drivers
@@ -308,8 +311,13 @@ CONFIG_PIC32_SDHCI=y
 # SPI Flash Support
 #
 # CONFIG_SPI_FLASH is not set
-# CONFIG_DM_ETH is not set
-# CONFIG_PHYLIB is not set
+CONFIG_DM_ETH=y
+CONFIG_PHYLIB=y
+CONFIG_NETDEVICES=y
+# CONFIG_ALTERA_TSE is not set
+# CONFIG_E1000 is not set
+# CONFIG_ETH_DESIGNWARE is not set
+CONFIG_PIC32_ETH=y
 
 #
 # PCI
@@ -398,7 +406,7 @@ CONFIG_SYS_HZ=1000
 CONFIG_SYS_VSNPRINTF=y
 CONFIG_USE_TINY_PRINTF=y
 CONFIG_REGEX=y
-# CONFIG_LIB_RAND is not set
+CONFIG_LIB_RAND=y
 CONFIG_CMD_DHRYSTONE=y
 # CONFIG_RSA is not set
 # CONFIG_TPM is not set
diff --git a/include/configs/pic32mzdask.h b/include/configs/pic32mzdask.h
index 224b21c..7339f0f 100644
--- a/include/configs/pic32mzdask.h
+++ b/include/configs/pic32mzdask.h
@@ -73,6 +73,25 @@
                (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
 #define CONFIG_CMDLINE_EDITING         1
 
+/*-----------------------------------------------------------------------
+ * Networking Configuration
+ */
+#define CONFIG_MII
+#define CONFIG_PHY_SMSC
+#define CONFIG_SYS_RX_ETH_BUFFER       8
+#define CONFIG_NET_RETRY_COUNT         20
+#define CONFIG_ARP_TIMEOUT             500 /* millisec */
+
+#define CONFIG_CMD_MII
+
+/*
+ * BOOTP options
+ */
+#define CONFIG_BOOTP_BOOTFILESIZE
+#define CONFIG_BOOTP_BOOTPATH
+#define CONFIG_BOOTP_GATEWAY
+#define CONFIG_BOOTP_HOSTNAME
+
 /*
  * Handover flattened device tree (dtb file) to Linux kernel
  */
@@ -127,12 +146,16 @@
        "importbootenv= "                                       \
                "env import -t -r ${uenvaddr} ${filesize};\0"   \
                                                                \
+       "tftploadenv=tftp ${uenvaddr} ${uenvfile} \0"           \
+       "tftploadscr=tftp ${uenvaddr} ${scriptfile} \0"         \
+       "tftploadub=tftp ${loadaddr} ${ubootfile} \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"                          \
+       "loadbootenv=run mmcloadenv || run tftploadenv\0"       \
+       "loadbootscr=run mmcloadscr || run tftploadscr\0"       \
        "bootcmd_root= "                                        \
                "if run loadbootenv; then "                     \
                        "echo Loaded environment ${uenvfile}; " \
-- 
1.8.3.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to