Skip to content

Commit 1a91e31

Browse files
committed
Merge branches 'clk-fallthru', 'clk-ingenic', 'clk-tegra', 'clk-sirf' and 'clk-qoriq' into clk-next
- Add RTC related clks on Ingenic SoCs - Support USB PHY clks on Ingenic SoCs * clk-fallthru: clk: davinci: Use fallthrough pseudo-keyword clk: imx: Use fallthrough pseudo-keyword * clk-ingenic: clk: X1000: Add support for calculat REFCLK of USB PHY. clk: JZ4780: Reformat the code to align it. clk: JZ4780: Add functions for enable and disable USB PHY. clk: Ingenic: Add RTC related clocks for Ingenic SoCs. dt-bindings: clock: Add tabs to align code. dt-bindings: clock: Add RTC related clocks for Ingenic SoCs. * clk-tegra: clk: tegra: pll: Improve PLLM enable-state detection * clk-sirf: clk: clk-atlas6: fix return value check in atlas6_clk_init() * clk-qoriq: clk: qoriq: add LS1021A core pll mux options
6 parents 53e0742 + 7a346a3 + 810797c + fa64023 + 12b90b4 + 92df3a9 commit 1a91e31

File tree

11 files changed

+305
-156
lines changed

11 files changed

+305
-156
lines changed

drivers/clk/clk-qoriq.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@ static const struct clockgen_muxinfo clockgen2_cmux_cgb = {
244244
},
245245
};
246246

