mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 05/15] mci: mxs: Add devicetree support
Date: Wed, 28 Jan 2015 08:32:09 +0100	[thread overview]
Message-ID: <1422430339-11969-6-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1422430339-11969-1-git-send-email-s.hauer@pengutronix.de>

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>
---
 drivers/mci/mxs.c | 50 +++++++++++++++++++++++++++-----------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index 367964c..b36fb13 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);
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-01-28  7:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-28  7:32 [PATCH] MXS: Add device tree support and duckbill board support Sascha Hauer
2015-01-28  7:32 ` [PATCH 01/15] ARM: MXS: Fix vddd brownout setting Sascha Hauer
2015-01-28  7:32 ` [PATCH 02/15] MXS: power-init: inline only once used functions Sascha Hauer
2015-01-28  7:32 ` [PATCH 03/15] ARM: MXS: Do not register devices with device tree support Sascha Hauer
2015-01-28  7:32 ` [PATCH 04/15] ARM: MXS: Make gpio a driver Sascha Hauer
2015-01-28  7:32 ` Sascha Hauer [this message]
2015-01-28  7:32 ` [PATCH 06/15] serial: stm_serial: Add devicetree support Sascha Hauer
2015-01-28  7:32 ` [PATCH 07/15] ARM: MXS: Create ocotp device in SoC code Sascha Hauer
2015-01-28  7:32 ` [PATCH 08/15] ARM: MXS: ocotp: Add devicetree support Sascha Hauer
2015-01-28  7:32 ` [PATCH 09/15] of: Create platform_device when creating AMBA device failed Sascha Hauer
2015-01-28  7:32 ` [PATCH 10/15] pbl: Add support for memory_display Sascha Hauer
2015-01-28  7:32 ` [PATCH 11/15] pinctrl: Add MXS pinctrl driver Sascha Hauer
2015-01-28  7:32 ` [PATCH 12/15] ARM: MXS: Setup vdda in power prep Sascha Hauer
2015-01-28  7:32 ` [PATCH 13/15] ARM: MXS: Add regulator debug print Sascha Hauer
2015-01-28  7:32 ` [PATCH 14/15] ARM: MXS: power-init: Add parameters to mx28_power_init() Sascha Hauer
2015-01-28  7:32 ` [PATCH 15/15] ARM: MXS: Add duckbill board support Sascha Hauer

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=1422430339-11969-6-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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