From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/18] mfd: Enable Device Tree for ab8500-core driver
Date: Thu, 17 May 2012 14:45:13 +0100 [thread overview]
Message-ID: <1337262323-27692-9-git-send-email-lee.jones@linaro.org> (raw)
In-Reply-To: <1337262323-27692-1-git-send-email-lee.jones@linaro.org>
This patch will allow the ab8500-core driver to be probed and set up
when booting when Device Tree is enabled. This includes platform ID
look-up which identifies the machine it is currently running on. If
we are undergoing a DT enabled boot, we will refuse to setup each of
the other ab8500-* devices, as they will be probed individually by DT.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/mfd/ab8500-core.c | 73 +++++++++++++++++++++++++++++++--------------
1 file changed, 51 insertions(+), 22 deletions(-)
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 0e2df71..bc6c2d5 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -20,6 +20,8 @@
#include <linux/mfd/abx500/ab8500.h>
#include <linux/mfd/dbx500-prcmu.h>
#include <linux/regulator/ab8500.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
/*
* Interrupt register offsets
@@ -1112,11 +1114,20 @@ static struct attribute_group ab9540_attr_group = {
.attrs = ab9540_sysfs_entries,
};
+static const struct of_device_id ab8500_match[] = {
+ {
+ .compatible = "stericsson,ab8500",
+ .data = (void *)AB8500_VERSION_AB8500,
+ },
+ {},
+};
+
static int __devinit ab8500_probe(struct platform_device *pdev)
{
struct ab8500_platform_data *plat = dev_get_platdata(&pdev->dev);
const struct platform_device_id *platid = platform_get_device_id(pdev);
- enum ab8500_version version = platid->driver_data;
+ enum ab8500_version version = AB8500_VERSION_UNDEFINED;
+ struct device_node *np = pdev->dev.of_node;
struct ab8500 *ab8500;
struct resource *resource;
int ret;
@@ -1129,6 +1140,14 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
if (plat)
ab8500->irq_base = plat->irq_base;
+ else if (np)
+ ret = of_property_read_u32(np, "stericsson,irq-base", &ab8500->irq_base);
+
+ if (!ab8500->irq_base) {
+ dev_info(&pdev->dev, "couldn't find irq-base\n");
+ ret = -EINVAL;
+ goto out_free_ab8500;
+ }
ab8500->dev = &pdev->dev;
@@ -1150,6 +1169,12 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ab8500);
+ if (platid)
+ version = platid->driver_data;
+ else if (np)
+ version = (unsigned int)
+ of_match_device(ab8500_match, &pdev->dev)->data;
+
if (version != AB8500_VERSION_UNDEFINED)
ab8500->version = version;
else {
@@ -1246,29 +1271,32 @@ static int __devinit ab8500_probe(struct platform_device *pdev)
goto out_removeirq;
}
- ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs,
- ARRAY_SIZE(abx500_common_devs), NULL,
- ab8500->irq_base);
-
- if (ret)
- goto out_freeirq;
+ if (!np) {
+ ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs,
+ ARRAY_SIZE(abx500_common_devs), NULL,
+ ab8500->irq_base);
- if (is_ab9540(ab8500))
- ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs,
- ARRAY_SIZE(ab9540_devs), NULL,
- ab8500->irq_base);
- else
- ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs,
- ARRAY_SIZE(ab8500_devs), NULL,
- ab8500->irq_base);
-
- if (is_ab9540(ab8500) || is_ab8505(ab8500))
- ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs,
- ARRAY_SIZE(ab9540_ab8505_devs), NULL,
- ab8500->irq_base);
+ if (ret)
+ goto out_freeirq;
+
+ if (is_ab9540(ab8500))
+ ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs,
+ ARRAY_SIZE(ab9540_devs), NULL,
+ ab8500->irq_base);
+ else
+ ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs,
+ ARRAY_SIZE(ab8500_devs), NULL,
+ ab8500->irq_base);
+ if (ret)
+ goto out_freeirq;
- if (ret)
- goto out_freeirq;
+ if (is_ab9540(ab8500) || is_ab8505(ab8500))
+ ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs,
+ ARRAY_SIZE(ab9540_ab8505_devs), NULL,
+ ab8500->irq_base);
+ if (ret)
+ goto out_freeirq;
+ }
if (!no_bm) {
/* Add battery management devices */
@@ -1338,6 +1366,7 @@ static struct platform_driver ab8500_core_driver = {
.driver = {
.name = "ab8500-core",
.owner = THIS_MODULE,
+ .of_match_table = ab8500_match,
},
.probe = ab8500_probe,
.remove = __devexit_p(ab8500_remove),
--
1.7.9.5
next prev parent reply other threads:[~2012-05-17 13:45 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-17 13:45 [PATCH 00/18] DT enablement for Snowball Lee Jones
2012-05-17 13:45 ` [PATCH 01/18] i2c: Add Device Tree support to the Nomadik I2C driver Lee Jones
2012-05-20 20:53 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 02/18] ARM: ux500: Remove unused i2c platform_data initialisation code Lee Jones
2012-05-17 13:45 ` [PATCH 03/18] ARM: ux500: Provide auxdata to be used as name base clock search for nmk-i2c Lee Jones
2012-05-17 13:45 ` [PATCH 04/18] ARM: ux500: CONFIG: Compile in support for leds-gpio Lee Jones
2012-05-17 13:45 ` [PATCH 05/18] ARM: ux500: Enable the user LED on Snowball via Device Tree Lee Jones
2012-05-17 13:45 ` [PATCH 06/18] mfd: ab8500: Remove confusing ab8500-i2c file and merge into ab8500-core Lee Jones
2012-05-20 20:58 ` Linus Walleij
2012-05-21 7:52 ` Lee Jones
2012-05-17 13:45 ` [PATCH 07/18] ARM: ux500: PRCMU related configuration and layout corrections for Device Tree Lee Jones
2012-05-17 13:45 ` Lee Jones [this message]
2012-05-17 13:45 ` [PATCH 09/18] regulator: ab8500: Split up probe() into manageable pieces Lee Jones
2012-05-18 7:36 ` Mark Brown
2012-05-18 7:53 ` Lee Jones
2012-05-20 21:15 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 10/18] ARM: ux500: Add support for ab8500 regulators into the Device Tree Lee Jones
2012-05-17 13:45 ` [PATCH 11/18] regulator: Enable the ab8500 for " Lee Jones
2012-05-18 7:36 ` Mark Brown
2012-05-18 7:52 ` Lee Jones
2012-05-20 21:14 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 12/18] ARM: ux500: Disable platform setup of the ab8500 when DT is enabled Lee Jones
2012-05-17 21:22 ` Arnd Bergmann
2012-05-17 21:58 ` Lee Jones
2012-05-18 10:38 ` Arnd Bergmann
2012-05-18 11:00 ` Lee Jones
2012-05-18 11:12 ` Arnd Bergmann
2012-05-18 12:36 ` Lee Jones
2012-05-18 20:38 ` Arnd Bergmann
2012-05-17 13:45 ` [PATCH 13/18] ARM: ux500: Apply ab8500-debug node do the db8500 DT structure Lee Jones
2012-05-20 21:00 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 14/18] mfd: Enable ab8500-debug when Device Tree is enabled Lee Jones
2012-05-20 21:00 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 15/18] mfd: Prevent unassigned pointer from being used in ab8500-gpadc driver Lee Jones
2012-05-20 21:02 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 16/18] ARM: ux500: Add a ab8500-gpadc node to the db8500 Device Tree Lee Jones
2012-05-20 21:01 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 17/18] mfd: Enable ab8500-gpadc driver for " Lee Jones
2012-05-20 21:02 ` Linus Walleij
2012-05-17 13:45 ` [PATCH 18/18] ARM: ux500: Add support for input/ponkey into the db8500's " Lee Jones
2012-05-20 21:03 ` Linus Walleij
2012-05-17 21:25 ` [PATCH 00/18] DT enablement for Snowball Arnd Bergmann
2012-05-17 21:41 ` Mark Brown
2012-05-17 21:49 ` Lee Jones
2012-05-19 15:25 ` Samuel Ortiz
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=1337262323-27692-9-git-send-email-lee.jones@linaro.org \
--to=lee.jones@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).