clk: at91: pmc: add generic clock ops
Add generic clock ops to be used by every AT91 PMC driver built on top of CCF. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
This commit is contained in:
committed by
Eugen Hristev
parent
36a9630fcb
commit
7b7e226739
@@ -5,8 +5,79 @@
|
||||
*/
|
||||
|
||||
#include <asm/io.h>
|
||||
#include <clk-uclass.h>
|
||||
#include <common.h>
|
||||
|
||||
#include "pmc.h"
|
||||
|
||||
static int at91_clk_of_xlate(struct clk *clk, struct ofnode_phandle_args *args)
|
||||
{
|
||||
if (args->args_count != 2) {
|
||||
debug("AT91: clk: Invalid args_count: %d\n", args->args_count);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
clk->id = AT91_TO_CLK_ID(args->args[0], args->args[1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ulong at91_clk_get_rate(struct clk *clk)
|
||||
{
|
||||
struct clk *c;
|
||||
int ret;
|
||||
|
||||
ret = clk_get_by_id(clk->id, &c);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return clk_get_rate(c);
|
||||
}
|
||||
|
||||
static ulong at91_clk_set_rate(struct clk *clk, ulong rate)
|
||||
{
|
||||
struct clk *c;
|
||||
int ret;
|
||||
|
||||
ret = clk_get_by_id(clk->id, &c);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return clk_set_rate(c, rate);
|
||||
}
|
||||
|
||||
static int at91_clk_enable(struct clk *clk)
|
||||
{
|
||||
struct clk *c;
|
||||
int ret;
|
||||
|
||||
ret = clk_get_by_id(clk->id, &c);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return clk_enable(c);
|
||||
}
|
||||
|
||||
static int at91_clk_disable(struct clk *clk)
|
||||
{
|
||||
struct clk *c;
|
||||
int ret;
|
||||
|
||||
ret = clk_get_by_id(clk->id, &c);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return clk_disable(c);
|
||||
}
|
||||
|
||||
const struct clk_ops at91_clk_ops = {
|
||||
.of_xlate = at91_clk_of_xlate,
|
||||
.set_rate = at91_clk_set_rate,
|
||||
.get_rate = at91_clk_get_rate,
|
||||
.enable = at91_clk_enable,
|
||||
.disable = at91_clk_disable,
|
||||
};
|
||||
|
||||
/**
|
||||
* pmc_read() - read content at address base + off into val
|
||||
*
|
||||
|
||||
@@ -75,6 +75,8 @@ extern const struct clk_programmable_layout at91rm9200_programmable_layout;
|
||||
extern const struct clk_programmable_layout at91sam9g45_programmable_layout;
|
||||
extern const struct clk_programmable_layout at91sam9x5_programmable_layout;
|
||||
|
||||
extern const struct clk_ops at91_clk_ops;
|
||||
|
||||
struct clk *at91_clk_main_rc(void __iomem *reg, const char *name,
|
||||
const char *parent_name);
|
||||
struct clk *at91_clk_main_osc(void __iomem *reg, const char *name,
|
||||
|
||||
Reference in New Issue
Block a user