All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mugunthan V N <mugunthanvnm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 02/19] dm: timer: uclass: add timer init to add timer device
Date: Fri, 25 Dec 2015 18:38:51 +0530	[thread overview]
Message-ID: <567D3FE3.3080008@ti.com> (raw)
In-Reply-To: <CAEUhbmWkc=zx-1=0bCbCMbEV4Pw9AmOTwXZgQkyuuo+SuoJEbA@mail.gmail.com>

On Friday 25 December 2015 05:43 PM, Bin Meng wrote:
> Hi Mugunthan,
> 
> On Fri, Dec 25, 2015 at 6:41 PM, 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>
>> ---
>>
>> Submitting 02/19 only for v3 as there is no change on other
>> patches and to reduce traffic.
>>
>> This patch is verified on AM437x SK and DRA74 EVM logs [1] and
>> pushed a branch for testing
>>
>> [1] - http://pastebin.ubuntu.com/14205433/
>> [2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dm-timer-v3
>>
>> Changes from v2->v3:
>> * Fixed issue which is in v2 that if no chosen timer node is
>>   present in DT then timer init always fails without trying
>>   first available timer.
>>
>> ---
>>  doc/device-tree-bindings/chosen.txt | 43 +++++++++++++++++++++++++++++++++++++
>>  drivers/timer/timer-uclass.c        | 41 +++++++++++++++++++++++++++++++++++
>>  lib/time.c                          | 13 ++---------
>>  3 files changed, 86 insertions(+), 11 deletions(-)
>>  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..bf9a30a
>> --- /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 at f00";
>> +       };
>> +
>> +       timer2 at f00 {
>> +               compatible = "vendor,some-timer";
>> +               reg = <0xf00 0x10>;
>> +       };
>> +};
>> diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
>> index aca421b..b6699f2 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,45 @@ u64 timer_conv_64(u32 count)
>>         return ((u64)gd->timebase_h << 32) | gd->timebase_l;
>>  }
>>
>> +int timer_init(void)
>> +{
>> +       const void *blob = gd->fdt_blob;
>> +       struct udevice *dev = NULL;
>> +       int node;
>> +       int ret;
>> +
>> +       /* 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;
> 
> Thanks for the quick v3!
> 
>> +       } 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)) {
>> +                               int ret = device_probe(dev);
> 
> nits: no need to declare another ret. Just "ret = device_probe(dev)".

Hmmm, yep not needed.

> 
>> +                               if (ret)
>> +                                       return ret;
>> +                       }
>> +               }
>> +       }
>> +
>> +       if (dev) {
>> +               gd->timer = dev;
>> +               return 0;
>> +       }
>> +
>> +       return -ENODEV;
>> +}
>> +
>>  UCLASS_DRIVER(timer) = {
>>         .id             = UCLASS_TIMER,
>>         .name           = "timer",
>> diff --git a/lib/time.c b/lib/time.c
>> index f37a662..d4060f1 100644
>> --- a/lib/time.c
>> +++ b/lib/time.c
>> @@ -43,17 +43,8 @@ extern unsigned long __weak timer_read_counter(void);
>>  #ifdef CONFIG_TIMER
>>  static int notrace dm_timer_init(void)
>>  {
>> -       struct udevice *dev;
>> -       int ret;
>> -
>> -       if (!gd->timer) {
>> -               ret = uclass_first_device(UCLASS_TIMER, &dev);
>> -               if (ret)
>> -                       return ret;
>> -               if (!dev)
>> -                       return -ENODEV;
>> -               gd->timer = dev;
>> -       }
>> +       if (!gd->timer)
>> +               return timer_init();
> 
> What about my comments in v2, that make timer_init() static or just
> move codes in timer_init() into this dm_timer_init()?

Oops, missed :)

The timer_init() code can be moved to dm_timer_init(), but since it
provides timer uclass functionality I kept the code in timer-uclass driver.

Now since dm_timer_init() doesn't have any thing other than calling
timer_init, I will move the dm_timer_init() to timer_uclass and move
timer_init code to it.

Regards
Mugunthan V N

  reply	other threads:[~2015-12-25 13:08 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-24 10:38 [U-Boot] [PATCH v2 00/19] driver model bring-up of omap timer on dra72, dra74, am335x and am437x-sk evm Mugunthan V N
2015-12-24 10:38 ` [U-Boot] [PATCH v2 01/19] arm: omap-common: do not build timer when CONFIG_TIMER defined Mugunthan V N
2016-01-04 19:57   ` Tom Rini
2016-01-16  1:20     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 02/19] dm: timer: uclass: add timer init to add timer device Mugunthan V N
2015-12-25  2:10   ` Bin Meng
2015-12-25  7:08     ` Mugunthan V N
2015-12-25 10:41   ` [U-Boot] [PATCH v3 " Mugunthan V N
2015-12-25 12:13     ` Bin Meng
2015-12-25 13:08       ` Mugunthan V N [this message]
2016-01-16  1:20         ` Simon Glass
2016-01-16 16:03     ` [U-Boot] [PATCH v4 02/19] dm: timer: uclass: add timer init in uclass driver " Mugunthan V N
2016-01-16 16:08       ` Mugunthan V N
2016-01-16 16:41         ` Simon Glass
2016-01-16 16:51           ` Mugunthan V N
2016-01-18  3:58             ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 03/19] dm: timer: uclass: Add flag to control sequence numbering Mugunthan V N
2016-01-04 19:57   ` Tom Rini
2016-01-06  0:25   ` Simon Glass
2016-01-16  1:21     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 04/19] drivers: timer: omap_timer: add timer driver for omap devices based on dm Mugunthan V N
2016-01-04 19:57   ` Tom Rini
2016-01-16  1:21   ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 05/19] am43xx_evm: timer: do not define CONFIG_TIMER for spl Mugunthan V N
2016-01-04 19:57   ` Tom Rini
2016-01-16  1:21   ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 06/19] arm: dts: am437x-sk-evm: add tick-timer to chosen node Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22   ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 07/19] defconfig: am437x_sk_evm: enable timer driver model Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 08/19] arm: dts: am437x-gp-evm: add tick-timer to chosen node Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 09/19] defconfig: am437x_gp_evm: enable timer driver model Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 10/19] am335x_evm: timer: do not define CONFIG_TIMER for spl Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 11/19] arm: dts: am335x-boneblack: add tick-timer to chosen node Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 12/19] defconfig: am335x_boneblack_vboot: enable timer driver model Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 13/19] arm: dts: am335x-evm: add tick-timer to chosen node Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 14/19] defconfig: am335x_gp_evm: enable timer driver model Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 15/19] ti_omap5_common: timer: do not define CONFIG_TIMER for spl Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 16/19] arm: dts: dra72-evm: add tick-timer to chosen node Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 17/19] defconfig: dra72_evm: enable timer driver model Mugunthan V N
2016-01-04 19:58   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 18/19] arm: dts: dra7-evm: add tick-timer to chosen node Mugunthan V N
2016-01-04 19:59   ` Tom Rini
2016-01-16  1:22     ` Simon Glass
2015-12-24 10:38 ` [U-Boot] [PATCH v2 19/19] defconfig: dra74_evm: enable timer driver model Mugunthan V N
2016-01-04 19:59   ` Tom Rini
2016-01-16  1:22     ` Simon Glass

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=567D3FE3.3080008@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.