Commit b2e39dc0 authored by Alexandre Belloni's avatar Alexandre Belloni Committed by Stephen Boyd

clk: at91: allow clock registration from C code

Remove static keyword to allow functions to be used from other units. Also
move some struct and function declarations to pmc.h
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
[sboyd@kernel.org: Include pmc.h]
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent c1e4580a
...@@ -277,7 +277,7 @@ static void clk_generated_startup(struct clk_generated *gck) ...@@ -277,7 +277,7 @@ static void clk_generated_startup(struct clk_generated *gck)
>> AT91_PMC_PCR_GCKDIV_OFFSET; >> AT91_PMC_PCR_GCKDIV_OFFSET;
} }
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock, at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
const char *name, const char **parent_names, const char *name, const char **parent_names,
u8 num_parents, u8 id, bool pll_audio, u8 num_parents, u8 id, bool pll_audio,
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <soc/at91/atmel-sfr.h> #include <soc/at91/atmel-sfr.h>
#include "pmc.h"
#define I2S_BUS_NR 2 #define I2S_BUS_NR 2
struct clk_i2s_mux { struct clk_i2s_mux {
...@@ -48,7 +50,7 @@ static const struct clk_ops clk_i2s_mux_ops = { ...@@ -48,7 +50,7 @@ static const struct clk_ops clk_i2s_mux_ops = {
.determine_rate = __clk_mux_determine_rate, .determine_rate = __clk_mux_determine_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_i2s_mux_register(struct regmap *regmap, const char *name, at91_clk_i2s_mux_register(struct regmap *regmap, const char *name,
const char * const *parent_names, const char * const *parent_names,
unsigned int num_parents, u8 bus_id) unsigned int num_parents, u8 bus_id)
......
...@@ -128,7 +128,7 @@ static const struct clk_ops main_osc_ops = { ...@@ -128,7 +128,7 @@ static const struct clk_ops main_osc_ops = {
.is_prepared = clk_main_osc_is_prepared, .is_prepared = clk_main_osc_is_prepared,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_main_osc(struct regmap *regmap, at91_clk_register_main_osc(struct regmap *regmap,
const char *name, const char *name,
const char *parent_name, const char *parent_name,
...@@ -275,7 +275,7 @@ static const struct clk_ops main_rc_osc_ops = { ...@@ -275,7 +275,7 @@ static const struct clk_ops main_rc_osc_ops = {
.recalc_accuracy = clk_main_rc_osc_recalc_accuracy, .recalc_accuracy = clk_main_rc_osc_recalc_accuracy,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_main_rc_osc(struct regmap *regmap, at91_clk_register_main_rc_osc(struct regmap *regmap,
const char *name, const char *name,
u32 frequency, u32 accuracy) u32 frequency, u32 accuracy)
...@@ -403,7 +403,7 @@ static const struct clk_ops rm9200_main_ops = { ...@@ -403,7 +403,7 @@ static const struct clk_ops rm9200_main_ops = {
.recalc_rate = clk_rm9200_main_recalc_rate, .recalc_rate = clk_rm9200_main_recalc_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_rm9200_main(struct regmap *regmap, at91_clk_register_rm9200_main(struct regmap *regmap,
const char *name, const char *name,
const char *parent_name) const char *parent_name)
...@@ -541,7 +541,7 @@ static const struct clk_ops sam9x5_main_ops = { ...@@ -541,7 +541,7 @@ static const struct clk_ops sam9x5_main_ops = {
.get_parent = clk_sam9x5_main_get_parent, .get_parent = clk_sam9x5_main_get_parent,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_sam9x5_main(struct regmap *regmap, at91_clk_register_sam9x5_main(struct regmap *regmap,
const char *name, const char *name,
const char **parent_names, const char **parent_names,
......
...@@ -24,17 +24,6 @@ ...@@ -24,17 +24,6 @@
#define MASTER_DIV_SHIFT 8 #define MASTER_DIV_SHIFT 8
#define MASTER_DIV_MASK 0x3 #define MASTER_DIV_MASK 0x3
struct clk_master_characteristics {
struct clk_range output;
u32 divisors[4];
u8 have_div3_pres;
};
struct clk_master_layout {
u32 mask;
u8 pres_shift;
};
#define to_clk_master(hw) container_of(hw, struct clk_master, hw) #define to_clk_master(hw) container_of(hw, struct clk_master, hw)
struct clk_master { struct clk_master {
...@@ -120,7 +109,7 @@ static const struct clk_ops master_ops = { ...@@ -120,7 +109,7 @@ static const struct clk_ops master_ops = {
.get_parent = clk_master_get_parent, .get_parent = clk_master_get_parent,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_master(struct regmap *regmap, at91_clk_register_master(struct regmap *regmap,
const char *name, int num_parents, const char *name, int num_parents,
const char **parent_names, const char **parent_names,
...@@ -161,12 +150,12 @@ at91_clk_register_master(struct regmap *regmap, ...@@ -161,12 +150,12 @@ at91_clk_register_master(struct regmap *regmap,
} }
static const struct clk_master_layout at91rm9200_master_layout = { const struct clk_master_layout at91rm9200_master_layout = {
.mask = 0x31F, .mask = 0x31F,
.pres_shift = 2, .pres_shift = 2,
}; };
static const struct clk_master_layout at91sam9x5_master_layout = { const struct clk_master_layout at91sam9x5_master_layout = {
.mask = 0x373, .mask = 0x373,
.pres_shift = 4, .pres_shift = 4,
}; };
......
...@@ -104,7 +104,7 @@ static const struct clk_ops peripheral_ops = { ...@@ -104,7 +104,7 @@ static const struct clk_ops peripheral_ops = {
.is_enabled = clk_peripheral_is_enabled, .is_enabled = clk_peripheral_is_enabled,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_peripheral(struct regmap *regmap, const char *name, at91_clk_register_peripheral(struct regmap *regmap, const char *name,
const char *parent_name, u32 id) const char *parent_name, u32 id)
{ {
...@@ -331,7 +331,7 @@ static const struct clk_ops sam9x5_peripheral_ops = { ...@@ -331,7 +331,7 @@ static const struct clk_ops sam9x5_peripheral_ops = {
.set_rate = clk_sam9x5_peripheral_set_rate, .set_rate = clk_sam9x5_peripheral_set_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock, at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
const char *name, const char *parent_name, const char *name, const char *parent_name,
u32 id, const struct clk_range *range) u32 id, const struct clk_range *range)
......
...@@ -34,20 +34,6 @@ ...@@ -34,20 +34,6 @@
#define PLL_OUT_SHIFT 14 #define PLL_OUT_SHIFT 14
#define PLL_MAX_ID 1 #define PLL_MAX_ID 1
struct clk_pll_characteristics {
struct clk_range input;
int num_output;
struct clk_range *output;
u16 *icpll;
u8 *out;
};
struct clk_pll_layout {
u32 pllr_mask;
u16 mul_mask;
u8 mul_shift;
};
#define to_clk_pll(hw) container_of(hw, struct clk_pll, hw) #define to_clk_pll(hw) container_of(hw, struct clk_pll, hw)
struct clk_pll { struct clk_pll {
...@@ -285,7 +271,7 @@ static const struct clk_ops pll_ops = { ...@@ -285,7 +271,7 @@ static const struct clk_ops pll_ops = {
.set_rate = clk_pll_set_rate, .set_rate = clk_pll_set_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_pll(struct regmap *regmap, const char *name, at91_clk_register_pll(struct regmap *regmap, const char *name,
const char *parent_name, u8 id, const char *parent_name, u8 id,
const struct clk_pll_layout *layout, const struct clk_pll_layout *layout,
...@@ -331,25 +317,25 @@ at91_clk_register_pll(struct regmap *regmap, const char *name, ...@@ -331,25 +317,25 @@ at91_clk_register_pll(struct regmap *regmap, const char *name,
} }
static const struct clk_pll_layout at91rm9200_pll_layout = { const struct clk_pll_layout at91rm9200_pll_layout = {
.pllr_mask = 0x7FFFFFF, .pllr_mask = 0x7FFFFFF,
.mul_shift = 16, .mul_shift = 16,
.mul_mask = 0x7FF, .mul_mask = 0x7FF,
}; };
static const struct clk_pll_layout at91sam9g45_pll_layout = { const struct clk_pll_layout at91sam9g45_pll_layout = {
.pllr_mask = 0xFFFFFF, .pllr_mask = 0xFFFFFF,
.mul_shift = 16, .mul_shift = 16,
.mul_mask = 0xFF, .mul_mask = 0xFF,
}; };
static const struct clk_pll_layout at91sam9g20_pllb_layout = { const struct clk_pll_layout at91sam9g20_pllb_layout = {
.pllr_mask = 0x3FFFFF, .pllr_mask = 0x3FFFFF,
.mul_shift = 16, .mul_shift = 16,
.mul_mask = 0x3F, .mul_mask = 0x3F,
}; };
static const struct clk_pll_layout sama5d3_pll_layout = { const struct clk_pll_layout sama5d3_pll_layout = {
.pllr_mask = 0x1FFFFFF, .pllr_mask = 0x1FFFFFF,
.mul_shift = 18, .mul_shift = 18,
.mul_mask = 0x7F, .mul_mask = 0x7F,
......
...@@ -75,7 +75,7 @@ static const struct clk_ops plldiv_ops = { ...@@ -75,7 +75,7 @@ static const struct clk_ops plldiv_ops = {
.set_rate = clk_plldiv_set_rate, .set_rate = clk_plldiv_set_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_plldiv(struct regmap *regmap, const char *name, at91_clk_register_plldiv(struct regmap *regmap, const char *name,
const char *parent_name) const char *parent_name)
{ {
......
...@@ -25,12 +25,6 @@ ...@@ -25,12 +25,6 @@
#define PROG_PRES(layout, pckr) ((pckr >> layout->pres_shift) & PROG_PRES_MASK) #define PROG_PRES(layout, pckr) ((pckr >> layout->pres_shift) & PROG_PRES_MASK)
#define PROG_MAX_RM9200_CSS 3 #define PROG_MAX_RM9200_CSS 3
struct clk_programmable_layout {
u8 pres_shift;
u8 css_mask;
u8 have_slck_mck;
};
struct clk_programmable { struct clk_programmable {
struct clk_hw hw; struct clk_hw hw;
struct regmap *regmap; struct regmap *regmap;
...@@ -170,7 +164,7 @@ static const struct clk_ops programmable_ops = { ...@@ -170,7 +164,7 @@ static const struct clk_ops programmable_ops = {
.set_rate = clk_programmable_set_rate, .set_rate = clk_programmable_set_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_programmable(struct regmap *regmap, at91_clk_register_programmable(struct regmap *regmap,
const char *name, const char **parent_names, const char *name, const char **parent_names,
u8 num_parents, u8 id, u8 num_parents, u8 id,
...@@ -211,19 +205,19 @@ at91_clk_register_programmable(struct regmap *regmap, ...@@ -211,19 +205,19 @@ at91_clk_register_programmable(struct regmap *regmap,
return hw; return hw;
} }
static const struct clk_programmable_layout at91rm9200_programmable_layout = { const struct clk_programmable_layout at91rm9200_programmable_layout = {
.pres_shift = 2, .pres_shift = 2,
.css_mask = 0x3, .css_mask = 0x3,
.have_slck_mck = 0, .have_slck_mck = 0,
}; };
static const struct clk_programmable_layout at91sam9g45_programmable_layout = { const struct clk_programmable_layout at91sam9g45_programmable_layout = {
.pres_shift = 2, .pres_shift = 2,
.css_mask = 0x3, .css_mask = 0x3,
.have_slck_mck = 1, .have_slck_mck = 1,
}; };
static const struct clk_programmable_layout at91sam9x5_programmable_layout = { const struct clk_programmable_layout at91sam9x5_programmable_layout = {
.pres_shift = 4, .pres_shift = 4,
.css_mask = 0x7, .css_mask = 0x7,
.have_slck_mck = 0, .have_slck_mck = 0,
......
...@@ -40,7 +40,7 @@ static const struct clk_ops sam9260_slow_ops = { ...@@ -40,7 +40,7 @@ static const struct clk_ops sam9260_slow_ops = {
.get_parent = clk_sam9260_slow_get_parent, .get_parent = clk_sam9260_slow_get_parent,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_sam9260_slow(struct regmap *regmap, at91_clk_register_sam9260_slow(struct regmap *regmap,
const char *name, const char *name,
const char **parent_names, const char **parent_names,
......
...@@ -111,7 +111,7 @@ static const struct clk_ops at91sam9x5_smd_ops = { ...@@ -111,7 +111,7 @@ static const struct clk_ops at91sam9x5_smd_ops = {
.set_rate = at91sam9x5_clk_smd_set_rate, .set_rate = at91sam9x5_clk_smd_set_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name, at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
const char **parent_names, u8 num_parents) const char **parent_names, u8 num_parents)
{ {
......
...@@ -88,7 +88,7 @@ static const struct clk_ops system_ops = { ...@@ -88,7 +88,7 @@ static const struct clk_ops system_ops = {
.is_prepared = clk_system_is_prepared, .is_prepared = clk_system_is_prepared,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_system(struct regmap *regmap, const char *name, at91_clk_register_system(struct regmap *regmap, const char *name,
const char *parent_name, u8 id) const char *parent_name, u8 id)
{ {
......
...@@ -192,7 +192,7 @@ static const struct clk_ops at91sam9n12_usb_ops = { ...@@ -192,7 +192,7 @@ static const struct clk_ops at91sam9n12_usb_ops = {
.set_rate = at91sam9x5_clk_usb_set_rate, .set_rate = at91sam9x5_clk_usb_set_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name, at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
const char **parent_names, u8 num_parents) const char **parent_names, u8 num_parents)
{ {
...@@ -225,7 +225,7 @@ at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name, ...@@ -225,7 +225,7 @@ at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
return hw; return hw;
} }
static struct clk_hw * __init struct clk_hw * __init
at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name, at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name,
const char *parent_name) const char *parent_name)
{ {
...@@ -342,7 +342,7 @@ static const struct clk_ops at91rm9200_usb_ops = { ...@@ -342,7 +342,7 @@ static const struct clk_ops at91rm9200_usb_ops = {
.set_rate = at91rm9200_clk_usb_set_rate, .set_rate = at91rm9200_clk_usb_set_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91rm9200_clk_register_usb(struct regmap *regmap, const char *name, at91rm9200_clk_register_usb(struct regmap *regmap, const char *name,
const char *parent_name, const u32 *divisors) const char *parent_name, const u32 *divisors)
{ {
......
...@@ -125,7 +125,7 @@ static const struct clk_ops utmi_ops = { ...@@ -125,7 +125,7 @@ static const struct clk_ops utmi_ops = {
.recalc_rate = clk_utmi_recalc_rate, .recalc_rate = clk_utmi_recalc_rate,
}; };
static struct clk_hw * __init struct clk_hw * __init
at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr, at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr,
const char *name, const char *parent_name) const char *name, const char *parent_name)
{ {
......
...@@ -26,9 +26,151 @@ struct clk_range { ...@@ -26,9 +26,151 @@ struct clk_range {
#define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,} #define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,}
struct clk_master_layout {
u32 mask;
u8 pres_shift;
};
extern const struct clk_master_layout at91rm9200_master_layout;
extern const struct clk_master_layout at91sam9x5_master_layout;
struct clk_master_characteristics {
struct clk_range output;
u32 divisors[4];
u8 have_div3_pres;
};
struct clk_pll_layout {
u32 pllr_mask;
u16 mul_mask;
u8 mul_shift;
};
extern const struct clk_pll_layout at91rm9200_pll_layout;
extern const struct clk_pll_layout at91sam9g45_pll_layout;
extern const struct clk_pll_layout at91sam9g20_pllb_layout;
extern const struct clk_pll_layout sama5d3_pll_layout;
struct clk_pll_characteristics {
struct clk_range input;
int num_output;
struct clk_range *output;
u16 *icpll;
u8 *out;
};
struct clk_programmable_layout {
u8 pres_shift;
u8 css_mask;
u8 have_slck_mck;
};
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;
int of_at91_get_clk_range(struct device_node *np, const char *propname, int of_at91_get_clk_range(struct device_node *np, const char *propname,
struct clk_range *range); struct clk_range *range);
struct clk_hw *of_clk_hw_pmc_get(struct of_phandle_args *clkspec, void *data);
struct clk_hw * __init
at91_clk_register_audio_pll_frac(struct regmap *regmap, const char *name,
const char *parent_name);
struct clk_hw * __init
at91_clk_register_audio_pll_pad(struct regmap *regmap, const char *name,
const char *parent_name);
struct clk_hw * __init
at91_clk_register_audio_pll_pmc(struct regmap *regmap, const char *name,
const char *parent_name);
struct clk_hw * __init
at91_clk_register_generated(struct regmap *regmap, spinlock_t *lock,
const char *name, const char **parent_names,
u8 num_parents, u8 id, bool pll_audio,
const struct clk_range *range);
struct clk_hw * __init
at91_clk_register_h32mx(struct regmap *regmap, const char *name,
const char *parent_name);
struct clk_hw * __init
at91_clk_i2s_mux_register(struct regmap *regmap, const char *name,
const char * const *parent_names,
unsigned int num_parents, u8 bus_id);
struct clk_hw * __init
at91_clk_register_main_rc_osc(struct regmap *regmap, const char *name,
u32 frequency, u32 accuracy);
struct clk_hw * __init
at91_clk_register_main_osc(struct regmap *regmap, const char *name,
const char *parent_name, bool bypass);
struct clk_hw * __init
at91_clk_register_rm9200_main(struct regmap *regmap,
const char *name,
const char *parent_name);
struct clk_hw * __init
at91_clk_register_sam9x5_main(struct regmap *regmap, const char *name,
const char **parent_names, int num_parents);
struct clk_hw * __init
at91_clk_register_master(struct regmap *regmap, const char *name,
int num_parents, const char **parent_names,
const struct clk_master_layout *layout,
const struct clk_master_characteristics *characteristics);
struct clk_hw * __init
at91_clk_register_peripheral(struct regmap *regmap, const char *name,
const char *parent_name, u32 id);
struct clk_hw * __init
at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
const char *name, const char *parent_name,
u32 id, const struct clk_range *range);
struct clk_hw * __init
at91_clk_register_pll(struct regmap *regmap, const char *name,
const char *parent_name, u8 id,
const struct clk_pll_layout *layout,
const struct clk_pll_characteristics *characteristics);
struct clk_hw * __init
at91_clk_register_plldiv(struct regmap *regmap, const char *name,
const char *parent_name);
struct clk_hw * __init
at91_clk_register_programmable(struct regmap *regmap, const char *name,
const char **parent_names, u8 num_parents, u8 id,
const struct clk_programmable_layout *layout);
struct clk_hw * __init
at91_clk_register_sam9260_slow(struct regmap *regmap,
const char *name,
const char **parent_names,
int num_parents);
struct clk_hw * __init
at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
const char **parent_names, u8 num_parents);
struct clk_hw * __init
at91_clk_register_system(struct regmap *regmap, const char *name,
const char *parent_name, u8 id);
struct clk_hw * __init
at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,
const char **parent_names, u8 num_parents);
struct clk_hw * __init
at91sam9n12_clk_register_usb(struct regmap *regmap, const char *name,
const char *parent_name);
struct clk_hw * __init
at91rm9200_clk_register_usb(struct regmap *regmap, const char *name,
const char *parent_name, const u32 *divisors);
struct clk_hw * __init
at91_clk_register_utmi(struct regmap *regmap_pmc, struct regmap *regmap_sfr,
const char *name, const char *parent_name);
#ifdef CONFIG_PM #ifdef CONFIG_PM
void pmc_register_id(u8 id); void pmc_register_id(u8 id);
void pmc_register_pck(u8 pck); void pmc_register_pck(u8 pck);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment