Skip to contentSkip to conversation

Support display (and even more) on the BSH SMM S2/PRO boards

PATCH In review Dario Binacchi 5 participants 48 messages Sep 13, 2024 – Oct 1, 2024

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover Support display (and even more) on the BSH SMM S2/PRO boards

This series was created out of the need to supportsimple-framebuffer for BSH boards SMM_S2 and SMM_S2PRO. To achieve this goal, it was necessary to develop additional code and/or drivers for all the required components (i. e. clock, power domain, video, etc.). This series has a Linux counterpart that will also be submitted upstream as soon as possible. Furthermore, given the overlap in topics with the recent series [1], we are open to collaborate on the common parts to ensure proper development.

[1] https://lore.kernel.org/all/[email protected]/T/#mb7cd440abc6fcc0de205f577eb3225e1c1c76823

Dario Binacchi (6):
boot: fdt_simplefb: add a debug message
video: mxsfb: support simple frame-buffer
video: bridge: samsung: support simple frame-buffer imx8mn_bsh_smm_s2/pro: support simple frame-buffer imx8mn_bsh_smm_s2/pro: enable simple frame-buffer imx8mn_bsh_smm_s2/pro: add splash screen with BSH logo

Michael Trimarchi (20):
clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present for gate
and mux
clk: imx8mn: Prevent clock critical path from disabling during
reparent and set_rate
clk: imx8mm: Prevent clock critical path from disabling during
reparent and set_rate
clk: clk-uclass: Implement CLK_OPS_PARENT_ENABLE
clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled
clk: imx8mn: Mark IMX8MN_SYS_PLL2 and IMX8MN_SYS_PLL3 as enabled
clk: imx8mn: add video clocks support
power: Add iMX8M block ctrl driver for dispmix
video: Add video link framework
video: bridge: Add check_timing interface
video: dsi_host: add disable host interface
video: Update mxsfb video drivers for iMX8MM/iMX8MN display
video: Enable DM_UC_FLAG_SEQ_ALIAS for display and bridge
phy: dphy: add support to calculate the timing based on hs_clk_rate
phy: dphy: Correct lpx parameter and its derivatives(ta_{get,go,sure})
phy: dphy: Correct clk_pre parameter
lib: div64: sync with Linux
video: bridge: Add Samsung DSIM bridge
video: Add Synaptics R63353 panel driver imx8mn_bsh_smm_s2/pro: Enable display on reference design

 .../dts/imx8mn-bsh-smm-s2-u-boot-common.dtsi  |   23 +
 board/bsh/imx8mn_smm_s2/imx8mn_smm_s2.c       |   99 ++
 boot/fdt_simplefb.c                           |    2 +
 common/stdio.c                                |    4 +
 configs/imx8mn_bsh_smm_s2_defconfig           |   21 +
 configs/imx8mn_bsh_smm_s2pro_defconfig        |   21 +
 drivers/clk/clk-gate.c                        |    1 +
 drivers/clk/clk-mux.c                         |    2 +-
 drivers/clk/clk-uclass.c                      |   67 +-
 drivers/clk/clk.c                             |    9 +
 drivers/clk/imx/clk-imx8mm.c                  |   73 +-
 drivers/clk/imx/clk-imx8mn.c                  |  131 +-
 drivers/phy/meson-axg-mipi-dphy.c             |    2 +-
 drivers/phy/phy-core-mipi-dphy.c              |   36 +-
 drivers/power/domain/Kconfig                  |    6 +
 drivers/power/domain/Makefile                 |    1 +
 drivers/power/domain/imx8m-blk-ctrl.c         |  438 +++++
 drivers/power/domain/imx8m-power-domain.c     |  213 ++-
 drivers/video/Kconfig                         |   14 +
 drivers/video/Makefile                        |    2 +
 drivers/video/bridge/Kconfig                  |   13 +
 drivers/video/bridge/Makefile                 |    1 +
 drivers/video/bridge/samsung-dsi-host.c       | 1576 +++++++++++++++++
 drivers/video/bridge/samsung-dsim.c           |  151 ++
 drivers/video/bridge/samsung-dsim.h           |   20 +
 drivers/video/bridge/video-bridge-uclass.c    |   11 +
 drivers/video/display-uclass.c                |    1 +
 drivers/video/dsi-host-uclass.c               |   10 +
 drivers/video/mxsfb.c                         |  144 +-
 drivers/video/synaptics-r63353.c              |  228 +++
 drivers/video/video_link.c                    |  529 ++++++
 include/clk.h                                 |    9 +
 include/configs/imx8mn_bsh_smm_s2.h           |    1 +
 include/configs/imx8mn_bsh_smm_s2_common.h    |    4 +
 include/configs/imx8mn_bsh_smm_s2pro.h        |    1 +
 include/dsi_host.h                            |    8 +
 include/linux/clk-provider.h                  |    1 +
 include/linux/math64.h                        |  110 ++
 include/phy-mipi-dphy.h                       |    3 +
 include/video_bridge.h                        |   20 +
 include/video_link.h                          |   19 +
 tools/logos/bsh.bmp                           |  Bin 0 -> 10644 bytes
 42 files changed, 3942 insertions(+), 83 deletions(-)
 create mode 100644 drivers/power/domain/imx8m-blk-ctrl.c
 create mode 100644 drivers/video/bridge/samsung-dsi-host.c
 create mode 100644 drivers/video/bridge/samsung-dsim.c
 create mode 100644 drivers/video/bridge/samsung-dsim.h
 create mode 100644 drivers/video/synaptics-r63353.c
 create mode 100644 drivers/video/video_link.c
 create mode 100644 include/video_link.h
 create mode 100644 tools/logos/bsh.bmp
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/26 clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present for gate and mux

From: Michael Trimarchi <[email protected]>

Gate and mux does not have .set_rate operation, but they could have CLK_SET_PARENT_RATE flag set. In that case it's usually possible to find a parent up the tree which is capable of setting the rate (div, pll, etc). Add clk_generic_set_rate to allow them to trasverse the clock tree.

---

 drivers/clk/clk-gate.c       |  1 +
 drivers/clk/clk-mux.c        |  2 +-
 drivers/clk/clk-uclass.c     | 20 ++++++++++++++++++++
 drivers/clk/clk.c            |  9 +++++++++
 include/clk.h                |  9 +++++++++
 include/linux/clk-provider.h |  1 +
 6 files changed, 41 insertions(+), 1 deletion(-)
drivers/clk/clk-gate.c +1 -0
index bf1c6a93b468..bd0d3d44ac8c 100644
@@ -115,6 +115,7 @@ const struct clk_ops clk_gate_ops = {
 	.enable = clk_gate_enable,
 	.disable = clk_gate_disable,
 	.get_rate = clk_generic_get_rate,
+	.set_rate = clk_generic_set_rate,
 };
 
 struct clk *clk_register_gate(struct device *dev, const char *name,
drivers/clk/clk-mux.c +1 -1
index 62477e15d27a..4feb8e8c821d 100644
@@ -150,13 +150,13 @@ static int clk_mux_set_parent(struct clk *clk, struct clk *parent)
 #else
 	writel(reg, mux->reg);
 #endif
-
 	return 0;
 }
 
 const struct clk_ops clk_mux_ops = {
 	.get_rate = clk_generic_get_rate,
 	.set_parent = clk_mux_set_parent,
+	.set_rate = clk_generic_set_rate,
 };
 
 struct clk *clk_hw_register_mux_table(struct device *dev, const char *name,
drivers/clk/clk-uclass.c +20 -0
index 16169dac2340..e8db9b0ff2fd 100644
@@ -515,6 +515,26 @@ ulong clk_get_parent_rate(struct clk *clk)
 	return pclk->rate;
 }
 
+ulong clk_set_parent_rate(struct clk *clk, ulong rate)
+{
+	const struct clk_ops *ops;
+	struct clk *pclk;
+
+	debug("%s(clk=%p)\n", __func__, clk);
+	if (!clk_valid(clk))
+		return 0;
+
+	pclk = clk_get_parent(clk);
+	if (IS_ERR(pclk))
+		return -ENODEV;
+
+	ops = clk_dev_ops(pclk->dev);
+	if (!ops->set_rate)
+		return -ENOSYS;
+
+	return clk_set_rate(pclk, rate);
+}
+
 ulong clk_round_rate(struct clk *clk, ulong rate)
 {
 	const struct clk_ops *ops;
drivers/clk/clk.c +9 -0
index b8c2e8d531b9..67c6b23231ff 100644
@@ -13,6 +13,7 @@
 #include <dm/uclass.h>
 #include <dm/lists.h>
 #include <dm/device-internal.h>
+#include <linux/clk-provider.h>
 
 int clk_register(struct clk *clk, const char *drv_name,
 		 const char *name, const char *parent_name)
@@ -60,6 +61,14 @@ ulong clk_generic_get_rate(struct clk *clk)
 	return clk_get_parent_rate(clk);
 }
 
+ulong clk_generic_set_rate(struct clk *clk, ulong rate)
+{
+	if (clk->flags & CLK_SET_RATE_PARENT)
+		return clk_set_parent_rate(clk, rate);
+
+	return clk_get_parent_rate(clk);
+}
+
 const char *clk_hw_get_name(const struct clk *hw)
 {
 	assert(hw);
include/clk.h +9 -0
index 045e923a529b..f0fd524ee519 100644
@@ -452,6 +452,15 @@ struct clk *clk_get_parent(struct clk *clk);
  */
 ulong clk_get_parent_rate(struct clk *clk);
 
+/**
+ * clk_set_parent_rate() - Set parent of current clock rate.
+ * @clk:	A clock struct that was previously successfully requested by
+ *		clk_request/get_by_*().
+ *
+ * Return: clock rate in Hz, or -ve error code.
+ */
+ulong clk_set_parent_rate(struct clk *clk, ulong rate);
+
 /**
  * clk_round_rate() - Adjust a rate to the exact rate a clock can provide
  * @clk: A clock struct that was previously successfully requested by
include/linux/clk-provider.h +1 -0
index 59f9c241b846..459fa2d15ceb 100644
@@ -253,6 +253,7 @@ struct clk *clk_register_fixed_rate(struct device *dev, const char *name,
 
 const char *clk_hw_get_name(const struct clk *hw);
 ulong clk_generic_get_rate(struct clk *clk);
+ulong clk_generic_set_rate(struct clk *clk, ulong rate);
 
 struct clk *dev_get_clk_ptr(struct udevice *dev);
 
Signature · 1 line
2.43.0
#2 lore raw

PATCH 2/26 clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

This commit ensures that critical clock paths are not disabled during reparent and set_rate operations within the clock framework, paving the way for the inclusion of new features.

---

 drivers/clk/imx/clk-imx8mn.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/clk/imx/clk-imx8mn.c +21 -5
index 125215e84f41..c96a2ebaa19a 100644
@@ -29,10 +29,19 @@ static const char * const imx8mn_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "
 					       "sys_pll2_1000m", "sys_pll1_800m", "sys_pll1_400m",
 					       "audio_pll1_out", "sys_pll3_out", };
 
+static const char * const imx8mn_noc_sels[] = {"osc_24m", "sys_pll1_800m", "sys_pll3_out",
+					       "sys_pll2_1000m", "sys_pll2_500m", "audio_pll1_out",
+					       "video_pll_out", "audio_pll2_out", };
+
 static const char * const imx8mn_ahb_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_800m",
 					       "sys_pll1_400m", "sys_pll2_125m", "sys_pll3_out",
 					       "audio_pll1_out", "video_pll_out", };
 
+static const char * const imx8mn_main_axi_sels[] = {"osc_24m", "sys_pll2_333m", "sys_pll1_800m",
+						    "sys_pll2_250m", "sys_pll2_1000m",
+						    "audio_pll1_out", "video_pll_out",
+						    "sys_pll1_100m",};
+
 static const char * const imx8mn_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
 						    "sys_pll2_250m", "sys_pll2_200m", "audio_pll1_out",
 						    "video_pll_out", "sys_pll3_out", };
@@ -67,6 +76,9 @@ static const char * const imx8mn_usdhc2_sels[] = {"clock-osc-24m", "sys_pll1_400
 						  "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m",
 						  "audio_pll2_out", "sys_pll1_100m", };
 
+static const char * const imx8mn_gic_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
+					       "sys_pll2_100m", "sys_pll1_800m", "clk_ext2",
+					       "clk_ext4", "audio_pll2_out" };
 #if CONFIG_IS_ENABLED(DM_SPI)
 static const char * const imx8mn_ecspi1_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
 						  "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
@@ -286,15 +298,18 @@ static int imx8mn_clk_probe(struct udevice *dev)
 	clk_dm(IMX8MN_CLK_IPG_ROOT,
 	       imx_clk_divider2("ipg_root", "ahb", base + 0x9080, 0, 1));
 
+	/* BUS */
+	clk_dm(IMX8MN_CLK_MAIN_AXI,
+	       imx8m_clk_composite_critical("main_axi", imx8mn_main_axi_sels, base + 0x8800));
 	clk_dm(IMX8MN_CLK_ENET_AXI,
-	       imx8m_clk_composite("enet_axi", imx8mn_enet_axi_sels,
-				   base + 0x8880));
+	       imx8m_clk_composite("enet_axi", imx8mn_enet_axi_sels, base + 0x8880));
 	clk_dm(IMX8MN_CLK_NAND_USDHC_BUS,
-	       imx8m_clk_composite_critical("nand_usdhc_bus",
-					    imx8mn_nand_usdhc_sels,
+	       imx8m_clk_composite_critical("nand_usdhc_bus", imx8mn_nand_usdhc_sels,
 					    base + 0x8900));
 	clk_dm(IMX8MN_CLK_USB_BUS,
 		imx8m_clk_composite("usb_bus", imx8mn_usb_bus_sels, base + 0x8b80));
+	clk_dm(IMX8MN_CLK_NOC,
+	       imx8m_clk_composite_critical("noc", imx8mn_noc_sels, base + 0x8d00));
 
 	/* IP */
 	clk_dm(IMX8MN_CLK_USDHC1,
@@ -389,7 +404,8 @@ static int imx8mn_clk_probe(struct udevice *dev)
 	clk_dm(IMX8MN_CLK_PWM4_ROOT,
 	       imx_clk_gate4("pwm4_root_clk", "pwm4", base + 0x42b0, 0));
 #endif
-
+	clk_dm(IMX8MN_CLK_GIC,
+	       imx8m_clk_composite_critical("gic", imx8mn_gic_sels, base + 0xb200));
 #if CONFIG_IS_ENABLED(DM_SPI)
 	clk_dm(IMX8MN_CLK_ECSPI1,
 	       imx8m_clk_composite("ecspi1", imx8mn_ecspi1_sels, base + 0xb280));
Signature · 1 line
2.43.0
#3 lore raw

PATCH 3/26 clk: imx8mm: Prevent clock critical path from disabling during reparent and set_rate

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

This commit ensures that critical clock paths are not disabled during reparent and set_rate operations within the clock framework, paving the way for the inclusion of new features.

---

 drivers/clk/imx/clk-imx8mm.c | 64 +++++++++++++++++++++++++++++-------
 1 file changed, 52 insertions(+), 12 deletions(-)
drivers/clk/imx/clk-imx8mm.c +52 -12
index a91c6767fac5..432348a15cad 100644
@@ -27,11 +27,25 @@ static const char * const imx8mm_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "
 					       "sys_pll2_1000m", "sys_pll1_800m", "sys_pll1_400m",
 					       "audio_pll1_out", "sys_pll3_out", };
 
+#ifndef CONFIG_SPL_BUILD
+static const char * const imx8mm_noc_sels[] = {"clock-osc-24m", "sys_pll1_800m", "sys_pll3_out",
+					       "sys_pll2_1000m", "sys_pll2_500m", "audio_pll1_out",
+					       "video_pll1_out", "audio_pll2_out", };
+
+static const char * const imx8mm_noc_apb_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll3_out",
+						   "sys_pll2_333m", "sys_pll2_200m",
+						   "sys_pll1_800m", "audio_pll1_out",
+						   "video_pll1_out", };
+
 static const char * const imx8mm_ahb_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_800m",
 					       "sys_pll1_400m", "sys_pll2_125m", "sys_pll3_out",
 					       "audio_pll1_out", "video_pll1_out", };
 
-#ifndef CONFIG_SPL_BUILD
+static const char * const imx8mm_main_axi_sels[] = {"clock-osc-24m", "sys_pll2_333m",
+						    "sys_pll1_800m", "sys_pll2_250m",
+						    "sys_pll2_1000m", "audio_pll1_out",
+						    "video_pll1_out", "sys_pll1_100m",};
+
 static const char * const imx8mm_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
 						    "sys_pll2_250m", "sys_pll2_200m", "audio_pll1_out",
 						    "video_pll1_out", "sys_pll3_out", };
@@ -47,6 +61,11 @@ static const char * const imx8mm_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2
 static const char * const imx8mm_enet_phy_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m",
 						    "sys_pll2_200m", "sys_pll2_500m", "video_pll1_out",
 						    "audio_pll2_out", };
+
+static const char * const imx8mm_dram_apb_sels[] = {"clock-osc-24m", "sys_pll2_200m",
+						    "sys_pll1_40m", "sys_pll1_160m",
+						    "sys_pll1_800m", "sys_pll3_out",
+						    "sys_pll2_250m", "audio_pll2_out", };
 #endif
 
 static const char * const imx8mm_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
@@ -82,8 +101,9 @@ static const char * const imx8mm_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m"
 						"audio_pll2_out", "sys_pll1_133m", };
 
 #if CONFIG_IS_ENABLED(PCIE_DW_IMX)
-static const char * const imx8mm_pcie1_ctrl_sels[] = {"clock-osc-24m", "sys_pll2_250m", "sys_pll2_200m",
-						      "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_500m",
+static const char * const imx8mm_pcie1_ctrl_sels[] = {"clock-osc-24m", "sys_pll2_250m",
+						      "sys_pll2_200m", "sys_pll1_266m",
+						      "sys_pll1_800m", "sys_pll2_500m",
 						      "sys_pll2_333m", "sys_pll3_out", };
 
 static const char * const imx8mm_pcie1_phy_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll2_500m",
@@ -135,6 +155,10 @@ static const char * const imx8mm_usb_phy_sels[] = {"clock-osc-24m", "sys_pll1_10
 						   "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
 						   "clk_ext3", "audio_pll2_out", };
 
+static const char * const imx8mm_gic_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
+					       "sys_pll2_100m", "sys_pll1_800m", "clk_ext2",
+					       "clk_ext4", "audio_pll2_out" };
+
 #if CONFIG_IS_ENABLED(DM_SPI)
 static const char * const imx8mm_ecspi1_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m",
 						  "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out",
@@ -283,18 +307,34 @@ static int imx8mm_clk_probe(struct udevice *dev)
 	       imx_clk_divider2("arm_a53_div", "arm_a53_cg",
 				base + 0x8000, 0, 3));
 
-	clk_dm(IMX8MM_CLK_AHB,
-	       imx8m_clk_composite_critical("ahb", imx8mm_ahb_sels,
-					    base + 0x9000));
 	clk_dm(IMX8MM_CLK_IPG_ROOT,
 	       imx_clk_divider2("ipg_root", "ahb", base + 0x9080, 0, 1));
 
+#ifndef CONFIG_SPL_BUILD
+	/* BUS */
+	clk_dm(IMX8MM_CLK_MAIN_AXI,
+	       imx8m_clk_composite_critical("main_axi",
+					    imx8mm_main_axi_sels, base + 0x8800));
+	clk_dm(IMX8MM_CLK_ENET_AXI,
+	       imx8m_clk_composite("enet_axi", imx8mm_enet_axi_sels, base + 0x8880));
+	clk_dm(IMX8MM_CLK_NOC,
+	       imx8m_clk_composite_critical("noc", imx8mm_noc_sels, base + 0x8d00));
+	clk_dm(IMX8MM_CLK_NOC_APB,
+	       imx8m_clk_composite_critical("noc_apb", imx8mm_noc_apb_sels,
+					    base + 0x8d80));
+	clk_dm(IMX8MM_CLK_AHB,
+	       imx8m_clk_composite_critical("ahb", imx8mm_ahb_sels, base + 0x9000));
+	clk_dm(IMX8MM_CLK_DRAM_APB,
+	       imx8m_clk_composite_critical("dram_apb", imx8mm_dram_apb_sels,
+					    base + 0xa080));
+#endif
+
 	clk_dm(IMX8MM_CLK_NAND_USDHC_BUS,
-	       imx8m_clk_composite_critical("nand_usdhc_bus",
-					    imx8mm_nand_usdhc_sels,
+	       imx8m_clk_composite_critical("nand_usdhc_bus", imx8mm_nand_usdhc_sels,
 					    base + 0x8900));
+
 	clk_dm(IMX8MM_CLK_USB_BUS,
-		imx8m_clk_composite("usb_bus", imx8mm_usb_bus_sels, base + 0x8b80));
+	       imx8m_clk_composite("usb_bus", imx8mm_usb_bus_sels, base + 0x8b80));
 
 	/* IP */
 #if CONFIG_IS_ENABLED(PCIE_DW_IMX)
@@ -358,9 +398,6 @@ static int imx8mm_clk_probe(struct udevice *dev)
 
 	/* clks not needed in SPL stage */
 #ifndef CONFIG_SPL_BUILD
-	clk_dm(IMX8MM_CLK_ENET_AXI,
-	       imx8m_clk_composite("enet_axi", imx8mm_enet_axi_sels,
-				   base + 0x8880));
 	clk_dm(IMX8MM_CLK_ENET_REF,
 	       imx8m_clk_composite("enet_ref", imx8mm_enet_ref_sels,
 	       base + 0xa980));
@@ -396,6 +433,9 @@ static int imx8mm_clk_probe(struct udevice *dev)
 	       imx_clk_gate4("pcie1_root_clk", "pcie1_ctrl", base + 0x4250, 0));
 #endif
 
+	clk_dm(IMX8MM_CLK_GIC,
+	       imx8m_clk_composite_critical("gic", imx8mm_gic_sels, base + 0xb200));
+
 #if CONFIG_IS_ENABLED(DM_SPI)
 	clk_dm(IMX8MM_CLK_ECSPI1,
 	       imx8m_clk_composite("ecspi1", imx8mm_ecspi1_sels, base + 0xb280));
Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH 03/26] clk: imx8mm: Prevent clock critical path from disabling during reparent and set_rate

Quoted 18 lines · Dario Binacchi

From: Michael Trimarchi <[email protected]>

This commit ensures that critical clock paths are not disabled during reparent and set_rate operations within the clock framework, paving the way for the inclusion of new features.

---

  drivers/clk/imx/clk-imx8mm.c | 64 +++++++++++++++++++++++++++++-------
  1 file changed, 52 insertions(+), 12 deletions(-)
drivers/clk/imx/clk-imx8mm.c +0 -0
index a91c6767fac5..432348a15cad 100644

