All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 00/11] dm: timer: x86: 64-bit counter support and tsc timer dm conversion
@ 2015-11-13  8:11 Bin Meng
  2015-11-13  8:11 ` [U-Boot] [PATCH v3 01/11] dm: timer: Fix several nits Bin Meng
                   ` (11 more replies)
  0 siblings, 12 replies; 40+ messages in thread
From: Bin Meng @ 2015-11-13  8:11 UTC (permalink / raw)
  To: u-boot

This series enhances timer uclass driver to support 64-bit counter
value, and convert tsc timer to driver model to be used by all x86
boards.

As a result of dm conversion, the TSC_CALIBRATION_BYPASS Kconfig
option is no longer needed, and the TSC frequency can be specified
in the board device tree.

This v2 is rebased on top of u-boot-dm/master, to resolve conflicts
with Altera timer updates and the new Sandbox timer driver.

Changes in v3:
- Update commit message to reflect the v2 changes (ie: there is
  no "counter-64bit" property)
- Really remove "counter-64bit" property from tsc_timer.dtsi

Changes in v2:
- Rebase on u-boot-dm/master
- Change 'Timer' to 'timer' in the sandbox timer Kconfig
- New patch to use device tree to pass the clock frequency
- Do not use "counter-64bit" property, instead create an inline
  function for 32-bit timer driver to construct a 64-bit timer value.
- Remove "counter-64bit" property

Bin Meng (11):
  dm: timer: Fix several nits
  dm: timer: Implement pre_probe()
  timer: altera: Remove the codes to get clock frequency
  timer: sandbox: Use device tree to pass the clock frequency
  dm: timer: Support 64-bit counter
  x86: Reomve MIN_PORT80_KCLOCKS_DELAY
  x86: tsc: Use notrace from <linux/compiler.h>
  x86: tsc: Add driver model timer support
  x86: Convert to use driver model timer
  x86: tsc: Remove legacy timer codes
  x86: tsc: Move tsc_timer.c to drivers/timer

 arch/sandbox/dts/sandbox.dts                |   1 +
 arch/x86/Kconfig                            |  20 ------
 arch/x86/cpu/baytrail/valleyview.c          |   3 -
 arch/x86/cpu/coreboot/timestamp.c           |  22 ------
 arch/x86/cpu/cpu.c                          |  18 -----
 arch/x86/cpu/efi/efi.c                      |   4 --
 arch/x86/cpu/ivybridge/cpu.c                |   1 -
 arch/x86/cpu/qemu/Kconfig                   |   1 -
 arch/x86/cpu/qemu/qemu.c                    |   3 -
 arch/x86/cpu/quark/Kconfig                  |   5 --
 arch/x86/cpu/quark/quark.c                  |   3 -
 arch/x86/cpu/queensbay/tnc.c                |   3 -
 arch/x86/dts/bayleybay.dts                  |   1 +
 arch/x86/dts/broadwell_som-6896.dts         |   1 +
 arch/x86/dts/chromebook_link.dts            |   1 +
 arch/x86/dts/chromebox_panther.dts          |   1 +
 arch/x86/dts/crownbay.dts                   |   1 +
 arch/x86/dts/efi.dts                        |   5 ++
 arch/x86/dts/galileo.dts                    |   5 ++
 arch/x86/dts/minnowmax.dts                  |   1 +
 arch/x86/dts/qemu-x86_i440fx.dts            |   5 ++
 arch/x86/dts/qemu-x86_q35.dts               |   5 ++
 arch/x86/dts/tsc_timer.dtsi                 |   6 ++
 arch/x86/include/asm/global_data.h          |   3 -
 arch/x86/lib/Makefile                       |   1 -
 configs/bayleybay_defconfig                 |   1 +
 configs/chromebook_link_defconfig           |   2 +-
 configs/chromebox_panther_defconfig         |   2 +-
 configs/coreboot-x86_defconfig              |   3 +-
 configs/crownbay_defconfig                  |   1 +
 configs/efi-x86_defconfig                   |   2 +-
 configs/galileo_defconfig                   |   1 +
 configs/minnowmax_defconfig                 |   1 +
 configs/qemu-x86_defconfig                  |   1 +
 drivers/timer/Kconfig                       |  19 +++--
 drivers/timer/Makefile                      |   1 +
 drivers/timer/altera_timer.c                |  10 +--
 drivers/timer/sandbox_timer.c               |   6 +-
 drivers/timer/timer-uclass.c                |  19 +++--
 {arch/x86/lib => drivers/timer}/tsc_timer.c | 104 ++++++++++++++++------------
 include/configs/x86-common.h                |   2 -
 include/timer.h                             |  34 ++++++---
 lib/time.c                                  |   9 ++-
 43 files changed, 164 insertions(+), 174 deletions(-)
 create mode 100644 arch/x86/dts/tsc_timer.dtsi
 rename {arch/x86/lib => drivers/timer}/tsc_timer.c (87%)

