Skip to contentSkip to conversation

Mixel MIPI DPHY support for NXPs i.MX8 SOCs

PATCH Superseded Guido Günther 3 participants 7 messages May 7, 2019 – May 8, 2019

Subsystems (3)

v10 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v10 cover Mixel MIPI DPHY support for NXPs i.MX8 SOCs

This adds initial support for the Mixel IP based mipi dphy as found on i.MX8 processors. It has support for the i.MX8MQ, support for other variants can be added - once the platform specific parts are in - via the provided devdata. The driver is somewhat based on what's found in NXPs BSP.

Public documentation on the DPHY's registers is currently thin in the i.MX8 reference manuals (even on the i.MX8QXP form 11/18) so most of the values were taken from existing drivers. Newer NXP drivers have a bit more details so where possible the timings are calculated and validated.

This was tested with the an initial version of a NWL MIPI DSI host controller driver

    https://lists.freedesktop.org/archives/dri-devel/2019-March/209685.html

and a forward ported DCSS driver on linux-next 20190506.

Robert Chiras (the author of the corresponding driver in NXPs vendor tree) got this driver to work in his tree as well using mxsfb:

    https://www.spinics.net/lists/arm-kernel/msg711950.html

Changes from v9
* As per review comments from Fabio Estevam
* Sort includes alphabetically
* Remove excessive new lines between functions
* Drop error message on devm_ioremap_resource, handled by the core already.
* Don't default to it on i.MX8
* As per review comments from Sam Ravnborg
* Use clearer variablenames:

       struct regmap *regs -> regmap
       void __iomem *regs -> base

* Use u32 for all parameters of get_best_ratio()
* Don't use non-ascii symbols in debug message
* Change MODULE_LICENSE to GPL
* As per review comment from Andreas Färber
* Change co-authored-by: to co-developed-by:
* Collect Signed-off-by from Robert Chiras

Changes from v8
* Collect Reviewed-by from Rob Herring
* Fix {hs,clk}_prepare vs {hs,clk}_zero debug print out

Changes from v7
* As per review comments from Rob Herring
* Use fsl, as vendor prefix
* Drop changes to vendor-prefixes.txt due to that
* Shorten mixel_dphy to dphy in the example
* Fix an indentation error noticed by checkpatch that got introduced in v6
* Use lowercase letters in hex addresses in DT bindings example

Changes from v6
* Depend on HAS_IOMEM (fixes a build problem on UM spotted by kbuild)

Changes from v5
* Fix build problems on mips (spotted by the kbuild test robot) by using u32 consistently and long long for lp_t.

Changes from v4
* Build by default on ARCH_MXC && ARM64

Changes form v3
* Check correct variable after devm_ioremap_resource
* Add Robert Chiras as Co-authored-by since he's the author of the driver in NXPs BSP.

Changes from v2
* As per review comments from Fabio Estevam
* KConfig: select REGMAP_MMIO
* Drop phy_read
* Don't make phy_write inline
* Remove duplicate debugging output
* Comment style and typo fixes
* Add #defines's for PLL lock timing values
* Return correct error value when PLL fails to lock
* Check error when enabling clock
* Use devm_ioremap_resource
* As per review comments from Robert Chiras
* Deassert PD_DPHY after PLL lock (as per mixel ref manual)
* Assert PD_{DPHY,PLL} before power on (as per mixel ref manual)manual
* Add exit phy_op to reset CN/CM/CO

Changes from v1
* As per review comments from Fabio Estevam
* Kconfig: tristate mixel dphy support.
* Drop unused 'ret' in mixel_dphy_ref_power_off.
* Match values of DPHY_RXL{PRP,DRP} to those of
https://source.codeaurora.org/external/imx/linux-imx/log/?h=imx_4.14.78_1.0.0_ga
The previous values were based on 4.9.
* Use resource size on devm_ioremap, we have that in dt already.
* Use regmap so it's simple to dump the registers.
* Use regmap_read_poll_timeout instead of open coded loop.
* Add undocumented rxhs_settle register
* As per review comments from Sam Ravnborg
* Move driver to d/phy/freescale/
* Move SPDX-License-Identifier to top of file.
* Drop '/* #define DEBUG 1 */'.
* Use GPL-2.0+ since the vendor driver uses that as well.
* Drop the mutex, register access is now protected by regmap.
* Fix various style / indentation issues.
* Check for register read, write and ioremap errors
* Improve phy timing calculations
* Use LP clock rate where sensible, check for errors
* Use ad hoc forumulas for timings involving hs clock
* Switch from dphy_ops to devdata. Other i.MX8 variants differ in register layout too
* Add Mixel Inc to vendor-prefixes.txt

