Skip to content

Commit 68b3b6f

Browse files
committed
clk: at91: mark ddr clocks as critical
Mark DDR clocks as critical for AT91 devices. These clocks are enabled by bootloader when initializing DDR and needs to stay enabled. Up to this patch the DDR clocks were requested from drivers/memory/atmel-sdramc.c which does only clock request and enable. There is no need to have a separate driver just for this, thus the atmel-sdramc.c will be deleted in a subsequent patch. Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1b929c0 commit 68b3b6f

15 files changed

+131
-43
lines changed

drivers/clk/at91/at91rm9200.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
183183
for (i = 0; i < ARRAY_SIZE(at91rm9200_systemck); i++) {
184184
hw = at91_clk_register_system(regmap, at91rm9200_systemck[i].n,
185185
at91rm9200_systemck[i].p,
186-
at91rm9200_systemck[i].id);
186+
at91rm9200_systemck[i].id, 0);
187187
if (IS_ERR(hw))
188188
goto err_free;
189189

drivers/clk/at91/at91sam9260.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
460460
for (i = 0; i < data->num_sck; i++) {
461461
hw = at91_clk_register_system(regmap, data->sck[i].n,
462462
data->sck[i].p,
463-
data->sck[i].id);
463+
data->sck[i].id, 0);
464464
if (IS_ERR(hw))
465465
goto err_free;
466466