-- 
1.8.2.1

^ permalink raw reply	[flat|nested] 40+ messages in thread
* [U-Boot] [PATCH v3 05/11] dm: timer: Support 64-bit counter
@ 2015-11-24 20:31 Simon Glass
  2015-11-25  1:41 ` Bin Meng
  0 siblings, 1 reply; 40+ messages in thread
From: Simon Glass @ 2015-11-24 20:31 UTC (permalink / raw)
  To: u-boot

From: Bin Meng <bmeng.cn@gmail.com>

There are timers with a 64-bit counter value but current timer
uclass driver assumes a 32-bit one. Modify timer_get_count()
to ask timer driver to always return a 64-bit counter value,
and provide an inline helper function timer_conv_64() to handle
the 32-bit/64-bit conversion automatically.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Change timer_conv_64() to a normal function instead of inline
- Avoid using DECLARE_GLOBAL_DATA_PTR in the timer.h header file

 drivers/timer/altera_timer.c  |  4 ++--
 drivers/timer/sandbox_timer.c |  2 +-
 drivers/timer/timer-uclass.c  | 15 ++++++++++++---
 include/timer.h               | 14 +++++++++++---
 lib/time.c                    |  9 ++++++---
 5 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/timer/altera_timer.c b/drivers/timer/altera_timer.c
index 2364f1b..89fe05b 100644
--- a/drivers/timer/altera_timer.c
+++ b/drivers/timer/altera_timer.c
@@ -34,7 +34,7 @@ struct altera_timer_platdata {
 	struct altera_timer_regs *regs;
 };
 
-static int altera_timer_get_count(struct udevice *dev, unsigned long *count)
+static int altera_timer_get_count(struct udevice *dev, u64 *count)
 {
 	struct altera_timer_platdata *plat = dev->platdata;
 	struct altera_timer_regs *const regs = plat->regs;
@@ -46,7 +46,7 @@ static int altera_timer_get_count(struct udevice *dev, unsigned long *count)
 	/* Read timer value */
 	val = readl(&regs->snapl) & 0xffff;
 	val |= (readl(&regs->snaph) & 0xffff) << 16;
-	*count = ~val;
+	*count = timer_conv_64(~val);
 
 	return 0;
 }
diff --git a/drivers/timer/sandbox_timer.c b/drivers/timer/sandbox_timer.c
index 4b20af2..00a9944 100644
--- a/drivers/timer/sandbox_timer.c
+++ b/drivers/timer/sandbox_timer.c
@@ -18,7 +18,7 @@ void sandbox_timer_add_offset(unsigned long offset)
 	sandbox_timer_offset += offset;
 }
 
-static int sandbox_timer_get_count(struct udevice *dev, unsigned long *count)
+static int sandbox_timer_get_count(struct udevice *dev, u64 *count)
 {
 	*count = os_get_nsec() / 1000 + sandbox_timer_offset * 1000;
 
diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
index 0218591..aca421b 100644
--- a/drivers/timer/timer-uclass.c
+++ b/drivers/timer/timer-uclass.c
@@ -13,14 +13,14 @@ 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
+ * a 32/64 bits free-running up counter. The get_rate() method is used to get
  * the input clock frequency of the timer. The get_count() method is used
- * to get the current 32 bits count value. If the hardware is counting down,
+ * to get the current 64 bits count value. If the hardware is counting down,
  * the value should be inversed inside the method. There may be no real
  * tick, and no timer interrupt.
  */
 
-int timer_get_count(struct udevice *dev, unsigned long *count)
+int timer_get_count(struct udevice *dev, u64 *count)
 {
 	const struct timer_ops *ops = device_get_ops(dev);
 
@@ -47,6 +47,15 @@ static int timer_pre_probe(struct udevice *dev)
 	return 0;
 }
 
+u64 timer_conv_64(u32 count)
+{
+	/* increment tbh if tbl has rolled over */
+	if (count < gd->timebase_l)
+		gd->timebase_h++;
+	gd->timebase_l = count;
+	return ((u64)gd->timebase_h << 32) | gd->timebase_l;
+}
+
 UCLASS_DRIVER(timer) = {
 	.id		= UCLASS_TIMER,
 	.name		= "timer",
diff --git a/include/timer.h b/include/timer.h
index ed5c685..7fee17e 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -8,13 +8,21 @@
 #define _TIMER_H_
 
 /*
+ * timer_conv_64 - convert 32-bit counter value to 64-bit
+ *
+ * @count: 32-bit counter value
+ * @return: 64-bit counter value
+ */
+u64 timer_conv_64(u32 count);
+
+/*
  * Get the current timer count
  *
  * @dev: The timer device
  * @count: pointer that returns the current timer count
  * @return: 0 if OK, -ve on error
  */
-int timer_get_count(struct udevice *dev, unsigned long *count);
+int timer_get_count(struct udevice *dev, u64 *count);
 
 /*
  * Get the timer input clock frequency
@@ -35,10 +43,10 @@ struct timer_ops {
 	 * Get the current timer count
 	 *
 	 * @dev: The timer device
-	 * @count: pointer that returns the current timer count
+	 * @count: pointer that returns the current 64-bit timer count
 	 * @return: 0 if OK, -ve on error
 	 */
-	int (*get_count)(struct udevice *dev, unsigned long *count);
+	int (*get_count)(struct udevice *dev, u64 *count);
 };
 
 /*
diff --git a/lib/time.c b/lib/time.c
index b001745..f37a662 100644
--- a/lib/time.c
+++ b/lib/time.c
@@ -69,9 +69,9 @@ ulong notrace get_tbclk(void)
 	return timer_get_rate(gd->timer);
 }
 
-unsigned long notrace timer_read_counter(void)
+uint64_t notrace get_ticks(void)
 {
-	unsigned long count;
+	u64 count;
 	int ret;
 
 	ret = dm_timer_init();
@@ -84,7 +84,8 @@ unsigned long notrace timer_read_counter(void)
 
 	return count;
 }
-#endif /* CONFIG_TIMER */
+
+#else /* !CONFIG_TIMER */
 
 uint64_t __weak notrace get_ticks(void)
 {
@@ -97,6 +98,8 @@ uint64_t __weak notrace get_ticks(void)
 	return ((uint64_t)gd->timebase_h << 32) | gd->timebase_l;
 }
 
+#endif /* CONFIG_TIMER */
+
 /* Returns time in milliseconds */
 static uint64_t notrace tick_to_time(uint64_t tick)
 {
-- 
2.6.0.rc2.230.g3dd15c0

^ permalink raw reply related	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2015-11-26 17:49 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13  8:11 [U-Boot] [PATCH v3 00/11] dm: timer: x86: 64-bit counter support and tsc timer dm conversion Bin Meng
2015-11-13  8:11 ` [U-Boot] [PATCH v3 01/11] dm: timer: Fix several nits Bin Meng
2015-11-24  2:26   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 02/11] dm: timer: Implement pre_probe() Bin Meng
2015-11-24  2:26   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 03/11] timer: altera: Remove the codes to get clock frequency Bin Meng
2015-11-24  2:26   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 04/11] timer: sandbox: Use device tree to pass the " Bin Meng
2015-11-22 16:24   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 05/11] dm: timer: Support 64-bit counter Bin Meng
2015-11-14  2:04   ` Simon Glass
2015-11-16  2:19     ` Bin Meng
2015-11-20 21:10       ` Simon Glass
2015-11-21  0:41         ` Thomas Chou
2015-11-22 16:21           ` Simon Glass
2015-11-24  2:27             ` Simon Glass
2015-11-24 10:09             ` Simon Glass
2015-11-24 14:01               ` Thomas Chou
2015-11-24 18:23                 ` Simon Glass
2015-11-24 20:32                   ` Simon Glass
2015-11-25  3:20                   ` Thomas Chou
2015-11-25  6:44                     ` Bin Meng
2015-11-25 16:51                       ` Simon Glass
2015-11-26 17:49                         ` Simon Glass
2015-11-16  5:03     ` Bin Meng
2015-11-13  8:11 ` [U-Boot] [PATCH v3 06/11] x86: Reomve MIN_PORT80_KCLOCKS_DELAY Bin Meng
2015-11-24  2:27   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 07/11] x86: tsc: Use notrace from <linux/compiler.h> Bin Meng
2015-11-24  2:27   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 08/11] x86: tsc: Add driver model timer support Bin Meng
2015-11-24  2:27   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 09/11] x86: Convert to use driver model timer Bin Meng
2015-11-24  2:27   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 10/11] x86: tsc: Remove legacy timer codes Bin Meng
2015-11-24  2:27   ` Simon Glass
2015-11-13  8:11 ` [U-Boot] [PATCH v3 11/11] x86: tsc: Move tsc_timer.c to drivers/timer Bin Meng
2015-11-24  2:27   ` Simon Glass
2015-11-13  9:20 ` [U-Boot] [PATCH v3 00/11] dm: timer: x86: 64-bit counter support and tsc timer dm conversion Thomas Chou
2015-11-24 20:31 [U-Boot] [PATCH v3 05/11] dm: timer: Support 64-bit counter Simon Glass
2015-11-25  1:41 ` Bin Meng

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.