[PATCH v5 0/6] Add support for Orange Pi 3

125 views
Skip to first unread message

meg...@megous.com

unread,
May 20, 2019, 7:50:14 PM5/20/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

This series implements support for Xunlong Orange Pi 3 board.

Unfortunately, this board needs some small driver patches, so I have
split the boards DT patch into chunks that require patches for drivers
in various subsystems.

Suggested merging plan/dependencies:

- stmmac patches are needed for ethernet support (patches 1-3)
- these should be ready now
- HDMI support (patches 4-6)
- needs DT and driver review

Changes in v2:
- added dt-bindings documentation for the board's compatible string
(suggested by Clement)
- addressed checkpatch warnings and code formatting issues (on Maxime's
suggestions)
- stmmac: dropped useless parenthesis, reworded description of the patch
(suggested by Sergei)
- drop useles dev_info() about the selected io bias voltage
- docummented io voltage bias selection variant macros
- wifi: marked WiFi DTS patch and realted mmc1_pins as "DO NOT MERGE",
because wifi depends on H6 RTC support that's not merged yet (suggested
by Clement)
- added missing signed-of-bys
- changed &usb2otg dr_mode to otg, and added a note about VBUS
- improved wording of HDMI driver's DDC power supply patch

Changes in v3:
- dropped already applied patches
- changed pinctrl I/O bias selection constants to enum and renamed
- added /omit-if-no-ref/ to mmc1_pins
- made mmc1_pins default pinconf for mmc1 in H6 dtsi
- move ddc-supply to HDMI connector node, updated patch descriptions,
changed dt-bindings docs

Changes in v4:
- fix checkpatch warnings/style issues
- use enum in struct sunxi_desc_function for io_bias_cfg_variant
- collected acked-by's
- fix compile error in drivers/pinctrl/sunxi/pinctrl-sun9i-a80-r.c:156
caused by missing conversion from has_io_bias_cfg struct member
(I've kept the acked-by, because it's a trivial change, but feel free
to object.) (reported by Martin A. on github)
I did not have A80 pinctrl enabled for some reason, so I did not catch
this sooner.
- dropped brcm firmware patch (was already applied)
- dropped the wifi dts patch (will re-send after H6 RTC gets merged,
along with bluetooth support, in a separate series)

Changes in v5:
- dropped already applied patches (pinctrl patches, mmc1 pinconf patch)
- rename GMAC-3V3 -> GMAC-3V to match the schematic (Jagan)
- changed hdmi-connector's ddc-supply property to ddc-en-gpios
(Rob Herring)

Please take a look.

thank you and regards,
Ondrej Jirman

Icenowy Zheng (2):
net: stmmac: sun8i: add support for Allwinner H6 EMAC
net: stmmac: sun8i: force select external PHY when no internal one

Ondrej Jirman (4):
arm64: dts: allwinner: orange-pi-3: Enable ethernet
dt-bindings: display: hdmi-connector: Support DDC bus enable
drm: sun4i: Add support for enabling DDC I2C bus to sun8i_dw_hdmi glue
arm64: dts: allwinner: orange-pi-3: Enable HDMI output

.../display/connector/hdmi-connector.txt | 1 +
.../dts/allwinner/sun50i-h6-orangepi-3.dts | 70 +++++++++++++++++++
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 55 ++++++++++++++-
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h | 3 +
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 21 ++++++
5 files changed, 147 insertions(+), 3 deletions(-)

--
2.21.0

meg...@megous.com

unread,
May 20, 2019, 7:50:14 PM5/20/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Icenowy Zheng, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com, Ondrej Jirman
From: Icenowy Zheng <ice...@aosc.io>

The PHY selection bit also exists on SoCs without an internal PHY; if it's
set to 1 (internal PHY, default value) then the MAC will not make use of
any PHY such SoCs.

This problem appears when adapting for H6, which has no real internal PHY
(the "internal PHY" on H6 is not on-die, but on a co-packaged AC200 chip,
connected via RMII interface at GPIO bank A).

Force the PHY selection bit to 0 when the SOC doesn't have an internal PHY,
to address the problem of a wrong default value.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index 3258dec84d55..0484c289f328 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -907,6 +907,11 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
* address. No need to mask it again.
*/
reg |= 1 << H3_EPHY_ADDR_SHIFT;
+ } else {
+ /* For SoCs without internal PHY the PHY selection bit should be
+ * set to 0 (external PHY).
+ */
+ reg &= ~H3_EPHY_SELECT;
}

if (!of_property_read_u32(node, "allwinner,tx-delay-ps", &val)) {
--
2.21.0

meg...@megous.com

unread,
May 20, 2019, 7:50:14 PM5/20/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

Orange Pi 3 has two regulators that power the Realtek RTL8211E. According
to the phy datasheet, both regulators need to be enabled at the same time,
but we can only specify a single phy-supply in the DT.

This can be achieved by making one regulator depedning on the other via
vin-supply. While it's not a technically correct description of the
hardware, it achieves the purpose.

All values of RX/TX delay were tested exhaustively and a middle one of the
working values was chosen.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../dts/allwinner/sun50i-h6-orangepi-3.dts | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts b/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
index 17d496990108..2c6807b74ff6 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
@@ -15,6 +15,7 @@

aliases {
serial0 = &uart0;
+ ethernet0 = &emac;
};

chosen {
@@ -44,6 +45,27 @@
regulator-max-microvolt = <5000000>;
regulator-always-on;
};
+
+ /*
+ * The board uses 2.5V RGMII signalling. Power sequence to enable
+ * the phy is to enable GMAC-2V5 and GMAC-3V (aldo2) power rails
+ * at the same time and to wait 100ms.
+ */
+ reg_gmac_2v5: gmac-2v5 {
+ compatible = "regulator-fixed";
+ regulator-name = "gmac-2v5";
+ regulator-min-microvolt = <2500000>;
+ regulator-max-microvolt = <2500000>;
+ startup-delay-us = <100000>;
+ enable-active-high;
+ gpio = <&pio 3 6 GPIO_ACTIVE_HIGH>; /* PD6 */
+
+ /* The real parent of gmac-2v5 is reg_vcc5v, but we need to
+ * enable two regulators to power the phy. This is one way
+ * to achieve that.
+ */
+ vin-supply = <&reg_aldo2>; /* GMAC-3V */
+ };
};

&cpu0 {
@@ -58,6 +80,28 @@
status = "okay";
};

+&emac {
+ pinctrl-names = "default";
+ pinctrl-0 = <&ext_rgmii_pins>;
+ phy-mode = "rgmii";
+ phy-handle = <&ext_rgmii_phy>;
+ phy-supply = <&reg_gmac_2v5>;
+ allwinner,rx-delay-ps = <1500>;
+ allwinner,tx-delay-ps = <700>;
+ status = "okay";
+};
+
+&mdio {
+ ext_rgmii_phy: ethernet-phy@1 {
+ compatible = "ethernet-phy-ieee802.3-c22";
+ reg = <1>;
+
+ reset-gpios = <&pio 3 14 GPIO_ACTIVE_LOW>; /* PD14 */
+ reset-assert-us = <15000>;
+ reset-deassert-us = <40000>;
+ };
+};
+
&mmc0 {
vmmc-supply = <&reg_cldo1>;
cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
--
2.21.0

meg...@megous.com

unread,
May 20, 2019, 7:50:15 PM5/20/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

Orange Pi 3 board requires enabling a voltage shifting circuit via GPIO
for the DDC bus to be usable.

Add support for hdmi-connector node's optional ddc-en-gpios property to
support this use case.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c | 55 +++++++++++++++++++++++++--
drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h | 3 ++
2 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
index 39d8509d96a0..59b81ba02d96 100644
--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c
@@ -98,6 +98,30 @@ static u32 sun8i_dw_hdmi_find_possible_crtcs(struct drm_device *drm,
return crtcs;
}

+static int sun8i_dw_hdmi_find_connector_pdev(struct device *dev,
+ struct platform_device **pdev_out)
+{
+ struct platform_device *pdev;
+ struct device_node *remote;
+
+ remote = of_graph_get_remote_node(dev->of_node, 1, -1);
+ if (!remote)
+ return -ENODEV;
+
+ if (!of_device_is_compatible(remote, "hdmi-connector")) {
+ of_node_put(remote);
+ return -ENODEV;
+ }
+
+ pdev = of_find_device_by_node(remote);
+ of_node_put(remote);
+ if (!pdev)
+ return -ENODEV;
+
+ *pdev_out = pdev;
+ return 0;
+}
+
static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
void *data)
{
@@ -151,16 +175,29 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
return PTR_ERR(hdmi->regulator);
}

+ ret = sun8i_dw_hdmi_find_connector_pdev(dev, &hdmi->connector_pdev);
+ if (!ret) {
+ hdmi->ddc_en = gpiod_get_optional(&hdmi->connector_pdev->dev,
+ "ddc-en", GPIOD_OUT_HIGH);
+ if (IS_ERR(hdmi->ddc_en)) {
+ platform_device_put(hdmi->connector_pdev);
+ dev_err(dev, "Couldn't get ddc-en gpio\n");
+ return PTR_ERR(hdmi->ddc_en);
+ }
+ }
+
ret = regulator_enable(hdmi->regulator);
if (ret) {
dev_err(dev, "Failed to enable regulator\n");
- return ret;
+ goto err_unref_ddc_en;
}

+ gpiod_set_value(hdmi->ddc_en, 1);
+
ret = reset_control_deassert(hdmi->rst_ctrl);
if (ret) {
dev_err(dev, "Could not deassert ctrl reset control\n");
- goto err_disable_regulator;
+ goto err_disable_ddc_en;
}

ret = clk_prepare_enable(hdmi->clk_tmds);
@@ -213,8 +250,14 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master,
clk_disable_unprepare(hdmi->clk_tmds);
err_assert_ctrl_reset:
reset_control_assert(hdmi->rst_ctrl);
-err_disable_regulator:
+err_disable_ddc_en:
+ gpiod_set_value(hdmi->ddc_en, 0);
regulator_disable(hdmi->regulator);
+err_unref_ddc_en:
+ if (hdmi->ddc_en)
+ gpiod_put(hdmi->ddc_en);
+
+ platform_device_put(hdmi->connector_pdev);

return ret;
}
@@ -228,7 +271,13 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master,
sun8i_hdmi_phy_remove(hdmi);
clk_disable_unprepare(hdmi->clk_tmds);
reset_control_assert(hdmi->rst_ctrl);
+ gpiod_set_value(hdmi->ddc_en, 0);
regulator_disable(hdmi->regulator);
+
+ if (hdmi->ddc_en)
+ gpiod_put(hdmi->ddc_en);
+
+ platform_device_put(hdmi->connector_pdev);
}

static const struct component_ops sun8i_dw_hdmi_ops = {
diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
index 720c5aa8adc1..dad66b8301c2 100644
--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h
@@ -9,6 +9,7 @@
#include <drm/bridge/dw_hdmi.h>
#include <drm/drm_encoder.h>
#include <linux/clk.h>
+#include <linux/gpio/consumer.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/reset.h>
@@ -190,6 +191,8 @@ struct sun8i_dw_hdmi {
struct regulator *regulator;
const struct sun8i_dw_hdmi_quirks *quirks;
struct reset_control *rst_ctrl;
+ struct platform_device *connector_pdev;
+ struct gpio_desc *ddc_en;
};

static inline struct sun8i_dw_hdmi *
--
2.21.0

meg...@megous.com

unread,
May 20, 2019, 7:50:15 PM5/20/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

Orange Pi 3 has a DDC_CEC_EN signal connected to PH2, that enables the DDC
I2C bus voltage shifter. Before EDID can be read, we need to pull PH2 high.
This is realized by the ddc-en-gpios property.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../dts/allwinner/sun50i-h6-orangepi-3.dts | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts b/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
index 2c6807b74ff6..01bb1bafe284 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
@@ -22,6 +22,18 @@
stdout-path = "serial0:115200n8";
};

+ connector {
+ compatible = "hdmi-connector";
+ ddc-en-gpios = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */
+ type = "a";
+
+ port {
+ hdmi_con_in: endpoint {
+ remote-endpoint = <&hdmi_out_con>;
+ };
+ };
+ };
+
leds {
compatible = "gpio-leds";

@@ -72,6 +84,10 @@
cpu-supply = <&reg_dcdca>;
};

+&de {
+ status = "okay";
+};
+
&ehci0 {
status = "okay";
};
@@ -91,6 +107,16 @@
status = "okay";
};

