Skip to content

Commit b6f3162

Browse files
committed
Merge branches 'clk-unisoc', 'clk-trivial', 'clk-bcm', 'clk-st' and 'clk-ast2600' into clk-next
* clk-unisoc: clk: sprd: add mipi_csi_xx gate clocks clk: sprd: add dt-bindings include for mipi_csi_xx clocks dt-bindings: clk: sprd: add mipi_csi_xx clocks for SC9863A clk: sprd: check its parent status before reading gate clock clk: sprd: return correct type of value for _sprd_pll_recalc_rate clk: sprd: mark the local clock symbols static * clk-trivial: clk: versatile: remove redundant assignment to pointer clk clk: clk-xgene: Fix a typo in Kconfig clk: Remove unused inline function clk_debug_reparent * clk-bcm: clk: bcm2835: Constify struct debugfs_reg32 clk: bcm2835: Remove casting to bcm2835_clk_register clk: bcm2835: Fix return type of bcm2835_register_gate * clk-st: clk: clk-flexgen: fix clock-critical handling * clk-ast2600: clk: ast2600: Fix AHB clock divider for A1
6 parents 8c88e56 + 2c1c969 + 6f4d3c1 + dc54326 + a403bba + 2d49106 commit b6f3162

File tree

12 files changed

+142
-66
lines changed

12 files changed

+142
-66
lines changed

Documentation/devicetree/bindings/clock/sprd,sc9863a-clk.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ properties:
2828
- sprd,sc9863a-rpll
2929
- sprd,sc9863a-dpll
3030
- sprd,sc9863a-mm-gate
31+
- sprd,sc9863a-mm-clk
3132
- sprd,sc9863a-apapb-gate
3233

3334
clocks:

drivers/clk/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ config COMMON_CLK_XGENE
267267
default ARCH_XGENE
268268
depends on ARM64 || COMPILE_TEST
269269
---help---
270-
Sypport for the APM X-Gene SoC reference, PLL, and device clocks.
270+
Support for the APM X-Gene SoC reference, PLL, and device clocks.
271271

272272
config COMMON_CLK_LOCHNAGAR
273273
tristate "Cirrus Logic Lochnagar clock driver"

drivers/clk/bcm/clk-bcm2835.c

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ static unsigned long bcm2835_measure_tcnt_mux(struct bcm2835_cprman *cprman,
396396
}
397397

398398
static void bcm2835_debugfs_regset(struct bcm2835_cprman *cprman, u32 base,
399-
struct debugfs_reg32 *regs, size_t nregs,
400-
struct dentry *dentry)
399+
const struct debugfs_reg32 *regs,
400+
size_t nregs, struct dentry *dentry)
401401
{
402402
struct debugfs_regset32 *regset;
403403

@@ -1240,7 +1240,7 @@ static u8 bcm2835_clock_get_parent(struct clk_hw *hw)
12401240
return (src & CM_SRC_MASK) >> CM_SRC_SHIFT;
12411241
}
12421242

