Skip to content

Commit 863a81c

Browse files
Boris Brezillonalexandrebelloni
Boris Brezillon
authored andcommitted
clk: at91: make use of syscon to share PMC registers in several drivers
The PMC block is providing several functionnalities: - system clk management - cpuidle - platform suspend Replace the void __iomem *regs field by a regmap (retrieved using syscon) so that we can later share the regmap across several drivers without exporting a new specific API or a global void __iomem * variable. Signed-off-by: Boris Brezillon <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Acked-by: Stephen Boyd <[email protected]>
1 parent 92e963f commit 863a81c

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

arch/arm/mach-at91/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ config HAVE_AT91_USB_CLK
104104
config COMMON_CLK_AT91
105105
bool
106106
select COMMON_CLK
107+
select MFD_SYSCON
107108

108109
config HAVE_AT91_SMD
109110
bool

drivers/clk/at91/pmc.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/irqchip/chained_irq.h>
2020
#include <linux/irqdomain.h>
2121
#include <linux/of_irq.h>
22+
#include <linux/mfd/syscon.h>
2223

2324
#include <asm/proc-fns.h>
2425

@@ -223,6 +224,7 @@ static const struct at91_pmc_caps sama5d3_caps = {
223224
};
224225

225226
static struct at91_pmc *__init at91_pmc_init(struct device_node *np,
227+
struct regmap *regmap,
226228
void __iomem *regbase, int virq,
227229
const struct at91_pmc_caps *caps)
228230
{
@@ -238,7 +240,7 @@ static struct at91_pmc *__init at91_pmc_init(struct device_node *np,
238240
return NULL;
239241

240242
spin_lock_init(&pmc->lock);
241-
pmc->regbase = regbase;
243+
pmc->regmap = regmap;
242244
pmc->virq = virq;
243245
pmc->caps = caps;
244246

@@ -394,16 +396,18 @@ static void __init of_at91_pmc_setup(struct device_node *np,
394396
void (*clk_setup)(struct device_node *, struct at91_pmc *);
395397
const struct of_device_id *clk_id;
396398
void __iomem *regbase = of_iomap(np, 0);
399+
struct regmap *regmap;
397400
int virq;
398401

399-
if (!regbase)
400-
return;
402+
regmap = syscon_node_to_regmap(np);
403+
if (IS_ERR(regmap))
404+
panic("Could not retrieve syscon regmap");
401405

402406
virq = irq_of_parse_and_map(np, 0);
403407
if (!virq)
404408
return;
405409

406-
pmc = at91_pmc_init(np, regbase, virq, caps);
410+
pmc = at91_pmc_init(np, regmap, regbase, virq, caps);
407411
if (!pmc)
408412
return;
409413
for_each_child_of_node(np, childnp) {

drivers/clk/at91/pmc.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <linux/io.h>
1616
#include <linux/irqdomain.h>
17+
#include <linux/regmap.h>
1718
#include <linux/spinlock.h>
1819

1920
struct clk_range {
@@ -28,7 +29,7 @@ struct at91_pmc_caps {
2829
};
2930

3031
struct at91_pmc {
31-
void __iomem *regbase;
32+
struct regmap *regmap;
3233
int virq;
3334
spinlock_t lock;
3435
const struct at91_pmc_caps *caps;
@@ -48,12 +49,16 @@ static inline void pmc_unlock(struct at91_pmc *pmc)
4849

4950
static inline u32 pmc_read(struct at91_pmc *pmc, int offset)
5051
{
51-
return readl(pmc->regbase + offset);
52+
unsigned int ret = 0;
53+
54+
regmap_read(pmc->regmap, offset, &ret);
55+
56+
return ret;
5257
}
5358

5459
static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value)
5560
{
56-
writel(value, pmc->regbase + offset);
61+
regmap_write(pmc->regmap, offset, value);
5762
}
5863

5964
int of_at91_get_clk_range(struct device_node *np, const char *propname,

0 commit comments

Comments
 (0)