+&hdmi {
+ status = "okay";
+};
+
+&hdmi_out {
+ hdmi_out_con: endpoint {
+ remote-endpoint = <&hdmi_con_in>;
+ };
+};
+
&mdio {
ext_rgmii_phy: ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
--
2.21.0

meg...@megous.com

unread,
May 20, 2019, 7:50:15 PM5/20/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

Some Allwinner SoC using boards (Orange Pi 3 for example) need to enable
on-board voltage shifting logic for the DDC bus using a gpio to be able
to access DDC bus. Use ddc-en-gpios property on the hdmi-connector to
model this.

Add binding documentation for optional ddc-en-gpios property.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../devicetree/bindings/display/connector/hdmi-connector.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt b/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
index 508aee461e0d..aeb07c4bd703 100644
--- a/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
+++ b/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
@@ -9,6 +9,7 @@ Optional properties:
- label: a symbolic name for the connector
- hpd-gpios: HPD GPIO number
- ddc-i2c-bus: phandle link to the I2C controller used for DDC EDID probing
+- ddc-en-gpios: signal to enable DDC bus

Required nodes:
- Video port for HDMI input
--
2.21.0

Sergei Shtylyov

unread,
May 21, 2019, 5:27:34 AM5/21/19
to meg...@megous.com, linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Icenowy Zheng, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
Hello!

On 21.05.2019 2:50, meg...@megous.com wrote:

> From: Icenowy Zheng <ice...@aosc.io>
>
> The PHY selection bit also exists on SoCs without an internal PHY; if it's
> set to 1 (internal PHY, default value) then the MAC will not make use of
> any PHY such SoCs.
^ "on" or "with" missing?

> This problem appears when adapting for H6, which has no real internal PHY
> (the "internal PHY" on H6 is not on-die, but on a co-packaged AC200 chip,
> connected via RMII interface at GPIO bank A).
>
> Force the PHY selection bit to 0 when the SOC doesn't have an internal PHY,
> to address the problem of a wrong default value.
>
> Signed-off-by: Icenowy Zheng <ice...@aosc.io>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>
[...]

MBR, Sergei

Ondřej Jirman

unread,
May 21, 2019, 5:56:33 AM5/21/19
to Sergei Shtylyov, linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Icenowy Zheng, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
Hello Sergei,

On Tue, May 21, 2019 at 12:27:24PM +0300, Sergei Shtylyov wrote:
> Hello!
>
> On 21.05.2019 2:50, meg...@megous.com wrote:
>
> > From: Icenowy Zheng <ice...@aosc.io>
> >
> > The PHY selection bit also exists on SoCs without an internal PHY; if it's
> > set to 1 (internal PHY, default value) then the MAC will not make use of
> > any PHY such SoCs.
> ^ "on" or "with" missing?

It's missing 'on'.

thank you,
Ondrej

Maxime Ripard

unread,
May 21, 2019, 7:46:20 AM5/21/19
to meg...@megous.com, linux...@googlegroups.com, Chen-Yu Tsai, Rob Herring, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
Hi,
Do you really need this to be done all the time? I'm guessing you
would only need this when running .get_modes, right?

Maxime

--
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
signature.asc

Ondřej Jirman

unread,
May 21, 2019, 8:15:22 AM5/21/19
to Maxime Ripard, linux...@googlegroups.com, Chen-Yu Tsai, Rob Herring, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
Hi Maxime,
I don't think it hurts anything. Enabled voltage shifting circuit doesn't
draw any current, unless DDC is actually transmitting data. On most boards
I'd imagine this circuit is always on anyway (Orange Pi 3 schematic even has
an option to tie this signal to VCC-IO instead of GPIO).

Schematic: https://megous.com/dl/tmp/bfcdd32d655aaa76.png

thank you and regards,
o.

Maxime Ripard

unread,
May 23, 2019, 8:27:13 AM5/23/19
to linux...@googlegroups.com, Chen-Yu Tsai, Rob Herring, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
Ok, it works for me then
signature.asc

Rob Herring