1243-
static struct debugfs_reg32 bcm2835_debugfs_clock_reg32[] = {
1243+
static const struct debugfs_reg32 bcm2835_debugfs_clock_reg32[] = {
12441244
{
12451245
.name = "ctl",
12461246
.offset = 0,
@@ -1296,8 +1296,9 @@ static const struct clk_ops bcm2835_vpu_clock_clk_ops = {
12961296
};
12971297

12981298
static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
1299-
const struct bcm2835_pll_data *data)
1299+
const void *data)
13001300
{
1301+
const struct bcm2835_pll_data *pll_data = data;
13011302
struct bcm2835_pll *pll;
13021303
struct clk_init_data init;
13031304
int ret;
@@ -1307,7 +1308,7 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
13071308
/* All of the PLLs derive from the external oscillator. */
13081309
init.parent_names = &cprman->real_parent_names[0];
13091310
init.num_parents = 1;
1310-
init.name = data->name;
1311+
init.name = pll_data->name;
13111312
init.ops = &bcm2835_pll_clk_ops;
13121313
init.flags = CLK_IGNORE_UNUSED;
13131314

@@ -1316,7 +1317,7 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
13161317
return NULL;
13171318

13181319
pll->cprman = cprman;
1319-
pll->data = data;
1320+
pll->data = pll_data;
13201321
pll->hw.init = &init;
13211322

13221323
ret = devm_clk_hw_register(cprman->dev, &pll->hw);
@@ -1327,35 +1328,36 @@ static struct clk_hw *bcm2835_register_pll(struct bcm2835_cprman *cprman,
13271328

13281329
static struct clk_hw *
13291330
bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
1330-
const struct bcm2835_pll_divider_data *data)
1331+
const void *data)
13311332
{
1333+
const struct bcm2835_pll_divider_data *divider_data = data;
13321334
struct bcm2835_pll_divider *divider;
13331335
struct clk_init_data init;
13341336
const char *divider_name;
13351337
int ret;
13361338

1337-
if (data->fixed_divider != 1) {
1339+
if (divider_data->fixed_divider != 1) {
13381340
divider_name = devm_kasprintf(cprman->dev, GFP_KERNEL,
1339-
"%s_prediv", data->name);
1341+
"%s_prediv", divider_data->name);
13401342
if (!divider_name)
13411343
return NULL;
13421344
} else {
1343-
divider_name = data->name;
1345+
divider_name = divider_data->name;
13441346
}
13451347

13461348
memset(&init, 0, sizeof(init));
13471349

1348-
init.parent_names = &data->source_pll;
1350+
init.parent_names = &divider_data->source_pll;
13491351
init.num_parents = 1;
13501352
init.name = divider_name;
13511353
init.ops = &bcm2835_pll_divider_clk_ops;
1352-
init.flags = data->flags | CLK_IGNORE_UNUSED;
1354+
init.flags = divider_data->flags | CLK_IGNORE_UNUSED;
13531355

13541356
divider = devm_kzalloc(cprman->dev, sizeof(*divider), GFP_KERNEL);
13551357
if (!divider)
13561358
return NULL;
13571359

1358-
divider->div.reg = cprman->regs + data->a2w_reg;
1360+
divider->div.reg = cprman->regs + divider_data->a2w_reg;
13591361
divider->div.shift = A2W_PLL_DIV_SHIFT;
13601362
divider->div.width = A2W_PLL_DIV_BITS;
13611363
divider->div.flags = CLK_DIVIDER_MAX_AT_ZERO;
@@ -1364,7 +1366,7 @@ bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
13641366
divider->div.table = NULL;
13651367

13661368
divider->cprman = cprman;
1367-
divider->data = data;
1369+
divider->data = divider_data;
13681370

13691371
ret = devm_clk_hw_register(cprman->dev, &divider->div.hw);
13701372
if (ret)
@@ -1374,20 +1376,22 @@ bcm2835_register_pll_divider(struct bcm2835_cprman *cprman,
13741376
* PLLH's channels have a fixed divide by 10 afterwards, which
13751377
* is what our consumers are actually using.
13761378
*/
1377-
if (data->fixed_divider != 1) {
1378-
return clk_hw_register_fixed_factor(cprman->dev, data->name,
1379+
if (divider_data->fixed_divider != 1) {
1380+
return clk_hw_register_fixed_factor(cprman->dev,
1381+
divider_data->name,
13791382
divider_name,
13801383
CLK_SET_RATE_PARENT,
13811384
1,
1382-
data->fixed_divider);
1385+
divider_data->fixed_divider);
13831386
}
13841387

13851388
return &divider->div.hw;
13861389
}
13871390

13881391
static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
1389-
const struct bcm2835_clock_data *data)
1392+
const void *data)
13901393
{
1394+
const struct bcm2835_clock_data *clock_data = data;
13911395
struct bcm2835_clock *clock;
13921396
struct clk_init_data init;
13931397
const char *parents[1 << CM_SRC_BITS];
@@ -1398,8 +1402,8 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
13981402
* Replace our strings referencing parent clocks with the
13991403
* actual clock-output-name of the parent.
14001404
*/
1401-
for (i = 0; i < data->num_mux_parents; i++) {
1402-
parents[i] = data->parents[i];
1405+
for (i = 0; i < clock_data->num_mux_parents; i++) {
1406+
parents[i] = clock_data->parents[i];
14031407

14041408
ret = match_string(cprman_parent_names,
14051409
ARRAY_SIZE(cprman_parent_names),
@@ -1410,18 +1414,18 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
14101414

14111415
memset(&init, 0, sizeof(init));
14121416
init.parent_names = parents;
1413-
init.num_parents = data->num_mux_parents;
1414-
init.name = data->name;
1415-
init.flags = data->flags | CLK_IGNORE_UNUSED;
1417+
init.num_parents = clock_data->num_mux_parents;
1418+
init.name = clock_data->name;
1419+
init.flags = clock_data->flags | CLK_IGNORE_UNUSED;
14161420

14171421
/*
14181422
* Pass the CLK_SET_RATE_PARENT flag if we are allowed to propagate
14191423
* rate changes on at least of the parents.
14201424
*/
1421-
if (data->set_rate_parent)
1425+
if (clock_data->set_rate_parent)
14221426
init.flags |= CLK_SET_RATE_PARENT;
14231427

1424-
if (data->is_vpu_clock) {
1428+
if (clock_data->is_vpu_clock) {
14251429
init.ops = &bcm2835_vpu_clock_clk_ops;
14261430
} else {
14271431
init.ops = &bcm2835_clock_clk_ops;
@@ -1430,7 +1434,7 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
14301434
/* If the clock wasn't actually enabled at boot, it's not
14311435
* critical.
14321436
*/
1433-
if (!(cprman_read(cprman, data->ctl_reg) & CM_ENABLE))
1437+
if (!(cprman_read(cprman, clock_data->ctl_reg) & CM_ENABLE))
14341438
init.flags &= ~CLK_IS_CRITICAL;
14351439
}
14361440

@@ -1439,7 +1443,7 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
14391443
return NULL;
14401444

14411445
clock->cprman = cprman;
1442-
clock->data = data;
1446+
clock->data = clock_data;
14431447
clock->hw.init = &init;
14441448

14451449
ret = devm_clk_hw_register(cprman->dev, &clock->hw);
@@ -1448,25 +1452,27 @@ static struct clk_hw *bcm2835_register_clock(struct bcm2835_cprman *cprman,
14481452
return &clock->hw;
14491453
}
14501454

1451-
static struct clk *bcm2835_register_gate(struct bcm2835_cprman *cprman,
1452-
const struct bcm2835_gate_data *data)
1455+
static struct clk_hw *bcm2835_register_gate(struct bcm2835_cprman *cprman,
1456+
const void *data)
14531457
{
1454-
return clk_register_gate(cprman->dev, data->name, data->parent,
1455-
CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
1456-
cprman->regs + data->ctl_reg,
1457-
CM_GATE_BIT, 0, &cprman->regs_lock);
1458+
const struct bcm2835_gate_data *gate_data = data;
1459+
1460+
return clk_hw_register_gate(cprman->dev, gate_data->name,
1461+
gate_data->parent,
1462+
CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
1463+
cprman->regs + gate_data->ctl_reg,
1464+
CM_GATE_BIT, 0, &cprman->regs_lock);
14581465
}
14591466

1460-
typedef struct clk_hw *(*bcm2835_clk_register)(struct bcm2835_cprman *cprman,
1461-
const void *data);
14621467
struct bcm2835_clk_desc {
1463-
bcm2835_clk_register clk_register;
1468+
struct clk_hw *(*clk_register)(struct bcm2835_cprman *cprman,
1469+
const void *data);
14641470
unsigned int supported;
14651471
const void *data;
14661472
};
14671473

14681474
/* assignment helper macros for different clock types */
1469-
#define _REGISTER(f, s, ...) { .clk_register = (bcm2835_clk_register)f, \
1475+
#define _REGISTER(f, s, ...) { .clk_register = f, \
14701476
.supported = s, \
14711477
.data = __VA_ARGS__ }
14721478
#define REGISTER_PLL(s, ...) _REGISTER(&bcm2835_register_pll, \

drivers/clk/clk-ast2600.c

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,14 +642,22 @@ static const u32 ast2600_a0_axi_ahb_div_table[] = {
642642
2, 2, 3, 5,
643643
};
644644

645-
static const u32 ast2600_a1_axi_ahb_div_table[] = {
646-
4, 6, 2, 4,
645+
static const u32 ast2600_a1_axi_ahb_div0_tbl[] = {
646+
3, 2, 3, 4,
647+
};
648+
649+
static const u32 ast2600_a1_axi_ahb_div1_tbl[] = {
650+
3, 4, 6, 8,
651+
};
652+
653+
static const u32 ast2600_a1_axi_ahb200_tbl[] = {
654+
3, 4, 3, 4, 2, 2, 2, 2,
647655
};
648656

649657
static void __init aspeed_g6_cc(struct regmap *map)
650658
{
651659
struct clk_hw *hw;
652-
u32 val, div, chip_id, axi_div, ahb_div;
660+
u32 val, div, divbits, chip_id, axi_div, ahb_div;
653661

654662
clk_hw_register_fixed_rate(NULL, "clkin", NULL, 0, 25000000);
655663

@@ -679,11 +687,22 @@ static void __init aspeed_g6_cc(struct regmap *map)
679687
else
680688
axi_div = 2;
681689

690+
divbits = (val >> 11) & 0x3;
682691
regmap_read(map, ASPEED_G6_SILICON_REV, &chip_id);
683-
if (chip_id & BIT(16))
684-
ahb_div = ast2600_a1_axi_ahb_div_table[(val >> 11) & 0x3];
685-
else
692+
if (chip_id & BIT(16)) {
693+
if (!divbits) {
694+
ahb_div = ast2600_a1_axi_ahb200_tbl[(val >> 8) & 0x3];
695+
if (val & BIT(16))
696+
ahb_div *= 2;
697+
} else {
698+
if (val & BIT(16))
699+
ahb_div = ast2600_a1_axi_ahb_div1_tbl[divbits];
700+
else
701+
ahb_div = ast2600_a1_axi_ahb_div0_tbl[divbits];
702+
}
703+
} else {
686704
ahb_div = ast2600_a0_axi_ahb_div_table[(val >> 11) & 0x3];
705+
}
687706

688707
hw = clk_hw_register_fixed_factor(NULL, "ahb", "hpll", 0, 1, axi_div * ahb_div);
689708
aspeed_g6_clk_data->hws[ASPEED_CLK_AHB] = hw;

drivers/clk/clk.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,10 +3295,6 @@ static int __init clk_debug_init(void)
32953295
late_initcall(clk_debug_init);
32963296
#else
32973297
static inline void clk_debug_register(struct clk_core *core) { }
3298-
static inline void clk_debug_reparent(struct clk_core *core,
3299-
struct clk_core *new_parent)
3300-
{
3301-
}
33023298
static inline void clk_debug_unregister(struct clk_core *core)
33033299
{
33043300
}

drivers/clk/sprd/gate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,15 @@ static int sprd_gate_is_enabled(struct clk_hw *hw)
9494
{
9595
struct sprd_gate *sg = hw_to_sprd_gate(hw);
9696
struct sprd_clk_common *common = &sg->common;
97+
struct clk_hw *parent;
9798
unsigned int reg;
9899

100+
if (sg->flags & SPRD_GATE_NON_AON) {
101+
parent = clk_hw_get_parent(hw);
102+
if (!parent || !clk_hw_is_enabled(parent))
103+
return 0;
104+
}
105+
99106
regmap_read(common->regmap, common->reg, &reg);
100107

101108
if (sg->flags & CLK_GATE_SET_TO_DISABLE)

drivers/clk/sprd/gate.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ struct sprd_gate {
1919
struct sprd_clk_common common;
2020
};
2121

22+
/*
23+
* sprd_gate->flags is used for:
24+
* CLK_GATE_SET_TO_DISABLE BIT(0)
25+
* CLK_GATE_HIWORD_MASK BIT(1)
26+
* CLK_GATE_BIG_ENDIAN BIT(2)
27+
* so we define new flags from BIT(3)
28+
*/
29+
#define SPRD_GATE_NON_AON BIT(3) /* not alway powered on, check before read */
30+
2231
#define SPRD_SC_GATE_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, \
2332
_sc_offset, _enable_mask, _flags, \
2433
_gate_flags, _udelay, _ops, _fn) \

drivers/clk/sprd/pll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static unsigned long _sprd_pll_recalc_rate(const struct sprd_pll *pll,
106106

107107
cfg = kcalloc(regs_num, sizeof(*cfg), GFP_KERNEL);
108108
if (!cfg)
109-
return -ENOMEM;
109+
return parent_rate;
110110

111111
for (i = 0; i < regs_num; i++)
112112
cfg[i] = sprd_pll_read(pll, i);

0 commit comments

Comments
 (0)