drivers/clk/imx/clk-imx8mm.c static const char * const imx8mm_a53_sels[] = {"clock-osc-24m", "arm_pll_out", " · line 34

Quoted 8 lines
drivers/clk/imx/clk-imx8mm.c +5 -0
@@ -27,11 +27,25 @@ static const char * const imx8mm_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "
  					       "sys_pll2_1000m", "sys_pll1_800m", "sys_pll1_400m",
  					       "audio_pll1_out", "sys_pll3_out", };
 
+#ifndef CONFIG_SPL_BUILD
+static const char * const imx8mm_noc_sels[] = {"clock-osc-24m", "sys_pll1_800m", "sys_pll3_out",
+					       "sys_pll2_1000m", "sys_pll2_500m", "audio_pll1_out",
+					       "video_pll1_out", "audio_pll2_out", };
+

This seems to be adding a lot of new clock, such a change is not described in the commit message.

What problem is this patch solving ? The commit message needs to be updated, it does not seem to match the patch at all.

#5 lore raw

PATCH 4/26 clk: clk-uclass: Implement CLK_OPS_PARENT_ENABLE

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

There are scenario that we need to enable the new parent clock before reparent, or we need to do the same with clk_set_rate. The patch cover those scenario

---

 drivers/clk/clk-uclass.c | 47 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
drivers/clk/clk-uclass.c +46 -1
index e8db9b0ff2fd..b571a3620222 100644
@@ -582,7 +582,9 @@ static void clk_clean_rate_cache(struct clk *clk)
 ulong clk_set_rate(struct clk *clk, ulong rate)
 {
 	const struct clk_ops *ops;
+	struct clk *pclk;
 	struct clk *clkp;
+	ulong ret;
 
 	debug("%s(clk=%p, rate=%lu)\n", __func__, clk, rate);
 	if (!clk_valid(clk))
@@ -597,11 +599,37 @@ ulong clk_set_rate(struct clk *clk, ulong rate)
 	/* Clean up cached rates for us and all child clocks */
 	clk_clean_rate_cache(clkp);
 
-	return ops->set_rate(clk, rate);
+	if (clk->flags & CLK_SET_RATE_UNGATE) {
+		ret = clk_enable(clk);
+		if (ret)
+			return ret;
+	}
+
+	pclk = clk_get_parent(clk);
+	if (pclk) {
+		if (clk->flags & CLK_OPS_PARENT_ENABLE) {
+			ret = clk_enable(pclk);
+			if (ret)
+				goto out;
+		}
+	}
+
+	ret = ops->set_rate(clk, rate);
+
+	if (pclk && clk->flags & CLK_OPS_PARENT_ENABLE)
+		clk_disable(pclk);
+
+out:
+	if (clk->flags & CLK_SET_RATE_UNGATE)
+		clk_disable(clk);
+
+	return ret;
 }
 
 int clk_set_parent(struct clk *clk, struct clk *parent)
 {
+	struct clk *old_parent;
+
 	const struct clk_ops *ops;
 	int ret;
 
@@ -613,6 +641,15 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 	if (!ops->set_parent)
 		return -ENOSYS;
 
+	if (clk->enable_count)
+		clk_enable(parent);
+
+	old_parent = clk_get_parent(clk);
+	if (clk->flags & CLK_OPS_PARENT_ENABLE) {
+		clk_enable(old_parent);
+		clk_enable(parent);
+	}
+
 	ret = ops->set_parent(clk, parent);
 	if (ret)
 		return ret;
@@ -620,6 +657,14 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
 	if (CONFIG_IS_ENABLED(CLK_CCF))
 		ret = device_reparent(clk->dev, parent->dev);
 
+	if (clk->flags & CLK_OPS_PARENT_ENABLE) {
+		clk_disable(parent);
+		clk_disable(old_parent);
+	}
+
+	if (clk->enable_count)
+		clk_disable(old_parent);
+
 	return ret;
 }
 
Signature · 1 line
2.43.0
#6 lore raw

PATCH 5/26 clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Both clock are enabled by the bootloader and we need to increase their reference count to avoid disable during reparent operation.

---

 drivers/clk/imx/clk-imx8mm.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/clk/imx/clk-imx8mm.c +9 -0
index 432348a15cad..0e71ceefe96c 100644
@@ -176,6 +176,8 @@ static const char * const imx8mm_ecspi3_sels[] = {"clock-osc-24m", "sys_pll2_200
 static int imx8mm_clk_probe(struct udevice *dev)
 {
 	void __iomem *base;
+	struct clk *clk;
+	int ret;
 
 	base = (void *)ANATOP_BASE_ADDR;
 
@@ -458,6 +460,13 @@ static int imx8mm_clk_probe(struct udevice *dev)
 	clk_dm(IMX8MM_CLK_QSPI_ROOT,
 	       imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0));
 #endif
+	ret = clk_get_by_id(IMX8MM_SYS_PLL2, &clk);
+	if (!ret)
+		clk_enable(clk);
+
+	ret = clk_get_by_id(IMX8MM_SYS_PLL3, &clk);
+	if (!ret)
+		clk_enable(clk);
 
 	clk_dm(IMX8MM_CLK_ARM,
 	       imx_clk_mux2_flags("arm_core", base + 0x9880, 24, 1,
Signature · 1 line
2.43.0
#7 lore raw

Re: [PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled

Quoted 26 lines · Dario Binacchi

From: Michael Trimarchi <[email protected]>

Both clock are enabled by the bootloader and we need to increase their reference count to avoid disable during reparent operation.

---

  drivers/clk/imx/clk-imx8mm.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/clk/imx/clk-imx8mm.c +2 -0
index 432348a15cad..0e71ceefe96c 100644
@@ -176,6 +176,8 @@ static const char * const imx8mm_ecspi3_sels[] = {"clock-osc-24m", "sys_pll2_200
  static int imx8mm_clk_probe(struct udevice *dev)
  {
  	void __iomem *base;
+	struct clk *clk;
+	int ret;
 
  	base = (void *)ANATOP_BASE_ADDR;
 

drivers/clk/imx/clk-imx8mm.c static int imx8mm_clk_probe(struct udevice *dev) · line 469

Quoted 10 lines
drivers/clk/imx/clk-imx8mm.c +7 -0
@@ -458,6 +460,13 @@ static int imx8mm_clk_probe(struct udevice *dev)
  	clk_dm(IMX8MM_CLK_QSPI_ROOT,
  	       imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0));
  #endif
+	ret = clk_get_by_id(IMX8MM_SYS_PLL2, &clk);
+	if (!ret)
+		clk_enable(clk);
+
+	ret = clk_get_by_id(IMX8MM_SYS_PLL3, &clk);
+	if (!ret)
+		clk_enable(clk);

This enables these PLLs for all boards, even the ones which do not need those are use those for other purposes like drive the CLKOUT outputs from them. Please describe DT consumers, do not hack board-specific changes into generic drivers.

#8 lore raw

PATCH 6/26 clk: imx8mn: Mark IMX8MN_SYS_PLL2 and IMX8MN_SYS_PLL3 as enabled

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Both clock are enabled by the bootloader and we need to increase their reference count to avoid disable during reparent operation.

---

 drivers/clk/imx/clk-imx8mn.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/clk/imx/clk-imx8mn.c +8 -0
index c96a2ebaa19a..449ebf2d0733 100644
@@ -154,6 +154,7 @@ static const char * const imx8mn_usb_phy_sels[] = {"clock-osc-24m", "sys_pll1_10
 static int imx8mn_clk_probe(struct udevice *dev)
 {
 	struct clk osc_24m_clk;
+	struct clk *clk;
 	void __iomem *base;
 	int ret;
 
@@ -420,6 +421,13 @@ static int imx8mn_clk_probe(struct udevice *dev)
 	clk_dm(IMX8MN_CLK_ECSPI3_ROOT,
 	       imx_clk_gate4("ecspi3_root_clk", "ecspi3", base + 0x4090, 0));
 #endif
+	ret = clk_get_by_id(IMX8MN_SYS_PLL2, &clk);
+	if (!ret)
+		clk_enable(clk);
+
+	ret = clk_get_by_id(IMX8MN_SYS_PLL3, &clk);
+	if (!ret)
+		clk_enable(clk);
 
 	clk_dm(IMX8MN_CLK_ARM,
 	       imx_clk_mux2_flags("arm_core", base + 0x9880, 24, 1,
Signature · 1 line
2.43.0
#9 lore raw

PATCH 7/26 clk: imx8mn: add video clocks support

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add clocks support for the video subsystem.

---

 drivers/clk/imx/clk-imx8mn.c | 97 +++++++++++++++++++++++++++++++++---
 1 file changed, 90 insertions(+), 7 deletions(-)
drivers/clk/imx/clk-imx8mn.c +90 -7
index 449ebf2d0733..7ea4c90fa137 100644
@@ -17,6 +17,7 @@
 static u32 share_count_nand;
 
 static const char * const pll_ref_sels[] = { "clock-osc-24m", "dummy", "dummy", "dummy", };
+static const char * const video_pll_bypass_sels[] = {"video_pll", "video_pll_ref_sel", };
 static const char * const dram_pll_bypass_sels[] = {"dram_pll", "dram_pll_ref_sel", };
 static const char * const arm_pll_bypass_sels[] = {"arm_pll", "arm_pll_ref_sel", };
 static const char * const sys_pll1_bypass_sels[] = {"sys_pll1", "sys_pll1_ref_sel", };
@@ -47,17 +48,52 @@ static const char * const imx8mn_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_2
 						    "video_pll_out", "sys_pll3_out", };
 
 #ifndef CONFIG_SPL_BUILD
-static const char * const imx8mn_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m",
-						    "sys_pll2_100m", "sys_pll1_160m", "audio_pll1_out",
+static const char * const imx8mn_disp_axi_sels[] = {"clock-osc-24m", "sys_pll2_1000m",
+						    "sys_pll1_800m", "sys_pll3_out", "sys_pll1_40m",
+						    "audio_pll2_out", "clk_ext1", "clk_ext4", };
+
+static const char * const imx8mn_disp_apb_sels[] = {"clock-osc-24m", "sys_pll2_125m",
+						    "sys_pll1_800m", "sys_pll3_out", "sys_pll1_40m",
+						    "audio_pll2_out", "clk_ext1", "clk_ext3", };
+
+static const char * const imx8mn_disp_pixel_sels[] = {"clock-osc-24m", "video_pll_out",
+						      "audio_pll2_out", "audio_pll1_out",
+						      "sys_pll1_800m", "sys_pll2_1000m",
+						      "sys_pll3_out", "clk_ext4", };
+
+static const char * const imx8mn_dsi_core_sels[] = {"clock-osc-24m", "sys_pll1_266m",
+						    "sys_pll2_250m", "sys_pll1_800m",
+						    "sys_pll2_1000m", "sys_pll3_out",
+						    "audio_pll2_out", "video_pll_out", };
+
+static const char * const imx8mn_dsi_phy_sels[] = {"clock-osc-24m", "sys_pll2_125m",
+						   "sys_pll2_100m", "sys_pll1_800m",
+						   "sys_pll2_1000m", "clk_ext2",
+						   "audio_pll2_out", "video_pll_out", };
+
+static const char * const imx8mn_dsi_dbi_sels[] = {"clock-osc-24m", "sys_pll1_266m",
+						   "sys_pll2_100m", "sys_pll1_800m",
+						   "sys_pll2_1000m", "sys_pll3_out",
+						   "audio_pll2_out", "video_pll_out", };
+
+static const char * const imx8mn_camera_pixel_sels[] = {"clock-osc-24m", "sys_pll1_266m",
+							"sys_pll2_250m", "sys_pll1_800m",
+							"sys_pll2_1000m", "sys_pll3_out",
+							"audio_pll2_out", "video_pll_out", };
+
+static const char * const imx8mn_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m",
+						    "sys_pll2_50m", "sys_pll2_100m",
+						    "sys_pll1_160m", "audio_pll1_out",
 						    "video_pll_out", "clk_ext4", };
 
-static const char * const imx8mn_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out",
-						      "clk_ext1", "clk_ext2", "clk_ext3",
-						      "clk_ext4", "video_pll_out", };
+static const char * const imx8mn_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m",
+						      "audio_pll1_out", "clk_ext1", "clk_ext2",
+						      "clk_ext3", "clk_ext4", "video_pll_out", };
 
 static const char * const imx8mn_enet_phy_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m",
-						    "sys_pll2_200m", "sys_pll2_500m", "audio_pll1_out",
-						    "video_pll_out", "audio_pll2_out", };
+						    "sys_pll2_200m", "sys_pll2_500m",
+						    "audio_pll1_out", "video_pll_out",
+						    "audio_pll2_out", };
 #endif
 
 static const char * const imx8mn_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m",
@@ -151,6 +187,10 @@ static const char * const imx8mn_usb_phy_sels[] = {"clock-osc-24m", "sys_pll1_10
 						   "sys_pll2_100m", "sys_pll2_200m", "clk_ext2",
 						   "clk_ext3", "audio_pll2_out", };
 
+#ifndef CONFIG_SPL_BUILD
+static unsigned int share_count_disp;
+#endif
+
 static int imx8mn_clk_probe(struct udevice *dev)
 {
 	struct clk osc_24m_clk;
@@ -191,8 +231,19 @@ static int imx8mn_clk_probe(struct udevice *dev)
 	clk_dm(IMX8MN_SYS_PLL3,
 	       imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel",
 			       base + 0x114, &imx_1416x_pll));
+	clk_dm(IMX8MN_VIDEO_PLL_REF_SEL,
+	       imx_clk_mux("video_pll_ref_sel", base + 0x28, 0, 2,
+			   pll_ref_sels, ARRAY_SIZE(pll_ref_sels)));
+	clk_dm(IMX8MN_VIDEO_PLL1,
+	       imx_clk_pll14xx("video_pll", "video_pll_ref_sel",
+			       base + 0x28, &imx_1443x_pll));
 
 	/* PLL bypass out */
+	clk_dm(IMX8MN_VIDEO_PLL_BYPASS,
+	       imx_clk_mux_flags("video_pll_bypass", base + 0x28, 16, 1,
+				 video_pll_bypass_sels,
+				 ARRAY_SIZE(video_pll_bypass_sels),
+				 CLK_SET_RATE_PARENT));
 	clk_dm(IMX8MN_DRAM_PLL_BYPASS,
 	       imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1,
 				 dram_pll_bypass_sels,
@@ -220,6 +271,9 @@ static int imx8mn_clk_probe(struct udevice *dev)
 				 CLK_SET_RATE_PARENT));
 
 	/* PLL out gate */
+	clk_dm(IMX8MN_VIDEO_PLL_OUT,
+	       imx_clk_gate("video_pll_out", "video_pll_bypass",
+			    base + 0x28, 13));
 	clk_dm(IMX8MN_DRAM_PLL_OUT,
 	       imx_clk_gate("dram_pll_out", "dram_pll_bypass",
 			    base + 0x50, 13));
@@ -376,6 +430,35 @@ static int imx8mn_clk_probe(struct udevice *dev)
 
 	/* clks not needed in SPL stage */
 #ifndef CONFIG_SPL_BUILD
+	clk_dm(IMX8MN_CLK_DISP_AXI,
+	       imx8m_clk_composite("disp_axi", imx8mn_disp_axi_sels, base + 0x8a00));
+	clk_dm(IMX8MN_CLK_DISP_APB,
+	       imx8m_clk_composite("disp_apb", imx8mn_disp_apb_sels, base + 0x8a80));
+	clk_dm(IMX8MN_CLK_DISP_PIXEL,
+	       __imx8m_clk_composite("disp_pixel", imx8mn_disp_pixel_sels, base + 0xa500,
+				     CLK_SET_RATE_PARENT));
+	clk_dm(IMX8MN_CLK_DSI_CORE,
+	       imx8m_clk_composite("dsi_core", imx8mn_dsi_core_sels, base + 0xbb00));
+	clk_dm(IMX8MN_CLK_DSI_PHY_REF,
+	       imx8m_clk_composite("dsi_phy_ref", imx8mn_dsi_phy_sels, base + 0xbb80));
+	clk_dm(IMX8MN_CLK_DSI_DBI,
+	       imx8m_clk_composite("dsi_dbi", imx8mn_dsi_dbi_sels, base + 0xbc00));
+	clk_dm(IMX8MN_CLK_CAMERA_PIXEL,
+	       imx8m_clk_composite("camera_pixel", imx8mn_camera_pixel_sels, base + 0xbd00));
+
+	clk_dm(IMX8MN_CLK_DISP_AXI_ROOT,
+	       imx_clk_gate2_shared2("disp_axi_root_clk", "disp_axi", base + 0x45d0, 0,
+				     &share_count_disp));
+	clk_dm(IMX8MN_CLK_DISP_APB_ROOT,
+	       imx_clk_gate2_shared2("disp_apb_root_clk", "disp_apb", base + 0x45d0, 0,
+				     &share_count_disp));
+	clk_dm(IMX8MN_CLK_CAMERA_PIXEL_ROOT,
+	       imx_clk_gate2_shared2("camera_pixel_clk", "camera_pixel", base + 0x45d0, 0,
+				     &share_count_disp));
+	clk_dm(IMX8MN_CLK_DISP_PIXEL_ROOT,
+	       imx_clk_gate2_shared2("disp_pixel_clk", "disp_pixel", base + 0x45d0, 0,
+				     &share_count_disp));
+
 	clk_dm(IMX8MN_CLK_ENET_REF,
 	       imx8m_clk_composite("enet_ref", imx8mn_enet_ref_sels,
 	       base + 0xa980));
Signature · 1 line
2.43.0
#10 lore raw

PATCH 8/26 power: Add iMX8M block ctrl driver for dispmix

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add iMX8 block ctrl driver for displaymix on iMX8MM/iMX8MN and mediamix on iMX8MP.

To support blk ctrl driver, the power domain driver on iMX8M needs update to add relevant PGC domains

---

 drivers/power/domain/Kconfig              |   6 +
 drivers/power/domain/Makefile             |   1 +
 drivers/power/domain/imx8m-blk-ctrl.c     | 438 ++++++++++++++++++++++
 drivers/power/domain/imx8m-power-domain.c | 213 ++++++++++-
 4 files changed, 656 insertions(+), 2 deletions(-)
 create mode 100644 drivers/power/domain/imx8m-blk-ctrl.c
drivers/power/domain/Kconfig +6 -0
index bd82d2f7044b..fb006b6e8e28 100644
@@ -40,6 +40,12 @@ config IMX8M_POWER_DOMAIN
 	  Enable support for manipulating NXP i.MX8M on-SoC power domains via
 	  requests to the ATF.
 
+config IMX8M_BLK_CTRL
+	bool "Enable i.MX8M block control driver"
+	depends on POWER_DOMAIN && ARCH_IMX8M
+	help
+	  Enable support for manipulating NXP i.MX8M on-SoC block control driver
+
 config IMX8MP_HSIOMIX_BLKCTRL
 	bool "Enable i.MX8MP HSIOMIX domain driver"
 	depends on POWER_DOMAIN && IMX8MP
drivers/power/domain/Makefile +1 -0
index 2daab73eb758..46849fd2a4db 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_APPLE_PMGR_POWER_DOMAIN) += apple-pmgr.o
 obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
 obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o
 obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
+obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
 obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o
 obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
 obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
drivers/power/domain/imx8m-blk-ctrl.c new file +438 -0

438 lines not on this page · raw message

drivers/power/domain/imx8m-power-domain.c +211 -2

333 lines not on this page · raw message

Signature · 1 line
2.43.0
#11 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hello Dario,

Quoted 163 lines · Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add iMX8 block ctrl driver for displaymix on iMX8MM/iMX8MN and mediamix on iMX8MP.

To support blk ctrl driver, the power domain driver on iMX8M needs update to add relevant PGC domains

---

  drivers/power/domain/Kconfig              |   6 +
  drivers/power/domain/Makefile             |   1 +
  drivers/power/domain/imx8m-blk-ctrl.c     | 438 ++++++++++++++++++++++
  drivers/power/domain/imx8m-power-domain.c | 213 ++++++++++-
  4 files changed, 656 insertions(+), 2 deletions(-)

create mode 100644 drivers/power/domain/imx8m-blk-ctrl.c

drivers/power/domain/Kconfig +6 -0
index bd82d2f7044b..fb006b6e8e28 100644
@@ -40,6 +40,12 @@ config IMX8M_POWER_DOMAIN
  	  Enable support for manipulating NXP i.MX8M on-SoC power domains via
  	  requests to the ATF.
 
+config IMX8M_BLK_CTRL
+	bool "Enable i.MX8M block control driver"
+	depends on POWER_DOMAIN && ARCH_IMX8M
+	help
+	  Enable support for manipulating NXP i.MX8M on-SoC block control driver
+
  config IMX8MP_HSIOMIX_BLKCTRL
  	bool "Enable i.MX8MP HSIOMIX domain driver"
  	depends on POWER_DOMAIN && IMX8MP
drivers/power/domain/Makefile +1 -0
index 2daab73eb758..46849fd2a4db 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_APPLE_PMGR_POWER_DOMAIN) += apple-pmgr.o
  obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
  obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o
  obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
+obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
  obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o
  obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
  obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
drivers/power/domain/imx8m-blk-ctrl.c new file +108 -0
new file mode 100644
index 000000000000..4c89078b991b
@@ -0,0 +1,438 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 NXP
+ */
+
+#include <dm.h>
+#include <malloc.h>
+#include <power-domain-uclass.h>
+#include <asm/io.h>
+#include <dm/device-internal.h>
+#include <dm/device.h>
+#include <dt-bindings/power/imx8mm-power.h>
+#include <dt-bindings/power/imx8mn-power.h>
+#include <dt-bindings/power/imx8mp-power.h>
+#include <clk.h>
+#include <linux/delay.h>
+
+#define BLK_SFT_RSTN	0x0
+#define BLK_CLK_EN	0x4
+#define BLK_MIPI_RESET_DIV	0x8 /* Mini/Nano/Plus DISPLAY_BLK_CTRL only */
+
+#define DOMAIN_MAX_CLKS 4
+
+struct imx8m_blk_ctrl_domain {
+	struct clk clks[DOMAIN_MAX_CLKS];
+	struct power_domain power_dev;
+};
+
+struct imx8m_blk_ctrl {
+	void __iomem *base;
+	struct power_domain bus_power_dev;
+	struct imx8m_blk_ctrl_domain *domains;
+};
+
+struct imx8m_blk_ctrl_domain_data {
+	const char *name;
+	const char * const *clk_names;
+	const char *gpc_name;
+	int num_clks;
+	u32 rst_mask;
+	u32 clk_mask;
+	u32 mipi_phy_rst_mask;
+};
+
+struct imx8m_blk_ctrl_data {
+	int max_reg;
+	const struct imx8m_blk_ctrl_domain_data *domains;
+	int num_domains;
+	u32 bus_rst_mask;
+	u32 bus_clk_mask;
+};
+
+static int imx8m_blk_ctrl_request(struct power_domain *power_domain)
+{
+	return 0;
+}
+
+static int imx8m_blk_ctrl_free(struct power_domain *power_domain)
+{
+	return 0;
+}
+
+static int imx8m_blk_ctrl_enable_domain_clk(struct udevice *dev, ulong domain_id, bool enable)
+{
+	int ret, i;
+	struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+	struct imx8m_blk_ctrl_data *drv_data =
+		(struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+
+	debug("%s num_clk %u\n", __func__, drv_data->domains[domain_id].num_clks);
+
+	for (i = 0; i < drv_data->domains[domain_id].num_clks; i++) {
+		debug("%s clk %s\n", __func__, drv_data->domains[domain_id].clk_names[i]);
+		if (enable)
+			ret = clk_enable(&priv->domains[domain_id].clks[i]);
+		else
+			ret = clk_disable(&priv->domains[domain_id].clks[i]);
+		if (ret && ret != -ENOENT) {
+			printf("Failed to %s domain clk %s\n", enable ? "enable" : "disable",
+			       drv_data->domains[domain_id].clk_names[i]);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
+{
+	struct udevice *dev = power_domain->dev;
+	struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+	struct imx8m_blk_ctrl_data *drv_data =
+		(struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+	int ret;
+
+	debug("%s, id %lu\n", __func__, power_domain->id);
+
+	if (!priv->domains[power_domain->id].power_dev.dev)
+		return -ENODEV;
+
+	ret = power_domain_on(&priv->bus_power_dev);
+	if (ret < 0) {
+		printf("Failed to power up bus domain %d\n", ret);
+		return ret;
+	}
+
+	/* Enable bus clock and deassert bus reset */
+	setbits_le32(priv->base + BLK_CLK_EN, drv_data->bus_clk_mask);

drivers/power/domain/imx8m-blk-ctrl.c line 118

Quoted 10 lines
drivers/power/domain/imx8m-blk-ctrl.c new file +10 -0
+	setbits_le32(priv->base + BLK_SFT_RSTN, drv_data->bus_rst_mask);
+
+	/* wait for reset to propagate */
+	udelay(5);
+
+	/* put devices into reset */
+	clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
+	if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
+		clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
+			     rv_data->domains[power_domain->id].mipi_phy_rst_mask);

Does this build for you?

I needed the following fix:

drivers/power/domain/imx8m-blk-ctrl.c +2 -2
index 4c89078b99..b772d50480 100644
@@ -114,8 +114,8 @@ static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
        /* put devices into reset */
        clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
        if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
-               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
-                            rv_data->domains[power_domain->id].mipi_phy_rst_mask);
+               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV,
+                            drv_data->domains[power_domain->id].mipi_phy_rst_mask);
 
        /* enable upstream and blk-ctrl clocks to allow reset to propagate */
        ret = imx8m_blk_ctrl_enable_domain_clk(dev, power_domain->id, true);

to get it building.

BTW: Just also working on bootlogo support for an imx8mp based board!

I now applied your patches:

clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present for gate and mux
clk: clk-uclass: Implement CLK_OPS_PARENT_ENABLE

And added in my adapted /drivers/clk/imx/clk-imx8mp.c (imported from linux)

clk_dm(IMX8MP_CLK_MEDIA_AXI, imx8m_clk_composite_flags("media_axi", imx8mp_media_axi_sels, ARRAY_SIZE(imx8mp_media_axi_sels), base + 0x8a00, CLK_IS_CRITICAL));

instead of using imx8m_clk_composite, and dropped my approach to get clocks up and working.

Also dropped my similiar approach for mediablock and used your

power: Add iMX8M block ctrl driver for dispmix

And with this 3 patches, bootlogo works also/still fine for me!

I did not applied/need your patches:

clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled
clk: imx8mn: Mark IMX8MN_SYS_PLL2 and IMX8MN_SYS_PLL3 as enabled

Of course, they are for imx8mm, but I mean I do not need similiar patches for imx8mp!

Also not applied (as for imx8mm)
clk: imx8mn: add video clocks support

but as said, have similiar patch for clk-imx8mp.c

May you check if using imx8m_clk_composite_flags() is working for you?

I did not applied your patches 09/26 and the following patches from your series, as I made a video bridge driver based on

linux driver drivers/gpu/drm/bridge/fsl-ldb.c

and a lcdif driver based on linux:/drivers/gpu/drm/mxsfb/lcdif_drv.c

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#12 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hello Heiko,

Quoted 198 lines · Heiko Schocher

Hello Dario,

Quoted 163 lines · Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add iMX8 block ctrl driver for displaymix on iMX8MM/iMX8MN and mediamix on iMX8MP.

To support blk ctrl driver, the power domain driver on iMX8M needs update to add relevant PGC domains

---

  drivers/power/domain/Kconfig              |   6 +
  drivers/power/domain/Makefile             |   1 +
  drivers/power/domain/imx8m-blk-ctrl.c     | 438 ++++++++++++++++++++++
  drivers/power/domain/imx8m-power-domain.c | 213 ++++++++++-
  4 files changed, 656 insertions(+), 2 deletions(-)

create mode 100644 drivers/power/domain/imx8m-blk-ctrl.c

drivers/power/domain/Kconfig +6 -0
index bd82d2f7044b..fb006b6e8e28 100644
@@ -40,6 +40,12 @@ config IMX8M_POWER_DOMAIN
        Enable support for manipulating NXP i.MX8M on-SoC power domains via
        requests to the ATF.
 
+config IMX8M_BLK_CTRL
+     bool "Enable i.MX8M block control driver"
+     depends on POWER_DOMAIN && ARCH_IMX8M
+     help
+       Enable support for manipulating NXP i.MX8M on-SoC block control driver
+
  config IMX8MP_HSIOMIX_BLKCTRL
      bool "Enable i.MX8MP HSIOMIX domain driver"
      depends on POWER_DOMAIN && IMX8MP
drivers/power/domain/Makefile +1 -0
index 2daab73eb758..46849fd2a4db 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_APPLE_PMGR_POWER_DOMAIN) += apple-pmgr.o
  obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
  obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o
  obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
+obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
  obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o
  obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
  obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
drivers/power/domain/imx8m-blk-ctrl.c new file +108 -0
new file mode 100644
index 000000000000..4c89078b991b
@@ -0,0 +1,438 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 NXP
+ */
+
+#include <dm.h>
+#include <malloc.h>
+#include <power-domain-uclass.h>
+#include <asm/io.h>
+#include <dm/device-internal.h>
+#include <dm/device.h>
+#include <dt-bindings/power/imx8mm-power.h>
+#include <dt-bindings/power/imx8mn-power.h>
+#include <dt-bindings/power/imx8mp-power.h>
+#include <clk.h>
+#include <linux/delay.h>
+
+#define BLK_SFT_RSTN 0x0
+#define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano/Plus DISPLAY_BLK_CTRL only */
+
+#define DOMAIN_MAX_CLKS 4
+
+struct imx8m_blk_ctrl_domain {
+     struct clk clks[DOMAIN_MAX_CLKS];
+     struct power_domain power_dev;
+};
+
+struct imx8m_blk_ctrl {
+     void __iomem *base;
+     struct power_domain bus_power_dev;
+     struct imx8m_blk_ctrl_domain *domains;
+};
+
+struct imx8m_blk_ctrl_domain_data {
+     const char *name;
+     const char * const *clk_names;
+     const char *gpc_name;
+     int num_clks;
+     u32 rst_mask;
+     u32 clk_mask;
+     u32 mipi_phy_rst_mask;
+};
+
+struct imx8m_blk_ctrl_data {
+     int max_reg;
+     const struct imx8m_blk_ctrl_domain_data *domains;
+     int num_domains;
+     u32 bus_rst_mask;
+     u32 bus_clk_mask;
+};
+
+static int imx8m_blk_ctrl_request(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_free(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_enable_domain_clk(struct udevice *dev, ulong domain_id, bool enable)
+{
+     int ret, i;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+
+     debug("%s num_clk %u\n", __func__, drv_data->domains[domain_id].num_clks);
+
+     for (i = 0; i < drv_data->domains[domain_id].num_clks; i++) {
+             debug("%s clk %s\n", __func__, drv_data->domains[domain_id].clk_names[i]);
+             if (enable)
+                     ret = clk_enable(&priv->domains[domain_id].clks[i]);
+             else
+                     ret = clk_disable(&priv->domains[domain_id].clks[i]);
+             if (ret && ret != -ENOENT) {
+                     printf("Failed to %s domain clk %s\n", enable ? "enable" : "disable",
+                            drv_data->domains[domain_id].clk_names[i]);
+                     return ret;
+             }
+     }
+
+     return 0;
+}
+
+static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
+{
+     struct udevice *dev = power_domain->dev;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+     int ret;
+
+     debug("%s, id %lu\n", __func__, power_domain->id);
+
+     if (!priv->domains[power_domain->id].power_dev.dev)
+             return -ENODEV;
+
+     ret = power_domain_on(&priv->bus_power_dev);
+     if (ret < 0) {
+             printf("Failed to power up bus domain %d\n", ret);
+             return ret;
+     }
+
+     /* Enable bus clock and deassert bus reset */
+     setbits_le32(priv->base + BLK_CLK_EN, drv_data->bus_clk_mask);

drivers/power/domain/imx8m-blk-ctrl.c line 118

Quoted 10 lines
drivers/power/domain/imx8m-blk-ctrl.c new file +10 -0
+     setbits_le32(priv->base + BLK_SFT_RSTN, drv_data->bus_rst_mask);
+
+     /* wait for reset to propagate */
+     udelay(5);
+
+     /* put devices into reset */
+     clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
+     if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
+             clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
+                          rv_data->domains[power_domain->id].mipi_phy_rst_mask);

Does this build for you?

I needed the following fix:

drivers/power/domain/imx8m-blk-ctrl.c +2 -2
index 4c89078b99..b772d50480 100644
@@ -114,8 +114,8 @@ static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
         /* put devices into reset */
         clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
         if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
-               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
-                            rv_data->domains[power_domain->id].mipi_phy_rst_mask);
+               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV,
+                            drv_data->domains[power_domain->id].mipi_phy_rst_mask);
 
         /* enable upstream and blk-ctrl clocks to allow reset to propagate */
         ret = imx8m_blk_ctrl_enable_domain_clk(dev, power_domain->id, true);
Quoted 1 line

to get it building.

Yes, you're right. I made some changes suggested by patman, and before applying the
patch, I didn't recompile, so I didn't notice.

Quoted 32 lines

BTW: Just also working on bootlogo support for an imx8mp based board!

I now applied your patches:

clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present for gate and mux
clk: clk-uclass: Implement CLK_OPS_PARENT_ENABLE

And added in my adapted /drivers/clk/imx/clk-imx8mp.c (imported from linux)

clk_dm(IMX8MP_CLK_MEDIA_AXI, imx8m_clk_composite_flags("media_axi", imx8mp_media_axi_sels, ARRAY_SIZE(imx8mp_media_axi_sels), base + 0x8a00, CLK_IS_CRITICAL));

instead of using imx8m_clk_composite, and dropped my approach to get clocks up and working.

Also dropped my similiar approach for mediablock and used your

power: Add iMX8M block ctrl driver for dispmix

And with this 3 patches, bootlogo works also/still fine for me!

I did not applied/need your patches:

clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled
clk: imx8mn: Mark IMX8MN_SYS_PLL2 and IMX8MN_SYS_PLL3 as enabled

Of course, they are for imx8mm, but I mean I do not need similiar patches for imx8mp!

Quoted 6 lines

Also not applied (as for imx8mm)
clk: imx8mn: add video clocks support

but as said, have similiar patch for clk-imx8mp.c

May you check if using imx8m_clk_composite_flags() is working for you?

I will do it

Quoted 8 lines

I did not applied your patches 09/26 and the following patches from your series, as I made a video bridge driver based on

linux driver drivers/gpu/drm/bridge/fsl-ldb.c

and a lcdif driver based on linux:/drivers/gpu/drm/mxsfb/lcdif_drv.c

Thank you for you feedback Heiko

Regards,
Dario

Quoted 6 lines

bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]

Signature · 17 lines
Dario Binacchi

Senior Embedded Linux Developer

[email protected]

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
[email protected]

www.amarulasolutions.com
#13 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Dario,

Quoted 252 lines · Dario Binacchi

Hello Heiko,

Quoted 198 lines · Heiko Schocher

Hello Dario,

Quoted 163 lines · Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add iMX8 block ctrl driver for displaymix on iMX8MM/iMX8MN and mediamix on iMX8MP.

To support blk ctrl driver, the power domain driver on iMX8M needs update to add relevant PGC domains

---

   drivers/power/domain/Kconfig              |   6 +
   drivers/power/domain/Makefile             |   1 +
   drivers/power/domain/imx8m-blk-ctrl.c     | 438 ++++++++++++++++++++++
   drivers/power/domain/imx8m-power-domain.c | 213 ++++++++++-
   4 files changed, 656 insertions(+), 2 deletions(-)

create mode 100644 drivers/power/domain/imx8m-blk-ctrl.c

drivers/power/domain/Kconfig +6 -0
index bd82d2f7044b..fb006b6e8e28 100644
@@ -40,6 +40,12 @@ config IMX8M_POWER_DOMAIN
         Enable support for manipulating NXP i.MX8M on-SoC power domains via
         requests to the ATF.
 
+config IMX8M_BLK_CTRL
+     bool "Enable i.MX8M block control driver"
+     depends on POWER_DOMAIN && ARCH_IMX8M
+     help
+       Enable support for manipulating NXP i.MX8M on-SoC block control driver
+
   config IMX8MP_HSIOMIX_BLKCTRL
       bool "Enable i.MX8MP HSIOMIX domain driver"
       depends on POWER_DOMAIN && IMX8MP
drivers/power/domain/Makefile +1 -0
index 2daab73eb758..46849fd2a4db 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_APPLE_PMGR_POWER_DOMAIN) += apple-pmgr.o
   obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
   obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o
   obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
+obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
   obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o
   obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
   obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
drivers/power/domain/imx8m-blk-ctrl.c new file +108 -0
new file mode 100644
index 000000000000..4c89078b991b
@@ -0,0 +1,438 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 NXP
+ */
+
+#include <dm.h>
+#include <malloc.h>
+#include <power-domain-uclass.h>
+#include <asm/io.h>
+#include <dm/device-internal.h>
+#include <dm/device.h>
+#include <dt-bindings/power/imx8mm-power.h>
+#include <dt-bindings/power/imx8mn-power.h>
+#include <dt-bindings/power/imx8mp-power.h>
+#include <clk.h>
+#include <linux/delay.h>
+
+#define BLK_SFT_RSTN 0x0
+#define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano/Plus DISPLAY_BLK_CTRL only */
+
+#define DOMAIN_MAX_CLKS 4
+
+struct imx8m_blk_ctrl_domain {
+     struct clk clks[DOMAIN_MAX_CLKS];
+     struct power_domain power_dev;
+};
+
+struct imx8m_blk_ctrl {
+     void __iomem *base;
+     struct power_domain bus_power_dev;
+     struct imx8m_blk_ctrl_domain *domains;
+};
+
+struct imx8m_blk_ctrl_domain_data {
+     const char *name;
+     const char * const *clk_names;
+     const char *gpc_name;
+     int num_clks;
+     u32 rst_mask;
+     u32 clk_mask;
+     u32 mipi_phy_rst_mask;
+};
+
+struct imx8m_blk_ctrl_data {
+     int max_reg;
+     const struct imx8m_blk_ctrl_domain_data *domains;
+     int num_domains;
+     u32 bus_rst_mask;
+     u32 bus_clk_mask;
+};
+
+static int imx8m_blk_ctrl_request(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_free(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_enable_domain_clk(struct udevice *dev, ulong domain_id, bool enable)
+{
+     int ret, i;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+
+     debug("%s num_clk %u\n", __func__, drv_data->domains[domain_id].num_clks);
+
+     for (i = 0; i < drv_data->domains[domain_id].num_clks; i++) {
+             debug("%s clk %s\n", __func__, drv_data->domains[domain_id].clk_names[i]);
+             if (enable)
+                     ret = clk_enable(&priv->domains[domain_id].clks[i]);
+             else
+                     ret = clk_disable(&priv->domains[domain_id].clks[i]);
+             if (ret && ret != -ENOENT) {
+                     printf("Failed to %s domain clk %s\n", enable ? "enable" : "disable",
+                            drv_data->domains[domain_id].clk_names[i]);
+                     return ret;
+             }
+     }
+
+     return 0;
+}
+
+static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
+{
+     struct udevice *dev = power_domain->dev;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+     int ret;
+
+     debug("%s, id %lu\n", __func__, power_domain->id);
+
+     if (!priv->domains[power_domain->id].power_dev.dev)
+             return -ENODEV;
+
+     ret = power_domain_on(&priv->bus_power_dev);
+     if (ret < 0) {
+             printf("Failed to power up bus domain %d\n", ret);
+             return ret;
+     }
+
+     /* Enable bus clock and deassert bus reset */
+     setbits_le32(priv->base + BLK_CLK_EN, drv_data->bus_clk_mask);

drivers/power/domain/imx8m-blk-ctrl.c line 118

Quoted 10 lines
drivers/power/domain/imx8m-blk-ctrl.c new file +10 -0
+     setbits_le32(priv->base + BLK_SFT_RSTN, drv_data->bus_rst_mask);
+
+     /* wait for reset to propagate */
+     udelay(5);
+
+     /* put devices into reset */
+     clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
+     if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
+             clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
+                          rv_data->domains[power_domain->id].mipi_phy_rst_mask);

Does this build for you?

I needed the following fix:

drivers/power/domain/imx8m-blk-ctrl.c +2 -2
index 4c89078b99..b772d50480 100644
@@ -114,8 +114,8 @@ static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
          /* put devices into reset */
          clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
          if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
-               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
-                            rv_data->domains[power_domain->id].mipi_phy_rst_mask);
+               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV,
+                            drv_data->domains[power_domain->id].mipi_phy_rst_mask);
 
          /* enable upstream and blk-ctrl clocks to allow reset to propagate */
          ret = imx8m_blk_ctrl_enable_domain_clk(dev, power_domain->id, true);
Quoted 1 line

to get it building.

Yes, you're right. I made some changes suggested by patman, and before applying the
patch, I didn't recompile, so I didn't notice.

Quoted 32 lines

BTW: Just also working on bootlogo support for an imx8mp based board!

I now applied your patches:

clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present for gate and mux
clk: clk-uclass: Implement CLK_OPS_PARENT_ENABLE

And added in my adapted /drivers/clk/imx/clk-imx8mp.c (imported from linux)

clk_dm(IMX8MP_CLK_MEDIA_AXI, imx8m_clk_composite_flags("media_axi", imx8mp_media_axi_sels, ARRAY_SIZE(imx8mp_media_axi_sels), base + 0x8a00, CLK_IS_CRITICAL));

instead of using imx8m_clk_composite, and dropped my approach to get clocks up and working.

Also dropped my similiar approach for mediablock and used your

power: Add iMX8M block ctrl driver for dispmix

And with this 3 patches, bootlogo works also/still fine for me!

I did not applied/need your patches:

clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled
clk: imx8mn: Mark IMX8MN_SYS_PLL2 and IMX8MN_SYS_PLL3 as enabled

Of course, they are for imx8mm, but I mean I do not need similiar patches for imx8mp!

Quoted 6 lines

Also not applied (as for imx8mm)
clk: imx8mn: add video clocks support

but as said, have similiar patch for clk-imx8mp.c

May you check if using imx8m_clk_composite_flags() is working for you?

I will do it

Quoted 4 lines

I did not applied your patches 09/26 and the following patches from your series, as I made a video bridge driver based on

Quoted 6 lines
Quoted 4 lines

linux driver drivers/gpu/drm/bridge/fsl-ldb.c

and a lcdif driver based on linux:/drivers/gpu/drm/mxsfb/lcdif_drv.c

Thank you for you feedback Heiko

You are welcome!

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Do you have fec ethernet on your board?

Thanks!

bye,
Heiko

Quoted 13 lines

Regards,
Dario

Quoted 6 lines

bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#14 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Heko

Quoted 263 lines · Heiko Schocher

Hi Dario,

Quoted 252 lines · Dario Binacchi

Hello Heiko,

Quoted 198 lines · Heiko Schocher

Hello Dario,

Quoted 163 lines · Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add iMX8 block ctrl driver for displaymix on iMX8MM/iMX8MN and mediamix on iMX8MP.

To support blk ctrl driver, the power domain driver on iMX8M needs update to add relevant PGC domains

---

   drivers/power/domain/Kconfig              |   6 +
   drivers/power/domain/Makefile             |   1 +
   drivers/power/domain/imx8m-blk-ctrl.c     | 438 ++++++++++++++++++++++
   drivers/power/domain/imx8m-power-domain.c | 213 ++++++++++-
   4 files changed, 656 insertions(+), 2 deletions(-)

create mode 100644 drivers/power/domain/imx8m-blk-ctrl.c

drivers/power/domain/Kconfig +6 -0
index bd82d2f7044b..fb006b6e8e28 100644
@@ -40,6 +40,12 @@ config IMX8M_POWER_DOMAIN
         Enable support for manipulating NXP i.MX8M on-SoC power domains via
         requests to the ATF.
 
+config IMX8M_BLK_CTRL
+     bool "Enable i.MX8M block control driver"
+     depends on POWER_DOMAIN && ARCH_IMX8M
+     help
+       Enable support for manipulating NXP i.MX8M on-SoC block control driver
+
   config IMX8MP_HSIOMIX_BLKCTRL
       bool "Enable i.MX8MP HSIOMIX domain driver"
       depends on POWER_DOMAIN && IMX8MP
drivers/power/domain/Makefile +1 -0
index 2daab73eb758..46849fd2a4db 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_APPLE_PMGR_POWER_DOMAIN) += apple-pmgr.o
   obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
   obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o
   obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
+obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
   obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o
   obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
   obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
