[PATCH 06/27] serial: pxa: get the clock from the clk API

Sascha Hauer s.hauer at pengutronix.de
Sun Aug 16 10:56:26 PDT 2026


pxa_get_uartclk() was a per SoC constant, and the PXA25x and PXA27x
versions of it are gone. Use the clk api to handle clocks.

A clk driver for PXA is not yet present in the tree, but PXA has
no board support currently, so we can safely break bisectability
here.

Assisted-by: Claude Opus 5
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/serial/serial_pxa.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/serial_pxa.c b/drivers/serial/serial_pxa.c
index 97342f923e..a0bebef811 100644
--- a/drivers/serial/serial_pxa.c
+++ b/drivers/serial/serial_pxa.c
@@ -9,7 +9,7 @@
 #include <init.h>
 #include <malloc.h>
 
-#include <mach/pxa/clock.h>
+#include <linux/clk.h>
 #include <asm/io.h>
 
 #define RBR		0x00	/* Receive Buffer Register (read only) */
@@ -90,6 +90,7 @@
 struct pxa_serial_priv {
 	void __iomem *regs;
 	struct console_device cdev;
+	struct clk *clk;
 };
 
 static void __iomem *to_regs(struct console_device *cdev)
@@ -124,6 +125,8 @@ static void pxa_serial_flush(struct console_device *cdev)
 
 static int pxa_serial_setbaudrate(struct console_device *cdev, int baudrate)
 {
+	struct pxa_serial_priv *priv =
+		container_of(cdev, struct pxa_serial_priv, cdev);
 	unsigned char cval = LCR_WLEN8;			/* 8N1 */
 	unsigned int quot;
 
@@ -131,7 +134,7 @@ static int pxa_serial_setbaudrate(struct console_device *cdev, int baudrate)
 	writel(IER_UUE, to_regs(cdev) + IER);
 
 	/* write divisor */
-	quot = (pxa_get_uartclk() + (8 * baudrate)) / (16 * baudrate);
+	quot = (clk_get_rate(priv->clk) + (8 * baudrate)) / (16 * baudrate);
 
 	writel(cval | LCR_DLAB, to_regs(cdev) + LCR);	/* set DLAB */
 	writel(quot & 0xff, to_regs(cdev) + DLL);
@@ -154,6 +157,7 @@ static int pxa_serial_probe(struct device *dev)
 	struct resource *iores;
 	struct console_device *cdev;
 	struct pxa_serial_priv *priv;
+	int ret;
 
 	priv = xzalloc(sizeof(*priv));
 	cdev = &priv->cdev;
@@ -162,6 +166,14 @@ static int pxa_serial_probe(struct device *dev)
 		return PTR_ERR(iores);
 	priv->regs = IOMEM(iores->start);
 
+	priv->clk = clk_get(dev, NULL);
+	if (IS_ERR(priv->clk))
+		return PTR_ERR(priv->clk);
+
+	ret = clk_enable(priv->clk);
+	if (ret)
+		return ret;
+
 	dev->priv = priv;
 	cdev->dev = dev;
 	cdev->tstc = pxa_serial_tstc;

-- 
2.47.3




More information about the barebox mailing list