[PATCH 04/27] mci: pxamci: get the clock from the clk API

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


The driver enabled its clock by poking CKEN directly and asked
pxa_get_mmcclk() for the rate. Use the clk api to handle the 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/mci/Kconfig  |  4 ++--
 drivers/mci/pxamci.c | 25 +++++++++++++++----------
 drivers/mci/pxamci.h |  1 +
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index 55e63aad92..2c3365e723 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -192,10 +192,10 @@ config MCI_OMAP_HSMMC
 
 config MCI_PXA
 	bool "PXA"
-	depends on ARCH_PXA2XX
+	depends on ARCH_PXA
 	help
 	  Enable this entry to add support to read and write SD cards on a
-	  XScale PXA25x / PXA27x based system.
+	  XScale PXA3xx based system.
 
 config MCI_ATMEL
 	bool "ATMEL (AT91)"
diff --git a/drivers/mci/pxamci.c b/drivers/mci/pxamci.c
index 1f2aaf2031..5e26022729 100644
--- a/drivers/mci/pxamci.c
+++ b/drivers/mci/pxamci.c
@@ -14,8 +14,8 @@
 #include <init.h>
 #include <mci.h>
 #include <linux/err.h>
+#include <linux/clk.h>
 
-#include <mach/pxa/clock.h>
 #include <mach/pxa/mci_pxa2xx.h>
 #include <mach/pxa/pxa-regs.h>
 #include "pxamci.h"
@@ -26,11 +26,6 @@
 #define TX_TIMEOUT (250 * MSECOND)
 #define CMD_TIMEOUT (100 * MSECOND)
 
-static void mmc_clk_enable(void)
-{
-	CKEN |= CKEN_MMC;
-}
-
 static int pxamci_set_power(struct pxamci_host *host, int on)
 {
 	mci_dbg("on=%d\n", on);
@@ -272,7 +267,7 @@ static int pxamci_request(struct mci_host *mci, struct mci_cmd *cmd)
 static void pxamci_set_ios(struct mci_host *mci, struct mci_ios *ios)
 {
 	struct pxamci_host *host = to_pxamci(mci);
-	unsigned int clk_in = pxa_get_mmcclk();
+	unsigned int clk_in = clk_get_rate(host->clk);
 	int fact;
 
 	mci_dbg("bus_width=%d, clock=%u\n", ios->bus_width, ios->clock);
@@ -326,15 +321,24 @@ static int pxamci_probe(struct device *dev)
 {
 	struct resource *iores;
 	struct pxamci_host *host;
+	unsigned long rate;
 	int gpio_power = -1;
+	int ret;
 
-	mmc_clk_enable();
 	host = xzalloc(sizeof(*host));
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
 		return PTR_ERR(iores);
 	host->base = IOMEM(iores->start);
 
+	host->clk = clk_get(dev, NULL);
+	if (IS_ERR(host->clk))
+		return PTR_ERR(host->clk);
+
+	ret = clk_enable(host->clk);
+	if (ret)
+		return ret;
+
 	host->mci.ops = pxamci_ops;
 	host->mci.host_caps = MMC_CAP_4_BIT_DATA;
 	host->mci.hw_dev = dev;
@@ -343,8 +347,9 @@ static int pxamci_probe(struct device *dev)
 	/*
 	 * Calculate minimum clock rate, rounding up.
 	 */
-	host->mci.f_min = pxa_get_mmcclk() >> 6;
-	host->mci.f_max = pxa_get_mmcclk();
+	rate = clk_get_rate(host->clk);
+	host->mci.f_min = rate >> 6;
+	host->mci.f_max = rate;
 
 	/*
 	 * Ensure that the host controller is shut down, and setup
diff --git a/drivers/mci/pxamci.h b/drivers/mci/pxamci.h
index 3dd93cb267..30119a5607 100644
--- a/drivers/mci/pxamci.h
+++ b/drivers/mci/pxamci.h
@@ -78,6 +78,7 @@ struct pxamci_host {
 	struct mci_host			mci;
 	void __iomem			*base;
 	struct pxamci_platform_data	*pdata;
+	struct clk			*clk;
 
 	unsigned int			cmdat;
 	int				clkrt;

-- 
2.47.3




More information about the barebox mailing list