public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Mugunthan V N <mugunthanvnm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 02/19] dm: timer: uclass: add timer init to add timer device
Date: Sat, 28 Nov 2015 11:43:26 +0530	[thread overview]
Message-ID: <56594606.2090204@ti.com> (raw)
In-Reply-To: <CAPnjgZ2pJjePpfno-JEi9pEnXfkCYbnXvy+sE0Uxad2aD+ZT6w@mail.gmail.com>

On Saturday 28 November 2015 01:10 AM, Simon Glass wrote:
> Hi Mugunthan,
> 
> On 27 November 2015 at 00:31, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>> 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 <mugunthanvnm@ti.com>
>> ---
>>  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 at f00:115200";
>> +       };
>> +
>> +       serial at 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 at 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 <common.h>
>>  #include <dm.h>
>> +#include <dm/lists.h>
>> +#include <dm/device-internal.h>
>>  #include <errno.h>
>>  #include <timer.h>
>>
>> +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;
> 
> Please add a debug() here to help people diagnose problems.

timer_init is called even before we have serial_init in
common/board_f.c. So we don't have console yet to add debug logs.

> 
>> +
>> +               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)
> 
> debug()
> 
>> +                                       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;
> 
> This code should move up into the timer_init() function. So the sequence is:
> 
> - look for a device with 'chosen'
> - find the first device
> 

Will do it in v2.

Regards
Mugunthan V N

  reply	other threads:[~2015-11-28  6:13 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-27  8:31 [U-Boot] [PATCH 00/19] device model bring-up of omap timer on dra72, dra74, am335x and am437x-sk evm Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 01/19] arm: omap-common: do not build timer when CONFIG_TIMER defined Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 02/19] dm: timer: uclass: add timer init to add timer device Mugunthan V N
2015-11-27 19:40   ` Simon Glass
2015-11-28  6:13     ` Mugunthan V N [this message]
2015-11-28  8:26   ` Bin Meng
2015-11-28 11:38     ` Mugunthan V N
2015-11-28 11:46       ` Bin Meng
2015-11-29 13:16         ` Mugunthan V N
2015-12-01  2:39           ` Bin Meng
2015-12-02  9:29             ` Bin Meng
2015-12-02  9:50               ` Mugunthan V N
2015-12-10  1:48                 ` Bin Meng
2015-11-27  8:31 ` [U-Boot] [PATCH 03/19] dm: timer: uclass: Add flag to control sequence numbering Mugunthan V N
2015-11-27 19:40   ` Simon Glass
2015-11-28  8:30   ` Bin Meng
2015-11-27  8:31 ` [U-Boot] [PATCH 04/19] drivers: timer: omap_timer: add timer driver for omap devices based on dm Mugunthan V N
2015-11-28 11:52   ` Bin Meng
2015-11-29 13:19     ` Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 05/19] am43xx_evm: timer: do not define CONFIG_TIMER for spl Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 06/19] arm: dts: am437x-sk-evm: add tick-timer to chosen node Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 07/19] defconfig: am437x_sk_evm: enable timer driver model Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 08/19] arm: dts: am437x-gp-evm: add tick-timer to chosen node Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 09/19] defconfig: am437x_gp_evm: enable timer driver model Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 10/19] am335x_evm: timer: do not define CONFIG_TIMER for spl Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 11/19] arm: dts: am335x-boneblack: add tick-timer to chosen node Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 12/19] defconfig: am335x_boneblack_vboot: enable timer driver model Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 13/19] arm: dts: am335x-evm: add tick-timer to chosen node Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 14/19] defconfig: am335x_gp_evm: enable timer driver model Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 15/19] ti_omap5_common: timer: do not define CONFIG_TIMER for spl Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 16/19] arm: dts: dra72-evm: add tick-timer to chosen node Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 17/19] defconfig: dra72_evm: enable timer driver model Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 18/19] arm: dts: dra7-evm: add tick-timer to chosen node Mugunthan V N
2015-11-27  8:31 ` [U-Boot] [PATCH 19/19] defconfig: dra74_evm: enable timer driver model Mugunthan V N
2015-11-27 19:40 ` [U-Boot] [PATCH 00/19] device model bring-up of omap timer on dra72, dra74, am335x and am437x-sk evm Simon Glass
2015-11-28  6:15   ` Mugunthan V N

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=56594606.2090204@ti.com \
    --to=mugunthanvnm@ti.com \
    --cc=u-boot@lists.denx.de \
    /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