public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: u-boot@lists.denx.de
Cc: Adam Ford <aford173@gmail.com>,
	"Ying-Chun Liu (PaulLiu)" <paul.liu@linaro.org>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Matteo Lisi <matteo.lisi@engicam.com>,
	Marek Vasut <marex@denx.de>,
	Olaf Mandel <o.mandel@menlosystems.com>,
	Peng Fan <peng.fan@nxp.com>, Tim Harvey <tharvey@gateworks.com>,
	"Ariel D'Alessandro" <ariel.dalessandro@collabora.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Ilko Iliev <iliev@ronetix.at>, Fabio Estevam <festevam@gmail.com>,
	Marco Franchi <marcofrk@gmail.com>,
	Alifer Moraes <alifer.wsdm@gmail.com>,
	Simon Glass <sjg@chromium.org>
Subject: [RFC 2/3] serial: mxc: Enable getting and enabling clocks with CCF Composite
Date: Sat, 30 Apr 2022 11:14:21 -0500	[thread overview]
Message-ID: <20220430161422.558361-3-aford173@gmail.com> (raw)
In-Reply-To: <20220430161422.558361-1-aford173@gmail.com>

Certain platforms have the UART clocks exposed through the CCF.
When they are, it's possible to enable and query the clock(s)
for a given UART. Add support getting, enabling, and querying
the clocks.

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

diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c
index e4970a169b..c68040ba74 100644
--- a/drivers/serial/serial_mxc.c
+++ b/drivers/serial/serial_mxc.c
@@ -10,6 +10,7 @@
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/clock.h>
 #include <asm/global_data.h>
+#include <clk.h>
 #include <dm/platform_data/serial_mxc.h>
 #include <serial.h>
 #include <linux/compiler.h>
@@ -266,8 +267,13 @@ __weak struct serial_device *default_serial_console(void)
 int mxc_serial_setbrg(struct udevice *dev, int baudrate)
 {
 	struct mxc_serial_plat *plat = dev_get_plat(dev);
-	u32 clk = imx_get_uartclk();
+	u32 clk;
 
+#if CONFIG_IS_ENABLED(CLK_COMPOSITE_CCF)
+	 clk = clk_get_rate(&plat->ipg_clk);
+#else
+	clk = imx_get_uartclk;
+#endif
 	_mxc_serial_setbrg(plat->reg, clk, baudrate, plat->use_dte);
 
 	return 0;
@@ -277,6 +283,22 @@ static int mxc_serial_probe(struct udevice *dev)
 {
 	struct mxc_serial_plat *plat = dev_get_plat(dev);
 
+#if CONFIG_IS_ENABLED(CLK_COMPOSITE_CCF)
+	int ret = 0;
+
+	ret = clk_enable(&plat->per_clk);
+	if (ret) {
+		printf("Failed to enable per_clk\n");
+		return ret;
+	}
+
+	ret = clk_enable(&plat->per_clk);
+	if (ret) {
+		printf("Failed to enable ipg_clk\n");
+		return ret;
+	}
+
+#endif
 	_mxc_serial_init(plat->reg, plat->use_dte);
 
 	return 0;
@@ -339,6 +361,21 @@ static int mxc_serial_of_to_plat(struct udevice *dev)
 
 	plat->use_dte = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
 					"fsl,dte-mode");
+#if CONFIG_IS_ENABLED(CLK_COMPOSITE_CCF)
+	int ret = 0;
+
+	ret = clk_get_by_name(dev, "per", &plat->per_clk);
+	if (ret) {
+		printf("Failed to get per_clk\n");
+		return ret;
+	}
+
+	ret = clk_get_by_name(dev, "ipg", &plat->ipg_clk);
+	if (ret) {
+		printf("Failed to get per_clk\n");
+		return ret;
+	}
+#endif
 	return 0;
 }
 
diff --git a/include/dm/platform_data/serial_mxc.h b/include/dm/platform_data/serial_mxc.h
index cc59eeb1dd..9a8c8498bf 100644
--- a/include/dm/platform_data/serial_mxc.h
+++ b/include/dm/platform_data/serial_mxc.h
@@ -10,6 +10,8 @@
 struct mxc_serial_plat {
 	struct mxc_uart *reg;  /* address of registers in physical memory */
 	bool use_dte;
+	struct clk per_clk;
+	struct clk ipg_clk;
 };
 
 #endif
-- 
2.34.1


  parent reply	other threads:[~2022-04-30 16:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-30 16:14 [RFC 0/3] imx8m: Remove manual UART clock initialization Adam Ford
2022-04-30 16:14 ` [RFC 1/3] clk: imx8mm: Add UART clocks Adam Ford
2022-04-30 16:14 ` Adam Ford [this message]
2022-05-01  9:48   ` [RFC 2/3] serial: mxc: Enable getting and enabling clocks with CCF Composite Peng Fan (OSS)
2022-05-01 15:16     ` Adam Ford
2022-04-30 16:14 ` [RFC 3/3] imx8: imx8mm_beacon: Remove manual UART clock initialization Adam Ford

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=20220430161422.558361-3-aford173@gmail.com \
    --to=aford173@gmail.com \
    --cc=alifer.wsdm@gmail.com \
    --cc=ariel.dalessandro@collabora.com \
    --cc=festevam@gmail.com \
    --cc=iliev@ronetix.at \
    --cc=jagan@amarulasolutions.com \
    --cc=marcofrk@gmail.com \
    --cc=marex@denx.de \
    --cc=matteo.lisi@engicam.com \
    --cc=michael@amarulasolutions.com \
    --cc=o.mandel@menlosystems.com \
    --cc=paul.liu@linaro.org \
    --cc=peng.fan@nxp.com \
    --cc=sjg@chromium.org \
    --cc=tharvey@gateworks.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