public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 7/9] arm: ls1021atwr: Convert to use driver model TSEC driver
Date: Fri, 19 Jul 2019 00:29:59 +0300	[thread overview]
Message-ID: <20190718213001.24815-8-olteanv@gmail.com> (raw)
In-Reply-To: <20190718213001.24815-1-olteanv@gmail.com>

From: Bin Meng <bmeng.cn@gmail.com>

Now that we have added driver model support to the TSEC driver,
convert ls1021atwr board to use it.

This depends on previous DM series for ls1021atwr:
http://patchwork.ozlabs.org/patch/561855/

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>

[Vladimir] Made the following changes:
- Added 'status = "disabled";' for all Ethernet ports in ls1021a.dtsi
- Fixed the confusion between the SGMII/TBI PCS for enet0 and enet1 -
  a mistake ported over from Linux. Each SGMII PCS lies on the private
  MDIO bus of the interface (and the RGMII enet2 has no SGMII PCS).
- Added CONFIG_DM_ETH to all ls1021atwr_* defconfigs
- Completely removed non-DM_ETH support from ls1021atwr
- Changed "compatible" string from "fsl,tsec-mdio" to "fsl,etsec2-mdio"
  and from "fsl,tsec" to "fsl,etsec2" to match Linux
---
Changes from v2:

None.

Changes from v1:

Applied non-reverse #ifdef logic where possible.
Removed the non-DM_ETH code from board/freescale/ls1021atwr/ and
include/configs/ls1021atwr.h.
Aligned compatible strings to Linux.

 arch/arm/cpu/armv7/ls102xa/cpu.c              |  2 +-
 arch/arm/cpu/armv7/ls102xa/fdt.c              | 10 +++++
 arch/arm/dts/ls1021a-twr.dtsi                 | 32 ++++++++++++++++
 arch/arm/dts/ls1021a.dtsi                     | 30 +++++++++++++--
 board/freescale/ls1021atwr/ls1021atwr.c       | 38 -------------------
 configs/ls1021atwr_nor_SECURE_BOOT_defconfig  |  2 +
 configs/ls1021atwr_nor_defconfig              |  2 +
 configs/ls1021atwr_nor_lpuart_defconfig       |  2 +
 configs/ls1021atwr_qspi_defconfig             |  2 +
 ...s1021atwr_sdcard_ifc_SECURE_BOOT_defconfig |  2 +
 configs/ls1021atwr_sdcard_ifc_defconfig       |  2 +
 configs/ls1021atwr_sdcard_qspi_defconfig      |  2 +
 include/configs/ls1021atwr.h                  | 28 +-------------
 13 files changed, 85 insertions(+), 69 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/cpu.c b/arch/arm/cpu/armv7/ls102xa/cpu.c
