Skip to content

Commit 52fe6b5

Browse files
ConchuODclaudiubeznea
authored andcommitted
clk: microchip: mpfs: move id & offset out of clock structs
The id and offset are the only thing differentiating the clock structs from "regular" clock structures. On the pretext of converting to more normal structures, move the id and offset out of the clock structs and into the hw structs instead. Reviewed-by: Daire McNamara <[email protected]> Signed-off-by: Conor Dooley <[email protected]> Reviewed-by: Claudiu Beznea <[email protected]> Signed-off-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 14016e4 commit 52fe6b5

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

drivers/clk/microchip/clk-mpfs.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ struct mpfs_msspll_hw_clock {
5151

5252
struct mpfs_cfg_clock {
5353
const struct clk_div_table *table;
54-
unsigned int id;
55-
u32 reg_offset;
5654
u8 shift;
5755
u8 width;
5856
u8 flags;
@@ -63,19 +61,21 @@ struct mpfs_cfg_hw_clock {
6361
void __iomem *sys_base;
6462
struct clk_hw hw;
6563
struct clk_init_data init;
64+
unsigned int id;
65+
u32 reg_offset;
6666
};
6767

6868
#define to_mpfs_cfg_clk(_hw) container_of(_hw, struct mpfs_cfg_hw_clock, hw)
6969

7070
struct mpfs_periph_clock {
71-
unsigned int id;
7271
u8 shift;
7372
};
7473

7574
struct mpfs_periph_hw_clock {
7675
struct mpfs_periph_clock periph;
7776
void __iomem *sys_base;
7877
struct clk_hw hw;
78+
unsigned int id;
7979
};
8080

8181
#define to_mpfs_periph_clk(_hw) container_of(_hw, struct mpfs_periph_hw_clock, hw)
@@ -241,7 +241,7 @@ static unsigned long mpfs_cfg_clk_recalc_rate(struct clk_hw *hw, unsigned long p
241241
void __iomem *base_addr = cfg_hw->sys_base;
242242
u32 val;
243243

244-
val = readl_relaxed(base_addr + cfg->reg_offset) >> cfg->shift;
244+
val = readl_relaxed(base_addr + cfg_hw->reg_offset) >> cfg->shift;
245245
val &= clk_div_mask(cfg->width);
246246

247247
return divider_recalc_rate(hw, prate, val, cfg->table, cfg->flags, cfg->width);
@@ -270,10 +270,10 @@ static int mpfs_cfg_clk_set_rate(struct clk_hw *hw, unsigned long rate, unsigned
270270
return divider_setting;
271271

272272
spin_lock_irqsave(&mpfs_clk_lock, flags);
273-
val = readl_relaxed(base_addr + cfg->reg_offset);
273+
val = readl_relaxed(base_addr + cfg_hw->reg_offset);
274274
val &= ~(clk_div_mask(cfg->width) << cfg_hw->cfg.shift);
275275
val |= divider_setting << cfg->shift;
276-
writel_relaxed(val, base_addr + cfg->reg_offset);
276+
writel_relaxed(val, base_addr + cfg_hw->reg_offset);
277277

278278
spin_unlock_irqrestore(&mpfs_clk_lock, flags);
279279

@@ -287,11 +287,11 @@ static const struct clk_ops mpfs_clk_cfg_ops = {
287287
};
288288

289289
#define CLK_CFG(_id, _name, _parent, _shift, _width, _table, _flags, _offset) { \
290-
.cfg.id = _id, \
290+
.id = _id, \
291291
.cfg.shift = _shift, \
292292
.cfg.width = _width, \
293293
.cfg.table = _table, \
294-
.cfg.reg_offset = _offset, \
294+
.reg_offset = _offset, \
295295
.cfg.flags = _flags, \
296296
.hw.init = CLK_HW_INIT(_name, _parent, &mpfs_clk_cfg_ops, 0), \
297297
}
@@ -309,11 +309,11 @@ static struct mpfs_cfg_hw_clock mpfs_cfg_clks[] = {
309309
CLK_CFG(CLK_AHB, "clk_ahb", "clk_msspll", 4, 2, mpfs_div_ahb_table, 0,
310310
REG_CLOCK_CONFIG_CR),
311311
{
312-
.cfg.id = CLK_RTCREF,
312+
.id = CLK_RTCREF,
313313
.cfg.shift = 0,
314314
.cfg.width = 12,
315315
.cfg.table = mpfs_div_rtcref_table,
316-
.cfg.reg_offset = REG_RTC_CLOCK_CR,
316+
.reg_offset = REG_RTC_CLOCK_CR,
317317
.cfg.flags = CLK_DIVIDER_ONE_BASED,
318318
.hw.init =
319319
CLK_HW_INIT_PARENTS_DATA("clk_rtcref", mpfs_ext_ref, &mpfs_clk_cfg_ops, 0),
@@ -341,9 +341,9 @@ static int mpfs_clk_register_cfgs(struct device *dev, struct mpfs_cfg_hw_clock *
341341
ret = mpfs_clk_register_cfg(dev, cfg_hw, sys_base);
342342
if (ret)
343343
return dev_err_probe(dev, ret, "failed to register clock id: %d\n",
344-
cfg_hw->cfg.id);
344+
cfg_hw->id);
345345

346-
id = cfg_hw->cfg.id;
346+
id = cfg_hw->id;
347347
data->hw_data.hws[id] = &cfg_hw->hw;
348348
}
349349

@@ -411,7 +411,7 @@ static const struct clk_ops mpfs_periph_clk_ops = {
411411
};
412412

413413
#define CLK_PERIPH(_id, _name, _parent, _shift, _flags) { \
414-
.periph.id = _id, \
414+
.id = _id, \
415415
.periph.shift = _shift, \
416416
.hw.init = CLK_HW_INIT_HW(_name, _parent, &mpfs_periph_clk_ops, \
417417
_flags), \
@@ -486,9 +486,9 @@ static int mpfs_clk_register_periphs(struct device *dev, struct mpfs_periph_hw_c
486486
ret = mpfs_clk_register_periph(dev, periph_hw, sys_base);
487487
if (ret)
488488
return dev_err_probe(dev, ret, "failed to register clock id: %d\n",
489-
periph_hw->periph.id);
489+
periph_hw->id);
490490

491-
id = periph_hws[i].periph.id;
491+
id = periph_hws[i].id;
492492
data->hw_data.hws[id] = &periph_hw->hw;
493493
}
494494

0 commit comments

Comments
 (0)