Skip to contentSkip to conversation

share rtc-sa1100 driver to arch-mmp

PATCH New Haojian Zhuang 3 participants 12 messages Feb 23, 2012 – Feb 24, 2012

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover share rtc-sa1100 driver to arch-mmp

Share rtc-sa1100 driver among arch-sa1100/arch-pxa/arch-mmp.

Changelog:

v3:
1) Remove the register definition from resource in order to build rtc-pxa and rtc-sa1100 together. Leave hard coded register definiton in rtc-sa1100.
2) Remove the dummy clock definition in rtc-sa1100.
3) Move the clk_prepare_enable() into open() function.

v2:
1) Use DEFINE_RES_*() to define resource in arch-sa1100.

#1 lore raw

PATCH v3 1/7 rtc: sa1100: remove periodic code

Since periodic timer is already supported by hrtimer in rtc interface, we needn't keep the duplicated code in rtc-sa1100.c any more.

---
 drivers/rtc/rtc-sa1100.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)
drivers/rtc/rtc-sa1100.c +0 -15
index cb9a585..fef52c8 100644
@@ -42,19 +42,8 @@
 #define RTC_DEF_TRIM		0
 
 static const unsigned long RTC_FREQ = 1024;
-static struct rtc_time rtc_alarm;
 static DEFINE_SPINLOCK(sa1100_rtc_lock);
 
