linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks
@ 2023-03-21  2:31 Adam Ford
  2023-03-21  2:31 ` [PATCH V2 1/4] clk: imx: composite-8m: Add support to determine_rate Adam Ford
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Adam Ford @ 2023-03-21  2:31 UTC (permalink / raw)
  To: linux-clk
  Cc: aford, Adam Ford, Abel Vesa, Peng Fan, Michael Turquette,
	Stephen Boyd, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, linux-arm-kernel, linux-kernel

Both the i.MX8M Mini and Nano have a video_pll which can be used 
to source a clock which feeds the lcdif interface.  This interface
currently fixes video_pll and divides down the clock feeding LCDIF.
However, when connected to an HDMI bridge chip that supports a
variety of video resolutions and refresh rates, the only settings
that properly sync are ones that evenly divide from the video_pll_out
clock.

This series adds the ability for the clk-compolsite-8m to
request a better parent clock rate if the proper clock flag is
enable and sets that flag in the corresponding imx8mm and 
imx8mn video_pll clocks to increase the number of resolutions
and refresh rates timings that the LCDIF can produce.

This also has a side benefit of allowing the video-pll to run
at a lower clock speed which can potentially save some power
depending on the requested resolution and refresh rate.

V2:  Split off the new imx8m_clk_hw_composite_flags definition
     into its own patch and re-order to fix build error.
      
Adam Ford (3):
  clk: imx: composite-8m: Add support to determine_rate
  clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate
  clk: imx: Let IMX8MN_CLK_DISP_PIXEL set parent rate

 drivers/clk/imx/clk-composite-8m.c | 7 +++++++
 drivers/clk/imx/clk-imx8mm.c       | 2 +-
 drivers/clk/imx/clk-imx8mn.c       | 2 +-
 drivers/clk/imx/clk.h              | 4 ++++
 4 files changed, 13 insertions(+), 2 deletions(-)

-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH V2 1/4] clk: imx: composite-8m: Add support to determine_rate
  2023-03-21  2:31 [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Adam Ford
@ 2023-03-21  2:31 ` Adam Ford
  2023-03-21  2:31 ` [PATCH V2 2/4] clk: imx: Add imx8m_clk_hw_composite_flags macro Adam Ford
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Adam Ford @ 2023-03-21  2:31 UTC (permalink / raw)
  To: linux-clk
  Cc: aford, Adam Ford, Abel Vesa, Peng Fan, Michael Turquette,
	Stephen Boyd, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, linux-arm-kernel, linux-kernel

Similar to imx/clk-composite-93 and imx/clk-divider-gate, the
imx8m_clk_composite_divider_ops can support determine_rate.
Without this the parent clocks are set to a fixed value, and
if a consumer needs a slower reate, the clock is divided, but
the division is only as good as the parent clock rate.

With this added, the system can attempt to adjust the parent rate
if the proper flags are set which can lead to a more precise clock
value.

Signed-off-by: Adam Ford <aford173@gmail.com>
---
V2:  No Change

diff --git a/drivers/clk/imx/clk-composite-8m.c b/drivers/clk/imx/clk-composite-8m.c
index cbf0d7955a00..3b63e47f088f 100644
--- a/drivers/clk/imx/clk-composite-8m.c
+++ b/drivers/clk/imx/clk-composite-8m.c
@@ -119,10 +119,17 @@ static int imx8m_clk_composite_divider_set_rate(struct clk_hw *hw,
 	return ret;
 }
 
+static int clk_divider_determine_rate(struct clk_hw *hw,
+				      struct clk_rate_request *req)
+{
+	return clk_divider_ops.determine_rate(hw, req);
+}
+
 static const struct clk_ops imx8m_clk_composite_divider_ops = {
 	.recalc_rate = imx8m_clk_composite_divider_recalc_rate,
 	.round_rate = imx8m_clk_composite_divider_round_rate,
 	.set_rate = imx8m_clk_composite_divider_set_rate,
+	.determine_rate = clk_divider_determine_rate,
 };
 
 static u8 imx8m_clk_composite_mux_get_parent(struct clk_hw *hw)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 2/4] clk: imx: Add imx8m_clk_hw_composite_flags macro
  2023-03-21  2:31 [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Adam Ford
  2023-03-21  2:31 ` [PATCH V2 1/4] clk: imx: composite-8m: Add support to determine_rate Adam Ford
