Add the internal phy support
Subsystems (8)
v2 cover Add the internal phy support
The rk3228 and rk3328 support internal phy inside, let's enable it to work. And the internal phy need to do some special setting, so register the rockchip internal phy driver.
David Wu (11):
net: phy: Add rockchip phy driver support
multi_v7_defconfig: Make rockchip phy built-in
arm64: defconfig: Enable CONFIG_ROCKCHIP_PHY
net: stmmac: dwmac-rk: Remove unwanted code for rk3328_set_to_rmii()
net: stmmac: dwmac-rk: Add internal phy support
net: stmmac: dwmac-rk: Add internal phy support for rk3228
net: stmmac: dwmac-rk: Add internal phy supprot for rk3328
ARM: dts: rk322x: Add support internal phy for gmac
ARM: dts: rk3228-evb: Enable the internal phy for gmac
ARM64: dts: rockchip: Add gmac2phy node support for rk3328
ARM64: dts: rockchip: Enable gmac2phy for rk3328-evb
.../devicetree/bindings/net/rockchip-dwmac.txt | 4 +- arch/arm/boot/dts/rk3228-evb.dts | 19 +++ arch/arm/boot/dts/rk322x.dtsi | 8 +- arch/arm/configs/multi_v7_defconfig | 1 + arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 17 +++ arch/arm64/boot/dts/rockchip/rk3328.dtsi | 24 ++++ arch/arm64/configs/defconfig | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 135 +++++++++++++++++++-- drivers/net/phy/Kconfig | 5 + drivers/net/phy/Makefile | 1 + drivers/net/phy/rockchip.c | 128 +++++++++++++++++++ 11 files changed, 328 insertions(+), 15 deletions(-) create mode 100644 drivers/net/phy/rockchip.c
Signature · 1 line
1.9.1
PATCH v2 1/11 net: phy: Add rockchip phy driver support
Support internal ephy currently.
---
changes in v2:
- Alphabetic order for Kconfig and Makefile.
- Add analog register init.
- Disable auto-mdix for workround.
- Rename config
drivers/net/phy/Kconfig | 5 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/rockchip.c | 128 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 drivers/net/phy/rockchip.c
drivers/net/phy/Kconfig +5 -0
@@ -334,6 +334,11 @@ config REALTEK_PHY ---help--- Supports the Realtek 821x PHY. +config ROCKCHIP_PHY + tristate "Drivers for ROCKCHIP PHYs" + ---help--- + Currently supports the internal ephy. + config SMSC_PHY tristate "SMSC PHYs" ---help---
drivers/net/phy/Makefile +1 -0
@@ -66,6 +66,7 @@ obj-$(CONFIG_MICROSEMI_PHY) += mscc.o obj-$(CONFIG_NATIONAL_PHY) += national.o obj-$(CONFIG_QSEMI_PHY) += qsemi.o obj-$(CONFIG_REALTEK_PHY) += realtek.o +obj-$(CONFIG_ROCKCHIP_PHY) += rockchip.o obj-$(CONFIG_SMSC_PHY) += smsc.o obj-$(CONFIG_STE10XP) += ste10Xp.o obj-$(CONFIG_TERANETICS_PHY) += teranetics.o
drivers/net/phy/rockchip.c new file +128 -0
128 lines not on this page · raw message
Signature · 1 line
1.9.1
Andrew Lunn
maintainerRe: [PATCH v2 01/11] net: phy: Add rockchip phy driver support
drivers/net/phy/rockchip.c line 94
Quoted 5 lines
drivers/net/phy/rockchip.c new file +5
-0+/* +* If mode switch happens from 10BT to 100BT, all DSP/AFE +* registers are set to default values. So any AFE/DSP +* registers have to be re-initialized in this case. +*/
Hi David
Are they also lost on suspend and resume?
Andrew
Re: [PATCH v2 01/11] net: phy: Add rockchip phy driver support
Hi Andrew,
? 2017/7/27 21:38, Andrew Lunn ??:
Quoted 9 lines
drivers/net/phy/rockchip.c line 94
Quoted 5 lines
drivers/net/phy/rockchip.c new file +5
-0+/* +* If mode switch happens from 10BT to 100BT, all DSP/AFE +* registers are set to default values. So any AFE/DSP +* registers have to be re-initialized in this case. +*/ Hi David
Are they also lost on suspend and resume?
Yes, i will add the re-initialized on suspend and resume?and thank you?
Quoted 5 lines
Andrew
Re: [PATCH v2 01/11] net: phy: Add rockchip phy driver support
In reply to David WuQuoted 21 lines · David Wu
Support internal ephy currently.
Signed-off-by David Wu <[email protected]>---
changes in v2:
- Alphabetic order forKconfigandMakefile.
- Add analog register init.
- Disable auto-mdix for workround.
- Rename configdrivers/net/phy/Kconfig | 5 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/rockchip.c | 128 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 drivers/net/phy/rockchip.cdrivers/net/phy/Kconfig +0
-0
drivers/net/phy/Kconfig config REALTEK_PHY · line 338
Quoted 5 lines
drivers/net/phy/Kconfig +2
-0@@ -334,6 +334,11 @@ config REALTEK_PHY ---help--- Supports the Realtek 821x PHY. +config ROCKCHIP_PHY + tristate "Drivers for ROCKCHIP PHYs"
"Driver for Rockchip Ethernet PHYs" would seem more appropriate, this is just one driver for now.
drivers/net/phy/Kconfig config REALTEK_PHY · line 340
Quoted 2 lines
drivers/net/phy/Kconfig +2
-0+ ---help--- + Currently supports the internal ephy.
EPHY is usually how an Ethernet PHY is abbreviated.
Quoted 22 lines
drivers/net/phy/Kconfig +1
-0+ config SMSC_PHY tristate "SMSC PHYs" ---help---drivers/net/phy/Makefile +1
-0@@ -66,6 +66,7 @@ obj-$(CONFIG_MICROSEMI_PHY) += mscc.o obj-$(CONFIG_NATIONAL_PHY) += national.o obj-$(CONFIG_QSEMI_PHY) += qsemi.o obj-$(CONFIG_REALTEK_PHY) += realtek.o +obj-$(CONFIG_ROCKCHIP_PHY) += rockchip.o obj-$(CONFIG_SMSC_PHY) += smsc.o obj-$(CONFIG_STE10XP) += ste10Xp.o obj-$(CONFIG_TERANETICS_PHY) += teranetics.odrivers/net/phy/rockchip.c new file +0
-0
drivers/net/phy/rockchip.c line 8
Quoted 8 lines
drivers/net/phy/rockchip.c new file +8
-0@@ -0,0 +1,128 @@ +/** +* drivers/net/phy/rockchip.c +* +* Driver for ROCKCHIP PHY +* +* Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd +* +* David Wu<[email protected]>
Missing space between your last name and your email address, there is another typo like this in the MODULE_AUTHOR() macro.
Quoted 34 lines
drivers/net/phy/rockchip.c new file +34
-0+* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/mii.h> +#include <linux/ethtool.h> +#include <linux/phy.h> +#include <linux/netdevice.h> + +#define MII_INTERNAL_CTRL_STATUS 17 +#define SMI_ADDR_TSTCNTL 20 +#define SMI_ADDR_TSTREAD1 21 +#define SMI_ADDR_TSTREAD2 22 +#define SMI_ADDR_TSTWRITE 23 + +#define AUTOMDIX_EN BIT(7) +#define TSTCNTL_RD (BIT(15) | BIT(10)) +#define TSTCNTL_WR (BIT(14) | BIT(10)) + +#define WR_ADDR_A7CFG 0x18 + +static void rockchip_init_tstmode (struct phy_device *phydev) +{ +/* Enable access to Analog and DSP register banks */ +phy_write (phydev,SMI_ADDR_TSTCNTL ,0x0400 ); +phy_write (phydev,SMI_ADDR_TSTCNTL ,0x0000 ); +phy_write (phydev,SMI_ADDR_TSTCNTL ,0x0400 ); +}
drivers/net/phy/rockchip.c line 52
Quoted 10 lines
drivers/net/phy/rockchip.c new file +10
-0+ +static void rockchip_close_tstmode (struct phy_device *phydev) +{ +/* Back to basic register bank */ +phy_write (phydev,SMI_ADDR_TSTCNTL ,0x0000 ); +} + +static void rockchip_internal_phy_analog_init (struct phy_device *phydev) +{ +rockchip_init_tstmode (phydev);
Technically MDIO writes can fail, but you are not propagating the return value, so you could be stuck on a bad page/bank.
drivers/net/phy/rockchip.c line 59
Quoted 7 lines
drivers/net/phy/rockchip.c new file +7
-0+ +/* +* Adjust tx amplitude to make sginal better, +* the default value is 0x8. +*/ +phy_write (phydev,SMI_ADDR_TSTWRITE ,0xB ); +phy_write (phydev,SMI_ADDR_TSTCNTL ,TSTCNTL_WR |WR_ADDR_A7CFG );
Likewise.
drivers/net/phy/rockchip.c line 61
Quoted 2 lines
drivers/net/phy/rockchip.c new file +2
-0+ +rockchip_close_tstmode (phydev);
Same here.
drivers/net/phy/rockchip.c line 71
Quoted 10 lines
drivers/net/phy/rockchip.c new file +10
-0+} + +static int rockchip_internal_phy_config_init (struct phy_device *phydev) +{ +int val; + +/* +* The auto MIDX has linked problem on some board, +* workround to disable auto MDIX. +*/
If this a board-specific problem you may consider register a PHY fixup for the affected boards, or introduce a specific property to illustrate that MDI-X is broken.
drivers/net/phy/rockchip.c line 74
Quoted 3 lines
drivers/net/phy/rockchip.c new file +3
-0+ val =phy_read (phydev,MII_INTERNAL_CTRL_STATUS ); + val &= ~AUTOMDIX_EN ; +phy_write (phydev,MII_INTERNAL_CTRL_STATUS , val);
You also need to reject MDI configuration requests coming via phy_ethtool_ksettings_set() which you should see in the phyddrv::config_ane callback.
Quoted 12 lines
drivers/net/phy/rockchip.c new file +12
-0+ +rockchip_internal_phy_analog_init (phydev); + +return 0 ; +} + +static int rockchip_internal_phy_read_status (struct phy_device *phydev) +{ +int ret, old_speed; + + old_speed = phydev->speed; + ret =genphy_read_status (phydev);
drivers/net/phy/rockchip.c line 96
Quoted 10 lines
drivers/net/phy/rockchip.c new file +10
-0+if (ret) +return ret; + +/* +* If mode switch happens from 10BT to 100BT, all DSP/AFE +* registers are set to default values. So any AFE/DSP +* registers have to be re-initialized in this case. +*/ +if ((old_speed ==SPEED_10 ) && (phydev->speed ==SPEED_100 )) +rockchip_internal_phy_analog_init (phydev);
link changes can be intercepted with a link_change_notify callback, which would be more appropriate than doing this during read_status here.
drivers/net/phy/rockchip.c line 104
Quoted 8 lines
drivers/net/phy/rockchip.c new file +8
-0+ +return ret; +} + +static struct phy_driver rockchip_phy_driver[] = { +{ + .phy_id =0x1234d400 , + .phy_id_mask =0xffff0000 ,
This mask is way too wide, the industry practice is to have the last 4 digits contain the PHY revision, so I would expect to see 0xffff_fff0 here as a mask.
drivers/net/phy/rockchip.c line 105
Quoted 1 line
drivers/net/phy/rockchip.c new file +1
-0+ .name = "rockchip internal ephy",
Rockchip internal EPHY?
drivers/net/phy/rockchip.c line 108
Quoted 3 lines
drivers/net/phy/rockchip.c new file +3
-0+ .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause + | SUPPORTED_Asym_Pause), + .soft_reset = genphy_soft_reset,
Since this is a driver for an internal PHY you also need:
.flags = PHY_IS_INTERNAL
drivers/net/phy/rockchip.c line 113
Quoted 5 lines
drivers/net/phy/rockchip.c new file +5
-0+ .config_init = rockchip_internal_phy_config_init, + .config_aneg = genphy_config_aneg, + .read_status = rockchip_internal_phy_read_status, + .suspend = genphy_suspend, + .resume = genphy_resume,
You probably need your resume function to restore the AFE/DSP settings that were done in rockchip_internal_phy_config_init()
drivers/net/phy/rockchip.c line 120
Quoted 7 lines
drivers/net/phy/rockchip.c new file +7
-0+}, +}; + +module_phy_driver (rockchip_phy_driver); + +static struct mdio_device_id __maybe_unused rockchip_phy_tbl[] = { + {0x1234d400 ,0xffff0000 },
Please also fix up the mask here.
drivers/net/phy/rockchip.c line 126
Quoted 6 lines
drivers/net/phy/rockchip.c new file +6
-0+ { } +}; + +MODULE_DEVICE_TABLE (mdio, rockchip_phy_tbl); + +MODULE_AUTHOR ("David Wu<[email protected]>" );
Typo here (same as in the heading).
drivers/net/phy/rockchip.c line 127
Quoted 1 line
drivers/net/phy/rockchip.c new file +1
-0+MODULE_DESCRIPTION ("Rockchip phy driver" );
"Rockchip Ethernet PHY driver" so make it clear what type of PHY it manages?
Quoted 2 lines
drivers/net/phy/rockchip.c new file +1
-0+MODULE_LICENSE ("GPL v2" );
Signature · 1 line
Florian
Re: [PATCH v2 01/11] net: phy: Add rockchip phy driver support
Hi Florian,
? 2017/7/28 0:51, Florian Fainelli ??:
Quoted 5 lines
Quoted 5 lines
drivers/net/phy/rockchip.c new file +5
-0+} + +static int rockchip_internal_phy_config_init (struct phy_device *phydev) +{ +int val;
Quoted 8 lines
drivers/net/phy/rockchip.c line 71
Quoted 5 lines
drivers/net/phy/rockchip.c new file +5
-0+ +/* +* The auto MIDX has linked problem on some board, +* workround to disable auto MDIX. +*/ If this a board-specific problem you may consider register a PHY fixup for the affected boards, or introduce a specific property to illustrate that MDI-X is broken.
You mean is that if I need disable Auto-mdix, then I'm going to add a property to DTS, from here to decide whether or not to close Auto-mdix?
Quoted 1 line
PATCH v2 2/11 multi_v7_defconfig: Make rockchip phy built-in
In reply to David WuEnable the rockchip phy for multi_v7_defconfig builds.
--- arch/arm/configs/multi_v7_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/configs/multi_v7_defconfig +1 -0
@@ -270,6 +270,7 @@ CONFIG_ICPLUS_PHY=y CONFIG_REALTEK_PHY=y CONFIG_MICREL_PHY=y CONFIG_FIXED_PHY=y +CONFIG_ROCKCHIP_PHY=y CONFIG_USB_PEGASUS=y CONFIG_USB_RTL8152=m CONFIG_USB_USBNET=y
Signature · 1 line
1.9.1
PATCH v2 3/11 arm64: defconfig: Enable CONFIG_ROCKCHIP_PHY
In reply to David WuMake the rockchip phy driver built into the kernel.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -203,6 +203,7 @@ CONFIG_MARVELL_PHY=m CONFIG_MESON_GXL_PHY=m CONFIG_MICREL_PHY=y CONFIG_REALTEK_PHY=m +CONFIG_ROCKCHIP_PHY=y CONFIG_USB_PEGASUS=m CONFIG_USB_RTL8150=m CONFIG_USB_RTL8152=m
Signature · 1 line
1.9.1
PATCH v2 4/11 net: stmmac: dwmac-rk: Remove unwanted code for rk3328_set_to_rmii()
In reply to David WuThis is wrong setting for rk3328_set_to_rmii(), so remove it.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 3 --- 1 file changed, 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +0 -3
@@ -365,9 +365,6 @@ static void rk3328_set_to_rmii(struct rk_priv_data *bsp_priv)regmap_write (bsp_priv->grf,RK3328_GRF_MAC_CON1 ,RK3328_GMAC_PHY_INTF_SEL_RMII |RK3328_GMAC_RMII_MODE ); - -/* set MAC to RMII mode */ -regmap_write (bsp_priv->grf,RK3328_GRF_MAC_CON1 ,GRF_BIT (11 )); }static void rk3328_set_rgmii_speed (struct rk_priv_data *bsp_priv,int speed)
Signature · 1 line
1.9.1
PATCH v2 5/11 net: stmmac: dwmac-rk: Add internal phy support
In reply to David WuTo make internal phy work, need to configure the phy_clock, phy cru_reset and related registers.
---
changes in v2:
- Use the standard "phy-mode" property for internal phy. (Florian)
- Move the internal macphy clock to the optional properties. (Heiko)
.../devicetree/bindings/net/rockchip-dwmac.txt | 4 +- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 94 +++++++++++++++++++++- 2 files changed, 93 insertions(+), 5 deletions(-)
Documentation/devicetree/bindings/net/rockchip-dwmac.txt +3 -1
@@ -25,7 +25,8 @@ Required properties: - clock-names: One name for each entry in the clocks property. - phy-mode: See ethernet.txt file in the same directory. - pinctrl-names: Names corresponding to the numbered pinctrl states. - - pinctrl-0: pin-control mode. can be <&rgmii_pins> or <&rmii_pins>. + - pinctrl-0: pin-control mode. can be <&rgmii_pins>, <&rmii_pins> or led pins + for internal phy mode. - clock_in_out: For RGMII, it must be "input", means main clock(125MHz) is not sourced from SoC's PLL, but input from PHY; For RMII, "input" means PHY provides the reference clock(50MHz), "output" means GMAC provides the
@@ -40,6 +41,7 @@ Optional properties: - tx_delay: Delay value for TXD timing. Range value is 0~0x7F, 0x30 as default. - rx_delay: Delay value for RXD timing. Range value is 0~0x7F, 0x10 as default. - phy-supply: phandle to a regulator if the PHY needs one + - clocks: <&cru MAC_PHY>: clock for internal macphy Example:
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +90 -4
187 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 6/11 net: stmmac: dwmac-rk: Add internal phy support for rk3228
There is only one mac controller in rk3228, which could connect to external phy or internal phy, use the grf_com_mux bit15 to route external/internal phy.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +12 -0
@@ -86,6 +86,8 @@ struct rk_priv_data {#define RK3228_GRF_MAC_CON0 0x0900#define RK3228_GRF_MAC_CON1 0x0904 +#define RK3228_GRF_CON_MUX 0x50 +/* RK3228_GRF_MAC_CON0 */ #define RK3228_GMAC_CLK_RX_DL_CFG (val) HIWORD_UPDATE(val, 0x7F, 7)#define RK3228_GMAC_CLK_TX_DL_CFG (val) HIWORD_UPDATE(val, 0x7F, 0)
@@ -111,6 +113,9 @@ struct rk_priv_data {#define RK3228_GMAC_RXCLK_DLY_ENABLE GRF_BIT(1)#define RK3228_GMAC_RXCLK_DLY_DISABLE GRF_CLR_BIT(1) +/* RK3228_GRF_COM_MUX */ +#define RK3228_GRF_CON_MUX_GMAC_INTERNAL_PHY GRF_BIT(15) +static void rk3228_set_to_rgmii (struct rk_priv_data *bsp_priv,int tx_delay,int rx_delay) {
@@ -191,11 +196,18 @@ static void rk3228_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)dev_err (dev,"unknown speed value for RMII! speed=%d" , speed); } +static void rk3228_internal_phy_powerup (struct rk_priv_data *priv) +{ +regmap_write (priv->grf,RK3228_GRF_CON_MUX , +RK3228_GRF_CON_MUX_GMAC_INTERNAL_PHY ); +} +static const struct rk_gmac_ops rk3228_ops = { .set_to_rgmii = rk3228_set_to_rgmii, .set_to_rmii = rk3228_set_to_rmii, .set_rgmii_speed = rk3228_set_rgmii_speed, .set_rmii_speed = rk3228_set_rmii_speed, + .internal_phy_powerup = rk3228_internal_phy_powerup, };#define RK3288_GRF_SOC_CON1 0x0248
Signature · 1 line
1.9.1
PATCH v2 7/11 net: stmmac: dwmac-rk: Add internal phy supprot for rk3328
In reply to David WuThere are two mac controllers in the rk3328, the one connects to external phy, and the other one connects to internal phy. Like the mac of external phy, the internal phy's mac also needs to configure the related mac registers at GRF.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +23 -3
@@ -323,6 +323,8 @@ static void rk3288_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)#define RK3328_GRF_MAC_CON0 0x0900#define RK3328_GRF_MAC_CON1 0x0904 +#define RK3328_GRF_MAC_CON2 0x0908 +#define RK3328_GRF_MACPHY_CON1 0xb04/* RK3328_GRF_MAC_CON0 */ #define RK3328_GMAC_CLK_RX_DL_CFG (val) HIWORD_UPDATE(val, 0x7F, 7)
@@ -349,6 +351,9 @@ static void rk3288_set_rmii_speed(struct rk_priv_data *bsp_priv, int speed)#define RK3328_GMAC_RXCLK_DLY_ENABLE GRF_BIT(1)#define RK3328_GMAC_RXCLK_DLY_DISABLE GRF_CLR_BIT(0) +/* RK3328_GRF_MACPHY_CON1 */ +#define RK3328_MACPHY_RMII_MODE GRF_BIT(9) +static void rk3328_set_to_rgmii (struct rk_priv_data *bsp_priv,int tx_delay,int rx_delay) {
@@ -373,13 +378,17 @@ static void rk3328_set_to_rgmii(struct rk_priv_data *bsp_priv,static void rk3328_set_to_rmii (struct rk_priv_data *bsp_priv) {struct device *dev = &bsp_priv->pdev->dev; +unsigned int reg;if (IS_ERR (bsp_priv->grf)) {dev_err (dev,"Missing rockchip,grf property\n" );return ; } -regmap_write (bsp_priv->grf,RK3328_GRF_MAC_CON1 , + reg = bsp_priv->internal_phy ?RK3328_GRF_MAC_CON2 : +RK3328_GRF_MAC_CON1 ; + +regmap_write (bsp_priv->grf, reg,RK3328_GMAC_PHY_INTF_SEL_RMII |RK3328_GMAC_RMII_MODE ); }
@@ -409,29 +418,40 @@ static void rk3328_set_rgmii_speed(struct rk_priv_data *bsp_priv, int speed)static void rk3328_set_rmii_speed (struct rk_priv_data *bsp_priv,int speed) {struct device *dev = &bsp_priv->pdev->dev; +unsigned int reg;if (IS_ERR (bsp_priv->grf)) {dev_err (dev,"Missing rockchip,grf property\n" );return ; } + reg = bsp_priv->internal_phy ?RK3328_GRF_MAC_CON2 : +RK3328_GRF_MAC_CON1 ; +if (speed ==10 ) -regmap_write (bsp_priv->grf,RK3328_GRF_MAC_CON1 , +regmap_write (bsp_priv->grf, reg,RK3328_GMAC_RMII_CLK_2_5M |RK3328_GMAC_SPEED_10M );else if (speed ==100 ) -regmap_write (bsp_priv->grf,RK3328_GRF_MAC_CON1 , +regmap_write (bsp_priv->grf, reg,RK3328_GMAC_RMII_CLK_25M |RK3328_GMAC_SPEED_100M );else dev_err (dev,"unknown speed value for RMII! speed=%d" , speed); } +static void rk3328_internal_phy_powerup (struct rk_priv_data *priv) +{ +regmap_write (priv->grf,RK3328_GRF_MACPHY_CON1 , +RK3328_MACPHY_RMII_MODE ); +} +static const struct rk_gmac_ops rk3328_ops = { .set_to_rgmii = rk3328_set_to_rgmii, .set_to_rmii = rk3328_set_to_rmii, .set_rgmii_speed = rk3328_set_rgmii_speed, .set_rmii_speed = rk3328_set_rmii_speed, + .internal_phy_powerup = rk3328_internal_phy_powerup, };#define RK3366_GRF_SOC_CON6 0x0418
Signature · 1 line
1.9.1
PATCH v2 8/11 ARM: dts: rk322x: Add support internal phy for gmac
In reply to David WuThis patch adds internal mac phy clock and internal mac phy reset for rk gmac using.
--- arch/arm/boot/dts/rk322x.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/rk322x.dtsi +4 -4
@@ -611,13 +611,13 @@ clocks = <&cru SCLK_MAC>, <&cru SCLK_MAC_RX>, <&cru SCLK_MAC_TX>, <&cru SCLK_MAC_REF>, <&cru SCLK_MAC_REFOUT>, <&cru ACLK_GMAC>, - <&cru PCLK_GMAC>; + <&cru PCLK_GMAC>, <&cru SCLK_MAC_PHY>; clock-names = "stmmaceth", "mac_clk_rx", "mac_clk_tx", "clk_mac_ref", "clk_mac_refout", "aclk_mac", - "pclk_mac"; - resets = <&cru SRST_GMAC>; - reset-names = "stmmaceth"; + "pclk_mac", "clk_macphy"; + resets = <&cru SRST_GMAC>, <&cru SRST_MACPHY>; + reset-names = "stmmaceth", "mac-phy"; rockchip,grf = <&grf>; status = "disabled"; };
Signature · 1 line
1.9.1
PATCH v2 9/11 ARM: dts: rk3228-evb: Enable the internal phy for gmac
In reply to David WuThis patch enables the internal phy for rk3228 evb board by default.
To use the external 1000M phy on evb board, need to make some switch of evb board to be on.
--- arch/arm/boot/dts/rk3228-evb.dts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm/boot/dts/rk3228-evb.dts +19 -0
@@ -50,6 +50,16 @@ device_type = "memory"; reg = <0x60000000 0x40000000>; }; + + vcc_phy: vcc-phy-regulator { + compatible = "regulator-fixed"; + enable-active-high; + regulator-name = "vcc_phy"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + regulator-boot-on; + }; }; &emmc {
@@ -60,6 +70,15 @@ status = "okay"; }; +&gmac { + assigned-clocks = <&cru SCLK_MAC_SRC>; + assigned-clock-rates = <50000000>; + clock_in_out = "output"; + phy-supply = <&vcc_phy>; + phy-mode = "internal"; + status = "okay"; +}; + &tsadc { status = "okay";
Signature · 1 line
1.9.1
Andrew Lunn
maintainerRe: [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
In reply to David WuQuoted 7 lines · David Wu
To make internal phy work, need to configure the
phy_clock, phycru_resetand related registers.Signed-off-by David Wu <[email protected]>---
changes in v2:
- Use the standard "phy-mode" property for internal phy. (Florian)
I think we need to discuss this. This PHY appears to be on an MDIO bus, it uses a standard PHY driver, and it appears to be using an RMII interface. So it is just an ordinary PHY.
Internal is supposed to be something which is not ordinary, does not use one of the standard phy modes, needs something special to make it work.
Florain, it appears to be your suggestion to use internal. What do you say?
Andrew
Re: [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
Quoted 4 lines · Andrew Lunn
Quoted 3 lines · David Wu
To make internal phy work, need to configure the
phy_clock, phycru_resetand related registers.
Quoted 8 lines
Quoted 4 lines
Signed-off-by David Wu <[email protected]>---
changes in v2:
- Use the standard "phy-mode" property for internal phy. (Florian)I think we need to discuss this. This PHY appears to be on an MDIO bus, it uses a standard PHY driver, and it appears to be using an RMII interface. So it is just an ordinary PHY.
First, the fact that the internal PHY also appears through MDIO is orthogonal to the fact that it is internal or external. Plenty of designs have internal PHYs exposed through MDIO because that is convenient. What matters though is how the data/clock lines are wired internally, which is what "phy-mode" describes.
Quoted 7 lines
Internal is supposed to be something which is not ordinary, does not use one of the standard phy modes, needs something special to make it work.
Florain, it appears to be your suggestion to use internal. What do you say?
phy-mode = "internal" really means that it is not a standard MII variant to connect the data/clock lines between the Ethernet MAC and the PHY, and this can happen in some designs (although quite unlikely). So from there we could do several things depending on the requirements:
- if you can have your Ethernet MAC driver perform the necessary configuration *after* you have been able to bind the PHY device with its PHY driver, then the PHY driver should have PHY_IS_INTERNAL in its flags, and you can use phy_is_internal() from PHYLIB to tell you that and we could imagine using: phy-mode = "rmii" because that would not too much of a stretch
- if you need knowledge about this PHY connection type prior to binding the PHY device and its driver (that is, before of_phy_connect()) we could add a boolean property e.g: "phy-is-internal" that allows us to know that, or we can have a new phy-mode value, e.g: "internal-rmii" which describes that, either way would probably be fine, but the former scales better
Then again, using phy-mode = "internal" even though this is Reduced MII is not big of a deal IMHO as long as there is no loss of information and that internal de-facto means internal reduced MII for instance.
Signature · 1 line
Florian
Re: [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
Quoted 40 lines · Florian Fainelli
Quoted 4 lines · Andrew Lunn
Quoted 3 lines · David Wu
To make internal phy work, need to configure the
phy_clock, phycru_resetand related registers.Quoted 8 lines
Quoted 4 lines
Signed-off-by David Wu <[email protected]>---
changes in v2:
- Use the standard "phy-mode" property for internal phy. (Florian)I think we need to discuss this. This PHY appears to be on an MDIO bus, it uses a standard PHY driver, and it appears to be using an RMII interface. So it is just an ordinary PHY.
First, the fact that the internal PHY also appears through MDIO is orthogonal to the fact that it is internal or external. Plenty of designs have internal PHYs exposed through MDIO because that is convenient. What matters though is how the data/clock lines are wired internally, which is what "phy-mode" describes.
Quoted 7 lines
Internal is supposed to be something which is not ordinary, does not use one of the standard phy modes, needs something special to make it work.
Florain, it appears to be your suggestion to use internal. What do you say?
phy-mode = "internal" really means that it is not a standard MII variant to connect the data/clock lines between the Ethernet MAC and the PHY, and this can happen in some designs (although quite unlikely). So from there we could do several things depending on the requirements:
- if you can have your Ethernet MAC driver perform the necessary configuration *after* you have been able to bind the PHY device with its PHY driver, then the PHY driver should have
PHY_IS_INTERNALin its flags, and you can usephy_is_internal()from PHYLIB to tell you that and we could imagine using: phy-mode = "rmii" because that would not too much of a stretch
Quoted 7 lines
- if you need knowledge about this PHY connection type prior to binding the PHY device and its driver (that is, before
of_phy_connect()) we could add a boolean property e.g: "phy-is-internal" that allows us to know that, or we can have a new phy-mode value, e.g: "internal-rmii" which describes that, either way would probably be fine, but the former scales better
Hello
We have the same problem on Allwinner SoCs for dwmac-sun8i, we need to set a syscon for chossing between internal/external PHY. Having this phy-is-internal would be very helpfull. (adding internal-xmii will add too many flags in our case)
Thanks
Regards
Corentin Labbe
Re: [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
Quoted 48 lines · Corentin Labbe
Quoted 40 lines · Florian Fainelli
Quoted 4 lines · Andrew Lunn
Quoted 3 lines · David Wu
To make internal phy work, need to configure the
phy_clock, phycru_resetand related registers.Quoted 8 lines
Quoted 4 lines
Signed-off-by David Wu <[email protected]>---
changes in v2:
- Use the standard "phy-mode" property for internal phy. (Florian)I think we need to discuss this. This PHY appears to be on an MDIO bus, it uses a standard PHY driver, and it appears to be using an RMII interface. So it is just an ordinary PHY.
First, the fact that the internal PHY also appears through MDIO is orthogonal to the fact that it is internal or external. Plenty of designs have internal PHYs exposed through MDIO because that is convenient. What matters though is how the data/clock lines are wired internally, which is what "phy-mode" describes.
Quoted 7 lines
Internal is supposed to be something which is not ordinary, does not use one of the standard phy modes, needs something special to make it work.
Florain, it appears to be your suggestion to use internal. What do you say?
phy-mode = "internal" really means that it is not a standard MII variant to connect the data/clock lines between the Ethernet MAC and the PHY, and this can happen in some designs (although quite unlikely). So from there we could do several things depending on the requirements:
- if you can have your Ethernet MAC driver perform the necessary configuration *after* you have been able to bind the PHY device with its PHY driver, then the PHY driver should have
PHY_IS_INTERNALin its flags, and you can usephy_is_internal()from PHYLIB to tell you that and we could imagine using: phy-mode = "rmii" because that would not too much of a stretchQuoted 6 lines
- if you need knowledge about this PHY connection type prior to binding the PHY device and its driver (that is, before
of_phy_connect()) we could add a boolean property e.g: "phy-is-internal" that allows us to know that, or we can have a new phy-mode value, e.g: "internal-rmii" which describes that, either way would probably be fine, but the former scales better
Quoted 5 lines
We have the same problem on Allwinner SoCs for dwmac-sun8i, we need to set a syscon for chossing between internal/external PHY.
Having this phy-is-internal would be very helpfull. (adding internal-xmii will add too many flags in our case)
In our case, we'll always have a phy node, so we can have a compatible that will give you the same information.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170728/c65c919d/attachment-0001.sig>
Re: [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
In reply to Florian FainelliHi Florian,
? 2017/7/28 0:54, Florian Fainelli ??:
Quoted 7 lines
- if you need knowledge about this PHY connection type prior to binding the PHY device and its driver (that is, before
of_phy_connect()) we could add a boolean property e.g: "phy-is-internal" that allows us to know that, or we can have a new phy-mode value, e.g: "internal-rmii" which describes that, either way would probably be fine, but the former scales better
Using "phy-is-internal" is very helpful, but it is easy to confuse with the real internal PHY, may we use the other words like phy is inlined?.
Quoted 4 lines
Then again, using phy-mode = "internal" even though this is Reduced MII is not big of a deal IMHO as long as there is no loss of information and that internal de-facto means internal reduced MII for instance.
Re: [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
Hi David, Florian, Andrew,
Quoted 12 lines · David.Wu
Hi Florian,
Quoted 8 lines · Florian Fainelli
- if you need knowledge about this PHY connection type prior to binding the PHY device and its driver (that is, before
of_phy_connect()) we could add a boolean property e.g: "phy-is-internal" that allows us to know that, or we can have a new phy-mode value, e.g: "internal-rmii" which describes that, either way would probably be fine, but the former scales better
Quoted 4 lines
Using "phy-is-internal" is very helpful, but it is easy to confuse with the real internal PHY, may we use the other words like phy is inlined🙂.
If "internal" is confusing, would "phy-is-integrated" in the MAC node work?
Either way we would like to have a definitive solution to this. Our dwmac-sun8i driver is already in v4.13-rc1, with a somewhat flaky method of knowing whether the internal PHY is used (phy-mode = "mii").
We really want a fix for this release, otherwise we would be force to revert either the internal PHY part or the whole driver.
ChenYu
Then again, using phy-mode = "internal" even though this is Reduced MII
Quoted 11 lines
Quoted 4 lines
is not big of a deal IMHO as long as there is no loss of information and that internal de-facto means internal reduced MII for instance. --
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
In reply to David.WuHi David, Florian, Andrew
(resent in plain text)
Quoted 13 lines · David.Wu
Hi Florian,
? 2017/7/28 0:54, Florian Fainelli ??:
Quoted 8 lines
- if you need knowledge about this PHY connection type prior to binding the PHY device and its driver (that is, before
of_phy_connect()) we could add a boolean property e.g: "phy-is-internal" that allows us to know that, or we can have a new phy-mode value, e.g: "internal-rmii" which describes that, either way would probably be fine, but the former scales better
Quoted 2 lines
Using "phy-is-internal" is very helpful, but it is easy to confuse with the real internal PHY, may we use the other words like phy is inlined.
If "internal" is confusing, would "phy-is-integrated" in the MAC node work?
Either way we would like to have a definitive solution to this. Our dwmac-sun8i driver is already in v4.13-rc1, with a somewhat flaky method of knowing whether the internal PHY is used (phy-mode = "mii").
We really want a fix for this release, otherwise we would be force to revert either the internal PHY part or the whole driver.
ChenYu
Quoted 12 lines
Quoted 5 lines
Then again, using phy-mode = "internal" even though this is Reduced MII is not big of a deal IMHO as long as there is no loss of information and that internal de-facto means internal reduced MII for instance. --
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v2 05/11] net: stmmac: dwmac-rk: Add internal phy support
In reply to Andrew LunnHi Andrew,
? 2017/7/27 21:48, Andrew Lunn ??:
Quoted 7 lines
I think we need to discuss this. This PHY appears to be on an MDIO bus, it uses a standard PHY driver, and it appears to be using an RMII interface. So it is just an ordinary PHY.
Internal is supposed to be something which is not ordinary, does not use one of the standard phy modes, needs something special to make it work.
Yes, it is a ordinary PHY in fact, using MDIO bus, but it is a internal phy inside Soc, so the "internal" is not the internal as Florain said.
PATCH v2 10/11 ARM64: dts: rockchip: Add gmac2phy node support for rk3328
In reply to David WuThe gmac2phy controller of rk3328 is connected to internal phy directly inside, add the node for the internal phy support.
--- arch/arm64/boot/dts/rockchip/rk3328.dtsi | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/arm64/boot/dts/rockchip/rk3328.dtsi +24 -0
@@ -63,6 +63,8 @@ i2c1 = &i2c1; i2c2 = &i2c2; i2c3 = &i2c3; + ethernet0 = &gmac2io; + ethernet1 = &gmac2phy; }; cpus {
@@ -424,6 +426,28 @@ status = "disabled"; }; + gmac2phy: eth@ff550000 { + compatible = "rockchip,rk3328-gmac"; + reg = <0x0 0xff550000 0x0 0x10000>; + rockchip,grf = <&grf>; + interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq"; + clocks = <&cru SCLK_MAC2PHY_SRC>, <&cru SCLK_MAC2PHY_RXTX>, + <&cru SCLK_MAC2PHY_RXTX>, <&cru SCLK_MAC2PHY_REF>, + <&cru ACLK_MAC2PHY>, <&cru PCLK_MAC2PHY>, + <&cru SCLK_MAC2PHY_OUT>; + clock-names = "stmmaceth", "mac_clk_rx", + "mac_clk_tx", "clk_mac_ref", + "aclk_mac", "pclk_mac", + "clk_macphy"; + resets = <&cru SRST_GMAC2PHY_A>, <&cru SRST_MACPHY>; + reset-names = "stmmaceth", "mac-phy"; + phy-mode = "internal"; + pinctrl-names = "default"; + pinctrl-0 = <&fephyled_rxm1 &fephyled_linkm1>; + status = "disabled"; + }; + gic: interrupt-controller@ff811000 { compatible = "arm,gic-400"; #interrupt-cells = <3>;
Signature · 1 line
1.9.1
PATCH v2 11/11 ARM64: dts: rockchip: Enable gmac2phy for rk3328-evb
In reply to David WuEnable the gmac2phy, make the gmac2phy work on
the rk3328-evb board.
--- arch/arm64/boot/dts/rockchip/rk3328-evb.dts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
arch/arm64/boot/dts/rockchip/rk3328-evb.dts +17 -0
@@ -50,6 +50,23 @@ chosen { stdout-path = "serial2:1500000n8"; }; + + vcc_phy: vcc-phy-regulator { + compatible = "regulator-fixed"; + regulator-name = "vcc_phy"; + regulator-always-on; + regulator-boot-on; + }; +}; + +&gmac2phy { + phy-supply = <&vcc_phy>; + clock_in_out = "output"; + assigned-clocks = <&cru SCLK_MAC2PHY_SRC>; + assigned-clock-rate = <50000000>; + assigned-clocks = <&cru SCLK_MAC2PHY>; + assigned-clock-parents = <&cru SCLK_MAC2PHY_SRC>; + status = "okay"; }; &uart2 {
Signature · 1 line
1.9.1