[U-Boot] [PATCH v2 0/5] sunxi: Enable EMAC on various boards

Hi,
This series enables the EMAC for some A83T and A64 boards.
Changes since v1:
- Added "bitfield: Include linux/bitops.h for ffs()" to fix build errors - Use bitfield_replace_by_mask() instead of open coding bitfield ops - Trimmed used pins in the device tree to only those actually needed - Enabled Realtek PHY driver - Added "sunxi: Enable EMAC on the Bananapi M64"
ChenYu
Chen-Yu Tsai (5): bitfield: Include linux/bitops.h for ffs() net: sun8i_emac: Support RX/TX delay chains sunxi: Enable EMAC on the Cubietruck Plus sunxi: Enable EMAC on the Bananapi M3 sunxi: Enable EMAC on the Bananapi M64
arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi | 39 +++++++++++++++++++++ arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi | 40 ++++++++++++++++++++++ .../arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi | 38 ++++++++++++++++++++ configs/Cubietruck_plus_defconfig | 2 ++ configs/Sinovoip_BPI_M3_defconfig | 2 ++ drivers/net/sun8i_emac.c | 22 ++++++++++++ include/bitfield.h | 1 + 7 files changed, 144 insertions(+) create mode 100644 arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi create mode 100644 arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi

bitfield_shift() uses the ffs() function, which is provided by bitops.h.
Explicitly include this header.
Signed-off-by: Chen-Yu Tsai wens@csie.org --- include/bitfield.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/bitfield.h b/include/bitfield.h index a59f3c279aad..adfae49de580 100644 --- a/include/bitfield.h +++ b/include/bitfield.h @@ -37,6 +37,7 @@ * tables which describe all bitfields in all registers. */
+#include <linux/bitops.h> #include <linux/types.h>
/* Produces a mask of set bits covering a range of a uint value */

On Fri, Nov 24, 2017 at 11:08 PM, Chen-Yu Tsai wens@csie.org wrote:
bitfield_shift() uses the ffs() function, which is provided by bitops.h.
Explicitly include this header.
Signed-off-by: Chen-Yu Tsai wens@csie.org
Reviewed-by: Joe Hershberger joe.hershberger@ni.com

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 wens@csie.org --- drivers/net/sun8i_emac.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index 3ccc6b0bb612..ea26450d34bc 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -14,6 +14,7 @@ #include <asm/io.h> #include <asm/arch/clock.h> #include <asm/arch/gpio.h> +#include <bitfield.h> #include <common.h> #include <dm.h> #include <fdt_support.h> @@ -56,6 +57,8 @@ #define H3_EPHY_SELECT BIT(15) /* 1: internal PHY, 0: external PHY */
#define SC_RMII_EN BIT(13) +#define SC_TXDC_MASK GENMASK(12, 10) +#define SC_RXDC_MASK GENMASK(9, 5) #define SC_EPIT BIT(2) /* 1: RGMII, 0: MII */ #define SC_ETCS_MASK GENMASK(1, 0) #define SC_ETCS_EXT_GMII 0x1 @@ -125,6 +128,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 +295,10 @@ 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 = bitfield_replace_by_mask(reg, SC_RXDC_MASK, priv->rx_delay); + reg = bitfield_replace_by_mask(reg, SC_TXDC_MASK, priv->tx_delay); + switch (priv->interface) { case PHY_INTERFACE_MODE_MII: /* default */ @@ -839,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; }

On Fri, Nov 24, 2017 at 11:08 PM, Chen-Yu Tsai wens@csie.org wrote:
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.
I'm not seeing this in doc/device-tree-bindings/net/

On Wed, Dec 6, 2017 at 4:50 AM, Joe Hershberger joe.hershberger@ni.com wrote:
On Fri, Nov 24, 2017 at 11:08 PM, Chen-Yu Tsai wens@csie.org wrote:
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.
I'm not seeing this in doc/device-tree-bindings/net/
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docu...
The bindings have been restored as of v4.15-rc1.
We are following DT bindings as defined in the Linux kernel. Deviation is kept to a minimum, and eliminated if possible. We still need to migrate the driver to the new bindings for the internal PHY bits. But that bit might still be changed during the 4.15 release cycle.
ChenYu