drivers/clk/at91/at91sam9g45.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ static const struct clk_pll_characteristics plla_characteristics = {
4040
static const struct {
4141
char *n;
4242
char *p;
43+
unsigned long flags;
4344
u8 id;
4445
} at91sam9g45_systemck[] = {
45-
{ .n = "ddrck", .p = "masterck_div", .id = 2 },
46+
/*
47+
* ddrck feeds DDR controller and is enabled by bootloader thus we need
48+
* to keep it enabled in case there is no Linux consumer for it.
49+
*/
50+
{ .n = "ddrck", .p = "masterck_div", .id = 2, .flags = CLK_IS_CRITICAL },
4651
{ .n = "uhpck", .p = "usbck", .id = 6 },
4752
{ .n = "pck0", .p = "prog0", .id = 8 },
4853
{ .n = "pck1", .p = "prog1", .id = 9 },
@@ -198,7 +203,8 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
198203
for (i = 0; i < ARRAY_SIZE(at91sam9g45_systemck); i++) {
199204
hw = at91_clk_register_system(regmap, at91sam9g45_systemck[i].n,
200205
at91sam9g45_systemck[i].p,
201-
at91sam9g45_systemck[i].id);
206+
at91sam9g45_systemck[i].id,
207+
at91sam9g45_systemck[i].flags);
202208
if (IS_ERR(hw))
203209
goto err_free;
204210

drivers/clk/at91/at91sam9n12.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,14 @@ static const struct clk_pll_characteristics pllb_characteristics = {
5454
static const struct {
5555
char *n;
5656
char *p;
57+
unsigned long flags;
5758
u8 id;
5859
} at91sam9n12_systemck[] = {
59-
{ .n = "ddrck", .p = "masterck_div", .id = 2 },
60+
/*
61+
* ddrck feeds DDR controller and is enabled by bootloader thus we need
62+
* to keep it enabled in case there is no Linux consumer for it.
63+
*/
64+
{ .n = "ddrck", .p = "masterck_div", .id = 2, .flags = CLK_IS_CRITICAL },
6065
{ .n = "lcdck", .p = "masterck_div", .id = 3 },
6166
{ .n = "uhpck", .p = "usbck", .id = 6 },
6267
{ .n = "udpck", .p = "usbck", .id = 7 },
@@ -223,7 +228,8 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
223228
for (i = 0; i < ARRAY_SIZE(at91sam9n12_systemck); i++) {
224229
hw = at91_clk_register_system(regmap, at91sam9n12_systemck[i].n,
225230
at91sam9n12_systemck[i].p,
226-
at91sam9n12_systemck[i].id);
231+
at91sam9n12_systemck[i].id,
232+
at91sam9n12_systemck[i].flags);
227233
if (IS_ERR(hw))
228234
goto err_free;
229235

@@ -236,7 +242,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
236242
at91sam9n12_periphck[i].n,
237243
"masterck_div",
238244
at91sam9n12_periphck[i].id,
239-
&range, INT_MIN);
245+
&range, INT_MIN, 0);
240246
if (IS_ERR(hw))
241247
goto err_free;
242248

drivers/clk/at91/at91sam9rl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
160160
for (i = 0; i < ARRAY_SIZE(at91sam9rl_systemck); i++) {
161161
hw = at91_clk_register_system(regmap, at91sam9rl_systemck[i].n,
162162
at91sam9rl_systemck[i].p,
163-
at91sam9rl_systemck[i].id);
163+
at91sam9rl_systemck[i].id, 0);
164164
if (IS_ERR(hw))
165165
goto err_free;
166166

drivers/clk/at91/at91sam9x5.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ static const struct clk_pll_characteristics plla_characteristics = {
4141
static const struct {
4242
char *n;
4343
char *p;
44+
unsigned long flags;
4445
u8 id;
4546
} at91sam9x5_systemck[] = {
46-
{ .n = "ddrck", .p = "masterck_div", .id = 2 },
47+
/*
48+
* ddrck feeds DDR controller and is enabled by bootloader thus we need
49+
* to keep it enabled in case there is no Linux consumer for it.
50+
*/
51+
{ .n = "ddrck", .p = "masterck_div", .id = 2, .flags = CLK_IS_CRITICAL },
4752
{ .n = "smdck", .p = "smdclk", .id = 4 },
4853
{ .n = "uhpck", .p = "usbck", .id = 6 },
4954
{ .n = "udpck", .p = "usbck", .id = 7 },
@@ -248,15 +253,17 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
248253
for (i = 0; i < ARRAY_SIZE(at91sam9x5_systemck); i++) {
249254
hw = at91_clk_register_system(regmap, at91sam9x5_systemck[i].n,
250255
at91sam9x5_systemck[i].p,
251-
at91sam9x5_systemck[i].id);
256+
at91sam9x5_systemck[i].id,
257+
at91sam9x5_systemck[i].flags);
252258
if (IS_ERR(hw))
253259
goto err_free;
254260

255261
at91sam9x5_pmc->shws[at91sam9x5_systemck[i].id] = hw;
256262
}
257263

258264
if (has_lcdck) {
259-
hw = at91_clk_register_system(regmap, "lcdck", "masterck_div", 3);
265+
hw = at91_clk_register_system(regmap, "lcdck", "masterck_div",
266+
3, 0);
260267
if (IS_ERR(hw))
261268
goto err_free;
262269

@@ -269,7 +276,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
269276
at91sam9x5_periphck[i].n,
270277
"masterck_div",
271278
at91sam9x5_periphck[i].id,
272-
&range, INT_MIN);
279+
&range, INT_MIN, 0);
273280
if (IS_ERR(hw))
274281
goto err_free;
275282

@@ -282,7 +289,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
282289
extra_pcks[i].n,
283290
"masterck_div",
284291
extra_pcks[i].id,
285-
&range, INT_MIN);
292+
&range, INT_MIN, 0);
286293
if (IS_ERR(hw))
287294
goto err_free;
288295