drivers/power/domain/imx8m-blk-ctrl.c new file +108 -0
new file mode 100644
index 000000000000..4c89078b991b
@@ -0,0 +1,438 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 NXP
+ */
+
+#include <dm.h>
+#include <malloc.h>
+#include <power-domain-uclass.h>
+#include <asm/io.h>
+#include <dm/device-internal.h>
+#include <dm/device.h>
+#include <dt-bindings/power/imx8mm-power.h>
+#include <dt-bindings/power/imx8mn-power.h>
+#include <dt-bindings/power/imx8mp-power.h>
+#include <clk.h>
+#include <linux/delay.h>
+
+#define BLK_SFT_RSTN 0x0
+#define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano/Plus DISPLAY_BLK_CTRL only */
+
+#define DOMAIN_MAX_CLKS 4
+
+struct imx8m_blk_ctrl_domain {
+     struct clk clks[DOMAIN_MAX_CLKS];
+     struct power_domain power_dev;
+};
+
+struct imx8m_blk_ctrl {
+     void __iomem *base;
+     struct power_domain bus_power_dev;
+     struct imx8m_blk_ctrl_domain *domains;
+};
+
+struct imx8m_blk_ctrl_domain_data {
+     const char *name;
+     const char * const *clk_names;
+     const char *gpc_name;
+     int num_clks;
+     u32 rst_mask;
+     u32 clk_mask;
+     u32 mipi_phy_rst_mask;
+};
+
+struct imx8m_blk_ctrl_data {
+     int max_reg;
+     const struct imx8m_blk_ctrl_domain_data *domains;
+     int num_domains;
+     u32 bus_rst_mask;
+     u32 bus_clk_mask;
+};
+
+static int imx8m_blk_ctrl_request(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_free(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_enable_domain_clk(struct udevice *dev, ulong domain_id, bool enable)
+{
+     int ret, i;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+
+     debug("%s num_clk %u\n", __func__, drv_data->domains[domain_id].num_clks);
+
+     for (i = 0; i < drv_data->domains[domain_id].num_clks; i++) {
+             debug("%s clk %s\n", __func__, drv_data->domains[domain_id].clk_names[i]);
+             if (enable)
+                     ret = clk_enable(&priv->domains[domain_id].clks[i]);
+             else
+                     ret = clk_disable(&priv->domains[domain_id].clks[i]);
+             if (ret && ret != -ENOENT) {
+                     printf("Failed to %s domain clk %s\n", enable ? "enable" : "disable",
+                            drv_data->domains[domain_id].clk_names[i]);
+                     return ret;
+             }
+     }
+
+     return 0;
+}
+
+static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
+{
+     struct udevice *dev = power_domain->dev;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+     int ret;
+
+     debug("%s, id %lu\n", __func__, power_domain->id);
+
+     if (!priv->domains[power_domain->id].power_dev.dev)
+             return -ENODEV;
+
+     ret = power_domain_on(&priv->bus_power_dev);
+     if (ret < 0) {
+             printf("Failed to power up bus domain %d\n", ret);
+             return ret;
+     }
+
+     /* Enable bus clock and deassert bus reset */
+     setbits_le32(priv->base + BLK_CLK_EN, drv_data->bus_clk_mask);

drivers/power/domain/imx8m-blk-ctrl.c line 118

Quoted 10 lines
drivers/power/domain/imx8m-blk-ctrl.c new file +10 -0
+     setbits_le32(priv->base + BLK_SFT_RSTN, drv_data->bus_rst_mask);
+
+     /* wait for reset to propagate */
+     udelay(5);
+
+     /* put devices into reset */
+     clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
+     if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
+             clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
+                          rv_data->domains[power_domain->id].mipi_phy_rst_mask);

Does this build for you?

I needed the following fix:

drivers/power/domain/imx8m-blk-ctrl.c +2 -2
index 4c89078b99..b772d50480 100644
@@ -114,8 +114,8 @@ static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
          /* put devices into reset */
          clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
          if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
-               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
-                            rv_data->domains[power_domain->id].mipi_phy_rst_mask);
+               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV,
+                            drv_data->domains[power_domain->id].mipi_phy_rst_mask);
 
          /* enable upstream and blk-ctrl clocks to allow reset to propagate */
          ret = imx8m_blk_ctrl_enable_domain_clk(dev, power_domain->id, true);
Quoted 1 line

to get it building.

Yes, you're right. I made some changes suggested by patman, and before applying the
patch, I didn't recompile, so I didn't notice.

Quoted 32 lines

BTW: Just also working on bootlogo support for an imx8mp based board!

I now applied your patches:

clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present for gate and mux
clk: clk-uclass: Implement CLK_OPS_PARENT_ENABLE

And added in my adapted /drivers/clk/imx/clk-imx8mp.c (imported from linux)

clk_dm(IMX8MP_CLK_MEDIA_AXI, imx8m_clk_composite_flags("media_axi", imx8mp_media_axi_sels, ARRAY_SIZE(imx8mp_media_axi_sels), base + 0x8a00, CLK_IS_CRITICAL));

instead of using imx8m_clk_composite, and dropped my approach to get clocks up and working.

Also dropped my similiar approach for mediablock and used your

power: Add iMX8M block ctrl driver for dispmix

And with this 3 patches, bootlogo works also/still fine for me!

I did not applied/need your patches:

clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled
clk: imx8mn: Mark IMX8MN_SYS_PLL2 and IMX8MN_SYS_PLL3 as enabled

Of course, they are for imx8mm, but I mean I do not need similiar patches for imx8mp!

Quoted 6 lines

Also not applied (as for imx8mm)
clk: imx8mn: add video clocks support

but as said, have similiar patch for clk-imx8mp.c

May you check if using imx8m_clk_composite_flags() is working for you?

I will do it

Quoted 4 lines

I did not applied your patches 09/26 and the following patches from your series, as I made a video bridge driver based on

Quoted 6 lines
Quoted 4 lines

linux driver drivers/gpu/drm/bridge/fsl-ldb.c

and a lcdif driver based on linux:/drivers/gpu/drm/mxsfb/lcdif_drv.c

Thank you for you feedback Heiko

Quoted 9 lines

You are welcome!

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

Can you check it?

Michael

Quoted 24 lines

Do you have fec ethernet on your board?

Thanks!

bye,
Heiko

Quoted 13 lines

Regards,
Dario

Quoted 6 lines

bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]

--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#15 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Micahel,

Quoted 276 lines · Michael Nazzareno Trimarchi

Hi Heko

Quoted 263 lines · Heiko Schocher

Hi Dario,

Quoted 252 lines · Dario Binacchi

Hello Heiko,

Quoted 198 lines · Heiko Schocher

Hello Dario,

Quoted 163 lines · Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add iMX8 block ctrl driver for displaymix on iMX8MM/iMX8MN and mediamix on iMX8MP.

To support blk ctrl driver, the power domain driver on iMX8M needs update to add relevant PGC domains

---

    drivers/power/domain/Kconfig              |   6 +
    drivers/power/domain/Makefile             |   1 +
    drivers/power/domain/imx8m-blk-ctrl.c     | 438 ++++++++++++++++++++++
    drivers/power/domain/imx8m-power-domain.c | 213 ++++++++++-
    4 files changed, 656 insertions(+), 2 deletions(-)

create mode 100644 drivers/power/domain/imx8m-blk-ctrl.c

drivers/power/domain/Kconfig +6 -0
index bd82d2f7044b..fb006b6e8e28 100644
@@ -40,6 +40,12 @@ config IMX8M_POWER_DOMAIN
          Enable support for manipulating NXP i.MX8M on-SoC power domains via
          requests to the ATF.
 
+config IMX8M_BLK_CTRL
+     bool "Enable i.MX8M block control driver"
+     depends on POWER_DOMAIN && ARCH_IMX8M
+     help
+       Enable support for manipulating NXP i.MX8M on-SoC block control driver
+
    config IMX8MP_HSIOMIX_BLKCTRL
        bool "Enable i.MX8MP HSIOMIX domain driver"
        depends on POWER_DOMAIN && IMX8MP
drivers/power/domain/Makefile +1 -0
index 2daab73eb758..46849fd2a4db 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_APPLE_PMGR_POWER_DOMAIN) += apple-pmgr.o
    obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
    obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o
    obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
+obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o
    obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o
    obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
    obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
drivers/power/domain/imx8m-blk-ctrl.c new file +108 -0
new file mode 100644
index 000000000000..4c89078b991b
@@ -0,0 +1,438 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 NXP
+ */
+
+#include <dm.h>
+#include <malloc.h>
+#include <power-domain-uclass.h>
+#include <asm/io.h>
+#include <dm/device-internal.h>
+#include <dm/device.h>
+#include <dt-bindings/power/imx8mm-power.h>
+#include <dt-bindings/power/imx8mn-power.h>
+#include <dt-bindings/power/imx8mp-power.h>
+#include <clk.h>
+#include <linux/delay.h>
+
+#define BLK_SFT_RSTN 0x0
+#define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano/Plus DISPLAY_BLK_CTRL only */
+
+#define DOMAIN_MAX_CLKS 4
+
+struct imx8m_blk_ctrl_domain {
+     struct clk clks[DOMAIN_MAX_CLKS];
+     struct power_domain power_dev;
+};
+
+struct imx8m_blk_ctrl {
+     void __iomem *base;
+     struct power_domain bus_power_dev;
+     struct imx8m_blk_ctrl_domain *domains;
+};
+
+struct imx8m_blk_ctrl_domain_data {
+     const char *name;
+     const char * const *clk_names;
+     const char *gpc_name;
+     int num_clks;
+     u32 rst_mask;
+     u32 clk_mask;
+     u32 mipi_phy_rst_mask;
+};
+
+struct imx8m_blk_ctrl_data {
+     int max_reg;
+     const struct imx8m_blk_ctrl_domain_data *domains;
+     int num_domains;
+     u32 bus_rst_mask;
+     u32 bus_clk_mask;
+};
+
+static int imx8m_blk_ctrl_request(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_free(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_enable_domain_clk(struct udevice *dev, ulong domain_id, bool enable)
+{
+     int ret, i;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+
+     debug("%s num_clk %u\n", __func__, drv_data->domains[domain_id].num_clks);
+
+     for (i = 0; i < drv_data->domains[domain_id].num_clks; i++) {
+             debug("%s clk %s\n", __func__, drv_data->domains[domain_id].clk_names[i]);
+             if (enable)
+                     ret = clk_enable(&priv->domains[domain_id].clks[i]);
+             else
+                     ret = clk_disable(&priv->domains[domain_id].clks[i]);
+             if (ret && ret != -ENOENT) {
+                     printf("Failed to %s domain clk %s\n", enable ? "enable" : "disable",
+                            drv_data->domains[domain_id].clk_names[i]);
+                     return ret;
+             }
+     }
+
+     return 0;
+}
+
+static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
+{
+     struct udevice *dev = power_domain->dev;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+     int ret;
+
+     debug("%s, id %lu\n", __func__, power_domain->id);
+
+     if (!priv->domains[power_domain->id].power_dev.dev)
+             return -ENODEV;
+
+     ret = power_domain_on(&priv->bus_power_dev);
+     if (ret < 0) {
+             printf("Failed to power up bus domain %d\n", ret);
+             return ret;
+     }
+
+     /* Enable bus clock and deassert bus reset */
+     setbits_le32(priv->base + BLK_CLK_EN, drv_data->bus_clk_mask);

drivers/power/domain/imx8m-blk-ctrl.c line 118

Quoted 10 lines
drivers/power/domain/imx8m-blk-ctrl.c new file +10 -0
+     setbits_le32(priv->base + BLK_SFT_RSTN, drv_data->bus_rst_mask);
+
+     /* wait for reset to propagate */
+     udelay(5);
+
+     /* put devices into reset */
+     clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
+     if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
+             clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
+                          rv_data->domains[power_domain->id].mipi_phy_rst_mask);

Does this build for you?

I needed the following fix:

drivers/power/domain/imx8m-blk-ctrl.c +2 -2
index 4c89078b99..b772d50480 100644
@@ -114,8 +114,8 @@ static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
           /* put devices into reset */
           clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
           if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
-               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
-                            rv_data->domains[power_domain->id].mipi_phy_rst_mask);
+               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV,
+                            drv_data->domains[power_domain->id].mipi_phy_rst_mask);
 
           /* enable upstream and blk-ctrl clocks to allow reset to propagate */
           ret = imx8m_blk_ctrl_enable_domain_clk(dev, power_domain->id, true);
Quoted 1 line

to get it building.

Yes, you're right. I made some changes suggested by patman, and before applying the
patch, I didn't recompile, so I didn't notice.

Quoted 32 lines

BTW: Just also working on bootlogo support for an imx8mp based board!

I now applied your patches:

clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present for gate and mux
clk: clk-uclass: Implement CLK_OPS_PARENT_ENABLE

And added in my adapted /drivers/clk/imx/clk-imx8mp.c (imported from linux)

clk_dm(IMX8MP_CLK_MEDIA_AXI, imx8m_clk_composite_flags("media_axi", imx8mp_media_axi_sels, ARRAY_SIZE(imx8mp_media_axi_sels), base + 0x8a00, CLK_IS_CRITICAL));

instead of using imx8m_clk_composite, and dropped my approach to get clocks up and working.

Also dropped my similiar approach for mediablock and used your

power: Add iMX8M block ctrl driver for dispmix

And with this 3 patches, bootlogo works also/still fine for me!

I did not applied/need your patches:

clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled
clk: imx8mn: Mark IMX8MN_SYS_PLL2 and IMX8MN_SYS_PLL3 as enabled

Of course, they are for imx8mm, but I mean I do not need similiar patches for imx8mp!

Quoted 6 lines

Also not applied (as for imx8mm)
clk: imx8mn: add video clocks support

but as said, have similiar patch for clk-imx8mp.c

May you check if using imx8m_clk_composite_flags() is working for you?

I will do it

Quoted 4 lines

I did not applied your patches 09/26 and the following patches from your series, as I made a video bridge driver based on

Quoted 6 lines
Quoted 4 lines

linux driver drivers/gpu/drm/bridge/fsl-ldb.c

and a lcdif driver based on linux:/drivers/gpu/drm/mxsfb/lcdif_drv.c

Thank you for you feedback Heiko

Quoted 9 lines

You are welcome!

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines

prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08

Author: Michael Trimarchi <[email protected]>
Date:   Tue Jul 9 08:28:13 2024 +0200

clk: clk-uclass: Print clk name in clk_enable/clk_disable

Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

Thanks!

Quoted 1 line

Can you check it?

Yep, will do.

bye,
Heiko

Quoted 31 lines

Michael

Quoted 24 lines

Do you have fec ethernet on your board?

Thanks!

bye,
Heiko

Quoted 13 lines

Regards,
Dario

Quoted 6 lines

bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]

--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#16 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hello Michael,

Quoted 314 lines · Heiko Schocher

Hi Micahel,

Quoted 276 lines · Michael Nazzareno Trimarchi

Hi Heko

Quoted 263 lines · Heiko Schocher

Hi Dario,

Quoted 252 lines · Dario Binacchi

Hello Heiko,

Quoted 198 lines · Heiko Schocher

Hello Dario,

Quoted 163 lines · Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add iMX8 block ctrl driver for displaymix on iMX8MM/iMX8MN and mediamix on iMX8MP.

To support blk ctrl driver, the power domain driver on iMX8M needs update to add relevant PGC domains

---

    drivers/power/domain/Kconfig              |   6 + drivers/power/domain/Makefile             |   1 + drivers/power/domain/imx8m-blk-ctrl.c     | 438 ++++++++++++++++++++++ drivers/power/domain/imx8m-power-domain.c | 213 ++++++++++-

    4 files changed, 656 insertions(+), 2 deletions(-)

    create mode 100644 drivers/power/domain/imx8m-blk-ctrl.c

drivers/power/domain/Kconfig +0 -0
index bd82d2f7044b..fb006b6e8e28 100644
@@ -40,6 +40,12 @@ config IMX8M_POWER_DOMAIN

          Enable support for manipulating NXP i.MX8M on-SoC power domains via requests to the ATF.

drivers/power/domain/Kconfig +6 -0
+config IMX8M_BLK_CTRL
+     bool "Enable i.MX8M block control driver"
+     depends on POWER_DOMAIN && ARCH_IMX8M
+     help
+       Enable support for manipulating NXP i.MX8M on-SoC block control driver
+

    config IMX8MP_HSIOMIX_BLKCTRL
        bool "Enable i.MX8MP HSIOMIX domain driver" depends on POWER_DOMAIN && IMX8MP

drivers/power/domain/Makefile +0 -0
index 2daab73eb758..46849fd2a4db 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_APPLE_PMGR_POWER_DOMAIN) += apple-pmgr.o

    obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o imx8-power-domain.o obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o +obj-$(CONFIG_IMX8M_BLK_CTRL) += imx8m-blk-ctrl.o obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o

drivers/power/domain/imx8m-blk-ctrl.c new file +108 -0
new file mode 100644
index 000000000000..4c89078b991b
@@ -0,0 +1,438 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 NXP
+ */
+
+#include <dm.h>
+#include <malloc.h>
+#include <power-domain-uclass.h>
+#include <asm/io.h>
+#include <dm/device-internal.h>
+#include <dm/device.h>
+#include <dt-bindings/power/imx8mm-power.h>
+#include <dt-bindings/power/imx8mn-power.h>
+#include <dt-bindings/power/imx8mp-power.h>
+#include <clk.h>
+#include <linux/delay.h>
+
+#define BLK_SFT_RSTN 0x0
+#define BLK_CLK_EN   0x4
+#define BLK_MIPI_RESET_DIV   0x8 /* Mini/Nano/Plus DISPLAY_BLK_CTRL only */
+
+#define DOMAIN_MAX_CLKS 4
+
+struct imx8m_blk_ctrl_domain {
+     struct clk clks[DOMAIN_MAX_CLKS];
+     struct power_domain power_dev;
+};
+
+struct imx8m_blk_ctrl {
+     void __iomem *base;
+     struct power_domain bus_power_dev;
+     struct imx8m_blk_ctrl_domain *domains;
+};
+
+struct imx8m_blk_ctrl_domain_data {
+     const char *name;
+     const char * const *clk_names;
+     const char *gpc_name;
+     int num_clks;
+     u32 rst_mask;
+     u32 clk_mask;
+     u32 mipi_phy_rst_mask;
+};
+
+struct imx8m_blk_ctrl_data {
+     int max_reg;
+     const struct imx8m_blk_ctrl_domain_data *domains;
+     int num_domains;
+     u32 bus_rst_mask;
+     u32 bus_clk_mask;
+};
+
+static int imx8m_blk_ctrl_request(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_free(struct power_domain *power_domain)
+{
+     return 0;
+}
+
+static int imx8m_blk_ctrl_enable_domain_clk(struct udevice *dev, ulong domain_id, bool enable)
+{
+     int ret, i;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+
+     debug("%s num_clk %u\n", __func__, drv_data->domains[domain_id].num_clks);
+
+     for (i = 0; i < drv_data->domains[domain_id].num_clks; i++) {
+             debug("%s clk %s\n", __func__, drv_data->domains[domain_id].clk_names[i]);
+             if (enable)
+                     ret = clk_enable(&priv->domains[domain_id].clks[i]);
+             else
+                     ret = clk_disable(&priv->domains[domain_id].clks[i]);
+             if (ret && ret != -ENOENT) {
+                     printf("Failed to %s domain clk %s\n", enable ? "enable" : "disable",
+                            drv_data->domains[domain_id].clk_names[i]);
+                     return ret;
+             }
+     }
+
+     return 0;
+}
+
+static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
+{
+     struct udevice *dev = power_domain->dev;
+     struct imx8m_blk_ctrl *priv = (struct imx8m_blk_ctrl *)dev_get_priv(dev);
+     struct imx8m_blk_ctrl_data *drv_data =
+             (struct imx8m_blk_ctrl_data *)dev_get_driver_data(dev);
+     int ret;
+
+     debug("%s, id %lu\n", __func__, power_domain->id);
+
+     if (!priv->domains[power_domain->id].power_dev.dev)
+             return -ENODEV;
+
+     ret = power_domain_on(&priv->bus_power_dev);
+     if (ret < 0) {
+             printf("Failed to power up bus domain %d\n", ret);
+             return ret;
+     }
+
+     /* Enable bus clock and deassert bus reset */
+     setbits_le32(priv->base + BLK_CLK_EN, drv_data->bus_clk_mask);

drivers/power/domain/imx8m-blk-ctrl.c line 118

Quoted 10 lines
drivers/power/domain/imx8m-blk-ctrl.c new file +10 -0
+     setbits_le32(priv->base + BLK_SFT_RSTN, drv_data->bus_rst_mask);
+
+     /* wait for reset to propagate */
+     udelay(5);
+
+     /* put devices into reset */
+     clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
+     if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
+             clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
+                          rv_data->domains[power_domain->id].mipi_phy_rst_mask);

Does this build for you?

I needed the following fix:

drivers/power/domain/imx8m-blk-ctrl.c +2 -2
index 4c89078b99..b772d50480 100644
@@ -114,8 +114,8 @@ static int imx8m_blk_ctrl_power_on(struct power_domain *power_domain)
            /* put devices into reset */
            clrbits_le32(priv->base + BLK_SFT_RSTN, drv_data->domains[power_domain->id].rst_mask);
            if (drv_data->domains[power_domain->id].mipi_phy_rst_mask)
-               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV, d
-                            rv_data->domains[power_domain->id].mipi_phy_rst_mask);
+               clrbits_le32(priv->base + BLK_MIPI_RESET_DIV,
+                            drv_data->domains[power_domain->id].mipi_phy_rst_mask);
 
            /* enable upstream and blk-ctrl clocks to allow reset to propagate */
            ret = imx8m_blk_ctrl_enable_domain_clk(dev, power_domain->id, true);
Quoted 1 line

to get it building.

Yes, you're right. I made some changes suggested by patman, and before applying the
   patch, I didn't recompile, so I didn't notice.

Quoted 32 lines

BTW: Just also working on bootlogo support for an imx8mp based board!

I now applied your patches:

clk: Propagate clk_set_rate() if CLK_SET_PARENT_RATE present for gate and mux
clk: clk-uclass: Implement CLK_OPS_PARENT_ENABLE

And added in my adapted /drivers/clk/imx/clk-imx8mp.c (imported from linux)

clk_dm(IMX8MP_CLK_MEDIA_AXI, imx8m_clk_composite_flags("media_axi", imx8mp_media_axi_sels, ARRAY_SIZE(imx8mp_media_axi_sels), base + 0x8a00, CLK_IS_CRITICAL));

instead of using imx8m_clk_composite, and dropped my approach to get clocks up and working.

Also dropped my similiar approach for mediablock and used your

power: Add iMX8M block ctrl driver for dispmix

And with this 3 patches, bootlogo works also/still fine for me!

I did not applied/need your patches:

clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Prevent clock critical path from disabling during reparent and set_rate
clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled
clk: imx8mn: Mark IMX8MN_SYS_PLL2 and IMX8MN_SYS_PLL3 as enabled

Of course, they are for imx8mm, but I mean I do not need similiar patches for imx8mp!

Quoted 6 lines

Also not applied (as for imx8mm)
clk: imx8mn: add video clocks support

but as said, have similiar patch for clk-imx8mp.c

May you check if using imx8m_clk_composite_flags() is working for you?

I will do it

Quoted 4 lines

I did not applied your patches 09/26 and the following patches from your series, as I made a video bridge driver based on

Quoted 6 lines
Quoted 4 lines

linux driver drivers/gpu/drm/bridge/fsl-ldb.c

and a lcdif driver based on linux:/drivers/gpu/drm/mxsfb/lcdif_drv.c

Thank you for you feedback Heiko

Quoted 9 lines

You are welcome!

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines

prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08
Author: Michael Trimarchi <[email protected]> Date:   Tue Jul 9 08:28:13 2024 +0200

    clk: clk-uclass: Print clk name in clk_enable/clk_disable

    Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

Quoted 5 lines

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

bye,
Heiko
[1]

