linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 3/4] drivers/amba: create devices from device tree
Date: Fri, 10 Jun 2011 17:11:46 -0600	[thread overview]
Message-ID: <20110610231146.GG28994@ponder.secretlab.ca> (raw)
In-Reply-To: <4DF29CB1.9070701@gmail.com>

On Fri, Jun 10, 2011 at 05:37:37PM -0500, Rob Herring wrote:
> On 06/10/2011 05:22 PM, Grant Likely wrote:
> >On Fri, Jun 10, 2011 at 03:48:42PM -0500, Rob Herring wrote:
> >>From: Rob Herring<rob.herring@calxeda.com>
> >>
> >>Add a function to create amba bus devices (i.e. primecell peripherals) from
> >>device tree nodes. The device tree scanning is done by
> >>of_platform_probe/populate functions which can call of_amba_device_create
> >>based on a match table entry.
> >>
> >>Nodes with a "arm,amba-deviceid" property can override the h/w peripheral id
> >>value.
> >>
> >>Based on the original work by Jeremy Kerr.
> >>
> >>Cc: Jeremy Kerr<jeremy.kerr@canonical.com>
> >>Cc: Grant Likely<grant.likely@secretlab.ca>
> >>Cc: linux at arm.linux.org.uk
> >>Cc: arnd at arndb.de
> >>Acked-by: Linus Walleij<linus.walleij@linaro.org>
> >>Signed-off-by: Rob Herring<rob.herring@calxeda.com>
> >>---
> >>  Documentation/devicetree/bindings/arm/amba.txt |   21 ++++++++++
> >>  drivers/amba/bus.c                             |   51 ++++++++++++++++++++++++
> >>  include/linux/amba/bus.h                       |   18 ++++++++
> >>  3 files changed, 90 insertions(+), 0 deletions(-)
> >>  create mode 100644 Documentation/devicetree/bindings/arm/amba.txt
> >>
> >>diff --git a/Documentation/devicetree/bindings/arm/amba.txt b/Documentation/devicetree/bindings/arm/amba.txt
> >>new file mode 100644
> >>index 0000000..23fde7f
> >>--- /dev/null
> >>+++ b/Documentation/devicetree/bindings/arm/amba.txt
> >>@@ -0,0 +1,21 @@
> >>+* ARM Primecell Peripherals
> >>+
> >>+ARM, Ltd. Primecell peripherals have a standard id register that can be used to
> >>+identify the peripheral type, vendor, and revision. This value can be used for
> >>+driver matching.
> >>+
> >>+Required properties:
> >>+
> >>+- compatible : should be a specific value for peripheral and "arm,amba-device"
> >
> >After recent conversations, I'd like to change this to
> >"arm,primecell" to better reflect the kind of devices it models.
> 
> That did cross my mind as I was writing the doc...
> 
> >
> >>+
> >>+Optional properties:
> >>+
> >>+- arm,amba-deviceid : Value to override the h/w value with
> >
> >Similarly, based on the primecell device documents, this should
> >probabaly be arm,primecell-periphid.
> >
> >>+
> >>+Example:
> >>+
> >>+serial at fff36000 {
> >>+	compatible = "arm,pl011", "arm,amba-device";
> >>+	arm,amba-deviceid =<0x00341011>;
> >>+};
> >>+
> >>diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> >>index d74926e..19f712b 100644
> >>--- a/drivers/amba/bus.c
> >>+++ b/drivers/amba/bus.c
> >>@@ -13,6 +13,11 @@
> >>  #include<linux/string.h>
> >>  #include<linux/slab.h>
> >>  #include<linux/io.h>
> >>+#include<linux/of.h>
> >>+#include<linux/of_irq.h>
> >>+#include<linux/of_address.h>
> >>+#include<linux/of_device.h>
> >>+#include<linux/of_platform.h>
> >>  #include<linux/pm.h>
> >>  #include<linux/pm_runtime.h>
> >>  #include<linux/amba/bus.h>
> >>@@ -785,3 +790,49 @@ EXPORT_SYMBOL(amba_device_unregister);
> >>  EXPORT_SYMBOL(amba_find_device);
> >>  EXPORT_SYMBOL(amba_request_regions);
> >>  EXPORT_SYMBOL(amba_release_regions);
> >>+
> >>+#ifdef CONFIG_OF
> >>+int of_amba_device_create(struct device_node *node, struct device *parent)
> >>+{
> >>+	struct amba_device *dev;
> >>+	const void *prop;
> >>+	int i, ret;
> >>+
> >>+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> >>+	if (!dev)
> >>+		return -ENOMEM;
> >>+
> >>+	/* setup generic device info */
> >>+	dev->dev.coherent_dma_mask = ~0;
> >>+	dev->dev.of_node = node;
> >>+	dev->dev.parent = parent;
> >>+	of_device_make_bus_id(&dev->dev);
> >>+
> >>+	/* setup amba-specific device info */
> >>+	dev->dma_mask = ~0;
> >>+
> >>+	/* Allow the arm,amba-deviceid value to override the h/w value */
> >>+	prop = of_get_property(node, "arm,amba-deviceid", NULL);
> >>+	if (prop)
> >>+		dev->periphid = of_read_ulong(prop, 1);
> >>+
> >>+	/* Decode the IRQs and address ranges */
> >>+	for (i = 0; i<  AMBA_NR_IRQS; i++)
> >>+		dev->irq[i] = irq_of_parse_and_map(node, i);
> >>+
> >>+	ret = of_address_to_resource(node, 0,&dev->res);
> >>+	if (ret)
> >>+		goto err_free;
> >>+
> >>+	ret = amba_device_register(dev,&iomem_resource);
> >>+	if (ret)
> >>+		goto err_free;
> >>+
> >>+	return 0;
> >>+
> >>+err_free:
> >>+	kfree(dev);
> >>+	return ret;
> >>+}
> >>+
> >
> >Yeah, I think this looks like the right thing to do.  I'll pick it up
> >into devicetree/test and probably move it to devicetree/arm in the
> >near future after testing a bit.
> 
> Okay, I'll respin with your and Arnd's comments.

Actually, hold off.  I'm working on it right now so I can get it into
my tree.  I'll take care of the respin.

g.

  reply	other threads:[~2011-06-10 23:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10 20:48 [PATCH v4 0/4] amba bus devicetree probing Rob Herring
2011-06-10 20:48 ` [PATCH v4 1/4] dt: check root nodes for match on of_platform_populate Rob Herring
2011-06-10 21:06   ` Arnd Bergmann
2011-06-10 21:11     ` Grant Likely
2011-06-10 21:17       ` Arnd Bergmann
2011-06-10 21:13   ` Grant Likely
2011-06-10 20:48 ` [PATCH v4 2/4] dt: add EXPORT_SYMBOL to of_platform_populate Rob Herring
2011-06-10 21:37   ` Grant Likely
2011-06-10 22:44     ` Rob Herring
2011-06-10 23:12       ` Grant Likely
2011-06-10 20:48 ` [PATCH v4 3/4] drivers/amba: create devices from device tree Rob Herring
2011-06-10 21:04   ` Arnd Bergmann
2011-06-10 22:30     ` Grant Likely
2011-06-10 22:22   ` Grant Likely
2011-06-10 22:37     ` Rob Herring
2011-06-10 23:11       ` Grant Likely [this message]
2011-06-10 20:48 ` [PATCH v4 4/4] dt: add amba device creation to platform bus scan Rob Herring
2011-06-10 21:02   ` Arnd Bergmann
2011-06-10 22:39   ` 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=20110610231146.GG28994@ponder.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --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).