[U-Boot] [PATCH 00/19] device model bring-up of omap timer on dra72, dra74, am335x and am437x-sk evm

This patch series enables omap timer to adopt driver model. This has been tested on the following evms (logs [1]) by invoking 'sleep 10' command with minicom timestamps. * dra72 evm * dra74 evm * am335x evm * am335x bbb * am437x-sk evm * am437x-gp evm
Also pushed a branch for testing [2]
This patch series depends on [3] for chosen node in dra74 evm dts file.
[1] - http://pastebin.ubuntu.com/13524650/ [2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dm-timer [3] - https://www.mail-archive.com/u-boot@lists.denx.de/msg193763.html
Mugunthan V N (19): arm: omap-common: do not build timer when CONFIG_TIMER defined dm: timer: uclass: add timer init to add timer device dm: timer: uclass: Add flag to control sequence numbering drivers: timer: omap_timer: add timer driver for omap devices based on dm am43xx_evm: timer: do not define CONFIG_TIMER for spl arm: dts: am437x-sk-evm: add tick-timer to chosen node defconfig: am437x_sk_evm: enable timer driver model arm: dts: am437x-gp-evm: add tick-timer to chosen node defconfig: am437x_gp_evm: enable timer driver model am335x_evm: timer: do not define CONFIG_TIMER for spl arm: dts: am335x-boneblack: add tick-timer to chosen node defconfig: am335x_boneblack_vboot: enable timer driver model arm: dts: am335x-evm: add tick-timer to chosen node defconfig: am335x_gp_evm: enable timer driver model ti_omap5_common: timer: do not define CONFIG_TIMER for spl arm: dts: dra72-evm: add tick-timer to chosen node defconfig: dra72_evm: enable timer driver model arm: dts: dra7-evm: add tick-timer to chosen node defconfig: dra74_evm: enable timer driver model
arch/arm/cpu/armv7/omap-common/Makefile | 6 ++ arch/arm/dts/am335x-boneblack.dts | 1 + arch/arm/dts/am335x-evm.dts | 1 + arch/arm/dts/am437x-gp-evm.dts | 1 + arch/arm/dts/am437x-sk-evm.dts | 1 + arch/arm/dts/dra7-evm.dts | 1 + arch/arm/dts/dra72-evm.dts | 1 + configs/am335x_boneblack_vboot_defconfig | 2 + configs/am335x_gp_evm_defconfig | 2 + configs/am437x_gp_evm_defconfig | 2 + configs/am437x_sk_evm_defconfig | 2 + configs/dra72_evm_defconfig | 2 + configs/dra74_evm_defconfig | 2 + doc/device-tree-bindings/chosen.txt | 43 ++++++++++++ drivers/timer/Kconfig | 6 ++ drivers/timer/Makefile | 1 + drivers/timer/omap-timer.c | 108 +++++++++++++++++++++++++++++++ drivers/timer/timer-uclass.c | 35 ++++++++++ include/configs/am335x_evm.h | 1 + include/configs/am43xx_evm.h | 1 + include/configs/ti_omap5_common.h | 1 + lib/time.c | 5 ++ 22 files changed, 225 insertions(+) create mode 100644 doc/device-tree-bindings/chosen.txt create mode 100644 drivers/timer/omap-timer.c

To prepare timer driver to DM/DT conversion do not build the exiting timer driver when CONFIG_TIMER is defined. But since omap's SPL doesn't support DM yet so built timer driver only for SPL build when CONFIG_TIMER is defined.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- arch/arm/cpu/armv7/omap-common/Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile index 464a5d1..87a7ac0 100644 --- a/arch/arm/cpu/armv7/omap-common/Makefile +++ b/arch/arm/cpu/armv7/omap-common/Makefile @@ -6,7 +6,13 @@ #
obj-y := reset.o +ifeq ($(CONFIG_TIMER),) obj-y += timer.o +else +ifdef CONFIG_SPL_BUILD +obj-y += timer.o +endif +endif obj-y += utils.o
ifneq ($(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),)

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@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 <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; + + 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;

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@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 <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.
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
Regards, Simon

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@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 <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

