Skip to contentSkip to conversation

phy: amlogic: Add support for the G12A Analog MIPI D-PHY

PATCH Superseded Neil Armstrong 2 participants 8 messages Jan 7, 2022 – Jan 10, 2022

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover phy: amlogic: Add support for the G12A Analog MIPI D-PHY

The Amlogic G12A SoCs embeds an Analog MIPI D-PHY to communicate with DSI panels, this adds the bindings.

This Analog D-PHY works with a separate Digital MIPI D-PHY.

This serie adds the Bindings and the PHY driver.

Changes from v2 at [2]:
- Bindings example fix

Changes from v1 at [1]:
- Bindings fixes

[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]

Neil Armstrong (2):
dt-bindings: phy: add Amlogic G12A Analog MIPI D-PHY bindings
phy: amlogic: Add G12A Analog MIPI D-PHY driver

 .../phy/amlogic,g12a-mipi-dphy-analog.yaml    |  35 ++++
 drivers/phy/amlogic/Kconfig                   |  12 ++
 drivers/phy/amlogic/Makefile                  |   1 +
 .../amlogic/phy-meson-g12a-mipi-dphy-analog.c | 177 ++++++++++++++++++
 4 files changed, 225 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/amlogic,g12a-mipi-dphy-analog.yaml
 create mode 100644 drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/2 dt-bindings: phy: add Amlogic G12A Analog MIPI D-PHY bindings

The Amlogic G12A SoCs embeds an Analog MIPI D-PHY to communicate with DSI panels, this adds the bindings.

This Analog D-PHY works with a separate Digital MIPI D-PHY.

---
 .../phy/amlogic,g12a-mipi-dphy-analog.yaml    | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/amlogic,g12a-mipi-dphy-analog.yaml
Documentation/devicetree/bindings/phy/amlogic,g12a-mipi-dphy-analog.yaml new file +35 -0
new file mode 100644
index 000000000000..7aa0c05d6ce4
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/phy/amlogic,g12a-mipi-dphy-analog.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Amlogic G12A MIPI analog PHY
+
+maintainers:
+  - Neil Armstrong <[email protected]>
+
+properties:
+  compatible:
+    const: amlogic,g12a-mipi-dphy-analog
+
+  "#phy-cells":
+    const: 0
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - "#phy-cells"
+
+additionalProperties: false
+
+examples:
+  - |
+    phy@0 {
+          compatible = "amlogic,g12a-mipi-dphy-analog";
+          reg = <0x0 0xc>;
+          #phy-cells = <0>;
+    };
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v3 1/2] dt-bindings: phy: add Amlogic G12A Analog MIPI D-PHY bindings

Hi Neil,

On Fri, Jan 7, 2022 at 4:05 PM Neil Armstrong <[email protected]> wrote:
[...]

Documentation/devicetree/bindings/phy/amlogic,g12a-mipi-dphy-analog.yaml line 25

Quoted 4 lines
Documentation/devicetree/bindings/phy/amlogic,g12a-mipi-dphy-analog.yaml new file +4 -0
+required:
+  - compatible
+  - reg
+  - "#phy-cells"

I also found a "MIPI DSI PHY clock" and "MIPI DSI PHY interrupt" in the datasheet.
I'm no expert on this and I'm just asking in case you have missed one of these:
Can you confirm that these belong to some other IP?

Best regards,
Martin

#3 lore raw

Re: [PATCH v3 1/2] dt-bindings: phy: add Amlogic G12A Analog MIPI D-PHY bindings

Quoted 4 lines · Martin Blumenstingl

Hi Neil,

On Fri, Jan 7, 2022 at 4:05 PM Neil Armstrong <[email protected]> wrote:
[...]

Quoted 8 lines

Documentation/devicetree/bindings/phy/amlogic,g12a-mipi-dphy-analog.yaml line 25

Quoted 4 lines
Documentation/devicetree/bindings/phy/amlogic,g12a-mipi-dphy-analog.yaml new file +4 -0
+required:
+  - compatible
+  - reg
+  - "#phy-cells"

I also found a "MIPI DSI PHY clock" and "MIPI DSI PHY interrupt" in the datasheet.
I'm no expert on this and I'm just asking in case you have missed one of these:
Can you confirm that these belong to some other IP?

Indeed the name is misleading, both go to the DSI Transceiver IP (dw-mipi-dsi)

Neil

Quoted 5 lines

Best regards,
Martin

#4 lore raw

Re: [PATCH v3 1/2] dt-bindings: phy: add Amlogic G12A Analog MIPI D-PHY bindings

Hi Neil,

Quoted 10 lines · Neil Armstrong
Quoted 8 lines · Martin Blumenstingl

Hi Neil,

