Re: [U-Boot] [PATCH v4 02/19] dm: timer: uclass: add timer init in uclass driver to add timer device

2016-01-17 Thread Simon Glass
Hi Mugunthan,

On 16 January 2016 at 09:51, Mugunthan V N  wrote:
> On Saturday 16 January 2016 10:11 PM, Simon Glass wrote:
>> Hi Mugunthan,
>>
>> On 16 January 2016 at 09:08, Mugunthan V N  wrote:
>>> On Saturday 16 January 2016 09:33 PM, Mugunthan V N wrote:
 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 
>>>
>>> Please drop this patch, will send a fixup patch as the series is already
>>> applied to u-boot-dm tree.
>>

>> You can send a new patch if you like and I can replace it. Either works for 
>> me.
>>
>
> Just sent a follow-up patch. Its good to not change the pushed history.

I actually do this all the time as I rebase against master before
testing and sending pull requests. It helps to avoid conflicts for Tom
to deal with.

So since you have given me two options, I've pick up this patch and
replaced the v3 patch with it. I checked that the effect is the same
as applying your fix-up. The patches were sitting around since
Christmas so I wanted to get them in to permit the maximum possible
testing window.

Applied to u-boot-dm, thanks!

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 02/19] dm: timer: uclass: add timer init in uclass driver to add timer device

2016-01-16 Thread Mugunthan V N
On Saturday 16 January 2016 09:33 PM, Mugunthan V N wrote:
> 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 

Please drop this patch, will send a fixup patch as the series is already
applied to u-boot-dm tree.

Regards
Mugunthan V N
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 02/19] dm: timer: uclass: add timer init in uclass driver to add timer device

2016-01-16 Thread Simon Glass
Hi Mugunthan,

On 16 January 2016 at 09:08, Mugunthan V N  wrote:
> On Saturday 16 January 2016 09:33 PM, Mugunthan V N wrote:
>> 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 
>
> Please drop this patch, will send a fixup patch as the series is already
> applied to u-boot-dm tree.

You can send a new patch if you like and I can replace it. Either works for me.

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 02/19] dm: timer: uclass: add timer init in uclass driver to add timer device

2016-01-16 Thread Mugunthan V N
On Saturday 16 January 2016 10:11 PM, Simon Glass wrote:
> Hi Mugunthan,
> 
> On 16 January 2016 at 09:08, Mugunthan V N  wrote:
>> On Saturday 16 January 2016 09:33 PM, Mugunthan V N wrote:
>>> 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 
>>
>> Please drop this patch, will send a fixup patch as the series is already
>> applied to u-boot-dm tree.
> 
> You can send a new patch if you like and I can replace it. Either works for 
> me.
> 

Just sent a follow-up patch. Its good to not change the pushed history.

Regards
Mugunthan V N

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v4 02/19] dm: timer: uclass: add timer init in uclass driver to add timer device

2016-01-16 Thread Mugunthan V N
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 
---
 doc/device-tree-bindings/chosen.txt | 43 
 drivers/timer/timer-uclass.c| 44 +
 include/timer.h |  9 
 lib/time.c  | 17 --
 4 files changed, 96 insertions(+), 17 deletions(-)
 create mode 100644 doc/device-tree-bindings/chosen.txt

Changes from v3:
* removed dm_timer_init() in lib/time.c as it doesn't add
  anything and simply calls uclass driver's init and also
  renamed timer_init() to dm_timer_init() as many platforms
  calls timer_init() before dm init.
* removed re-declaring of ret in dm_timer_init()

Tested this patch on DRA74x EVM  (logs [1]) with sleep 10 with
minicom timestamps and pushed a branch [2] for testing.

[1] - http://pastebin.ubuntu.com/14520385/
[2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dm-timer-v4

---

diff --git a/doc/device-tree-bindings/chosen.txt 
b/doc/device-tree-bindings/chosen.txt
new file mode 100644
index 000..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@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@f00";
+   };
+
+   timer2@f00 {
+   compatible = "vendor,some-timer";
+   reg = <0xf00 0x10>;
+   };
+};
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index aca421b..0480178 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -6,6 +6,8 @@
 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
@@ -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, );
+   if (ret)
+   return ret;
+   if (!dev)
+   return -ENODEV;
+   } else {
+   if (uclass_get_device_by_of_offset(UCLASS_TIMER, node, )) {
+   /*
+* 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, )) {
+   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",
diff --git a/include/timer.h b/include/timer.h
index 7fee17e..f14725c 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -8,6 +8,15 @@
 #define _TIMER_H_
 
 /*
+ * dm_timer_init - initialize a timer for time keeping. On success
+ * initializes gd->timer so that lib/timer can use it for future
+ * referrence.
+ *
+ * @return - 0 on success or error number
+ */
+int dm_timer_init(void);
+
+/*
  * timer_conv_64 - convert 32-bit counter value to 64-bit
  *
  * @count: 32-bit counter value
diff --git a/lib/time.c b/lib/time.c
index f37a662..e9f6861 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -41,23 +41,6 @@ extern unsigned long __weak timer_read_counter(void);