diff mbox series

[v3,2/4] soc: imx: imx8m-blk-ctrl: Add i.MX8MP media blk-ctrl

Message ID 20220326183329.5072-3-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series imx8mp: Add media block control | expand

Commit Message

Laurent Pinchart March 26, 2022, 6:33 p.m. UTC
From: Paul Elder <paul.elder@ideasonboard.com>

Add the description for the i.MX8MP media blk-ctrl.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #1
---
Changes since v1:

- Add ISP2 power domain and rename ISP to ISP1
---
 drivers/soc/imx/imx8m-blk-ctrl.c | 131 ++++++++++++++++++++++++++++++-
 1 file changed, 129 insertions(+), 2 deletions(-)

Comments

Marek Vasut March 26, 2022, 8:59 p.m. UTC | #1
On 3/26/22 19:33, Laurent Pinchart wrote:
> From: Paul Elder <paul.elder@ideasonboard.com>
> 
> Add the description for the i.MX8MP media blk-ctrl.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Marek Vasut <marex@denx.de>
> Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #1

Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #2 (the LVDS one)
Alexander Stein March 28, 2022, 6:51 a.m. UTC | #2
Hello Laurent,

Am Samstag, 26. März 2022, 19:33:27 CEST schrieb Laurent Pinchart:
> From: Paul Elder <paul.elder@ideasonboard.com>
> 
> Add the description for the i.MX8MP media blk-ctrl.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Marek Vasut <marex@denx.de>
> Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #1
> ---
> Changes since v1:
> 
> - Add ISP2 power domain and rename ISP to ISP1
> ---
>  drivers/soc/imx/imx8m-blk-ctrl.c | 131 ++++++++++++++++++++++++++++++-
>  1 file changed, 129 insertions(+), 2 deletions(-)

Which tree is this based on? I conflicts on linux-next with this patch [1],
which has already been picked by Shawn for 5.18. The conflict is rather simple 
though.

Best regards,
Alexander

[1] https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git/
commit/?h=imx-drivers-5.18&id=608d7c325e855cb4a853afef3cd9f0df594bd12d
Alexander Stein March 28, 2022, 6:54 a.m. UTC | #3
Hello Marek,

Am Samstag, 26. März 2022, 21:59:48 CEST schrieb Marek Vasut:
> On 3/26/22 19:33, Laurent Pinchart wrote:
> > From: Paul Elder <paul.elder@ideasonboard.com>
> > 
> > Add the description for the i.MX8MP media blk-ctrl.
> > 
> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Reviewed-by: Marek Vasut <marex@denx.de>
> > Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #1
> 
> Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #2 (the LVDS one)

You cc'ed me on the LCDIF patch, thanks for that. Could you please provide me 
the patch for the .dtsi as well? Thanks.

Best regards,
Alexander
Laurent Pinchart March 28, 2022, 6:58 a.m. UTC | #4
Hi Alexander,

On Mon, Mar 28, 2022 at 08:51:14AM +0200, Alexander Stein wrote:
> Am Samstag, 26. März 2022, 19:33:27 CEST schrieb Laurent Pinchart:
> > From: Paul Elder <paul.elder@ideasonboard.com>
> > 
> > Add the description for the i.MX8MP media blk-ctrl.
> > 
> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Reviewed-by: Marek Vasut <marex@denx.de>
> > Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #1
> > ---
> > Changes since v1:
> > 
> > - Add ISP2 power domain and rename ISP to ISP1
> > ---
> >  drivers/soc/imx/imx8m-blk-ctrl.c | 131 ++++++++++++++++++++++++++++++-
> >  1 file changed, 129 insertions(+), 2 deletions(-)
> 
> Which tree is this based on? I conflicts on linux-next with this patch [1],
> which has already been picked by Shawn for 5.18. The conflict is rather simple 
> though.

It's based on v5.17. I need to submit a v4, I'll rebase it on Shawn's
for-next branch.

> [1] https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git/
> commit/?h=imx-drivers-5.18&id=608d7c325e855cb4a853afef3cd9f0df594bd12d
Marek Vasut March 28, 2022, 3:32 p.m. UTC | #5
On 3/28/22 08:54, Alexander Stein wrote:
> Hello Marek,
> 
> Am Samstag, 26. März 2022, 21:59:48 CEST schrieb Marek Vasut:
>> On 3/26/22 19:33, Laurent Pinchart wrote:
>>> From: Paul Elder <paul.elder@ideasonboard.com>
>>>
>>> Add the description for the i.MX8MP media blk-ctrl.
>>>
>>> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>> Reviewed-by: Marek Vasut <marex@denx.de>
>>> Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #1
>>
>> Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #2 (the LVDS one)
> 
> You cc'ed me on the LCDIF patch, thanks for that. Could you please provide me
> the patch for the .dtsi as well? Thanks.