On Fri, Jan 7, 2022 at 4:05 PM Neil Armstrong <[email protected]> wrote:
[...]

Quoted 4 lines
Documentation/devicetree/bindings/phy/amlogic,g12a-mipi-dphy-analog.yaml new file +4 -0
+required:
+  - compatible
+  - reg
+  - "#phy-cells"
Quoted 6 lines
Quoted 4 lines

I also found a "MIPI DSI PHY clock" and "MIPI DSI PHY interrupt" in the datasheet.
I'm no expert on this and I'm just asking in case you have missed one of these:
Can you confirm that these belong to some other IP?

Indeed the name is misleading, both go to the DSI Transceiver IP (dw-mipi-dsi)

Thank you for clarifying this!

I just found an old comment from Rob on v2 of this series: [0] He mentions:
"If this is a child of something else, then put a $ref to this schema and the example in the parent schema."

To be honest: I completely forgot about that comment until now. If I had remembered it (and assuming that his comment is still valid) then I would have had to NACK my own Documentation/devicetree/bindings/phy/amlogic,meson8-hdmi-tx-phy.yaml For today it's already late so I'll look into this more tomorrow.

Best regards,
Martin

[0] https://lore.kernel.org/all/[email protected]/

#5 lore raw

PATCH v3 2/2 phy: amlogic: Add G12A Analog MIPI D-PHY driver

In reply to Neil Armstrong

The Amlogic G12A SoCs embeds an Analog MIPI D-PHY used to communicate with DSI panels.

---
 drivers/phy/amlogic/Kconfig                   |  12 ++
 drivers/phy/amlogic/Makefile                  |   1 +
 .../amlogic/phy-meson-g12a-mipi-dphy-analog.c | 177 ++++++++++++++++++
 3 files changed, 190 insertions(+)
 create mode 100644 drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c
drivers/phy/amlogic/Kconfig +12 -0
index db5d0cd757e3..ac898a102bcc 100644
@@ -49,6 +49,18 @@ config PHY_MESON_G12A_USB3_PCIE
 	  in Meson G12A SoCs.
 	  If unsure, say N.
 
+config PHY_MESON_G12A_MIPI_DPHY_ANALOG
+	tristate "Meson G12A MIPI Analog DPHY driver"
+	default ARCH_MESON
+	depends on OF && (ARCH_MESON || COMPILE_TEST)
+	select GENERIC_PHY
+	select REGMAP_MMIO
+	select GENERIC_PHY_MIPI_DPHY
+	help
+	  Enable this to support the Meson MIPI Analog DPHY found in Meson G12A
+	  SoCs.
+	  If unsure, say N.
+
 config PHY_MESON_AXG_PCIE
 	tristate "Meson AXG PCIE PHY driver"
 	default ARCH_MESON
drivers/phy/amlogic/Makefile +1 -0
index 8fa07fbd0d92..2eada0a683ca 100644
@@ -3,6 +3,7 @@ obj-$(CONFIG_PHY_MESON8B_USB2)			+= phy-meson8b-usb2.o
 obj-$(CONFIG_PHY_MESON_GXL_USB2)		+= phy-meson-gxl-usb2.o
 obj-$(CONFIG_PHY_MESON_G12A_USB2)		+= phy-meson-g12a-usb2.o
 obj-$(CONFIG_PHY_MESON_G12A_USB3_PCIE)		+= phy-meson-g12a-usb3-pcie.o
+obj-$(CONFIG_PHY_MESON_G12A_MIPI_DPHY_ANALOG)	+= phy-meson-g12a-mipi-dphy-analog.o
 obj-$(CONFIG_PHY_MESON_AXG_PCIE)		+= phy-meson-axg-pcie.o
 obj-$(CONFIG_PHY_MESON_AXG_MIPI_PCIE_ANALOG)	+= phy-meson-axg-mipi-pcie-analog.o
 obj-$(CONFIG_PHY_MESON_AXG_MIPI_DPHY)		+= phy-meson-axg-mipi-dphy.o
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +177 -0

177 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH v3 2/2] phy: amlogic: Add G12A Analog MIPI D-PHY driver

Hi Neil,

On Fri, Jan 7, 2022 at 4:06 PM Neil Armstrong <[email protected]> wrote:
[...]

drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c line 36

Quoted 10 lines
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +10 -0
+#define HHI_MIPI_CNTL2 0x08
+#define                HHI_MIPI_CNTL2_DIF_TX_CTL1      GENMASK(31, 16)
+#define                HHI_MIPI_CNTL2_CH_EN            GENMASK(15, 11)
+#define                HHI_MIPI_CNTL2_DIF_TX_CTL0      GENMASK(10, 0)
+
+#define DSI_LANE_0                             BIT(4)
+#define DSI_LANE_1                             BIT(3)
+#define DSI_LANE_CLK                           BIT(2)
+#define DSI_LANE_2                             BIT(1)
+#define DSI_LANE_3                             BIT(0)

