#include <linux/array_size.h>
#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <asm/div64.h>
#include <dt-bindings/clock/sophgo,sg2042-clkgen.h>
#include "clk-sg2042.h"
#define R_PLL_BEGIN …
#define R_PLL_STAT …
#define R_PLL_CLKEN_CONTROL …
#define R_MPLL_CONTROL …
#define R_FPLL_CONTROL …
#define R_DPLL0_CONTROL …
#define R_DPLL1_CONTROL …
#define R_CLKENREG0 …
#define R_CLKENREG1 …
#define R_CLKSELREG0 …
#define R_CLKDIVREG0 …
#define R_CLKDIVREG1 …
#define R_CLKDIVREG2 …
#define R_CLKDIVREG3 …
#define R_CLKDIVREG4 …
#define R_CLKDIVREG5 …
#define R_CLKDIVREG6 …
#define R_CLKDIVREG7 …
#define R_CLKDIVREG8 …
#define R_CLKDIVREG9 …
#define R_CLKDIVREG10 …
#define R_CLKDIVREG11 …
#define R_CLKDIVREG12 …
#define R_CLKDIVREG13 …
#define R_CLKDIVREG14 …
#define R_CLKDIVREG15 …
#define R_CLKDIVREG16 …
#define R_CLKDIVREG17 …
#define R_CLKDIVREG18 …
#define R_CLKDIVREG19 …
#define R_CLKDIVREG20 …
#define R_CLKDIVREG21 …
#define R_CLKDIVREG22 …
#define R_CLKDIVREG23 …
#define R_CLKDIVREG24 …
#define R_CLKDIVREG25 …
#define R_CLKDIVREG26 …
#define R_CLKDIVREG27 …
#define R_CLKDIVREG28 …
#define R_CLKDIVREG29 …
#define R_CLKDIVREG30 …
#define SHIFT_DIV_RESET_CTRL …
#define SHIFT_DIV_FACTOR_SEL …
#define SHIFT_DIV_FACTOR …
struct sg2042_divider_clock { … };
#define to_sg2042_clk_divider(_hw) …
struct sg2042_gate_clock { … };
struct sg2042_mux_clock { … };
#define to_sg2042_mux_nb(_nb) …
static unsigned long sg2042_clk_divider_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{ … }
static long sg2042_clk_divider_round_rate(struct clk_hw *hw,
unsigned long rate,
unsigned long *prate)
{ … }
static int sg2042_clk_divider_set_rate(struct clk_hw *hw,
unsigned long rate,
unsigned long parent_rate)
{ … }
static const struct clk_ops sg2042_clk_divider_ops = …;
static const struct clk_ops sg2042_clk_divider_ro_ops = …;
#define SG2042_DIV_FW(_id, _name, _parent, \
_r_ctrl, _shift, _width, \
_div_flag, _initval) …
#define SG2042_DIV_FW_RO(_id, _name, _parent, \
_r_ctrl, _shift, _width, \
_div_flag, _initval) …
#define SG2042_DIV_HW(_id, _name, _parent, \
_r_ctrl, _shift, _width, \
_div_flag, _initval) …
#define SG2042_DIV_HW_RO(_id, _name, _parent, \
_r_ctrl, _shift, _width, \
_div_flag, _initval) …
#define SG2042_DIV_HWS(_id, _name, _parent, \
_r_ctrl, _shift, _width, \
_div_flag, _initval) …
#define SG2042_DIV_HWS_RO(_id, _name, _parent, \
_r_ctrl, _shift, _width, \
_div_flag, _initval) …
#define SG2042_GATE_HWS(_id, _name, _parent, _flags, \
_r_enable, _bit_idx) …
#define SG2042_GATE_HW(_id, _name, _parent, _flags, \
_r_enable, _bit_idx) …
#define SG2042_GATE_FW(_id, _name, _parent, _flags, \
_r_enable, _bit_idx) …
#define SG2042_MUX(_id, _name, _parents, _flags, _r_select, _shift, _width) …
static const struct clk_hw *clk_gate_ddr01_div0[] = …;
static const struct clk_hw *clk_gate_ddr01_div1[] = …;
static const struct clk_hw *clk_gate_ddr23_div0[] = …;
static const struct clk_hw *clk_gate_ddr23_div1[] = …;
static const struct clk_hw *clk_gate_rp_cpu_normal_div0[] = …;
static const struct clk_hw *clk_gate_rp_cpu_normal_div1[] = …;
static const struct clk_hw *clk_gate_axi_ddr_div0[] = …;
static const struct clk_hw *clk_gate_axi_ddr_div1[] = …;
static const struct sg2042_gate_clock sg2042_gate_clks_level_1[] = …;
#define DEF_DIVFLAG …
static struct sg2042_divider_clock sg2042_div_clks_level_1[] = …;
static const u32 sg2042_mux_table[] = …;
#define clk_div_ddr01_0 …
#define clk_div_ddr01_1 …
#define clk_div_ddr23_0 …
#define clk_div_ddr23_1 …
#define clk_div_rp_cpu_normal_0 …
#define clk_div_rp_cpu_normal_1 …
#define clk_div_axi_ddr_0 …
#define clk_div_axi_ddr_1 …
static const struct clk_hw *clk_mux_ddr01_p[] = …;
static const struct clk_hw *clk_mux_ddr23_p[] = …;
static const struct clk_hw *clk_mux_rp_cpu_normal_p[] = …;
static const struct clk_hw *clk_mux_axi_ddr_p[] = …;
static const struct clk_hw *clk_mux_ddr01[] = …;
static const struct clk_hw *clk_mux_ddr23[] = …;
static const struct clk_hw *clk_mux_rp_cpu_normal[] = …;
static const struct clk_hw *clk_mux_axi_ddr[] = …;
static struct sg2042_mux_clock sg2042_mux_clks[] = …;
#define clk_div_top_rp_cmn_div2 …
#define clk_div_50m_a53 …
#define clk_div_timer1 …
#define clk_div_timer2 …
#define clk_div_timer3 …
#define clk_div_timer4 …
#define clk_div_timer5 …
#define clk_div_timer6 …
#define clk_div_timer7 …
#define clk_div_timer8 …
#define clk_div_uart_500m …
#define clk_div_ahb_lpc …
#define clk_div_efuse …
#define clk_div_tx_eth0 …
#define clk_div_ptp_ref_i_eth0 …
#define clk_div_ref_eth0 …
#define clk_div_emmc …
#define clk_div_sd …
#define clk_div_top_axi0 …
#define clk_div_100k_emmc …
#define clk_div_100k_sd …
#define clk_div_gpio_db …
#define clk_div_top_axi_hsperi …
static struct sg2042_divider_clock sg2042_div_clks_level_2[] = …;
static const struct clk_hw *clk_gate_rp_cpu_normal[] = …;
static const struct clk_hw *clk_gate_top_rp_cmn_div2[] = …;
static const struct sg2042_gate_clock sg2042_gate_clks_level_2[] = …;
static DEFINE_SPINLOCK(sg2042_clk_lock);
static int sg2042_clk_register_divs(struct device *dev,
struct sg2042_clk_data *clk_data,
struct sg2042_divider_clock div_clks[],
int num_div_clks)
{ … }
static int sg2042_clk_register_gates(struct device *dev,
struct sg2042_clk_data *clk_data,
const struct sg2042_gate_clock gate_clks[],
int num_gate_clks)
{ … }
static int sg2042_clk_register_gates_fw(struct device *dev,
struct sg2042_clk_data *clk_data,
const struct sg2042_gate_clock gate_clks[],
int num_gate_clks)
{ … }
static int sg2042_mux_notifier_cb(struct notifier_block *nb,
unsigned long event,
void *data)
{ … }
static int sg2042_clk_register_muxs(struct device *dev,
struct sg2042_clk_data *clk_data,
struct sg2042_mux_clock mux_clks[],
int num_mux_clks)
{ … }
static int sg2042_init_clkdata(struct platform_device *pdev,
int num_clks,
struct sg2042_clk_data **pp_clk_data)
{ … }
static int sg2042_clkgen_probe(struct platform_device *pdev)
{ … }
static const struct of_device_id sg2042_clkgen_match[] = …;
MODULE_DEVICE_TABLE(of, sg2042_clkgen_match);
static struct platform_driver sg2042_clkgen_driver = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;