On 1/28/21 12:41 PM, Peter Maydell wrote: > The ptimer API currently provides two methods for setting the period: > ptimer_set_period(), which takes a period in nanoseconds, and > ptimer_set_freq(), which takes a frequency in Hz. Neither of these > lines up nicely with the Clock API, because although both the Clock > and the ptimer track the frequency using a representation of whole > and fractional nanoseconds, conversion via either period-in-ns or > frequency-in-Hz will introduce a rounding error. > > Add a new function ptimer_set_period_from_clock() which takes the > Clock object directly to avoid the rounding issues. This includes a > facility for the user to specify that there is a frequency divider > between the Clock proper and the timer, as some timer devices like > the CMSDK APB dualtimer need this. > > To avoid having to drag in clock.h from ptimer.h we add the Clock > type to typedefs.h. > > Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> > Reviewed-by: Luc Michel <l...@lmichel.fr> > Message-id: 20210121190622.22000-2-peter.mayd...@linaro.org > --- > include/hw/ptimer.h | 22 ++++++++++++++++++++++ > include/qemu/typedefs.h | 1 + > hw/core/ptimer.c | 34 ++++++++++++++++++++++++++++++++++ > 3 files changed, 57 insertions(+)
Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org>