@ 2023-03-21  2:31 ` Adam Ford
  2023-03-21  2:31 ` [PATCH V2 3/4] clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate Adam Ford
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Adam Ford @ 2023-03-21  2:31 UTC (permalink / raw)
  To: linux-clk
  Cc: aford, Adam Ford, Abel Vesa, Peng Fan, Michael Turquette,
	Stephen Boyd, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, linux-arm-kernel, linux-kernel

In order to set custom flags to imx8m_clk_hw_composite,
split it off into a separate macro which can accept additional
flags.

Signed-off-by: Adam Ford <aford173@gmail.com>
---
V2:  Split into its own patch and re-order to fix build error

diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h
index 3d94722bbf99..621b0e84ef27 100644
--- a/drivers/clk/imx/clk.h
+++ b/drivers/clk/imx/clk.h
@@ -417,6 +417,10 @@ struct clk_hw *__imx8m_clk_hw_composite(const char *name,
 	_imx8m_clk_hw_composite(name, parent_names, reg, \
 			0, IMX_COMPOSITE_CLK_FLAGS_DEFAULT)
 
+#define imx8m_clk_hw_composite_flags(name, parent_names, reg, flags) \
+	_imx8m_clk_hw_composite(name, parent_names, reg, \
+			0, IMX_COMPOSITE_CLK_FLAGS_DEFAULT |  flags)
+
 #define imx8m_clk_hw_composite_critical(name, parent_names, reg) \
 	_imx8m_clk_hw_composite(name, parent_names, reg, \
 			0, IMX_COMPOSITE_CLK_FLAGS_CRITICAL)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 3/4] clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate
  2023-03-21  2:31 [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Adam Ford
  2023-03-21  2:31 ` [PATCH V2 1/4] clk: imx: composite-8m: Add support to determine_rate Adam Ford
  2023-03-21  2:31 ` [PATCH V2 2/4] clk: imx: Add imx8m_clk_hw_composite_flags macro Adam Ford
@ 2023-03-21  2:31 ` Adam Ford
  2023-03-21  2:31 ` [PATCH V2 4/4] clk: imx: Let IMX8MN_CLK_DISP_PIXEL " Adam Ford
  2023-03-23 22:31 ` [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Fabio Estevam
  4 siblings, 0 replies; 7+ messages in thread
From: Adam Ford @ 2023-03-21  2:31 UTC (permalink / raw)
  To: linux-clk
  Cc: aford, Adam Ford, Abel Vesa, Peng Fan, Michael Turquette,
	Stephen Boyd, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, linux-arm-kernel, linux-kernel

By default the display pixel clock needs to be evenly divide
down from 594MHz which rules out a significant number of
resolution and refresh rates.
The current clock tree looks something like:

video_pll1                  594000000
  video_pll1_bypass         594000000
     video_pll1_out         594000000
        lcdif_pixel         148500000

Now that composite-8m supports determine_rate, we can allow
lcdif_pixel to set the parent rate which then switches
every clock in the chain to a new frequency when lcdif_pixel
cannot evenly divide from video_pll1_out.

Signed-off-by: Adam Ford <aford173@gmail.com>
---
V2:  No Change

diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
index b618892170f2..075f643e3f35 100644
--- a/drivers/clk/imx/clk-imx8mm.c
+++ b/drivers/clk/imx/clk-imx8mm.c
@@ -468,7 +468,7 @@ static int imx8mm_clocks_probe(struct platform_device *pdev)
 	hws[IMX8MM_CLK_PCIE1_PHY] = imx8m_clk_hw_composite("pcie1_phy", imx8mm_pcie1_phy_sels, base + 0xa380);
 	hws[IMX8MM_CLK_PCIE1_AUX] = imx8m_clk_hw_composite("pcie1_aux", imx8mm_pcie1_aux_sels, base + 0xa400);
 	hws[IMX8MM_CLK_DC_PIXEL] = imx8m_clk_hw_composite("dc_pixel", imx8mm_dc_pixel_sels, base + 0xa480);
-	hws[IMX8MM_CLK_LCDIF_PIXEL] = imx8m_clk_hw_composite("lcdif_pixel", imx8mm_lcdif_pixel_sels, base + 0xa500);
+	hws[IMX8MM_CLK_LCDIF_PIXEL] = imx8m_clk_hw_composite_flags("lcdif_pixel", imx8mm_lcdif_pixel_sels, base + 0xa500, CLK_SET_RATE_PARENT);
 	hws[IMX8MM_CLK_SAI1] = imx8m_clk_hw_composite("sai1", imx8mm_sai1_sels, base + 0xa580);
 	hws[IMX8MM_CLK_SAI2] = imx8m_clk_hw_composite("sai2", imx8mm_sai2_sels, base + 0xa600);
 	hws[IMX8MM_CLK_SAI3] = imx8m_clk_hw_composite("sai3", imx8mm_sai3_sels, base + 0xa680);
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V2 4/4] clk: imx: Let IMX8MN_CLK_DISP_PIXEL set parent rate
  2023-03-21  2:31 [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Adam Ford
                   ` (2 preceding siblings ...)
  2023-03-21  2:31 ` [PATCH V2 3/4] clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate Adam Ford
@ 2023-03-21  2:31 ` Adam Ford
  2023-03-23 22:31 ` [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Fabio Estevam
  4 siblings, 0 replies; 7+ messages in thread
From: Adam Ford @ 2023-03-21  2:31 UTC (permalink / raw)
  To: linux-clk
  Cc: aford, Adam Ford, Abel Vesa, Peng Fan, Michael Turquette,
	Stephen Boyd, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	Fabio Estevam, NXP Linux Team, linux-arm-kernel, linux-kernel

By default the display pixel clock needs to be evenly divide
down from the video_pll_out clock which rules out a significant
number of resolution and refresh rates.

The current clock tree looks something like:

 video_pll                594000000
  video_pll_bypass        594000000
   video_pll_out          594000000
    disp_pixel            148500000
     disp_pixel_clk       148500000

Now that composite-8m supports determine_rate, we can allow
disp_pixel to set the parent rate which then switches
every clock in the chain to a new frequency when disp_pixel
cannot evenly divide from video_pll_out.

Signed-off-by: Adam Ford <aford173@gmail.com>
---
V2:  Move imx8m_clk_hw_composite_flags macro into its own patch

diff --git a/drivers/clk/imx/clk-imx8mn.c b/drivers/clk/imx/clk-imx8mn.c
index a042ed3a9d6c..4b23a4648600 100644
--- a/drivers/clk/imx/clk-imx8mn.c
+++ b/drivers/clk/imx/clk-imx8mn.c
@@ -470,7 +470,7 @@ static int imx8mn_clocks_probe(struct platform_device *pdev)
 	hws[IMX8MN_CLK_DRAM_ALT] = imx8m_clk_hw_fw_managed_composite("dram_alt", imx8mn_dram_alt_sels, base + 0xa000);
 	hws[IMX8MN_CLK_DRAM_APB] = imx8m_clk_hw_fw_managed_composite_critical("dram_apb", imx8mn_dram_apb_sels, base + 0xa080);
 
-	hws[IMX8MN_CLK_DISP_PIXEL] = imx8m_clk_hw_composite("disp_pixel", imx8mn_disp_pixel_sels, base + 0xa500);
+	hws[IMX8MN_CLK_DISP_PIXEL] = imx8m_clk_hw_composite_flags("disp_pixel", imx8mn_disp_pixel_sels, base + 0xa500, CLK_SET_RATE_PARENT);
 	hws[IMX8MN_CLK_SAI2] = imx8m_clk_hw_composite("sai2", imx8mn_sai2_sels, base + 0xa600);
 	hws[IMX8MN_CLK_SAI3] = imx8m_clk_hw_composite("sai3", imx8mn_sai3_sels, base + 0xa680);
 	hws[IMX8MN_CLK_SAI5] = imx8m_clk_hw_composite("sai5", imx8mn_sai5_sels, base + 0xa780);
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks
  2023-03-21  2:31 [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Adam Ford
                   ` (3 preceding siblings ...)
  2023-03-21  2:31 ` [PATCH V2 4/4] clk: imx: Let IMX8MN_CLK_DISP_PIXEL " Adam Ford
@ 2023-03-23 22:31 ` Fabio Estevam
  2023-03-23 22:44   ` Adam Ford
  4 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2023-03-23 22:31 UTC (permalink / raw)
  To: Adam Ford
  Cc: linux-clk, aford, Abel Vesa, Peng Fan, Michael Turquette,
	Stephen Boyd, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	NXP Linux Team, linux-arm-kernel, linux-kernel

On Mon, Mar 20, 2023 at 11:31 PM Adam Ford <aford173@gmail.com> wrote:
>
> Both the i.MX8M Mini and Nano have a video_pll which can be used
> to source a clock which feeds the lcdif interface.  This interface
> currently fixes video_pll and divides down the clock feeding LCDIF.
> However, when connected to an HDMI bridge chip that supports a
> variety of video resolutions and refresh rates, the only settings
> that properly sync are ones that evenly divide from the video_pll_out
> clock.
>
> This series adds the ability for the clk-compolsite-8m to
> request a better parent clock rate if the proper clock flag is
> enable and sets that flag in the corresponding imx8mm and
> imx8mn video_pll clocks to increase the number of resolutions
> and refresh rates timings that the LCDIF can produce.
>
> This also has a side benefit of allowing the video-pll to run
> at a lower clock speed which can potentially save some power
> depending on the requested resolution and refresh rate.
>
> V2:  Split off the new imx8m_clk_hw_composite_flags definition
>      into its own patch and re-order to fix build error.
>
> Adam Ford (3):
>   clk: imx: composite-8m: Add support to determine_rate
>   clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate
>   clk: imx: Let IMX8MN_CLK_DISP_PIXEL set parent rate

For the series:

Reviewed-by: Fabio Estevam <festevam@gmail.com>

Should drivers/clk/imx/clk-imx8mp.c also be adjusted in the same way?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks
  2023-03-23 22:31 ` [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Fabio Estevam
@ 2023-03-23 22:44   ` Adam Ford
  0 siblings, 0 replies; 7+ messages in thread
From: Adam Ford @ 2023-03-23 22:44 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: linux-clk, aford, Abel Vesa, Peng Fan, Michael Turquette,
	Stephen Boyd, Shawn Guo, Sascha Hauer, Pengutronix Kernel Team,
	NXP Linux Team, linux-arm-kernel, linux-kernel

On Thu, Mar 23, 2023 at 5:31 PM Fabio Estevam <festevam@gmail.com> wrote:
>
> On Mon, Mar 20, 2023 at 11:31 PM Adam Ford <aford173@gmail.com> wrote:
> >
> > Both the i.MX8M Mini and Nano have a video_pll which can be used
> > to source a clock which feeds the lcdif interface.  This interface
> > currently fixes video_pll and divides down the clock feeding LCDIF.
> > However, when connected to an HDMI bridge chip that supports a
> > variety of video resolutions and refresh rates, the only settings
> > that properly sync are ones that evenly divide from the video_pll_out
> > clock.
> >
> > This series adds the ability for the clk-compolsite-8m to
> > request a better parent clock rate if the proper clock flag is
> > enable and sets that flag in the corresponding imx8mm and
> > imx8mn video_pll clocks to increase the number of resolutions
> > and refresh rates timings that the LCDIF can produce.
> >
> > This also has a side benefit of allowing the video-pll to run
> > at a lower clock speed which can potentially save some power
> > depending on the requested resolution and refresh rate.
> >
> > V2:  Split off the new imx8m_clk_hw_composite_flags definition
> >      into its own patch and re-order to fix build error.
> >
> > Adam Ford (3):
> >   clk: imx: composite-8m: Add support to determine_rate
> >   clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate
> >   clk: imx: Let IMX8MN_CLK_DISP_PIXEL set parent rate
>
> For the series:
>
> Reviewed-by: Fabio Estevam <festevam@gmail.com>
>
Thanks!

> Should drivers/clk/imx/clk-imx8mp.c also be adjusted in the same way?

The LVDS and the DSI clocks are shared from a common parent, so I am
not sure of the impact of this.  I have an IMX8MP and I have it
working with DSI->HDMI and the LVDS, but I was waiting on the DSI
series from Jagan to get applied first and I wanted to make sure this
series gets accepted before I started work on the 8MP.

I will be traveling to Thailand for the next 3 weeks, so I'm hoping to
review the 8MP when I return.

adam

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-23 22:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21  2:31 [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Adam Ford
2023-03-21  2:31 ` [PATCH V2 1/4] clk: imx: composite-8m: Add support to determine_rate Adam Ford
2023-03-21  2:31 ` [PATCH V2 2/4] clk: imx: Add imx8m_clk_hw_composite_flags macro Adam Ford
2023-03-21  2:31 ` [PATCH V2 3/4] clk: imx8mm: Let IMX8MM_CLK_LCDIF_PIXEL set parent rate Adam Ford
2023-03-21  2:31 ` [PATCH V2 4/4] clk: imx: Let IMX8MN_CLK_DISP_PIXEL " Adam Ford
2023-03-23 22:31 ` [PATCH V2 0/4] clk: imx: Improve imx8mm/imx8mn LCDIF clocks Fabio Estevam
2023-03-23 22:44   ` Adam Ford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).