│   │    <> Net:   clk_set_defaults(gpio@30230000)
│   │    <> clk_set_default_parents: could not read assigned-clock-parents for 00000000fee74d90 name=gpio@30230000
│   │    <> clk_set_defaults(aristainetos3-fec-rgmii-grp)
│   │    <> clk_set_default_parents: could not read assigned-clock-parents for 00000000fee75780 name=aristainetos3-fec-rgmii-grp
│   │    <> clk_set_defaults(ethernet@30be0000)
│   │    <> clk_get_by_indexed_prop(dev=00000000fee7ad20, index=0, clk=00000000fee5e3b8)
│   │    <> clk_of_xlate_default(clk=00000000fee5e3b8)
│   │    <> clk_request(dev=00000000fee77480, clk=00000000fee5e3b8)
│   │    <> clk_get_by_indexed_prop(dev=00000000fee7ad20, index=0, clk=00000000fee5e390)
│   │    <> clk_of_xlate_default(clk=00000000fee5e390)
│   │    <> clk_request(dev=00000000fee77480, clk=00000000fee5e390)
│   │    <> clk_set_parent(clk=00000000fee825c0, parent=00000000fee80680)
│   │    <> clk_get_parent(clk=00000000fee825c0)
│   │    <> clk_enable(clk=00000000fee743d0 name=clock-osc-24m)
│   │    <> clk_enable(clk=00000000fee80680 name=sys_pll1_266m)
│   │    <> clk_enable(clk=00000000fee7fb40 name=sys_pll1_out)
│   │    <> clk_disable(clk=00000000fee80680 name=sys_pll1_266m)
│   │    <> clk_disable(clk=00000000fee7fb40 name=sys_pll1_out)
│   │    <> clk_disable(clk=00000000fee743d0 name=clock-osc-24m)
│   │    <> clk_get_by_indexed_prop(dev=00000000fee7ad20, index=1, clk=00000000fee5e3b8)
│   │    <> clk_of_xlate_default(clk=00000000fee5e3b8)
│   │    <> clk_request(dev=00000000fee77480, clk=00000000fee5e3b8)
│   │    <> clk_get_by_indexed_prop(dev=00000000fee7ad20, index=1, clk=00000000fee5e390)
│   │    <> clk_of_xlate_default(clk=00000000fee5e390)
│   │    <> clk_request(dev=00000000fee77480, clk=00000000fee5e390)
│   │    <> clk_set_parent(clk=00000000fee85b80, parent=00000000fee80b80)
│   │    <> clk_get_parent(clk=00000000fee85b80)
│   │    <> clk_enable(clk=00000000fee743d0 name=clock-osc-24m)
│   │    <> clk_enable(clk=00000000fee80b80 name=sys_pll2_100m)
│   │    <> clk_enable(clk=00000000fee7fc80 name=sys_pll2_out)
│   │    <> clk_enable(clk=00000000fee7f480 name=sys_pll2_bypass)
│   │    <> clk_enable(clk=00000000fee7eb80 name=sys_pll2)
│   │    <> clk_enable(clk=00000000fee7e280 name=sys_pll2_ref_sel)
│   │    <> clk_enable(clk=00000000fee743d0 name=clock-osc-24m)
│   │    <> clk_disable(clk=00000000fee80b80 name=sys_pll2_100m)
│   │    <> clk_disable(clk=00000000fee7fc80 name=sys_pll2_out)
│   │    <> clk_disable(clk=00000000fee7f480 name=sys_pll2_bypass)
│   │    <> clk_disable(clk=00000000fee7eb80 name=sys_pll2)

[2]

drivers/clk/imx/clk-imx8mp.c +9 -0
index d6865509cb..f6fa66094d 100644
@@ -235,6 +235,7 @@ static const char * const imx8mp_clkout_sels[] = {"audio_pll1_out", "audio_pll2_
 static int imx8mp_clk_probe(struct udevice *dev)
 {
        struct clk osc_24m_clk, osc_32k_clk;
+       struct clk *clk;
        void __iomem *base;
        int ret;
 
@@ -303,6 +304,14 @@ static int imx8mp_clk_probe(struct udevice *dev)
                return ret;
        clk_dm(IMX8MP_CLK_32K, dev_get_clk_ptr(osc_32k_clk.dev));
 
+       ret = clk_get_by_id(IMX8MP_SYS_PLL2, &clk);
+       if (!ret)
+               clk_enable(clk);
+
+       ret = clk_get_by_id(IMX8MP_SYS_PLL3, &clk);
+       if (!ret)
+               clk_enable(clk);
+
        base = dev_read_addr_ptr(dev);
        if (!base)
                return -EINVAL;
Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#17 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Heiko,

Quoted 57 lines
Quoted 43 lines
Quoted 8 lines
Quoted 7 lines

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines

prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08
Author: Michael Trimarchi <[email protected]> Date:   Tue Jul 9 08:28:13 2024 +0200

    clk: clk-uclass: Print clk name in clk_enable/clk_disable

    Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

Quoted 5 lines

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

My series is complimentary, even though there are some overlaps that we need to merge.

Thanks,
Miquèl

#18 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Miguel

Quoted 73 lines · Miquel Raynal

Hi Heiko,

Quoted 57 lines
Quoted 43 lines
Quoted 8 lines
Quoted 7 lines

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines

prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08

Author: Michael Trimarchi <[email protected]>
Date:   Tue Jul 9 08:28:13 2024 +0200

clk: clk-uclass: Print clk name in clk_enable/clk_disable

Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

Quoted 5 lines

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

Quoted 8 lines

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

The clock patches are not specific at all. You need to have it working for the parent for each component.
This is a standard way to do it and nothing magic compared to other implementations. I don't see
in your series any addressing or reparent clock or take in account that a clock should be enable before
reparenting.

Quoted 2 lines

My series is complimentary, even though there are some overlaps that we need to merge.

The only collision I can see from your series is that you re-write the imx approach of power domain.
Can you please expand here a bit your point?

Michael

Quoted 3 lines

Thanks,
Miquèl

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#19 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Michael,

[email protected] wrote on Tue, 1 Oct 2024 10:33:56 +0200:

Quoted 82 lines

Hi Miguel

Quoted 79 lines · Miquel Raynal

Hi Heiko,

Quoted 57 lines
Quoted 43 lines
Quoted 8 lines
Quoted 7 lines

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines

prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08

Author: Michael Trimarchi <[email protected]>
Date:   Tue Jul 9 08:28:13 2024 +0200

clk: clk-uclass: Print clk name in clk_enable/clk_disable

Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

Quoted 5 lines

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

Quoted 5 lines
Quoted 2 lines

https://lore.kernel.org/u-boot/[email protected]/

The clock patches are not specific at all. You need to have it working for the parent for each component.

The diff shown by Heiko is explicitly enabling PLLs by naming them in the iMX driver. This is not the correct approach. The problem of having non-enabled new parents is global. Parent clocks should be enabled before changing muxes, and this should be enforced by the clock core/uclass, not the SoC drivers.

Quoted 2 lines

This is a standard way to do it and nothing magic compared to other implementations.

No, naming PLLs explicitly is not the correct approach.

Quoted 4 lines

I don't see
in your series any addressing or reparent clock or take in account that a clock should be enable before
reparenting.

That's exactly the link above, whose diff is pasted here for reference:

@@ -595,6 +595,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
if (!ops->set_parent)
return -ENOSYS;

+ ret = clk_enable(parent);
+ if (ret)
+ return ret;

Quoted 7 lines
Quoted 3 lines

My series is complimentary, even though there are some overlaps that we need to merge.

The only collision I can see from your series is that you re-write the imx approach of power domain.
Can you please expand here a bit your point?

Well, that's what I'd call an overlap :) There are also similar changes in the clock core IIRC. Well, there is a bit of merging that needs to happen I guess, but if you don't think there is any then my series can enter as-is (once the comments addressed, ofc).

Thanks,
Miquèl

#20 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hello Miquel,

Quoted 89 lines · Miquel Raynal

Hi Michael,

[email protected] wrote on Tue, 1 Oct 2024 10:33:56 +0200:

Quoted 85 lines

Hi Miguel

Quoted 81 lines · Miquel Raynal

Hi Heiko,

Quoted 57 lines
Quoted 43 lines
Quoted 8 lines
Quoted 7 lines

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines

prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08

Author: Michael Trimarchi <[email protected]>
Date:   Tue Jul 9 08:28:13 2024 +0200

clk: clk-uclass: Print clk name in clk_enable/clk_disable

Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

Quoted 5 lines

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 8 lines
Quoted 2 lines

The clock patches are not specific at all. You need to have it working for the parent for each component.

The diff shown by Heiko is explicitly enabling PLLs by naming them in the iMX driver. This is not the correct approach. The problem of having non-enabled new parents is global. Parent clocks should be enabled before changing muxes, and this should be enforced by the clock core/uclass, not the SoC drivers.

Okay, valid argument.

Quoted 14 lines
Quoted 3 lines

This is a standard way to do it and nothing magic compared to other implementations.

No, naming PLLs explicitly is not the correct approach.

Quoted 4 lines

I don't see
in your series any addressing or reparent clock or take in account that a clock should be enable before
reparenting.

That's exactly the link above, whose diff is pasted here for reference:

Review int clk_set_parent(struct clk *clk, struct clk *parent) · line 600

Quoted 6 lines
(quoted diff) +3 -0
@@ -595,6 +595,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
  	if (!ops->set_parent)
  		return -ENOSYS;
 
+	ret = clk_enable(parent);
+	if (ret)
+		return ret;

As I said before, I had *exact* the same patch and thought I made a big hack :-P

But I wonder ... if this a generic "problem", why nobody had yet problems with it...

Thanks!

bye,
Heiko

Quoted 15 lines
Quoted 6 lines
Quoted 2 lines

My series is complimentary, even though there are some overlaps that we need to merge.

The only collision I can see from your series is that you re-write the imx approach of power domain.
Can you please expand here a bit your point?

Well, that's what I'd call an overlap :) There are also similar changes in the clock core IIRC. Well, there is a bit of merging that needs to happen I guess, but if you don't think there is any then my series can enter as-is (once the comments addressed, ofc).

Thanks,
Miquèl

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#21 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi all

Quoted 128 lines · Heiko Schocher

Hello Miquel,

Quoted 89 lines · Miquel Raynal

Hi Michael,

[email protected] wrote on Tue, 1 Oct 2024 10:33:56 +0200:

Quoted 85 lines

Hi Miguel

Quoted 81 lines · Miquel Raynal

Hi Heiko,

Quoted 57 lines
Quoted 43 lines
Quoted 8 lines
Quoted 7 lines

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines

prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08

Author: Michael Trimarchi <[email protected]>
Date:   Tue Jul 9 08:28:13 2024 +0200

clk: clk-uclass: Print clk name in clk_enable/clk_disable

Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

Quoted 5 lines

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 8 lines
Quoted 2 lines

The clock patches are not specific at all. You need to have it working for the parent for each component.

The diff shown by Heiko is explicitly enabling PLLs by naming them in the iMX driver. This is not the correct approach. The problem of having non-enabled new parents is global. Parent clocks should be enabled before changing muxes, and this should be enforced by the clock core/uclass, not the SoC drivers.

Okay, valid argument.

Quoted 14 lines
Quoted 3 lines

This is a standard way to do it and nothing magic compared to other implementations.

No, naming PLLs explicitly is not the correct approach.

Quoted 4 lines

I don't see
in your series any addressing or reparent clock or take in account that a clock should be enable before
reparenting.

That's exactly the link above, whose diff is pasted here for reference:

Review int clk_set_parent(struct clk *clk, struct clk *parent) · line 600

Quoted 6 lines
(quoted diff) +3 -0
@@ -595,6 +595,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
      if (!ops->set_parent)
              return -ENOSYS;
 
+     ret = clk_enable(parent);
+     if (ret)
+             return ret;

As I said before, I had *exact* the same patch and thought I made a big hack :-P

Quoted 2 lines

But I wonder ... if this a generic "problem", why nobody had yet problems with it...

I think that a generic approach that takes into account the reparent is more valuable, then
this. If a clock is enabled by another stage and we don't aware about it we need to mark
as enabled. I think that this force of enable it's just a short path that does not solve the generic
problem. I really tried to abstract what is really implemented in other OS on the same topic.
I don't want to have a discussion about who should merge first.

Michael

Quoted 18 lines

Thanks!

bye,
Heiko

Quoted 12 lines
Quoted 6 lines
Quoted 2 lines

My series is complimentary, even though there are some overlaps that we need to merge.

The only collision I can see from your series is that you re-write the imx approach of power domain.
Can you please expand here a bit your point?

Well, that's what I'd call an overlap :) There are also similar changes in the clock core IIRC. Well, there is a bit of merging that needs to happen I guess, but if you don't think there is any then my series can enter as-is (once the comments addressed, ofc).

Quoted 8 lines
Quoted 3 lines

Thanks,
Miquèl

--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: [email protected]

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com

#22 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Michael,

Quoted 56 lines
Quoted 56 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 8 lines
Quoted 2 lines

The clock patches are not specific at all. You need to have it working for the parent for each component.

The diff shown by Heiko is explicitly enabling PLLs by naming them in the iMX driver. This is not the correct approach. The problem of having non-enabled new parents is global. Parent clocks should be enabled before changing muxes, and this should be enforced by the clock core/uclass, not the SoC drivers.

Okay, valid argument.

Quoted 14 lines
Quoted 3 lines

This is a standard way to do it and nothing magic compared to other implementations.

No, naming PLLs explicitly is not the correct approach.

Quoted 4 lines

I don't see
in your series any addressing or reparent clock or take in account that a clock should be enable before
reparenting.

That's exactly the link above, whose diff is pasted here for reference:

Review int clk_set_parent(struct clk *clk, struct clk *parent) · line 600

Quoted 6 lines
(quoted diff) +3 -0
@@ -595,6 +595,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
      if (!ops->set_parent)
              return -ENOSYS;
 
+     ret = clk_enable(parent);
+     if (ret)
+             return ret;  

As I said before, I had *exact* the same patch and thought I made a big hack :-P

Quoted 6 lines
Quoted 2 lines

But I wonder ... if this a generic "problem", why nobody had yet problems with it...

I think that a generic approach that takes into account the reparent is more valuable, then
this.

I'm sorry I don't fully understand your answer. I assume you agree with the generic approach quoted above.

Quoted 3 lines

If a clock is enabled by another stage and we don't aware about it we need to mark
as enabled.

clk_enable() already handles this kind of situation.

Quoted 3 lines

I think that this force of enable it's just a short path that does not solve the generic
problem.

What "force of enable"? The parent needs to be enabled before we use it as parent. The logic is always the same:
- clk_enable() the new parent
- change the parent
- clk_disable() the old parent
I don't see any short path here.

Quoted 2 lines

I really tried to abstract what is really implemented in other OS on the same topic.

FYI, Linux does the clk_enable(parent) like above.

Thanks,
Miquèl

#23 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi

Quoted 86 lines · Miquel Raynal

Hi Michael,

Quoted 56 lines
Quoted 56 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 8 lines
Quoted 2 lines

The clock patches are not specific at all. You need to have it working for the parent for each component.

The diff shown by Heiko is explicitly enabling PLLs by naming them in the iMX driver. This is not the correct approach. The problem of having non-enabled new parents is global. Parent clocks should be enabled before changing muxes, and this should be enforced by the clock core/uclass, not the SoC drivers.

Okay, valid argument.

Quoted 14 lines
Quoted 3 lines

This is a standard way to do it and nothing magic compared to other implementations.

No, naming PLLs explicitly is not the correct approach.

Quoted 4 lines

I don't see
in your series any addressing or reparent clock or take in account that a clock should be enable before
reparenting.

That's exactly the link above, whose diff is pasted here for reference:

Review int clk_set_parent(struct clk *clk, struct clk *parent) · line 600

Quoted 6 lines
(quoted diff) +3 -0
@@ -595,6 +595,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
      if (!ops->set_parent)
              return -ENOSYS;
 
+     ret = clk_enable(parent);
+     if (ret)
+             return ret;

As I said before, I had *exact* the same patch and thought I made a big hack :-P

Quoted 6 lines
Quoted 2 lines

But I wonder ... if this a generic "problem", why nobody had yet problems with it...

I think that a generic approach that takes into account the reparent is more valuable, then
this.

I'm sorry I don't fully understand your answer. I assume you agree with the generic approach quoted above.

Quoted 3 lines

If a clock is enabled by another stage and we don't aware about it we need to mark
as enabled.

clk_enable() already handles this kind of situation.

Quoted 3 lines

I think that this force of enable it's just a short path that does not solve the generic
problem.

What "force of enable"? The parent needs to be enabled before we use it as parent. The logic is always the same:
- clk_enable() the new parent
- change the parent
- clk_disable() the old parent
I don't see any short path here.

Quoted 5 lines
Quoted 2 lines

I really tried to abstract what is really implemented in other OS on the same topic.

FYI, Linux does the clk_enable(parent) like above.

You mean linux enables a clock in set_parent even if the clock_chain is not yet enabled.
clock a disable
clock b disable

clk_set_parent(a, b) b->a now b is enabled?

Michael

Quoted 2 lines

Thanks,
Miquèl

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#24 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Michael,

[email protected] wrote on Tue, 1 Oct 2024 15:02:56 +0200:

Quoted 95 lines

Hi

Quoted 86 lines · Miquel Raynal

Hi Michael,

Quoted 56 lines
Quoted 56 lines
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 8 lines
Quoted 2 lines

The clock patches are not specific at all. You need to have it working for the parent for each component.

The diff shown by Heiko is explicitly enabling PLLs by naming them in the iMX driver. This is not the correct approach. The problem of having non-enabled new parents is global. Parent clocks should be enabled before changing muxes, and this should be enforced by the clock core/uclass, not the SoC drivers.

Okay, valid argument.

Quoted 14 lines
Quoted 3 lines

This is a standard way to do it and nothing magic compared to other implementations.

No, naming PLLs explicitly is not the correct approach.

Quoted 4 lines

I don't see
in your series any addressing or reparent clock or take in account that a clock should be enable before
reparenting.

That's exactly the link above, whose diff is pasted here for reference:

Review int clk_set_parent(struct clk *clk, struct clk *parent) · line 600

Quoted 6 lines
(quoted diff) +3 -0
@@ -595,6 +595,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
      if (!ops->set_parent)
              return -ENOSYS;
 
+     ret = clk_enable(parent);
+     if (ret)
+             return ret;  

As I said before, I had *exact* the same patch and thought I made a big hack :-P

Quoted 6 lines
Quoted 2 lines

But I wonder ... if this a generic "problem", why nobody had yet problems with it...

I think that a generic approach that takes into account the reparent is more valuable, then
this.

I'm sorry I don't fully understand your answer. I assume you agree with the generic approach quoted above.

Quoted 3 lines

If a clock is enabled by another stage and we don't aware about it we need to mark
as enabled.

clk_enable() already handles this kind of situation.

Quoted 3 lines

I think that this force of enable it's just a short path that does not solve the generic
problem.

What "force of enable"? The parent needs to be enabled before we use it as parent. The logic is always the same:
- clk_enable() the new parent
- change the parent
- clk_disable() the old parent
I don't see any short path here.

Quoted 5 lines
Quoted 2 lines

I really tried to abstract what is really implemented in other OS on the same topic.

FYI, Linux does the clk_enable(parent) like above.

Quoted 6 lines

You mean linux enables a clock in set_parent even if the clock_chain is not yet enabled.
clock a disable
clock b disable

clk_set_parent(a, b) b->a now b is enabled?

Actually you're right Linux does the enable call only if a flag is set (and anyway it's not in the faulty case reported above) or when the reparented clock is already clocking. I'll have to check again with this clk_enable() solves the situation and what could be done instead.

Thanks,
Miquèl

#25 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

In reply to Heiko Schocher

Hi Heiko,

[email protected] wrote on Tue, 1 Oct 2024 10:57:27 +0200:

Quoted 112 lines

Hello Miquel,

Quoted 85 lines · Miquel Raynal

Hi Michael,

[email protected] wrote on Tue, 1 Oct 2024 10:33:56 +0200:

Quoted 81 lines

Hi Miguel

Quoted 78 lines · Miquel Raynal

Hi Heiko,

Quoted 55 lines
Quoted 41 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

Hmm.. unfortunately ... I had applied your 2 clock patches, which

fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

prints the clock name so if you enable

the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08

Author: Michael Trimarchi <[email protected]>
Date:   Tue Jul 9 08:28:13 2024 +0200

clk: clk-uclass: Print clk name in clk_enable/clk_disable

Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

Quoted 5 lines

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 2 lines

The clock patches are not specific at all. You need to have it working for the parent for each component.

The diff shown by Heiko is explicitly enabling PLLs by naming them in the iMX driver. This is not the correct approach. The problem of having non-enabled new parents is global. Parent clocks should be enabled before changing muxes, and this should be enforced by the clock core/uclass, not the SoC drivers.

Okay, valid argument.

Quoted 13 lines
Quoted 3 lines

This is a standard way to do it and nothing magic compared to other implementations.

No, naming PLLs explicitly is not the correct approach.

Quoted 4 lines

I don't see
in your series any addressing or reparent clock or take in account that a clock should be enable before
reparenting.

That's exactly the link above, whose diff is pasted here for reference:

Quoted 9 lines

Review int clk_set_parent(struct clk *clk, struct clk *parent) · line 599

Quoted 6 lines
(quoted diff) +2 -0
@@ -595,6 +595,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
  	if (!ops->set_parent)
  		return -ENOSYS;  
  > +	ret = clk_enable(parent);  
+	if (ret)
+		return ret;  

As I said before, I had *exact* the same patch and thought I made a big hack :-P

I don't think so :-)

Quoted 2 lines

But I wonder ... if this a generic "problem", why nobody had yet problems with it...

It depends on your hardware and how you use it I guess. If you look into the terribly complex clock slices explanation in the imx8mp manual, you'll see what the target clock interface does behind the scenes when you use it. There are like 25 steps internally to prevent glitch-free changes. I suspect one of those actions to stall if the parent is not enabled early enough during the reparenting procedure.

Now, the reason why parents might be disabled is because of the high level of configurability this SoC offers which is likely higher than many other SoCs. But in general, to avoid these stalls, there has been a quite extensive use of assigned-clocks properties. I believe with yet another entry in this list, we could probably make it work, but that's not the correct approach either.

Thanks,
Miquèl

#26 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

In reply to Miquel Raynal

Hello Miquel,

Quoted 72 lines · Miquel Raynal

Hi Heiko,

Quoted 57 lines
Quoted 43 lines
Quoted 8 lines
Quoted 7 lines

Hmm.. unfortunately ... I had applied your 2 clock patches, which fixed a problem with enabling parent clocks ... but they broke booting on a carrier which has fec ethernet! After "Net: " output the board hang...

I reverted your 2 clock patches and it bootet again ... so there is a problem ... try to get some more time to look into...

Quoted 13 lines

