The driver was probed by name only and took its configuration from
platform data. Nothing in tree ever registered that platform data, so the
gpio_power / setpower / init hooks were dead code, and the driver could
not be used from a device tree at all.

Match "marvell,pxa-mmc" and let mci_of_parse() pick up bus-width and the
other generic properties. The power switching goes away with the platform
data: the MCI core already gets a "vmmc" regulator from the device tree,
which is how the supply is described upstream.

mci_ops.init() stays, now as a stub: mci_card_probe() calls it without
checking it for NULL.

Assisted-by: Claude Opus 5
Signed-off-by: Sascha Hauer <[email protected]>
---
 drivers/mci/pxamci.c          | 47 +++++++++++++++++--------------------------
 drivers/mci/pxamci.h          |  1 -
 include/mach/pxa/mci_pxa2xx.h | 12 -----------
 3 files changed, 18 insertions(+), 42 deletions(-)

diff --git a/drivers/mci/pxamci.c b/drivers/mci/pxamci.c
index 5e26022729..236d4d97b4 100644
--- a/drivers/mci/pxamci.c
+++ b/drivers/mci/pxamci.c
@@ -13,10 +13,10 @@
 #include <clock.h>
 #include <init.h>
 #include <mci.h>
+#include <of.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 
-#include <mach/pxa/mci_pxa2xx.h>
 #include <mach/pxa/pxa-regs.h>
 #include "pxamci.h"
 
@@ -26,18 +26,6 @@
 #define TX_TIMEOUT (250 * MSECOND)
 #define CMD_TIMEOUT (100 * MSECOND)
 
-static int pxamci_set_power(struct pxamci_host *host, int on)
-{
-       mci_dbg("on=%d\n", on);
-       if (host->pdata && host->pdata->gpio_power > 0)
-               gpio_set_value(host->pdata->gpio_power,
-                              !!on ^ host->pdata->gpio_power_invert);
-       else if (host->pdata && host->pdata->setpower)
-               host->pdata->setpower(&host->mci, on);
-       mdelay(250);
-       return 0;
-}
-
 static void pxamci_start_clock(struct pxamci_host *host)
 {
        mmc_writel(START_CLOCK, MMC_STRPCL);
@@ -297,17 +285,16 @@ static void pxamci_set_ios(struct mci_host *mci, struct 
mci_ios *ios)
 
        host->cmdat |= CMDAT_INIT;
 
-       pxamci_set_power(host, 1);
        pxamci_stop_clock(host);
        mmc_writel(host->clkrt, MMC_CLKRT);
 }
 
+/*
+ * The MCI core calls this unconditionally, so it has to exist even though
+ * there is nothing left to do here since the platform data went away.
+ */
 static int pxamci_init(struct mci_host *mci, struct device *dev)
 {
-       struct pxamci_host *host = to_pxamci(mci);
-
-       if (host->pdata && host->pdata->init)
-               return host->pdata->init(mci, dev);
        return 0;
 }
 
@@ -322,7 +309,6 @@ static int pxamci_probe(struct device *dev)
        struct resource *iores;
        struct pxamci_host *host;
        unsigned long rate;
-       int gpio_power = -1;
        int ret;
 
        host = xzalloc(sizeof(*host));
@@ -344,6 +330,8 @@ static int pxamci_probe(struct device *dev)
        host->mci.hw_dev = dev;
        host->mci.voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
 
+       mci_of_parse(&host->mci);
+
        /*
         * Calculate minimum clock rate, rounding up.
         */
@@ -360,20 +348,21 @@ static int pxamci_probe(struct device *dev)
        mmc_writel(64, MMC_RESTO);
        mmc_writel(0, MMC_I_MASK);
 
-       host->pdata = dev->platform_data;
-       if (host->pdata)
-               gpio_power = host->pdata->gpio_power;
-
-       if (gpio_power > 0)
-               gpio_direction_output(gpio_power,
-                                     host->pdata->gpio_power_invert);
-
-       mci_register(&host->mci);
-       return 0;
+       return mci_register(&host->mci);
 }
 
+static __maybe_unused struct of_device_id pxamci_dt_ids[] = {
+       {
+               .compatible = "marvell,pxa-mmc",
+       }, {
+               /* sentinel */
+       }
+};
+MODULE_DEVICE_TABLE(of, pxamci_dt_ids);
+
 static struct driver pxamci_driver = {
        .name  = DRIVER_NAME,
        .probe = pxamci_probe,
+       .of_compatible = DRV_OF_COMPAT(pxamci_dt_ids),
 };
 device_platform_driver(pxamci_driver);
diff --git a/drivers/mci/pxamci.h b/drivers/mci/pxamci.h
index 30119a5607..1879d9603b 100644
--- a/drivers/mci/pxamci.h
+++ b/drivers/mci/pxamci.h
@@ -77,7 +77,6 @@
 struct pxamci_host {
        struct mci_host                 mci;
        void __iomem                    *base;
-       struct pxamci_platform_data     *pdata;
        struct clk                      *clk;
 
        unsigned int                    cmdat;
diff --git a/include/mach/pxa/mci_pxa2xx.h b/include/mach/pxa/mci_pxa2xx.h
deleted file mode 100644
index 299e543479..0000000000
--- a/include/mach/pxa/mci_pxa2xx.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-
-
-struct mci_host;
-struct device;
-
-struct pxamci_platform_data {
-       int gpio_power;
-       int gpio_power_invert;
-       int (*init)(struct mci_host*, struct device*);
-       int (*setpower)(struct mci_host*, int on);
-};

-- 
2.47.3


Reply via email to