no-OS
no_os_clk.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef _NO_OS_CLK_H_
34 #define _NO_OS_CLK_H_
35 
36 /******************************************************************************/
37 /***************************** Include Files **********************************/
38 /******************************************************************************/
39 #include <stdint.h>
40 
41 /******************************************************************************/
42 /************************* Structure Declarations *****************************/
43 /******************************************************************************/
46  const char *name;
48  uint8_t hw_ch_num;
52  void *dev_desc;
53 };
54 
55 struct no_os_clk_hw {
56  void *dev;
57  int32_t (*dev_clk_enable)();
58  int32_t (*dev_clk_disable)();
59  int32_t (*dev_clk_recalc_rate)();
60  int32_t (*dev_clk_set_rate)();
61  int32_t (*dev_clk_round_rate)();
62 };
63 
64 struct no_os_clk {
65  struct no_os_clk_hw *hw;
66  uint32_t hw_ch_num;
67  const char *name;
68  const struct no_os_clk_desc *clk_desc;
69 };
70 
75 typedef struct no_os_clk_desc {
77  const char *name;
79  uint8_t hw_ch_num;
83  void *dev_desc;
85 
93  int (*init)(struct no_os_clk_desc **, const struct no_os_clk_init_param *);
95  int (*clk_enable)(struct no_os_clk_desc *);
97  int (*clk_disable)(struct no_os_clk_desc *);
99  int (*clk_recalc_rate)(struct no_os_clk_desc *, uint64_t *);
100  /* Round the desired frequency to a rate that CLK can actually output. */
101  int (*clk_round_rate)(struct no_os_clk_desc *, uint64_t, uint64_t *);
102  /* Change CLK frequency function pointer. */
103  int (*clk_set_rate)(struct no_os_clk_desc *, uint64_t);
105  int (*remove)(struct no_os_clk_desc *);
106 };
107 
108 /******************************************************************************/
109 /************************ Functions Declarations ******************************/
110 /******************************************************************************/
111 
112 /* Initialize CLK ops. */
113 int32_t no_os_clk_init(struct no_os_clk_desc **desc,
114  const struct no_os_clk_init_param *param);
115 
116 /* Free the resources allocated by no_os_clk_init(). */
117 int32_t no_os_clk_remove(struct no_os_clk_desc *desc);
118 
119 /* Start the clock. */
120 int32_t no_os_clk_enable(struct no_os_clk_desc *desc);
121 
122 /* Stop the clock. */
123 int32_t no_os_clk_disable(struct no_os_clk_desc *desc);
124 
125 /* Get the current frequency of the clock. */
126 int32_t no_os_clk_recalc_rate(struct no_os_clk_desc *desc,
127  uint64_t *rate);
128 
129 /* Round the desired frequency to a rate that the clock can actually output. */
130 int32_t no_os_clk_round_rate(struct no_os_clk_desc *desc,
131  uint64_t rate,
132  uint64_t *rounded_rate);
133 
134 /* Change the frequency of the clock. */
135 int32_t no_os_clk_set_rate(struct no_os_clk_desc *desc,
136  uint64_t rate);
137 
138 #endif // _NO_OS_CLK_H_
no_os_clk_hw::dev_clk_round_rate
int32_t(* dev_clk_round_rate)()
Definition: no_os_clk.h:61
no_os_clk::hw
struct no_os_clk_hw * hw
Definition: no_os_clk.h:65
no_os_clk_platform_ops::remove
int(* remove)(struct no_os_clk_desc *)
Definition: no_os_clk.h:105
no_os_clk_init_param::platform_ops
const struct no_os_clk_platform_ops * platform_ops
Definition: no_os_clk.h:50
no_os_clk_hw
Definition: no_os_clk.h:55
no_os_clk_hw::dev_clk_recalc_rate
int32_t(* dev_clk_recalc_rate)()
Definition: no_os_clk.h:59
no_os_clk_init_param::name
const char * name
Definition: no_os_clk.h:46
no_os_clk_enable
int32_t no_os_clk_enable(struct no_os_clk_desc *desc)
no_os_clk
Definition: no_os_clk.h:64
no_os_clk_init
int32_t no_os_clk_init(struct no_os_clk_desc **desc, const struct no_os_clk_init_param *param)
no_os_clk_platform_ops::clk_recalc_rate
int(* clk_recalc_rate)(struct no_os_clk_desc *, uint64_t *)
Definition: no_os_clk.h:99
no_os_clk::name
const char * name
Definition: no_os_clk.h:67
no_os_clk::clk_desc
const struct no_os_clk_desc * clk_desc
Definition: no_os_clk.h:68
no_os_clk_disable
int32_t no_os_clk_disable(struct no_os_clk_desc *desc)
no_os_clk_platform_ops::clk_set_rate
int(* clk_set_rate)(struct no_os_clk_desc *, uint64_t)
Definition: no_os_clk.h:103
no_os_clk_desc::name
const char * name
Definition: no_os_clk.h:77
no_os_clk_set_rate
int32_t no_os_clk_set_rate(struct no_os_clk_desc *desc, uint64_t rate)
no_os_clk_desc
struct no_os_clk_desc no_os_clk_desc
no_os_clk_desc::hw_ch_num
uint8_t hw_ch_num
Definition: no_os_clk.h:79
no_os_clk_desc
Structure holding CLK descriptor.
Definition: no_os_clk.h:75
no_os_clk_hw::dev
void * dev
Definition: no_os_clk.h:56
no_os_clk::hw_ch_num
uint32_t hw_ch_num
Definition: no_os_clk.h:66
no_os_clk_init_param::dev_desc
void * dev_desc
Definition: no_os_clk.h:52
no_os_clk_hw::dev_clk_enable
int32_t(* dev_clk_enable)()
Definition: no_os_clk.h:57
no_os_clk_init_param
Definition: no_os_clk.h:44
no_os_clk_remove
int32_t no_os_clk_remove(struct no_os_clk_desc *desc)
no_os_clk_hw::dev_clk_disable
int32_t(* dev_clk_disable)()
Definition: no_os_clk.h:58
no_os_clk_platform_ops::clk_round_rate
int(* clk_round_rate)(struct no_os_clk_desc *, uint64_t, uint64_t *)
Definition: no_os_clk.h:101
no_os_clk_desc::platform_ops
const struct no_os_clk_platform_ops * platform_ops
Definition: no_os_clk.h:81
no_os_clk_platform_ops
Structure holding CLK function pointers that point to the platform specific function.
Definition: no_os_clk.h:91
no_os_clk_platform_ops::init
int(* init)(struct no_os_clk_desc **, const struct no_os_clk_init_param *)
Definition: no_os_clk.h:93
no_os_clk_desc::dev_desc
void * dev_desc
Definition: no_os_clk.h:83
no_os_clk_init_param::hw_ch_num
uint8_t hw_ch_num
Definition: no_os_clk.h:48
no_os_clk_hw::dev_clk_set_rate
int32_t(* dev_clk_set_rate)()
Definition: no_os_clk.h:60
no_os_clk_platform_ops::clk_enable
int(* clk_enable)(struct no_os_clk_desc *)
Definition: no_os_clk.h:95
no_os_clk_platform_ops::clk_disable
int(* clk_disable)(struct no_os_clk_desc *)
Definition: no_os_clk.h:97
no_os_clk_recalc_rate
int32_t no_os_clk_recalc_rate(struct no_os_clk_desc *desc, uint64_t *rate)
no_os_clk_round_rate
int32_t no_os_clk_round_rate(struct no_os_clk_desc *desc, uint64_t rate, uint64_t *rounded_rate)