We have a fec, but we had I think two patches more on it. I forget to answer Marek
about them because I don't have my board now and because he is partially right (or maybe right).
Anyway when we boot we could have and we have clocks that are enabled by bootrom or SPL that
we need to declare as enable like PLL2/PLL3 those clocks are parts or could be part of reparent so,
you need to have a reference counter on them that allow to not disable during the down chain disable
and up chain enable. I think that what happens to your ethernet it's that you disable some clock that is
critical to the board to survive. I had a patch merged by Tom that

Yep, thats what I think too! If you access registers in a block for which the clock is not enabled ... it just hang...

Quoted 3 lines

prints the clock name so if you enable
the debug of the clock you will find that your board stops working during one of this reparinting.

I currently work on 2024.07... will rebase if 2024.10 is out...

Ah, you mean:

commit a70d991212c9684e09ed80ece69ce1ff7bfd9f08
Author: Michael Trimarchi <[email protected]> Date:   Tue Jul 9 08:28:13 2024 +0200

    clk: clk-uclass: Print clk name in clk_enable/clk_disable

    Print clk name in clk_enable and clk_disable. Make sense to know what clock get disabled/enabled before a system crash or system hang.

Quoted 5 lines

I have the same change when I debug :-P

IIRC I did not see the clock names ... but I will recheck!

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

Quoted 7 lines

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

Yes, I also had such a "fix" first, before seeing Darios patchset!

Damn, I did not see your patches...

regarding your patch ... I am unsure which version is the best one ... I fear of side effects for other plattforms adding this change in generic "drivers/clk/clk-uclass.c" file...

Quoted 2 lines

My series is complimentary, even though there are some overlaps that we need to merge.

I try to find time to test them on my board!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#27 lore raw

Re: [PATCH 08/26] power: Add iMX8M block ctrl driver for dispmix

Hi Heiko,

Quoted 28 lines
Quoted 20 lines
Quoted 8 lines

I see with your patch the clock names, so fine... and see [1]

Hmm... I am on imx8mp, and I think the changes the patchset do in

"clk: imx8mn: Prevent clock critical path from disabling during reparent and set_rate"

are in clk-imx8mp already ...

Quoted 7 lines

Ported the patch from patchset

"[PATCH 05/26] clk: imx8mm: Mark IMX8MM_SYS_PLL2 and IMX8MM_SYS_PLL3 as enabled"

to imx8mp [2] and fec ethernet works again for me on imx8mp!

Could you add this if you post a v2 ?

TBH I don't feel like the below change is the correct one, it is too specific. The clock core is recursive and thus should handle the reparenting situations gracefully.

Quoted 7 lines

I posted a series that is targeting the LVDS output on imx8mp. You should probably consider checking these patches as well if you work on imx8mp as well. I also had similar breakages with Ethernet which happened during the assigned-clocks handling. This patch, which is more future and platform agnostic, fixed it:

https://lore.kernel.org/u-boot/[email protected]/

Quoted 7 lines

Yes, I also had such a "fix" first, before seeing Darios patchset!

Damn, I did not see your patches...

regarding your patch ... I am unsure which version is the best one ... I fear of side effects for other plattforms adding this change in generic "drivers/clk/clk-uclass.c" file...

FYI, this is the same approach as Linux. I don't expect any hardware related breakage, however if people have already tried to workaround the core's mistakes by doing more than expected in the SoC drivers, maybe we will observe issues.

Quoted 4 lines
Quoted 2 lines

My series is complimentary, even though there are some overlaps that we need to merge.

I try to find time to test them on my board!

Sure, let me know if you have troubles, it's still fresh :-) I will rework it a bit as it received already interesting feedback, and will note to Cc you (as well as Dario/Michael) in v2.

Thanks,
Miquèl

#28 lore raw

PATCH 9/26 video: Add video link framework

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

The video link framework bases a port-endpoint gragh in DTB to connect the video components in uclass like: video, display, bridge, and panel.

Using the port-endpoint gragh, we manage multiple video link and user can select one of them for splash screen.

---

 common/stdio.c             |   4 +
 drivers/video/Kconfig      |   6 +
 drivers/video/Makefile     |   1 +
 drivers/video/video_link.c | 529 +++++++++++++++++++++++++++++++++++++
 include/video_link.h       |  19 ++
 5 files changed, 559 insertions(+)
 create mode 100644 drivers/video/video_link.c
 create mode 100644 include/video_link.h
common/stdio.c +4 -0
index a61220ce4b9c..66360c97ed12 100644
@@ -17,6 +17,7 @@
 #include <stdio_dev.h>
 #include <serial.h>
 #include <splash.h>
+#include <video_link.h>
 #include <i2c.h>
 #include <asm/global_data.h>
 #include <dm/device-internal.h>
@@ -340,6 +341,9 @@ int stdio_add_devices(void)
 		struct udevice *vdev;
 		int ret;
 
+		if (IS_ENABLED(CONFIG_VIDEO_LINK))
+			video_link_init();
+
 		if (!IS_ENABLED(CONFIG_SYS_CONSOLE_IS_IN_ENV)) {
 			for (ret = uclass_first_device_check(UCLASS_VIDEO,
 							     &vdev);
drivers/video/Kconfig +6 -0
index 6e79694fd192..cafdc15f9fe2 100644
@@ -833,6 +833,12 @@ config VIDEO_SEPS525
 source "drivers/video/zynqmp/Kconfig"
 source "drivers/video/nexell/Kconfig"
 
+config VIDEO_LINK
+	bool "Enable video link framework support"
+	help
+	   This option enables a video link framework basing on port-endpoint graph
+	   to connect video components.
+
 config CONSOLE_SCROLL_LINES
 	int "Number of lines to scroll the console by"
 	default 1
drivers/video/Makefile +1 -0
index f3f70cd04a17..9fd3645994f1 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_$(SPL_TPL_)SIMPLE_PANEL) += simple_panel.o
 obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
 obj-$(CONFIG_$(SPL_TPL_)BMP) += bmp.o
 
+obj-$(CONFIG_VIDEO_LINK) += video_link.o
 endif
 
 obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_backlight.o
drivers/video/video_link.c new file +529 -0

529 lines not on this page · raw message

include/video_link.h new file +19 -0
new file mode 100644
index 000000000000..5350bfa9e9d1
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright 2020 NXP
+ */
+
+#ifndef __VIDEO_LINK
+#define __VIDEO_LINK
+
+int video_link_init(void);
+
+int video_link_shut_down(void);
+
+struct udevice *video_link_get_next_device(struct udevice *curr_dev);
+
+struct udevice *video_link_get_video_device(void);
+
+int video_link_get_display_timings(struct display_timing *timings);
+
+#endif
Signature · 1 line
2.43.0
#29 lore raw

PATCH 10/26 video: bridge: Add check_timing interface

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Add new interface check_timing to video bridge uclass. For bridge device who may update timing needs to implement the callback. So host device can sync the timing with the bridge.

---

 drivers/video/bridge/video-bridge-uclass.c | 10 ++++++++++
 include/video_bridge.h                     | 20 ++++++++++++++++++++
 2 files changed, 30 insertions(+)
drivers/video/bridge/video-bridge-uclass.c +10 -0
index 2084a2e03ee8..7432107238cc 100644
@@ -48,6 +48,16 @@ int video_bridge_check_attached(struct udevice *dev)
 	return ops->check_attached(dev);
 }
 
+int video_bridge_check_timing(struct udevice *dev, struct display_timing *timing)
+{
+	struct video_bridge_ops *ops = video_bridge_get_ops(dev);
+
+	if (ops->check_timing)
+		return ops->check_timing(dev, timing);
+
+	return 0;
+}
+
 int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size)
 {
 	struct video_bridge_ops *ops = video_bridge_get_ops(dev);
include/video_bridge.h +20 -0
index 3b429eac578a..8b71b04a1119 100644
@@ -44,6 +44,17 @@ struct video_bridge_ops {
 	 */
 	int (*check_attached)(struct udevice *dev);
 
+	/**
+	 * check_timing() - check if the timing need update after the bridge device attached
+	 *
+	 * This method is optional - if not provided then return 0
+	 *
+	 * @dev:	Device to check
+	 * @active:	The timing to be checked and updated
+	 * Return: 0 if OK, -ve on error
+	 */
+	int (*check_timing)(struct udevice *dev, struct display_timing *timing);
+
 	/**
 	 * set_backlight() - Set the backlight brightness
 	 *
@@ -98,6 +109,15 @@ int video_bridge_set_active(struct udevice *dev, bool active);
  */
 int video_bridge_check_attached(struct udevice *dev);
 
+/**
+ * check_timing() - check if the timing need update after the bridge device attached
+ *
+ * @dev:	Device to check
+ * @active:	The timing to be checked and updated
+ * Return: 0 if OK, -ve on error
+ */
+int video_bridge_check_timing(struct udevice *dev, struct display_timing *timing);
+
 /**
  * video_bridge_read_edid() - Read information from EDID
  *
Signature · 1 line
2.43.0
#30 lore raw

PATCH 11/26 video: dsi_host: add disable host interface

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Current operations structure has provided disable callback, but there is no API from dsi_host uclass to use it.

Add this disable host interface, so that dsi bridge can call it to disable host

---

 drivers/video/dsi-host-uclass.c | 10 ++++++++++
 include/dsi_host.h              |  8 ++++++++
 2 files changed, 18 insertions(+)
drivers/video/dsi-host-uclass.c +10 -0
index fde275ad7e2e..745991f8dd94 100644
@@ -34,6 +34,16 @@ int dsi_host_enable(struct udevice *dev)
 	return ops->enable(dev);
 }
 
+int dsi_host_disable(struct udevice *dev)
+{
+	struct dsi_host_ops *ops = dsi_host_get_ops(dev);
+
+	if (!ops->disable)
+		return -ENOSYS;
+
+	return ops->disable(dev);
+}
+
 UCLASS_DRIVER(dsi_host) = {
 	.id		= UCLASS_DSI_HOST,
 	.name		= "dsi_host",
include/dsi_host.h +8 -0
index 83f8839db68d..5873ab698d9e 100644
@@ -70,4 +70,12 @@ int dsi_host_init(struct udevice *dev,
  */
 int dsi_host_enable(struct udevice *dev);
 
+/**
+ * dsi_host_disable
+ *
+ * @dev:	dsi host device
+ * @return 0 if OK, -ve on error
+ */
+int dsi_host_disable(struct udevice *dev);
+
 #endif
Signature · 1 line
2.43.0
#31 lore raw

PATCH 12/26 video: Update mxsfb video drivers for iMX8MM/iMX8MN display

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Update mxsfb for LCD video driver

---

 drivers/video/mxsfb.c | 139 ++++++++++++++++++++++++++++--------------
 1 file changed, 93 insertions(+), 46 deletions(-)
drivers/video/mxsfb.c +93 -46
index 792d6314d15e..45431f0a1047 100644
@@ -21,8 +21,13 @@
 #include <asm/global_data.h>
 #include <asm/mach-imx/dma.h>
 #include <asm/io.h>
+#include <reset.h>
+#include <panel.h>
+#include <video_bridge.h>
+#include <video_link.h>
 
 #include "videomodes.h"
+#include <dm/device-internal.h>
 
 #define	PS2KHZ(ps)	(1000000000UL / (ps))
 #define HZ2PS(hz)	(1000000000UL / ((hz) / 1000))
@@ -30,6 +35,11 @@
 #define BITS_PP		18
 #define BYTES_PP	4
 
+struct mxsfb_priv {
+	fdt_addr_t reg_base;
+	struct udevice *disp_dev;
+};
+
 struct mxs_dma_desc desc;
 
 /**
@@ -56,9 +66,10 @@ __weak void mxsfb_system_setup(void)
  */
 
 static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
-			 struct display_timing *timings, int bpp)
+			 struct display_timing *timings, int bpp, bool bridge)
 {
-	struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
+	struct mxsfb_priv *priv = dev_get_priv(dev);
+	struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)priv->reg_base;
 	const enum display_flags flags = timings->flags;
 	uint32_t word_len = 0, bus_width = 0;
 	uint8_t valid_data = 0;
@@ -109,7 +120,7 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
 	}
 #else
 	/* Kick in the LCDIF clock */
-	mxs_set_lcdclk(MXS_LCDIF_BASE, timings->pixelclock.typ / 1000);
+	mxs_set_lcdclk(priv->reg_base, timings->pixelclock.typ / 1000);
 #endif
 
 	/* Restart the LCDIF block */
@@ -142,26 +153,30 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
 		LCDIF_CTRL_BYPASS_COUNT | LCDIF_CTRL_LCDIF_MASTER,
 		&regs->hw_lcdif_ctrl);
 
