[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1449248628-3486-2-git-send-email-alexandre.belloni@free-electrons.com>
Date: Fri, 4 Dec 2015 18:03:36 +0100
From: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
To: Nicolas Ferre <nicolas.ferre@...el.com>,
Boris Brezillon <boris.brezillon@...e-electrons.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@...osoft.com>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...eaurora.org>,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-clk@...r.kernel.org,
Alexandre Belloni <alexandre.belloni@...e-electrons.com>
Subject: [PATCH v3 01/13] clk: at91: make use of syscon to share PMC registers in several drivers
From: Boris Brezillon <boris.brezillon@...e-electrons.com>
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 <boris.brezillon@...e-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
Acked-by: Stephen Boyd <sboyd@...eaurora.org>
---
arch/arm/mach-at91/Kconfig | 1 +
drivers/clk/at91/pmc.c | 12 ++++++++----
drivers/clk/at91/pmc.h | 11 ++++++++---
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 92673006e55c..dd1571251ea6 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -95,6 +95,7 @@ config HAVE_AT91_USB_CLK
config COMMON_CLK_AT91
bool
select COMMON_CLK
+ select MFD_SYSCON
config HAVE_AT91_SMD
bool
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 8476b570779b..481146029b2e 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -19,6 +19,7 @@
#include <linux/irqchip/chained_irq.h>
#include <linux/irqdomain.h>
#include <linux/of_irq.h>
+#include <linux/mfd/syscon.h>
#include <asm/proc-fns.h>
@@ -223,6 +224,7 @@ static const struct at91_pmc_caps sama5d3_caps = {
};
static struct at91_pmc *__init at91_pmc_init(struct device_node *np,
+ struct regmap *regmap,
void __iomem *regbase, int virq,
const struct at91_pmc_caps *caps)
{
@@ -238,7 +240,7 @@ static struct at91_pmc *__init at91_pmc_init(struct device_node *np,
return NULL;
spin_lock_init(&pmc->lock);
- pmc->regbase = regbase;
+ pmc->regmap = regmap;
pmc->virq = virq;
pmc->caps = caps;
@@ -394,16 +396,18 @@ static void __init of_at91_pmc_setup(struct device_node *np,
void (*clk_setup)(struct device_node *, struct at91_pmc *);
const struct of_device_id *clk_id;
void __iomem *regbase = of_iomap(np, 0);
+ struct regmap *regmap;
int virq;
- if (!regbase)
- return;
+ regmap = syscon_node_to_regmap(np);
+ if (IS_ERR(regmap))
+ panic("Could not retrieve syscon regmap");
virq = irq_of_parse_and_map(np, 0);
if (!virq)
return;
- pmc = at91_pmc_init(np, regbase, virq, caps);
+ pmc = at91_pmc_init(np, regmap, regbase, virq, caps);
if (!pmc)
return;
for_each_child_of_node(np, childnp) {
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
index f65739272779..e1fc0b0e1d8c 100644
--- a/drivers/clk/at91/pmc.h
+++ b/drivers/clk/at91/pmc.h
@@ -14,6 +14,7 @@
#include <linux/io.h>
#include <linux/irqdomain.h>
+#include <linux/regmap.h>
#include <linux/spinlock.h>
struct clk_range {
@@ -28,7 +29,7 @@ struct at91_pmc_caps {
};
struct at91_pmc {
- void __iomem *regbase;
+ struct regmap *regmap;
int virq;
spinlock_t lock;
const struct at91_pmc_caps *caps;
@@ -48,12 +49,16 @@ static inline void pmc_unlock(struct at91_pmc *pmc)
static inline u32 pmc_read(struct at91_pmc *pmc, int offset)
{
- return readl(pmc->regbase + offset);
+ unsigned int ret = 0;
+
+ regmap_read(pmc->regmap, offset, &ret);
+
+ return ret;
}
static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value)
{
- writel(value, pmc->regbase + offset);
+ regmap_write(pmc->regmap, offset, value);
}
int of_at91_get_clk_range(struct device_node *np, const char *propname,
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists