Skip to contentSkip to conversation

Add Ethernet support for Amlogic P212 Reference board

PATCH New Neil Armstrong 3 participants 11 messages Oct 18, 2017 – Nov 17, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add Ethernet support for Amlogic P212 Reference board

This patchset aims to add support for the Internal RMII Ethernet PHY of the Amlogic Meson GXL S905X SoC on the Amlogic P212 Reference board.

The Internal PHY needs a specific config then acts as a generic PHY.

Neil Armstrong (3):
net: phy: Add Amlogic Meson GXL Internal PHY support
arm: meson: Add supplementary ethernet registers definitions
arm: amlogic: p212: Add support for Ethernet with Internal PHY

 arch/arm/include/asm/arch-meson/gxbb.h |  3 ++
 board/amlogic/p212/p212.c              | 39 ++++++++++++++++++++++-
 configs/p212_defconfig                 |  4 +++
 drivers/net/phy/Kconfig                |  3 ++
 drivers/net/phy/Makefile               |  1 +
 drivers/net/phy/meson-gxl.c            | 57 ++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy.c                  |  3 ++
 include/configs/p212.h                 |  2 ++
 include/phy.h                          |  1 +
 9 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/phy/meson-gxl.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/3 net: phy: Add Amlogic Meson GXL Internal PHY support

The Amlogic Meson GXL/GXM families embeds an internal RMII Ethernet PHY.

The PHY acts as a generic PHY but needs a slight configuration right before it's configuration.

---
 drivers/net/phy/Kconfig     |  3 +++
 drivers/net/phy/Makefile    |  1 +
 drivers/net/phy/meson-gxl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy.c       |  3 +++
 include/phy.h               |  1 +
 5 files changed, 65 insertions(+)
 create mode 100644 drivers/net/phy/meson-gxl.c
drivers/net/phy/Kconfig +3 -0
index 4d02d8b..e32f1eb 100644
@@ -55,6 +55,9 @@ config PHY_LXT
 config PHY_MARVELL
 	bool "Marvell Ethernet PHYs support"
 
+config PHY_MESON_GXL
+	bool "Amlogic Meson GXL Internal PHY support"
+
 config PHY_MICREL
 	bool "Micrel Ethernet PHYs support"
 	help
drivers/net/phy/Makefile +1 -0
index 54f32f6..1e264b2 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_PHY_LXT) += lxt.o
 obj-$(CONFIG_PHY_MARVELL) += marvell.o
 obj-$(CONFIG_PHY_MICREL_KSZ8XXX) += micrel_ksz8xxx.o
 obj-$(CONFIG_PHY_MICREL_KSZ90X1) += micrel_ksz90x1.o
+obj-$(CONFIG_PHY_MESON_GXL) += meson-gxl.o
 obj-$(CONFIG_PHY_NATSEMI) += natsemi.o
 obj-$(CONFIG_PHY_REALTEK) += realtek.o
 obj-$(CONFIG_PHY_SMSC) += smsc.o
drivers/net/phy/meson-gxl.c new file +57 -0

57 lines not on this page · raw message

drivers/net/phy/phy.c +3 -0
index 5be51d7..fd3dd55 100644
@@ -494,6 +494,9 @@ int phy_init(void)
 #ifdef CONFIG_PHY_MICREL_KSZ90X1
 	phy_micrel_ksz90x1_init();
 #endif
+#ifdef CONFIG_PHY_MESON_GXL
+	phy_meson_gxl_init();
+#endif
 #ifdef CONFIG_PHY_NATSEMI
 	phy_natsemi_init();
 #endif
include/phy.h +1 -0
index a0b1f12..50f1e12 100644
@@ -268,6 +268,7 @@ int phy_lxt_init(void);
 int phy_marvell_init(void);
 int phy_micrel_ksz8xxx_init(void);
 int phy_micrel_ksz90x1_init(void);
+int phy_meson_gxl_init(void);
 int phy_natsemi_init(void);
 int phy_realtek_init(void);
 int phy_smsc_init(void);
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/3 net: phy: Add Amlogic Meson GXL Internal PHY support

Quoted 6 lines · Neil Armstrong

The Amlogic Meson GXL/GXM families embeds an internal RMII Ethernet PHY.

The PHY acts as a generic PHY but needs a slight configuration right before it's configuration.

Quoted 8 lines
---
 drivers/net/phy/Kconfig     |  3 +++
 drivers/net/phy/Makefile    |  1 +
 drivers/net/phy/meson-gxl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy.c       |  3 +++
 include/phy.h               |  1 +
 5 files changed, 65 insertions(+)
 create mode 100644 drivers/net/phy/meson-gxl.c

We really should create a uclass for PHY drivers before adding any more of these.

Regards,
Simon

#3 lore raw

