Skip to contentSkip to conversation

arm/dt: register devices from device tree

RFC PATCH In review Grant Likely 4 participants 10 messages Jan 26, 2011 – Feb 1, 2011

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

cover arm/dt: register devices from device tree

Hi all,

For right now this is only an early implementation and there are several bugs that prevent all devices from getting registered correctly, and not all of the dts data is accurate. However, it starts to show what a device-tree enabled machine_desc looks like using the versatile platform as an example, and I wanted to get it out for people to see.

A significant change in this series compared with the previous version is that the devicetree clock lookup code has been decoupled from the common struct clk patches that Jeremy is currently working on. This means that there is more machine-specific code than there needs to be for handling clocks, but it can be removed after a common struct clk is merged.

This series is based on:

git://git.secretlab.ca/git/linux-2.6 devicetree/arm

g.

---

Grant Likely (2):
arm/dt: Add dt machine definition arm/versatile: add a device tree versatile platform

Jeremy Kerr (3):
drivers/amba: probe via device tree
of: add clock providers
arm/clkdev: lookup clocks from OF clock providers

 arch/arm/boot/dts/versatile.dts        |  138 ++++++++++++++++++++++++++++++++
 arch/arm/include/asm/mach/arch.h       |    9 ++
 arch/arm/mach-versatile/Kconfig        |    8 ++
 arch/arm/mach-versatile/Makefile       |    1 
 arch/arm/mach-versatile/versatile_ab.c |    6 -
 arch/arm/mach-versatile/versatile_dt.c |  108 +++++++++++++++++++++++++
 arch/arm/mach-versatile/versatile_pb.c |    6 -
 arch/arm/plat-versatile/clock.c        |    2 
 drivers/amba/bus.c                     |   67 ++++++++++++++++
 drivers/clk/clkdev.c                   |    7 ++
 drivers/of/Kconfig                     |    5 +
 drivers/of/Makefile                    |    1 
 drivers/of/clock.c                     |  133 +++++++++++++++++++++++++++++++
 include/linux/amba/bus.h               |    5 +
 include/linux/of_clk.h                 |   36 ++++++++
 15 files changed, 520 insertions(+), 12 deletions(-)
 create mode 100644 arch/arm/boot/dts/versatile.dts
 create mode 100644 arch/arm/mach-versatile/versatile_dt.c
 create mode 100644 drivers/of/clock.c
 create mode 100644 include/linux/of_clk.h
Signature · 1 line
Signature
#1 lore raw

RFC PATCH 1/5 arm/dt: Add dt machine definition

---
 arch/arm/include/asm/mach/arch.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
arch/arm/include/asm/mach/arch.h +9 -0
index 2ed24e7..13c0e69 100644
@@ -67,4 +67,13 @@ static const struct machine_desc __mach_desc_##_type	\
 #define MACHINE_END				\
 };
 