247+
static const struct clockgen_muxinfo ls1021a_cmux = {
248+
{
249+
{ CLKSEL_VALID, CGA_PLL1, PLL_DIV1 },
250+
{ CLKSEL_VALID, CGA_PLL1, PLL_DIV2 },
251+
{ CLKSEL_VALID, CGA_PLL1, PLL_DIV4 },
252+
}
253+
};
254+
247255
static const struct clockgen_muxinfo ls1028a_hwa1 = {
248256
{
249257
{ CLKSEL_VALID, PLATFORM_PLL, PLL_DIV1 },
@@ -577,7 +585,7 @@ static const struct clockgen_chipinfo chipinfo[] = {
577585
{
578586
.compat = "fsl,ls1021a-clockgen",
579587
.cmux_groups = {
580-
&t1023_cmux
588+
&ls1021a_cmux
581589
},
582590
.cmux_to_group = {
583591
0, -1

drivers/clk/davinci/pll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ static int davinci_pll_sysclk_rate_change(struct notifier_block *nb,
651651
pllcmd = readl(pll->base + PLLCMD);
652652
pllcmd |= PLLCMD_GOSET;
653653
writel(pllcmd, pll->base + PLLCMD);
654-
/* fallthrough */
654+
fallthrough;
655655
case PRE_RATE_CHANGE:
656656
/* Wait until for outstanding changes to take effect */
657657
do {

drivers/clk/imx/clk-pllv3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,15 +433,15 @@ struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name,
433433
break;
434434
case IMX_PLLV3_USB_VF610:
435435
pll->div_shift = 1;
436-
/* fall through */
436+
fallthrough;
437437
case IMX_PLLV3_USB:
438438
ops = &clk_pllv3_ops;
439439
pll->powerup_set = true;
440440
break;
441441
case IMX_PLLV3_AV_IMX7:
442442
pll->num_offset = PLL_IMX7_NUM_OFFSET;
443443
pll->denom_offset = PLL_IMX7_DENOM_OFFSET;
444-
/* fall through */
444+
fallthrough;
445445
case IMX_PLLV3_AV:
446446
ops = &clk_pllv3_av_ops;
447447
break;

drivers/clk/ingenic/jz4780-cgu.c

Lines changed: 91 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* Copyright (c) 2013-2015 Imagination Technologies
66
* Author: Paul Burton <[email protected]>
7+
* Copyright (c) 2020 周琰杰 (Zhou Yanjie) <[email protected]>
78
*/
89

910
#include <linux/clk-provider.h>
@@ -19,49 +20,50 @@
1920

2021
/* CGU register offsets */
2122
#define CGU_REG_CLOCKCONTROL 0x00
22-
#define CGU_REG_LCR 0x04
23-
#define CGU_REG_APLL 0x10
24-
#define CGU_REG_MPLL 0x14
25-
#define CGU_REG_EPLL 0x18
26-
#define CGU_REG_VPLL 0x1c
27-
#define CGU_REG_CLKGR0 0x20
28-
#define CGU_REG_OPCR 0x24
29-
#define CGU_REG_CLKGR1 0x28
30-
#define CGU_REG_DDRCDR 0x2c
31-
#define CGU_REG_VPUCDR 0x30
32-
#define CGU_REG_USBPCR 0x3c
33-
#define CGU_REG_USBRDT 0x40
34-
#define CGU_REG_USBVBFIL 0x44
35-
#define CGU_REG_USBPCR1 0x48
36-
#define CGU_REG_LP0CDR 0x54
37-
#define CGU_REG_I2SCDR 0x60
38-
#define CGU_REG_LP1CDR 0x64
39-
#define CGU_REG_MSC0CDR 0x68
40-
#define CGU_REG_UHCCDR 0x6c
41-
#define CGU_REG_SSICDR 0x74
42-
#define CGU_REG_CIMCDR 0x7c
43-
#define CGU_REG_PCMCDR 0x84
44-
#define CGU_REG_GPUCDR 0x88
45-
#define CGU_REG_HDMICDR 0x8c
46-
#define CGU_REG_MSC1CDR 0xa4
47-
#define CGU_REG_MSC2CDR 0xa8
48-
#define CGU_REG_BCHCDR 0xac
49-
#define CGU_REG_CLOCKSTATUS 0xd4
23+
#define CGU_REG_LCR 0x04
24+
#define CGU_REG_APLL 0x10
25+
#define CGU_REG_MPLL 0x14
26+
#define CGU_REG_EPLL 0x18
27+
#define CGU_REG_VPLL 0x1c
28+
#define CGU_REG_CLKGR0 0x20
29+
#define CGU_REG_OPCR 0x24
30+
#define CGU_REG_CLKGR1 0x28
31+
#define CGU_REG_DDRCDR 0x2c
32+
#define CGU_REG_VPUCDR 0x30
33+
#define CGU_REG_USBPCR 0x3c
34+
#define CGU_REG_USBRDT 0x40
35+
#define CGU_REG_USBVBFIL 0x44
36+
#define CGU_REG_USBPCR1 0x48
37+
#define CGU_REG_LP0CDR 0x54
38+
#define CGU_REG_I2SCDR 0x60
39+
#define CGU_REG_LP1CDR 0x64
40+
#define CGU_REG_MSC0CDR 0x68
41+
#define CGU_REG_UHCCDR 0x6c
42+
#define CGU_REG_SSICDR 0x74
43+
#define CGU_REG_CIMCDR 0x7c
44+
#define CGU_REG_PCMCDR 0x84
45+
#define CGU_REG_GPUCDR 0x88
46+
#define CGU_REG_HDMICDR 0x8c
47+
#define CGU_REG_MSC1CDR 0xa4
48+
#define CGU_REG_MSC2CDR 0xa8
49+
#define CGU_REG_BCHCDR 0xac
50+
#define CGU_REG_CLOCKSTATUS 0xd4
5051

5152
/* bits within the OPCR register */
52-
#define OPCR_SPENDN0 BIT(7)
53-
#define OPCR_SPENDN1 BIT(6)
53+
#define OPCR_SPENDN0 BIT(7)
54+
#define OPCR_SPENDN1 BIT(6)
5455

5556
/* bits within the USBPCR register */
56-
#define USBPCR_USB_MODE BIT(31)
57+
#define USBPCR_USB_MODE BIT(31)
5758
#define USBPCR_IDPULLUP_MASK (0x3 << 28)
58-
#define USBPCR_COMMONONN BIT(25)
59-
#define USBPCR_VBUSVLDEXT BIT(24)
59+
#define USBPCR_COMMONONN BIT(25)
60+
#define USBPCR_VBUSVLDEXT BIT(24)
6061
#define USBPCR_VBUSVLDEXTSEL BIT(23)
61-
#define USBPCR_POR BIT(22)
62-
#define USBPCR_OTG_DISABLE BIT(20)
62+
#define USBPCR_POR BIT(22)
63+
#define USBPCR_SIDDQ BIT(21)
64+
#define USBPCR_OTG_DISABLE BIT(20)
6365
#define USBPCR_COMPDISTUNE_MASK (0x7 << 17)
64-
#define USBPCR_OTGTUNE_MASK (0x7 << 14)
66+
#define USBPCR_OTGTUNE_MASK (0x7 << 14)
6567
#define USBPCR_SQRXTUNE_MASK (0x7 << 11)
6668
#define USBPCR_TXFSLSTUNE_MASK (0xf << 7)
6769
#define USBPCR_TXPREEMPHTUNE BIT(6)
@@ -78,54 +80,28 @@
7880
#define USBPCR1_REFCLKDIV_48 (0x2 << USBPCR1_REFCLKDIV_SHIFT)
7981
#define USBPCR1_REFCLKDIV_24 (0x1 << USBPCR1_REFCLKDIV_SHIFT)
8082
#define USBPCR1_REFCLKDIV_12 (0x0 << USBPCR1_REFCLKDIV_SHIFT)
81-
#define USBPCR1_USB_SEL BIT(28)
82-
#define USBPCR1_WORD_IF0 BIT(19)
83-
#define USBPCR1_WORD_IF1 BIT(18)
83+
#define USBPCR1_USB_SEL BIT(28)
84+
#define USBPCR1_WORD_IF0 BIT(19)
85+
#define USBPCR1_WORD_IF1 BIT(18)
8486

8587
/* bits within the USBRDT register */
86-
#define USBRDT_VBFIL_LD_EN BIT(25)
87-
#define USBRDT_USBRDT_MASK 0x7fffff
88+
#define USBRDT_VBFIL_LD_EN BIT(25)
89+
#define USBRDT_USBRDT_MASK 0x7fffff
8890

8991
/* bits within the USBVBFIL register */
9092
#define USBVBFIL_IDDIGFIL_SHIFT 16
9193
#define USBVBFIL_IDDIGFIL_MASK (0xffff << USBVBFIL_IDDIGFIL_SHIFT)
9294
#define USBVBFIL_USBVBFIL_MASK (0xffff)
9395

9496
/* bits within the LCR register */
95-
#define LCR_PD_SCPU BIT(31)
96-
#define LCR_SCPUS BIT(27)
97+
#define LCR_PD_SCPU BIT(31)
98+
#define LCR_SCPUS BIT(27)
9799

98100
/* bits within the CLKGR1 register */
99-
#define CLKGR1_CORE1 BIT(15)
101+
#define CLKGR1_CORE1 BIT(15)
100102

101103
static struct ingenic_cgu *cgu;
102104

103-
static u8 jz4780_otg_phy_get_parent(struct clk_hw *hw)
104-
{
105-
/* we only use CLKCORE, revisit if that ever changes */
106-
return 0;
107-
}
108-
109-
static int jz4780_otg_phy_set_parent(struct clk_hw *hw, u8 idx)
110-
{
111-
unsigned long flags;
112-
u32 usbpcr1;
113-
114-
if (idx > 0)
115-
return -EINVAL;
116-
117-
spin_lock_irqsave(&cgu->lock, flags);
118-
119-
usbpcr1 = readl(cgu->base + CGU_REG_USBPCR1);
120-
usbpcr1 &= ~USBPCR1_REFCLKSEL_MASK;
121-
/* we only use CLKCORE */
122-
usbpcr1 |= USBPCR1_REFCLKSEL_CORE;
123-
writel(usbpcr1, cgu->base + CGU_REG_USBPCR1);
124-
125-
spin_unlock_irqrestore(&cgu->lock, flags);
126-
return 0;
127-
}
128-
129105
static unsigned long jz4780_otg_phy_recalc_rate(struct clk_hw *hw,
130106
unsigned long parent_rate)
131107
{
@@ -149,7 +125,6 @@ static unsigned long jz4780_otg_phy_recalc_rate(struct clk_hw *hw,
149125
return 19200000;
150126
}
151127

152-
BUG();
153128
return parent_rate;
154129
}
155130

@@ -206,13 +181,43 @@ static int jz4780_otg_phy_set_rate(struct clk_hw *hw, unsigned long req_rate,
206181
return 0;
207182
}
208183

209-
static const struct clk_ops jz4780_otg_phy_ops = {
210-
.get_parent = jz4780_otg_phy_get_parent,
211-
.set_parent = jz4780_otg_phy_set_parent,
184+
static int jz4780_otg_phy_enable(struct clk_hw *hw)
185+
{
186+
void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR;
187+
void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR;
188+
189+
writel(readl(reg_opcr) | OPCR_SPENDN0, reg_opcr);
190+
writel(readl(reg_usbpcr) & ~USBPCR_OTG_DISABLE & ~USBPCR_SIDDQ, reg_usbpcr);
191+
return 0;
192+
}
212193

194+
static void jz4780_otg_phy_disable(struct clk_hw *hw)
195+
{
196+
void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR;
197+
void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR;
198+
199+
writel(readl(reg_opcr) & ~OPCR_SPENDN0, reg_opcr);
200+
writel(readl(reg_usbpcr) | USBPCR_OTG_DISABLE | USBPCR_SIDDQ, reg_usbpcr);
201+
}
202+
203+
static int jz4780_otg_phy_is_enabled(struct clk_hw *hw)
204+
{
205+
void __iomem *reg_opcr = cgu->base + CGU_REG_OPCR;
206+
void __iomem *reg_usbpcr = cgu->base + CGU_REG_USBPCR;
207+
208+
return (readl(reg_opcr) & OPCR_SPENDN0) &&
209+
!(readl(reg_usbpcr) & USBPCR_SIDDQ) &&
210+
!(readl(reg_usbpcr) & USBPCR_OTG_DISABLE);
211+
}
212+
213+
static const struct clk_ops jz4780_otg_phy_ops = {
213214
.recalc_rate = jz4780_otg_phy_recalc_rate,
214215
.round_rate = jz4780_otg_phy_round_rate,
215216
.set_rate = jz4780_otg_phy_set_rate,
217+
218+
.enable = jz4780_otg_phy_enable,
219+
.disable = jz4780_otg_phy_disable,
220+
.is_enabled = jz4780_otg_phy_is_enabled,
216221
};
217222

218223
static int jz4780_core1_enable(struct clk_hw *hw)
@@ -516,6 +521,18 @@ static const struct ingenic_cgu_clk_info jz4780_cgu_clocks[] = {
516521
.gate = { CGU_REG_CLKGR0, 1 },
517522
},
518523

524+
[JZ4780_CLK_EXCLK_DIV512] = {
525+
"exclk_div512", CGU_CLK_FIXDIV,
526+
.parents = { JZ4780_CLK_EXCLK },
527+
.fixdiv = { 512 },
528+
},
529+
530+
[JZ4780_CLK_RTC] = {
531+
"rtc_ercs", CGU_CLK_MUX | CGU_CLK_GATE,
532+
.parents = { JZ4780_CLK_EXCLK_DIV512, JZ4780_CLK_RTCLK },
533+
.mux = { CGU_REG_OPCR, 2, 1},
534+
},
535+
519536
/* Gate-only clocks */
520537

521538
[JZ4780_CLK_NEMC] = {

0 commit comments

Comments
 (0)