PATCH 1/3 net: phy: Add Amlogic Meson GXL Internal PHY support

Quoted 16 lines · Simon Glass
Quoted 6 lines · Neil Armstrong

The Amlogic Meson GXL/GXM families embeds an internal RMII Ethernet PHY.

The PHY acts as a generic PHY but needs a slight configuration right before it's configuration.

Quoted 8 lines
---
 drivers/net/phy/Kconfig     |  3 +++
 drivers/net/phy/Makefile    |  1 +
 drivers/net/phy/meson-gxl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy.c       |  3 +++
 include/phy.h               |  1 +
 5 files changed, 65 insertions(+)
 create mode 100644 drivers/net/phy/meson-gxl.c
Quoted 6 lines

We really should create a uclass for PHY drivers before adding any more of these.

Regards,
Simon

Hi Simon,

Sure, this would indeed be necessary, but is it necessary to wait for the uclass to merge mode PHYs ?

Neil

#4 lore raw

PATCH 1/3 net: phy: Add Amlogic Meson GXL Internal PHY support

Quoted 20 lines · Neil Armstrong
Quoted 19 lines · Simon Glass
Quoted 6 lines · Neil Armstrong

The Amlogic Meson GXL/GXM families embeds an internal RMII Ethernet PHY.

The PHY acts as a generic PHY but needs a slight configuration right before it's configuration.

Quoted 8 lines
---
 drivers/net/phy/Kconfig     |  3 +++
 drivers/net/phy/Makefile    |  1 +
 drivers/net/phy/meson-gxl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy.c       |  3 +++
 include/phy.h               |  1 +
 5 files changed, 65 insertions(+)
 create mode 100644 drivers/net/phy/meson-gxl.c

We really should create a uclass for PHY drivers before adding any more of these.

Quoted 8 lines
Quoted 3 lines

Regards,
Simon

Hi Simon,

Sure, this would indeed be necessary, but is it necessary to wait for the uclass to merge mode PHYs ?

Well, this isn't going in before the next release (along with all of the other amlogic stuff, which looks good otherwise btw). So, do you have time to take a pass at a uclass?

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-amlogic/attachments/20171029/9ed4e0fe/attachment.sig>
#5 lore raw

PATCH 1/3 net: phy: Add Amlogic Meson GXL Internal PHY support

Le 29/10/2017 13:04, Tom Rini a ?crit :

Quoted 25 lines · Neil Armstrong
Quoted 24 lines · Simon Glass
Quoted 22 lines · Neil Armstrong
Quoted 6 lines

The Amlogic Meson GXL/GXM families embeds an internal RMII Ethernet PHY.

The PHY acts as a generic PHY but needs a slight configuration right before it's configuration.

Quoted 8 lines
---
 drivers/net/phy/Kconfig     |  3 +++
 drivers/net/phy/Makefile    |  1 +
 drivers/net/phy/meson-gxl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/net/phy/phy.c       |  3 +++
 include/phy.h               |  1 +
 5 files changed, 65 insertions(+)
 create mode 100644 drivers/net/phy/meson-gxl.c

We really should create a uclass for PHY drivers before adding any more of these.

Regards,
Simon

Quoted 9 lines
Quoted 4 lines

Hi Simon,

Sure, this would indeed be necessary, but is it necessary to wait for the uclass to merge mode PHYs ?

Well, this isn't going in before the next release (along with all of the other amlogic stuff, which looks good otherwise btw). So, do you have time to take a pass at a uclass?

Hi Tom, Simon,

I can give a try, but with my limited uclass/dm knowledge, it will only be basic and will some review.

Should the plan be to introduce DM support for net PHY subsystem, then introduce this meson GXL phy as first implementation ?

Should I remove support for non-dm PHY drivers and probing when DM is enabled ?

Neil

#6 lore raw

PATCH 1/3 net: phy: Add Amlogic Meson GXL Internal PHY support

In reply to Neil Armstrong
Quoted 6 lines · Neil Armstrong

The Amlogic Meson GXL/GXM families embeds an internal RMII Ethernet PHY.

The PHY acts as a generic PHY but needs a slight configuration right before it's configuration.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-amlogic/attachments/20171117/48b59010/attachment.sig>
#7 lore raw

PATCH 2/3 arm: meson: Add supplementary ethernet registers definitions

In reply to Neil Armstrong

On Amlogic Meson GXL/GXM, supplementary ethernet configuration registers were added to configure the internal RMII PHY interface.

---
 arch/arm/include/asm/arch-meson/gxbb.h | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/include/asm/arch-meson/gxbb.h +3 -0
index ce41349..74d5290 100644
@@ -22,11 +22,14 @@
 
 #define GXBB_ETH_REG_0		GXBB_PERIPHS_ADDR(0x50)
 #define GXBB_ETH_REG_1		GXBB_PERIPHS_ADDR(0x51)
