public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 06/10] clk: imx6: Add imx6ul clock tree support
Date: Tue,  2 Apr 2019 16:58:39 +0530	[thread overview]
Message-ID: <20190402112843.992-7-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20190402112843.992-1-jagan@amarulasolutions.com>

i.MX6 clock control module comprise of parent clocks, gates, multiplexers,
dividers, PODF, PLL, fixed rate and etc.

So, the U-Boot implementation of ccm has divided into gates and tree.

1) gate clocks are generic clock configuration of enable/disable bit management
   which can be handle via imx6_clock_gate.
2) tree clocks are handle via tree clock management where it link the clocks
   based on the parent clock which usually required to get and set the
   clock rates.

This patch add tree clock management for imx6ul USDHC clocks, so the mmc driver
from imx6 can eventually use this so getting the USDHC clock rates.

Unlike Linux, U-Boot implementation may not require to maintain exact clock tree
due to various constrains and use cases. So here is how the clock tree differs
between them.

usdhc clock tree in Linux:
-------------------------
USDHC1 => USDHC1_PODF => USDHC1_SEL => PLL2_PFD2 => PLL2_BUS => PLL2_BYPASS => PLL2 => OSC

usdhc clock tree in U-Boot:
---------------------------
USDHC1 => USDHC1_PODF => USDHC1_SEL => PLL2_PFD2 => PLL2_BUS => OSC

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/clk/imx/clk-imx6ul.c | 48 ++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/clk/imx/clk-imx6ul.c b/drivers/clk/imx/clk-imx6ul.c
index f5250e8b72..8528176eec 100644
--- a/drivers/clk/imx/clk-imx6ul.c
+++ b/drivers/clk/imx/clk-imx6ul.c
@@ -10,6 +10,53 @@
 #include <asm/arch/clock.h>
 #include <dt-bindings/clock/imx6ul-clock.h>
 
+static const unsigned long pll2_bus[] = {
+	IMX6UL_CLK_OSC,
+};
+
+static const unsigned long pfd_352m[] = {
+	IMX6UL_CLK_PLL2_BUS,
+};
+
+static const unsigned long usdhc_sel[] = {
+	IMX6UL_CLK_PLL2_PFD2,
+	IMX6UL_CLK_PLL2_PFD0,
+};
+
+static const unsigned long usdhc1_podf[] = {
+	IMX6UL_CLK_USDHC1_SEL,
+};
+
+static const unsigned long usdhc2_podf[] = {
+	IMX6UL_CLK_USDHC2_SEL,
+};
+
+static const unsigned long usdhc1[] = {
+	IMX6UL_CLK_USDHC1_PODF,
+};
+
+static const unsigned long usdhc2[] = {
+	IMX6UL_CLK_USDHC2_PODF,
+};
+
+static const struct imx6_clk_tree imx6ul_tree[] = {
+	[IMX6UL_CLK_OSC]		= FIXED(OSC_24M_ULL),
+
+	[IMX6UL_CLK_PLL2_BUS]		= PLL_DIV(pll2_bus, 0x30, 13, 1),
+
+	[IMX6UL_CLK_PLL2_PFD0]		= PLL_PFD(pfd_352m, 0x100, 6, 0),
+	[IMX6UL_CLK_PLL2_PFD2]		= PLL_PFD(pfd_352m, 0x100, 6, 2),
+
+	[IMX6UL_CLK_USDHC2_SEL]		= MUX(usdhc_sel, 0x01c, 17, 1),
+	[IMX6UL_CLK_USDHC1_SEL]		= MUX(usdhc_sel, 0x01c, 16, 1),
+
+	[IMX6UL_CLK_USDHC2_PODF]	= DIV(usdhc2_podf, 0x024, 16, 3),
+	[IMX6UL_CLK_USDHC1_PODF]	= DIV(usdhc1_podf, 0x024, 11, 3),
+
+	[IMX6UL_CLK_USDHC2]		= SIMPLE(usdhc2),
+	[IMX6UL_CLK_USDHC1]		= SIMPLE(usdhc1),
+};
+
 static const struct imx6_clk_gate imx6ul_gates[] = {
 	[IMX6UL_CLK_USDHC1]		= GATE(0x080, GENMASK(3, 2)),
 	[IMX6UL_CLK_USDHC2]		= GATE(0x080, GENMASK(5, 4)),
@@ -17,6 +64,7 @@ static const struct imx6_clk_gate imx6ul_gates[] = {
 
 static const struct imx6_clk_desc imx6ul_clk_desc = {
 	.gates = imx6ul_gates,
+	.tree = imx6ul_tree,
 };
 
 static const struct udevice_id clk_imx6ul_ids[] = {
-- 
2.18.0.321.gffc6fa0e3

  parent reply	other threads:[~2019-04-02 11:28 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-02 11:28 [U-Boot] [PATCH v2 00/10] clk: imx: Add i.MX6 CLK support Jagan Teki
2019-04-02 11:28 ` [U-Boot] [PATCH v2 01/10] clk: imx: Kconfig: Make CONFIG_CLK available for selection Jagan Teki
2019-04-02 11:28 ` [U-Boot] [PATCH v2 02/10] clk: imx: Add i.MX6Q clock driver Jagan Teki
2019-04-02 11:28 ` [U-Boot] [PATCH v2 03/10] clk: imx: Add i.MX6UL " Jagan Teki
2019-04-02 11:28 ` [U-Boot] [PATCH v2 04/10] clk: Add clk_div_mask helper Jagan Teki
2019-04-02 11:28 ` [U-Boot] [PATCH v2 05/10] clk: imx: Add imx6q clock tree support Jagan Teki
2019-04-19  7:54   ` Lukasz Majewski
2019-04-02 11:28 ` Jagan Teki [this message]
2019-04-02 11:28 ` [U-Boot] [PATCH v2 07/10] ARM: dts: i.MX6QDL: Add u-boot, dm-spl for clks Jagan Teki
2019-04-02 11:28 ` [U-Boot] [PATCH v2 08/10] ARM: dts: i.MX6UL: " Jagan Teki
2019-04-02 11:28 ` [U-Boot] [PATCH v2 09/10] configs: icore_mipi: Enable CLK Jagan Teki
2019-04-02 11:28 ` [U-Boot] [PATCH v2 10/10] ARM: imx6: Enable CLK for Engicam i.MX6UL boards Jagan Teki
2019-04-04  9:01 ` [U-Boot] [PATCH v2 00/10] clk: imx: Add i.MX6 CLK support Lukasz Majewski
2019-04-04  9:26   ` Jagan Teki
2019-04-04 10:00     ` Lukasz Majewski
2019-04-04 15:48       ` Fabio Estevam
2019-04-04 15:56         ` Tom Rini
2019-04-04 16:05           ` Jagan Teki
2019-04-04 19:26             ` Tom Rini
2019-04-04 16:18       ` Jagan Teki
2019-04-04 20:49         ` Lukasz Majewski
2019-04-19  6:26           ` Jagan Teki
2019-04-19  8:01             ` Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190402112843.992-7-jagan@amarulasolutions.com \
    --to=jagan@amarulasolutions.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox