sunxi: A83T improvements
cover sunxi: A83T improvements
Hi,
This series is a bunch of improvements for A83T boards, the Bananapi M3 and Cubietruck Plus in particular:
- eMMC is enabled if it wasn't enabled already
- EMAC is enabled for Ethernet support
- MUSB switched to gadget mode
EMAC is not fully tested. The MII and auto-negotiation part looks good. But I got "CACHE: Misaligned operation at range [bbf38940, bbf38a18]" when the EMAC is first initialized and I didn't seem to be getting any packets through. AFAIK the EMAC is the same as the H3/H5 one, minus the internal PHY support. So it should just work, and if it doesn't then the problem lies elsewhere. If this is not acceptable, feel free to drop the last four patches.
ChenYu
Chen-Yu Tsai (9):
sunxi: rename Bananapi M3 dts file name
sunxi: Enable eMMC on Cubietruck Plus
sunxi: Fix USB PHY control register offset for A83T
sunxi: Switch MUSB to gadget mode on the Bananapi M3
sunxi: Switch MUSB to gadget mode on the Cubietruck Plus
net: sun8i_emac: Support RX/TX delay chains
net: sun8i_emac: Fix build for non-H3/H5 SoCs
sunxi: Enable EMAC on the Cubietruck Plus
sunxi: Enable EMAC on the Bananapi M3
arch/arm/dts/Makefile | 4 +--
arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi | 41 ++++++++++++++++++++++
...ovoip-bpi-m3.dts => sun8i-a83t-bananapi-m3.dts} | 0
.../arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi | 39 ++++++++++++++++++++
arch/arm/mach-sunxi/usb_phy.c | 2 +-
configs/Cubietruck_plus_defconfig | 4 ++-
configs/Sinovoip_BPI_M3_defconfig | 5 +--
drivers/net/sun8i_emac.c | 28 +++++++++++++++
8 files changed, 117 insertions(+), 6 deletions(-)
create mode 100644 arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi
rename arch/arm/dts/{sun8i-a83t-sinovoip-bpi-m3.dts => sun8i-a83t-bananapi-m3.dts} (100%)
create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsiSignature · 1 line
2.14.1
PATCH 1/9 sunxi: rename Bananapi M3 dts file name
The upstream (Linux) device tree file for the Bananapi M3 follows the convention of using the well known brand name, instead of the vendor name, for naming. The file was recently added to upstream in commit 359b5a1e1c2d ("ARM: sun8i: a83t: Add device tree for Sinovoip Bananapi BPI-M3")
Rename the device tree file in U-boot to match.
---
arch/arm/dts/Makefile | 4 ++--
.../{sun8i-a83t-sinovoip-bpi-m3.dts => sun8i-a83t-bananapi-m3.dts} | 0
configs/Sinovoip_BPI_M3_defconfig | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
rename arch/arm/dts/{sun8i-a83t-sinovoip-bpi-m3.dts => sun8i-a83t-bananapi-m3.dts} (100%)arch/arm/dts/Makefile +2 -2
@@ -307,8 +307,8 @@ dtb-$(CONFIG_MACH_SUN8I_A33) += \ sun8i-r16-parrot.dtb dtb-$(CONFIG_MACH_SUN8I_A83T) += \ sun8i-a83t-allwinner-h8homlet-v2.dtb \ - sun8i-a83t-cubietruck-plus.dtb \ - sun8i-a83t-sinovoip-bpi-m3.dtb + sun8i-a83t-bananapi-m3.dtb \ + sun8i-a83t-cubietruck-plus.dtb dtb-$(CONFIG_MACH_SUN8I_H3) += \ sun8i-h2-plus-orangepi-zero.dtb \ sun8i-h3-bananapi-m2-plus.dtb \
arch/arm/dts/sun8i-a83t-bananapi-m3.dts renamed from arch/arm/dts/sun8i-a83t-sinovoip-bpi-m3.dts +0 -0
configs/Sinovoip_BPI_M3_defconfig +1 -1
@@ -13,7 +13,7 @@ CONFIG_USB0_ID_DET="PH11" CONFIG_USB1_VBUS_PIN="PD24" CONFIG_AXP_GPIO=y CONFIG_SATAPWR="PD25" -CONFIG_DEFAULT_DEVICE_TREE="sun8i-a83t-sinovoip-bpi-m3" +CONFIG_DEFAULT_DEVICE_TREE="sun8i-a83t-bananapi-m3" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set CONFIG_CONSOLE_MUX=y CONFIG_SPL=y
Signature · 1 line
2.14.1
Maxime Ripard
AppliedPATCH 1/9 sunxi: rename Bananapi M3 dts file name
Quoted 9 lines · Chen-Yu Tsai
The upstream (Linux) device tree file for the Bananapi M3 follows the convention of using the well known brand name, instead of the vendor name, for naming. The file was recently added to upstream in commit
359b5a1e1c2d("ARM: sun8i: a83t: Add device tree for Sinovoip Bananapi BPI-M3")Rename the device tree file in U-boot to match.
Signed-off-by Chen-Yu Tsai <[email protected]>
Applied, thanks!
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.denx.de/pipermail/u-boot/attachments/20170922/44f035ba/attachment.sig>
PATCH 2/9 sunxi: Enable eMMC on Cubietruck Plus
In reply to Chen-Yu TsaiSet CONFIG_MMC_SUNXI_SLOT_EXTRA=2 to enable the eMMC controller to access eMMC on the board.
--- configs/Cubietruck_plus_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/Cubietruck_plus_defconfig +1 -0
@@ -4,6 +4,7 @@ CONFIG_MACH_SUN8I_A83T=y CONFIG_DRAM_CLK=672 CONFIG_DRAM_ZQ=15355 CONFIG_DRAM_ODT_EN=y +CONFIG_MMC_SUNXI_SLOT_EXTRA=2 CONFIG_USB0_VBUS_PIN="AXP0-VBUS-ENABLE" CONFIG_USB0_VBUS_DET="AXP0-VBUS-DETECT" CONFIG_USB0_ID_DET="PH11"
Signature · 1 line
2.14.1
Maxime Ripard
AppliedPATCH 2/9 sunxi: Enable eMMC on Cubietruck Plus
Quoted 4 lines · Chen-Yu Tsai
Set
CONFIG_MMC_SUNXI_SLOT_EXTRA=2to enable the eMMC controller to access eMMC on the board.Signed-off-by Chen-Yu Tsai <[email protected]>
Applied, thanks!
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.denx.de/pipermail/u-boot/attachments/20170922/1dfc1045/attachment.sig>
PATCH 3/9 sunxi: Fix USB PHY control register offset for A83T
In reply to Chen-Yu TsaiIt was recently discovered that the USB PHY control register offset on the A83T is 0x410 like on the A33, not 0x404. Fix it.
--- arch/arm/mach-sunxi/usb_phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-sunxi/usb_phy.c +1 -1
@@ -19,7 +19,7 @@#include <errno.h> #define SUNXI_USB_PMU_IRQ_ENABLE 0x800 -#ifdef CONFIG_MACH_SUN8I_A33 +#if definedCONFIG_MACH_SUN8I_A33 || definedCONFIG_MACH_SUN8I_A83T #define SUNXI_USB_CSR 0x410#else #define SUNXI_USB_CSR 0x404
Signature · 1 line
2.14.1
PATCH 3/9 sunxi: Fix USB PHY control register offset for A83T
Hi
Quoted 5 lines · Chen-Yu Tsai
It was recently discovered that the USB PHY control register offset on the A83T is
0x410like on the A33, not0x404. Fix it.Fixes 0c935acb9e5d ("sunxi: usb_phy: Add support for A83T USB PHYs")Signed-off-by Chen-Yu Tsai <[email protected]>
Ok, so I think I screw this one up.
I had already a patch for that that was queued by Jagan into another branch.
I've merged both branches, it should superseed this patch.
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.denx.de/pipermail/u-boot/attachments/20170922/22505beb/attachment.sig>
PATCH 4/9 sunxi: Switch MUSB to gadget mode on the Bananapi M3
In reply to Chen-Yu TsaiThe Bananapi M3 has a micro-USB OTG port. It supports both host and gadget mode. Having the OTG port operate in gadget mode is more useful, as we can use it for fastboot or Ethernet over USB.
The board has 2 other USB host ports that are supported. These can be used for connecting peripherals.
--- configs/Sinovoip_BPI_M3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configs/Sinovoip_BPI_M3_defconfig +1 -1
@@ -27,5 +27,5 @@ CONFIG_AXP_DCDC5_VOLT=1200 CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_SW_ON=y CONFIG_USB_EHCI_HCD=y -CONFIG_USB_MUSB_HOST=y +CONFIG_USB_MUSB_GADGET=y CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
Signature · 1 line
2.14.1
PATCH 4/9 sunxi: Switch MUSB to gadget mode on the Bananapi M3
Quoted 17 lines · Chen-Yu Tsai
The Bananapi M3 has a micro-USB OTG port. It supports both host and gadget mode. Having the OTG port operate in gadget mode is more useful, as we can use it for fastboot or Ethernet over USB.
The board has 2 other USB host ports that are supported. These can be used for connecting peripherals.
Signed-off-by Chen-Yu Tsai <[email protected]>--- configs/Sinovoip_BPI_M3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)configs/Sinovoip_BPI_M3_defconfig +0
-0
configs/Sinovoip_BPI_M3_defconfig CONFIG_AXP_DCDC5_VOLT=1200 · line 30
Quoted 5 lines
configs/Sinovoip_BPI_M3_defconfig +1
-1@@ -27,5 +27,5 @@ CONFIG_AXP_DCDC5_VOLT=1200 CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_SW_ON=y CONFIG_USB_EHCI_HCD=y -CONFIG_USB_MUSB_HOST=y +CONFIG_USB_MUSB_GADGET=y
I wonder whether this could become the default.
As far as I can see, having it as host can only be useful on the tablets we support.
Maybe we can add a config option for tablets device, and if it's set, enable in host mode, and if not defaults to gadget.
Eventually, we could move all the options that are not really useful on anything but a tablet that we currently select, like USB_KEYBOARD
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.denx.de/pipermail/u-boot/attachments/20170922/f01dffe8/attachment.sig>
PATCH 4/9 sunxi: Switch MUSB to gadget mode on the Bananapi M3
Quoted 26 lines · Maxime Ripard
Quoted 17 lines · Chen-Yu Tsai
The Bananapi M3 has a micro-USB OTG port. It supports both host and gadget mode. Having the OTG port operate in gadget mode is more useful, as we can use it for fastboot or Ethernet over USB.
The board has 2 other USB host ports that are supported. These can be used for connecting peripherals.
Signed-off-by Chen-Yu Tsai <[email protected]>--- configs/Sinovoip_BPI_M3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)configs/Sinovoip_BPI_M3_defconfig +0
-0configs/Sinovoip_BPI_M3_defconfig CONFIG_AXP_DCDC5_VOLT=1200 · line 30
Quoted 5 lines
configs/Sinovoip_BPI_M3_defconfig +1
-1@@ -27,5 +27,5 @@ CONFIG_AXP_DCDC5_VOLT=1200 CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_SW_ON=y CONFIG_USB_EHCI_HCD=y -CONFIG_USB_MUSB_HOST=y +CONFIG_USB_MUSB_GADGET=yI wonder whether this could become the default.
Quoted 8 lines
As far as I can see, having it as host can only be useful on the tablets we support.
Maybe we can add a config option for tablets device, and if it's set, enable in host mode, and if not defaults to gadget.
Eventually, we could move all the options that are not really useful on anything but a tablet that we currently select, like
USB_KEYBOARD
There are also the cases where the OTG controller is routed to a USB host port. These are likely set top boxes. It would probably be better to have the user be able to explicitly set it to gadget mode if they want to do development, but otherwise be in host mode by default.
ChenYu
PATCH 4/9 sunxi: Switch MUSB to gadget mode on the Bananapi M3
Quoted 34 lines · Chen-Yu Tsai
Quoted 32 lines · Maxime Ripard
Quoted 17 lines · Chen-Yu Tsai
The Bananapi M3 has a micro-USB OTG port. It supports both host and gadget mode. Having the OTG port operate in gadget mode is more useful, as we can use it for fastboot or Ethernet over USB.
The board has 2 other USB host ports that are supported. These can be used for connecting peripherals.
Signed-off-by Chen-Yu Tsai <[email protected]>--- configs/Sinovoip_BPI_M3_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)configs/Sinovoip_BPI_M3_defconfig +0
-0configs/Sinovoip_BPI_M3_defconfig CONFIG_AXP_DCDC5_VOLT=1200 · line 30
Quoted 5 lines
configs/Sinovoip_BPI_M3_defconfig +1
-1@@ -27,5 +27,5 @@ CONFIG_AXP_DCDC5_VOLT=1200 CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_SW_ON=y CONFIG_USB_EHCI_HCD=y -CONFIG_USB_MUSB_HOST=y +CONFIG_USB_MUSB_GADGET=yI wonder whether this could become the default.
As far as I can see, having it as host can only be useful on the tablets we support.
Maybe we can add a config option for tablets device, and if it's set, enable in host mode, and if not defaults to gadget.
Quoted 7 lines
Quoted 2 lines
Eventually, we could move all the options that are not really useful on anything but a tablet that we currently select, like
USB_KEYBOARDThere are also the cases where the OTG controller is routed to a USB host port. These are likely set top boxes. It would probably be better to have the user be able to explicitly set it to gadget mode if they want to do development, but otherwise be in host mode by default.
I don't know, maybe I'm heavily (confirmation) biased, but I've seen far more people using the micro USB as a gadget (or at least, not as a host, just powering the board), than people using it as hosts.
Actually, apart from the boards that are wiring it to an USB-A connector, I haven't seen anyone use that kind of setup, ever.
For the tablets where it's your only option to interact with the device since you don't have any UARTs, it makes sense. Same thing for the ones that wire it to a USB-A connector. But for all the boards out there with a micro or mini USB connector that can power them, I really feel like the default should be to a gadget.
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.denx.de/pipermail/u-boot/attachments/20170922/e4c8c690/attachment.sig>
PATCH 5/9 sunxi: Switch MUSB to gadget mode on the Cubietruck Plus
In reply to Chen-Yu TsaiThe Cubietruck Plus has a micro-USB OTG port. It supports both host and gadget mode. Having the OTG port operate in gadget mode is more useful, as we can use it for fastboot or Ethernet over USB.
The board has 2 other USB host ports that are supported. These can be used for connecting peripherals.
--- configs/Cubietruck_plus_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configs/Cubietruck_plus_defconfig +1 -1
@@ -26,5 +26,5 @@ CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_DLDO4_VOLT=3300 CONFIG_AXP_FLDO1_VOLT=1200 CONFIG_USB_EHCI_HCD=y -CONFIG_USB_MUSB_HOST=y +CONFIG_USB_MUSB_GADGET=y CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE=y
Signature · 1 line
2.14.1
PATCH 6/9 net: sun8i_emac: Support RX/TX delay chains
In reply to Chen-Yu TsaiThe EMAC syscon has configurable RX/TX delay chains for use with RGMII PHYs.
This adds support for configuring them via device tree properties. The property names and format were defined in Linux's dwmac-sun8i binding that was merged at one point.
--- drivers/net/sun8i_emac.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/net/sun8i_emac.c +25 -0
@@ -56,6 +56,10 @@#define H3_EPHY_SELECT BIT(15)/* 1: internal PHY, 0: external PHY */ #define SC_RMII_EN BIT(13) +#define SC_TXDC_SHIFT 10 +#define SC_TXDC_MASK GENMASK(2, 0) +#define SC_RXDC_SHIFT 5 +#define SC_RXDC_MASK GENMASK(4, 0)#define SC_EPIT BIT(2)/* 1: RGMII, 0: MII */ #define SC_ETCS_MASK GENMASK(1, 0)#define SC_ETCS_EXT_GMII 0x1
@@ -125,6 +129,8 @@ struct emac_eth_dev {u32 addr;u32 tx_slot;bool use_internal_phy; +u32 tx_delay; +u32 rx_delay;enum emac_variant variant;void *mac_reg;
@@ -290,6 +296,12 @@ static int sun8i_emac_set_syscon(struct emac_eth_dev *priv)if (priv->variant ==H3_EMAC || priv->variant ==A64_EMAC ) reg &= ~SC_RMII_EN ; +/* Configure RX/TX delay chains */ + reg &= ~(SC_RXDC_MASK <<SC_RXDC_SHIFT ); + reg &= ~(SC_TXDC_MASK <<SC_TXDC_SHIFT ); + reg |= (priv->rx_delay &SC_RXDC_MASK ) <<SC_RXDC_SHIFT ; + reg |= (priv->tx_delay &SC_TXDC_MASK ) <<SC_TXDC_SHIFT ; +switch (priv->interface) {case PHY_INTERFACE_MODE_MII :/* default */
@@ -836,6 +848,19 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) }#endif +/* Get RX/TX delays for RGMII */ + priv->rx_delay =fdtdec_get_uint (gd->fdt_blob,dev_of_offset (dev), +"allwinner,rx-delay-ps" ,0 ); +if (priv->rx_delay %100 || priv->rx_delay >3100 ) +debug ("%s: invalid rx delay value\n" , __func__); + priv->rx_delay /=100 ; + + priv->tx_delay =fdtdec_get_uint (gd->fdt_blob,dev_of_offset (dev), +"allwinner,tx-delay-ps" ,0 ); +if (priv->tx_delay %100 || priv->tx_delay >800 ) +debug ("%s: invalid tx delay value\n" , __func__); + priv->tx_delay /=100 ; +return 0 ; }
Signature · 1 line
2.14.1
PATCH 6/9 net: sun8i_emac: Support RX/TX delay chains
Quoted 8 lines · Chen-Yu Tsai
The EMAC syscon has configurable RX/TX delay chains for use with RGMII PHYs.
This adds support for configuring them via device tree properties. The property names and format were defined in Linux's dwmac-sun8i binding that was merged at one point.
Signed-off-by Chen-Yu Tsai <[email protected]>
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.denx.de/pipermail/u-boot/attachments/20170922/79277068/attachment.sig>
PATCH 6/9 net: sun8i_emac: Support RX/TX delay chains
In reply to Chen-Yu TsaiQuoted 37 lines · Chen-Yu Tsai
The EMAC syscon has configurable RX/TX delay chains for use with RGMII PHYs.
This adds support for configuring them via device tree properties. The property names and format were defined in Linux's dwmac-sun8i binding that was merged at one point.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/net/sun8i_emac.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/net/sun8i_emac.c +6
-0@@ -56,6 +56,10 @@#define H3_EPHY_SELECT BIT(15)/* 1: internal PHY, 0: external PHY */ #define SC_RMII_EN BIT(13) +#define SC_TXDC_SHIFT 10 +#define SC_TXDC_MASK GENMASK(2, 0) +#define SC_RXDC_SHIFT 5 +#define SC_RXDC_MASK GENMASK(4, 0)#define SC_EPIT BIT(2)/* 1: RGMII, 0: MII */ #define SC_ETCS_MASK GENMASK(1, 0)#define SC_ETCS_EXT_GMII 0x1@@ -125,6 +129,8 @@ struct emac_eth_dev {u32 addr;u32 tx_slot;bool use_internal_phy; +u32 tx_delay; +u32 rx_delay;enum emac_variant variant;void *mac_reg;
drivers/net/sun8i_emac.c static int sun8i_emac_set_syscon(struct emac_eth_dev *priv) · line 303
Quoted 8 lines
drivers/net/sun8i_emac.c +5
-0@@ -290,6 +296,12 @@ static int sun8i_emac_set_syscon(struct emac_eth_dev *priv)if (priv->variant ==H3_EMAC || priv->variant ==A64_EMAC ) reg &= ~SC_RMII_EN ; +/* Configure RX/TX delay chains */ + reg &= ~(SC_RXDC_MASK <<SC_RXDC_SHIFT ); + reg &= ~(SC_TXDC_MASK <<SC_TXDC_SHIFT ); + reg |= (priv->rx_delay &SC_RXDC_MASK ) <<SC_RXDC_SHIFT ; + reg |= (priv->tx_delay &SC_TXDC_MASK ) <<SC_TXDC_SHIFT ;
Why not use bitfield_replace_by_mask() from include/bitfield.h?
Quoted 31 lines
drivers/net/sun8i_emac.c +14
-1+switch (priv->interface) {case PHY_INTERFACE_MODE_MII :/* default */ @@ -836,6 +848,19 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) }#endif +/* Get RX/TX delays for RGMII */ + priv->rx_delay =fdtdec_get_uint (gd->fdt_blob,dev_of_offset (dev), +"allwinner,rx-delay-ps" ,0 ); +if (priv->rx_delay %100 || priv->rx_delay >3100 ) +debug ("%s: invalid rx delay value\n" , __func__); + priv->rx_delay /=100 ; + + priv->tx_delay =fdtdec_get_uint (gd->fdt_blob,dev_of_offset (dev), +"allwinner,tx-delay-ps" ,0 ); +if (priv->tx_delay %100 || priv->tx_delay >800 ) +debug ("%s: invalid tx delay value\n" , __func__); + priv->tx_delay /=100 ; +return 0 ; } --2.14.1
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 6/9 net: sun8i_emac: Support RX/TX delay chains
Quoted 41 lines · Joe Hershberger
Quoted 40 lines · Chen-Yu Tsai
The EMAC syscon has configurable RX/TX delay chains for use with RGMII PHYs.
This adds support for configuring them via device tree properties. The property names and format were defined in Linux's dwmac-sun8i binding that was merged at one point.
Signed-off-by Chen-Yu Tsai <[email protected]>--- drivers/net/sun8i_emac.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)drivers/net/sun8i_emac.c +6
-0@@ -56,6 +56,10 @@#define H3_EPHY_SELECT BIT(15)/* 1: internal PHY, 0: external PHY */ #define SC_RMII_EN BIT(13) +#define SC_TXDC_SHIFT 10 +#define SC_TXDC_MASK GENMASK(2, 0) +#define SC_RXDC_SHIFT 5 +#define SC_RXDC_MASK GENMASK(4, 0)#define SC_EPIT BIT(2)/* 1: RGMII, 0: MII */ #define SC_ETCS_MASK GENMASK(1, 0)#define SC_ETCS_EXT_GMII 0x1@@ -125,6 +129,8 @@ struct emac_eth_dev {u32 addr;u32 tx_slot;bool use_internal_phy; +u32 tx_delay; +u32 rx_delay;enum emac_variant variant;void *mac_reg;@@ -290,6 +296,12 @@ static int sun8i_emac_set_syscon(struct emac_eth_dev *priv)if (priv->variant ==H3_EMAC || priv->variant ==A64_EMAC ) reg &= ~SC_RMII_EN ;
Quoted 7 lines
drivers/net/sun8i_emac.c static int sun8i_emac_set_syscon(struct emac_eth_dev *priv) · line 303
Quoted 5 lines
drivers/net/sun8i_emac.c +5
-0+/* Configure RX/TX delay chains */ + reg &= ~(SC_RXDC_MASK <<SC_RXDC_SHIFT ); + reg &= ~(SC_TXDC_MASK <<SC_TXDC_SHIFT ); + reg |= (priv->rx_delay &SC_RXDC_MASK ) <<SC_RXDC_SHIFT ; + reg |= (priv->tx_delay &SC_TXDC_MASK ) <<SC_TXDC_SHIFT ;Why not use
bitfield_replace_by_mask()frominclude/bitfield.h?
Because I wasn't aware of such helpers. If that's preferred I'll respin the patch.
ChenYu
Quoted 31 lines
Quoted 31 lines
drivers/net/sun8i_emac.c +14
-1+switch (priv->interface) {case PHY_INTERFACE_MODE_MII :/* default */ @@ -836,6 +848,19 @@ static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev) }#endif +/* Get RX/TX delays for RGMII */ + priv->rx_delay =fdtdec_get_uint (gd->fdt_blob,dev_of_offset (dev), +"allwinner,rx-delay-ps" ,0 ); +if (priv->rx_delay %100 || priv->rx_delay >3100 ) +debug ("%s: invalid rx delay value\n" , __func__); + priv->rx_delay /=100 ; + + priv->tx_delay =fdtdec_get_uint (gd->fdt_blob,dev_of_offset (dev), +"allwinner,tx-delay-ps" ,0 ); +if (priv->tx_delay %100 || priv->tx_delay >800 ) +debug ("%s: invalid tx delay value\n" , __func__); + priv->tx_delay /=100 ; +return 0 ; } --2.14.1
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 7/9 net: sun8i_emac: Fix build for non-H3/H5 SoCs
In reply to Chen-Yu TsaiOnly the H3/H5 SoCs have an internal PHY and its related clock and reset controls.
Use an #ifdef to guard the internal PHY control code block so it can be built for other SoCs, such as the A83T or A64.
--- drivers/net/sun8i_emac.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/sun8i_emac.c +3 -0
@@ -616,6 +616,8 @@ static void sun8i_emac_board_setup(struct emac_eth_dev *priv) {struct sunxi_ccm_reg *ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE ; +#ifdef CONFIG_MACH_SUNXI_H3_H5 +/* Only H3/H5 have clock controls for internal EPHY */ if (priv->use_internal_phy) {/* Set clock gating for ephy */ setbits_le32 (&ccm->bus_gate4,BIT (AHB_GATE_OFFSET_EPHY ));
@@ -623,6 +625,7 @@ static void sun8i_emac_board_setup(struct emac_eth_dev *priv)/* Deassert EPHY */ setbits_le32(&ccm->ahb_reset2_cfg, BIT(AHB_RESET_OFFSET_EPHY)); } +#endif /* Set clock gating for emac */ setbits_le32 (&ccm->ahb_gate0,BIT (AHB_GATE_OFFSET_GMAC ));
Signature · 1 line
2.14.1
PATCH 7/9 net: sun8i_emac: Fix build for non-H3/H5 SoCs
Quoted 7 lines · Chen-Yu Tsai
Only the H3/H5 SoCs have an internal PHY and its related clock and reset controls.
Use an #ifdef to guard the internal PHY control code block so it can be built for other SoCs, such as the A83T or A64.
Signed-off-by Chen-Yu Tsai <[email protected]>
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.denx.de/pipermail/u-boot/attachments/20170922/f21dce32/attachment.sig>
PATCH 7/9 net: sun8i_emac: Fix build for non-H3/H5 SoCs
In reply to Chen-Yu TsaiQuoted 7 lines · Chen-Yu Tsai
Only the H3/H5 SoCs have an internal PHY and its related clock and reset controls.
Use an #ifdef to guard the internal PHY control code block so it can be built for other SoCs, such as the A83T or A64.
Signed-off-by Chen-Yu Tsai <[email protected]>
PATCH 7/9 net: sun8i_emac: Fix build for non-H3/H5 SoCs
Quoted 10 lines · Joe Hershberger
Quoted 7 lines · Chen-Yu Tsai
Only the H3/H5 SoCs have an internal PHY and its related clock and reset controls.
Use an #ifdef to guard the internal PHY control code block so it can be built for other SoCs, such as the A83T or A64.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Joe Hershberger <[email protected]>
This hasn't been applied yet. Can someone apply this? Jagan?
Thanks
ChenYu
PATCH 7/9 net: sun8i_emac: Fix build for non-H3/H5 SoCs
Quoted 6 lines · Chen-Yu Tsai
Quoted 4 lines · Joe Hershberger
Quoted 3 lines · Chen-Yu Tsai
Only the H3/H5 SoCs have an internal PHY and its related clock and reset controls.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Use an #ifdef to guard the internal PHY control code block so it can be built for other SoCs, such as the A83T or A64.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Joe Hershberger <[email protected]>This hasn't been applied yet. Can someone apply this? Jagan?
Few emac patches on this series still under review, was this independent fix?
Signature · 4 lines
Jagan Teki Free Software Engineer | www.openedev.com U-Boot, Linux | Upstream Maintainer Hyderabad, India.
PATCH 7/9 net: sun8i_emac: Fix build for non-H3/H5 SoCs
Quoted 10 lines · Jagan Teki
Quoted 9 lines · Chen-Yu Tsai
Quoted 7 lines · Joe Hershberger
Quoted 6 lines · Chen-Yu Tsai
Only the H3/H5 SoCs have an internal PHY and its related clock and reset controls.
Use an #ifdef to guard the internal PHY control code block so it can be built for other SoCs, such as the A83T or A64.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Joe Hershberger <[email protected]>This hasn't been applied yet. Can someone apply this? Jagan?
Few emac patches on this series still under review, was this independent fix?
I would consider it an independent fix. Nothing prevents people from manually enabling the EMAC driver on other SoCs. They will then get a build fail that this patch fixes.
As for the other patches, I respin them soon enough.
ChenYu
PATCH 7/9 net: sun8i_emac: Fix build for non-H3/H5 SoCs
Quoted 17 lines · Chen-Yu Tsai
Quoted 16 lines · Jagan Teki
Quoted 14 lines · Chen-Yu Tsai
Quoted 10 lines · Joe Hershberger
Quoted 7 lines · Chen-Yu Tsai
Only the H3/H5 SoCs have an internal PHY and its related clock and reset controls.
Use an #ifdef to guard the internal PHY control code block so it can be built for other SoCs, such as the A83T or A64.
Signed-off-by Chen-Yu Tsai <[email protected]>Reviewed-by Joe Hershberger <[email protected]>This hasn't been applied yet. Can someone apply this? Jagan?
Quoted 7 lines
Quoted 1 line
Few emac patches on this series still under review, was this independent fix?
I would consider it an independent fix. Nothing prevents people from manually enabling the EMAC driver on other SoCs. They will then get a build fail that this patch fixes.
As for the other patches, I respin them soon enough.
Applied to u-boot-sunxi/master
thanks!
Signature · 4 lines
Jagan Teki Free Software Engineer | www.openedev.com U-Boot, Linux | Upstream Maintainer Hyderabad, India.
PATCH 8/9 sunxi: Enable EMAC on the Cubietruck Plus
In reply to Chen-Yu TsaiThe Cubietruck Plus has an RTL8211E PHY connected to the EMAC using RGMII. The PHY is powered by DLDO4 @ 3.3V, while the I/O pins are powered by DLDO3 @ 2.5V.
This patch adds a U-boot specific dtsi file for the board adding an enabled EMAC node, and enables the EMAC driver in the defconfig. The binding used here is the old revision currently supported in U-boot. There is no stable binding nor support in upstream Linux at this time.
--- .../arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi | 39 ++++++++++++++++++++++ configs/Cubietruck_plus_defconfig | 1 + 2 files changed, 40 insertions(+) create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi
arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi new file +39 -0
@@ -0,0 +1,39 @@ +#include "sunxi-u-boot.dtsi" + +/ { + aliases { + ethernet0 = &emac; + }; + + soc { + emac: ethernet at 01c30000 { + compatible = "allwinner,sun8i-a83t-emac"; + reg = <0x01c30000 0x2000>, <0x01c00030 0x4>; + reg-names = "emac", "syscon"; + interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&rgmii_pins>; + phy-mode = "rgmii"; + phy = <&phy1>; + status = "okay"; + + phy1: ethernet-phy at 1 { + reg = <1>; + }; + }; + }; +}; + +&pio { + rgmii_pins: rgmii_pins { + allwinner,pins = "PD8", "PD9", "PD10", "PD11", + "PD12", "PD13", "PD15", + "PD16", "PD17", "PD18", "PD19", + "PD20", "PD21", "PD22", "PD23"; + allwinner,function = "emac"; + allwinner,drive = <3>; + allwinner,pull = <0>; + }; +};
configs/Cubietruck_plus_defconfig +1 -0
@@ -22,6 +22,7 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUN8I_EMAC=y CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_DLDO4_VOLT=3300 CONFIG_AXP_FLDO1_VOLT=1200
Signature · 1 line
2.14.1
PATCH 9/9 sunxi: Enable EMAC on the Bananapi M3
In reply to Chen-Yu TsaiThe Bananapi M3 has an RTL8211E PHY connected to the EMAC using RGMII. The PHY is powered by DCDC1 through SW @ 3.3V.
This patch adds a U-boot specific dtsi file for the board adding an enabled EMAC node, and enables the EMAC driver in the defconfig. The binding used here is the old revision currently supported in U-boot. There is no stable binding nor support in upstream Linux at this time.
--- arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi | 41 +++++++++++++++++++++++++ configs/Sinovoip_BPI_M3_defconfig | 1 + 2 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi
arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi new file +41 -0
@@ -0,0 +1,41 @@ +#include "sunxi-u-boot.dtsi" + +/ { + aliases { + ethernet0 = &emac; + }; + + soc { + emac: ethernet at 01c30000 { + compatible = "allwinner,sun8i-a83t-emac"; + reg = <0x01c30000 0x2000>, <0x01c00030 0x4>; + reg-names = "emac", "syscon"; + interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>; + #address-cells = <1>; + #size-cells = <0>; + pinctrl-names = "default"; + pinctrl-0 = <&rgmii_pins>; + phy-mode = "rgmii"; + phy = <&phy1>; + allwinner,rx-delay-ps = <700>; + allwinner,tx-delay-ps = <700>; + status = "okay"; + + phy1: ethernet-phy at 1 { + reg = <1>; + }; + }; + }; +}; + +&pio { + rgmii_pins: rgmii_pins { + allwinner,pins = "PD8", "PD9", "PD10", "PD11", + "PD12", "PD13", "PD15", + "PD16", "PD17", "PD18", "PD19", + "PD20", "PD21", "PD22", "PD23"; + allwinner,function = "emac"; + allwinner,drive = <3>; + allwinner,pull = <0>; + }; +};
configs/Sinovoip_BPI_M3_defconfig +1 -0
@@ -23,6 +23,7 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUN8I_EMAC=y CONFIG_AXP_DCDC5_VOLT=1200 CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_SW_ON=y
Signature · 1 line
2.14.1