Skip to content

Commit 8e842f0

Browse files
claudiubezneanoglitch
authored andcommitted
clk: at91: clk-master: remove dead code
Commit facb87a ("clk: at91: sama7g5: remove prescaler part of master clock") removed the master clock's prescaler from clock tree of SAMA7G5 as it has been discovered that there is a hardware bug when trying to change it at run-time (bug is described in description of commit facb87a ("clk: at91: sama7g5: remove prescaler part of master clock")). This was previously changed at CPUFreq driver request. Thus, with commit facb87a ("clk: at91: sama7g5: remove prescaler part of master clock") there is no need of code that handles run-time changes of master clock's prescaler, thus remove this code. Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Nicolas Ferre <nicolas.ferre@microchip.com> Link: https://lore.kernel.org/r/20220203110202.18329-1-claudiu.beznea@microchip.com
1 parent 1a94472 commit 8e842f0

File tree

13 files changed

+18
-134
lines changed

13 files changed

+18
-134
lines changed

drivers/clk/at91/at91rm9200.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ static void __init at91rm9200_pmc_setup(struct device_node *np)
143143
parent_names,
144144
&at91rm9200_master_layout,
145145
&rm9200_mck_characteristics,
146-
&rm9200_mck_lock, CLK_SET_RATE_GATE,
147-
INT_MIN);
146+
&rm9200_mck_lock);
148147
if (IS_ERR(hw))
149148
goto err_free;
150149

drivers/clk/at91/at91sam9260.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
419419
parent_names,
420420
&at91rm9200_master_layout,
421421
data->mck_characteristics,
422-
&at91sam9260_mck_lock,
423-
CLK_SET_RATE_GATE, INT_MIN);
422+
&at91sam9260_mck_lock);
424423
if (IS_ERR(hw))
425424
goto err_free;
426425

drivers/clk/at91/at91sam9g45.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ static void __init at91sam9g45_pmc_setup(struct device_node *np)
154154
parent_names,
155155
&at91rm9200_master_layout,
156156
&mck_characteristics,
157-
&at91sam9g45_mck_lock,
158-
CLK_SET_RATE_GATE, INT_MIN);
157+
&at91sam9g45_mck_lock);
159158
if (IS_ERR(hw))
160159
goto err_free;
161160

drivers/clk/at91/at91sam9n12.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ static void __init at91sam9n12_pmc_setup(struct device_node *np)
181181
parent_names,
182182
&at91sam9x5_master_layout,
183183
&mck_characteristics,
184-
&at91sam9n12_mck_lock,
185-
CLK_SET_RATE_GATE, INT_MIN);
184+
&at91sam9n12_mck_lock);
186185
if (IS_ERR(hw))
187186
goto err_free;
188187

drivers/clk/at91/at91sam9rl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
123123
parent_names,
124124
&at91rm9200_master_layout,
125125
&sam9rl_mck_characteristics,
126-
&sam9rl_mck_lock, CLK_SET_RATE_GATE,
127-
INT_MIN);
126+
&sam9rl_mck_lock);
128127
if (IS_ERR(hw))
129128
goto err_free;
130129

drivers/clk/at91/at91sam9x5.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
201201
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 4,
202202
parent_names,
203203
&at91sam9x5_master_layout,
204-
&mck_characteristics, &mck_lock,
205-
CLK_SET_RATE_GATE, INT_MIN);
204+
&mck_characteristics, &mck_lock);
206205
if (IS_ERR(hw))
207206
goto err_free;
208207

drivers/clk/at91/clk-master.c

Lines changed: 6 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -374,85 +374,6 @@ static void clk_sama7g5_master_best_diff(struct clk_rate_request *req,
374374
}
375375
}
376376