At first I thought that these should be named HHI_MIPI_CNTL2_DSI_LANE_0 (and similar).
But then I understood that they aren't bits directly in HHI_MIPI_CNTL2 but they belong to HHI_MIPI_CNTL2_CH_EN.
Have you considered naming them for example HHI_MIPI_CNTL2_CH_EN_DSI_LANE_0 to make this more clear?

[...]

drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c line 137

Quoted 4 lines
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +4 -0
+       if (IS_ERR(map)) {
+               dev_err(dev,
+                       "failed to get HHI regmap\n");
+               return PTR_ERR(map);

I suggest using:
return dev_err_probe(dev, PTR_ERR(map), "failed to get HHI regmap\n");
to simplify the code

[...]

drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c line 147

Quoted 5 lines
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +5 -0
+       if (IS_ERR(priv->phy)) {
+               ret = PTR_ERR(priv->phy);
+               if (ret != -EPROBE_DEFER)
+                       dev_err(dev, "failed to create PHY\n");
+               return ret;

and similar here:
return dev_err_probe(dev, PTR_ERR(priv->phy), "failed to create PHY\n");

[...]

drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c line 162

Quoted 5 lines
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +5 -0
+static const struct of_device_id phy_g12a_mipi_dphy_analog_of_match[] = {
+       {
+               .compatible = "amlogic,g12a-mipi-dphy-analog",
+       },
+       { },

In the past I was suggested to use:
{ /* sentinel */ }
meaning: no trailing comma here so nobody can add entries after the sentinel by accident.
I suggest doing the same here if you re-spin this series.

Thank you!
Martin

#7 lore raw

Re: [PATCH v3 2/2] phy: amlogic: Add G12A Analog MIPI D-PHY driver

Hi,

Quoted 45 lines · Martin Blumenstingl

Hi Neil,

On Fri, Jan 7, 2022 at 4:06 PM Neil Armstrong <[email protected]> wrote:
[...]

drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c line 36

Quoted 10 lines
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +10 -0
+#define HHI_MIPI_CNTL2 0x08
+#define                HHI_MIPI_CNTL2_DIF_TX_CTL1      GENMASK(31, 16)
+#define                HHI_MIPI_CNTL2_CH_EN            GENMASK(15, 11)
+#define                HHI_MIPI_CNTL2_DIF_TX_CTL0      GENMASK(10, 0)
+
+#define DSI_LANE_0                             BIT(4)
+#define DSI_LANE_1                             BIT(3)
+#define DSI_LANE_CLK                           BIT(2)
+#define DSI_LANE_2                             BIT(1)
+#define DSI_LANE_3                             BIT(0)

At first I thought that these should be named HHI_MIPI_CNTL2_DSI_LANE_0 (and similar).
But then I understood that they aren't bits directly in HHI_MIPI_CNTL2 but they belong to HHI_MIPI_CNTL2_CH_EN.
Have you considered naming them for example HHI_MIPI_CNTL2_CH_EN_DSI_LANE_0 to make this more clear?

[...]

drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c line 137

Quoted 4 lines
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +4 -0
+       if (IS_ERR(map)) {
+               dev_err(dev,
+                       "failed to get HHI regmap\n");
+               return PTR_ERR(map);

I suggest using:
return dev_err_probe(dev, PTR_ERR(map), "failed to get HHI regmap\n");
to simplify the code

[...]

drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c line 147

Quoted 5 lines
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +5 -0
+       if (IS_ERR(priv->phy)) {
+               ret = PTR_ERR(priv->phy);
+               if (ret != -EPROBE_DEFER)
+                       dev_err(dev, "failed to create PHY\n");
+               return ret;

and similar here:
return dev_err_probe(dev, PTR_ERR(priv->phy), "failed to create PHY\n");

[...]

drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c line 162

Quoted 5 lines
drivers/phy/amlogic/phy-meson-g12a-mipi-dphy-analog.c new file +5 -0
+static const struct of_device_id phy_g12a_mipi_dphy_analog_of_match[] = {
+       {
+               .compatible = "amlogic,g12a-mipi-dphy-analog",
+       },
+       { },
Quoted 5 lines

In the past I was suggested to use:
{ /* sentinel */ }
meaning: no trailing comma here so nobody can add entries after the sentinel by accident.
I suggest doing the same here if you re-spin this series.

Yep, will do the changes,

Thanks,
Neil

Quoted 5 lines

Thank you!
Martin

Signature · 3 lines
linux-phy mailing list
[email protected]
https://lists.infradead.org/mailman/listinfo/linux-phy