+#define GXBB_ETH_REG_2		GXBB_PERIPHS_ADDR(0x56)
+#define GXBB_ETH_REG_3		GXBB_PERIPHS_ADDR(0x57)
 
 #define GXBB_ETH_REG_0_PHY_INTF		BIT(0)
 #define GXBB_ETH_REG_0_TX_PHASE(x)	(((x) & 3) << 5)
 #define GXBB_ETH_REG_0_TX_RATIO(x)	(((x) & 7) << 7)
 #define GXBB_ETH_REG_0_PHY_CLK_EN	BIT(10)
+#define GXBB_ETH_REG_0_INVERT_RMII_CLK	BIT(11)
 #define GXBB_ETH_REG_0_CLK_EN		BIT(12)
 
 /* HIU registers */
Signature · 1 line
2.7.4
#8 lore raw

PATCH 2/3 arm: meson: Add supplementary ethernet registers definitions

Quoted 4 lines · Neil Armstrong

On Amlogic Meson GXL/GXM, supplementary ethernet configuration registers were added to configure the internal RMII PHY interface.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-amlogic/attachments/20171117/1c016374/attachment.sig>
#9 lore raw

PATCH 3/3 arm: amlogic: p212: Add support for Ethernet with Internal PHY

In reply to Neil Armstrong

This patch adds support for the Internal RMII Ethernet PHY on the Amlogic P212 Reference Board.

---
 board/amlogic/p212/p212.c | 39 ++++++++++++++++++++++++++++++++++++++-
 configs/p212_defconfig    |  4 ++++
 include/configs/p212.h    |  2 ++
 3 files changed, 44 insertions(+), 1 deletion(-)
board/amlogic/p212/p212.c +38 -1
index 1eeb7f2..ece8096 100644
@@ -9,6 +9,13 @@
 #include <dm.h>
 #include <asm/io.h>
 #include <asm/arch/gxbb.h>
+#include <asm/arch/sm.h>
+#include <phy.h>
+
+#define EFUSE_SN_OFFSET		20
+#define EFUSE_SN_SIZE		16
+#define EFUSE_MAC_OFFSET	52
+#define EFUSE_MAC_SIZE		6
 
 int board_init(void)
 {
@@ -17,5 +24,35 @@ int board_init(void)
 
 int misc_init_r(void)
 {
-       return 0;
+	u8 mac_addr[EFUSE_MAC_SIZE];
+	char serial[EFUSE_SN_SIZE];
+	ssize_t len;
+
+	/* Set RMII mode */
+	out_le32(GXBB_ETH_REG_0, GXBB_ETH_REG_0_INVERT_RMII_CLK |
+				 GXBB_ETH_REG_0_CLK_EN);
+
+	/* Use Internal PHY */
+	out_le32(GXBB_ETH_REG_2, 0x10110181);
+	out_le32(GXBB_ETH_REG_3, 0xe40908ff);
+
+	/* Enable power and clock gate */
+	setbits_le32(GXBB_GCLK_MPEG_1, GXBB_GCLK_MPEG_1_ETH);
+	clrbits_le32(GXBB_MEM_PD_REG_0, GXBB_MEM_PD_REG_0_ETH_MASK);
+
+	if (!eth_env_get_enetaddr("ethaddr", mac_addr)) {
+		len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
+					  mac_addr, EFUSE_MAC_SIZE);
+		if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr))
+			eth_env_set_enetaddr("ethaddr", mac_addr);
+	}
+
+	if (!env_get("serial#")) {
+		len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial,
+			EFUSE_SN_SIZE);
+		if (len == EFUSE_SN_SIZE)
+			env_set("serial#", serial);
+	}
+
+	return 0;
 }
configs/p212_defconfig +4 -0
index 3c57621..d4b5349 100644
@@ -20,6 +20,10 @@ CONFIG_OF_CONTROL=y
 CONFIG_DM_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_MESON_GX=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_PHY_MESON_GXL=y
+CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_MESON_GXL=y
 CONFIG_DEBUG_UART_MESON=y
include/configs/p212.h +2 -0
index 0477384..793b556 100644
@@ -12,6 +12,8 @@
 
 #define CONFIG_MISC_INIT_R
 
+#define CONFIG_PHY_ADDR 		8
+
 /* Serial setup */
 #define CONFIG_CONS_INDEX		0
 
Signature · 1 line
2.7.4
#10 lore raw

PATCH 3/3 arm: amlogic: p212: Add support for Ethernet with Internal PHY

Quoted 4 lines · Neil Armstrong

This patch adds support for the Internal RMII Ethernet PHY on the Amlogic P212 Reference Board.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-amlogic/attachments/20171117/be913554/attachment.sig>