Hi Mugunthan,
On Fri, Nov 27, 2015 at 4:31 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
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;
I believe this is a wrong device tree syntax as timer2 is not a label.
};
timer2@f00 {
compatible = "vendor,some-uart";
some-timer
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)
This introduces a timer_init() which won't build for x86 as x86 has a timer_init() already.
+{
const void *blob = gd->fdt_blob;
struct udevice *dev;
int node;
if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
Why do we need this if check? I think it can be removed.
/* 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();
timer_init() is already called in board_r.c. Can we avoid duplicate calls? Maybe we should remove the call in board_r.c for DM.
if (gd->timer)
return 0;
ret = uclass_first_device(UCLASS_TIMER, &dev); if (ret) return ret;
--
Regards, Bin

On Saturday 28 November 2015 01:56 PM, Bin Meng wrote:
Hi Mugunthan,
On Fri, Nov 27, 2015 at 4:31 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
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;
I believe this is a wrong device tree syntax as timer2 is not a label.
Will fix it in next version.
};
timer2@f00 {
compatible = "vendor,some-uart";
some-timer
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)
This introduces a timer_init() which won't build for x86 as x86 has a timer_init() already.
You mean init_timer() in arch/x86/lib/tsc_timer.c, once x86 timer is converted to driver model the init_timer() should be removed. Similar init_timer() is also present in omap as well, but with patch 01 of this series timer driver is removed from build when CONFIG_TIMER is defined in defconfig.
+{
const void *blob = gd->fdt_blob;
struct udevice *dev;
int node;
if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
Why do we need this if check? I think it can be removed.
/* 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();
timer_init() is already called in board_r.c. Can we avoid duplicate calls? Maybe we should remove the call in board_r.c for DM.
from board_r.c, timer_init is added only for MICROBLAZE, AVR32 and M68K architectures. May be those who work on these architectures can initiate of this removal during timer dm conversion.
Regards Mugunthan V N

Hi Mugunthan,
On Sat, Nov 28, 2015 at 7:38 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
On Saturday 28 November 2015 01:56 PM, Bin Meng wrote:
Hi Mugunthan,
On Fri, Nov 27, 2015 at 4:31 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
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;
I believe this is a wrong device tree syntax as timer2 is not a label.
Will fix it in next version.
};
timer2@f00 {
compatible = "vendor,some-uart";
some-timer
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)
This introduces a timer_init() which won't build for x86 as x86 has a timer_init() already.
You mean init_timer() in arch/x86/lib/tsc_timer.c, once x86 timer is converted to driver model the init_timer() should be removed. Similar
x86 timer has already been converted to driver model. Please rebase your series on top of dm/master and you can see the converted driver there.
init_timer() is also present in omap as well, but with patch 01 of this series timer driver is removed from build when CONFIG_TIMER is defined in defconfig.
Yes, but your patch 01 will break x86. I can prepare a patch for x86 if you like.
+{
const void *blob = gd->fdt_blob;
struct udevice *dev;
int node;
if (CONFIG_IS_ENABLED(OF_CONTROL) && blob) {
Why do we need this if check? I think it can be removed.
/* 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();
timer_init() is already called in board_r.c. Can we avoid duplicate calls? Maybe we should remove the call in board_r.c for DM.
from board_r.c, timer_init is added only for MICROBLAZE, AVR32 and M68K architectures. May be those who work on these architectures can initiate of this removal during timer dm conversion.
Regards, Bin

On Saturday 28 November 2015 05:16 PM, Bin Meng wrote:
Yes, but your patch 01 will break x86. I can prepare a patch for x86 if you like
Can you send the patch so that I can include it on my next series.
Regards Mugunthan V N

Hi Mugunthan,
On Sun, Nov 29, 2015 at 9:16 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
On Saturday 28 November 2015 05:16 PM, Bin Meng wrote:
Yes, but your patch 01 will break x86. I can prepare a patch for x86 if you like
Can you send the patch so that I can include it on my next series.
Sure, I will prepare a patch for x86 soon.
Regards Mugunthan V N
Regards, Bin

Hi Mugunthan,
On Tue, Dec 1, 2015 at 10:39 AM, Bin Meng bmeng.cn@gmail.com wrote:
Hi Mugunthan,
On Sun, Nov 29, 2015 at 9:16 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
On Saturday 28 November 2015 05:16 PM, Bin Meng wrote:
Yes, but your patch 01 will break x86. I can prepare a patch for x86 if you like
Can you send the patch so that I can include it on my next series.
Sure, I will prepare a patch for x86 soon.
Please check my x86 patch @ http://patchwork.ozlabs.org/patch/551259/
Feel free to create your v2 on top of mine, or just include mine in your v2.
Regards, Bin

On Wednesday 02 December 2015 02:59 PM, Bin Meng wrote:
Hi Mugunthan,
On Tue, Dec 1, 2015 at 10:39 AM, Bin Meng bmeng.cn@gmail.com wrote:
Hi Mugunthan,
On Sun, Nov 29, 2015 at 9:16 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
On Saturday 28 November 2015 05:16 PM, Bin Meng wrote:
Yes, but your patch 01 will break x86. I can prepare a patch for x86 if you like
Can you send the patch so that I can include it on my next series.
Sure, I will prepare a patch for x86 soon.
Please check my x86 patch @ http://patchwork.ozlabs.org/patch/551259/
Feel free to create your v2 on top of mine, or just include mine in your v2.
Thanks, will pick your patch for v2 series.
Regards Mugunthan V N

Hi Mugunthan,
On Wed, Dec 2, 2015 at 5:50 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
On Wednesday 02 December 2015 02:59 PM, Bin Meng wrote:
Hi Mugunthan,
On Tue, Dec 1, 2015 at 10:39 AM, Bin Meng bmeng.cn@gmail.com wrote:
Hi Mugunthan,
On Sun, Nov 29, 2015 at 9:16 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
On Saturday 28 November 2015 05:16 PM, Bin Meng wrote:
Yes, but your patch 01 will break x86. I can prepare a patch for x86 if you like
Can you send the patch so that I can include it on my next series.
Sure, I will prepare a patch for x86 soon.
Please check my x86 patch @ http://patchwork.ozlabs.org/patch/551259/
Feel free to create your v2 on top of mine, or just include mine in your v2.
Thanks, will pick your patch for v2 series.
Just let you know my patches are in mainline.
Regards, Bin

Like SPI and I2C, timer devices also have multiple chip instances. This patch adds the flag 'DM_UC_FLAG_SEQ_ALIAS' in timer_uclass driver to control device sequence numbering.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- drivers/timer/timer-uclass.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 78ec989..5840cb4 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -72,5 +72,6 @@ int timer_init(void) UCLASS_DRIVER(timer) = { .id = UCLASS_TIMER, .name = "timer", + .flags = DM_UC_FLAG_SEQ_ALIAS, .per_device_auto_alloc_size = sizeof(struct timer_dev_priv), };

On 27 November 2015 at 00:31, Mugunthan V N mugunthanvnm@ti.com wrote:
Like SPI and I2C, timer devices also have multiple chip instances. This patch adds the flag 'DM_UC_FLAG_SEQ_ALIAS' in timer_uclass driver to control device sequence numbering.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com
drivers/timer/timer-uclass.c | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Fri, Nov 27, 2015 at 4:31 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
Like SPI and I2C, timer devices also have multiple chip instances. This patch adds the flag 'DM_UC_FLAG_SEQ_ALIAS' in timer_uclass driver to control device sequence numbering.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com
drivers/timer/timer-uclass.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c index 78ec989..5840cb4 100644 --- a/drivers/timer/timer-uclass.c +++ b/drivers/timer/timer-uclass.c @@ -72,5 +72,6 @@ int timer_init(void) UCLASS_DRIVER(timer) = { .id = UCLASS_TIMER, .name = "timer",
.flags = DM_UC_FLAG_SEQ_ALIAS, .per_device_auto_alloc_size = sizeof(struct timer_dev_priv),
};
Reviewed-by: Bin Meng bmeng.cn@gmail.com

Adding a timer driver for omap devices based on driver model and device tree.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- drivers/timer/Kconfig | 6 +++ drivers/timer/Makefile | 1 + drivers/timer/omap-timer.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/timer/omap-timer.c
diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig index 601e493..98ba012 100644 --- a/drivers/timer/Kconfig +++ b/drivers/timer/Kconfig @@ -23,4 +23,10 @@ config SANDBOX_TIMER Select this to enable an emulated timer for sandbox. It gets time from host os.
+config OMAP_TIMER + bool "Omap Timer support" + depends on TIMER + help + Select this to enable an timer for Omap devices. + endmenu diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile index 300946e..2eb9cfc 100644 --- a/drivers/timer/Makefile +++ b/drivers/timer/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_TIMER) += timer-uclass.o obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o obj-$(CONFIG_SANDBOX_TIMER) += sandbox_timer.o +obj-$(CONFIG_OMAP_TIMER) += omap-timer.o diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c new file mode 100644 index 0000000..2532e74 --- /dev/null +++ b/drivers/timer/omap-timer.c @@ -0,0 +1,108 @@ +/* + * TI OMAP Timer driver + * + * Copyright (C) 2015, Texas Instruments, Incorporated + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <timer.h> +#include <asm/io.h> +#include <asm/arch/clock.h> + +DECLARE_GLOBAL_DATA_PTR; + +/* Timer register bits */ +#define TCLR_START BIT(0) /* Start=1 */ +#define TCLR_AUTO_RELOAD BIT(1) /* Auto reload */ +#define TCLR_PRE_EN BIT(5) /* Pre-scaler enable */ +#define TCLR_PTV_SHIFT (2) /* Pre-scaler shift value */ + +#define TIMER_CLOCK (V_SCLK / (2 << CONFIG_SYS_PTV)) + +struct omap_gptimer_regs { + unsigned int tidr; /* offset 0x00 */ + unsigned char res1[12]; + unsigned int tiocp_cfg; /* offset 0x10 */ + unsigned char res2[12]; + unsigned int tier; /* offset 0x20 */ + unsigned int tistatr; /* offset 0x24 */ + unsigned int tistat; /* offset 0x28 */ + unsigned int tisr; /* offset 0x2c */ + unsigned int tcicr; /* offset 0x30 */ + unsigned int twer; /* offset 0x34 */ + unsigned int tclr; /* offset 0x38 */ + unsigned int tcrr; /* offset 0x3c */ + unsigned int tldr; /* offset 0x40 */ + unsigned int ttgr; /* offset 0x44 */ + unsigned int twpc; /* offset 0x48 */ + unsigned int tmar; /* offset 0x4c */ + unsigned int tcar1; /* offset 0x50 */ + unsigned int tscir; /* offset 0x54 */ + unsigned int tcar2; /* offset 0x58 */ +}; + +/* Omap Timer Priv */ +struct omap_timer_priv { + struct omap_gptimer_regs *regs; +}; + +static int omap_timer_get_count(struct udevice *dev, unsigned long *count) +{ + struct omap_timer_priv *priv = dev_get_priv(dev); + + *count = readl(&priv->regs->tcrr); + + return 0; +} + +static int omap_timer_probe(struct udevice *dev) +{ + struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev); + struct omap_timer_priv *priv = dev_get_priv(dev); + + uc_priv->clock_rate = TIMER_CLOCK; + + /* start the counter ticking up, reload value on overflow */ + writel(0, &priv->regs->tldr); + /* enable timer */ + writel((CONFIG_SYS_PTV << 2) | TCLR_PRE_EN | TCLR_AUTO_RELOAD | + TCLR_START, &priv->regs->tclr); + + return 0; +} + +static int omap_timer_ofdata_to_platdata(struct udevice *dev) +{ + struct omap_timer_priv *priv = dev_get_priv(dev); + + priv->regs = (struct omap_gptimer_regs *)dev_get_addr(dev); + + return 0; +} + + +static const struct timer_ops omap_timer_ops = { + .get_count = omap_timer_get_count, +}; + +static const struct udevice_id omap_timer_ids[] = { + { .compatible = "ti,am335x-timer" }, + { .compatible = "ti,am4372-timer" }, + { .compatible = "ti,omap5430-timer" }, + {} +}; + +U_BOOT_DRIVER(omap_timer) = { + .name = "omap_timer", + .id = UCLASS_TIMER, + .of_match = omap_timer_ids, + .ofdata_to_platdata = omap_timer_ofdata_to_platdata, + .priv_auto_alloc_size = sizeof(struct omap_timer_priv), + .probe = omap_timer_probe, + .ops = &omap_timer_ops, + .flags = DM_FLAG_PRE_RELOC, +};

Hi Mugunthan,
On Fri, Nov 27, 2015 at 4:31 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
Adding a timer driver for omap devices based on driver model and device tree.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com
drivers/timer/Kconfig | 6 +++ drivers/timer/Makefile | 1 + drivers/timer/omap-timer.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/timer/omap-timer.c
diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig index 601e493..98ba012 100644 --- a/drivers/timer/Kconfig +++ b/drivers/timer/Kconfig @@ -23,4 +23,10 @@ config SANDBOX_TIMER Select this to enable an emulated timer for sandbox. It gets time from host os.
+config OMAP_TIMER
bool "Omap Timer support"
nits: Timer -> timer. Please see dm/master branch which has a commit to fix all these nits in the existing timer drivers.
depends on TIMER
help
Select this to enable an timer for Omap devices.
endmenu diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile index 300946e..2eb9cfc 100644 --- a/drivers/timer/Makefile +++ b/drivers/timer/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_TIMER) += timer-uclass.o obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o obj-$(CONFIG_SANDBOX_TIMER) += sandbox_timer.o +obj-$(CONFIG_OMAP_TIMER) += omap-timer.o diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c new file mode 100644 index 0000000..2532e74 --- /dev/null +++ b/drivers/timer/omap-timer.c @@ -0,0 +1,108 @@ +/*
- TI OMAP Timer driver
nits: Timer -> timer
- Copyright (C) 2015, Texas Instruments, Incorporated
- SPDX-License-Identifier: GPL-2.0+
- */
+#include <common.h> +#include <dm.h> +#include <errno.h> +#include <timer.h> +#include <asm/io.h> +#include <asm/arch/clock.h>
+DECLARE_GLOBAL_DATA_PTR;
+/* Timer register bits */ +#define TCLR_START BIT(0) /* Start=1 */ +#define TCLR_AUTO_RELOAD BIT(1) /* Auto reload */ +#define TCLR_PRE_EN BIT(5) /* Pre-scaler enable */ +#define TCLR_PTV_SHIFT (2) /* Pre-scaler shift value */
+#define TIMER_CLOCK (V_SCLK / (2 << CONFIG_SYS_PTV))
+struct omap_gptimer_regs {
unsigned int tidr; /* offset 0x00 */
unsigned char res1[12];
unsigned int tiocp_cfg; /* offset 0x10 */
unsigned char res2[12];
unsigned int tier; /* offset 0x20 */
unsigned int tistatr; /* offset 0x24 */
unsigned int tistat; /* offset 0x28 */
unsigned int tisr; /* offset 0x2c */
unsigned int tcicr; /* offset 0x30 */
unsigned int twer; /* offset 0x34 */
unsigned int tclr; /* offset 0x38 */
unsigned int tcrr; /* offset 0x3c */
unsigned int tldr; /* offset 0x40 */
unsigned int ttgr; /* offset 0x44 */
unsigned int twpc; /* offset 0x48 */
unsigned int tmar; /* offset 0x4c */
unsigned int tcar1; /* offset 0x50 */
unsigned int tscir; /* offset 0x54 */
unsigned int tcar2; /* offset 0x58 */
+};
+/* Omap Timer Priv */ +struct omap_timer_priv {
struct omap_gptimer_regs *regs;
+};
+static int omap_timer_get_count(struct udevice *dev, unsigned long *count)
Please rebase your series on top of dm/master, where this API parameter 'count' has been changed to u64.
+{
struct omap_timer_priv *priv = dev_get_priv(dev);
*count = readl(&priv->regs->tcrr);
return 0;
+}
+static int omap_timer_probe(struct udevice *dev) +{
struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
struct omap_timer_priv *priv = dev_get_priv(dev);
uc_priv->clock_rate = TIMER_CLOCK;
/* start the counter ticking up, reload value on overflow */
writel(0, &priv->regs->tldr);
/* enable timer */
writel((CONFIG_SYS_PTV << 2) | TCLR_PRE_EN | TCLR_AUTO_RELOAD |
TCLR_START, &priv->regs->tclr);
return 0;
+}
+static int omap_timer_ofdata_to_platdata(struct udevice *dev) +{
struct omap_timer_priv *priv = dev_get_priv(dev);
priv->regs = (struct omap_gptimer_regs *)dev_get_addr(dev);
return 0;
+}
+static const struct timer_ops omap_timer_ops = {
.get_count = omap_timer_get_count,
+};
+static const struct udevice_id omap_timer_ids[] = {
{ .compatible = "ti,am335x-timer" },
{ .compatible = "ti,am4372-timer" },
{ .compatible = "ti,omap5430-timer" },
{}
+};
+U_BOOT_DRIVER(omap_timer) = {
.name = "omap_timer",
.id = UCLASS_TIMER,
.of_match = omap_timer_ids,
.ofdata_to_platdata = omap_timer_ofdata_to_platdata,
.priv_auto_alloc_size = sizeof(struct omap_timer_priv),
.probe = omap_timer_probe,
.ops = &omap_timer_ops,
.flags = DM_FLAG_PRE_RELOC,
+};
Regards, Bin

