[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 01/25] ptimer: Add new ptimer_set_period_from_clock() func
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH v2 01/25] ptimer: Add new ptimer_set_period_from_clock() function |
Date: |
Thu, 28 Jan 2021 15:38:00 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 |
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.maydell@linaro.org>
> Reviewed-by: Luc Michel <luc@lmichel.fr>
> Message-id: 20210121190622.22000-2-peter.maydell@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é <f4bug@amsat.org>
- [PATCH v2 00/25] Convert CMSDK timer, watchdog, dualtimer to Clock framework, Peter Maydell, 2021/01/28
- [PATCH v2 02/25] clock: Add new clock_has_source() function, Peter Maydell, 2021/01/28
- [PATCH v2 03/25] tests: Add a simple test of the CMSDK APB timer, Peter Maydell, 2021/01/28
- [PATCH v2 05/25] tests: Add a simple test of the CMSDK APB dual timer, Peter Maydell, 2021/01/28
- [PATCH v2 01/25] ptimer: Add new ptimer_set_period_from_clock() function, Peter Maydell, 2021/01/28
- Re: [PATCH v2 01/25] ptimer: Add new ptimer_set_period_from_clock() function,
Philippe Mathieu-Daudé <=
- [PATCH v2 07/25] hw/timer/cmsdk-apb-timer: Add Clock input, Peter Maydell, 2021/01/28
- [PATCH v2 04/25] tests: Add a simple test of the CMSDK APB watchdog, Peter Maydell, 2021/01/28
- [PATCH v2 06/25] hw/timer/cmsdk-apb-timer: Rename CMSDKAPBTIMER struct to CMSDKAPBTimer, Peter Maydell, 2021/01/28
- [PATCH v2 08/25] hw/timer/cmsdk-apb-dualtimer: Add Clock input, Peter Maydell, 2021/01/28
- [PATCH v2 10/25] hw/arm/armsse: Rename "MAINCLK" property to "MAINCLK_FRQ", Peter Maydell, 2021/01/28
- [PATCH v2 09/25] hw/watchdog/cmsdk-apb-watchdog: Add Clock input, Peter Maydell, 2021/01/28
- [PATCH v2 11/25] hw/arm/armsse: Wire up clocks, Peter Maydell, 2021/01/28
- [PATCH v2 13/25] hw/arm/mps2: Create and connect SYSCLK Clock, Peter Maydell, 2021/01/28
- [PATCH v2 12/25] hw/arm/mps2: Inline CMSDK_APB_TIMER creation, Peter Maydell, 2021/01/28
- [PATCH v2 16/25] hw/arm/stellaris: Convert SSYS to QOM device, Peter Maydell, 2021/01/28