Skip to content

Commit 23fe31d

Browse files
WeiyiLu-MediaTekbebarino
authored andcommitted
clk: mediatek: Add configurable pcw_chg_reg to mtk_pll_data
In previous MediaTek PLL design, it assumes the pcw change control is always on the CON1 register. However, the pcw change bit on MT8183 was moved onto CON0 because the the PCW length of audio PLLs are extended to 32-bit. Add configurable pcw_chg_reg to set the pcw change control register address or using the default control register CON1 if without setting in pll data. Signed-off-by: Weiyi Lu <[email protected]> Reviewed-by: James Liao <[email protected]> Reviewed-by: Nicolas Boichat <[email protected]> Tested-by: Nicolas Boichat <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent d90240b commit 23fe31d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

drivers/clk/mediatek/clk-mtk.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ struct mtk_pll_data {
233233
int pcwibits;
234234
uint32_t pcw_reg;
235235
int pcw_shift;
236+
uint32_t pcw_chg_reg;
236237
const struct mtk_pll_div_table *div_table;
237238
const char *parent_name;
238239
};

drivers/clk/mediatek/clk-pll.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define CON0_BASE_EN BIT(0)
2828
#define CON0_PWR_ON BIT(0)
2929
#define CON0_ISO_EN BIT(1)
30-
#define CON0_PCW_CHG BIT(31)
30+
#define PCW_CHG_MASK BIT(31)
3131

3232
#define AUDPLL_TUNER_EN BIT(31)
3333

@@ -51,6 +51,7 @@ struct mtk_clk_pll {
5151
void __iomem *tuner_addr;
5252
void __iomem *tuner_en_addr;
5353
void __iomem *pcw_addr;
54+
void __iomem *pcw_chg_addr;
5455
const struct mtk_pll_data *data;
5556
};
5657

@@ -122,7 +123,7 @@ static void __mtk_pll_tuner_disable(struct mtk_clk_pll *pll)
122123
static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw,
123124
int postdiv)
124125
{
125-
u32 con1, val;
126+
u32 chg, val;
126127
int pll_en;
127128

128129
pll_en = readl(pll->base_addr + REG_CON0) & CON0_BASE_EN;
@@ -147,14 +148,14 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw,
147148
val |= pcw << pll->data->pcw_shift;
148149
writel(val, pll->pcw_addr);
149150

150-
con1 = readl(pll->base_addr + REG_CON1);
151+
chg = readl(pll->pcw_chg_addr);
151152

152153
if (pll_en)
153-
con1 |= CON0_PCW_CHG;
154+
chg |= PCW_CHG_MASK;
154155

155-
writel(con1, pll->base_addr + REG_CON1);
156+
writel(chg, pll->pcw_chg_addr);
156157
if (pll->tuner_addr)
157-
writel(con1 + 1, pll->tuner_addr);
158+
writel(val + 1, pll->tuner_addr);
158159

159160
/* restore tuner_en */
160161
__mtk_pll_tuner_enable(pll);
@@ -329,6 +330,10 @@ static struct clk *mtk_clk_register_pll(const struct mtk_pll_data *data,
329330
pll->pwr_addr = base + data->pwr_reg;
330331
pll->pd_addr = base + data->pd_reg;
331332
pll->pcw_addr = base + data->pcw_reg;
333+
if (data->pcw_chg_reg)
334+
pll->pcw_chg_addr = base + data->pcw_chg_reg;
335+
else
336+
pll->pcw_chg_addr = pll->base_addr + REG_CON1;
332337
if (data->tuner_reg)
333338
pll->tuner_addr = base + data->tuner_reg;
334339
if (data->tuner_en_reg)

0 commit comments

Comments
 (0)