+#define MACH_TYPE_DT	0xffffffff
+
+#define DT_MACHINE_START(_name, _namestr)		\
+static const struct machine_desc __mach_desc_##_name	\
+ __used							\
+ __attribute__((__section__(".arch.info.init"))) = {	\
+	.nr		= MACH_TYPE_DT,			\
+	.name		= _namestr,
+
 #endif
#4 lore raw

RFC PATCH 2/5 drivers/amba: probe via device tree

In reply to Grant Likely

From: Jeremy Kerr <[email protected]>

Add functions to parse the AMBA bus through the device tree.

---
 drivers/amba/bus.c       |   67 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/amba/bus.h |    5 +++
 2 files changed, 72 insertions(+), 0 deletions(-)
drivers/amba/bus.c +67 -0
index e7df019..e753fa9 100644
@@ -13,6 +13,10 @@
 #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/amba/bus.h>
 
 #include <asm/irq.h>
@@ -486,3 +490,66 @@ EXPORT_SYMBOL(amba_device_unregister);
 EXPORT_SYMBOL(amba_find_device);
 EXPORT_SYMBOL(amba_request_regions);
 EXPORT_SYMBOL(amba_release_regions);
+
+#ifdef CONFIG_OF
+static 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;
+
+	/* 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;
+
+	/* Sanity check the arm,amba-deviceid value */
+	prop = of_get_property(node, "arm,amba-deviceid", NULL);
+	if (!prop)
+		dev_warn(&dev->dev, "arm,amba-deviceid property missing; "
+				    "probe gives 0x%08x.\n", dev->periphid);
+
+	if (prop && (dev->periphid != of_read_ulong(prop, 1)))
+		dev_warn(&dev->dev, "arm,amba-deviceid value (0x%08lx) and "
+				    "probed value (0x%08x) don't agree.",
+				    of_read_ulong(prop, 1), dev->periphid);
+
+	return 0;
+
+err_free:
+	kfree(dev);
+	return ret;
+}
+
+void of_amba_bus_populate(struct device_node *node, struct device *parent)
+{
+	struct device_node *child;
+
+	for_each_child_of_node(node, child) {
+		if (of_device_is_compatible(child, "arm,amba-device"))
+			of_amba_device_create(child, parent);
+	}
+}
+EXPORT_SYMBOL(of_amba_bus_populate);
+
+#endif /* CONFIG_OF */
include/linux/amba/bus.h +5 -0
index 9e7f259..4baa4cf 100644
@@ -90,4 +90,9 @@ void amba_release_regions(struct amba_device *);
 #define amba_manf(d)	AMBA_MANF_BITS((d)->periphid)
 #define amba_part(d)	AMBA_PART_BITS((d)->periphid)
 
+#ifdef CONFIG_OF
+struct device_node;
+void of_amba_bus_populate(struct device_node *node, struct device *parent);
+#endif
+
 #endif
#5 lore raw

RFC PATCH 3/5 of: add clock providers

In reply to Grant Likely

From: Jeremy Kerr <[email protected]>

Based on work by Ben Herrenschmidt, this patch adds an of_clk_get function to allow platforms to retrieve clock data from the device tree.

Platform register a provider through of_clk_add_provider, which will be called when a device references the provider's OF node for a clock reference.

[grant.likely at secretlab.ca: fix Kconfig conflict]
---
 drivers/of/Kconfig     |    5 ++
 drivers/of/Makefile    |    1 
 drivers/of/clock.c     |  134 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/of_clk.h |   36 +++++++++++++
 4 files changed, 176 insertions(+), 0 deletions(-)
 create mode 100644 drivers/of/clock.c
 create mode 100644 include/linux/of_clk.h
drivers/of/Kconfig +5 -0
index 3c6e100..6650583 100644
@@ -69,4 +69,9 @@ config OF_MDIO
 	help
 	  OpenFirmware MDIO bus (Ethernet PHY) accessors
 
+config OF_CLOCK
+	def_bool y
+	depends on HAVE_CLK
+	help
+	  OpenFirmware clock accessors
 endmenu # OF
drivers/of/Makefile +1 -0
index 3ab21a0..c378c7b 100644
@@ -5,6 +5,7 @@ obj-$(CONFIG_OF_ADDRESS)  += address.o
 obj-$(CONFIG_OF_IRQ)    += irq.o
 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
 obj-$(CONFIG_OF_GPIO)   += gpio.o
+obj-$(CONFIG_OF_CLOCK)	+= clock.o
 obj-$(CONFIG_OF_I2C)	+= of_i2c.o
 obj-$(CONFIG_OF_NET)	+= of_net.o
 obj-$(CONFIG_OF_SPI)	+= of_spi.o
drivers/of/clock.c new file +134 -0

134 lines not on this page · raw message

