qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 2/4] hw/timer: Refactor NPCM7XX Timer to use CLK clock


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2 2/4] hw/timer: Refactor NPCM7XX Timer to use CLK clock
Date: Sun, 13 Dec 2020 12:28:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0

Hi Wu,

[The list is mangling your From: ...]

On 12/11/20 11:22 PM, Hao Wu via wrote:
> This patch makes NPCM7XX Timer to use a the timer clock generated by the
> CLK module instead of the magic nubmer TIMER_REF_HZ.

Typo "number".

> 
> Reviewed-by: Havard Skinnemoen <hskinnemoen@google.com>
> Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
> Signed-off-by: Hao Wu <wuhaotsh@google.com>
> ---
>  hw/arm/npcm7xx.c                 |  5 +++++
>  hw/timer/npcm7xx_timer.c         | 25 +++++++++++++++----------
>  include/hw/misc/npcm7xx_clk.h    |  6 ------
>  include/hw/timer/npcm7xx_timer.h |  1 +
>  4 files changed, 21 insertions(+), 16 deletions(-)
> 
> diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
> index 47e2b6fc40..fabfb1697b 100644
> --- a/hw/arm/npcm7xx.c
> +++ b/hw/arm/npcm7xx.c
> @@ -22,6 +22,7 @@
>  #include "hw/char/serial.h"
>  #include "hw/loader.h"
>  #include "hw/misc/unimp.h"
> +#include "hw/qdev-clock.h"
>  #include "hw/qdev-properties.h"
>  #include "qapi/error.h"
>  #include "qemu/units.h"
> @@ -420,6 +421,10 @@ static void npcm7xx_realize(DeviceState *dev, Error 
> **errp)
>          int first_irq;
>          int j;
>  
> +        /* Connect the timer clock. */
> +        qdev_connect_clock_in(DEVICE(&s->tim[i]), "clock", 
> qdev_get_clock_out(
> +                    DEVICE(&s->clk), "timer-clock"));
> +
>          sysbus_realize(sbd, &error_abort);
>          sysbus_mmio_map(sbd, 0, npcm7xx_tim_addr[i]);
>  
> diff --git a/hw/timer/npcm7xx_timer.c b/hw/timer/npcm7xx_timer.c
> index d24445bd6e..9469c959e2 100644
> --- a/hw/timer/npcm7xx_timer.c
> +++ b/hw/timer/npcm7xx_timer.c
> @@ -17,8 +17,8 @@
>  #include "qemu/osdep.h"
>  
>  #include "hw/irq.h"
> +#include "hw/qdev-clock.h"
>  #include "hw/qdev-properties.h"
> -#include "hw/misc/npcm7xx_clk.h"
>  #include "hw/timer/npcm7xx_timer.h"
>  #include "migration/vmstate.h"
>  #include "qemu/bitops.h"
> @@ -130,7 +130,7 @@ static int64_t npcm7xx_timer_count_to_ns(NPCM7xxTimer *t, 
> uint32_t count)
>  {
>      int64_t ns = count;
>  
> -    ns *= NANOSECONDS_PER_SECOND / NPCM7XX_TIMER_REF_HZ;
> +    ns *= NANOSECONDS_PER_SECOND / clock_get_hz(t->ctrl->clock);

Why not use clock_get_ns()?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]