Browse Source

Merge changes from topic "add_clk_callbacks" into integration

* changes:
  feat(clk): add set_rate callback
  feat(clk): add set_parent callback
pull/2000/merge
Madhukar Pappireddy 5 months ago
committed by TrustedFirmware Code Review
parent
commit
0567eca0b9
  1. 21
      drivers/clk/clk.c
  2. 5
      include/drivers/clk.h

21
drivers/clk/clk.c

@ -34,6 +34,20 @@ unsigned long clk_get_rate(unsigned long id)
return ops->get_rate(id);
}
int clk_set_rate(unsigned long id, unsigned long rate, unsigned long *orate)
{
unsigned long lrate;
assert((ops != NULL) && (ops->set_rate != NULL));
if (orate != NULL) {
return ops->set_rate(id, rate, orate);
}
/* In case the caller is not interested in the output rate */
return ops->set_rate(id, rate, &lrate);
}
int clk_get_parent(unsigned long id)
{
assert((ops != NULL) && (ops->get_parent != NULL));
@ -41,6 +55,13 @@ int clk_get_parent(unsigned long id)
return ops->get_parent(id);
}
int clk_set_parent(unsigned long id, unsigned long parent_id)
{
assert((ops != NULL) && (ops->set_parent != NULL));
return ops->set_parent(id, parent_id);
}
bool clk_is_enabled(unsigned long id)
{
assert((ops != NULL) && (ops->is_enabled != NULL));

5
include/drivers/clk.h

@ -13,15 +13,20 @@ struct clk_ops {
int (*enable)(unsigned long id);
void (*disable)(unsigned long id);
unsigned long (*get_rate)(unsigned long id);
int (*set_rate)(unsigned long id, unsigned long rate,
unsigned long *orate);
int (*get_parent)(unsigned long id);
int (*set_parent)(unsigned long id, unsigned long parent_id);
bool (*is_enabled)(unsigned long id);
};
int clk_enable(unsigned long id);
void clk_disable(unsigned long id);
unsigned long clk_get_rate(unsigned long id);
int clk_set_rate(unsigned long id, unsigned long rate, unsigned long *orate);
bool clk_is_enabled(unsigned long id);
int clk_get_parent(unsigned long id);
int clk_set_parent(unsigned long id, unsigned long parent_id);
void clk_register(const struct clk_ops *ops);

Loading…
Cancel
Save