summaryrefslogtreecommitdiffstats
path: root/drivers/timer
diff options
context:
space:
mode:
authorMugunthan V N <mugunthanvnm@ti.com>2016-01-16 21:33:58 +0530
committerSimon Glass <sjg@chromium.org>2016-01-20 19:06:21 -0700
commitc8336975381d481829e3e6a81c38cd118826ca03 (patch)
treefae575cc1e4752a6a2272fd3607c1d124e1a1e5d /drivers/timer
parent28a6c01187d30f0e7b7dbe6e4e198e76ce6246f1 (diff)
downloadblackbird-obmc-uboot-c8336975381d481829e3e6a81c38cd118826ca03.tar.gz
blackbird-obmc-uboot-c8336975381d481829e3e6a81c38cd118826ca03.zip
dm: timer: uclass: add timer init in uclass driver to add timer device
Adding timer init function in timer-uclass driver to create and initialize the timer device on platforms where u-boot,dm-pre-reloc is not used. Since there will be multiple timer devices in the system, adding a tick-timer node in chosen node to know which timer device to be used as tick timer in u-boot. Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Diffstat (limited to 'drivers/timer')
-rw-r--r--drivers/timer/timer-uclass.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index aca421bdea..04801784ba 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -6,6 +6,8 @@
#include <common.h>
#include <dm.h>
+#include <dm/lists.h>
+#include <dm/device-internal.h>
#include <errno.h>
#include <timer.h>
@@ -56,6 +58,48 @@ u64 timer_conv_64(u32 count)
return ((u64)gd->timebase_h << 32) | gd->timebase_l;
}
+int notrace dm_timer_init(void)
+{
+ const void *blob = gd->fdt_blob;
+ struct udevice *dev = NULL;
+ int node;
+ int ret;
+
+ if (gd->timer)
+ return 0;
+
+ /* Check for a chosen timer to be used for tick */
+ node = fdtdec_get_chosen_node(blob, "tick-timer");
+ if (node < 0) {
+ /* No chosen timer, trying first available timer */
+ ret = uclass_first_device(UCLASS_TIMER, &dev);
+ if (ret)
+ return ret;
+ if (!dev)
+ return -ENODEV;
+ } else {
+ if (uclass_get_device_by_of_offset(UCLASS_TIMER, node, &dev)) {
+ /*
+ * If the timer is not marked to be bound before
+ * relocation, bind it anyway.
+ */
+ if (node > 0 &&
+ !lists_bind_fdt(gd->dm_root, blob, node, &dev)) {
+ ret = device_probe(dev);
+ if (ret)
+ return ret;
+ }
+ }
+ }
+
+ if (dev) {
+ gd->timer = dev;
+ return 0;
+ }
+
+ return -ENODEV;
+}
+
UCLASS_DRIVER(timer) = {
.id = UCLASS_TIMER,
.name = "timer",
OpenPOWER on IntegriCloud