-	writel(valid_data << LCDIF_CTRL1_BYTE_PACKING_FORMAT_OFFSET,
+	writel((valid_data << LCDIF_CTRL1_BYTE_PACKING_FORMAT_OFFSET) |
+		LCDIF_CTRL1_RECOVER_ON_UNDERFLOW,
 		&regs->hw_lcdif_ctrl1);
 
+	if (bridge)
+		writel(LCDIF_CTRL2_OUTSTANDING_REQS_REQ_16, &regs->hw_lcdif_ctrl2);
+
 	mxsfb_system_setup();
 
 	writel((timings->vactive.typ << LCDIF_TRANSFER_COUNT_V_COUNT_OFFSET) |
 		timings->hactive.typ, &regs->hw_lcdif_transfer_count);
 
-	vdctrl0 = LCDIF_VDCTRL0_ENABLE_PRESENT | LCDIF_VDCTRL0_ENABLE_POL |
+	vdctrl0 = LCDIF_VDCTRL0_ENABLE_PRESENT |
 		  LCDIF_VDCTRL0_VSYNC_PERIOD_UNIT |
 		  LCDIF_VDCTRL0_VSYNC_PULSE_WIDTH_UNIT |
 		  timings->vsync_len.typ;
 
-	if(flags & DISPLAY_FLAGS_HSYNC_HIGH)
+	if (flags & DISPLAY_FLAGS_HSYNC_HIGH)
 		vdctrl0 |= LCDIF_VDCTRL0_HSYNC_POL;
-	if(flags & DISPLAY_FLAGS_VSYNC_HIGH)
+	if (flags & DISPLAY_FLAGS_VSYNC_HIGH)
 		vdctrl0 |= LCDIF_VDCTRL0_VSYNC_POL;
-	if(flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
+	if (flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE)
 		vdctrl0 |= LCDIF_VDCTRL0_DOTCLK_POL;
-	if(flags & DISPLAY_FLAGS_DE_HIGH)
+	if (flags & DISPLAY_FLAGS_DE_HIGH)
 		vdctrl0 |= LCDIF_VDCTRL0_ENABLE_POL;
 
 	writel(vdctrl0, &regs->hw_lcdif_vdctrl0);
@@ -198,10 +213,10 @@ static void mxs_lcd_init(struct udevice *dev, u32 fb_addr,
 }
 
 static int mxs_probe_common(struct udevice *dev, struct display_timing *timings,
-			    int bpp, u32 fb)
+			    int bpp, u32 fb, bool bridge)
 {
 	/* Start framebuffer */
-	mxs_lcd_init(dev, fb, timings, bpp);
+	mxs_lcd_init(dev, fb, timings, bpp, bridge);
 
 #ifdef CONFIG_VIDEO_MXS_MODE_SYSTEM
 	/*
@@ -212,7 +227,8 @@ static int mxs_probe_common(struct udevice *dev, struct display_timing *timings,
 	 * sets the RUN bit, then waits until it gets cleared and repeats this
 	 * infinitelly. This way, we get smooth continuous updates of the LCD.
 	 */
-	struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
+	struct mxsfb_priv *priv = dev_get_priv(dev);
+	struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)priv->reg_base;
 
 	memset(&desc, 0, sizeof(struct mxs_dma_desc));
 	desc.address = (dma_addr_t)&desc;
@@ -229,9 +245,9 @@ static int mxs_probe_common(struct udevice *dev, struct display_timing *timings,
 	return 0;
 }
 
-static int mxs_remove_common(u32 fb)
+static int mxs_remove_common(phys_addr_t reg_base, u32 fb)
 {
-	struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)MXS_LCDIF_BASE;
+	struct mxs_lcdif_regs *regs = (struct mxs_lcdif_regs *)(reg_base);
 	int timeout = 1000000;
 
 	if (!fb)
@@ -258,6 +274,7 @@ static int mxs_of_get_timings(struct udevice *dev,
 	int ret = 0;
 	u32 display_phandle;
 	ofnode display_node;
+	struct mxsfb_priv *priv = dev_get_priv(dev);
 
 	ret = ofnode_read_u32(dev_ofnode(dev), "display", &display_phandle);
 	if (ret) {
@@ -278,10 +295,19 @@ static int mxs_of_get_timings(struct udevice *dev,
 		return -EINVAL;
 	}
 
-	ret = ofnode_decode_display_timing(display_node, 0, timings);
-	if (ret) {
-		dev_err(dev, "failed to get any display timings\n");
-		return -EINVAL;
+	priv->disp_dev = video_link_get_next_device(dev);
+	if (priv->disp_dev) {
+		ret = video_link_get_display_timings(timings);
+		if (ret) {
+			dev_err(dev, "failed to get any video link display timings\n");
+			return -EINVAL;
+		}
+	} else {
+		ret = ofnode_decode_display_timing(display_node, 0, timings);
+		if (ret) {
+			dev_err(dev, "failed to get any display timings\n");
+			return -EINVAL;
+		}
 	}
 
 	return ret;
@@ -291,20 +317,58 @@ static int mxs_video_probe(struct udevice *dev)
 {
 	struct video_uc_plat *plat = dev_get_uclass_plat(dev);
 	struct video_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct mxsfb_priv *priv = dev_get_priv(dev);
 
 	struct display_timing timings;
 	u32 bpp = 0;
 	u32 fb_start, fb_end;
 	int ret;
+	bool enable_bridge = false;
 
 	debug("%s() plat: base 0x%lx, size 0x%x\n",
 	       __func__, plat->base, plat->size);
 
+	priv->reg_base = dev_read_addr(dev);
+	if (priv->reg_base == FDT_ADDR_T_NONE) {
+		dev_err(dev, "lcdif base address is not found\n");
+		return -EINVAL;
+	}
+
 	ret = mxs_of_get_timings(dev, &timings, &bpp);
 	if (ret)
 		return ret;
 
-	ret = mxs_probe_common(dev, &timings, bpp, plat->base);
+	if (priv->disp_dev) {
+		if (IS_ENABLED(CONFIG_VIDEO_BRIDGE)) {
+			if (device_get_uclass_id(priv->disp_dev) == UCLASS_VIDEO_BRIDGE) {
+				ret = video_bridge_attach(priv->disp_dev);
+				if (ret) {
+					dev_err(dev, "fail to attach bridge\n");
+					return ret;
+				}
+
+				ret = video_bridge_set_backlight(priv->disp_dev, 80);
+				if (ret) {
+					dev_err(dev, "fail to set backlight\n");
+					return ret;
+				}
+
+				enable_bridge = true;
+				video_bridge_check_timing(priv->disp_dev, &timings);
+			}
+		}
+
+		if (device_get_uclass_id(priv->disp_dev) == UCLASS_PANEL) {
+			ret = panel_enable_backlight(priv->disp_dev);
+			if (ret) {
+				dev_err(dev, "panel %s enable backlight error %d\n",
+					priv->disp_dev->name, ret);
+				return ret;
+			}
+		}
+	}
+
+	ret = mxs_probe_common(dev, &timings, bpp, plat->base, enable_bridge);
 	if (ret)
 		return ret;
 
@@ -343,33 +407,9 @@ static int mxs_video_probe(struct udevice *dev)
 static int mxs_video_bind(struct udevice *dev)
 {
 	struct video_uc_plat *plat = dev_get_uclass_plat(dev);
-	struct display_timing timings;
-	u32 bpp = 0;
-	u32 bytes_pp = 0;
-	int ret;
 
-	ret = mxs_of_get_timings(dev, &timings, &bpp);
-	if (ret)
-		return ret;
-
-	switch (bpp) {
-	case 32:
-	case 24:
-	case 18:
-		bytes_pp = 4;
-		break;
-	case 16:
-		bytes_pp = 2;
-		break;
-	case 8:
-		bytes_pp = 1;
-		break;
-	default:
-		dev_err(dev, "invalid bpp specified (bpp = %i)\n", bpp);
-		return -EINVAL;
-	}
-
-	plat->size = timings.hactive.typ * timings.vactive.typ * bytes_pp;
+	/* Max size supported by LCDIF, because in bind, we can't probe panel */
+	plat->size = 1920 * 1080 * 4 * 2;
 
 	return 0;
 }
@@ -377,8 +417,12 @@ static int mxs_video_bind(struct udevice *dev)
 static int mxs_video_remove(struct udevice *dev)
 {
 	struct video_uc_plat *plat = dev_get_uclass_plat(dev);
+	struct mxsfb_priv *priv = dev_get_priv(dev);
+
+	if (priv->disp_dev)
+		device_remove(priv->disp_dev, DM_REMOVE_NORMAL);
 
-	mxs_remove_common(plat->base);
+	mxs_remove_common(priv->reg_base, plat->base);
 
 	return 0;
 }
@@ -389,6 +433,8 @@ static const struct udevice_id mxs_video_ids[] = {
 	{ .compatible = "fsl,imx6sx-lcdif" },
 	{ .compatible = "fsl,imx7ulp-lcdif" },
 	{ .compatible = "fsl,imxrt-lcdif" },
+	{ .compatible = "fsl,imx8mm-lcdif" },
+	{ .compatible = "fsl,imx8mn-lcdif" },
 	{ /* sentinel */ }
 };
 
@@ -400,4 +446,5 @@ U_BOOT_DRIVER(mxs_video) = {
 	.probe	= mxs_video_probe,
 	.remove = mxs_video_remove,
 	.flags	= DM_FLAG_PRE_RELOC | DM_FLAG_OS_PREPARE,
+	.priv_auto   = sizeof(struct mxsfb_priv),
 };
Signature · 1 line
2.43.0
#32 lore raw

PATCH 13/26 video: Enable DM_UC_FLAG_SEQ_ALIAS for display and bridge

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

To support multiple display or bridge devices, enable the flag, so we can assign the req seq via DTB alias

---

 drivers/video/bridge/video-bridge-uclass.c | 1 +
 drivers/video/display-uclass.c             | 1 +
 2 files changed, 2 insertions(+)
drivers/video/bridge/video-bridge-uclass.c +1 -0
index 7432107238cc..5e2b76851fed 100644
@@ -145,6 +145,7 @@ int video_bridge_set_active(struct udevice *dev, bool active)
 UCLASS_DRIVER(video_bridge) = {
 	.id		= UCLASS_VIDEO_BRIDGE,
 	.name		= "video_bridge",
+	.flags		= DM_UC_FLAG_SEQ_ALIAS,
 	.per_device_auto	= sizeof(struct video_bridge_priv),
 	.pre_probe	= video_bridge_pre_probe,
 };
drivers/video/display-uclass.c +1 -0
index 61a73e1bc2a6..07f05be7dd17 100644
@@ -80,5 +80,6 @@ bool display_in_use(struct udevice *dev)
 UCLASS_DRIVER(display) = {
 	.id		= UCLASS_DISPLAY,
 	.name		= "display",
+	.flags          = DM_UC_FLAG_SEQ_ALIAS,
 	.per_device_plat_auto	= sizeof(struct display_plat),
 };
Signature · 1 line
2.43.0
#33 lore raw

PATCH 14/26 phy: dphy: add support to calculate the timing based on hs_clk_rate

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Upstream Linux commit 22168675bae7.

For MIPI-CSI sender use-case it is common to specify the allowed link-frequencies which should be used for the MIPI link and is half the hs-clock rate.

This commit adds a helper to calculate the D-PHY timing based on the hs-clock rate so we don't need to calculate the timings within the driver.

---

 drivers/phy/phy-core-mipi-dphy.c | 30 +++++++++++++++++++++++++-----
 include/phy-mipi-dphy.h          |  3 +++
 2 files changed, 28 insertions(+), 5 deletions(-)
drivers/phy/phy-core-mipi-dphy.c +25 -5
index 8fb985a1e682..727c2b040520 100644
@@ -13,21 +13,23 @@
 /*
  * Minimum D-PHY timings based on MIPI D-PHY specification. Derived
  * from the valid ranges specified in Section 6.9, Table 14, Page 41
- * of the D-PHY specification (v2.1).
+ * of the D-PHY specification (v1.2).
  */
-int phy_mipi_dphy_get_default_config(unsigned long pixel_clock,
+static int phy_mipi_dphy_calc_config(unsigned long pixel_clock,
 				     unsigned int bpp,
 				     unsigned int lanes,
+				     unsigned long long hs_clk_rate,
 				     struct phy_configure_opts_mipi_dphy *cfg)
 {
-	unsigned long long hs_clk_rate;
 	unsigned long long ui;
 
 	if (!cfg)
 		return -EINVAL;
 
-	hs_clk_rate = pixel_clock * bpp;
-	do_div(hs_clk_rate, lanes);
+	if (!hs_clk_rate) {
+		hs_clk_rate = pixel_clock * bpp;
+		do_div(hs_clk_rate, lanes);
+	}
 
 	ui = ALIGN(PSEC_PER_SEC, hs_clk_rate);
 	do_div(ui, hs_clk_rate);
@@ -74,6 +76,24 @@ int phy_mipi_dphy_get_default_config(unsigned long pixel_clock,
 	return 0;
 }
 
+int phy_mipi_dphy_get_default_config(unsigned long pixel_clock,
+				     unsigned int bpp,
+				     unsigned int lanes,
+				     struct phy_configure_opts_mipi_dphy *cfg)
+{
+	return phy_mipi_dphy_calc_config(pixel_clock, bpp, lanes, 0, cfg);
+}
+
+int phy_mipi_dphy_get_default_config_for_hsclk(unsigned long long hs_clk_rate,
+					       unsigned int lanes,
+					       struct phy_configure_opts_mipi_dphy *cfg)
+{
+	if (!hs_clk_rate)
+		return -EINVAL;
+
+	return phy_mipi_dphy_calc_config(0, 0, lanes, hs_clk_rate, cfg);
+}
+
 /*
  * Validate D-PHY configuration according to MIPI D-PHY specification
  * (v1.2, Section Section 6.9 "Global Operation Timing Parameters").
include/phy-mipi-dphy.h +3 -0
index a877ffee845d..1ac128d78dfe 100644
@@ -279,6 +279,9 @@ int phy_mipi_dphy_get_default_config(unsigned long pixel_clock,
 				     unsigned int bpp,
 				     unsigned int lanes,
 				     struct phy_configure_opts_mipi_dphy *cfg);
+int phy_mipi_dphy_get_default_config_for_hsclk(unsigned long long hs_clk_rate,
+					       unsigned int lanes,
+					       struct phy_configure_opts_mipi_dphy *cfg);
 int phy_mipi_dphy_config_validate(struct phy_configure_opts_mipi_dphy *cfg);
 
 #endif /* __PHY_MIPI_DPHY_H_ */
Signature · 1 line
2.43.0
#34 lore raw

PATCH 15/26 phy: dphy: Correct lpx parameter and its derivatives(ta_{get, go, sure})

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Upstream linux commit 3153fa38e38af5.

According to the comment of the function phy_mipi_dphy_get_default_config(), it uses minimum D-PHY timings based on MIPI D-PHY specification. They are derived from the valid ranges specified in Section 6.9, Table 14, Page 41 of the D-PHY specification (v1.2). The table 14 explicitly mentions that the minimum T-LPX parameter is 50 nanoseconds and the minimum TA-SURE parameter is T-LPX nanoseconds. Likewise, the kernel doc of the 'lpx' and 'ta_sure' members of struct phy_configure_opts_mipi_dphy mentions that the minimum values are 50000 picoseconds and @lpx picoseconds respectively. Also, the function phy_mipi_dphy_config_validate() checks if cfg->lpx is less than 50000 picoseconds and if cfg->ta_sure is less than cfg->lpx, which hints the same minimum values.

Without this patch, the function phy_mipi_dphy_get_default_config() wrongly sets cfg->lpx to 60000 picoseconds and cfg->ta_sure to 2 * cfg->lpx. So, let's correct them to 50000 picoseconds and cfg->lpx respectively.

Note that I've only tested the patch with RM67191 DSI panel on i.MX8mq EVK. Help is needed to test with other i.MX8mq, Meson and Rockchip platforms, as I don't have the hardwares.

---

 drivers/phy/phy-core-mipi-dphy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-core-mipi-dphy.c +2 -2
index 727c2b040520..79cab9125002 100644
@@ -64,10 +64,10 @@ static int phy_mipi_dphy_calc_config(unsigned long pixel_clock,
 	cfg->hs_trail = max(4 * 8 * ui, 60000 + 4 * 4 * ui);
 
 	cfg->init = 100;
-	cfg->lpx = 60000;
+	cfg->lpx = 50000;
 	cfg->ta_get = 5 * cfg->lpx;
 	cfg->ta_go = 4 * cfg->lpx;
-	cfg->ta_sure = 2 * cfg->lpx;
+	cfg->ta_sure = cfg->lpx;
 	cfg->wakeup = 1000;
 
 	cfg->hs_clk_rate = hs_clk_rate;
Signature · 1 line
2.43.0
#35 lore raw

PATCH 16/26 phy: dphy: Correct clk_pre parameter

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Upstream linux commit 9a8406ba1a9a29.

The D-PHY specification (v1.2) explicitly mentions that the T-CLK-PRE parameter's unit is Unit Interval(UI) and the minimum value is 8. Also, kernel doc of the 'clk_pre' member of struct phy_configure_opts_mipi_dphy mentions that it should be in UI. However, the dphy core driver wrongly sets 'clk_pre' to 8000, which seems to hint that it's in picoseconds.

So, let's fix the dphy core driver to correctly reflect the T-CLK-PRE parameter's minimum value according to the D-PHY specification.

I'm assuming that all impacted custom drivers shall program values in TxByteClkHS cycles into hardware for the T-CLK-PRE parameter. The D-PHY specification mentions that the frequency of TxByteClkHS is exactly 1/8 the High-Speed(HS) bit rate(each HS bit consumes one UI). So, relevant custom driver code is changed to program those values as DIV_ROUND_UP(cfg->clk_pre, BITS_PER_BYTE), then.

Note that I've only tested the patch with RM67191 DSI panel on i.MX8mq EVK. Help is needed to test with other i.MX8mq, Meson and Rockchip platforms, as I don't have the hardwares.

---

 drivers/phy/meson-axg-mipi-dphy.c | 2 +-
 drivers/phy/phy-core-mipi-dphy.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/phy/meson-axg-mipi-dphy.c +1 -1
index 3f89de19970b..fb10ccca6ac1 100644
@@ -237,7 +237,7 @@ static int phy_meson_axg_mipi_dphy_power_on(struct phy *phy)
 		     (DIV_ROUND_UP(priv->config.clk_zero, temp) << 16) |
 		     (DIV_ROUND_UP(priv->config.clk_prepare, temp) << 24));
 	regmap_write(priv->regmap, MIPI_DSI_CLK_TIM1,
-		     DIV_ROUND_UP(priv->config.clk_pre, temp));
+		     DIV_ROUND_UP(priv->config.clk_pre, BITS_PER_BYTE));
 
 	regmap_write(priv->regmap, MIPI_DSI_HS_TIM,
 		     DIV_ROUND_UP(priv->config.hs_exit, temp) |
drivers/phy/phy-core-mipi-dphy.c +1 -1
index 79cab9125002..27cff85709d9 100644
@@ -36,7 +36,7 @@ static int phy_mipi_dphy_calc_config(unsigned long pixel_clock,
 
 	cfg->clk_miss = 0;
 	cfg->clk_post = 60000 + 52 * ui;
-	cfg->clk_pre = 8000;
+	cfg->clk_pre = 8;
 	cfg->clk_prepare = 38000;
 	cfg->clk_settle = 95000;
 	cfg->clk_term_en = 0;
Signature · 1 line
2.43.0
#36 lore raw

PATCH 17/26 lib: div64: sync with Linux

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Sync with Linux commit fc4a0db4149af ("Merge tag '6.5'").

---

 include/linux/math64.h | 110 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 110 insertions(+)
include/linux/math64.h +110 -0
index eaa9fd5b9685..82bd7472a32c 100644
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _LINUX_MATH64_H
 #define _LINUX_MATH64_H
 
@@ -12,6 +13,11 @@
 
 /**
  * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
+ * @dividend: unsigned 64bit dividend
+ * @divisor: unsigned 32bit divisor
+ * @remainder: pointer to unsigned 32bit remainder
+ *
+ * Return: sets ``*remainder``, then returns dividend / divisor
  *
  * This is commonly provided by 32bit archs to provide an optimized 64bit
  * divide.
@@ -24,6 +30,11 @@ static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
 
 /**
  * div_s64_rem - signed 64bit divide with 32bit divisor with remainder
+ * @dividend: signed 64bit dividend
+ * @divisor: signed 32bit divisor
+ * @remainder: pointer to signed 32bit remainder
+ *
+ * Return: sets ``*remainder``, then returns dividend / divisor
  */
 static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
 {
@@ -33,6 +44,11 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
 
 /**
  * div64_u64_rem - unsigned 64bit divide with 64bit divisor and remainder
+ * @dividend: unsigned 64bit dividend
+ * @divisor: unsigned 64bit divisor
+ * @remainder: pointer to unsigned 64bit remainder
+ *
+ * Return: sets ``*remainder``, then returns dividend / divisor
  */
 static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
 {
@@ -42,6 +58,10 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
 
 /**
  * div64_u64 - unsigned 64bit divide with 64bit divisor
+ * @dividend: unsigned 64bit dividend
+ * @divisor: unsigned 64bit divisor
+ *
+ * Return: dividend / divisor
  */
 static inline u64 div64_u64(u64 dividend, u64 divisor)
 {
@@ -53,6 +73,10 @@ static inline u64 div64_u64(u64 dividend, u64 divisor)
 
 /**
  * div64_s64 - signed 64bit divide with 64bit divisor
+ * @dividend: signed 64bit dividend
+ * @divisor: signed 64bit divisor
+ *
+ * Return: dividend / divisor
  */
 static inline s64 div64_s64(s64 dividend, s64 divisor)
 {
@@ -92,10 +116,14 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
 
 /**
  * div_u64 - unsigned 64bit divide with 32bit divisor
+ * @dividend: unsigned 64bit dividend
+ * @divisor: unsigned 32bit divisor
  *
  * This is the most common 64bit divide and should be used if possible,
  * as many 32bit archs can optimize this variant better than a full 64bit
  * divide.
+ *
+ * Return: dividend / divisor
  */
 #ifndef div_u64
 static inline u64 div_u64(u64 dividend, u32 divisor)
@@ -107,6 +135,10 @@ static inline u64 div_u64(u64 dividend, u32 divisor)
 
 /**
  * div_s64 - signed 64bit divide with 32bit divisor
+ * @dividend: signed 64bit dividend
+ * @divisor: signed 32bit divisor
+ *
+ * Return: dividend / divisor
  */
 #ifndef div_s64
 static inline s64 div_s64(s64 dividend, s32 divisor)
@@ -228,6 +260,24 @@ static inline u64 mul_u64_u64_shr(u64 a, u64 b, unsigned int shift)
 
 #endif
 
+#ifndef mul_s64_u64_shr
+static inline u64 mul_s64_u64_shr(s64 a, u64 b, unsigned int shift)
+{
+	u64 ret;
+
+	/*
+	 * Extract the sign before the multiplication and put it back
+	 * afterwards if needed.
+	 */
+	ret = mul_u64_u64_shr(abs(a), b, shift);
+
+	if (a < 0)
+		ret = -((s64)ret);
+
+	return ret;
+}
+#endif /* mul_s64_u64_shr */
+
 #ifndef mul_u64_u32_div
 static inline u64 mul_u64_u32_div(u64 a, u32 mul, u32 divisor)
 {
@@ -257,4 +307,64 @@ static inline u64 mul_u64_u32_div(u64 a, u32 mul, u32 divisor)
 }
 #endif /* mul_u64_u32_div */
 
+u64 mul_u64_u64_div_u64(u64 a, u64 mul, u64 div);
+
+/**
+ * DIV64_U64_ROUND_UP - unsigned 64bit divide with 64bit divisor rounded up
+ * @ll: unsigned 64bit dividend
+ * @d: unsigned 64bit divisor
+ *
+ * Divide unsigned 64bit dividend by unsigned 64bit divisor
+ * and round up.
+ *
+ * Return: dividend / divisor rounded up
+ */
+#define DIV64_U64_ROUND_UP(ll, d)	\
+	({ u64 _tmp = (d); div64_u64((ll) + _tmp - 1, _tmp); })
+
+/**
+ * DIV64_U64_ROUND_CLOSEST - unsigned 64bit divide with 64bit divisor rounded to nearest integer
+ * @dividend: unsigned 64bit dividend
+ * @divisor: unsigned 64bit divisor
+ *
+ * Divide unsigned 64bit dividend by unsigned 64bit divisor
+ * and round to closest integer.
+ *
+ * Return: dividend / divisor rounded to nearest integer
+ */
+#define DIV64_U64_ROUND_CLOSEST(dividend, divisor)	\
+	({ u64 _tmp = (divisor); div64_u64((dividend) + _tmp / 2, _tmp); })
+
+/**
+ * DIV_U64_ROUND_CLOSEST - unsigned 64bit divide with 32bit divisor rounded to nearest integer
+ * @dividend: unsigned 64bit dividend
+ * @divisor: unsigned 32bit divisor
+ *
+ * Divide unsigned 64bit dividend by unsigned 32bit divisor
+ * and round to closest integer.
+ *
+ * Return: dividend / divisor rounded to nearest integer
+ */
+#define DIV_U64_ROUND_CLOSEST(dividend, divisor)	\
+	({ u32 _tmp = (divisor); div_u64((u64)(dividend) + _tmp / 2, _tmp); })
+
+/**
+ * DIV_S64_ROUND_CLOSEST - signed 64bit divide with 32bit divisor rounded to nearest integer
+ * @dividend: signed 64bit dividend
+ * @divisor: signed 32bit divisor
+ *
+ * Divide signed 64bit dividend by signed 32bit divisor
+ * and round to closest integer.
+ *
+ * Return: dividend / divisor rounded to nearest integer
+ */
+#define DIV_S64_ROUND_CLOSEST(dividend, divisor)(	\
+{							\
+	s64 __x = (dividend);				\
+	s32 __d = (divisor);				\
+	((__x > 0) == (__d > 0)) ?			\
+		div_s64((__x + (__d / 2)), __d) :	\
+		div_s64((__x - (__d / 2)), __d);	\
+}							\
+)
 #endif /* _LINUX_MATH64_H */
Signature · 1 line
2.43.0
#37 lore raw

PATCH 18/26 video: bridge: Add Samsung DSIM bridge

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

Samsung MIPI DSIM controller is common DSI IP that can be used in various SoCs like Exynos, i.MX8M Mini/Nano.

In order to access this DSI controller between various platform SoCs, the ideal way to incorporate this in the as a bridge that can support all different platform.

---

 drivers/video/bridge/Kconfig            |   13 +
 drivers/video/bridge/Makefile           |    1 +
 drivers/video/bridge/samsung-dsi-host.c | 1567 +++++++++++++++++++++++
 drivers/video/bridge/samsung-dsim.c     |  148 +++
 drivers/video/bridge/samsung-dsim.h     |   20 +
 5 files changed, 1749 insertions(+)
 create mode 100644 drivers/video/bridge/samsung-dsi-host.c
 create mode 100644 drivers/video/bridge/samsung-dsim.c
 create mode 100644 drivers/video/bridge/samsung-dsim.h
drivers/video/bridge/Kconfig +13 -0
index ab9172737201..5cb1e7af9935 100644
@@ -44,6 +44,19 @@ config VIDEO_BRIDGE_ANALOGIX_ANX6345
 	 The Analogix ANX6345 is RGB-to-DP converter. It enables an eDP LCD
 	 panel to be connected to an parallel LCD interface.
 
+config VIDEO_BRIDGE_SAMSUNG_DSIM
+	bool "Enable IMX SEC DSI video support"
+	select MIPI_DPHY_HELPERS
+	select VIDEO_BRIDGE
+	select VIDEO_LINK
+	select VIDEO_MIPI_DSI
+	help
+	  Enables the common driver code for the Samsung
+	  MIPI DSI block found in SoCs from various vendors.
+	  As this does not provide any functionality by itself (but
+	  rather requires a SoC-specific glue driver to call it), it
+	  can not be enabled from the configuration menu.
+
 config VIDEO_BRIDGE_SOLOMON_SSD2825
 	bool "Solomon SSD2825 bridge driver"
 	depends on PANEL && DM_GPIO
drivers/video/bridge/Makefile +1 -0
index 58697e3cbe90..8f49013299ae 100644
@@ -8,5 +8,6 @@ obj-$(CONFIG_VIDEO_BRIDGE_PARADE_DP501) += dp501.o
 obj-$(CONFIG_VIDEO_BRIDGE_PARADE_PS862X) += ps862x.o
 obj-$(CONFIG_VIDEO_BRIDGE_NXP_PTN3460) += ptn3460.o
 obj-$(CONFIG_VIDEO_BRIDGE_ANALOGIX_ANX6345) += anx6345.o
+obj-$(CONFIG_VIDEO_BRIDGE_SAMSUNG_DSIM) += samsung-dsim.o samsung-dsi-host.o
 obj-$(CONFIG_VIDEO_BRIDGE_SOLOMON_SSD2825) += ssd2825.o
 obj-$(CONFIG_VIDEO_BRIDGE_TOSHIBA_TC358768) += tc358768.o
drivers/video/bridge/samsung-dsi-host.c new file +1567 -0

1,567 lines not on this page · raw message

drivers/video/bridge/samsung-dsim.c new file +148 -0

148 lines not on this page · raw message

drivers/video/bridge/samsung-dsim.h new file +20 -0
new file mode 100644
index 000000000000..9bb2a379589b
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Amarula Solutions
+ */
+
+#ifndef SAMSUNG_DSIM_H
+#define SAMSUNG_DSIM_H
+
+enum samsung_dsim_type {
+	DSIM_TYPE_EXYNOS3250,
+	DSIM_TYPE_EXYNOS4210,
+	DSIM_TYPE_EXYNOS5410,
+	DSIM_TYPE_EXYNOS5422,
+	DSIM_TYPE_EXYNOS5433,
+	DSIM_TYPE_IMX8MM,
+	DSIM_TYPE_IMX8MP,
+	DSIM_TYPE_COUNT,
+};
+
+#endif
Signature · 1 line
2.43.0
#38 lore raw

PATCH 19/26 video: Add Synaptics R63353 panel driver

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

The LS068B3SX02 panel is based on the Synaptics R63353 Controller. Add a driver for it.

---

 drivers/video/Kconfig            |   8 ++
 drivers/video/Makefile           |   1 +
 drivers/video/synaptics-r63353.c | 228 +++++++++++++++++++++++++++++++
 3 files changed, 237 insertions(+)
 create mode 100644 drivers/video/synaptics-r63353.c
drivers/video/Kconfig +8 -0
index cafdc15f9fe2..520577976571 100644
@@ -627,6 +627,14 @@ config VIDEO_LCD_SSD2828_RESET
 	The reset pin of SSD2828 chip. This takes a string in the format
 	understood by 'sunxi_name_to_gpio' function, e.g. PH1 for pin 1 of port H.
 
+config VIDEO_LCD_SYNAPTICS_R63353
+	tristate "Synaptics R63353-based DSI LCD panels support"
+	select VIDEO_MIPI_DSI
+	default n
+	help
+	  Say Y if you want to enable support for panels based on the
+	  Synaptics R63353 controller.
+
 config VIDEO_LCD_TDO_TL070WSH30
 	bool "TDO TL070WSH30 DSI LCD panel support"
 	select VIDEO_MIPI_DSI
drivers/video/Makefile +1 -0
index 9fd3645994f1..4d836efcfa41 100644
@@ -66,6 +66,7 @@ obj-$(CONFIG_VIDEO_LCD_RENESAS_R61307) += renesas-r61307.o
 obj-$(CONFIG_VIDEO_LCD_RENESAS_R69328) += renesas-r69328.o
 obj-$(CONFIG_VIDEO_LCD_SAMSUNG_LTL106HL02) += samsung-ltl106hl02.o
 obj-$(CONFIG_VIDEO_LCD_SSD2828) += ssd2828.o
+obj-$(CONFIG_VIDEO_LCD_SYNAPTICS_R63353) += synaptics-r63353.o
 obj-$(CONFIG_VIDEO_LCD_TDO_TL070WSH30) += tdo-tl070wsh30.o
 obj-$(CONFIG_VIDEO_MCDE_SIMPLE) += mcde_simple.o
 obj-${CONFIG_VIDEO_MESON} += meson/
drivers/video/synaptics-r63353.c new file +228 -0

228 lines not on this page · raw message

Signature · 1 line
2.43.0
#39 lore raw

PATCH 20/26 imx8mn_bsh_smm_s2/pro: Enable display on reference design

In reply to Dario Binacchi

From: Michael Trimarchi <[email protected]>

---

 .../dts/imx8mn-bsh-smm-s2-u-boot-common.dtsi  | 23 +++++++++++++++++++
 configs/imx8mn_bsh_smm_s2_defconfig           | 15 ++++++++++++
 configs/imx8mn_bsh_smm_s2pro_defconfig        | 15 ++++++++++++
 3 files changed, 53 insertions(+)
arch/arm/dts/imx8mn-bsh-smm-s2-u-boot-common.dtsi +23 -0
index 19b0d8977539..8cae580e2851 100644
@@ -6,6 +6,19 @@
 
 #include "imx8mn-u-boot.dtsi"
 
+/ {
+	aliases {
+		display0 = &lcdif;
+	};
+
+	samsung_dsi_host: dsi-host {
+		compatible = "samsung,sec-mipi-dsi";
+		clocks = <&clk IMX8MN_CLK_DSI_PHY_REF>;
+		clock-names = "sclk_mipi";
+		status = "okay";
+	};
+};
+
 &{/soc@0/bus@30800000/i2c@30a20000/pmic@4b} {
 	bootph-pre-ram;
 };
@@ -30,6 +43,16 @@
 	bootph-pre-ram;
 };
 
+&lcdif {
+	display = <&display0>;
+
+	/* panel is r8g8b8 */
+	display0: display@0 {
+		bits-per-pixel = <24>;
+		bits-per-color = <8>;
+	};
+};
+
 &pinctrl_i2c1 {
 	bootph-pre-ram;
 };
configs/imx8mn_bsh_smm_s2_defconfig +15 -0
index b4351a392eff..2fa8bc22747e 100644
@@ -56,6 +56,7 @@ CONFIG_SYS_PROMPT="> "
 CONFIG_CMD_FUSE=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_CMD_BMP=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nand0=gpmi-nand"
 CONFIG_MTDPARTS_DEFAULT="gpmi-nand:64m(nandboot),16m(nandfit),32m(nandkernel),1m(nanddtb),8m(nandtee),-(nandrootfs)"
@@ -74,6 +75,8 @@ CONFIG_FASTBOOT_BUF_ADDR=0x40480000
 CONFIG_FASTBOOT_BUF_SIZE=0x20000000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_UUU_SUPPORT=y
+CONFIG_DM_GPIO_LOOKUP_LABEL=y
+CONFIG_SPL_DM_GPIO_LOOKUP_LABEL=y
 CONFIG_MXC_GPIO=y
 CONFIG_DM_I2C=y
 # CONFIG_MMC is not set
@@ -94,12 +97,17 @@ CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_IMX8M_POWER_DOMAIN=y
+CONFIG_IMX8M_BLK_CTRL=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_BD71837=y
 CONFIG_SPL_DM_PMIC_BD71837=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_PWM=y
+CONFIG_PWM_IMX=y
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
@@ -112,5 +120,12 @@ CONFIG_USB_GADGET_MANUFACTURER="FSL"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
+CONFIG_VIDEO=y
+CONFIG_VIDEO_LCD_SYNAPTICS_R63353=y
+CONFIG_VIDEO_BRIDGE_SAMSUNG_DSIM=y
+CONFIG_VIDEO_MXS=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
 CONFIG_IMX_WATCHDOG=y
 # CONFIG_FAT_WRITE is not set
configs/imx8mn_bsh_smm_s2pro_defconfig +15 -0
index 0faa3376fd3d..b6b62b9d53f9 100644
@@ -53,6 +53,7 @@ CONFIG_CMD_FUSE=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_USB=y
 CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_CMD_BMP=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
@@ -68,6 +69,8 @@ CONFIG_FASTBOOT_BUF_SIZE=0x20000000
 CONFIG_FASTBOOT_FLASH=y
 CONFIG_FASTBOOT_UUU_SUPPORT=y
 CONFIG_FASTBOOT_FLASH_MMC_DEV=0
+CONFIG_DM_GPIO_LOOKUP_LABEL=y
+CONFIG_SPL_DM_GPIO_LOOKUP_LABEL=y
 CONFIG_MXC_GPIO=y
 CONFIG_DM_I2C=y
 CONFIG_SUPPORT_EMMC_BOOT=y
@@ -83,12 +86,17 @@ CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_IMX8M_POWER_DOMAIN=y
+CONFIG_IMX8M_BLK_CTRL=y
 CONFIG_DM_PMIC=y
 CONFIG_DM_PMIC_BD71837=y
 CONFIG_SPL_DM_PMIC_BD71837=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_PWM=y
+CONFIG_PWM_IMX=y
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
@@ -101,5 +109,12 @@ CONFIG_USB_GADGET_MANUFACTURER="FSL"
 CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
+CONFIG_VIDEO=y
+CONFIG_VIDEO_LCD_SYNAPTICS_R63353=y
+CONFIG_VIDEO_BRIDGE_SAMSUNG_DSIM=y
+CONFIG_VIDEO_MXS=y
+CONFIG_BMP_16BPP=y
+CONFIG_BMP_24BPP=y
+CONFIG_BMP_32BPP=y
 CONFIG_IMX_WATCHDOG=y
 # CONFIG_FAT_WRITE is not set
Signature · 1 line
2.43.0
#40 lore raw

PATCH 21/26 boot: fdt_simplefb: add a debug message

In reply to Dario Binacchi

The printed information is useful when adding support for the simple frame buffer to a board.

---

 boot/fdt_simplefb.c | 2 ++
 1 file changed, 2 insertions(+)
boot/fdt_simplefb.c +2 -0
index 53415548459a..22aaad9d5c5b 100644
@@ -61,6 +61,8 @@ static int fdt_simplefb_configure_node(void *blob, int off)
 		return -EINVAL;
 	}
 
+	debug("Simple frame buffer at 0x%lx, pixels %dx%d, format %s\n",
+	      fb_base, xsize, ysize, name);
 	return fdt_setup_simplefb_node(blob, off, fb_base, xsize, ysize,
 				       xsize * (1 << bpix) / 8, name);
 }
Signature · 1 line
2.43.0
#41 lore raw

PATCH 22/26 video: mxsfb: support simple frame-buffer

In reply to Dario Binacchi

If you want to pass the frame-buffer to the kernel, the video output is initialized by U-Boot, and kept by the kernel. The patch does not turn off the power domains or reset the peripheral if you want to support such feature.

---

 drivers/video/mxsfb.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/video/mxsfb.c +6 -1
index 45431f0a1047..06b2a2461246 100644
@@ -422,7 +422,8 @@ static int mxs_video_remove(struct udevice *dev)
 	if (priv->disp_dev)
 		device_remove(priv->disp_dev, DM_REMOVE_NORMAL);
 
-	mxs_remove_common(priv->reg_base, plat->base);
+	if (!IS_ENABLED(CONFIG_VIDEO_DT_SIMPLEFB))
+		mxs_remove_common(priv->reg_base, plat->base);
 
 	return 0;
 }
@@ -445,6 +446,10 @@ U_BOOT_DRIVER(mxs_video) = {
 	.bind	= mxs_video_bind,
 	.probe	= mxs_video_probe,
 	.remove = mxs_video_remove,
+#if !IS_ENABLED(CONFIG_VIDEO_DT_SIMPLEFB)
 	.flags	= DM_FLAG_PRE_RELOC | DM_FLAG_OS_PREPARE,
+#else
+	.flags	= DM_FLAG_PRE_RELOC | DM_FLAG_OS_PREPARE | DM_FLAG_LEAVE_PD_ON,
+#endif
 	.priv_auto   = sizeof(struct mxsfb_priv),
 };
Signature · 1 line
2.43.0
#42 lore raw

PATCH 23/26 video: bridge: samsung: support simple frame-buffer

In reply to Dario Binacchi

If you want to pass the frame-buffer to the kernel, the video output is initialized by U-Boot, and kept by the kernel. The patch does not turn off the power domains or disable the peripheral if you want to support such feature.

---

 drivers/video/bridge/samsung-dsi-host.c | 9 +++++++++
 drivers/video/bridge/samsung-dsim.c     | 3 +++
 2 files changed, 12 insertions(+)
drivers/video/bridge/samsung-dsi-host.c +9 -0
index dd3e33c4edc7..2d0e8f71a756 100644
@@ -1281,6 +1281,7 @@ static void samsung_dsi_set_standby(struct samsung_dsi *dsim, bool standby)
 	samsung_dsim_write(dsim, DSIM_MDRESOL_REG, mdresol);
 }
 
+#if (!IS_ENABLED(CONFIG_VIDEO_DT_SIMPLEFB))
 static void samsung_dsi_disable_clock(struct samsung_dsi *dsim)
 {
 	u32 reg;
@@ -1294,6 +1295,7 @@ static void samsung_dsi_disable_clock(struct samsung_dsi *dsim)
 	reg &= ~DSIM_PLL_EN;
 	samsung_dsim_write(dsim, DSIM_PLLCTRL_REG, reg);
 }
+#endif
 
 static inline struct samsung_dsi *host_to_dsi(struct mipi_dsi_host *host)
 {
@@ -1515,6 +1517,12 @@ static int samsung_dsi_enable(struct udevice *dev)
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_VIDEO_DT_SIMPLEFB)
+static int samsung_dsi_disable(struct udevice *dev)
+{
+	return 0;
+}
+#else
 static int samsung_dsi_disable(struct udevice *dev)
 {
 	u32 intsrc;
@@ -1532,6 +1540,7 @@ static int samsung_dsi_disable(struct udevice *dev)
 
 	return 0;
 }
+#endif
 
 struct dsi_host_ops samsung_dsi_ops = {
 	.init = samsung_dsi_init,
drivers/video/bridge/samsung-dsim.c +3 -0
index 986f1d830844..36e45abb3009 100644
@@ -144,5 +144,8 @@ U_BOOT_DRIVER(samsung_dsim) = {
 	.remove				= samsung_dsim_remove,
 	.probe				= samsung_dsim_probe,
 	.ops				= &samsung_dsim_ops,
+#if IS_ENABLED(CONFIG_VIDEO_DT_SIMPLEFB)
+	.flags				= DM_FLAG_LEAVE_PD_ON,
+#endif
 	.priv_auto		= sizeof(struct samsung_dsim_priv),
 };
Signature · 1 line
2.43.0
#43 lore raw

PATCH 24/26 imx8mn_bsh_smm_s2/pro: support simple frame-buffer

In reply to Dario Binacchi

If you want to pass the frame-buffer to the kernel, the video output is initialized by U-Boot, and kept by the kernel. The commit modifies the device tree to be passed to the kernel just before launching it, to prevent the kernel from reinitializing hardware that has already been configured by the bootloader.

---

 board/bsh/imx8mn_smm_s2/imx8mn_smm_s2.c | 99 +++++++++++++++++++++++++
 1 file changed, 99 insertions(+)
board/bsh/imx8mn_smm_s2/imx8mn_smm_s2.c +99 -0
index c99896873991..87eb4e7ed63e 100644
@@ -5,6 +5,8 @@
 
 #include <asm/arch/sys_proto.h>
 #include <env.h>
+#include <fdt_simplefb.h>
+#include <fdt_support.h>
 
 int board_init(void)
 {
@@ -20,3 +22,100 @@ int board_late_init(void)
 
 	return 0;
 }
+
+#if (IS_ENABLED(CONFIG_OF_LIBFDT) && IS_ENABLED(CONFIG_FDT_SIMPLEFB) && \
+	IS_ENABLED(CONFIG_VIDEO))
+static void smm_s2_setup_simplefb(void *blob)
+{
+#define DT_BLK_CTRL_NODE_PATH "/soc@0/bus@32c00000/blk-ctrl@32e28000"
+#define DT_GPC_NODE_PATH "/soc@0/bus@30000000/gpc@303a0000"
+#define DT_MIPI_DSI_NODE_PATH "/soc@0/bus@32c00000/dsi@32e10000"
+#define DT_LCDIF_NODE_PATH "/soc@0/bus@32c00000/lcdif@32e00000"
+
+	const char *dt_addnode[][2] = {
+		{ DT_BLK_CTRL_NODE_PATH, "lcdif" },
+		{ DT_BLK_CTRL_NODE_PATH, "mipi-dsi" },
+	};
+
+	const char *dt_addprop[][2] = {
+		{ "/regulator-3v3-O2", "regulator-boot-on" },
+		{ "/regulator-3v3-O3", "regulator-boot-on" },
+		{ DT_GPC_NODE_PATH "/pgc/power-domain@3", "fsl,boot-on" },
+		{ DT_GPC_NODE_PATH "/pgc/power-domain@4", "fsl,boot-on" },
+		{ DT_BLK_CTRL_NODE_PATH "/lcdif", "fsl,boot-on" },
+		{ DT_BLK_CTRL_NODE_PATH "/mipi-dsi", "fsl,boot-on" },
+		{ DT_MIPI_DSI_NODE_PATH, "samsung,boot-on" },
+		{ DT_MIPI_DSI_NODE_PATH "/panel@0", "syna,boot-on" },
+		{ DT_LCDIF_NODE_PATH, "fsl,boot-on" },
+	};
+	const char *dt_delprop[][2] = {
+		{ DT_BLK_CTRL_NODE_PATH, "assigned-clock-rates" },
+		{ DT_GPC_NODE_PATH "/pgc/power-domain@3", "assigned-clock-rates" }, // pgc_dispmix
+		{ DT_LCDIF_NODE_PATH, "assigned-clock-rates" },
+	};
+	int i, ret, offset;
+
+	ret = fdt_simplefb_enable_and_mem_rsv(blob);
+	if (ret) {
+		printf("Failed to enable framebuffer DTS node\n");
+		return;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(dt_addnode); i++) {
+		const char *path = dt_addnode[i][0];
+		const char *node = dt_addnode[i][1];
+
+		offset = fdt_path_offset(blob, path);
+		if (offset < 0) {
+			printf("Missing node %s, err=%s\n", path,
+			       fdt_strerror(offset));
+			continue;
+		}
+
+		offset = fdt_find_or_add_subnode(blob, offset, node);
+		if (offset < 0)
+			printf("Failed to create node %s, err=%s\n", path,
+			       fdt_strerror(offset));
+		else
+			debug("Add node %s:%s\n", path, node);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(dt_addprop); i++) {
+		const char *path = dt_addprop[i][0];
+		const char *prop = dt_addprop[i][1];
+
+		ret = fdt_find_and_setprop(blob, path, prop, NULL, 0, 1);
+		if (ret < 0)
+			printf("Failed to add property %s:%s, err=%s\n", path, prop,
+			       fdt_strerror(ret));
+		else
+			debug("Add property %s:%s\n", path, prop);
+	}
+
+	for (i = 0; i < ARRAY_SIZE(dt_delprop); i++) {
+		const char *path = dt_delprop[i][0];
+		const char *prop = dt_delprop[i][1];
+
+		offset = fdt_path_offset(blob, path);
+		if (offset < 0) {
+			printf("Missing node %s\n", path);
+			continue;
+		}
+
+		ret = fdt_delprop(blob, offset, prop);
+		if (ret < 0)
+			printf("Failed to delete property %s:%s\n", path, prop);
+		else
+			debug("Delete property %s:%s\n", path, prop);
+	}
+}
+#endif
+
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+	if (IS_ENABLED(CONFIG_OF_LIBFDT) && IS_ENABLED(CONFIG_FDT_SIMPLEFB) &&
+	    IS_ENABLED(CONFIG_VIDEO))
+		smm_s2_setup_simplefb(blob);
+
+	return 0;
+}
Signature · 1 line
2.43.0
#44 lore raw

PATCH 25/26 imx8mn_bsh_smm_s2/pro: enable simple frame-buffer

In reply to Dario Binacchi

---

 configs/imx8mn_bsh_smm_s2_defconfig    | 3 +++
 configs/imx8mn_bsh_smm_s2pro_defconfig | 3 +++
 2 files changed, 6 insertions(+)
configs/imx8mn_bsh_smm_s2_defconfig +3 -0
index 2fa8bc22747e..4982b58407c6 100644
@@ -28,7 +28,9 @@ CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SYS_BOOTM_LEN=0x2000000
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_FDT_SIMPLEFB=y
 CONFIG_DEFAULT_FDT_FILE="freescale/imx8mn-bsh-smm-s2.dtb"
 CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=2067
@@ -124,6 +126,7 @@ CONFIG_VIDEO=y
 CONFIG_VIDEO_LCD_SYNAPTICS_R63353=y
 CONFIG_VIDEO_BRIDGE_SAMSUNG_DSIM=y
 CONFIG_VIDEO_MXS=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
 CONFIG_BMP_16BPP=y
 CONFIG_BMP_24BPP=y
 CONFIG_BMP_32BPP=y
configs/imx8mn_bsh_smm_s2pro_defconfig +3 -0
index b6b62b9d53f9..7ae99adf7fad 100644
@@ -29,7 +29,9 @@ CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SYS_BOOTM_LEN=0x2000000
 CONFIG_DISTRO_DEFAULTS=y
+CONFIG_OF_BOARD_SETUP=y
 CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_FDT_SIMPLEFB=y
 CONFIG_DEFAULT_FDT_FILE="freescale/imx8mn-bsh-smm-s2pro.dtb"
 CONFIG_SYS_CBSIZE=2048
 CONFIG_SYS_PBSIZE=2067
@@ -113,6 +115,7 @@ CONFIG_VIDEO=y
 CONFIG_VIDEO_LCD_SYNAPTICS_R63353=y
 CONFIG_VIDEO_BRIDGE_SAMSUNG_DSIM=y
 CONFIG_VIDEO_MXS=y
+CONFIG_VIDEO_DT_SIMPLEFB=y
 CONFIG_BMP_16BPP=y
 CONFIG_BMP_24BPP=y
 CONFIG_BMP_32BPP=y
Signature · 1 line
2.43.0
#45 lore raw

PATCH 26/26 imx8mn_bsh_smm_s2/pro: add splash screen with BSH logo

In reply to Dario Binacchi

Display the BSH logo with features VIDEO_LOGO and SPLASH_SCREEN on imx8mn_bsh_smm_s2/pro boards.

With CONFIG_SYS_VENDOR = "bsh", the logo bsh.bmp is selected, loaded at the address indicated by splashimage and centered with "splashpos=m,m".

---

 configs/imx8mn_bsh_smm_s2_defconfig        |   3 +++
 configs/imx8mn_bsh_smm_s2pro_defconfig     |   3 +++
 include/configs/imx8mn_bsh_smm_s2.h        |   1 +
 include/configs/imx8mn_bsh_smm_s2_common.h |   4 ++++
 include/configs/imx8mn_bsh_smm_s2pro.h     |   1 +
 tools/logos/bsh.bmp                        | Bin 0 -> 10644 bytes
 6 files changed, 12 insertions(+)
 create mode 100644 tools/logos/bsh.bmp
configs/imx8mn_bsh_smm_s2_defconfig +3 -0
index 4982b58407c6..b3190945c59c 100644
@@ -123,10 +123,13 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
 CONFIG_VIDEO=y
+CONFIG_VIDEO_LOGO=y
 CONFIG_VIDEO_LCD_SYNAPTICS_R63353=y
 CONFIG_VIDEO_BRIDGE_SAMSUNG_DSIM=y
 CONFIG_VIDEO_MXS=y
 CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
 CONFIG_BMP_16BPP=y
 CONFIG_BMP_24BPP=y
 CONFIG_BMP_32BPP=y
configs/imx8mn_bsh_smm_s2pro_defconfig +3 -0
index 7ae99adf7fad..db83a326c053 100644
@@ -112,10 +112,13 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x0525
 CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
 CONFIG_CI_UDC=y
 CONFIG_VIDEO=y
+CONFIG_VIDEO_LOGO=y
 CONFIG_VIDEO_LCD_SYNAPTICS_R63353=y
 CONFIG_VIDEO_BRIDGE_SAMSUNG_DSIM=y
 CONFIG_VIDEO_MXS=y
 CONFIG_VIDEO_DT_SIMPLEFB=y
+CONFIG_SPLASH_SCREEN=y
+CONFIG_SPLASH_SCREEN_ALIGN=y
 CONFIG_BMP_16BPP=y
 CONFIG_BMP_24BPP=y
 CONFIG_BMP_32BPP=y
include/configs/imx8mn_bsh_smm_s2.h +1 -0
index deeed9c2f582..c8bd55fd3744 100644
@@ -38,6 +38,7 @@
 #define CFG_EXTRA_ENV_SETTINGS \
 	MEM_LAYOUT_ENV_SETTINGS \
 	NANDARGS \
+	SPLASH_ENV_SETTINGS \
 	BOOTENV
 
 #define PHYS_SDRAM_SIZE			SZ_256M
include/configs/imx8mn_bsh_smm_s2_common.h +4 -0
index 204fc4b31647..5d6b22e04139 100644
@@ -21,6 +21,10 @@
 	"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
 	"bootcmd_mfg=echo Running fastboot mode; fastboot usb 0\0" \
 
+#define SPLASH_ENV_SETTINGS \
+	"splashimage=0x5bb00000\0" \
+	"splashpos=m,m\0" \
+
 /* Link Definitions */
 
 #define CFG_SYS_INIT_RAM_ADDR	0x40000000
include/configs/imx8mn_bsh_smm_s2pro.h +1 -0
index 8619fdde7fdb..dd26e0b885d2 100644
@@ -25,6 +25,7 @@
 #define CFG_EXTRA_ENV_SETTINGS \
 	MEM_LAYOUT_ENV_SETTINGS \
 	EMMCARGS \
+	SPLASH_ENV_SETTINGS \
 	BOOTENV
 
 #define PHYS_SDRAM_SIZE			SZ_512M
tools/logos/bsh.bmp new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..5b6fb1ebd50d70c7f5ce4a51042271e9634d8d81
GIT binary patch
Signature · 1 line
2.43.0
#46 lore raw
In reply to Dario Binacchi

Hi Dario,

[email protected] wrote on Fri, 13 Sep 2024 11:55:42 +0200:

Quoted 9 lines

This series was created out of the need to supportsimple-framebuffer for BSH boards SMM_S2 and SMM_S2PRO. To achieve this goal, it was necessary to develop additional code and/or drivers for all the required components (i. e. clock, power domain, video, etc.). This series has a Linux counterpart that will also be submitted upstream as soon as possible. Furthermore, given the overlap in topics with the recent series [1], we are open to collaborate on the common parts to ensure proper development.

[1] https://lore.kernel.org/all/[email protected]/T/#mb7cd440abc6fcc0de205f577eb3225e1c1c76823

I received a bit of feedback on this U-Boot series, I can take the feedback into account and send a v2. Then, if you are still okay, you can stack your patches on top of mine and do the required adaptations (on both sides).

Thanks,
Miquèl

#47 lore raw

Hi Miquel,

Quoted 14 lines · Miquel Raynal

Hi Dario,

[email protected] wrote on Fri, 13 Sep 2024 11:55:42 +0200:

Quoted 8 lines

This series was created out of the need to supportsimple-framebuffer for BSH boards SMM_S2 and SMM_S2PRO. To achieve this goal, it was necessary to develop additional code and/or drivers for all the required components (i. e. clock, power domain, video, etc.). This series has a Linux counterpart that will also be submitted upstream as soon as possible. Furthermore, given the overlap in topics with the recent series [1], we are open to collaborate on the common parts to ensure proper development.

Quoted 6 lines
Quoted 1 line

[1] https://lore.kernel.org/all/[email protected]/T/#mb7cd440abc6fcc0de205f577eb3225e1c1c76823

I received a bit of feedback on this U-Boot series, I can take the feedback into account and send a v2. Then, if you are still okay, you can stack your patches on top of mine and do the required adaptations (on both sides).

Sure, go ahead with version 2.

Thanks and regards,
Dario

Quoted 3 lines

Thanks,
Miquèl

Signature · 17 lines
Dario Binacchi

Senior Embedded Linux Developer

[email protected]

__________________________________


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
[email protected]

www.amarulasolutions.com