index ecf9e869855e..9ccfe1042ce5 100644
--- a/arch/arm/cpu/armv7/ls102xa/cpu.c
+++ b/arch/arm/cpu/armv7/ls102xa/cpu.c
@@ -296,7 +296,7 @@ int cpu_mmc_init(bd_t *bis)
 
 int cpu_eth_init(bd_t *bis)
 {
-#ifdef CONFIG_TSEC_ENET
+#if defined(CONFIG_TSEC_ENET) && !defined(CONFIG_DM_ETH)
 	tsec_standard_init(bis);
 #endif
 
diff --git a/arch/arm/cpu/armv7/ls102xa/fdt.c b/arch/arm/cpu/armv7/ls102xa/fdt.c
index 8bf9c42b2260..1aadffff5991 100644
--- a/arch/arm/cpu/armv7/ls102xa/fdt.c
+++ b/arch/arm/cpu/armv7/ls102xa/fdt.c
@@ -16,12 +16,17 @@
 #include <tsec.h>
 #include <asm/arch/immap_ls102xa.h>
 #include <fsl_sec.h>
+#include <dm.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
 void ft_fixup_enet_phy_connect_type(void *fdt)
 {
+#ifdef CONFIG_DM_ETH
+	struct udevice *dev;
+#else
 	struct eth_device *dev;
+#endif
 	struct tsec_private *priv;
 	const char *enet_path, *phy_path;
 	char enet[16];
@@ -29,7 +34,12 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
 	int phy_node;
 	int i = 0;
 	uint32_t ph;
+#ifdef CONFIG_DM_ETH
+	char *name[3] = { "ethernet at 2d10000", "ethernet at 2d50000",
+			  "ethernet at 2d90000" };
+#else
 	char *name[3] = { "eTSEC1", "eTSEC2", "eTSEC3" };
+#endif
 
 	for (; i < ARRAY_SIZE(name); i++) {
 		dev = eth_get_dev_by_name(name[i]);
diff --git a/arch/arm/dts/ls1021a-twr.dtsi b/arch/arm/dts/ls1021a-twr.dtsi
index 5d3275ced913..27c96f95400a 100644
--- a/arch/arm/dts/ls1021a-twr.dtsi
+++ b/arch/arm/dts/ls1021a-twr.dtsi
@@ -51,6 +51,26 @@
 	};
 };
 
+&enet0 {
+	tbi-handle = <&tbi0>;
+	phy-handle = <&sgmii_phy2>;
+	phy-connection-type = "sgmii";
+	status = "okay";
+};
+
+&enet1 {
+	tbi-handle = <&tbi1>;
+	phy-handle = <&sgmii_phy0>;
+	phy-connection-type = "sgmii";
+	status = "okay";
+};
+
+&enet2 {
+	phy-handle = <&rgmii_phy1>;
+	phy-connection-type = "rgmii-id";
+	status = "okay";
+};
+
 &i2c0 {
 	status = "okay";
 };
@@ -84,12 +104,24 @@
 	sgmii_phy0: ethernet-phy at 0 {
 		reg = <0x0>;
 	};
+
 	rgmii_phy1: ethernet-phy at 1 {
 		reg = <0x1>;
 	};
+
 	sgmii_phy2: ethernet-phy at 2 {
 		reg = <0x2>;
 	};
+
+	/* SGMII PCS for enet0 */
+	tbi0: tbi-phy at 1f {
+		reg = <0x1f>;
+		device_type = "tbi-phy";
+	};
+};
+
+&mdio1 {
+	/* SGMII PCS for enet1 */
 	tbi1: tbi-phy at 1f {
 		reg = <0x1f>;
 		device_type = "tbi-phy";
diff --git a/arch/arm/dts/ls1021a.dtsi b/arch/arm/dts/ls1021a.dtsi
index 7fb24ab68787..e419d9c44fcb 100644
--- a/arch/arm/dts/ls1021a.dtsi
+++ b/arch/arm/dts/ls1021a.dtsi
@@ -350,12 +350,36 @@
 				 <&platform_clk 1>;
 		};
 
+		enet0: ethernet at 2d10000 {
+			compatible = "fsl,etsec2";
+			reg = <0x2d10000 0x1000>;
+			status = "disabled";
+		};
+
+		enet1: ethernet at 2d50000 {
+			compatible = "fsl,etsec2";
+			reg = <0x2d50000 0x1000>;
+			status = "disabled";
+		};
+
+		enet2: ethernet at 2d90000 {
+			compatible = "fsl,etsec2";
+			reg = <0x2d90000 0x1000>;
+			status = "disabled";
+		};
+
 		mdio0: mdio at 2d24000 {
-			compatible = "gianfar";
-			device_type = "mdio";
+			compatible = "fsl,etsec2-mdio";
+			reg = <0x2d24000 0x4000>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+		};
+
+		mdio1: mdio at 2d64000 {
+			compatible = "fsl,etsec2-mdio";
+			reg = <0x2d64000 0x4000>;
 			#address-cells = <1>;
 			#size-cells = <0>;
-			reg = <0x2d24000 0x4000>;
 		};
 
 		usb at 8600000 {
diff --git a/board/freescale/ls1021atwr/ls1021atwr.c b/board/freescale/ls1021atwr/ls1021atwr.c
index 01ba1bc96213..fcf2ec97889d 100644
--- a/board/freescale/ls1021atwr/ls1021atwr.c
+++ b/board/freescale/ls1021atwr/ls1021atwr.c
@@ -248,44 +248,6 @@ int board_mmc_init(bd_t *bis)
 
 int board_eth_init(bd_t *bis)
 {
-#ifdef CONFIG_TSEC_ENET
-	struct fsl_pq_mdio_info mdio_info;
-	struct tsec_info_struct tsec_info[4];
-	int num = 0;
-
-#ifdef CONFIG_TSEC1
-	SET_STD_TSEC_INFO(tsec_info[num], 1);
-	if (is_serdes_configured(SGMII_TSEC1)) {
-		puts("eTSEC1 is in sgmii mode.\n");
-		tsec_info[num].flags |= TSEC_SGMII;
-	}
-	num++;
-#endif
-#ifdef CONFIG_TSEC2
-	SET_STD_TSEC_INFO(tsec_info[num], 2);
-	if (is_serdes_configured(SGMII_TSEC2)) {
-		puts("eTSEC2 is in sgmii mode.\n");
-		tsec_info[num].flags |= TSEC_SGMII;
-	}
-	num++;
-#endif
-#ifdef CONFIG_TSEC3
-	SET_STD_TSEC_INFO(tsec_info[num], 3);
-	tsec_info[num].interface = PHY_INTERFACE_MODE_RGMII_ID;
-	num++;
-#endif
-	if (!num) {
-		printf("No TSECs initialized\n");
-		return 0;
-	}
-
-	mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
-	mdio_info.name = DEFAULT_MII_NAME;
-	fsl_pq_mdio_init(bis, &mdio_info);
-
-	tsec_eth_init(bis, tsec_info, num);
-#endif
-
 	return pci_eth_init(bis);
 }
 
diff --git a/configs/ls1021atwr_nor_SECURE_BOOT_defconfig b/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
index 6c4bb9aaf665..830affc925b5 100644
--- a/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
+++ b/configs/ls1021atwr_nor_SECURE_BOOT_defconfig
@@ -40,7 +40,9 @@ CONFIG_SYS_FLASH_CFI=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MII=y
+CONFIG_DM_ETH=y
 CONFIG_TSEC_ENET=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
diff --git a/configs/ls1021atwr_nor_defconfig b/configs/ls1021atwr_nor_defconfig
index 9d8c2024c04e..c4d18c6f6907 100644
--- a/configs/ls1021atwr_nor_defconfig
+++ b/configs/ls1021atwr_nor_defconfig
@@ -40,7 +40,9 @@ CONFIG_SYS_FLASH_CFI=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MII=y
+CONFIG_DM_ETH=y
 CONFIG_TSEC_ENET=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
diff --git a/configs/ls1021atwr_nor_lpuart_defconfig b/configs/ls1021atwr_nor_lpuart_defconfig
index b9cfdb6fd69e..b74d58a3487c 100644
--- a/configs/ls1021atwr_nor_lpuart_defconfig
+++ b/configs/ls1021atwr_nor_lpuart_defconfig
@@ -42,7 +42,9 @@ CONFIG_SYS_FLASH_CFI=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MII=y
+CONFIG_DM_ETH=y
 CONFIG_TSEC_ENET=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
diff --git a/configs/ls1021atwr_qspi_defconfig b/configs/ls1021atwr_qspi_defconfig
index 8c27c5908cb5..911061a37881 100644
--- a/configs/ls1021atwr_qspi_defconfig
+++ b/configs/ls1021atwr_qspi_defconfig
@@ -42,7 +42,9 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MII=y
+CONFIG_DM_ETH=y
 CONFIG_TSEC_ENET=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
diff --git a/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig b/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
index 979878d560f4..d8c26393cead 100644
--- a/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
+++ b/configs/ls1021atwr_sdcard_ifc_SECURE_BOOT_defconfig
@@ -53,7 +53,9 @@ CONFIG_SYS_FLASH_CFI=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MII=y
+CONFIG_DM_ETH=y
 CONFIG_TSEC_ENET=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
diff --git a/configs/ls1021atwr_sdcard_ifc_defconfig b/configs/ls1021atwr_sdcard_ifc_defconfig
index 59af172cb8a1..d23c87504c9b 100644
--- a/configs/ls1021atwr_sdcard_ifc_defconfig
+++ b/configs/ls1021atwr_sdcard_ifc_defconfig
@@ -54,7 +54,9 @@ CONFIG_SYS_FLASH_CFI=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MII=y
+CONFIG_DM_ETH=y
 CONFIG_TSEC_ENET=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
diff --git a/configs/ls1021atwr_sdcard_qspi_defconfig b/configs/ls1021atwr_sdcard_qspi_defconfig
index d7fec5e365eb..7b2c2900a060 100644
--- a/configs/ls1021atwr_sdcard_qspi_defconfig
+++ b/configs/ls1021atwr_sdcard_qspi_defconfig
@@ -53,7 +53,9 @@ CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_PHY_GIGE=y
 CONFIG_E1000=y
 CONFIG_MII=y
+CONFIG_DM_ETH=y
 CONFIG_TSEC_ENET=y
+CONFIG_PHY_ATHEROS=y
 CONFIG_PCI=y
 CONFIG_DM_PCI=y
 CONFIG_DM_PCI_COMPAT=y
diff --git a/include/configs/ls1021atwr.h b/include/configs/ls1021atwr.h
index de0c9c7f26af..cbf7a496a564 100644
--- a/include/configs/ls1021atwr.h
+++ b/include/configs/ls1021atwr.h
@@ -260,33 +260,7 @@
  */
 
 #ifdef CONFIG_TSEC_ENET
-#define CONFIG_MII_DEFAULT_TSEC		1
-#define CONFIG_TSEC1			1
-#define CONFIG_TSEC1_NAME		"eTSEC1"
-#define CONFIG_TSEC2			1
-#define CONFIG_TSEC2_NAME		"eTSEC2"
-#define CONFIG_TSEC3			1
-#define CONFIG_TSEC3_NAME		"eTSEC3"
-
-#define TSEC1_PHY_ADDR			2
-#define TSEC2_PHY_ADDR			0
-#define TSEC3_PHY_ADDR			1
-
-#define TSEC1_FLAGS			(TSEC_GIGABIT | TSEC_REDUCED)
-#define TSEC2_FLAGS			(TSEC_GIGABIT | TSEC_REDUCED)
-#define TSEC3_FLAGS			(TSEC_GIGABIT | TSEC_REDUCED)
-
-#define TSEC1_PHYIDX			0
-#define TSEC2_PHYIDX			0
-#define TSEC3_PHYIDX			0
-
-#define CONFIG_ETHPRIME			"eTSEC1"
-
-#define CONFIG_PHY_ATHEROS
-
-#define CONFIG_HAS_ETH0
-#define CONFIG_HAS_ETH1
-#define CONFIG_HAS_ETH2
+#define CONFIG_ETHPRIME			"ethernet at 2d10000"
 #endif
 
 /* PCIe */
-- 
2.17.1

  parent reply	other threads:[~2019-07-18 21:29 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18 21:29 [U-Boot] [PATCH v3 0/9] NXP LS1021A-TSN Board Vladimir Oltean
2019-07-18 21:29 ` [U-Boot] [PATCH v3 1/9] net: tsec: Refactor the readout of the tbi-handle property Vladimir Oltean
2019-07-25 18:42   ` [U-Boot] " Joe Hershberger
2019-07-18 21:29 ` [U-Boot] [PATCH v3 2/9] net: tsec: Fix offset of MDIO registers for DM_ETH Vladimir Oltean
2019-07-23  6:23   ` Bin Meng
2019-07-25 18:42   ` [U-Boot] " Joe Hershberger
2019-07-18 21:29 ` [U-Boot] [PATCH v3 3/9] net: tsec: Reverse Christmas tree notation Vladimir Oltean
2019-07-25 18:42   ` [U-Boot] " Joe Hershberger
2019-07-18 21:29 ` [U-Boot] [PATCH v3 4/9] net: tsec: Make errors visible Vladimir Oltean
2019-07-25 18:42   ` [U-Boot] " Joe Hershberger
2019-07-18 21:29 ` [U-Boot] [PATCH v3 5/9] net: tsec: Common handling of MAC station address for DM_ETH Vladimir Oltean
2019-07-25 18:42   ` [U-Boot] " Joe Hershberger
2019-07-18 21:29 ` [U-Boot] [PATCH v3 6/9] net: tsec: Change compatible strings to match Linux Vladimir Oltean
2019-07-23  3:30   ` Joe Hershberger
2019-07-25 18:42   ` [U-Boot] " Joe Hershberger
2019-07-18 21:29 ` Vladimir Oltean [this message]
2019-07-25 18:42   ` [U-Boot] arm: ls1021atwr: Convert to use driver model TSEC driver Joe Hershberger
2019-07-18 21:30 ` [U-Boot] [PATCH v3 8/9] configs: ls1021atwr: Fix distro_bootcmd for QSPI boot Vladimir Oltean
2019-07-23  3:31   ` Joe Hershberger
2019-07-25 18:42   ` [U-Boot] " Joe Hershberger
2019-07-18 21:30 ` [U-Boot] [PATCH v3 9/9] Add support for the NXP LS1021A-TSN board Vladimir Oltean
2019-07-23  3:35   ` Joe Hershberger
2019-07-23  6:25   ` Bin Meng
2019-07-25 18:42   ` [U-Boot] " Joe Hershberger
2019-07-25 20:30     ` Vladimir Oltean
2019-07-23  0:15 ` [U-Boot] [PATCH v3 0/9] NXP LS1021A-TSN Board Joe Hershberger
2019-07-23  6:07   ` Vladimir Oltean
2019-07-23  7:37     ` Joe Hershberger
2019-07-24 15:37       ` Vladimir Oltean
2019-07-24 18:56         ` Joe Hershberger
2019-07-24 20:54           ` Vladimir Oltean
2019-08-14  9:37           ` Prabhakar Kushwaha
2019-08-14  9:52             ` Vladimir Oltean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190718213001.24815-8-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox