mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 22:35:14 +07:00
d633fb7ac1
The pericfg and infracfg units also provide reset lines to several other SoC internal units. This adds a function which can be called from the pericfg and infracfg initialization functions which will register the reset controller using reset_controller_register. The reset controller will provide support for resetting the units connected to the pericfg and infracfg controller. The units resetted by this controller can use the standard reset device tree binding to gain access to the reset lines. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
170 lines
4.0 KiB
C
170 lines
4.0 KiB
C
/*
|
|
* Copyright (c) 2014 MediaTek Inc.
|
|
* Author: James Liao <jamesjj.liao@mediatek.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#ifndef __DRV_CLK_MTK_H
|
|
#define __DRV_CLK_MTK_H
|
|
|
|
#include <linux/regmap.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/clk.h>
|
|
#include <linux/clk-provider.h>
|
|
|
|
#define MAX_MUX_GATE_BIT 31
|
|
#define INVALID_MUX_GATE_BIT (MAX_MUX_GATE_BIT + 1)
|
|
|
|
#define MHZ (1000 * 1000)
|
|
|
|
struct mtk_fixed_factor {
|
|
int id;
|
|
const char *name;
|
|
const char *parent_name;
|
|
int mult;
|
|
int div;
|
|
};
|
|
|
|
#define FACTOR(_id, _name, _parent, _mult, _div) { \
|
|
.id = _id, \
|
|
.name = _name, \
|
|
.parent_name = _parent, \
|
|
.mult = _mult, \
|
|
.div = _div, \
|
|
}
|
|
|
|
extern void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
|
|
int num, struct clk_onecell_data *clk_data);
|
|
|
|
struct mtk_composite {
|
|
int id;
|
|
const char *name;
|
|
const char * const *parent_names;
|
|
const char *parent;
|
|
unsigned flags;
|
|
|
|
uint32_t mux_reg;
|
|
uint32_t divider_reg;
|
|
uint32_t gate_reg;
|
|
|
|
signed char mux_shift;
|
|
signed char mux_width;
|
|
signed char gate_shift;
|
|
|
|
signed char divider_shift;
|
|
signed char divider_width;
|
|
|
|
signed char num_parents;
|
|
};
|
|
|
|
#define MUX_GATE(_id, _name, _parents, _reg, _shift, _width, _gate) { \
|
|
.id = _id, \
|
|
.name = _name, \
|
|
.mux_reg = _reg, \
|
|
.mux_shift = _shift, \
|
|
.mux_width = _width, \
|
|
.gate_reg = _reg, \
|
|
.gate_shift = _gate, \
|
|
.divider_shift = -1, \
|
|
.parent_names = _parents, \
|
|
.num_parents = ARRAY_SIZE(_parents), \
|
|
.flags = CLK_SET_RATE_PARENT, \
|
|
}
|
|
|
|
#define MUX(_id, _name, _parents, _reg, _shift, _width) { \
|
|
.id = _id, \
|
|
.name = _name, \
|
|
.mux_reg = _reg, \
|
|
.mux_shift = _shift, \
|
|
.mux_width = _width, \
|
|
.gate_shift = -1, \
|
|
.divider_shift = -1, \
|
|
.parent_names = _parents, \
|
|
.num_parents = ARRAY_SIZE(_parents), \
|
|
.flags = CLK_SET_RATE_PARENT, \
|
|
}
|
|
|
|
#define DIV_GATE(_id, _name, _parent, _gate_reg, _gate_shift, _div_reg, _div_width, _div_shift) { \
|
|
.id = _id, \
|
|
.parent = _parent, \
|
|
.name = _name, \
|
|
.divider_reg = _div_reg, \
|
|
.divider_shift = _div_shift, \
|
|
.divider_width = _div_width, \
|
|
.gate_reg = _gate_reg, \
|
|
.gate_shift = _gate_shift, \
|
|
.mux_shift = -1, \
|
|
.flags = 0, \
|
|
}
|
|
|
|
struct clk *mtk_clk_register_composite(const struct mtk_composite *mc,
|
|
void __iomem *base, spinlock_t *lock);
|
|
|
|
void mtk_clk_register_composites(const struct mtk_composite *mcs,
|
|
int num, void __iomem *base, spinlock_t *lock,
|
|
struct clk_onecell_data *clk_data);
|
|
|
|
struct mtk_gate_regs {
|
|
u32 sta_ofs;
|
|
u32 clr_ofs;
|
|
u32 set_ofs;
|
|
};
|
|
|
|
struct mtk_gate {
|
|
int id;
|
|
const char *name;
|
|
const char *parent_name;
|
|
const struct mtk_gate_regs *regs;
|
|
int shift;
|
|
const struct clk_ops *ops;
|
|
};
|
|
|
|
int mtk_clk_register_gates(struct device_node *node, const struct mtk_gate *clks,
|
|
int num, struct clk_onecell_data *clk_data);
|
|
|
|
struct clk_onecell_data *mtk_alloc_clk_data(unsigned int clk_num);
|
|
|
|
#define HAVE_RST_BAR BIT(0)
|
|
|
|
struct mtk_pll_data {
|
|
int id;
|
|
const char *name;
|
|
uint32_t reg;
|
|
uint32_t pwr_reg;
|
|
uint32_t en_mask;
|
|
uint32_t pd_reg;
|
|
uint32_t tuner_reg;
|
|
int pd_shift;
|
|
unsigned int flags;
|
|
const struct clk_ops *ops;
|
|
u32 rst_bar_mask;
|
|
unsigned long fmax;
|
|
int pcwbits;
|
|
uint32_t pcw_reg;
|
|
int pcw_shift;
|
|
};
|
|
|
|
void __init mtk_clk_register_plls(struct device_node *node,
|
|
const struct mtk_pll_data *plls, int num_plls,
|
|
struct clk_onecell_data *clk_data);
|
|
|
|
#ifdef CONFIG_RESET_CONTROLLER
|
|
void mtk_register_reset_controller(struct device_node *np,
|
|
unsigned int num_regs, int regofs);
|
|
#else
|
|
static inline void mtk_register_reset_controller(struct device_node *np,
|
|
unsigned int num_regs, int regofs)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#endif /* __DRV_CLK_MTK_H */
|