-static inline int rtc_periodic_alarm(struct rtc_time *tm)
-{
-	return  (tm->tm_year == -1) ||
-		((unsigned)tm->tm_mon >= 12) ||
-		((unsigned)(tm->tm_mday - 1) >= 31) ||
-		((unsigned)tm->tm_hour > 23) ||
-		((unsigned)tm->tm_min > 59) ||
-		((unsigned)tm->tm_sec > 59);
-}
-
 /*
  * Calculate the next alarm time given the requested alarm time mask
  * and the current time.
@@ -146,9 +135,6 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
 
 	rtc_update_irq(rtc, 1, events);
 
-	if (rtsr & RTSR_AL && rtc_periodic_alarm(&rtc_alarm))
-		rtc_update_alarm(&rtc_alarm);
-
 	spin_unlock(&sa1100_rtc_lock);
 
 	return IRQ_HANDLED;
@@ -225,7 +211,6 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
 	u32	rtsr;
 
-	memcpy(&alrm->time, &rtc_alarm, sizeof(struct rtc_time));
 	rtsr = RTSR;
 	alrm->enabled = (rtsr & RTSR_ALE) ? 1 : 0;
 	alrm->pending = (rtsr & RTSR_AL) ? 1 : 0;
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v3 2/7 rtc: sa1100: remove verification code of alarm

In reply to Haojian Zhuang

Since next alarm time is already calculated in rtc common interface, we needn't keep this logic in rtc-sa1100.c any more.

---
 drivers/rtc/rtc-sa1100.c |   66 +++++++--------------------------------------
 1 files changed, 11 insertions(+), 55 deletions(-)
drivers/rtc/rtc-sa1100.c +11 -55
index fef52c8..91d58bd 100644
@@ -44,54 +44,6 @@
 static const unsigned long RTC_FREQ = 1024;
 static DEFINE_SPINLOCK(sa1100_rtc_lock);
 
-/*
- * Calculate the next alarm time given the requested alarm time mask
- * and the current time.
- */
-static void rtc_next_alarm_time(struct rtc_time *next, struct rtc_time *now,
-	struct rtc_time *alrm)
-{
-	unsigned long next_time;
-	unsigned long now_time;
-
-	next->tm_year = now->tm_year;
-	next->tm_mon = now->tm_mon;
-	next->tm_mday = now->tm_mday;
-	next->tm_hour = alrm->tm_hour;
-	next->tm_min = alrm->tm_min;
-	next->tm_sec = alrm->tm_sec;
-
-	rtc_tm_to_time(now, &now_time);
-	rtc_tm_to_time(next, &next_time);
-
-	if (next_time < now_time) {
-		/* Advance one day */
-		next_time += 60 * 60 * 24;
-		rtc_time_to_tm(next_time, next);
-	}
-}
-
-static int rtc_update_alarm(struct rtc_time *alrm)
-{
-	struct rtc_time alarm_tm, now_tm;
-	unsigned long now, time;
-	int ret;
-
-	do {
-		now = RCNR;
-		rtc_time_to_tm(now, &now_tm);
-		rtc_next_alarm_time(&alarm_tm, &now_tm, alrm);
-		ret = rtc_tm_to_time(&alarm_tm, &time);
-		if (ret != 0)
-			break;
-
-		RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
-		RTAR = time;
-	} while (now != RCNR);
-
-	return ret;
-}
-
 static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
 {
 	struct platform_device *pdev = to_platform_device(dev_id);
@@ -219,16 +171,20 @@ static int sa1100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 
 static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
 {
+	unsigned long time;
 	int ret;
 
 	spin_lock_irq(&sa1100_rtc_lock);
-	ret = rtc_update_alarm(&alrm->time);
-	if (ret == 0) {
-		if (alrm->enabled)
-			RTSR |= RTSR_ALE;
-		else
-			RTSR &= ~RTSR_ALE;
-	}
+	ret = rtc_tm_to_time(&alrm->time, &time);
+	if (ret != 0)
+		goto out;
+	RTSR = RTSR & (RTSR_HZE|RTSR_ALE|RTSR_AL);
+	RTAR = time;
+	if (alrm->enabled)
+		RTSR |= RTSR_ALE;
+	else
+		RTSR &= ~RTSR_ALE;
+out:
 	spin_unlock_irq(&sa1100_rtc_lock);
 
 	return ret;
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH v3 3/7 rtc: sa1100: declare irq in resource

In reply to Haojian Zhuang

Avoid to hard coded irq in rtc-sa1100 driver since we could share it among arch-sa1100/arch-pxa/arch-mmp.

We still keep hard coded register address since the requirement is enabling both rtc-sa1100 and rtc-pxa driver. The register addresses are conflict since they're only two wrappers on the same rtc device.

---
 arch/arm/mach-pxa/devices.c    |   28 +++++++++--
 arch/arm/mach-sa1100/generic.c |    8 +++
 drivers/rtc/Kconfig            |    4 +-
 drivers/rtc/rtc-sa1100.c       |   98 +++++++++++++++++++++++++++-------------
 4 files changed, 100 insertions(+), 38 deletions(-)
arch/arm/mach-pxa/devices.c +23 -5
index 5bc1312..84f2d70 100644
@@ -406,20 +406,17 @@ static struct resource pxa_rtc_resources[] = {
 	[1] = {
 		.start  = IRQ_RTC1Hz,
 		.end    = IRQ_RTC1Hz,
+		.name	= "rtc 1Hz",
 		.flags  = IORESOURCE_IRQ,
 	},
 	[2] = {
 		.start  = IRQ_RTCAlrm,
 		.end    = IRQ_RTCAlrm,
+		.name	= "rtc alarm",
 		.flags  = IORESOURCE_IRQ,
 	},
 };
 
-struct platform_device sa1100_device_rtc = {
-	.name		= "sa1100-rtc",
-	.id		= -1,
-};
-
 struct platform_device pxa_device_rtc = {
 	.name		= "pxa-rtc",
 	.id		= -1,
@@ -427,6 +424,27 @@ struct platform_device pxa_device_rtc = {
 	.resource       = pxa_rtc_resources,
 };
 
+static struct resource sa1100_rtc_resources[] = {
+	{
+		.start  = IRQ_RTC1Hz,
+		.end    = IRQ_RTC1Hz,
+		.name	= "rtc 1Hz",
+		.flags  = IORESOURCE_IRQ,
+	}, {
+		.start  = IRQ_RTCAlrm,
+		.end    = IRQ_RTCAlrm,
+		.name	= "rtc alarm",
+		.flags  = IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device sa1100_device_rtc = {
+	.name		= "sa1100-rtc",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(sa1100_rtc_resources),
+	.resource	= sa1100_rtc_resources,
+};
+
 static struct resource pxa_ac97_resources[] = {
 	[0] = {
 		.start  = 0x40500000,
arch/arm/mach-sa1100/generic.c +8 -0
index bb10ee2..7c1ebf4 100644
@@ -345,9 +345,17 @@ void sa11x0_register_irda(struct irda_platform_data *irda)
 	sa11x0_register_device(&sa11x0ir_device, irda);
 }
 
+static struct resource sa1100_rtc_resources[] = {
+	DEFINE_RES_MEM(0x90010000, 0x9001003f),
+	DEFINE_RES_IRQ_NAMED(IRQ_RTC1Hz, "rtc 1Hz"),
+	DEFINE_RES_IRQ_NAMED(IRQ_RTCAlrm, "rtc alarm"),
+};
+
 static struct platform_device sa11x0rtc_device = {
 	.name		= "sa1100-rtc",
 	.id		= -1,
+	.num_resources	= ARRAY_SIZE(sa1100_rtc_resources),
+	.resource	= sa1100_rtc_resources,
 };
 
 static struct platform_device *sa11x0_devices[] __initdata = {
drivers/rtc/Kconfig +2 -2
index 3a125b8..59efc63 100644
@@ -773,8 +773,8 @@ config RTC_DRV_EP93XX
 	  will be called rtc-ep93xx.
 
 config RTC_DRV_SA1100
-	tristate "SA11x0/PXA2xx"
-	depends on ARCH_SA1100 || ARCH_PXA
+	tristate "SA11x0/PXA2xx/PXA910"
+	depends on ARCH_SA1100 || ARCH_PXA || ARCH_MMP
 	help
 	  If you say Y here you will get access to the real time clock
 	  built into your SA11x0 or PXA2xx CPU.
drivers/rtc/rtc-sa1100.c +67 -31

215 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#4 lore raw

PATCH v3 4/7 ARM: sa1100: clean up clock support

In reply to Haojian Zhuang

From: Jett.Zhou <[email protected]>

Add rtc clock support and clean clock support for gpio.

---
 arch/arm/Kconfig             |    2 +-
 arch/arm/mach-sa1100/clock.c |   63 ++++++++++++++++++++++++------------------
 2 files changed, 37 insertions(+), 28 deletions(-)
arch/arm/Kconfig +1 -1
index a48aecc..6e40039 100644
@@ -754,7 +754,7 @@ config ARCH_SA1100
 	select ARCH_HAS_CPUFREQ
 	select CPU_FREQ
 	select GENERIC_CLOCKEVENTS
-	select HAVE_CLK
+	select CLKDEV_LOOKUP
 	select HAVE_SCHED_CLOCK
 	select TICK_ONESHOT
 	select ARCH_REQUIRE_GPIOLIB
arch/arm/mach-sa1100/clock.c +36 -27

104 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#5 lore raw

PATCH v3 4/7 ARM: sa1100: clean up clock support

arch/arm/mach-sa1100/clock.c static void clk_gpio27_enable(void) · line 61

Quoted 9 lines · Haojian Zhuang

int clk_enable(struct clk *clk)
{

arch/arm/mach-sa1100/clock.c +1 -1
 	unsigned long flags;
 
 	spin_lock_irqsave(&clocks_lock, flags);
 	if (clk->enabled++ == 0)
-		clk_gpio27_enable();
+		clk->ops->enable(clk);
 	spin_unlock_irqrestore(&clocks_lock, flags);

If we're going to allow clk to be NULL, this needs:

	if (clk) {
		...
	}

around it.

arch/arm/mach-sa1100/clock.c void clk_disable(struct clk *clk) · line 76

Quoted 11 lines
arch/arm/mach-sa1100/clock.c +2 -1
+
 	return 0;
 }
 EXPORT_SYMBOL(clk_enable);
@@ -76,13 +72,26 @@ void clk_disable(struct clk *clk)
 
 	spin_lock_irqsave(&clocks_lock, flags);
 	if (--clk->enabled == 0)
-		clk_gpio27_disable();
+		clk->ops->disable(clk);
 	spin_unlock_irqrestore(&clocks_lock, flags);

Same here.

Quoted 4 lines
arch/arm/mach-sa1100/clock.c +0 -1
 }
 EXPORT_SYMBOL(clk_disable);
 
-unsigned long clk_get_rate(struct clk *clk)

arch/arm/mach-sa1100/clock.c void clk_disable(struct clk *clk) · line 89

Quoted 10 lines
arch/arm/mach-sa1100/clock.c +10 -0
+const struct clkops clk_gpio27_ops = {
+	.enable		= clk_gpio27_enable,
+	.disable	= clk_gpio27_disable,
+};
+
+static DEFINE_CLK(gpio27, &clk_gpio27_ops);
+
+static struct clk_lookup sa11xx_clkregs[] = {
+	CLKDEV_INIT("sa1111.0", NULL, &clk_gpio27),
+	CLKDEV_INIT("sa1100-rtc", NULL, NULL),

And as this introduces NULL clock, the above needs to be part of this patch.

Apart from that, it's fine.

#6 lore raw

PATCH v4 4/7 ARM: sa1100: clean up clock support

In reply to Haojian Zhuang

From: Jett.Zhou <[email protected]>

Add rtc clock support and clean clock support for gpio.

---
 arch/arm/Kconfig             |    2 +-
 arch/arm/mach-sa1100/clock.c |   82 ++++++++++++++++++++++++------------------
 2 files changed, 48 insertions(+), 36 deletions(-)
arch/arm/Kconfig +1 -1
index a48aecc..6e40039 100644
@@ -754,7 +754,7 @@ config ARCH_SA1100
 	select ARCH_HAS_CPUFREQ
 	select CPU_FREQ
 	select GENERIC_CLOCKEVENTS
-	select HAVE_CLK
+	select CLKDEV_LOOKUP
 	select HAVE_SCHED_CLOCK
 	select TICK_ONESHOT
 	select ARCH_REQUIRE_GPIOLIB
arch/arm/mach-sa1100/clock.c +47 -35

119 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#7 lore raw

PATCH v3 5/7 ARM: pxa: add rtc dummy clock

In reply to Haojian Zhuang

sa1100-rtc driver could be shared among sa1100/pxa/mmp series silicon. Since clk is used in mmp series silicon, add dummy clock support in pxa also.

---
 arch/arm/mach-pxa/pxa25x.c |    1 +
 arch/arm/mach-pxa/pxa27x.c |    1 +
 arch/arm/mach-pxa/pxa3xx.c |    1 +
 arch/arm/mach-pxa/pxa95x.c |    1 +
 4 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/mach-pxa/pxa25x.c +1 -0
index 91e4f6c..d43c1a7 100644
@@ -209,6 +209,7 @@ static struct clk_lookup pxa25x_clkregs[] = {
 	INIT_CLKREG(&clk_pxa25x_gpio11, NULL, "GPIO11_CLK"),
 	INIT_CLKREG(&clk_pxa25x_gpio12, NULL, "GPIO12_CLK"),
 	INIT_CLKREG(&clk_pxa25x_mem, "pxa2xx-pcmcia", NULL),
+	INIT_CLKREG(&clk_dummy, "sa1100-rtc", NULL),
 };
 
 static struct clk_lookup pxa25x_hwuart_clkreg =
arch/arm/mach-pxa/pxa27x.c +1 -0
index aed6cbc..cf2f9d1 100644
@@ -230,6 +230,7 @@ static struct clk_lookup pxa27x_clkregs[] = {
 	INIT_CLKREG(&clk_pxa27x_im, NULL, "IMCLK"),
 	INIT_CLKREG(&clk_pxa27x_memc, NULL, "MEMCLK"),
 	INIT_CLKREG(&clk_pxa27x_mem, "pxa2xx-pcmcia", NULL),
+	INIT_CLKREG(&clk_dummy, "sa1100-rtc", NULL),
 };
 
 #ifdef CONFIG_PM
arch/arm/mach-pxa/pxa3xx.c +1 -0
index 4f402af..8819348 100644
@@ -89,6 +89,7 @@ static struct clk_lookup pxa3xx_clkregs[] = {
 	INIT_CLKREG(&clk_pxa3xx_mmc2, "pxa2xx-mci.1", NULL),
 	INIT_CLKREG(&clk_pxa3xx_smemc, "pxa2xx-pcmcia", NULL),
 	INIT_CLKREG(&clk_pxa3xx_gpio, "pxa-gpio", NULL),
+	INIT_CLKREG(&clk_dummy, "sa1100-rtc", NULL),
 };
 
 #ifdef CONFIG_PM
arch/arm/mach-pxa/pxa95x.c +1 -0
index d082a58..35023d7 100644
@@ -231,6 +231,7 @@ static struct clk_lookup pxa95x_clkregs[] = {
 	INIT_CLKREG(&clk_pxa95x_pwm0, "pxa27x-pwm.0", NULL),
 	INIT_CLKREG(&clk_pxa95x_pwm1, "pxa27x-pwm.1", NULL),
 	INIT_CLKREG(&clk_pxa95x_gpio, "pxa-gpio", NULL),
+	INIT_CLKREG(&clk_dummy, "sa1100-rtc", NULL),
 };
 
 void __init pxa95x_init_irq(void)
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH v3 5/7 ARM: pxa: add rtc dummy clock

Quoted 11 lines · Haojian Zhuang

sa1100-rtc driver could be shared among sa1100/pxa/mmp series silicon. Since clk is used in mmp series silicon, add dummy clock support in pxa also.

---
 arch/arm/mach-pxa/pxa25x.c |    1 +
 arch/arm/mach-pxa/pxa27x.c |    1 +
 arch/arm/mach-pxa/pxa3xx.c |    1 +
 arch/arm/mach-pxa/pxa95x.c |    1 +
 4 files changed, 4 insertions(+), 0 deletions(-)

This is missing changes in arch/arm/mach-pxa/clock.c to prevent clk_enable() etc oopsing when called with a NULL clock.

maintainer
#9 lore raw

PATCH v3 5/7 ARM: pxa: add rtc dummy clock

Quoted 13 lines · Russell King - ARM Linux
Quoted 11 lines · Haojian Zhuang

sa1100-rtc driver could be shared among sa1100/pxa/mmp series silicon. Since clk is used in mmp series silicon, add dummy clock support in pxa also.

---

?arch/arm/mach-pxa/pxa25x.c | ? ?1 +
?arch/arm/mach-pxa/pxa27x.c | ? ?1 +
?arch/arm/mach-pxa/pxa3xx.c | ? ?1 +
?arch/arm/mach-pxa/pxa95x.c | ? ?1 +

?4 files changed, 4 insertions(+), 0 deletions(-)

Quoted 3 lines

This is missing changes in arch/arm/mach-pxa/clock.c to prevent clk_enable() etc oopsing when called with a NULL clock.

Since I'm still using existed dummy clock in arch-pxa, I needn't to append checking for NULL clock. The dummy clock do nothing for clk_enable() & clk_disable().

I'll remove dummy clock in arch-pxa later.

Thanks
Haojian

#10 lore raw

PATCH v3 6/7 rtc: sa1100: enable clk support

In reply to Haojian Zhuang

Enable clock support on rtc-sa1100.

---
 drivers/rtc/rtc-sa1100.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/rtc/rtc-sa1100.c +17 -0
index 0a36c7e..962510c 100644
@@ -23,6 +23,7 @@
 
 #include <linux/platform_device.h>
 #include <linux/module.h>
+#include <linux/clk.h>
 #include <linux/rtc.h>
 #include <linux/init.h>
 #include <linux/fs.h>
@@ -48,6 +49,7 @@ struct sa1100_rtc {
 	int			irq_1hz;
 	int			irq_alarm;
 	struct rtc_device	*rtc;
+	struct clk		*clk;
 };
 
 static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
@@ -104,6 +106,9 @@ static int sa1100_rtc_open(struct device *dev)
 	struct rtc_device *rtc = info->rtc;
 	int ret;
 
+	ret = clk_prepare_enable(info->clk);
+	if (ret)
+		goto fail_clk;
 	ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, IRQF_DISABLED,
 		"rtc 1Hz", dev);
 	if (ret) {
@@ -124,6 +129,8 @@ static int sa1100_rtc_open(struct device *dev)
  fail_ai:
 	free_irq(info->irq_1hz, dev);
  fail_ui:
+	clk_disable_unprepare(info->clk);
+ fail_clk:
 	return ret;
 }
 
@@ -137,6 +144,7 @@ static void sa1100_rtc_release(struct device *dev)
 
 	free_irq(info->irq_alarm, dev);
 	free_irq(info->irq_1hz, dev);
+	clk_disable_unprepare(info->clk);
 }
 
 static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
@@ -234,6 +242,12 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
 	info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
+	info->clk = clk_get(&pdev->dev, NULL);
+	if (IS_ERR(info->clk)) {
+		dev_err(&pdev->dev, "failed to find rtc clock source\n");
+		ret = PTR_ERR(info->clk);
+		goto err_clk;
+	}
 	info->irq_1hz = irq_1hz;
 	info->irq_alarm = irq_alarm;
 	spin_lock_init(&info->lock);
@@ -292,6 +306,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
 	return 0;
 err_dev:
 	platform_set_drvdata(pdev, NULL);
+	clk_put(info->clk);
+err_clk:
 	kfree(info);
 	return ret;
 }
@@ -302,6 +318,7 @@ static int sa1100_rtc_remove(struct platform_device *pdev)
 
 	if (info) {
 		rtc_device_unregister(info->rtc);
+		clk_put(info->clk);
 		platform_set_drvdata(pdev, NULL);
 		kfree(info);
 	}
Signature · 1 line
1.7.0.4
#11 lore raw

PATCH v3 7/7 ARM: mmp: enable rtc in pxa910

In reply to Haojian Zhuang

Support rtc-sa1100 driver in pxa910.

---
 arch/arm/mach-mmp/include/mach/pxa910.h    |    1 +
 arch/arm/mach-mmp/include/mach/regs-apbc.h |    1 +
 arch/arm/mach-mmp/include/mach/regs-rtc.h  |   23 +++++++++++++++++++++++
 arch/arm/mach-mmp/pxa910.c                 |   27 +++++++++++++++++++++++++++
 arch/arm/mach-mmp/ttc_dkb.c                |    1 +
 5 files changed, 53 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-mmp/include/mach/regs-rtc.h
arch/arm/mach-mmp/include/mach/pxa910.h +1 -0
index 4de13ab..e2e1f1e 100644
@@ -22,6 +22,7 @@ extern struct pxa_device_desc pxa910_device_pwm4;
 extern struct pxa_device_desc pxa910_device_nand;
 
 extern struct platform_device pxa910_device_gpio;
+extern struct platform_device pxa910_device_rtc;
 
 static inline int pxa910_add_uart(int id)
 {
arch/arm/mach-mmp/include/mach/regs-apbc.h +1 -0
index 1a96585..8a37fb0 100644
@@ -57,6 +57,7 @@
 #define APBC_PXA910_SSP1	APBC_REG(0x01c)
 #define APBC_PXA910_SSP2	APBC_REG(0x020)
 #define APBC_PXA910_IPC		APBC_REG(0x024)
+#define APBC_PXA910_RTC		APBC_REG(0x028)
 #define APBC_PXA910_TWSI0	APBC_REG(0x02c)
 #define APBC_PXA910_KPC		APBC_REG(0x030)
 #define APBC_PXA910_TIMERS	APBC_REG(0x034)
arch/arm/mach-mmp/include/mach/regs-rtc.h new file +23 -0
new file mode 100644
index 0000000..5bff886
@@ -0,0 +1,23 @@
+#ifndef __ASM_MACH_REGS_RTC_H
+#define __ASM_MACH_REGS_RTC_H
+
+#include <mach/addr-map.h>
+
+#define RTC_VIRT_BASE	(APB_VIRT_BASE + 0x10000)
+#define RTC_REG(x)	(*((volatile u32 __iomem *)(RTC_VIRT_BASE + (x))))
+
+/*
+ * Real Time Clock
+ */
+
+#define RCNR		RTC_REG(0x00)	/* RTC Count Register */
+#define RTAR		RTC_REG(0x04)	/* RTC Alarm Register */
+#define RTSR		RTC_REG(0x08)	/* RTC Status Register */
+#define RTTR		RTC_REG(0x0C)	/* RTC Timer Trim Register */
+
+#define RTSR_HZE	(1 << 3)	/* HZ interrupt enable */
+#define RTSR_ALE	(1 << 2)	/* RTC alarm interrupt enable */
+#define RTSR_HZ		(1 << 1)	/* HZ rising-edge detected */
+#define RTSR_AL		(1 << 0)	/* RTC alarm detected */
+
+#endif /* __ASM_MACH_REGS_RTC_H */
arch/arm/mach-mmp/pxa910.c +27 -0
index 3241a25..b6e1527 100644
@@ -92,6 +92,7 @@ static APBC_CLK(pwm2, PXA910_PWM2, 1, 13000000);
 static APBC_CLK(pwm3, PXA910_PWM3, 1, 13000000);
 static APBC_CLK(pwm4, PXA910_PWM4, 1, 13000000);
 static APBC_CLK(gpio, PXA910_GPIO, 0, 13000000);
+static APBC_CLK(rtc, PXA910_RTC, 8, 32768);
 
 static APMU_CLK(nand, NAND, 0x19b, 156000000);
 static APMU_CLK(u2o, USB, 0x1b, 480000000);
@@ -109,6 +110,7 @@ static struct clk_lookup pxa910_clkregs[] = {
 	INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL),
 	INIT_CLKREG(&clk_gpio, "pxa-gpio", NULL),
 	INIT_CLKREG(&clk_u2o, "pxa-u2o", "U2OCLK"),
+	INIT_CLKREG(&clk_rtc, "sa1100-rtc", NULL),
 };
 
 static int __init pxa910_init(void)
@@ -183,3 +185,28 @@ struct platform_device pxa910_device_gpio = {
 	.num_resources	= ARRAY_SIZE(pxa910_resource_gpio),
 	.resource	= pxa910_resource_gpio,
 };
+
+static struct resource pxa910_resource_rtc[] = {
+	{
+		.start	= 0xd4010000,
+		.end	= 0xd401003f,
+		.flags	= IORESOURCE_MEM,
+	}, {
+		.start	= IRQ_PXA910_RTC_INT,
+		.end	= IRQ_PXA910_RTC_INT,
+		.name	= "rtc 1Hz",
+		.flags	= IORESOURCE_IRQ,
+	}, {
+		.start	= IRQ_PXA910_RTC_ALARM,
+		.end	= IRQ_PXA910_RTC_ALARM,
+		.name	= "rtc alarm",
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+struct platform_device pxa910_device_rtc = {
+	.name		= "sa1100-rtc",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(pxa910_resource_rtc),
+	.resource	= pxa910_resource_rtc,
+};
arch/arm/mach-mmp/ttc_dkb.c +1 -0
index 5ac5d58..e72c709 100644
@@ -124,6 +124,7 @@ static struct platform_device ttc_dkb_device_onenand = {
 
 static struct platform_device *ttc_dkb_devices[] = {
 	&pxa910_device_gpio,
+	&pxa910_device_rtc,
 	&ttc_dkb_device_onenand,
 };
 
Signature · 1 line
1.7.0.4