include/linux/of_clk.h new file +36 -0
new file mode 100644
index 0000000..c2f6b5a
@@ -0,0 +1,36 @@
+/*
+ * Clock infrastructure for device tree platforms
+ */
+#ifndef __OF_CLK_H
+#define __OF_CLK_H
+
+struct device;
+struct clk;
+
+#ifdef CONFIG_OF_CLOCK
+
+struct device_node;
+
+int of_clk_add_provider(struct device_node *np,
+		struct clk *(*clk_src_get)(struct device_node *np,
+			const char *output_id,
+			void *data),
+		void *data);
+
+void of_clk_del_provider(struct device_node *np,
+		struct clk *(*clk_src_get)(struct device_node *np,
+			const char *output_id,
+			void *data),
+		void *data);
+
+struct clk *of_clk_get(struct device *dev, const char *id);
+
+#else
+static inline struct clk *of_clk_get(struct device *dev, const char *id)
+{
+	return NULL;
+}
+#endif
+
+#endif /* __OF_CLK_H */
+
#7 lore raw

RFC PATCH 4/5 arm/clkdev: lookup clocks from OF clock providers

In reply to Grant Likely

From: Jeremy Kerr <[email protected]>

Hook the OF clock provider infrastructure to clk_get.

---
 drivers/clk/clkdev.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/clk/clkdev.c +7 -0
index 0fc0a79..a546763 100644
@@ -19,6 +19,8 @@
 #include <linux/mutex.h>
 #include <linux/clk.h>
 #include <linux/clkdev.h>
+#include <linux/of.h>
+#include <linux/of_clk.h>
 
 static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
@@ -79,6 +81,11 @@ EXPORT_SYMBOL(clk_get_sys);
 struct clk *clk_get(struct device *dev, const char *con_id)
 {
 	const char *dev_id = dev ? dev_name(dev) : NULL;
+	struct clk *clk;
+
+	clk = of_clk_get(dev, con_id);
+	if (clk && __clk_get(clk))
+		return clk;
 
 	return clk_get_sys(dev_id, con_id);
 }
#9 lore raw

RFC PATCH 5/5 arm/versatile: add a device tree versatile platform

In reply to Grant Likely

For testing the dt work, define a dt-enabled versatile platform.

This patch includes some fixed clk parsing logic that really would be better as common code, but that depends on the common struct clk getting merged. In the mean time it is easy enough to implement it here.

Based on work originally written by Jeremy Kerr <[email protected]>

---
 arch/arm/boot/dts/versatile.dts        |  138 ++++++++++++++++++++++++++++++++
 arch/arm/mach-versatile/Kconfig        |    8 ++
 arch/arm/mach-versatile/Makefile       |    1 
 arch/arm/mach-versatile/versatile_ab.c |    6 -
 arch/arm/mach-versatile/versatile_dt.c |  108 +++++++++++++++++++++++++
 arch/arm/mach-versatile/versatile_pb.c |    6 -
 arch/arm/plat-versatile/clock.c        |    2 
 drivers/of/clock.c                     |    1 
 8 files changed, 257 insertions(+), 13 deletions(-)
 create mode 100644 arch/arm/boot/dts/versatile.dts
 create mode 100644 arch/arm/mach-versatile/versatile_dt.c
