diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/hw/ptimer.h | 22 | ||||
-rw-r--r-- | include/qemu/typedefs.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h index 412763fffb..c443218475 100644 --- a/include/hw/ptimer.h +++ b/include/hw/ptimer.h @@ -166,6 +166,28 @@ void ptimer_transaction_commit(ptimer_state *s); void ptimer_set_period(ptimer_state *s, int64_t period); /** + * ptimer_set_period_from_clock - Set counter increment from a Clock + * @s: ptimer to configure + * @clk: pointer to Clock object to take period from + * @divisor: value to scale the clock frequency down by + * + * If the ptimer is being driven from a Clock, this is the preferred + * way to tell the ptimer about the period, because it avoids any + * possible rounding errors that might happen if the internal + * representation of the Clock period was converted to either a period + * in ns or a frequency in Hz. + * + * If the ptimer should run at the same frequency as the clock, + * pass 1 as the @divisor; if the ptimer should run at half the + * frequency, pass 2, and so on. + * + * This function will assert if it is called outside a + * ptimer_transaction_begin/commit block. + */ +void ptimer_set_period_from_clock(ptimer_state *s, const Clock *clock, + unsigned int divisor); + +/** * ptimer_set_freq - Set counter frequency in Hz * @s: ptimer to configure * @freq: counter frequency in Hz diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 976b529dfb..68deb74ef6 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -34,6 +34,7 @@ typedef struct BlockDriverState BlockDriverState; typedef struct BusClass BusClass; typedef struct BusState BusState; typedef struct Chardev Chardev; +typedef struct Clock Clock; typedef struct CompatProperty CompatProperty; typedef struct CoMutex CoMutex; typedef struct CPUAddressSpace CPUAddressSpace; |