On Tue, Dec 5, 2017 at 8:34 PM, Chen-Yu Tsai wens@csie.org wrote:
On Wed, Dec 6, 2017 at 4:50 AM, Joe Hershberger joe.hershberger@ni.com wrote:
On Fri, Nov 24, 2017 at 11:08 PM, Chen-Yu Tsai wens@csie.org wrote:
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.
I'm not seeing this in doc/device-tree-bindings/net/
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docu...
The bindings have been restored as of v4.15-rc1.
We are following DT bindings as defined in the Linux kernel. Deviation is kept to a minimum, and eliminated if possible. We still need to migrate the driver to the new bindings for the internal PHY bits. But that bit might still be changed during the 4.15 release cycle.
That's good, but we want to have the currently supported bindings copied into the U-Boot tree under doc/device-tree-bindings/net/. Please include a patch that adds the bindings that your driver is using.
Thanks, -Joe

On Thu, Dec 7, 2017 at 4:20 AM, Joe Hershberger joe.hershberger@gmail.com wrote:
On Tue, Dec 5, 2017 at 8:34 PM, Chen-Yu Tsai wens@csie.org wrote:
On Wed, Dec 6, 2017 at 4:50 AM, Joe Hershberger joe.hershberger@ni.com wrote:
On Fri, Nov 24, 2017 at 11:08 PM, Chen-Yu Tsai wens@csie.org wrote:
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.
I'm not seeing this in doc/device-tree-bindings/net/
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docu...
The bindings have been restored as of v4.15-rc1.
We are following DT bindings as defined in the Linux kernel. Deviation is kept to a minimum, and eliminated if possible. We still need to migrate the driver to the new bindings for the internal PHY bits. But that bit might still be changed during the 4.15 release cycle.
That's good, but we want to have the currently supported bindings copied into the U-Boot tree under doc/device-tree-bindings/net/. Please include a patch that adds the bindings that your driver is using.
Looks like this is a new requirement. Or it wasn't really enforced before. Doesn't this make U-boot prone to having diverging device tree bindings? It has already happened with the regulator bindings, specifically the "regulator-name" property.
And by "currently supported", are you referring to what the driver expects, and not what the end result, i.e. the accepted bindings in Linux, should be? This driver is still in a state of catchup. The driver supports a previously merged then reverted set of bindings. These bindings were then brought back and updated for Linux v4.15 (unreleased yet, so may still change, again). So which set of bindings should I submit here?
And the goal _is_ to migrate the driver to what Linux is using, so we can share the device tree files.
Regards ChenYu

On Wed, Dec 6, 2017 at 8:35 PM, Chen-Yu Tsai wens@csie.org wrote:
On Thu, Dec 7, 2017 at 4:20 AM, Joe Hershberger joe.hershberger@gmail.com wrote:
On Tue, Dec 5, 2017 at 8:34 PM, Chen-Yu Tsai wens@csie.org wrote:
On Wed, Dec 6, 2017 at 4:50 AM, Joe Hershberger joe.hershberger@ni.com wrote:
On Fri, Nov 24, 2017 at 11:08 PM, Chen-Yu Tsai wens@csie.org wrote:
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.
I'm not seeing this in doc/device-tree-bindings/net/
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docu...
The bindings have been restored as of v4.15-rc1.
We are following DT bindings as defined in the Linux kernel. Deviation is kept to a minimum, and eliminated if possible. We still need to migrate the driver to the new bindings for the internal PHY bits. But that bit might still be changed during the 4.15 release cycle.
That's good, but we want to have the currently supported bindings copied into the U-Boot tree under doc/device-tree-bindings/net/. Please include a patch that adds the bindings that your driver is using.
Looks like this is a new requirement. Or it wasn't really enforced before. Doesn't this make U-boot prone to having diverging device tree bindings? It has already happened with the regulator bindings, specifically the "regulator-name" property.
And by "currently supported", are you referring to what the driver expects, and not what the end result, i.e. the accepted bindings in Linux, should be? This driver is still in a state of catchup. The driver supports a previously merged then reverted set of bindings. These bindings were then brought back and updated for Linux v4.15 (unreleased yet, so may still change, again). So which set of bindings should I submit here?
And the goal _is_ to migrate the driver to what Linux is using, so we can share the device tree files.
I believe the goal is to have them match the current state of the driver as supported in U-Boot, and a higher-level goal of keeping the bindings + driver in sync with Linux for sharing.
Correct, Simon?
Thanks, -Joe

