From: cavokz@gmail.com (Domenico Andreoli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: add DT support to the S3C SDI driver
Date: Wed, 13 Apr 2011 19:25:47 +0200 [thread overview]
Message-ID: <20110413172547.GA27819@dandreoli.com> (raw)
From: Domenico Andreoli <cavokz@gmail.com>
This patch adds DeviceTree support to the S3C SDI driver.
It implements all the configurations of the platform driver except the
set_power() callback and the ocr_avail mask.
Signed-off-by: Domenico Andreoli <cavokz@gmail.com>
---
ocr_avail is a bit mask that could be easily ported to DT. If there
is not any better (or readable) way to render it in DT, I will
straightforwardly implement it.
set_power() instead deserves some more considerations. Current
implementations boil down to gpio on/off settings, its DT implementation
is again straightforward. Problem would arise if any board requires
some naive implementation, would it require a different of_device_id
with proper .data set?
cheers,
Domenico
---
drivers/mmc/host/s3cmci.c | 83 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 78 insertions(+), 5 deletions(-)
Index: b/drivers/mmc/host/s3cmci.c
===================================================================
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/dma-mapping.h>
#include <linux/clk.h>
+#include <linux/slab.h>
#include <linux/mmc/host.h>
#include <linux/platform_device.h>
#include <linux/cpufreq.h>
@@ -22,6 +23,8 @@
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <mach/dma.h>
@@ -1544,6 +1547,58 @@
#endif /* CONFIG_DEBUG_FS */
+#ifdef CONFIG_OF
+
+enum of_s3cmci_flags {
+ OF_S3CMCI_USE_DMA = 1,
+};
+
+static struct s3c24xx_mci_pdata *s3cmci_of_init(struct device *dev)
+{
+ struct s3c24xx_mci_pdata *pdata;
+ const __be32 *spec;
+ enum of_gpio_flags gpio_flags;
+ int gpio;
+ u32 flags;
+
+ pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+ if(!pdata) {
+ dev_err(dev, "%s: failed to allocate pdata\n", dev->of_node->full_name);
+ return NULL;
+ }
+
+ gpio = of_get_gpio_flags(dev->of_node, 0, &gpio_flags);
+ if (gpio < 0) {
+ pdata->no_detect = 1;
+ } else {
+ pdata->gpio_detect = gpio;
+ pdata->detect_invert = (gpio_flags & OF_GPIO_ACTIVE_LOW) == OF_GPIO_ACTIVE_LOW;
+ }
+
+ gpio = of_get_gpio_flags(dev->of_node, 1, &gpio_flags);
+ if (gpio < 0) {
+ pdata->no_wprotect = 1;
+ } else {
+ pdata->gpio_wprotect = gpio;
+ pdata->wprotect_invert = (gpio_flags & OF_GPIO_ACTIVE_LOW) == OF_GPIO_ACTIVE_LOW;
+ }
+
+ spec = of_get_property(dev->of_node, "flags", 0);
+ flags = spec ? be32_to_cpup(spec) : 0;
+ pdata->use_dma = flags | OF_S3CMCI_USE_DMA;
+
+ return pdata;
+}
+
+#else
+
+static struct s3c24xx_mci_pdata *s3cmci_of_init(struct device *dev)
+{
+ return NULL;
+}
+
+#endif /* CONFIG_OF */
+
static int __devinit s3cmci_probe(struct platform_device *pdev)
{
struct s3cmci_host *host;
@@ -1552,7 +1607,12 @@
int is2440;
int i;
- is2440 = platform_get_device_id(pdev)->driver_data;
+ if (platform_get_device_id(pdev))
+ is2440 = platform_get_device_id(pdev)->driver_data;
+ else if (pdev->dev.of_match)
+ is2440 = (int) pdev->dev.of_match->data;
+ else
+ BUG();
mmc = mmc_alloc_host(sizeof(struct s3cmci_host), &pdev->dev);
if (!mmc) {
@@ -1577,11 +1637,11 @@
host->pdev = pdev;
host->is2440 = is2440;
- host->pdata = pdev->dev.platform_data;
- if (!host->pdata) {
+ if (!pdev->dev.platform_data && pdev->dev.of_node)
+ pdev->dev.platform_data = s3cmci_of_init(&pdev->dev);
+ if (!pdev->dev.platform_data)
pdev->dev.platform_data = &s3cmci_def_pdata;
- host->pdata = &s3cmci_def_pdata;
- }
+ host->pdata = pdev->dev.platform_data;
spin_lock_init(&host->complete_lock);
tasklet_init(&host->pio_tasklet, pio_tasklet, (unsigned long) host);
@@ -1901,12 +1961,25 @@
#define s3cmci_pm_ops NULL
#endif /* CONFIG_PM */
+#ifdef CONFIG_OF
+
+static const struct of_device_id s3cmci_of_match[] = {
+ { .compatible = "samsung,s3c2410-sdi", .data = (void *) 0, },
+ { .compatible = "samsung,s3c2412-sdi", .data = (void *) 1, },
+ { .compatible = "samsung,s3c2440-sdi", .data = (void *) 1, },
+ {},
+};
+
+#else /* CONFIG_OF */
+#define s3cmci_of_match NULL
+#endif /* CONFIG_OF */
static struct platform_driver s3cmci_driver = {
.driver = {
.name = "s3c-sdi",
.owner = THIS_MODULE,
.pm = s3cmci_pm_ops,
+ .of_match_table = s3cmci_of_match,
},
.id_table = s3cmci_driver_ids,
.probe = s3cmci_probe,
WARNING: multiple messages have this Message-ID (diff)
From: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: [PATCH] ARM: add DT support to the S3C SDI driver
Date: Wed, 13 Apr 2011 19:25:47 +0200 [thread overview]
Message-ID: <20110413172547.GA27819@dandreoli.com> (raw)
From: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
This patch adds DeviceTree support to the S3C SDI driver.
It implements all the configurations of the platform driver except the
set_power() callback and the ocr_avail mask.
Signed-off-by: Domenico Andreoli <cavokz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
ocr_avail is a bit mask that could be easily ported to DT. If there
is not any better (or readable) way to render it in DT, I will
straightforwardly implement it.
set_power() instead deserves some more considerations. Current
implementations boil down to gpio on/off settings, its DT implementation
is again straightforward. Problem would arise if any board requires
some naive implementation, would it require a different of_device_id
with proper .data set?
cheers,
Domenico
---
drivers/mmc/host/s3cmci.c | 83 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 78 insertions(+), 5 deletions(-)
Index: b/drivers/mmc/host/s3cmci.c
===================================================================
--- a/drivers/mmc/host/s3cmci.c
+++ b/drivers/mmc/host/s3cmci.c
@@ -14,6 +14,7 @@
#include <linux/module.h>
#include <linux/dma-mapping.h>
#include <linux/clk.h>
+#include <linux/slab.h>
#include <linux/mmc/host.h>
#include <linux/platform_device.h>
#include <linux/cpufreq.h>
@@ -22,6 +23,8 @@
#include <linux/gpio.h>
#include <linux/irq.h>
#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
#include <mach/dma.h>
@@ -1544,6 +1547,58 @@
#endif /* CONFIG_DEBUG_FS */
+#ifdef CONFIG_OF
+
+enum of_s3cmci_flags {
+ OF_S3CMCI_USE_DMA = 1,
+};
+
+static struct s3c24xx_mci_pdata *s3cmci_of_init(struct device *dev)
+{
+ struct s3c24xx_mci_pdata *pdata;
+ const __be32 *spec;
+ enum of_gpio_flags gpio_flags;
+ int gpio;
+ u32 flags;
+
+ pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
+ if(!pdata) {
+ dev_err(dev, "%s: failed to allocate pdata\n", dev->of_node->full_name);
+ return NULL;
+ }
+
+ gpio = of_get_gpio_flags(dev->of_node, 0, &gpio_flags);
+ if (gpio < 0) {
+ pdata->no_detect = 1;
+ } else {
+ pdata->gpio_detect = gpio;
+ pdata->detect_invert = (gpio_flags & OF_GPIO_ACTIVE_LOW) == OF_GPIO_ACTIVE_LOW;
+ }
+
+ gpio = of_get_gpio_flags(dev->of_node, 1, &gpio_flags);
+ if (gpio < 0) {
+ pdata->no_wprotect = 1;
+ } else {
+ pdata->gpio_wprotect = gpio;
+ pdata->wprotect_invert = (gpio_flags & OF_GPIO_ACTIVE_LOW) == OF_GPIO_ACTIVE_LOW;
+ }
+
+ spec = of_get_property(dev->of_node, "flags", 0);
+ flags = spec ? be32_to_cpup(spec) : 0;
+ pdata->use_dma = flags | OF_S3CMCI_USE_DMA;
+
+ return pdata;
+}
+
+#else
+
+static struct s3c24xx_mci_pdata *s3cmci_of_init(struct device *dev)
+{
+ return NULL;
+}
+
+#endif /* CONFIG_OF */
+
static int __devinit s3cmci_probe(struct platform_device *pdev)
{
struct s3cmci_host *host;
@@ -1552,7 +1607,12 @@
int is2440;
int i;
- is2440 = platform_get_device_id(pdev)->driver_data;
+ if (platform_get_device_id(pdev))
+ is2440 = platform_get_device_id(pdev)->driver_data;
+ else if (pdev->dev.of_match)
+ is2440 = (int) pdev->dev.of_match->data;
+ else
+ BUG();
mmc = mmc_alloc_host(sizeof(struct s3cmci_host), &pdev->dev);
if (!mmc) {
@@ -1577,11 +1637,11 @@
host->pdev = pdev;
host->is2440 = is2440;
- host->pdata = pdev->dev.platform_data;
- if (!host->pdata) {
+ if (!pdev->dev.platform_data && pdev->dev.of_node)
+ pdev->dev.platform_data = s3cmci_of_init(&pdev->dev);
+ if (!pdev->dev.platform_data)
pdev->dev.platform_data = &s3cmci_def_pdata;
- host->pdata = &s3cmci_def_pdata;
- }
+ host->pdata = pdev->dev.platform_data;
spin_lock_init(&host->complete_lock);
tasklet_init(&host->pio_tasklet, pio_tasklet, (unsigned long) host);
@@ -1901,12 +1961,25 @@
#define s3cmci_pm_ops NULL
#endif /* CONFIG_PM */
+#ifdef CONFIG_OF
+
+static const struct of_device_id s3cmci_of_match[] = {
+ { .compatible = "samsung,s3c2410-sdi", .data = (void *) 0, },
+ { .compatible = "samsung,s3c2412-sdi", .data = (void *) 1, },
+ { .compatible = "samsung,s3c2440-sdi", .data = (void *) 1, },
+ {},
+};
+
+#else /* CONFIG_OF */
+#define s3cmci_of_match NULL
+#endif /* CONFIG_OF */
static struct platform_driver s3cmci_driver = {
.driver = {
.name = "s3c-sdi",
.owner = THIS_MODULE,
.pm = s3cmci_pm_ops,
+ .of_match_table = s3cmci_of_match,
},
.id_table = s3cmci_driver_ids,
.probe = s3cmci_probe,
next reply other threads:[~2011-04-13 17:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-13 17:25 Domenico Andreoli [this message]
2011-04-13 17:25 ` [PATCH] ARM: add DT support to the S3C SDI driver Domenico Andreoli
2011-04-13 17:33 ` Grant Likely
2011-04-13 17:33 ` Grant Likely
2011-04-13 17:35 ` Grant Likely
2011-04-13 17:35 ` Grant Likely
2011-04-13 20:52 ` Domenico Andreoli
2011-04-13 20:52 ` Domenico Andreoli
2011-04-14 8:51 ` Vasily Khoruzhick
2011-04-14 8:51 ` Vasily Khoruzhick
2011-04-14 9:37 ` Domenico Andreoli
2011-04-14 9:37 ` Domenico Andreoli
2011-05-04 1:04 ` Grant Likely
2011-05-04 1:04 ` Grant Likely
[not found] ` <20110504010448.GA4952-e0URQFbLeQY2iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2011-05-04 2:07 ` Domenico Andreoli
[not found] ` <BANLkTim9UT8epyp7ccFdKq6-uobU2h0wdA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-05-04 2:18 ` Grant Likely
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=20110413172547.GA27819@dandreoli.com \
--to=cavokz@gmail.com \
--cc=linux-arm-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.