Are you testing the LVDS or DSI output ?
Alexander Stein March 29, 2022, 6:07 a.m. UTC | #6
Am Montag, 28. März 2022, 17:32:12 CEST schrieb Marek Vasut:
> On 3/28/22 08:54, Alexander Stein wrote:
> > Hello Marek,
> > 
> > Am Samstag, 26. März 2022, 21:59:48 CEST schrieb Marek Vasut:
> >> On 3/26/22 19:33, Laurent Pinchart wrote:
> >>> From: Paul Elder <paul.elder@ideasonboard.com>
> >>> 
> >>> Add the description for the i.MX8MP media blk-ctrl.
> >>> 
> >>> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> >>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>> Reviewed-by: Marek Vasut <marex@denx.de>
> >>> Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #1
> >> 
> >> Tested-by: Marek Vasut <marex@denx.de> # MX8MP LCDIF #2 (the LVDS one)
> > 
> > You cc'ed me on the LCDIF patch, thanks for that. Could you please provide
> > me the patch for the .dtsi as well? Thanks.
> 
> Are you testing the LVDS or DSI output ?

Right now the LVDS output. A colleague would be interested for DSI output to 
integrate the DSI-to-DP bridge later on.

Regards,
Alexander
diff mbox series

Patch

diff --git a/drivers/soc/imx/imx8m-blk-ctrl.c b/drivers/soc/imx/imx8m-blk-ctrl.c
index 511e74f0db8a..eb53468bf790 100644
--- a/drivers/soc/imx/imx8m-blk-ctrl.c
+++ b/drivers/soc/imx/imx8m-blk-ctrl.c
@@ -15,10 +15,11 @@ 
 
 #include <dt-bindings/power/imx8mm-power.h>
 #include <dt-bindings/power/imx8mn-power.h>
+#include <dt-bindings/power/imx8mp-power.h>
 
 #define BLK_SFT_RSTN	0x0
 #define BLK_CLK_EN	0x4
-#define BLK_MIPI_RESET_DIV	0x8 /* Mini/Nano DISPLAY_BLK_CTRL only */
+#define BLK_MIPI_RESET_DIV	0x8 /* Mini/Nano/Plus DISPLAY_BLK_CTRL only */
 
 struct imx8m_blk_ctrl_domain;
 
