2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2016-07-20 09:55:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Atmel Corporation
|
|
|
|
* Wenyou.Yang <wenyou.yang@atmel.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __AT91_PMC_H__
|
|
|
|
#define __AT91_PMC_H__
|
|
|
|
|
2020-09-07 14:46:38 +00:00
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
|
|
|
|
/* Keep a range of 256 available clocks for every clock type. */
|
|
|
|
#define AT91_TO_CLK_ID(_t, _i) (((_t) << 8) | ((_i) & 0xff))
|
|
|
|
#define AT91_CLK_ID_TO_DID(_i) ((_i) & 0xff)
|
2017-09-05 10:30:07 +00:00
|
|
|
|
2020-09-07 14:46:42 +00:00
|
|
|
struct clk_range {
|
|
|
|
unsigned long min;
|
|
|
|
unsigned long max;
|
|
|
|
};
|
|
|
|
|
2020-09-07 14:46:43 +00:00
|
|
|
struct clk_master_layout {
|
|
|
|
u32 offset;
|
|
|
|
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;
|
2020-07-01 07:42:58 +00:00
|
|
|
u32 divisors[5];
|
2020-09-07 14:46:43 +00:00
|
|
|
u8 have_div3_pres;
|
|
|
|
};
|
|
|
|
|
2020-09-07 14:46:42 +00:00
|
|
|
struct clk_pll_characteristics {
|
|
|
|
struct clk_range input;
|
|
|
|
int num_output;
|
|
|
|
const struct clk_range *output;
|
|
|
|
u16 *icpll;
|
|
|
|
u8 *out;
|
|
|
|
u8 upll : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct clk_pll_layout {
|
|
|
|
u32 pllr_mask;
|
|
|
|
u32 mul_mask;
|
|
|
|
u32 frac_mask;
|
|
|
|
u32 div_mask;
|
|
|
|
u32 endiv_mask;
|
|
|
|
u8 mul_shift;
|
|
|
|
u8 frac_shift;
|
|
|
|
u8 div_shift;
|
|
|
|
u8 endiv_shift;
|
|
|
|
};
|
|
|
|
|
2020-09-07 14:46:47 +00:00
|
|
|
struct clk_programmable_layout {
|
|
|
|
u8 pres_mask;
|
|
|
|
u8 pres_shift;
|
|
|
|
u8 css_mask;
|
|
|
|
u8 have_slck_mck;
|
|
|
|
u8 is_pres_direct;
|
|
|
|
};
|
|
|
|
|
2020-09-07 14:46:49 +00:00
|
|
|
struct clk_pcr_layout {
|
|
|
|
u32 offset;
|
|
|
|
u32 cmd;
|
|
|
|
u32 div_mask;
|
|
|
|
u32 gckcss_mask;
|
|
|
|
u32 pid_mask;
|
|
|
|
};
|
|
|
|
|
2023-03-08 14:39:50 +00:00
|
|
|
struct clk_usbck_layout {
|
|
|
|
u32 offset;
|
|
|
|
u32 usbs_mask;
|
|
|
|
u32 usbdiv_mask;
|
|
|
|
};
|
|
|
|
|
2023-03-08 14:39:52 +00:00
|
|
|
/**
|
|
|
|
* Clock setup description
|
|
|
|
* @cid: clock id corresponding to clock subsystem
|
|
|
|
* @pid: parent clock id corresponding to clock subsystem
|
|
|
|
* @rate: clock rate
|
|
|
|
* @prate: parent rate
|
|
|
|
*/
|
|
|
|
struct pmc_clk_setup {
|
|
|
|
unsigned int cid;
|
|
|
|
unsigned int pid;
|
|
|
|
unsigned long rate;
|
|
|
|
unsigned long prate;
|
|
|
|
};
|
|
|
|
|
2020-09-07 14:46:47 +00:00
|
|
|
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;
|
|
|
|
|
2020-09-07 14:46:51 +00:00
|
|
|
extern const struct clk_ops at91_clk_ops;
|
|
|
|
|
2020-09-07 14:46:41 +00:00
|
|
|
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,
|
|
|
|
const char *parent_name, bool bypass);
|
|
|
|
struct clk *at91_clk_rm9200_main(void __iomem *reg, const char *name,
|
|
|
|
const char *parent_name);
|
|
|
|
struct clk *at91_clk_sam9x5_main(void __iomem *reg, const char *name,
|
|
|
|
const char * const *parent_names, int num_parents,
|
|
|
|
const u32 *mux_table, int type);
|
2020-09-07 14:46:42 +00:00
|
|
|
struct clk *
|
2023-03-08 14:39:50 +00:00
|
|
|
sam9x60_clk_register_usb(void __iomem *base, const char *name,
|
|
|
|
const char * const *parent_names, u8 num_parents,
|
|
|
|
const struct clk_usbck_layout *usbck_layout,
|
|
|
|
const u32 *clk_mux_table, const u32 *mux_table, u8 id);
|
|
|
|
struct clk *
|
2020-09-07 14:46:42 +00:00
|
|
|
sam9x60_clk_register_div_pll(void __iomem *base, const char *name,
|
|
|
|
const char *parent_name, u8 id,
|
|
|
|
const struct clk_pll_characteristics *characteristics,
|
|
|
|
const struct clk_pll_layout *layout, bool critical);
|
|
|
|
struct clk *
|
|
|
|
sam9x60_clk_register_frac_pll(void __iomem *base, const char *name,
|
|
|
|
const char *parent_name, u8 id,
|
|
|
|
const struct clk_pll_characteristics *characteristics,
|
|
|
|
const struct clk_pll_layout *layout, bool critical);
|
2020-09-07 14:46:43 +00:00
|
|
|
struct clk *
|
2021-07-16 05:43:48 +00:00
|
|
|
at91_clk_register_master_pres(void __iomem *base, const char *name,
|
2020-09-07 14:46:43 +00:00
|
|
|
const char * const *parent_names, int num_parents,
|
|
|
|
const struct clk_master_layout *layout,
|
|
|
|
const struct clk_master_characteristics *characteristics,
|
|
|
|
const u32 *mux_table);
|
2020-09-07 14:46:44 +00:00
|
|
|
struct clk *
|
2021-07-16 05:43:48 +00:00
|
|
|
at91_clk_register_master_div(void __iomem *base,
|
|
|
|
const char *name, const char *parent_name,
|
|
|
|
const struct clk_master_layout *layout,
|
|
|
|
const struct clk_master_characteristics *characteristics);
|
|
|
|
struct clk *
|
2020-09-07 14:46:44 +00:00
|
|
|
at91_clk_sama7g5_register_master(void __iomem *base, const char *name,
|
|
|
|
const char * const *parent_names, int num_parents,
|
|
|
|
const u32 *mux_table, const u32 *clk_mux_table,
|
|
|
|
bool critical, u8 id);
|
2020-09-07 14:46:45 +00:00
|
|
|
struct clk *
|
|
|
|
at91_clk_register_utmi(void __iomem *base, struct udevice *dev,
|
|
|
|
const char *name, const char *parent_name);
|
2020-09-07 14:46:46 +00:00
|
|
|
struct clk *
|
|
|
|
at91_clk_sama7g5_register_utmi(void __iomem *base, const char *name,
|
|
|
|
const char *parent_name);
|
2020-09-07 14:46:47 +00:00
|
|
|
struct clk *
|
|
|
|
at91_clk_register_programmable(void __iomem *base, const char *name,
|
|
|
|
const char * const *parent_names, u8 num_parents, u8 id,
|
|
|
|
const struct clk_programmable_layout *layout,
|
|
|
|
const u32 *clk_mux_table, const u32 *mux_table);
|
2020-09-07 14:46:48 +00:00
|
|
|
struct clk *
|
|
|
|
at91_clk_register_system(void __iomem *base, const char *name,
|
|
|
|
const char *parent_name, u8 id);
|
2020-09-07 14:46:49 +00:00
|
|
|
struct clk *
|
|
|
|
at91_clk_register_peripheral(void __iomem *base, const char *name,
|
|
|
|
const char *parent_name, u32 id);
|
|
|
|
struct clk *
|
|
|
|
at91_clk_register_sam9x5_peripheral(void __iomem *base,
|
|
|
|
const struct clk_pcr_layout *layout,
|
|
|
|
const char *name, const char *parent_name,
|
|
|
|
u32 id, const struct clk_range *range);
|
2020-09-07 14:46:50 +00:00
|
|
|
struct clk *
|
|
|
|
at91_clk_register_generic(void __iomem *base,
|
|
|
|
const struct clk_pcr_layout *layout, const char *name,
|
|
|
|
const char * const *parent_names,
|
|
|
|
const u32 *clk_mux_table, const u32 *mux_table,
|
|
|
|
u8 num_parents, u8 id, const struct clk_range *range);
|
2020-09-07 14:46:41 +00:00
|
|
|
|
2020-09-07 14:46:38 +00:00
|
|
|
int at91_clk_mux_val_to_index(const u32 *table, u32 num_parents, u32 val);
|
|
|
|
int at91_clk_mux_index_to_val(const u32 *table, u32 num_parents, u32 index);
|
|
|
|
|
|
|
|
void pmc_read(void __iomem *base, unsigned int off, unsigned int *val);
|
|
|
|
void pmc_write(void __iomem *base, unsigned int off, unsigned int val);
|
|
|
|
void pmc_update_bits(void __iomem *base, unsigned int off, unsigned int mask,
|
|
|
|
unsigned int bits);
|
2020-09-07 14:46:39 +00:00
|
|
|
|
2023-03-08 14:39:52 +00:00
|
|
|
int at91_clk_setup(const struct pmc_clk_setup *setup, int size);
|
|
|
|
|
2016-07-20 09:55:12 +00:00
|
|
|
#endif
|