arch/arm/boot/dts/versatile.dts new file +138 -0
new file mode 100644
index 0000000..6ff9ee2
@@ -0,0 +1,138 @@
+/dts-v1/;
+
+/ {
+	model = "ARM Versatile-PB";
+	compatible = "arm,versatile-pb";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	interrupt-parent = <&vic>;
+
+	aliases {
+		uart0 = &uart0;
+		uart1 = &uart1;
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x0 0x08000000>;
+	};
+
+	chosen {
+		bootargs = "console=ttyAMA0 debug";
+	};
+
+	clocks {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		ref24_clk: clock at 0 {
+			compatible = "fixed-clock";
+			clock-frequency = <24000000>;
+			clock-outputs = "ref";
+		};
+
+		osc4_clk: clock at 1 {
+			compatible = "ics,icst307";
+			ref = <24000>;
+			vco-max = <200000>;
+			vd-range = <12 519>;
+			rd-range = <3 129>;
+			clock-outputs = "osc4";
+		};
+	};
+
+	vic: intc {
+		compatible = "arm,versatile-vic";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		reg = <0x10140000 0x1000>;
+	};
+
+	sic: intc at 10003000 {
+		compatible = "arm,versatile-vic";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		reg = <0x10003000 0x1000>;
+		interrupts = <31>; /* Cascaded to vic */
+	};
+
+	amba {
+		compatible = "arm,amba-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		fpga {
+			compatible = "arm,versatile-fpga", "simple-bus";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0x10000000 0x10000>;
+
+			fpga at 5000 {
+				compatible = "arm,amba-device";
+				reg = < 0x5000 0x1000 >;
+			};
+			fpga at 6000 {
+				compatible = "arm,pl050", "arm,amba-device";
+				reg = < 0x6000 0x1000 >;
+			};
+			fpga at 7000 {
+				compatible = "arm,pl050", "arm,amba-device";
+				reg = < 0x7000 0x1000 >;
+			};
+			fpga at 9000 {
+				compatible = "arm,pl011", "arm,amba-device";
+				reg = < 0x9000 0x1000 >;
+			};
+			fpga at b000 {
+				compatible = "arm,amba-device";
+				reg = < 0xb000 0x1000 >;
+			};
+		};
+
+		uart0: uart at 101f1000 {
+			compatible = "arm,pl011", "arm,amba-device";
+			reg = <0x101f1000 0x1000>;
+			arm,amba-deviceid = <0x00141011>;
+			interrupts = <12>;
+			bus-clock = <&ref24_clk>, "ref";
+		};
+
+		uart1: uart at 101f2000 {
+			compatible = "arm,pl011", "arm,amba-device";
+			reg = <0x101f2000 0x1000>;
+			arm,amba-deviceid = <0x00141011>;
+			interrupts = <13>;
+			bus-clock = <&ref24_clk>, "ref";
+		};
+	};
+
+	flash at 34000000 {
+		compatible = "arm,versatile-flash";
+		reg = <0x34000000 0x4000000>;
+		bank-width = <4>;
+	};
+
+	net at 10010000 {
+		compatible = "smsc,smc91c111";
+		reg = <0x10010000 0x10000>;
+		interrupts = <25>;
+	};
+
+	i2c at 10002000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "arm,versatile-i2c";
+		reg = <0x10002000 0x1000>;
+
+		rtc at 68 {
+			compatible = "dallas,ds1338";
+			reg = <0x68>;
+		};
+	};
+
+	lcd at 10008000 {
+		compatible = "arm,versatile-lcd";
+		reg = <0x10008000 0x1000>;
+	};
+};
arch/arm/mach-versatile/Kconfig +8 -0
index 3f7b5e9..3b417f4 100644
@@ -15,4 +15,12 @@ config MACH_VERSATILE_AB
 	help
 	  Include support for the ARM(R) Versatile/AP platform.
 
+config MACH_VERSATILE_DT
+	bool "Support Versatile platform from device tree"
+	select USE_OF
+	select CPU_ARM926T
+	help
+	  Include support for the ARM(R) Versatile/PB platform,
+	  using the device tree for discovery
+
 endmenu
arch/arm/mach-versatile/Makefile +1 -0
index 97cf4d8..81fa3fe 100644
@@ -5,4 +5,5 @@
 obj-y					:= core.o
 obj-$(CONFIG_ARCH_VERSATILE_PB)		+= versatile_pb.o
 obj-$(CONFIG_MACH_VERSATILE_AB)		+= versatile_ab.o
+obj-$(CONFIG_MACH_VERSATILE_DT)		+= versatile_dt.o
 obj-$(CONFIG_PCI)			+= pci.o
arch/arm/mach-versatile/versatile_ab.c +0 -6
index 62053df..aa9730f 100644
@@ -33,11 +33,6 @@
 
 #include "core.h"
 