drivers/clk/at91/clk-peripheral.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
445445
const struct clk_pcr_layout *layout,
446446
const char *name, const char *parent_name,
447447
u32 id, const struct clk_range *range,
448-
int chg_pid)
448+
int chg_pid, unsigned long flags)
449449
{
450450
struct clk_sam9x5_peripheral *periph;
451451
struct clk_init_data init;
@@ -462,12 +462,12 @@ at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
462462
init.name = name;
463463
init.parent_names = &parent_name;
464464
init.num_parents = 1;
465+
init.flags = flags;
465466
if (chg_pid < 0) {
466-
init.flags = 0;
467467
init.ops = &sam9x5_peripheral_ops;
468468
} else {
469-
init.flags = CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE |
470-
CLK_SET_RATE_PARENT;
469+
init.flags |= CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE |
470+
CLK_SET_RATE_PARENT;
471471
init.ops = &sam9x5_peripheral_chg_ops;
472472
}
473473

drivers/clk/at91/clk-system.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static const struct clk_ops system_ops = {
105105

106106
struct clk_hw * __init
107107
at91_clk_register_system(struct regmap *regmap, const char *name,
108-
const char *parent_name, u8 id)
108+
const char *parent_name, u8 id, unsigned long flags)
109109
{
110110
struct clk_system *sys;
111111
struct clk_hw *hw;
@@ -123,7 +123,7 @@ at91_clk_register_system(struct regmap *regmap, const char *name,
123123
init.ops = &system_ops;
124124
init.parent_names = &parent_name;
125125
init.num_parents = 1;
126-
init.flags = CLK_SET_RATE_PARENT;
126+
init.flags = CLK_SET_RATE_PARENT | flags;
127127

128128
sys->id = id;
129129
sys->hw.init = &init;

drivers/clk/at91/dt-compat.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,18 +493,28 @@ of_at91_clk_periph_setup(struct device_node *np, u8 type)
493493
parent_name, id);
494494
} else {
495495
struct clk_range range = CLK_RANGE(0, 0);
496+
unsigned long flags = 0;
496497

497498
of_at91_get_clk_range(periphclknp,
498499
"atmel,clk-output-range",
499500
&range);
500501

502+
/*
503+
* mpddr_clk feed DDR controller and is enabled by
504+
* bootloader thus we need to keep it enabled in case
505+
* there is no Linux consumer for it.
506+
*/
507+
if (!strcmp(periphclknp->name, "mpddr_clk"))
508+
flags = CLK_IS_CRITICAL;
509+
501510
hw = at91_clk_register_sam9x5_peripheral(regmap,
502511
&pmc_pcr_lock,
503512
&dt_pcr_layout,
504513
name,
505514
parent_name,
506515
id, &range,
507-
INT_MIN);
516+
INT_MIN,
517+
flags);
508518
}
509519

510520
if (IS_ERR(hw))
@@ -879,6 +889,8 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
879889
return;
880890

881891
for_each_child_of_node(np, sysclknp) {
892+
unsigned long flags = 0;
893+
882894
if (of_property_read_u32(sysclknp, "reg", &id))
883895
continue;
884896

@@ -887,7 +899,16 @@ static void __init of_at91rm9200_clk_sys_setup(struct device_node *np)
887899

888900
parent_name = of_clk_get_parent_name(sysclknp, 0);
889901

890-
hw = at91_clk_register_system(regmap, name, parent_name, id);
902+
/*
903+
* ddrck feeds DDR controller and is enabled by bootloader thus
904+
* we need to keep it enabled in case there is no Linux consumer
905+
* for it.
906+
*/
907+
if (!strcmp(sysclknp->name, "ddrck"))
908+
flags = CLK_IS_CRITICAL;
909+
910+
hw = at91_clk_register_system(regmap, name, parent_name, id,
911+
flags);
891912
if (IS_ERR(hw))
892913
continue;
893914

drivers/clk/at91/pmc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ at91_clk_register_sam9x5_peripheral(struct regmap *regmap, spinlock_t *lock,
199199
const struct clk_pcr_layout *layout,
200200
const char *name, const char *parent_name,
201201
u32 id, const struct clk_range *range,
202-
int chg_pid);
202+
int chg_pid, unsigned long flags);
203203

204204
struct clk_hw * __init
205205
at91_clk_register_pll(struct regmap *regmap, const char *name,
@@ -242,7 +242,7 @@ at91sam9x5_clk_register_smd(struct regmap *regmap, const char *name,
242242

243243
struct clk_hw * __init
244244
at91_clk_register_system(struct regmap *regmap, const char *name,
245-
const char *parent_name, u8 id);
245+
const char *parent_name, u8 id, unsigned long flags);
246246

247247
struct clk_hw * __init
248248
at91sam9x5_clk_register_usb(struct regmap *regmap, const char *name,

0 commit comments

Comments
 (0)