Guido Günther (2):
dt-bindings: phy: Add documentation for mixel dphy
phy: Add driver for mixel mipi dphy found on NXP's i.MX8 SoCs

 .../bindings/phy/mixel,mipi-dsi-phy.txt       |  29 +
 drivers/phy/freescale/Kconfig                 |  10 +
 drivers/phy/freescale/Makefile                |   1 +
 .../phy/freescale/phy-fsl-imx8-mipi-dphy.c    | 499 ++++++++++++++++++
 4 files changed, 539 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
 create mode 100644 drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
Signature · 1 line
2.20.1
#1 lore raw

PATCH v10 1/2 dt-bindings: phy: Add documentation for mixel dphy

Add support for the MIXEL DPHY IP as found on NXP's i.MX8MQ SoCs.

---
 .../bindings/phy/mixel,mipi-dsi-phy.txt       | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt
Documentation/devicetree/bindings/phy/mixel,mipi-dsi-phy.txt new file +29 -0
new file mode 100644
index 000000000000..9b23407233c0
@@ -0,0 +1,29 @@
+Mixel DSI PHY for i.MX8
+
+The Mixel MIPI-DSI PHY IP block is e.g. found on i.MX8 platforms (along the
+MIPI-DSI IP from Northwest Logic). It represents the physical layer for the
+electrical signals for DSI.
+
+Required properties:
+- compatible: Must be:
+  - "fsl,imx8mq-mipi-dphy"
+- clocks: Must contain an entry for each entry in clock-names.
+- clock-names: Must contain the following entries:
+  - "phy_ref": phandle and specifier referring to the DPHY ref clock
+- reg: the register range of the PHY controller
+- #phy-cells: number of cells in PHY, as defined in
+  Documentation/devicetree/bindings/phy/phy-bindings.txt
+  this must be <0>
+
+Optional properties:
+- power-domains: phandle to power domain
+
+Example:
+	dphy: dphy@30a0030 {
+		compatible = "fsl,imx8mq-mipi-dphy";
+		clocks = <&clk IMX8MQ_CLK_DSI_PHY_REF>;
+		clock-names = "phy_ref";
+		reg = <0x30a00300 0x100>;
+		power-domains = <&pd_mipi0>;
+		#phy-cells = <0>;
+        };
Signature · 1 line
2.20.1
#3 lore raw

PATCH v10 2/2 phy: Add driver for mixel mipi dphy found on NXP's i.MX8 SoCs

In reply to Guido Günther

This adds support for the Mixel DPHY as found on i.MX8 CPUs but since this is an IP core it will likely be found on others in the future. So instead of adding this to the nwl host driver make it a generic PHY driver.

The driver supports the i.MX8MQ. Support for i.MX8QM and i.MX8QXP can be added once the necessary system controller bits are in via mixel_dphy_devdata.

---
 drivers/phy/freescale/Kconfig                 |  10 +
 drivers/phy/freescale/Makefile                |   1 +
 .../phy/freescale/phy-fsl-imx8-mipi-dphy.c    | 499 ++++++++++++++++++
 3 files changed, 510 insertions(+)
 create mode 100644 drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c
drivers/phy/freescale/Kconfig +10 -0
index 832670b4952b..247be62d0981 100644
@@ -3,3 +3,13 @@ config PHY_FSL_IMX8MQ_USB
 	depends on OF && HAS_IOMEM
 	select GENERIC_PHY
 	default ARCH_MXC && ARM64
+
+config PHY_MIXEL_MIPI_DPHY
+	tristate "Mixel MIPI DSI PHY support"
+	depends on OF && HAS_IOMEM
+	select GENERIC_PHY
+	select GENERIC_PHY_MIPI_DPHY
+	select REGMAP_MMIO
+	help
+	  Enable this to add support for the Mixel DSI PHY as found
+	  on NXP's i.MX8 family of SOCs.
drivers/phy/freescale/Makefile +1 -0
index dc2b3f1f2f80..07491c926a2c 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_PHY_FSL_IMX8MQ_USB)	+= phy-fsl-imx8mq-usb.o
+obj-$(CONFIG_PHY_MIXEL_MIPI_DPHY)	+= phy-fsl-imx8-mipi-dphy.o
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c new file +499 -0

499 lines not on this page · raw message

Signature · 6 lines
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
reviewer Reviewed-by on v10 1/2
#2 lore raw