Hi Joe,
On 7 December 2017 at 11:45, Joe Hershberger joe.hershberger@gmail.com wrote:
On Wed, Dec 6, 2017 at 8:35 PM, Chen-Yu Tsai wens@csie.org wrote:
On Thu, Dec 7, 2017 at 4:20 AM, Joe Hershberger joe.hershberger@gmail.com wrote:
On Tue, Dec 5, 2017 at 8:34 PM, Chen-Yu Tsai wens@csie.org wrote:
On Wed, Dec 6, 2017 at 4:50 AM, Joe Hershberger joe.hershberger@ni.com wrote:
On Fri, Nov 24, 2017 at 11:08 PM, Chen-Yu Tsai wens@csie.org wrote:
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.
I'm not seeing this in doc/device-tree-bindings/net/
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docu...
The bindings have been restored as of v4.15-rc1.
We are following DT bindings as defined in the Linux kernel. Deviation is kept to a minimum, and eliminated if possible. We still need to migrate the driver to the new bindings for the internal PHY bits. But that bit might still be changed during the 4.15 release cycle.
That's good, but we want to have the currently supported bindings copied into the U-Boot tree under doc/device-tree-bindings/net/. Please include a patch that adds the bindings that your driver is using.
Looks like this is a new requirement. Or it wasn't really enforced before. Doesn't this make U-boot prone to having diverging device tree bindings? It has already happened with the regulator bindings, specifically the "regulator-name" property.
And by "currently supported", are you referring to what the driver expects, and not what the end result, i.e. the accepted bindings in Linux, should be? This driver is still in a state of catchup. The driver supports a previously merged then reverted set of bindings. These bindings were then brought back and updated for Linux v4.15 (unreleased yet, so may still change, again). So which set of bindings should I submit here?
And the goal _is_ to migrate the driver to what Linux is using, so we can share the device tree files.
I believe the goal is to have them match the current state of the driver as supported in U-Boot, and a higher-level goal of keeping the bindings + driver in sync with Linux for sharing.
Yes, they should match, and we should have the same binding file.
Also, please use dev_read_...() instead of fdtdec...() for all new code since that supports live tree.
Correct, Simon?
Thanks, -Joe
Regards, Simon

The 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. The U-boot driver has not been updated to support the new binding.
Signed-off-by: Chen-Yu Tsai wens@csie.org --- .../arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi | 38 ++++++++++++++++++++++ configs/Cubietruck_plus_defconfig | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi
diff --git a/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi b/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi new file mode 100644 index 000000000000..4637e128f76e --- /dev/null +++ b/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi @@ -0,0 +1,38 @@ +#include "sunxi-u-boot.dtsi" + +/ { + aliases { + ethernet0 = &emac; + }; + + soc { + emac: ethernet@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@1 { + reg = <1>; + }; + }; + }; +}; + +&pio { + rgmii_pins: rgmii_pins { + allwinner,pins = "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", + "PD11", "PD12", "PD13", "PD14", "PD18", + "PD19", "PD21", "PD22", "PD23"; + allwinner,function = "emac"; + allwinner,drive = <3>; + allwinner,pull = <0>; + }; +}; diff --git a/configs/Cubietruck_plus_defconfig b/configs/Cubietruck_plus_defconfig index 12120c2ceda5..77fbf91490c8 100644 --- a/configs/Cubietruck_plus_defconfig +++ b/configs/Cubietruck_plus_defconfig @@ -21,6 +21,8 @@ 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_PHY_REALTEK=y +CONFIG_SUN8I_EMAC=y CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_DLDO4_VOLT=3300 CONFIG_AXP_FLDO1_VOLT=1200

Hi,
On Sat, Nov 25, 2017 at 01:08:30PM +0800, Chen-Yu Tsai wrote:
The 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. The U-boot driver has not been updated to support the new binding.
Signed-off-by: Chen-Yu Tsai wens@csie.org
.../arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi | 38 ++++++++++++++++++++++ configs/Cubietruck_plus_defconfig | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi
diff --git a/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi b/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi new file mode 100644 index 000000000000..4637e128f76e --- /dev/null +++ b/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi @@ -0,0 +1,38 @@ +#include "sunxi-u-boot.dtsi"
+/ {
- aliases {
ethernet0 = &emac;
- };
- soc {
emac: ethernet@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@1 {
reg = <1>;
};
};
- };
+};
Now that we have a binding merged, can't we use that instead?
+&pio {
- rgmii_pins: rgmii_pins {
allwinner,pins = "PD2", "PD3", "PD4", "PD5", "PD6", "PD7",
"PD11", "PD12", "PD13", "PD14", "PD18",
"PD19", "PD21", "PD22", "PD23";
allwinner,function = "emac";
allwinner,drive = <3>;
allwinner,pull = <0>;
- };
+};
You should also use the new bindings here.
Thanks! Maxime