-static const char *versatile_ab_match[] __initdata = {
-	"arm,versatile-ab",
-	NULL,
-};
-
 MACHINE_START(VERSATILE_AB, "ARM-Versatile AB")
 	/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
 	.boot_params	= 0x00000100,
@@ -45,5 +40,4 @@ MACHINE_START(VERSATILE_AB, "ARM-Versatile AB")
 	.init_irq	= versatile_init_irq,
 	.timer		= &versatile_timer,
 	.init_machine	= versatile_init,
-	.dt_compat	= versatile_ab_match,
 MACHINE_END
arch/arm/mach-versatile/versatile_dt.c new file +108 -0

108 lines not on this page · raw message

arch/arm/mach-versatile/versatile_pb.c +0 -6
index eba12fa..bf46964 100644
@@ -106,11 +106,6 @@ static void __init versatile_pb_init(void)
 	}
 }
 
-static const char *versatile_pb_match[] __initdata = {
-	"arm,versatile-pb",
-	NULL,
-};
-
 MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
 	/* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
 	.boot_params	= 0x00000100,
@@ -118,5 +113,4 @@ MACHINE_START(VERSATILE_PB, "ARM-Versatile PB")
 	.init_irq	= versatile_init_irq,
 	.timer		= &versatile_timer,
 	.init_machine	= versatile_pb_init,
-	.dt_compat	= versatile_pb_match,
 MACHINE_END
arch/arm/plat-versatile/clock.c +2 -0
index 5c8b656..44545de 100644
@@ -13,6 +13,8 @@
 #include <linux/errno.h>
 #include <linux/clk.h>
 #include <linux/mutex.h>
+#include <linux/err.h>
+#include <linux/slab.h>
 
 #include <asm/hardware/icst.h>
 
drivers/of/clock.c +0 -1
index 3e2b221..7b5ea67 100644
@@ -131,4 +131,3 @@ struct clk *of_clk_get(struct device *dev, const char *id)
 
 	return clk;
 }
-
#8 lore raw

Re: [RFC PATCH 3/5] of: add clock providers

In reply to Grant Likely
Quoted 2 lines · Grant Likely
(quoted diff) +2 -0
+struct clk *of_clk_get(struct device *dev, const char *id)
+{

...

Quoted 4 lines
(quoted diff) +4 -0
+	snprintf(prop_name, 32, "%s-clock", id ? id : "bus");
+	prop = of_get_property(dev->of_node, prop_name, &sz);
+	if (!prop || sz < 4)
+		return NULL;

...

Quoted 11 lines
(quoted diff) +11 -0
+	 * size of the property. */
+	if (strlen(prop) + 1 > sz)
+		return NULL;
+
+	/* Find the clock provider node; check if it is registered as a
+	 * provider, and ask it for the relevant clk structure */
+	provnode = of_find_node_by_phandle(provhandle);
+	if (!provnode) {
+		pr_warn("%s: %s property in node %s references invalid phandle",
+			__func__, prop_name, dev->of_node->full_name);
+		return NULL;

...

Quoted 2 lines
(quoted diff) +2 -0
+	return clk;
+}

drivers/clk/clkdev.c EXPORT_SYMBOL(clk_get_sys); · line 91

Quoted 13 lines · Grant Likely
drivers/clk/clkdev.c +5 -0
@@ -79,6 +81,11 @@ EXPORT_SYMBOL(clk_get_sys);
 struct clk *clk_get(struct device *dev, const char *con_id)
 {
 	const char *dev_id = dev ? dev_name(dev) : NULL;
+	struct clk *clk;
+
+	clk = of_clk_get(dev, con_id);
+	if (clk && __clk_get(clk))
+		return clk;
 
 	return clk_get_sys(dev_id, con_id);
 }

The return value for clk_get() by almost all users is checked for specifically with IS_ERR() rather than an IS_ERR_OR_NULL(), so you're going to want to change your of_clk_get() error paths to return ERR_PTR()'s directly, or wrap it up like clk_get_sys() does.