unread,
May 24, 2019, 5:55:52 PM5/24/19
to meg...@megous.com, linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
On Tue, 21 May 2019 01:50:07 +0200, meg...@megous.com wrote:
> From: Ondrej Jirman <meg...@megous.com>
>
> Some Allwinner SoC using boards (Orange Pi 3 for example) need to enable
> on-board voltage shifting logic for the DDC bus using a gpio to be able
> to access DDC bus. Use ddc-en-gpios property on the hdmi-connector to
> model this.
>
> Add binding documentation for optional ddc-en-gpios property.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>
> ---
> .../devicetree/bindings/display/connector/hdmi-connector.txt | 1 +
> 1 file changed, 1 insertion(+)
>

Reviewed-by: Rob Herring <ro...@kernel.org>

meg...@megous.com

unread,
May 27, 2019, 12:22:41 PM5/27/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

This series implements support for Xunlong Orange Pi 3 board.

Unfortunately, this board needs some small driver patches, so I have
split the boards DT patch into chunks that require patches for drivers
in various subsystems.

Suggested merging plan/dependencies:

- stmmac patches are needed for ethernet support (patches 1-3)
- these should be ready now
- HDMI support (patches 4-6)
- should be ready
Changes in v6:
- added dt-bindings reviewed-by tag
- fix wording in stmmac commit (as suggested by Sergei)

meg...@megous.com

unread,
May 27, 2019, 12:22:42 PM5/27/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Icenowy Zheng, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com, Ondrej Jirman
From: Icenowy Zheng <ice...@aosc.io>

The PHY selection bit also exists on SoCs without an internal PHY; if it's
set to 1 (internal PHY, default value) then the MAC will not make use of
any PHY such SoCs.

This problem appears when adapting for H6, which has no real internal PHY
(the "internal PHY" on H6 is not on-die, but on a co-packaged AC200 chip,
connected via RMII interface at GPIO bank A).

Force the PHY selection bit to 0 when the SOC doesn't have an internal PHY,
to address the problem of a wrong default value.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
---

meg...@megous.com

unread,
May 27, 2019, 12:22:42 PM5/27/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

Orange Pi 3 has two regulators that power the Realtek RTL8211E. According
to the phy datasheet, both regulators need to be enabled at the same time,
but we can only specify a single phy-supply in the DT.

This can be achieved by making one regulator depedning on the other via
vin-supply. While it's not a technically correct description of the
hardware, it achieves the purpose.

All values of RX/TX delay were tested exhaustively and a middle one of the
working values was chosen.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../dts/allwinner/sun50i-h6-orangepi-3.dts | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts b/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
index 17d496990108..2c6807b74ff6 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
+ status = "okay";
+};
+

meg...@megous.com

unread,
May 27, 2019, 12:22:43 PM5/27/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

Some Allwinner SoC using boards (Orange Pi 3 for example) need to enable
on-board voltage shifting logic for the DDC bus using a gpio to be able
to access DDC bus. Use ddc-en-gpios property on the hdmi-connector to
model this.

Add binding documentation for optional ddc-en-gpios property.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../devicetree/bindings/display/connector/hdmi-connector.txt | 1 +
1 file changed, 1 insertion(+)

meg...@megous.com

unread,
May 27, 2019, 12:22:43 PM5/27/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

Orange Pi 3 has a DDC_CEC_EN signal connected to PH2, that enables the DDC
I2C bus voltage shifter. Before EDID can be read, we need to pull PH2 high.
This is realized by the ddc-en-gpios property.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../dts/allwinner/sun50i-h6-orangepi-3.dts | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts b/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
index 2c6807b74ff6..01bb1bafe284 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts
@@ -22,6 +22,18 @@
stdout-path = "serial0:115200n8";
};

+ connector {
+ compatible = "hdmi-connector";
+ ddc-en-gpios = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */
+ type = "a";
+
+ port {
+ hdmi_con_in: endpoint {
+ remote-endpoint = <&hdmi_out_con>;
+ };
+ };
+ };
+
leds {
compatible = "gpio-leds";

@@ -72,6 +84,10 @@
cpu-supply = <&reg_dcdca>;
};

+&de {
+ status = "okay";
+};
+
&ehci0 {
status = "okay";
};
@@ -91,6 +107,16 @@
status = "okay";
};

+&hdmi {
+ status = "okay";
+};
+

meg...@megous.com

unread,
May 27, 2019, 12:22:43 PM5/27/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
From: Ondrej Jirman <meg...@megous.com>

Orange Pi 3 board requires enabling a voltage shifting circuit via GPIO
for the DDC bus to be usable.