377-
static int clk_master_pres_determine_rate(struct clk_hw *hw,
378-
struct clk_rate_request *req)
379-
{
380-
struct clk_master *master = to_clk_master(hw);
381-
struct clk_rate_request req_parent = *req;
382-
const struct clk_master_characteristics *characteristics =
383-
master->characteristics;
384-
struct clk_hw *parent;
385-
long best_rate = LONG_MIN, best_diff = LONG_MIN;
386-
u32 pres;
387-
int i;
388-
389-
if (master->chg_pid < 0)
390-
return -EOPNOTSUPP;
391-
392-
parent = clk_hw_get_parent_by_index(hw, master->chg_pid);
393-
if (!parent)
394-
return -EOPNOTSUPP;
395-
396-
for (i = 0; i <= MASTER_PRES_MAX; i++) {
397-
if (characteristics->have_div3_pres && i == MASTER_PRES_MAX)
398-
pres = 3;
399-
else
400-
pres = 1 << i;
401-
402-
req_parent.rate = req->rate * pres;
403-
if (__clk_determine_rate(parent, &req_parent))
404-
continue;
405-
406-
clk_sama7g5_master_best_diff(req, parent, req_parent.rate,
407-
&best_diff, &best_rate, pres);
408-
if (!best_diff)
409-
break;
410-
}
411-
412-
return 0;
413-
}
414-
415-
static int clk_master_pres_set_rate(struct clk_hw *hw, unsigned long rate,
416-
unsigned long parent_rate)
417-
{
418-
struct clk_master *master = to_clk_master(hw);
419-
unsigned long flags;
420-
unsigned int pres, mckr, tmp;
421-
int ret;
422-
423-
pres = DIV_ROUND_CLOSEST(parent_rate, rate);
424-
if (pres > MASTER_PRES_MAX)
425-
return -EINVAL;
426-
427-
else if (pres == 3)
428-
pres = MASTER_PRES_MAX;
429-
else if (pres)
430-
pres = ffs(pres) - 1;
431-
432-
spin_lock_irqsave(master->lock, flags);
433-
ret = regmap_read(master->regmap, master->layout->offset, &mckr);
434-
if (ret)
435-
goto unlock;
436-
437-
mckr &= master->layout->mask;
438-
tmp = (mckr >> master->layout->pres_shift) & MASTER_PRES_MASK;
439-
if (pres == tmp)
440-
goto unlock;
441-
442-
mckr &= ~(MASTER_PRES_MASK << master->layout->pres_shift);
443-
mckr |= (pres << master->layout->pres_shift);
444-
ret = regmap_write(master->regmap, master->layout->offset, mckr);
445-
if (ret)
446-
goto unlock;
447-
448-
while (!clk_master_ready(master))
449-
cpu_relax();
450-
unlock:
451-
spin_unlock_irqrestore(master->lock, flags);
452-
453-
return ret;
454-
}
455-
456377
static unsigned long clk_master_pres_recalc_rate(struct clk_hw *hw,
457378
unsigned long parent_rate)
458379
{
@@ -539,13 +460,6 @@ static void clk_master_pres_restore_context(struct clk_hw *hw)
539460
pr_warn("MCKR PRES was not configured properly by firmware!\n");
540461
}
541462