On Mon, Nov 27, 2017 at 4:09 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Hi,
On Sat, Nov 25, 2017 at 01:08:30PM +0800, Chen-Yu Tsai wrote:
The 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. The U-boot driver has not been updated to support the new binding.
Signed-off-by: Chen-Yu Tsai wens@csie.org
.../arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi | 38 ++++++++++++++++++++++ configs/Cubietruck_plus_defconfig | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi
diff --git a/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi b/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi new file mode 100644 index 000000000000..4637e128f76e --- /dev/null +++ b/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi @@ -0,0 +1,38 @@ +#include "sunxi-u-boot.dtsi"
+/ {
aliases {
ethernet0 = &emac;
};
soc {
emac: ethernet@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@1 {
reg = <1>;
};
};
};
+};
Now that we have a binding merged, can't we use that instead?
That is the next step. It's also why I have these in a U-boot specific dtsi file. The driver is upgraded to support the now official bindings, then we sync up the dts files and rip out the u-boot stuff.
However I'm not sure when I'll get to that, and I'd like this feature to be available for people that need might it, such as the kernelci.org board farms.
+&pio {
rgmii_pins: rgmii_pins {
allwinner,pins = "PD2", "PD3", "PD4", "PD5", "PD6", "PD7",
"PD11", "PD12", "PD13", "PD14", "PD18",
"PD19", "PD21", "PD22", "PD23";
allwinner,function = "emac";
allwinner,drive = <3>;
allwinner,pull = <0>;
};
+};
You should also use the new bindings here.
See above.
ChenYu

On Mon, Nov 27, 2017 at 04:19:31PM +0800, Chen-Yu Tsai wrote:
On Mon, Nov 27, 2017 at 4:09 PM, Maxime Ripard maxime.ripard@free-electrons.com wrote:
Hi,
On Sat, Nov 25, 2017 at 01:08:30PM +0800, Chen-Yu Tsai wrote:
The 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. The U-boot driver has not been updated to support the new binding.
Signed-off-by: Chen-Yu Tsai wens@csie.org
.../arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi | 38 ++++++++++++++++++++++ configs/Cubietruck_plus_defconfig | 2 ++ 2 files changed, 40 insertions(+) create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi
diff --git a/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi b/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi new file mode 100644 index 000000000000..4637e128f76e --- /dev/null +++ b/arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi @@ -0,0 +1,38 @@ +#include "sunxi-u-boot.dtsi"
+/ {
aliases {
ethernet0 = &emac;
};
soc {
emac: ethernet@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@1 {
reg = <1>;
};
};
};
+};
Now that we have a binding merged, can't we use that instead?
That is the next step. It's also why I have these in a U-boot specific dtsi file. The driver is upgraded to support the now official bindings, then we sync up the dts files and rip out the u-boot stuff.
However I'm not sure when I'll get to that, and I'd like this feature to be available for people that need might it, such as the kernelci.org board farms.
Ok, that works for me.
On the DT part, Acked-by: Maxime Ripard maxime.ripard@free-electrons.com
Maxime

The 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. The U-boot driver has not been updated to support the new binding.
Signed-off-by: Chen-Yu Tsai wens@csie.org --- arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi | 40 +++++++++++++++++++++++++ configs/Sinovoip_BPI_M3_defconfig | 2 ++ 2 files changed, 42 insertions(+) create mode 100644 arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi
diff --git a/arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi b/arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi new file mode 100644 index 000000000000..5ac29058cc42 --- /dev/null +++ b/arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi @@ -0,0 +1,40 @@ +#include "sunxi-u-boot.dtsi" + +/ { + aliases { + ethernet0 = &emac; + }; + + soc { + emac: ethernet@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@1 { + reg = <1>; + }; + }; + }; +}; + +&pio { + rgmii_pins: rgmii_pins { + allwinner,pins = "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", + "PD11", "PD12", "PD13", "PD14", "PD18", + "PD19", "PD21", "PD22", "PD23"; + allwinner,function = "emac"; + allwinner,drive = <3>; + allwinner,pull = <0>; + }; +}; diff --git a/configs/Sinovoip_BPI_M3_defconfig b/configs/Sinovoip_BPI_M3_defconfig index 60aea1eb3d22..6360e3761e6b 100644 --- a/configs/Sinovoip_BPI_M3_defconfig +++ b/configs/Sinovoip_BPI_M3_defconfig @@ -22,6 +22,8 @@ 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_PHY_REALTEK=y +CONFIG_SUN8I_EMAC=y CONFIG_AXP_DCDC5_VOLT=1200 CONFIG_AXP_DLDO3_VOLT=2500 CONFIG_AXP_SW_ON=y

