From patchwork Fri Nov 27 08:31:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mugunthan V N X-Patchwork-Id: 549333 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id D99351402D5 for ; Fri, 27 Nov 2015 19:32:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 104264B91C; Fri, 27 Nov 2015 09:32:46 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1bTRVWO8jQSm; Fri, 27 Nov 2015 09:32:45 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5EFA54B90A; Fri, 27 Nov 2015 09:32:32 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9478C4B8F3 for ; Fri, 27 Nov 2015 09:32:23 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2JjfX3TdtANN for ; Fri, 27 Nov 2015 09:32:23 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by theia.denx.de (Postfix) with ESMTPS id 240DF4B8F1 for ; Fri, 27 Nov 2015 09:32:19 +0100 (CET) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id tAR8WEbj003954; Fri, 27 Nov 2015 02:32:14 -0600 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id tAR8WE4O020053; Fri, 27 Nov 2015 02:32:14 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.224.2; Fri, 27 Nov 2015 02:32:14 -0600 Received: from mugunthan-pc.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id tAR8W59R022948; Fri, 27 Nov 2015 02:32:12 -0600 From: Mugunthan V N To: Date: Fri, 27 Nov 2015 14:01:21 +0530 Message-ID: <1448613098-1579-3-git-send-email-mugunthanvnm@ti.com> X-Mailer: git-send-email 2.6.3.368.gf34be46 In-Reply-To: <1448613098-1579-1-git-send-email-mugunthanvnm@ti.com> References: <1448613098-1579-1-git-send-email-mugunthanvnm@ti.com> MIME-Version: 1.0 Cc: Tom Rini , Sekhar Nori Subject: [U-Boot] [PATCH 02/19] dm: timer: uclass: add timer init to add timer device X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Adding timer_init function 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 --- doc/device-tree-bindings/chosen.txt | 43 +++++++++++++++++++++++++++++++++++++ drivers/timer/timer-uclass.c | 34 +++++++++++++++++++++++++++++ lib/time.c | 5 +++++ 3 files changed, 82 insertions(+) create mode 100644 doc/device-tree-bindings/chosen.txt diff --git a/doc/device-tree-bindings/chosen.txt b/doc/device-tree-bindings/chosen.txt new file mode 100644 index 0000000..58f29f9 --- /dev/null +++ b/doc/device-tree-bindings/chosen.txt @@ -0,0 +1,43 @@ +The chosen node +--------------- +The chosen node does not represent a real device, but serves as a place +for passing data like which serial device to used to print the logs etc + + +stdout-path property +-------------------- +Device trees may specify the device to be used for boot console output +with a stdout-path property under /chosen. + +Example +------- +/ { + chosen { + stdout-path = "/serial@f00:115200"; + }; + + serial@f00 { + compatible = "vendor,some-uart"; + reg = <0xf00 0x10>; + }; +}; + +tick-timer property +------------------- +In a system there are multiple timers, specify which timer to be used +as the tick-timer. Earlier it was hardcoded in the timer driver now +since device tree has all the timer nodes. Specify which timer to be +used as tick timer. + +Example +------- +/ { + chosen { + tick-timer = &timer2; + }; + + timer2@f00 { + compatible = "vendor,some-uart"; + reg = <0xf00 0x10>; + }; +}; diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 12aee5b..78ec989 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -6,9 +6,13 @@ #include #include +#include +#include #include #include +DECLARE_GLOBAL_DATA_PTR; + /* * Implement a Timer uclass to work with lib/time.c. The timer is usually * a 32 bits free-running up counter. The get_rate() method is used to get @@ -35,6 +39,36 @@ unsigned long timer_get_rate(struct udevice *dev) return uc_priv->clock_rate; } +int timer_init(void) +{ + const void *blob = gd->fdt_blob; + struct udevice *dev; + int node; + + if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) { + /* Check for a chosen timer to be used for tick */ + node = fdtdec_get_chosen_node(blob, "tick-timer"); + if (node < 0) + return -ENODEV; + + 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)) { + int ret = device_probe(dev); + if (ret) + return ret; + } + } + } + + gd->timer = dev; + return 0; +} + UCLASS_DRIVER(timer) = { .id = UCLASS_TIMER, .name = "timer", diff --git a/lib/time.c b/lib/time.c index b001745..22f7d23 100644 --- a/lib/time.c +++ b/lib/time.c @@ -47,6 +47,11 @@ static int notrace dm_timer_init(void) int ret; if (!gd->timer) { + /* Check if we have a chosen timer */ + timer_init(); + if (gd->timer) + return 0; + ret = uclass_first_device(UCLASS_TIMER, &dev); if (ret) return ret;