mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-25 01:26:05 +07:00
ea8ca3109d
With the new clk parenting code, clk_init_data was expanded to include .parent_hws and .parent_data, for clk drivers to specify parents without name strings of clocks. Also some macros were added for using these two items to reference clock parents. Based on that to expand macros for sprd clocks: - SPRD_*_DATA, take an array of struct clk_parent_data * as its parents which should be a combination of .fw_name (devicetree clock-names), .hw (pointers to a local struct clk_hw). - SPRD_*_HW, take a local struct clk_hw pointer, instead of a string, as its parent. - SPRD_*_FW_NAME, take a string of clock-names decleared in the device tree as the clock parent. Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com> Link: https://lkml.kernel.org/r/20200304072730.9193-6-zhang.lyra@gmail.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
160 lines
5.4 KiB
C
160 lines
5.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
//
|
|
// Spreadtrum gate clock driver
|
|
//
|
|
// Copyright (C) 2017 Spreadtrum, Inc.
|
|
// Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
|
|
|
|
#ifndef _SPRD_GATE_H_
|
|
#define _SPRD_GATE_H_
|
|
|
|
#include "common.h"
|
|
|
|
struct sprd_gate {
|
|
u32 enable_mask;
|
|
u16 flags;
|
|
u16 sc_offset;
|
|
u16 udelay;
|
|
|
|
struct sprd_clk_common common;
|
|
};
|
|
|
|
#define SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _udelay, _ops, _fn) \
|
|
struct sprd_gate _struct = { \
|
|
.enable_mask = _enable_mask, \
|
|
.sc_offset = _sc_offset, \
|
|
.flags = _gate_flags, \
|
|
.udelay = _udelay, \
|
|
.common = { \
|
|
.regmap = NULL, \
|
|
.reg = _reg, \
|
|
.hw.init = _fn(_name, _parent, \
|
|
_ops, _flags), \
|
|
} \
|
|
}
|
|
|
|
#define SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _udelay, _ops) \
|
|
SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _udelay, _ops, CLK_HW_INIT)
|
|
|
|
#define SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \
|
|
_enable_mask, _flags, _gate_flags, _ops) \
|
|
SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, 0, _ops)
|
|
|
|
#define SPRD_SC_GATE_CLK(_struct, _name, _parent, _reg, _sc_offset, \
|
|
_enable_mask, _flags, _gate_flags) \
|
|
SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, _sc_offset, \
|
|
_enable_mask, _flags, _gate_flags, \
|
|
&sprd_sc_gate_ops)
|
|
|
|
#define SPRD_GATE_CLK(_struct, _name, _parent, _reg, \
|
|
_enable_mask, _flags, _gate_flags) \
|
|
SPRD_SC_GATE_CLK_OPS(_struct, _name, _parent, _reg, 0, \
|
|
_enable_mask, _flags, _gate_flags, \
|
|
&sprd_gate_ops)
|
|
|
|
#define SPRD_PLL_SC_GATE_CLK(_struct, _name, _parent, _reg, _sc_offset, \
|
|
_enable_mask, _flags, _gate_flags, \
|
|
_udelay) \
|
|
SPRD_SC_GATE_CLK_OPS_UDELAY(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _udelay, \
|
|
&sprd_pll_sc_gate_ops)
|
|
|
|
|
|
#define SPRD_SC_GATE_CLK_HW_OPS_UDELAY(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, \
|
|
_flags, _gate_flags, \
|
|
_udelay, _ops) \
|
|
SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _udelay, _ops, \
|
|
CLK_HW_INIT_HW)
|
|
|
|
#define SPRD_SC_GATE_CLK_HW_OPS(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _ops) \
|
|
SPRD_SC_GATE_CLK_HW_OPS_UDELAY(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, \
|
|
_flags, _gate_flags, 0, _ops)
|
|
|
|
#define SPRD_SC_GATE_CLK_HW(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags) \
|
|
SPRD_SC_GATE_CLK_HW_OPS(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, &sprd_sc_gate_ops)
|
|
|
|
#define SPRD_GATE_CLK_HW(_struct, _name, _parent, _reg, \
|
|
_enable_mask, _flags, _gate_flags) \
|
|
SPRD_SC_GATE_CLK_HW_OPS(_struct, _name, _parent, _reg, 0, \
|
|
_enable_mask, _flags, _gate_flags, \
|
|
&sprd_gate_ops)
|
|
|
|
#define SPRD_PLL_SC_GATE_CLK_HW(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _udelay) \
|
|
SPRD_SC_GATE_CLK_HW_OPS_UDELAY(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, \
|
|
_flags, _gate_flags, _udelay, \
|
|
&sprd_pll_sc_gate_ops)
|
|
|
|
#define SPRD_SC_GATE_CLK_FW_NAME_OPS_UDELAY(_struct, _name, _parent, \
|
|
_reg, _sc_offset, \
|
|
_enable_mask, _flags, \
|
|
_gate_flags, _udelay, _ops) \
|
|
SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _udelay, _ops, \
|
|
CLK_HW_INIT_FW_NAME)
|
|
|
|
#define SPRD_SC_GATE_CLK_FW_NAME_OPS(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _ops) \
|
|
SPRD_SC_GATE_CLK_FW_NAME_OPS_UDELAY(_struct, _name, _parent, \
|
|
_reg, _sc_offset, \
|
|
_enable_mask, _flags, \
|
|
_gate_flags, 0, _ops)
|
|
|
|
#define SPRD_SC_GATE_CLK_FW_NAME(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags) \
|
|
SPRD_SC_GATE_CLK_FW_NAME_OPS(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, &sprd_sc_gate_ops)
|
|
|
|
#define SPRD_GATE_CLK_FW_NAME(_struct, _name, _parent, _reg, \
|
|
_enable_mask, _flags, _gate_flags) \
|
|
SPRD_SC_GATE_CLK_FW_NAME_OPS(_struct, _name, _parent, _reg, 0, \
|
|
_enable_mask, _flags, _gate_flags, \
|
|
&sprd_gate_ops)
|
|
|
|
#define SPRD_PLL_SC_GATE_CLK_FW_NAME(_struct, _name, _parent, _reg, \
|
|
_sc_offset, _enable_mask, _flags, \
|
|
_gate_flags, _udelay) \
|
|
SPRD_SC_GATE_CLK_FW_NAME_OPS_UDELAY(_struct, _name, _parent, \
|
|
_reg, _sc_offset, \
|
|
_enable_mask, _flags, \
|
|
_gate_flags, _udelay, \
|
|
&sprd_pll_sc_gate_ops)
|
|
|
|
static inline struct sprd_gate *hw_to_sprd_gate(const struct clk_hw *hw)
|
|
{
|
|
struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
|
|
|
|
return container_of(common, struct sprd_gate, common);
|
|
}
|
|
|
|
extern const struct clk_ops sprd_gate_ops;
|
|
extern const struct clk_ops sprd_sc_gate_ops;
|
|
extern const struct clk_ops sprd_pll_sc_gate_ops;
|
|
|
|
#endif /* _SPRD_GATE_H_ */
|