drivers: clock_control: Opaque type for clock rate

Add an opaque type that is platform specific to be used when setting a
clock rate.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2021-11-29 09:45:07 -08:00 committed by Anas Nashif
commit e9fb33ebff

View file

@ -54,6 +54,14 @@ enum clock_control_status {
*/ */
typedef void *clock_control_subsys_t; typedef void *clock_control_subsys_t;
/**
* clock_control_subsys_rate_t is a type to identify a clock
* controller sub-system rate. Such data pointed is opaque and
* relevant only to set the clock controller rate of the driver
* instance being used.
*/
typedef void *clock_control_subsys_rate_t;
/** @brief Callback called on clock started. /** @brief Callback called on clock started.
* *
* @param dev Device structure whose driver controls the clock. * @param dev Device structure whose driver controls the clock.
@ -82,7 +90,7 @@ typedef enum clock_control_status (*clock_control_get_status_fn)(
typedef int (*clock_control_set)(const struct device *dev, typedef int (*clock_control_set)(const struct device *dev,
clock_control_subsys_t sys, clock_control_subsys_t sys,
uint32_t rate); clock_control_subsys_rate_t rate);
struct clock_control_driver_api { struct clock_control_driver_api {
clock_control on; clock_control on;
@ -245,7 +253,7 @@ static inline int clock_control_get_rate(const struct device *dev,
* *
* @param dev Device structure whose driver controls the clock. * @param dev Device structure whose driver controls the clock.
* @param sys Opaque data representing the clock. * @param sys Opaque data representing the clock.
* @param rate Subsystem clock rate. * @param rate Opaque data representing the clock rate to be used.
* *
* @retval -EALREADY if clock was already in the given rate. * @retval -EALREADY if clock was already in the given rate.
* @retval -ENOTSUP If the requested mode of operation is not supported. * @retval -ENOTSUP If the requested mode of operation is not supported.
@ -254,7 +262,7 @@ static inline int clock_control_get_rate(const struct device *dev,
*/ */
static inline int clock_control_set_rate(const struct device *dev, static inline int clock_control_set_rate(const struct device *dev,
clock_control_subsys_t sys, clock_control_subsys_t sys,
uint32_t rate) clock_control_subsys_rate_t rate)
{ {
int ret = device_usable_check(dev); int ret = device_usable_check(dev);