Re: [PATCH v10 1/2] dt-bindings: phy: Add documentation for mixel dphy

In reply to Guido Günther
Quoted 6 lines · Guido Günther

Add support for the MIXEL DPHY IP as found on NXP's i.MX8MQ SoCs.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

reviewer Reviewed-by on v10 2/2
#4 lore raw

Re: [PATCH v10 2/2] phy: Add driver for mixel mipi dphy found on NXP's i.MX8 SoCs

In reply to Guido Günther
Quoted 6 lines · Guido Günther

This adds support for the Mixel DPHY as found on i.MX8 CPUs but since this is an IP core it will likely be found on others in the future. So instead of adding this to the nwl host driver make it a generic PHY driver.

Quoted 7 lines

The driver supports the i.MX8MQ. Support for i.MX8QM and i.MX8QXP can be added once the necessary system controller bits are in via mixel_dphy_devdata.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v10 2/2
#5 lore raw

Re: [PATCH v10 2/2] phy: Add driver for mixel mipi dphy found on NXP's i.MX8 SoCs

In reply to Guido Günther

Hi Guido.

Looks good now, stumbled upon a few details I missed in last round. With these considered / fixed you can add my

Sam

drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c line 52

Quoted 7 lines
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c new file +7 -0
+#define CM(x)	(				\
+		((x) <	32)?0xe0|((x)-16) :	\
+		((x) <	64)?0xc0|((x)-32) :	\
+		((x) < 128)?0x80|((x)-64) :	\
+		((x) - 128))
+#define CN(x)	(((x) == 1)?0x1f : (((CN_BUF)>>((x)-1))&0x1f))
+#define CO(x)	((CO_BUF)>>(8-(x))&0x3)

A few spaces around the operators may help readability a little.

drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c line 117

Quoted 8 lines
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c new file +8 -0
+static int phy_write(struct phy *phy, u32 value, unsigned int reg)
+{
+	struct mixel_dphy_priv *priv = phy_get_drvdata(phy);
+	int ret;
+
+	ret = regmap_write(priv->regmap, reg, value);
+	if (ret < 0)
+		dev_err(&phy->dev, "Failed to write DPHY reg %d: %d", reg, ret);

I have recently learned that one has to remember trailign "\n"- please add.
Check all other dev_xxx as I noticed the newline is missing in a few more places.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+	dev_dbg(&phy->dev, "hs_clk/ref_clk=%ld/%ld ⩰ %d/%d\n",
                                                   ^

There was another of the symbols my terminal cannot show.

#6 lore raw

Re: [PATCH v10 2/2] phy: Add driver for mixel mipi dphy found on NXP's i.MX8 SoCs

Hi,

Quoted 18 lines · Sam Ravnborg

Hi Guido.

Looks good now, stumbled upon a few details I missed in last round. With these considered / fixed you can add my

Sam

drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c line 52

Quoted 7 lines
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c new file +7 -0
+#define CM(x)	(				\
+		((x) <	32)?0xe0|((x)-16) :	\
+		((x) <	64)?0xc0|((x)-32) :	\
+		((x) < 128)?0x80|((x)-64) :	\
+		((x) - 128))
+#define CN(x)	(((x) == 1)?0x1f : (((CN_BUF)>>((x)-1))&0x1f))
+#define CO(x)	((CO_BUF)>>(8-(x))&0x3)

A few spaces around the operators may help readability a little.

Quoted 13 lines

drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c line 117

Quoted 8 lines
drivers/phy/freescale/phy-fsl-imx8-mipi-dphy.c new file +8 -0
+static int phy_write(struct phy *phy, u32 value, unsigned int reg)
+{
+	struct mixel_dphy_priv *priv = phy_get_drvdata(phy);
+	int ret;
+
+	ret = regmap_write(priv->regmap, reg, value);
+	if (ret < 0)
+		dev_err(&phy->dev, "Failed to write DPHY reg %d: %d", reg, ret);

I have recently learned that one has to remember trailign "\n"- please add.
Check all other dev_xxx as I noticed the newline is missing in a few more places.

Argh...I thought I've fixed these up already but that was in the corresponding NWL driver only. Fixed now, thanks.

Quoted 7 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+
+	dev_dbg(&phy->dev, "hs_clk/ref_clk=%ld/%ld ⩰ %d/%d\n",
                                                   ^

There was another of the symbols my terminal cannot show.

Thanks! I've incorporated your suggestions and will send out a v11 by the end of the week in case there's more comments coming in. Cheers,
-- Guido