summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-prima2/Kconfig1
-rw-r--r--arch/arm/mach-prima2/rtciobrg.c48
-rw-r--r--include/linux/rtc/sirfsoc_rtciobrg.h4
3 files changed, 50 insertions, 3 deletions
diff --git a/arch/arm/mach-prima2/Kconfig b/arch/arm/mach-prima2/Kconfig
index e03d8b5c9ad0..9ab8932403e5 100644
--- a/arch/arm/mach-prima2/Kconfig
+++ b/arch/arm/mach-prima2/Kconfig
@@ -4,6 +4,7 @@ menuconfig ARCH_SIRF
4 select ARCH_REQUIRE_GPIOLIB 4 select ARCH_REQUIRE_GPIOLIB
5 select GENERIC_IRQ_CHIP 5 select GENERIC_IRQ_CHIP
6 select NO_IOPORT_MAP 6 select NO_IOPORT_MAP
7 select REGMAP
7 select PINCTRL 8 select PINCTRL
8 select PINCTRL_SIRF 9 select PINCTRL_SIRF
9 help 10 help
diff --git a/arch/arm/mach-prima2/rtciobrg.c b/arch/arm/mach-prima2/rtciobrg.c
index 8f66d8f7ca75..d4852d24dc7d 100644
--- a/arch/arm/mach-prima2/rtciobrg.c
+++ b/arch/arm/mach-prima2/rtciobrg.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * RTC I/O Bridge interfaces for CSR SiRFprimaII 2 * RTC I/O Bridge interfaces for CSR SiRFprimaII/atlas7
3 * ARM access the registers of SYSRTC, GPSRTC and PWRC through this module 3 * ARM access the registers of SYSRTC, GPSRTC and PWRC through this module
4 * 4 *
5 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. 5 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
@@ -10,6 +10,7 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/regmap.h>
13#include <linux/of.h> 14#include <linux/of.h>
14#include <linux/of_address.h> 15#include <linux/of_address.h>
15#include <linux/of_device.h> 16#include <linux/of_device.h>
@@ -66,6 +67,7 @@ u32 sirfsoc_rtc_iobrg_readl(u32 addr)
66{ 67{
67 unsigned long flags, val; 68 unsigned long flags, val;
68 69
70 /* TODO: add hwspinlock to sync with M3 */
69 spin_lock_irqsave(&rtciobrg_lock, flags); 71 spin_lock_irqsave(&rtciobrg_lock, flags);
70 72
71 val = __sirfsoc_rtc_iobrg_readl(addr); 73 val = __sirfsoc_rtc_iobrg_readl(addr);
@@ -90,6 +92,7 @@ void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr)
90{ 92{
91 unsigned long flags; 93 unsigned long flags;
92 94
95 /* TODO: add hwspinlock to sync with M3 */
93 spin_lock_irqsave(&rtciobrg_lock, flags); 96 spin_lock_irqsave(&rtciobrg_lock, flags);
94 97
95 sirfsoc_rtc_iobrg_pre_writel(val, addr); 98 sirfsoc_rtc_iobrg_pre_writel(val, addr);
@@ -102,6 +105,45 @@ void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr)
102} 105}
103EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_writel); 106EXPORT_SYMBOL_GPL(sirfsoc_rtc_iobrg_writel);
104 107
108
109static int regmap_iobg_regwrite(void *context, unsigned int reg,
110 unsigned int val)
111{
112 sirfsoc_rtc_iobrg_writel(val, reg);
113 return 0;
114}
115
116static int regmap_iobg_regread(void *context, unsigned int reg,
117 unsigned int *val)
118{
119 *val = (u32)sirfsoc_rtc_iobrg_readl(reg);
120 return 0;
121}
122
123static struct regmap_bus regmap_iobg = {
124 .reg_write = regmap_iobg_regwrite,
125 .reg_read = regmap_iobg_regread,
126};
127
128/**
129 * devm_regmap_init_iobg(): Initialise managed register map
130 *
131 * @iobg: Device that will be interacted with
132 * @config: Configuration for register map
133 *
134 * The return value will be an ERR_PTR() on error or a valid pointer
135 * to a struct regmap. The regmap will be automatically freed by the
136 * device management code.
137 */
138struct regmap *devm_regmap_init_iobg(struct device *dev,
139 const struct regmap_config *config)
140{
141 const struct regmap_bus *bus = &regmap_iobg;
142
143 return devm_regmap_init(dev, bus, dev, config);
144}
145EXPORT_SYMBOL_GPL(devm_regmap_init_iobg);
146
105static const struct of_device_id rtciobrg_ids[] = { 147static const struct of_device_id rtciobrg_ids[] = {
106 { .compatible = "sirf,prima2-rtciobg" }, 148 { .compatible = "sirf,prima2-rtciobg" },
107 {} 149 {}
@@ -132,7 +174,7 @@ static int __init sirfsoc_rtciobrg_init(void)
132} 174}
133postcore_initcall(sirfsoc_rtciobrg_init); 175postcore_initcall(sirfsoc_rtciobrg_init);
134 176
135MODULE_AUTHOR("Zhiwu Song <zhiwu.song@csr.com>, " 177MODULE_AUTHOR("Zhiwu Song <zhiwu.song@csr.com>");
136 "Barry Song <baohua.song@csr.com>"); 178MODULE_AUTHOR("Barry Song <baohua.song@csr.com>");
137MODULE_DESCRIPTION("CSR SiRFprimaII rtc io bridge"); 179MODULE_DESCRIPTION("CSR SiRFprimaII rtc io bridge");
138MODULE_LICENSE("GPL v2"); 180MODULE_LICENSE("GPL v2");
diff --git a/include/linux/rtc/sirfsoc_rtciobrg.h b/include/linux/rtc/sirfsoc_rtciobrg.h
index 2c92e1c8e055..aefd997262e4 100644
--- a/include/linux/rtc/sirfsoc_rtciobrg.h
+++ b/include/linux/rtc/sirfsoc_rtciobrg.h
@@ -9,10 +9,14 @@
9#ifndef _SIRFSOC_RTC_IOBRG_H_ 9#ifndef _SIRFSOC_RTC_IOBRG_H_
10#define _SIRFSOC_RTC_IOBRG_H_ 10#define _SIRFSOC_RTC_IOBRG_H_
11 11
12struct regmap_config;
13
12extern void sirfsoc_rtc_iobrg_besyncing(void); 14extern void sirfsoc_rtc_iobrg_besyncing(void);
13 15
14extern u32 sirfsoc_rtc_iobrg_readl(u32 addr); 16extern u32 sirfsoc_rtc_iobrg_readl(u32 addr);
15 17
16extern void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr); 18extern void sirfsoc_rtc_iobrg_writel(u32 val, u32 addr);
19struct regmap *devm_regmap_init_iobg(struct device *dev,
20 const struct regmap_config *config);
17 21
18#endif 22#endif