Add support for hdmi-connector node's optional ddc-en-gpios property to
support this use case.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---

meg...@megous.com

unread,
May 27, 2019, 12:22:43 PM5/27/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Icenowy Zheng, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com, Ondrej Jirman
From: Icenowy Zheng <ice...@aosc.io>

The EMAC on Allwinner H6 is just like the one on A64. The "internal PHY" on
H6 is on a co-packaged AC200 chip, and it's not really internal (it's
connected via RMII at PA GPIO bank).

Add support for the Allwinner H6 EMAC in the dwmac-sun8i driver.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
index ba124a4da793..3258dec84d55 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
@@ -147,6 +147,20 @@ static const struct emac_variant emac_variant_a64 = {
.tx_delay_max = 7,
};

+static const struct emac_variant emac_variant_h6 = {
+ .default_syscon_value = 0x50000,
+ .syscon_field = &sun8i_syscon_reg_field,
+ /* The "Internal PHY" of H6 is not on the die. It's on the
+ * co-packaged AC200 chip instead.
+ */
+ .soc_has_internal_phy = false,
+ .support_mii = true,
+ .support_rmii = true,
+ .support_rgmii = true,
+ .rx_delay_max = 31,
+ .tx_delay_max = 7,
+};
+
#define EMAC_BASIC_CTL0 0x00
#define EMAC_BASIC_CTL1 0x04
#define EMAC_INT_STA 0x08
@@ -1212,6 +1226,8 @@ static const struct of_device_id sun8i_dwmac_match[] = {
.data = &emac_variant_r40 },
{ .compatible = "allwinner,sun50i-a64-emac",
.data = &emac_variant_a64 },
+ { .compatible = "allwinner,sun50i-h6-emac",
+ .data = &emac_variant_h6 },
{ }
};
MODULE_DEVICE_TABLE(of, sun8i_dwmac_match);
--
2.21.0

Ondřej Jirman

unread,
May 31, 2019, 8:52:49 AM5/31/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
Hello,

On Mon, May 27, 2019 at 06:22:31PM +0200, megous via linux-sunxi wrote:
> From: Ondrej Jirman <meg...@megous.com>
>
> This series implements support for Xunlong Orange Pi 3 board.
>
> Unfortunately, this board needs some small driver patches, so I have
> split the boards DT patch into chunks that require patches for drivers
> in various subsystems.
>
> Suggested merging plan/dependencies:
>
> - stmmac patches are needed for ethernet support (patches 1-3)
> - these should be ready now
> - HDMI support (patches 4-6)
> - should be ready

If there are no futher comments, can all these patches please be merged?

thank you and kind regards,
Ondrej
> --
> You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/linux-sunxi/20190527162237.18495-1-megous%40megous.com.
> For more options, visit https://groups.google.com/d/optout.

Maxime Ripard

unread,
Jun 3, 2019, 2:25:14 PM6/3/19
to linux...@googlegroups.com, Chen-Yu Tsai, Rob Herring, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
On Fri, May 31, 2019 at 02:52:46PM +0200, Ondřej Jirman wrote:
> Hello,
>
> On Mon, May 27, 2019 at 06:22:31PM +0200, megous via linux-sunxi wrote:
> > From: Ondrej Jirman <meg...@megous.com>
> >
> > This series implements support for Xunlong Orange Pi 3 board.
> >
> > Unfortunately, this board needs some small driver patches, so I have
> > split the boards DT patch into chunks that require patches for drivers
> > in various subsystems.
> >
> > Suggested merging plan/dependencies:
> >
> > - stmmac patches are needed for ethernet support (patches 1-3)
> > - these should be ready now
> > - HDMI support (patches 4-6)
> > - should be ready
>
> If there are no futher comments, can all these patches please be merged?

I'm waiting for some feedback on the stmmac and the DW-HDMI
developpers to merge the rest

Rob Herring

unread,
Jun 11, 2019, 5:52:12 PM6/11/19
to meg...@megous.com, linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
On Mon, 27 May 2019 18:22:35 +0200, meg...@megous.com wrote:
> From: Ondrej Jirman <meg...@megous.com>
>
> Some Allwinner SoC using boards (Orange Pi 3 for example) need to enable
> on-board voltage shifting logic for the DDC bus using a gpio to be able
> to access DDC bus. Use ddc-en-gpios property on the hdmi-connector to
> model this.
>
> Add binding documentation for optional ddc-en-gpios property.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>
> ---
> .../devicetree/bindings/display/connector/hdmi-connector.txt | 1 +
> 1 file changed, 1 insertion(+)
>

Please add Acked-by/Reviewed-by tags when posting new versions. However,
there's no need to repost patches *only* to add the tags. The upstream
maintainer will do that for acks received on the version they apply.

If a tag was not added on purpose, please state why and what changed.

Ondřej Jirman

unread,
Jun 11, 2019, 6:25:42 PM6/11/19
to Rob Herring, Mark Rutland, Alexandre Torgue, devic...@vger.kernel.org, Maxime Ripard, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com, Chen-Yu Tsai, dri-...@lists.freedesktop.org, linux-...@vger.kernel.org, David Airlie, linux...@googlegroups.com, Jose Abreu, linux-ar...@lists.infradead.org, Daniel Vetter, Giuseppe Cavallaro, David S. Miller, Maxime Coquelin
Sorry, it was some mistake. Thanks for the note.

regards,
Ondrej

> _______________________________________________
> linux-arm-kernel mailing list
> linux-ar...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Jernej Škrabec

unread,
Jun 16, 2019, 7:05:19 AM6/16/19
to linux...@googlegroups.com, meg...@megous.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
Hi Ondrej!

Dne ponedeljek, 27. maj 2019 ob 18:22:36 CEST je megous via linux-sunxi
napisal(a):
Why don't you do that inside if clause where hdmi->ddc_en is assigned? It's
not useful otherwise anyway.

Besides, you would then only need to adjust one goto label in error path.
It seems that connector_pdev is needed only during intialization. Why do you
store it?

Best regards,
Jernej

Ondřej Jirman

unread,
Jun 16, 2019, 8:48:13 AM6/16/19
to Jernej Škrabec, linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com
Hi Jernej,
The idea is to enable DDC after enabling the regulator. I don't think it matters
for the particular HW that's on Orange Pi 3, and similar Xunlong boards, but
this is a fairly generic binding and it makes more sense to power the bus, and
then enable whatever aditional circuitry might be there for the IO.

I can move sun8i_dw_hdmi_find_connector_pdev lower, but I would then need to
disable the regulator in the error path, and I like to keep this order:

- parsing DT
- enabling actual HW stuff

Because parsing is likely to fail with DEFERED_PROBE, because GPIO or whatever
else is not yet ready, and this approach avoids enabling/disabling the HW
needlessly.
For some reason I thought that I need to keep it to keep the GPIO available,
but that's not true. I'll drop it.

thank you,
Ondrej

meg...@megous.com

unread,
Jun 20, 2019, 9:47:54 AM6/20/19
to linux...@googlegroups.com, Maxime Ripard, Chen-Yu Tsai, Rob Herring, Jernej Škrabec, Ondrej Jirman, David Airlie, Daniel Vetter, Mark Rutland, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu, David S. Miller, Maxime Coquelin, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-ar...@lists.infradead.org, linux-...@vger.kernel.org, net...@vger.kernel.org, linux...@st-md-mailman.stormreply.com, Rob Herring
From: Ondrej Jirman <meg...@megous.com>

Some Allwinner SoC using boards (Orange Pi 3 for example) need to enable
on-board voltage shifting logic for the DDC bus using a gpio to be able
to access DDC bus. Use ddc-en-gpios property on the hdmi-connector to
model this.

Add binding documentation for optional ddc-en-gpios property.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Rob Herring <ro...@kernel.org>
---
.../devicetree/bindings/display/connector/hdmi-connector.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt b/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
index 508aee461e0d..aeb07c4bd703 100644
--- a/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
+++ b/Documentation/devicetree/bindings/display/connector/hdmi-connector.txt
@@ -9,6 +9,7 @@ Optional properties:
- label: a symbolic name for the connector
- hpd-gpios: HPD GPIO number
- ddc-i2c-bus: phandle link to the I2C controller used for DDC EDID probing
+- ddc-en-gpios: signal to enable DDC bus

Required nodes:
- Video port for HDMI input
--
2.22.0

Reply all
Reply to author
Forward
0 new messages