On Saturday 28 November 2015 05:22 PM, Bin Meng wrote:
Hi Mugunthan,
On Fri, Nov 27, 2015 at 4:31 PM, Mugunthan V N mugunthanvnm@ti.com wrote:
Adding a timer driver for omap devices based on driver model and device tree.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com
drivers/timer/Kconfig | 6 +++ drivers/timer/Makefile | 1 + drivers/timer/omap-timer.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 drivers/timer/omap-timer.c
diff --git a/drivers/timer/Kconfig b/drivers/timer/Kconfig index 601e493..98ba012 100644 --- a/drivers/timer/Kconfig +++ b/drivers/timer/Kconfig @@ -23,4 +23,10 @@ config SANDBOX_TIMER Select this to enable an emulated timer for sandbox. It gets time from host os.
+config OMAP_TIMER
bool "Omap Timer support"
nits: Timer -> timer. Please see dm/master branch which has a commit to fix all these nits in the existing timer drivers.
Will fix it in next revision
depends on TIMER
help
Select this to enable an timer for Omap devices.
endmenu diff --git a/drivers/timer/Makefile b/drivers/timer/Makefile index 300946e..2eb9cfc 100644 --- a/drivers/timer/Makefile +++ b/drivers/timer/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_TIMER) += timer-uclass.o obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o obj-$(CONFIG_SANDBOX_TIMER) += sandbox_timer.o +obj-$(CONFIG_OMAP_TIMER) += omap-timer.o diff --git a/drivers/timer/omap-timer.c b/drivers/timer/omap-timer.c new file mode 100644 index 0000000..2532e74 --- /dev/null +++ b/drivers/timer/omap-timer.c @@ -0,0 +1,108 @@ +/*
- TI OMAP Timer driver
nits: Timer -> timer
- Copyright (C) 2015, Texas Instruments, Incorporated
- SPDX-License-Identifier: GPL-2.0+
- */
+#include <common.h> +#include <dm.h> +#include <errno.h> +#include <timer.h> +#include <asm/io.h> +#include <asm/arch/clock.h>
+DECLARE_GLOBAL_DATA_PTR;
+/* Timer register bits */ +#define TCLR_START BIT(0) /* Start=1 */ +#define TCLR_AUTO_RELOAD BIT(1) /* Auto reload */ +#define TCLR_PRE_EN BIT(5) /* Pre-scaler enable */ +#define TCLR_PTV_SHIFT (2) /* Pre-scaler shift value */
+#define TIMER_CLOCK (V_SCLK / (2 << CONFIG_SYS_PTV))
+struct omap_gptimer_regs {
unsigned int tidr; /* offset 0x00 */
unsigned char res1[12];
unsigned int tiocp_cfg; /* offset 0x10 */
unsigned char res2[12];
unsigned int tier; /* offset 0x20 */
unsigned int tistatr; /* offset 0x24 */
unsigned int tistat; /* offset 0x28 */
unsigned int tisr; /* offset 0x2c */
unsigned int tcicr; /* offset 0x30 */
unsigned int twer; /* offset 0x34 */
unsigned int tclr; /* offset 0x38 */
unsigned int tcrr; /* offset 0x3c */
unsigned int tldr; /* offset 0x40 */
unsigned int ttgr; /* offset 0x44 */
unsigned int twpc; /* offset 0x48 */
unsigned int tmar; /* offset 0x4c */
unsigned int tcar1; /* offset 0x50 */
unsigned int tscir; /* offset 0x54 */
unsigned int tcar2; /* offset 0x58 */
+};
+/* Omap Timer Priv */ +struct omap_timer_priv {
struct omap_gptimer_regs *regs;
+};
+static int omap_timer_get_count(struct udevice *dev, unsigned long *count)
Please rebase your series on top of dm/master, where this API parameter 'count' has been changed to u64.
Hmmm, will rebase to dm/master and submit my next revision.
Regards Mugunthan V N

Since OMAP's spl doesn't support DM currently, do not define CONFIG_TIMER for spl build.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- include/configs/am43xx_evm.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h index aac550a..9980203 100644 --- a/include/configs/am43xx_evm.h +++ b/include/configs/am43xx_evm.h @@ -142,6 +142,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_TIMER #endif
#ifndef CONFIG_SPL_BUILD

Specify timer2 to be used as tick-timer in chosen node.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- arch/arm/dts/am437x-sk-evm.dts | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/am437x-sk-evm.dts b/arch/arm/dts/am437x-sk-evm.dts index 3f9d808..85d3381 100644 --- a/arch/arm/dts/am437x-sk-evm.dts +++ b/arch/arm/dts/am437x-sk-evm.dts @@ -26,6 +26,7 @@
chosen { stdout-path = &uart0; + tick-timer = &timer2; };
backlight {

Enable timer driver model for am437x_sk_evm as omap-timer supports driver model.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- configs/am437x_sk_evm_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/configs/am437x_sk_evm_defconfig b/configs/am437x_sk_evm_defconfig index a9b6f52..56a7b11 100644 --- a/configs/am437x_sk_evm_defconfig +++ b/configs/am437x_sk_evm_defconfig @@ -18,3 +18,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_MACRONIX=y CONFIG_SYS_NS16550=y CONFIG_TI_QSPI=y +CONFIG_TIMER=y +CONFIG_OMAP_TIMER=y

Specify timer2 to be used as tick-timer in chosen node.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- arch/arm/dts/am437x-gp-evm.dts | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/am437x-gp-evm.dts b/arch/arm/dts/am437x-gp-evm.dts index b5f0b4e..8e23b96 100644 --- a/arch/arm/dts/am437x-gp-evm.dts +++ b/arch/arm/dts/am437x-gp-evm.dts @@ -26,6 +26,7 @@
chosen { stdout-path = &uart0; + tick-timer = &timer2; };
vmmcsd_fixed: fixedregulator-sd {

Enable timer driver model for am437x_gp_evm as omap-timer supports driver model.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- configs/am437x_gp_evm_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/configs/am437x_gp_evm_defconfig b/configs/am437x_gp_evm_defconfig index 7155c98..1d79ba19 100644 --- a/configs/am437x_gp_evm_defconfig +++ b/configs/am437x_gp_evm_defconfig @@ -18,3 +18,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_MACRONIX=y CONFIG_SYS_NS16550=y CONFIG_TI_QSPI=y +CONFIG_TIMER=y +CONFIG_OMAP_TIMER=y

Since OMAP's spl doesn't support DM currently, do not define CONFIG_TIMER for spl build.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- include/configs/am335x_evm.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index c51db8c..d93fdf1 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -361,6 +361,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_TIMER #endif
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_USBETH_SUPPORT)

Specify timer2 to be used as tick-timer in chosen node.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- arch/arm/dts/am335x-boneblack.dts | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/am335x-boneblack.dts b/arch/arm/dts/am335x-boneblack.dts index 679248a..27ebe4a 100644 --- a/arch/arm/dts/am335x-boneblack.dts +++ b/arch/arm/dts/am335x-boneblack.dts @@ -15,6 +15,7 @@ compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx"; chosen { stdout-path = &uart0; + tick-timer = &timer2; }; };

Enable timer driver model for am335x_boneblack_vboot as omap-timer supports driver model.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- configs/am335x_boneblack_vboot_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig index ad40b07..888d5b1 100644 --- a/configs/am335x_boneblack_vboot_defconfig +++ b/configs/am335x_boneblack_vboot_defconfig @@ -18,3 +18,5 @@ CONFIG_SPI_FLASH=y CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y CONFIG_SYS_NS16550=y +CONFIG_TIMER=y +CONFIG_OMAP_TIMER=y

Specify timer2 to be used as tick-timer in chosen node.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- arch/arm/dts/am335x-evm.dts | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/am335x-evm.dts b/arch/arm/dts/am335x-evm.dts index e1c5d4f..c0bc2af 100644 --- a/arch/arm/dts/am335x-evm.dts +++ b/arch/arm/dts/am335x-evm.dts @@ -16,6 +16,7 @@
chosen { stdout-path = &uart0; + tick-timer = &timer2; };
cpus {

Enable timer driver model for am335x_gp_evm as omap-timer supports driver model.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- configs/am335x_gp_evm_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/configs/am335x_gp_evm_defconfig b/configs/am335x_gp_evm_defconfig index 74d9ffb..49461e2 100644 --- a/configs/am335x_gp_evm_defconfig +++ b/configs/am335x_gp_evm_defconfig @@ -16,3 +16,5 @@ CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y CONFIG_SYS_NS16550=y CONFIG_RSA=y +CONFIG_TIMER=y +CONFIG_OMAP_TIMER=y

Since OMAP's spl doesn't support DM currently, do not define CONFIG_TIMER for spl build.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- include/configs/ti_omap5_common.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/ti_omap5_common.h b/include/configs/ti_omap5_common.h index 2d492f8..d164e6a 100644 --- a/include/configs/ti_omap5_common.h +++ b/include/configs/ti_omap5_common.h @@ -164,6 +164,7 @@ */ #ifdef CONFIG_SPL_BUILD #undef CONFIG_DM_MMC +#undef CONFIG_TIMER #endif
#endif /* __CONFIG_TI_OMAP5_COMMON_H */

Specify timer2 to be used as tick-timer in chosen node.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- arch/arm/dts/dra72-evm.dts | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/dra72-evm.dts b/arch/arm/dts/dra72-evm.dts index efb544c..6e3bbfd 100644 --- a/arch/arm/dts/dra72-evm.dts +++ b/arch/arm/dts/dra72-evm.dts @@ -16,6 +16,7 @@
chosen { stdout-path = &uart1; + tick-timer = &timer2; };
memory {

Enable timer driver model for dra72_evm_defconfig as omap-timer supports driver model.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- configs/dra72_evm_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/configs/dra72_evm_defconfig b/configs/dra72_evm_defconfig index 3205bd5..530a25e 100644 --- a/configs/dra72_evm_defconfig +++ b/configs/dra72_evm_defconfig @@ -20,3 +20,5 @@ CONFIG_SPI_FLASH_BAR=y CONFIG_SPI_FLASH_SPANSION=y CONFIG_SYS_NS16550=y CONFIG_TI_QSPI=y +CONFIG_TIMER=y +CONFIG_OMAP_TIMER=y

Specify timer2 to be used as tick-timer in chosen node.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- arch/arm/dts/dra7-evm.dts | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/dts/dra7-evm.dts b/arch/arm/dts/dra7-evm.dts index e4daa99..2568aad 100644 --- a/arch/arm/dts/dra7-evm.dts +++ b/arch/arm/dts/dra7-evm.dts @@ -16,6 +16,7 @@
chosen { stdout-path = &uart1; + tick-timer = &timer2; };
memory {

Enable timer driver model for dra74_evm_defconfig as omap-timer supports driver model.
Signed-off-by: Mugunthan V N mugunthanvnm@ti.com --- configs/dra74_evm_defconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/configs/dra74_evm_defconfig b/configs/dra74_evm_defconfig index 394edbe..a68870e 100644 --- a/configs/dra74_evm_defconfig +++ b/configs/dra74_evm_defconfig @@ -19,3 +19,5 @@ CONFIG_SPI_FLASH_SPANSION=y CONFIG_DM_SERIAL=y CONFIG_SYS_NS16550=y CONFIG_TI_QSPI=y +CONFIG_TIMER=y +CONFIG_OMAP_TIMER=y

Hi Mugunthan,
On 27 November 2015 at 00:31, Mugunthan V N mugunthanvnm@ti.com wrote:
This patch series enables omap timer to adopt driver model. This has been tested on the following evms (logs [1]) by invoking 'sleep 10' command with minicom timestamps.
- dra72 evm
- dra74 evm
- am335x evm
- am335x bbb
- am437x-sk evm
- am437x-gp evm
Also pushed a branch for testing [2]
This patch series depends on [3] for chosen node in dra74 evm dts file.
[1] - http://pastebin.ubuntu.com/13524650/ [2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dm-timer [3] - https://www.mail-archive.com/u-boot@lists.denx.de/msg193763.html
Just a nit - your cover letter subject says 'device model'. Mostly we call it 'driver model'. This is somewhat arbitrary but it's good to be consistent to avoid confusion, so if you end up resending this series, can you rename it?
Regards, Simon

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:
This patch series enables omap timer to adopt driver model. This has been tested on the following evms (logs [1]) by invoking 'sleep 10' command with minicom timestamps.
- dra72 evm
- dra74 evm
- am335x evm
- am335x bbb
- am437x-sk evm
- am437x-gp evm
Also pushed a branch for testing [2]
This patch series depends on [3] for chosen node in dra74 evm dts file.
[1] - http://pastebin.ubuntu.com/13524650/ [2] - git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git dm-timer [3] - https://www.mail-archive.com/u-boot@lists.denx.de/msg193763.html
Just a nit - your cover letter subject says 'device model'. Mostly we call it 'driver model'. This is somewhat arbitrary but it's good to be consistent to avoid confusion, so if you end up resending this series, can you rename it?
Sorry for the confusion, will fix on my future cover letters.
Regards Mugunthan V N
participants (3)
-
Bin Meng
-
Mugunthan V N
-
Simon Glass