RE: [PATCH v7 4/8] drm: imx: Add i.MX 6 MIPI DSI host platform driver
From: Daniel Vetter Date: Thu, Apr 30, 2020 at 14:58:41 > On Tue, Apr 28, 2020 at 10:08:04PM +0300, Adrian Ratiu wrote: > > Hi Daniel, > > > > On Tue, 28 Apr 2020, Daniel Vetter wrote: > > > On Wed, Apr 22, 2020 at 04:07:27AM +0300, Laurent Pinchart wrote: > > > > Hi Adrian, On Tue, Apr 21, 2020 at 07:16:06PM +0300, Adrian Ratiu > > > > wrote: > This adds support for the Synopsis DesignWare MIPI DSI > > > > v1.01 > host controller which is embedded in i.MX 6 SoCs. Based on > > > > > following patches, but updated/extended to work with existing > > > > > support found in the kernel: - drm: imx: Support Synopsys > > > > > DesignWare MIPI DSI host controller > Signed-off-by: Liu Ying > > > > > Cc: Fabio Estevam > > > > Cc: Enric Balletbo > Serra Reviewed-by: Emil > > > > Velikov > Tested-by: Adrian Pop > > > > > Tested-by: Arnaud Ferraris > > > > > Signed-off-by: Sjoerd Simons > > > > > Signed-off-by: Martyn Welch > > > > > Signed-off-by: Adrian Ratiu > > > > > --- Changes since v6: > - Replaced > > > > custom noop encoder with the simple drm encoder > (Enric) - Added > > > > CONFIG_DRM_IMX6_MIPI_DSI depends on > CONFIG_OF (Enric) - Dropped > > > > imx_mipi_dsi_register() because > now it only creates the dummy > > > > encoder which can easily be > done directly in imx_dsi_bind() > > > > > Changes since v5: > - Reword to remove unrelated device tree patch > > > > mention > (Fabio) - Move pllref_clk enable/disable to bind/unbind > > > > > (Ezequiel) - Fix freescale.com -> nxp.com email addresses > > > > > (Fabio) - Also added myself as module author (Fabio) - Use > > > > > DRM_DEV_* macros for consistency, print more error msg > Changes > > > > since v4: > - Split off driver-specific configuration of phy > > > > timings > due to new upstream API. - Move regmap infrastructure > > > > > logic to separate commit (Ezequiel) - Move dsi v1.01 layout > > > > > addition to a separate commit (Ezequiel) - Minor warnings > and > > > > driver name fixes > Changes since v3: > - Renamed platform driver > > > > to reflect it's i.MX6 > only. (Fabio) > Changes since v2: > - > > > > Fixed commit tags. (Emil) > Changes since v1: > - Moved register > > > > definitions & regmap initialization into > bridge module. Platform > > > > drivers get the regmap via > plat_data after calling the bridge > > > > probe. (Emil) > --- > drivers/gpu/drm/imx/Kconfig| 8 > > > > + > drivers/gpu/drm/imx/Makefile | 1 + > > > > > drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c | 391 > > > > > + 3 files changed, 400 insertions(+) > > > > > create mode 100644 drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > diff > > > > --git a/drivers/gpu/drm/imx/Kconfig > b/drivers/gpu/drm/imx/Kconfig > > > > index > 207bf7409dfba..0dffc72df7922 100644 --- > > > > > a/drivers/gpu/drm/imx/Kconfig +++ > b/drivers/gpu/drm/imx/Kconfig @@ > > > > -39,3 +39,11 @@ config > DRM_IMX_HDMI > depends on DRM_IMX help > > > > Choose this if you want to use > HDMI on i.MX6. > + +config > > > > DRM_IMX6_MIPI_DSI + tristate "Freescale i.MX6 > DRM MIPI DSI" > > > > + select DRM_DW_MIPI_DSI +depends on > DRM_IMX + depends > > > > on OF > > > > + help +Choose this if you want > to use MIPI DSI on i.MX6. > > > > diff > > > > --git > a/drivers/gpu/drm/imx/Makefile > > > > b/drivers/gpu/drm/imx/Makefile > index 21cdcc2faabc8..9a7843c593478 > > > > 100644 --- > a/drivers/gpu/drm/imx/Makefile +++ > > > > > b/drivers/gpu/drm/imx/Makefile @@ -9,3 +9,4 @@ > > > > > obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o > obj-$(CONFIG_DRM_IMX_LDB) > > > > += imx-ldb.o > obj-$(CONFIG_DRM_IMX_HDMI) += dw_hdmi-imx.o > > > > > +obj-$(CONFIG_DRM_IMX6_MIPI_DSI) += dw_mipi_dsi-imx6.o diff > --git > > > > a/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > > > > > b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c new file mode 100644 > > > > > index 0..f8a0a4fe16e21 --- /dev/null +++ > > > > > b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c @@ -0,0 +1,391 @@ > +// > > > > SPDX-License-Identifier: GPL-2.0+ +/* + * i.MX6 drm > driver - MIPI > > > > DSI Host Controller + * + * Copyright (C) > 2011-2015 Freescale > > > > Semiconductor, Inc. + * Copyright (C) > 2019-2020 Collabora, Ltd. > > > > + */ + +#include > +#include > > > > +#include > +#include > > > > +#include > > > > > +#include +#include > +#include > > > > +#include > +#include > > > > > +#include +#include > > > > > +#include + +#include "imx-drm.h" > > > > + > +#define DSI_PWR_UP 0x04 +#define > RESET > > > > 0 +#define > > > > POWERUP > BIT(0) + +#define DSI_PHY_IF_CTRL 0x5c > > > > > +#define > > > > PHY_IF_CTRL_RESET 0x0 + +#define > DSI_PHY_TST_CTRL0 > > > > 0x64 +#define > > > > PHY_TESTCLK > BIT(1) +#define PHY_UNTESTCLK 0 > > > > +#define > > > > > PHY_TESTCLR BIT(0) +#define > PHY_UNTE
Re: [PATCH v7 4/8] drm: imx: Add i.MX 6 MIPI DSI host platform driver
On Tue, Apr 28, 2020 at 10:08:04PM +0300, Adrian Ratiu wrote: > Hi Daniel, > > On Tue, 28 Apr 2020, Daniel Vetter wrote: > > On Wed, Apr 22, 2020 at 04:07:27AM +0300, Laurent Pinchart wrote: > > > Hi Adrian, On Tue, Apr 21, 2020 at 07:16:06PM +0300, Adrian Ratiu > > > wrote: > This adds support for the Synopsis DesignWare MIPI DSI > > > v1.01 > host controller which is embedded in i.MX 6 SoCs. Based on > > > > following patches, but updated/extended to work with existing > > > > support found in the kernel: - drm: imx: Support Synopsys > > > > DesignWare MIPI DSI host controller > Signed-off-by: Liu Ying > > > > Cc: Fabio Estevam > > > Cc: Enric Balletbo > Serra Reviewed-by: Emil > > > Velikov > Tested-by: Adrian Pop > > > > Tested-by: Arnaud Ferraris > > > > Signed-off-by: Sjoerd Simons > > > > Signed-off-by: Martyn Welch > > > > Signed-off-by: Adrian Ratiu > > > > --- Changes since v6: > - Replaced > > > custom noop encoder with the simple drm encoder > (Enric) - Added > > > CONFIG_DRM_IMX6_MIPI_DSI depends on > CONFIG_OF (Enric) - Dropped > > > imx_mipi_dsi_register() because > now it only creates the dummy > > > encoder which can easily be > done directly in imx_dsi_bind() > > > > Changes since v5: > - Reword to remove unrelated device tree patch > > > mention > (Fabio) - Move pllref_clk enable/disable to bind/unbind > > > > (Ezequiel) - Fix freescale.com -> nxp.com email addresses > > > > (Fabio) - Also added myself as module author (Fabio) - Use > > > > DRM_DEV_* macros for consistency, print more error msg > Changes > > > since v4: > - Split off driver-specific configuration of phy > > > timings > due to new upstream API. - Move regmap infrastructure > > > > logic to separate commit (Ezequiel) - Move dsi v1.01 layout > > > > addition to a separate commit (Ezequiel) - Minor warnings > and > > > driver name fixes > Changes since v3: > - Renamed platform driver > > > to reflect it's i.MX6 > only. (Fabio) > Changes since v2: > - > > > Fixed commit tags. (Emil) > Changes since v1: > - Moved register > > > definitions & regmap initialization into > bridge module. Platform > > > drivers get the regmap via > plat_data after calling the bridge > > > probe. (Emil) > --- > drivers/gpu/drm/imx/Kconfig| 8 > > > + > drivers/gpu/drm/imx/Makefile | 1 + > > > > drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c | 391 > > > > + 3 files changed, 400 insertions(+) > > > > create mode 100644 drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > diff > > > --git a/drivers/gpu/drm/imx/Kconfig > b/drivers/gpu/drm/imx/Kconfig > > > index > 207bf7409dfba..0dffc72df7922 100644 --- > > > > a/drivers/gpu/drm/imx/Kconfig +++ > b/drivers/gpu/drm/imx/Kconfig @@ > > > -39,3 +39,11 @@ config > DRM_IMX_HDMI > depends on DRM_IMX help > > > Choose this if you want to use > HDMI on i.MX6. > + +config > > > DRM_IMX6_MIPI_DSI + tristate "Freescale i.MX6 > DRM MIPI DSI" > > > + select DRM_DW_MIPI_DSI +depends on > DRM_IMX + depends on OF > > > + help +Choose this if you want > to use MIPI DSI on i.MX6. diff > > > --git > a/drivers/gpu/drm/imx/Makefile > > > b/drivers/gpu/drm/imx/Makefile > index 21cdcc2faabc8..9a7843c593478 > > > 100644 --- > a/drivers/gpu/drm/imx/Makefile +++ > > > > b/drivers/gpu/drm/imx/Makefile @@ -9,3 +9,4 @@ > > > > obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o > obj-$(CONFIG_DRM_IMX_LDB) > > > += imx-ldb.o > obj-$(CONFIG_DRM_IMX_HDMI) += dw_hdmi-imx.o > > > > +obj-$(CONFIG_DRM_IMX6_MIPI_DSI) += dw_mipi_dsi-imx6.o diff > --git > > > a/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > > > > b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c new file mode 100644 > > > > index 0..f8a0a4fe16e21 --- /dev/null +++ > > > > b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c @@ -0,0 +1,391 @@ > +// > > > SPDX-License-Identifier: GPL-2.0+ +/* + * i.MX6 drm > driver - MIPI > > > DSI Host Controller + * + * Copyright (C) > 2011-2015 Freescale > > > Semiconductor, Inc. + * Copyright (C) > 2019-2020 Collabora, Ltd. > > > + */ + +#include > +#include > > > +#include > +#include > > > +#include > > > > +#include +#include > +#include > > > +#include > +#include > > > > +#include +#include > > > > +#include + +#include "imx-drm.h" > > > + > +#define DSI_PWR_UP 0x04 +#define > RESET > > > 0 +#define > > > POWERUP > BIT(0) + +#define DSI_PHY_IF_CTRL 0x5c > > > > +#define > > > PHY_IF_CTRL_RESET 0x0 + +#define > DSI_PHY_TST_CTRL0 > > > 0x64 +#define > > > PHY_TESTCLK > BIT(1) +#define PHY_UNTESTCLK 0 > > > +#define > > > > PHY_TESTCLR BIT(0) +#define > PHY_UNTESTCLR > > > 0 + +#define > > > > DSI_PHY_TST_CTRL1 0x68 +#define PHY_TESTEN > BIT(16) +#define > > > PHY_UNTESTEN 0 +#define > PHY_TESTDOUT(n) > > > (((n) & 0xff) << 8) > > > > +#defin
Re: [PATCH v7 4/8] drm: imx: Add i.MX 6 MIPI DSI host platform driver
Hi Daniel, On Tue, 28 Apr 2020, Daniel Vetter wrote: On Wed, Apr 22, 2020 at 04:07:27AM +0300, Laurent Pinchart wrote: Hi Adrian, On Tue, Apr 21, 2020 at 07:16:06PM +0300, Adrian Ratiu wrote: > This adds support for the Synopsis DesignWare MIPI DSI v1.01 > host controller which is embedded in i.MX 6 SoCs. Based on > following patches, but updated/extended to work with existing > support found in the kernel: - drm: imx: Support Synopsys > DesignWare MIPI DSI host controller > Signed-off-by: Liu Ying > Cc: Fabio Estevam Cc: Enric Balletbo > Serra Reviewed-by: Emil Velikov > Tested-by: Adrian Pop > Tested-by: Arnaud Ferraris > Signed-off-by: Sjoerd Simons > Signed-off-by: Martyn Welch > Signed-off-by: Adrian Ratiu > --- Changes since v6: > - Replaced custom noop encoder with the simple drm encoder > (Enric) - Added CONFIG_DRM_IMX6_MIPI_DSI depends on > CONFIG_OF (Enric) - Dropped imx_mipi_dsi_register() because > now it only creates the dummy encoder which can easily be > done directly in imx_dsi_bind() > Changes since v5: > - Reword to remove unrelated device tree patch mention > (Fabio) - Move pllref_clk enable/disable to bind/unbind > (Ezequiel) - Fix freescale.com -> nxp.com email addresses > (Fabio) - Also added myself as module author (Fabio) - Use > DRM_DEV_* macros for consistency, print more error msg > Changes since v4: > - Split off driver-specific configuration of phy timings > due to new upstream API. - Move regmap infrastructure > logic to separate commit (Ezequiel) - Move dsi v1.01 layout > addition to a separate commit (Ezequiel) - Minor warnings > and driver name fixes > Changes since v3: > - Renamed platform driver to reflect it's i.MX6 > only. (Fabio) > Changes since v2: > - Fixed commit tags. (Emil) > Changes since v1: > - Moved register definitions & regmap initialization into > bridge module. Platform drivers get the regmap via > plat_data after calling the bridge probe. (Emil) > --- > drivers/gpu/drm/imx/Kconfig| 8 + > drivers/gpu/drm/imx/Makefile | 1 + > drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c | 391 > + 3 files changed, 400 insertions(+) > create mode 100644 drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > diff --git a/drivers/gpu/drm/imx/Kconfig > b/drivers/gpu/drm/imx/Kconfig index > 207bf7409dfba..0dffc72df7922 100644 --- > a/drivers/gpu/drm/imx/Kconfig +++ > b/drivers/gpu/drm/imx/Kconfig @@ -39,3 +39,11 @@ config > DRM_IMX_HDMI > depends on DRM_IMX help Choose this if you want to use > HDMI on i.MX6. > + +config DRM_IMX6_MIPI_DSI + tristate "Freescale i.MX6 > DRM MIPI DSI" + select DRM_DW_MIPI_DSI + depends on > DRM_IMX + depends on OF + help + Choose this if you want > to use MIPI DSI on i.MX6. diff --git > a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile > index 21cdcc2faabc8..9a7843c593478 100644 --- > a/drivers/gpu/drm/imx/Makefile +++ > b/drivers/gpu/drm/imx/Makefile @@ -9,3 +9,4 @@ > obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o > obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o > obj-$(CONFIG_DRM_IMX_HDMI) += dw_hdmi-imx.o > +obj-$(CONFIG_DRM_IMX6_MIPI_DSI) += dw_mipi_dsi-imx6.o diff > --git a/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c new file mode 100644 > index 0..f8a0a4fe16e21 --- /dev/null +++ > b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c @@ -0,0 +1,391 @@ > +// SPDX-License-Identifier: GPL-2.0+ +/* + * i.MX6 drm > driver - MIPI DSI Host Controller + * + * Copyright (C) > 2011-2015 Freescale Semiconductor, Inc. + * Copyright (C) > 2019-2020 Collabora, Ltd. + */ + +#include > +#include +#include > +#include +#include > +#include +#include > +#include +#include > +#include > +#include +#include > +#include + +#include "imx-drm.h" + > +#define DSI_PWR_UP 0x04 +#define > RESET0 +#define POWERUP > BIT(0) + +#define DSI_PHY_IF_CTRL 0x5c > +#define PHY_IF_CTRL_RESET 0x0 + +#define > DSI_PHY_TST_CTRL0 0x64 +#define PHY_TESTCLK > BIT(1) +#define PHY_UNTESTCLK 0 +#define > PHY_TESTCLR BIT(0) +#define > PHY_UNTESTCLR 0 + +#define > DSI_PHY_TST_CTRL1 0x68 +#define PHY_TESTEN > BIT(16) +#define PHY_UNTESTEN 0 +#define > PHY_TESTDOUT(n) (((n) & 0xff) << 8) > +#define PHY_TESTDIN(n) (((n) & 0xff) << > 0) + +struct imx_mipi_dsi { + struct drm_encoder > encoder; + struct device *dev; + struct regmap *mux_sel; + > struct dw_mipi_dsi *mipi_dsi; + struct clk *pllref_clk; + > + void __iomem *base; + unsigned int lane_mbps; +}; + > +struct dphy_pll_testdin_map { + unsigned int max_mbps; + > u8 testdin; +}; + +/* The table is based on 27MHz DPHY pll > reference clock. */ +static const struct dphy_pll_testdin_map > dptdin_map[] = { + {160, 0x04}, {180, 0x24}, {200, 0x44}, > {210, 0x06}, + {240, 0x26}, {250, 0x46}, {270, 0x08}, > {300, 0x28}, + {330, 0x48}, {360, 0x2a}, {400, 0x4a}, > {450
Re: [PATCH v7 4/8] drm: imx: Add i.MX 6 MIPI DSI host platform driver
On Wed, Apr 22, 2020 at 04:07:27AM +0300, Laurent Pinchart wrote: > Hi Adrian, > > On Tue, Apr 21, 2020 at 07:16:06PM +0300, Adrian Ratiu wrote: > > This adds support for the Synopsis DesignWare MIPI DSI v1.01 host > > controller which is embedded in i.MX 6 SoCs. > > > > Based on following patches, but updated/extended to work with existing > > support found in the kernel: > > > > - drm: imx: Support Synopsys DesignWare MIPI DSI host controller > > Signed-off-by: Liu Ying > > > > Cc: Fabio Estevam > > Cc: Enric Balletbo Serra > > Reviewed-by: Emil Velikov > > Tested-by: Adrian Pop > > Tested-by: Arnaud Ferraris > > Signed-off-by: Sjoerd Simons > > Signed-off-by: Martyn Welch > > Signed-off-by: Adrian Ratiu > > --- > > Changes since v6: > > - Replaced custom noop encoder with the simple drm encoder (Enric) > > - Added CONFIG_DRM_IMX6_MIPI_DSI depends on CONFIG_OF (Enric) > > - Dropped imx_mipi_dsi_register() because now it only creates the > > dummy encoder which can easily be done directly in imx_dsi_bind() > > > > Changes since v5: > > - Reword to remove unrelated device tree patch mention (Fabio) > > - Move pllref_clk enable/disable to bind/unbind (Ezequiel) > > - Fix freescale.com -> nxp.com email addresses (Fabio) > > - Also added myself as module author (Fabio) > > - Use DRM_DEV_* macros for consistency, print more error msg > > > > Changes since v4: > > - Split off driver-specific configuration of phy timings due > > to new upstream API. > > - Move regmap infrastructure logic to separate commit (Ezequiel) > > - Move dsi v1.01 layout addition to a separate commit (Ezequiel) > > - Minor warnings and driver name fixes > > > > Changes since v3: > > - Renamed platform driver to reflect it's i.MX6 only. (Fabio) > > > > Changes since v2: > > - Fixed commit tags. (Emil) > > > > Changes since v1: > > - Moved register definitions & regmap initialization into bridge > > module. Platform drivers get the regmap via plat_data after > > calling the bridge probe. (Emil) > > --- > > drivers/gpu/drm/imx/Kconfig| 8 + > > drivers/gpu/drm/imx/Makefile | 1 + > > drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c | 391 + > > 3 files changed, 400 insertions(+) > > create mode 100644 drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > > > > diff --git a/drivers/gpu/drm/imx/Kconfig b/drivers/gpu/drm/imx/Kconfig > > index 207bf7409dfba..0dffc72df7922 100644 > > --- a/drivers/gpu/drm/imx/Kconfig > > +++ b/drivers/gpu/drm/imx/Kconfig > > @@ -39,3 +39,11 @@ config DRM_IMX_HDMI > > depends on DRM_IMX > > help > > Choose this if you want to use HDMI on i.MX6. > > + > > +config DRM_IMX6_MIPI_DSI > > + tristate "Freescale i.MX6 DRM MIPI DSI" > > + select DRM_DW_MIPI_DSI > > + depends on DRM_IMX > > + depends on OF > > + help > > + Choose this if you want to use MIPI DSI on i.MX6. > > diff --git a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile > > index 21cdcc2faabc8..9a7843c593478 100644 > > --- a/drivers/gpu/drm/imx/Makefile > > +++ b/drivers/gpu/drm/imx/Makefile > > @@ -9,3 +9,4 @@ obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o > > obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o > > > > obj-$(CONFIG_DRM_IMX_HDMI) += dw_hdmi-imx.o > > +obj-$(CONFIG_DRM_IMX6_MIPI_DSI) += dw_mipi_dsi-imx6.o > > diff --git a/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > > b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > > new file mode 100644 > > index 0..f8a0a4fe16e21 > > --- /dev/null > > +++ b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > > @@ -0,0 +1,391 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* > > + * i.MX6 drm driver - MIPI DSI Host Controller > > + * > > + * Copyright (C) 2011-2015 Freescale Semiconductor, Inc. > > + * Copyright (C) 2019-2020 Collabora, Ltd. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "imx-drm.h" > > + > > +#define DSI_PWR_UP 0x04 > > +#define RESET 0 > > +#define POWERUPBIT(0) > > + > > +#define DSI_PHY_IF_CTRL0x5c > > +#define PHY_IF_CTRL_RESET 0x0 > > + > > +#define DSI_PHY_TST_CTRL0 0x64 > > +#define PHY_TESTCLKBIT(1) > > +#define PHY_UNTESTCLK 0 > > +#define PHY_TESTCLRBIT(0) > > +#define PHY_UNTESTCLR 0 > > + > > +#define DSI_PHY_TST_CTRL1 0x68 > > +#define PHY_TESTEN BIT(16) > > +#define PHY_UNTESTEN 0 > > +#define PHY_TESTDOUT(n)(((n) & 0xff) << 8) > > +#define PHY_TESTDIN(n) (((n) & 0xff) << 0) > > + > > +struct imx_mipi_dsi { > > + struct drm_encoder encoder; > > + struct device *dev; > > + struct regmap *mux_sel; > > +
Re: [PATCH v7 4/8] drm: imx: Add i.MX 6 MIPI DSI host platform driver
Hi Adrian, On Wed, Apr 22, 2020 at 12:33:10PM +0300, Adrian Ratiu wrote: > On Wed, 22 Apr 2020, Laurent Pinchart wrote: > > On Tue, Apr 21, 2020 at 07:16:06PM +0300, Adrian Ratiu wrote: > >> This adds support for the Synopsis DesignWare MIPI DSI v1.01 > >> host controller which is embedded in i.MX 6 SoCs. Based on > >> following patches, but updated/extended to work with existing > >> support found in the kernel: - drm: imx: Support Synopsys > >> DesignWare MIPI DSI host controller > >> Signed-off-by: Liu Ying > >> Cc: Fabio Estevam Cc: Enric Balletbo > >> Serra Reviewed-by: Emil Velikov > >> Tested-by: Adrian Pop > >> Tested-by: Arnaud Ferraris > >> Signed-off-by: Sjoerd Simons > >> Signed-off-by: Martyn Welch > >> Signed-off-by: Adrian Ratiu > >> --- Changes since v6: > >> - Replaced custom noop encoder with the simple drm encoder > >> (Enric) - Added CONFIG_DRM_IMX6_MIPI_DSI depends on CONFIG_OF > >> (Enric) - Dropped imx_mipi_dsi_register() because now it only > >> creates the dummy encoder which can easily be done directly > >> in imx_dsi_bind() > >> Changes since v5: > >> - Reword to remove unrelated device tree patch mention > >> (Fabio) - Move pllref_clk enable/disable to bind/unbind > >> (Ezequiel) - Fix freescale.com -> nxp.com email addresses > >> (Fabio) - Also added myself as module author (Fabio) - Use > >> DRM_DEV_* macros for consistency, print more error msg > >> Changes since v4: > >> - Split off driver-specific configuration of phy timings due > >> to new upstream API. - Move regmap infrastructure logic to > >> separate commit (Ezequiel) - Move dsi v1.01 layout addition > >> to a separate commit (Ezequiel) - Minor warnings and driver > >> name fixes > >> Changes since v3: > >> - Renamed platform driver to reflect it's i.MX6 only. (Fabio) > >> Changes since v2: > >> - Fixed commit tags. (Emil) > >> Changes since v1: > >> - Moved register definitions & regmap initialization into > >> bridge module. Platform drivers get the regmap via plat_data > >> after calling the bridge probe. (Emil) > >> --- > >> drivers/gpu/drm/imx/Kconfig| 8 + > >> drivers/gpu/drm/imx/Makefile | 1 + > >> drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c | 391 + > >> 3 files changed, 400 insertions(+) > >> create mode 100644 drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > >> diff --git a/drivers/gpu/drm/imx/Kconfig b/drivers/gpu/drm/imx/Kconfig > >> index 207bf7409dfba..0dffc72df7922 100644 > >> --- a/drivers/gpu/drm/imx/Kconfig > >> +++ b/drivers/gpu/drm/imx/Kconfig > >> @@ -39,3 +39,11 @@ config DRM_IMX_HDMI > >>depends on DRM_IMX help Choose this if you want to use > >> HDMI on i.MX6. > >> + +config DRM_IMX6_MIPI_DSI + tristate "Freescale i.MX6 > >> DRM MIPI DSI" +select DRM_DW_MIPI_DSI +depends on > >> DRM_IMX + depends on OF + help +Choose this if you want > >> to use MIPI DSI on i.MX6. diff --git > >> a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile > >> index 21cdcc2faabc8..9a7843c593478 100644 --- > >> a/drivers/gpu/drm/imx/Makefile +++ > >> b/drivers/gpu/drm/imx/Makefile @@ -9,3 +9,4 @@ > >> obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o > >> obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o > >> obj-$(CONFIG_DRM_IMX_HDMI) += dw_hdmi-imx.o > >> +obj-$(CONFIG_DRM_IMX6_MIPI_DSI) += dw_mipi_dsi-imx6.o diff > >> --git a/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > >> b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c new file mode 100644 > >> index 0..f8a0a4fe16e21 --- /dev/null +++ > >> b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c @@ -0,0 +1,391 @@ +// > >> SPDX-License-Identifier: GPL-2.0+ +/* + * i.MX6 drm driver - > >> MIPI DSI Host Controller + * + * Copyright (C) 2011-2015 > >> Freescale Semiconductor, Inc. + * Copyright (C) 2019-2020 > >> Collabora, Ltd. + */ + +#include +#include > >> +#include +#include > >> +#include > >> +#include +#include > >> +#include +#include > >> +#include > >> +#include +#include > >> +#include + +#include "imx-drm.h" + +#define > >> DSI_PWR_UP 0x04 +#define RESET > >> 0 +#define POWERUP BIT(0) + +#define > >> DSI_PHY_IF_CTRL0x5c +#define > >> PHY_IF_CTRL_RESET 0x0 + +#define DSI_PHY_TST_CTRL0 > >> 0x64 +#define PHY_TESTCLK BIT(1) +#define > >> PHY_UNTESTCLK 0 +#define PHY_TESTCLR > >> BIT(0) +#define PHY_UNTESTCLR 0 + > >> +#define DSI_PHY_TST_CTRL1 0x68 +#define PHY_TESTEN > >> BIT(16) +#define PHY_UNTESTEN 0 +#define > >> PHY_TESTDOUT(n)(((n) & 0xff) << 8) > >> +#define PHY_TESTDIN(n)(((n) & 0xff) << > >> 0) + +struct imx_mipi_dsi { + struct drm_encoder > >> encoder; + struct device *dev; + struct regmap *mux_sel; + > >> struct dw_mipi_dsi *mipi_dsi; +s
Re: [PATCH v7 4/8] drm: imx: Add i.MX 6 MIPI DSI host platform driver
On Wed, 22 Apr 2020, Laurent Pinchart wrote: Hi Adrian, Hi Laurent, On Tue, Apr 21, 2020 at 07:16:06PM +0300, Adrian Ratiu wrote: This adds support for the Synopsis DesignWare MIPI DSI v1.01 host controller which is embedded in i.MX 6 SoCs. Based on following patches, but updated/extended to work with existing support found in the kernel: - drm: imx: Support Synopsys DesignWare MIPI DSI host controller Signed-off-by: Liu Ying Cc: Fabio Estevam Cc: Enric Balletbo Serra Reviewed-by: Emil Velikov Tested-by: Adrian Pop Tested-by: Arnaud Ferraris Signed-off-by: Sjoerd Simons Signed-off-by: Martyn Welch Signed-off-by: Adrian Ratiu --- Changes since v6: - Replaced custom noop encoder with the simple drm encoder (Enric) - Added CONFIG_DRM_IMX6_MIPI_DSI depends on CONFIG_OF (Enric) - Dropped imx_mipi_dsi_register() because now it only creates the dummy encoder which can easily be done directly in imx_dsi_bind() Changes since v5: - Reword to remove unrelated device tree patch mention (Fabio) - Move pllref_clk enable/disable to bind/unbind (Ezequiel) - Fix freescale.com -> nxp.com email addresses (Fabio) - Also added myself as module author (Fabio) - Use DRM_DEV_* macros for consistency, print more error msg Changes since v4: - Split off driver-specific configuration of phy timings due to new upstream API. - Move regmap infrastructure logic to separate commit (Ezequiel) - Move dsi v1.01 layout addition to a separate commit (Ezequiel) - Minor warnings and driver name fixes Changes since v3: - Renamed platform driver to reflect it's i.MX6 only. (Fabio) Changes since v2: - Fixed commit tags. (Emil) Changes since v1: - Moved register definitions & regmap initialization into bridge module. Platform drivers get the regmap via plat_data after calling the bridge probe. (Emil) --- drivers/gpu/drm/imx/Kconfig| 8 + drivers/gpu/drm/imx/Makefile | 1 + drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c | 391 + 3 files changed, 400 insertions(+) create mode 100644 drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c diff --git a/drivers/gpu/drm/imx/Kconfig b/drivers/gpu/drm/imx/Kconfig index 207bf7409dfba..0dffc72df7922 100644 --- a/drivers/gpu/drm/imx/Kconfig +++ b/drivers/gpu/drm/imx/Kconfig @@ -39,3 +39,11 @@ config DRM_IMX_HDMI depends on DRM_IMX help Choose this if you want to use HDMI on i.MX6. + +config DRM_IMX6_MIPI_DSI + tristate "Freescale i.MX6 DRM MIPI DSI" + select DRM_DW_MIPI_DSI + depends on DRM_IMX + depends on OF + help + Choose this if you want to use MIPI DSI on i.MX6. diff --git a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile index 21cdcc2faabc8..9a7843c593478 100644 --- a/drivers/gpu/drm/imx/Makefile +++ b/drivers/gpu/drm/imx/Makefile @@ -9,3 +9,4 @@ obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o obj-$(CONFIG_DRM_IMX_HDMI) += dw_hdmi-imx.o +obj-$(CONFIG_DRM_IMX6_MIPI_DSI) += dw_mipi_dsi-imx6.o diff --git a/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c new file mode 100644 index 0..f8a0a4fe16e21 --- /dev/null +++ b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c @@ -0,0 +1,391 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * i.MX6 drm driver - MIPI DSI Host Controller + * + * Copyright (C) 2011-2015 Freescale Semiconductor, Inc. + * Copyright (C) 2019-2020 Collabora, Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "imx-drm.h" + +#define DSI_PWR_UP 0x04 +#define RESET 0 +#define POWERUPBIT(0) + +#define DSI_PHY_IF_CTRL 0x5c +#define PHY_IF_CTRL_RESET 0x0 + +#define DSI_PHY_TST_CTRL0 0x64 +#define PHY_TESTCLK BIT(1) +#define PHY_UNTESTCLK 0 +#define PHY_TESTCLR BIT(0) +#define PHY_UNTESTCLR 0 + +#define DSI_PHY_TST_CTRL1 0x68 +#define PHY_TESTEN BIT(16) +#define PHY_UNTESTEN 0 +#define PHY_TESTDOUT(n) (((n) & 0xff) << 8) +#define PHY_TESTDIN(n) (((n) & 0xff) << 0) + +struct imx_mipi_dsi { + struct drm_encoder encoder; + struct device *dev; + struct regmap *mux_sel; + struct dw_mipi_dsi *mipi_dsi; + struct clk *pllref_clk; + + void __iomem *base; + unsigned int lane_mbps; +}; + +struct dphy_pll_testdin_map { + unsigned int max_mbps; + u8 testdin; +}; + +/* The table is based on 27MHz DPHY pll reference clock. */ +static const struct dphy_pll_testdin_map dptdin_map[] = { + {160, 0x04}, {180, 0x24}, {200, 0x44}, {210, 0x06}, + {240, 0x26}, {250, 0x46}, {270, 0x08}, {300, 0x28}, + {330, 0x48}, {360, 0x2a}, {400, 0x4a}, {450, 0x0c}, + {500, 0x2c}, {550, 0x0e}, {600, 0x2e}, {650, 0x10}, + {700, 0x30}, {750, 0x12}, {800, 0x32}, {850, 0x14}, + {900, 0x34}, {950, 0x54}, {1000, 0x74} +}; + +static inline struct imx_mipi_dsi *enc_to_dsi(struct drm_encoder *enc) +{ + return container_of(enc, struc
Re: [PATCH v7 4/8] drm: imx: Add i.MX 6 MIPI DSI host platform driver
Hi Adrian, On Tue, Apr 21, 2020 at 07:16:06PM +0300, Adrian Ratiu wrote: > This adds support for the Synopsis DesignWare MIPI DSI v1.01 host > controller which is embedded in i.MX 6 SoCs. > > Based on following patches, but updated/extended to work with existing > support found in the kernel: > > - drm: imx: Support Synopsys DesignWare MIPI DSI host controller > Signed-off-by: Liu Ying > > Cc: Fabio Estevam > Cc: Enric Balletbo Serra > Reviewed-by: Emil Velikov > Tested-by: Adrian Pop > Tested-by: Arnaud Ferraris > Signed-off-by: Sjoerd Simons > Signed-off-by: Martyn Welch > Signed-off-by: Adrian Ratiu > --- > Changes since v6: > - Replaced custom noop encoder with the simple drm encoder (Enric) > - Added CONFIG_DRM_IMX6_MIPI_DSI depends on CONFIG_OF (Enric) > - Dropped imx_mipi_dsi_register() because now it only creates the > dummy encoder which can easily be done directly in imx_dsi_bind() > > Changes since v5: > - Reword to remove unrelated device tree patch mention (Fabio) > - Move pllref_clk enable/disable to bind/unbind (Ezequiel) > - Fix freescale.com -> nxp.com email addresses (Fabio) > - Also added myself as module author (Fabio) > - Use DRM_DEV_* macros for consistency, print more error msg > > Changes since v4: > - Split off driver-specific configuration of phy timings due > to new upstream API. > - Move regmap infrastructure logic to separate commit (Ezequiel) > - Move dsi v1.01 layout addition to a separate commit (Ezequiel) > - Minor warnings and driver name fixes > > Changes since v3: > - Renamed platform driver to reflect it's i.MX6 only. (Fabio) > > Changes since v2: > - Fixed commit tags. (Emil) > > Changes since v1: > - Moved register definitions & regmap initialization into bridge > module. Platform drivers get the regmap via plat_data after > calling the bridge probe. (Emil) > --- > drivers/gpu/drm/imx/Kconfig| 8 + > drivers/gpu/drm/imx/Makefile | 1 + > drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c | 391 + > 3 files changed, 400 insertions(+) > create mode 100644 drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > > diff --git a/drivers/gpu/drm/imx/Kconfig b/drivers/gpu/drm/imx/Kconfig > index 207bf7409dfba..0dffc72df7922 100644 > --- a/drivers/gpu/drm/imx/Kconfig > +++ b/drivers/gpu/drm/imx/Kconfig > @@ -39,3 +39,11 @@ config DRM_IMX_HDMI > depends on DRM_IMX > help > Choose this if you want to use HDMI on i.MX6. > + > +config DRM_IMX6_MIPI_DSI > + tristate "Freescale i.MX6 DRM MIPI DSI" > + select DRM_DW_MIPI_DSI > + depends on DRM_IMX > + depends on OF > + help > + Choose this if you want to use MIPI DSI on i.MX6. > diff --git a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile > index 21cdcc2faabc8..9a7843c593478 100644 > --- a/drivers/gpu/drm/imx/Makefile > +++ b/drivers/gpu/drm/imx/Makefile > @@ -9,3 +9,4 @@ obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o > obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o > > obj-$(CONFIG_DRM_IMX_HDMI) += dw_hdmi-imx.o > +obj-$(CONFIG_DRM_IMX6_MIPI_DSI) += dw_mipi_dsi-imx6.o > diff --git a/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > new file mode 100644 > index 0..f8a0a4fe16e21 > --- /dev/null > +++ b/drivers/gpu/drm/imx/dw_mipi_dsi-imx6.c > @@ -0,0 +1,391 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * i.MX6 drm driver - MIPI DSI Host Controller > + * > + * Copyright (C) 2011-2015 Freescale Semiconductor, Inc. > + * Copyright (C) 2019-2020 Collabora, Ltd. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "imx-drm.h" > + > +#define DSI_PWR_UP 0x04 > +#define RESET0 > +#define POWERUP BIT(0) > + > +#define DSI_PHY_IF_CTRL 0x5c > +#define PHY_IF_CTRL_RESET0x0 > + > +#define DSI_PHY_TST_CTRL00x64 > +#define PHY_TESTCLK BIT(1) > +#define PHY_UNTESTCLK0 > +#define PHY_TESTCLR BIT(0) > +#define PHY_UNTESTCLR0 > + > +#define DSI_PHY_TST_CTRL10x68 > +#define PHY_TESTEN BIT(16) > +#define PHY_UNTESTEN 0 > +#define PHY_TESTDOUT(n) (((n) & 0xff) << 8) > +#define PHY_TESTDIN(n) (((n) & 0xff) << 0) > + > +struct imx_mipi_dsi { > + struct drm_encoder encoder; > + struct device *dev; > + struct regmap *mux_sel; > + struct dw_mipi_dsi *mipi_dsi; > + struct clk *pllref_clk; > + > + void __iomem *base; > + unsigned int lane_mbps; > +}; > + > +struct dphy_pll_testdin_map { > + unsigned int max_mbps; > + u8 testdin; > +}; > + > +/* The table is based on 27MHz DPHY pll reference clock. */ > +static const s