542-
static void clk_master_pres_restore_context_chg(struct clk_hw *hw)
543-
{
544-
struct clk_master *master = to_clk_master(hw);
545-
546-
clk_master_pres_set_rate(hw, master->pms.rate, master->pms.parent_rate);
547-
}
548-
549463
static const struct clk_ops master_pres_ops = {
550464
.prepare = clk_master_prepare,
551465
.is_prepared = clk_master_is_prepared,
@@ -555,25 +469,13 @@ static const struct clk_ops master_pres_ops = {
555469
.restore_context = clk_master_pres_restore_context,
556470
};
557471

558-
static const struct clk_ops master_pres_ops_chg = {
559-
.prepare = clk_master_prepare,
560-
.is_prepared = clk_master_is_prepared,
561-
.determine_rate = clk_master_pres_determine_rate,
562-
.recalc_rate = clk_master_pres_recalc_rate,
563-
.get_parent = clk_master_pres_get_parent,
564-
.set_rate = clk_master_pres_set_rate,
565-
.save_context = clk_master_pres_save_context,
566-
.restore_context = clk_master_pres_restore_context_chg,
567-
};
568-
569472
static struct clk_hw * __init
570473
at91_clk_register_master_internal(struct regmap *regmap,
571474
const char *name, int num_parents,
572475
const char **parent_names,
573476
const struct clk_master_layout *layout,
574477
const struct clk_master_characteristics *characteristics,
575-
const struct clk_ops *ops, spinlock_t *lock, u32 flags,
576-
int chg_pid)
478+
const struct clk_ops *ops, spinlock_t *lock, u32 flags)
577479
{
578480
struct clk_master *master;
579481
struct clk_init_data init;
@@ -599,7 +501,6 @@ at91_clk_register_master_internal(struct regmap *regmap,
599501
master->layout = layout;
600502
master->characteristics = characteristics;
601503
master->regmap = regmap;
602-
master->chg_pid = chg_pid;
603504
master->lock = lock;
604505

605506
if (ops == &master_div_ops_chg) {
@@ -628,19 +529,13 @@ at91_clk_register_master_pres(struct regmap *regmap,
628529
const char **parent_names,
629530
const struct clk_master_layout *layout,
630531
const struct clk_master_characteristics *characteristics,
631-
spinlock_t *lock, u32 flags, int chg_pid)
532+
spinlock_t *lock)
632533
{
633-
const struct clk_ops *ops;
634-
635-
if (flags & CLK_SET_RATE_GATE)
636-
ops = &master_pres_ops;
637-
else
638-
ops = &master_pres_ops_chg;
639-
640534
return at91_clk_register_master_internal(regmap, name, num_parents,
641535
parent_names, layout,
642-
characteristics, ops,
643-
lock, flags, chg_pid);
536+
characteristics,
537+
&master_pres_ops,
538+
lock, CLK_SET_RATE_GATE);
644539
}
645540

646541
struct clk_hw * __init
@@ -661,7 +556,7 @@ at91_clk_register_master_div(struct regmap *regmap,
661556
hw = at91_clk_register_master_internal(regmap, name, 1,
662557
&parent_name, layout,
663558
characteristics, ops,
664-
lock, flags, -EINVAL);
559+
lock, flags);
665560

666561
if (!IS_ERR(hw) && safe_div) {
667562
master_div = to_clk_master(hw);

drivers/clk/at91/dt-compat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,7 @@ of_at91_clk_master_setup(struct device_node *np,
392392

393393
hw = at91_clk_register_master_pres(regmap, "masterck_pres", num_parents,
394394
parent_names, layout,
395-
characteristics, &mck_lock,
396-
CLK_SET_RATE_GATE, INT_MIN);
395+
characteristics, &mck_lock);
397396
if (IS_ERR(hw))
398397
goto out_free_characteristics;
399398

drivers/clk/at91/pmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ at91_clk_register_master_pres(struct regmap *regmap, const char *name,
175175
int num_parents, const char **parent_names,
176176
const struct clk_master_layout *layout,
177177
const struct clk_master_characteristics *characteristics,
178-
spinlock_t *lock, u32 flags, int chg_pid);
178+
spinlock_t *lock);
179179

180180
struct clk_hw * __init
181181
at91_clk_register_master_div(struct regmap *regmap, const char *name,

drivers/clk/at91/sam9x60.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ static void __init sam9x60_pmc_setup(struct device_node *np)
271271
parent_names[2] = "pllack_divck";
272272
hw = at91_clk_register_master_pres(regmap, "masterck_pres", 3,
273273
parent_names, &sam9x60_master_layout,
274-
&mck_characteristics, &mck_lock,
275-
CLK_SET_RATE_GATE, INT_MIN);
274+
&mck_characteristics, &mck_lock);
276275
if (IS_ERR(hw))
277276
goto err_free;
278277

0 commit comments

Comments
 (0)