@@ -40,7 +41,7 @@  struct imx8m_blk_ctrl_domain_data {
 	u32 clk_mask;
 
 	/*
-	 * i.MX8M Mini and Nano have a third DISPLAY_BLK_CTRL register
+	 * i.MX8M Mini, Nano and Plus have a third DISPLAY_BLK_CTRL register
 	 * which is used to control the reset for the MIPI Phy.
 	 * Since it's only present in certain circumstances,
 	 * an if-statement should be used before setting and clearing this
@@ -589,6 +590,129 @@  static const struct imx8m_blk_ctrl_data imx8mn_disp_blk_ctl_dev_data = {
 	.num_domains = ARRAY_SIZE(imx8mn_disp_blk_ctl_domain_data),
 };
 
+static int imx8mp_media_power_notifier(struct notifier_block *nb,
+				unsigned long action, void *data)
+{
+	struct imx8m_blk_ctrl *bc = container_of(nb, struct imx8m_blk_ctrl,
+						 power_nb);
+
+	if (action != GENPD_NOTIFY_ON && action != GENPD_NOTIFY_PRE_OFF)
+		return NOTIFY_OK;
+
+	/* Enable bus clock and deassert bus reset */
+	regmap_set_bits(bc->regmap, BLK_CLK_EN, BIT(8));
+	regmap_set_bits(bc->regmap, BLK_SFT_RSTN, BIT(8));
+
+	/*
+	 * On power up we have no software backchannel to the GPC to
+	 * wait for the ADB handshake to happen, so we just delay for a
+	 * bit. On power down the GPC driver waits for the handshake.
+	 */
+	if (action == GENPD_NOTIFY_ON)
+		udelay(5);
+
+	return NOTIFY_OK;
+}
+
+/*
+ * From i.MX 8M Plus Applications Processor Reference Manual, Rev. 1,
+ * section 13.2.2, 13.2.3
+ * isp-ahb and dwe are not in Figure 13-5. Media BLK_CTRL Clocks
+ */
+static const struct imx8m_blk_ctrl_domain_data imx8mp_media_blk_ctl_domain_data[] = {
+	[IMX8MP_MEDIABLK_PD_MIPI_DSI_1] = {
+		.name = "mediablk-mipi-dsi-1",
+		.clk_names = (const char *[]){ "apb", "phy", },
+		.num_clks = 2,
+		.gpc_name = "mipi-dsi1",
+		.rst_mask = BIT(0) | BIT(1),
+		.clk_mask = BIT(0) | BIT(1),
+		.mipi_phy_rst_mask = BIT(17),
+	},
+	[IMX8MP_MEDIABLK_PD_MIPI_CSI2_1] = {
+		.name = "mediablk-mipi-csi2-1",
+		.clk_names = (const char *[]){ "apb", "cam1" },
+		.num_clks = 2,
+		.gpc_name = "mipi-csi1",
+		.rst_mask = BIT(2) | BIT(3),
+		.clk_mask = BIT(2) | BIT(3),
+		.mipi_phy_rst_mask = BIT(16),
+	},
+	[IMX8MP_MEDIABLK_PD_LCDIF_1] = {
+		.name = "mediablk-lcdif-1",
+		.clk_names = (const char *[]){ "disp1", "apb", "axi", },
+		.num_clks = 3,
+		.gpc_name = "lcdif1",
+		.rst_mask = BIT(4) | BIT(5) | BIT(23),
+		.clk_mask = BIT(4) | BIT(5) | BIT(23),
+	},
+	[IMX8MP_MEDIABLK_PD_ISI] = {
+		.name = "mediablk-isi",
+		.clk_names = (const char *[]){ "axi", "apb" },
+		.num_clks = 2,
+		.gpc_name = "isi",
+		.rst_mask = BIT(6) | BIT(7),
+		.clk_mask = BIT(6) | BIT(7),
+	},
+	[IMX8MP_MEDIABLK_PD_MIPI_CSI2_2] = {
+		.name = "mediablk-mipi-csi2-2",
+		.clk_names = (const char *[]){ "apb", "cam2" },
+		.num_clks = 2,
+		.gpc_name = "mipi-csi2",
+		.rst_mask = BIT(9) | BIT(10),
+		.clk_mask = BIT(9) | BIT(10),
+		.mipi_phy_rst_mask = BIT(30),
+	},
+	[IMX8MP_MEDIABLK_PD_LCDIF_2] = {
+		.name = "mediablk-lcdif-2",
+		.clk_names = (const char *[]){ "disp1", "apb", "axi", },
+		.num_clks = 3,
+		.gpc_name = "lcdif2",
+		.rst_mask = BIT(11) | BIT(12) | BIT(24),
+		.clk_mask = BIT(11) | BIT(12) | BIT(24),
+	},
+	[IMX8MP_MEDIABLK_PD_ISP2] = {
+		.name = "mediablk-isp2",
+		.clk_names = (const char *[]){ "isp", "axi", "apb" },
+		.num_clks = 3,
+		.gpc_name = "isp2",
+		.rst_mask = BIT(13) | BIT(14) | BIT(15),
+		.clk_mask = BIT(13) | BIT(14) | BIT(15),
+	},
+	[IMX8MP_MEDIABLK_PD_ISP1] = {
+		.name = "mediablk-isp1",
+		.clk_names = (const char *[]){ "isp", "axi", "apb" },
+		.num_clks = 3,
+		.gpc_name = "isp1",
+		.rst_mask = BIT(16) | BIT(17) | BIT(18),
+		.clk_mask = BIT(16) | BIT(17) | BIT(18),
+	},
+	[IMX8MP_MEDIABLK_PD_DWE] = {
+		.name = "mediablk-dwe",
+		.clk_names = (const char *[]){ "axi", "apb" },
+		.num_clks = 2,
+		.gpc_name = "dwe",
+		.rst_mask = BIT(19) | BIT(20) | BIT(21),
+		.clk_mask = BIT(19) | BIT(20) | BIT(21),
+	},
+	[IMX8MP_MEDIABLK_PD_MIPI_DSI_2] = {
+		.name = "mediablk-mipi-dsi-2",
+		.clk_names = (const char *[]){ "phy", },
+		.num_clks = 1,
+		.gpc_name = "mipi-dsi2",
+		.rst_mask = BIT(22),
+		.clk_mask = BIT(22),
+		.mipi_phy_rst_mask = BIT(29),
+	},
+};
+
+static const struct imx8m_blk_ctrl_data imx8mp_media_blk_ctl_dev_data = {
+	.max_reg = 0x138,
+	.power_notifier_fn = imx8mp_media_power_notifier,
+	.domains = imx8mp_media_blk_ctl_domain_data,
+	.num_domains = ARRAY_SIZE(imx8mp_media_blk_ctl_domain_data),
+};
+
 static const struct of_device_id imx8m_blk_ctrl_of_match[] = {
 	{
 		.compatible = "fsl,imx8mm-vpu-blk-ctrl",
@@ -599,6 +723,9 @@  static const struct of_device_id imx8m_blk_ctrl_of_match[] = {
 	}, {
 		.compatible = "fsl,imx8mn-disp-blk-ctrl",
 		.data = &imx8mn_disp_blk_ctl_dev_data
+	}, {
+		.compatible = "fsl,imx8mp-media-blk-ctrl",
+		.data = &imx8mp_media_blk_ctl_dev_data
 	}, {
 		/* Sentinel */
 	}