summaryrefslogtreecommitdiffstats
path: root/drivers/mci/mxs.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-01-27 22:44:53 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-01-28 08:18:44 +0100
commit846f27cf928ff24b54cfe8512945ae4fcb2bd52a (patch)
tree9cba4be3dfa3006f297ffbfc138d5c5e1fae3e76 /drivers/mci/mxs.c
parent478ea1c0b1e4db8275786ff7fb285d61d7697656 (diff)
downloadbarebox-846f27cf928ff24b54cfe8512945ae4fcb2bd52a.tar.gz
barebox-846f27cf928ff24b54cfe8512945ae4fcb2bd52a.tar.xz
mci: mxs: Add devicetree support
Add device tree compatibles and allow retrieving data from device tree instead of platform_data only. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mci/mxs.c')
-rw-r--r--drivers/mci/mxs.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index 367964c1d0..b36fb13254 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -549,11 +549,6 @@ static int mxs_mci_probe(struct device_d *hw_dev)
struct mci_host *host;
unsigned long rate;
- if (hw_dev->platform_data == NULL) {
- dev_err(hw_dev, "Missing platform data\n");
- return -EINVAL;
- }
-
mxs_mci = xzalloc(sizeof(*mxs_mci));
host = &mxs_mci->host;
@@ -567,9 +562,16 @@ static int mxs_mci_probe(struct device_d *hw_dev)
return PTR_ERR(mxs_mci->regs);
/* feed forward the platform specific values */
- host->voltages = pd->voltages;
- host->host_caps = pd->caps;
- host->devname = pd->devname;
+ if (pd) {
+ host->voltages = pd->voltages;
+ host->host_caps = pd->caps;
+ host->devname = pd->devname;
+ host->f_min = pd->f_min;
+ host->f_max = pd->f_max;
+ } else {
+ host->voltages = MMC_VDD_32_33 | MMC_VDD_33_34, /* fixed to 3.3 V */
+ mci_of_parse(host);
+ }
mxs_mci->clk = clk_get(hw_dev, NULL);
if (IS_ERR(mxs_mci->clk))
@@ -579,22 +581,13 @@ static int mxs_mci_probe(struct device_d *hw_dev)
rate = clk_get_rate(mxs_mci->clk);
- if (pd->f_min == 0) {
- host->f_min = rate / 254 / 256;
- dev_dbg(hw_dev, "Min. frequency is %u Hz\n", host->f_min);
- } else {
- host->f_min = pd->f_min;
- dev_dbg(hw_dev, "Min. frequency is %u Hz, could be %lu Hz\n",
- host->f_min, rate / 254 / 256);
- }
- if (pd->f_max == 0) {
+ if (host->f_min < 400000)
+ host->f_min = 400000;
+ if (host->f_max == 0)
host->f_max = rate / 2 / 1;
- dev_dbg(hw_dev, "Max. frequency is %u Hz\n", host->f_max);
- } else {
- host->f_max = pd->f_max;
- dev_dbg(hw_dev, "Max. frequency is %u Hz, could be %lu Hz\n",
- host->f_max, rate / 2 / 1);
- }
+
+ dev_dbg(hw_dev, "Max. frequency is %u Hz\n", host->f_max);
+ dev_dbg(hw_dev, "Min. frequency is %u Hz\n", host->f_min);
if (IS_ENABLED(CONFIG_MCI_INFO)) {
mxs_mci->f_min = host->f_min;
@@ -605,8 +598,19 @@ static int mxs_mci_probe(struct device_d *hw_dev)
return mci_register(host);
}
+static __maybe_unused struct of_device_id mxs_mmc_compatible[] = {
+ {
+ .compatible = "fsl,imx23-mmc",
+ }, {
+ .compatible = "fsl,imx28-mmc",
+ }, {
+ /* sentinel */
+ }
+};
+
static struct driver_d mxs_mci_driver = {
.name = "mxs_mci",
.probe = mxs_mci_probe,
+ .of_compatible = DRV_OF_COMPAT(mxs_mmc_compatible),
};
device_platform_driver(mxs_mci_driver);