Given that there are multiple reasons why of_clk_get() can fail however, it's probably worth handing down the actual error rather than simply chomping it in to an -ENOENT.

#2 lore raw

Re: [RFC,1/5] arm/dt: Add dt machine definition

In reply to Grant Likely
Quoted 2 lines · Grant Likely

needs a description ...

arch/arm/include/asm/mach/arch.h static const struct machine_desc __mach_desc_##_type \ · line 75

Quoted 13 lines

---
arch/arm/include/asm/mach/arch.h | 9 +++++++++

 1 files changed, 9 insertions(+), 0 deletions(-)
arch/arm/include/asm/mach/arch.h +6 -0
+#define MACH_TYPE_DT	0xffffffff
+
+#define DT_MACHINE_START(_name, _namestr)		\
+static const struct machine_desc __mach_desc_##_name	\
+ __used							\
+ __attribute__((__section__(".arch.info.init"))) = {	\

linux/compiler.h defines __section for this

arch/arm/include/asm/mach/arch.h static const struct machine_desc __mach_desc_##_type \ · line 79

Quoted 4 lines
arch/arm/include/asm/mach/arch.h +3 -0
+	.nr		= MACH_TYPE_DT,			\
+	.name		= _namestr,
+
 #endif

milton

#3 lore raw

Re: [RFC,1/5] arm/dt: Add dt machine definition

Quoted 5 lines · Milton Miller
Quoted 2 lines · Grant Likely

needs a description ...

oops

Quoted 7 lines
Quoted 7 lines

---
arch/arm/include/asm/mach/arch.h |    9 +++++++++

 1 files changed, 9 insertions(+), 0 deletions(-)
Quoted 8 lines

arch/arm/include/asm/mach/arch.h static const struct machine_desc __mach_desc_##_type \ · line 75

Quoted 6 lines
arch/arm/include/asm/mach/arch.h +6 -0
+#define MACH_TYPE_DT 0xffffffff
+
+#define DT_MACHINE_START(_name, _namestr)            \
+static const struct machine_desc __mach_desc_##_name \
+ __used                                                      \
+ __attribute__((__section__(".arch.info.init"))) = { \

linux/compiler.h defines __section for this

For commonality, I duplicated what was already done for #define MACHINE_START in this same file. However, I'm not even entirely sure that I'm going to keep this hunk around. With some of the recent changes to the arm-dt patches, a special DT machine id of 0xffffffff is no longer needed. This patch may get dropped in a future posting of this series.

g.

Quoted 8 lines
Quoted 5 lines

+     .nr             = MACH_TYPE_DT,                 \
+     .name           = _namestr,
+
 #endif

milton

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#6 lore raw

Re: [RFC PATCH 3/5] of: add clock providers

In reply to Grant Likely

Grant,

Quoted 1 line · Grant Likely

+struct clk *of_clk_get(struct device *dev, const char *id)

It would help if this took a struct device_node rather than struct device. This would allow using of_clk_get directly for cases where you don't have a struct device. This is fairly common in core platform core which are not full drivers. The case I have run into is the timer init code. To make clk_get work, I would have to create a dummy struct device.

Alternatively, an of_clk_get_sys function is needed.

drivers/of/clock.c line 103

Quoted 11 lines
drivers/of/clock.c new file +11 -0
+{
+	struct device_node *provnode;
+	u32 provhandle;
+	int sz;
+	struct clk *clk;
+	char prop_name[32]; /* 32 is max size of property name */
+	const void *prop;
+
+	dev_dbg(dev, "Looking up %s-clock from device tree\n", id);
+
+	snprintf(prop_name, 32, "%s-clock", id ? id : "bus");

Many times a module just has 1 clock and id will be NULL. Is "bus-clock" really the best choice of name? A bus clock may exist, but be transparent to s/w. How about allowing "clock" or "%s-clock"?

If bus-clock is the default, then you should add this to the clock binding wiki page.

Rob