The Bananapi M64 has an RTL8211E PHY connected to the EMAC using RGMII. The PHY is powered by DCDC1 through SW @ 3.3V.
The EMAC driver is already enabled in the defconfig.
This patch adds a U-boot specific dtsi file for the board adding an enabled EMAC node. The binding used here is the old revision currently supported in U-boot. The U-boot driver has not been updated to support the new binding.
Signed-off-by: Chen-Yu Tsai wens@csie.org --- arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi
diff --git a/arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi b/arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi new file mode 100644 index 000000000000..f80a4255c0c1 --- /dev/null +++ b/arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi @@ -0,0 +1,39 @@ +#include "sunxi-u-boot.dtsi" + +/ { + aliases { + ethernet0 = &emac; + }; + + soc { + emac: ethernet@01c30000 { + compatible = "allwinner,sun50i-a64-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@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>; + }; +};

Hi,
On Sat, Nov 25, 2017 at 1:08 PM, Chen-Yu Tsai wens@csie.org wrote:
Hi,
This series enables the EMAC for some A83T and A64 boards.
Changes since v1:
- Added "bitfield: Include linux/bitops.h for ffs()" to fix build errors
- Use bitfield_replace_by_mask() instead of open coding bitfield ops
- Trimmed used pins in the device tree to only those actually needed
- Enabled Realtek PHY driver
- Added "sunxi: Enable EMAC on the Bananapi M64"
ChenYu
Chen-Yu Tsai (5): bitfield: Include linux/bitops.h for ffs() net: sun8i_emac: Support RX/TX delay chains sunxi: Enable EMAC on the Cubietruck Plus sunxi: Enable EMAC on the Bananapi M3 sunxi: Enable EMAC on the Bananapi M64
Any comments (particularly two the first two patches) on this series? Joe?
ChenYu
arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi | 39 +++++++++++++++++++++ arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi | 40 ++++++++++++++++++++++ .../arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi | 38 ++++++++++++++++++++ configs/Cubietruck_plus_defconfig | 2 ++ configs/Sinovoip_BPI_M3_defconfig | 2 ++ drivers/net/sun8i_emac.c | 22 ++++++++++++ include/bitfield.h | 1 + 7 files changed, 144 insertions(+) create mode 100644 arch/arm/dts/sun50i-a64-bananapi-m64-u-boot.dtsi create mode 100644 arch/arm/dts/sun8i-a83t-bananapi-m3-u-boot.dtsi create mode 100644 arch/arm/dts/sun8i-a83t-cubietruck-plus-u-boot.dtsi
-- 2.15.0

On Tue, Dec 5, 2017 at 7:07 AM, Chen-Yu Tsai wens@csie.org wrote:
Hi,
On Sat, Nov 25, 2017 at 1:08 PM, Chen-Yu Tsai wens@csie.org wrote:
Hi,
This series enables the EMAC for some A83T and A64 boards.
Changes since v1:
- Added "bitfield: Include linux/bitops.h for ffs()" to fix build errors
- Use bitfield_replace_by_mask() instead of open coding bitfield ops
- Trimmed used pins in the device tree to only those actually needed
- Enabled Realtek PHY driver
- Added "sunxi: Enable EMAC on the Bananapi M64"
ChenYu
Chen-Yu Tsai (5): bitfield: Include linux/bitops.h for ffs() net: sun8i_emac: Support RX/TX delay chains sunxi: Enable EMAC on the Cubietruck Plus sunxi: Enable EMAC on the Bananapi M3 sunxi: Enable EMAC on the Bananapi M64
Any comments (particularly two the first two patches) on this series? Joe?
I sent an issue with net: sun8i_emac: Support RX/TX delay chains
Cheers, -Joe
participants (5)
-
Chen-Yu Tsai
-
Joe Hershberger
-
Joe Hershberger
-
Maxime Ripard
-
Simon Glass