mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
clk: sunxi-ng: sun6i-rtc: Add feature bit for IOSC calibration
The sun6i-rtc CCU driver currently uses a global static variable to denote whether calibration is supported, which makes IOSC operations tightly coupled to this file. Convert this into a feature bit to decouple the logic. This allows the IOSC clock code to be moved into a shared module for reuse by other SoCs. Signed-off-by: Junhui Liu <junhui.liu@pigmoral.tech> Reviewed-by: Chen-Yu Tsai <wens@kernel.org> Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Link: https://patch.msgid.link/20260706-a733-rtc-v4-5-f330728db3d3@baylibre.com Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
This commit is contained in:
parent
192c6220e1
commit
d2fcd82ca0
|
|
@ -52,8 +52,6 @@ struct sun6i_rtc_match_data {
|
|||
u8 osc32k_fanout_nparents;
|
||||
};
|
||||
|
||||
static bool have_iosc_calibration;
|
||||
|
||||
static int ccu_iosc_enable(struct clk_hw *hw)
|
||||
{
|
||||
struct ccu_common *cm = hw_to_ccu_common(hw);
|
||||
|
|
@ -80,7 +78,7 @@ static unsigned long ccu_iosc_recalc_rate(struct clk_hw *hw,
|
|||
{
|
||||
struct ccu_common *cm = hw_to_ccu_common(hw);
|
||||
|
||||
if (have_iosc_calibration) {
|
||||
if (cm->features & CCU_FEATURE_IOSC_CALIBRATION) {
|
||||
u32 reg = readl(cm->base + IOSC_CLK_CALI_REG);
|
||||
|
||||
/*
|
||||
|
|
@ -119,7 +117,7 @@ static int ccu_iosc_32k_prepare(struct clk_hw *hw)
|
|||
struct ccu_common *cm = hw_to_ccu_common(hw);
|
||||
u32 val;
|
||||
|
||||
if (!have_iosc_calibration)
|
||||
if (!(cm->features & CCU_FEATURE_IOSC_CALIBRATION))
|
||||
return 0;
|
||||
|
||||
val = readl(cm->base + IOSC_CLK_CALI_REG);
|
||||
|
|
@ -134,7 +132,7 @@ static void ccu_iosc_32k_unprepare(struct clk_hw *hw)
|
|||
struct ccu_common *cm = hw_to_ccu_common(hw);
|
||||
u32 val;
|
||||
|
||||
if (!have_iosc_calibration)
|
||||
if (!(cm->features & CCU_FEATURE_IOSC_CALIBRATION))
|
||||
return;
|
||||
|
||||
val = readl(cm->base + IOSC_CLK_CALI_REG);
|
||||
|
|
@ -148,7 +146,7 @@ static unsigned long ccu_iosc_32k_recalc_rate(struct clk_hw *hw,
|
|||
struct ccu_common *cm = hw_to_ccu_common(hw);
|
||||
u32 val;
|
||||
|
||||
if (have_iosc_calibration) {
|
||||
if (cm->features & CCU_FEATURE_IOSC_CALIBRATION) {
|
||||
val = readl(cm->base + IOSC_CLK_CALI_REG);
|
||||
|
||||
/* Assume the calibrated 32k clock is accurate. */
|
||||
|
|
@ -167,7 +165,7 @@ static unsigned long ccu_iosc_32k_recalc_accuracy(struct clk_hw *hw,
|
|||
struct ccu_common *cm = hw_to_ccu_common(hw);
|
||||
u32 val;
|
||||
|
||||
if (have_iosc_calibration) {
|
||||
if (cm->features & CCU_FEATURE_IOSC_CALIBRATION) {
|
||||
val = readl(cm->base + IOSC_CLK_CALI_REG);
|
||||
|
||||
/* Assume the calibrated 32k clock is accurate. */
|
||||
|
|
@ -358,7 +356,10 @@ int sun6i_rtc_ccu_probe(struct device *dev, void __iomem *reg)
|
|||
return 0;
|
||||
|
||||
data = match->data;
|
||||
have_iosc_calibration = data->have_iosc_calibration;
|
||||
if (data->have_iosc_calibration) {
|
||||
iosc_clk.features |= CCU_FEATURE_IOSC_CALIBRATION;
|
||||
iosc_32k_clk.features |= CCU_FEATURE_IOSC_CALIBRATION;
|
||||
}
|
||||
|
||||
if (!data->have_ext_osc32k) {
|
||||
/* ext-osc32k-gate is an orphan, so do not register it. */
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#define CCU_FEATURE_CLOSEST_RATE BIT(9)
|
||||
#define CCU_FEATURE_DUAL_DIV BIT(10)
|
||||
#define CCU_FEATURE_UPDATE_BIT BIT(11)
|
||||
#define CCU_FEATURE_IOSC_CALIBRATION BIT(12)
|
||||
|
||||
/* MMC timing mode switch bit */
|
||||
#define CCU_MMC_NEW_TIMING_MODE BIT(30)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user