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 <hskinnem...@google.com> > Reviewed-by: Tyrone Ting <kft...@nuvoton.com> > Signed-off-by: Hao Wu <wuhao...@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()?