* [PATCH 0/2] ab8540 cut2: new rtc second resolution
@ 2013-05-24 9:59 Alexandre Torgue
2013-05-24 9:59 ` [PATCH 1/2] mfd: ab8540: add device for new rtc version on ab8540 cut2 Alexandre Torgue
2013-05-24 9:59 ` [PATCH 2/2] rtc: ab8540: add second resolution to rtc driver Alexandre Torgue
0 siblings, 2 replies; 4+ messages in thread
From: Alexandre Torgue @ 2013-05-24 9:59 UTC (permalink / raw)
To: Alessandro Zummo, rtc-linux, linux-kernel
Cc: Lee Jones, Samuel Ortiz, Alexandre Torgue
From: Alexandre Torgue <alexandre.torgue@st.com>
Android expects the RTC to have second resolution.
On ab8540 cut2 RTC block has a new register which
allows setting seconds for wakeup alarms.
Alexandre Torgue (2):
mfd: ab8540: add device for new rtc version on ab8540 cut2
rtc: ab8540: add second resolution to rtc driver
drivers/mfd/ab8500-core.c | 55 +++++++++++++++++++++++++++++-----
drivers/rtc/rtc-ab8500.c | 63 ++++++++++++++++++++++++++++++++++++++-
include/linux/mfd/abx500/ab8500.h | 2 ++
3 files changed, 111 insertions(+), 9 deletions(-)
--
1.8.2.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] mfd: ab8540: add device for new rtc version on ab8540 cut2
2013-05-24 9:59 [PATCH 0/2] ab8540 cut2: new rtc second resolution Alexandre Torgue
@ 2013-05-24 9:59 ` Alexandre Torgue
2013-05-28 9:47 ` Lee Jones
2013-05-24 9:59 ` [PATCH 2/2] rtc: ab8540: add second resolution to rtc driver Alexandre Torgue
1 sibling, 1 reply; 4+ messages in thread
From: Alexandre Torgue @ 2013-05-24 9:59 UTC (permalink / raw)
To: Alessandro Zummo, rtc-linux, linux-kernel
Cc: Lee Jones, Samuel Ortiz, Alexandre Torgue, Julien Delacou
From: Alexandre Torgue <alexandre.torgue@st.com>
AB8540 rtc have changed between AB8540_cut1 and AB8540_cut2.Different
ressources to define for those two version.
Signed-off-by: Julien Delacou <julien.delacou@stericsson.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 42abd3a..6f22527 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -650,6 +650,21 @@ static struct resource ab8500_rtc_resources[] = {
},
};
+static struct resource ab8540_rtc_resources[] = {
+ {
+ .name = "1S",
+ .start = AB8540_INT_RTC_1S,
+ .end = AB8540_INT_RTC_1S,
+ .flags = IORESOURCE_IRQ,
+ },
+ {
+ .name = "ALARM",
+ .start = AB8500_INT_RTC_ALARM,
+ .end = AB8500_INT_RTC_ALARM,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
static struct resource ab8500_poweronkey_db_resources[] = {
{
.name = "ONKEY_DBF",
@@ -1284,11 +1299,6 @@ static struct mfd_cell ab8540_devs[] = {
.resources = ab8505_gpadc_resources,
},
{
- .name = "ab8500-rtc",
- .num_resources = ARRAY_SIZE(ab8500_rtc_resources),
- .resources = ab8500_rtc_resources,
- },
- {
.name = "ab8500-acc-det",
.num_resources = ARRAY_SIZE(ab8500_av_acc_detect_resources),
.resources = ab8500_av_acc_detect_resources,
@@ -1328,6 +1338,24 @@ static struct mfd_cell ab8540_devs[] = {
},
};
+static struct mfd_cell ab8540_cut1_devs[] = {
+ {
+ .name = "ab8500-rtc",
+ .of_compatible = "stericsson,ab8500-rtc",
+ .num_resources = ARRAY_SIZE(ab8500_rtc_resources),
+ .resources = ab8500_rtc_resources,
+ },
+};
+
+static struct mfd_cell ab8540_cut2_devs[] = {
+ {
+ .name = "ab8540-rtc",
+ .of_compatible = "stericsson,ab8540-rtc",
+ .num_resources = ARRAY_SIZE(ab8540_rtc_resources),
+ .resources = ab8540_rtc_resources,
+ },
+};
+
static ssize_t show_chip_id(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -1731,11 +1759,22 @@ static int ab8500_probe(struct platform_device *pdev)
ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs,
ARRAY_SIZE(ab9540_devs), NULL,
ab8500->irq_base, ab8500->domain);
- else if (is_ab8540(ab8500))
+ else if (is_ab8540(ab8500)) {
ret = mfd_add_devices(ab8500->dev, 0, ab8540_devs,
ARRAY_SIZE(ab8540_devs), NULL,
- ab8500->irq_base, ab8500->domain);
- else if (is_ab8505(ab8500))
+ ab8500->irq_base, NULL);
+ if (ret)
+ return ret;
+
+ if (is_ab8540_1p2_or_earlier(ab8500))
+ ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut1_devs,
+ ARRAY_SIZE(ab8540_cut1_devs), NULL,
+ ab8500->irq_base, NULL);
+ else /* ab8540 >= cut2 */
+ ret = mfd_add_devices(ab8500->dev, 0, ab8540_cut2_devs,
+ ARRAY_SIZE(ab8540_cut2_devs), NULL,
+ ab8500->irq_base, NULL);
+ } else if (is_ab8505(ab8500))
ret = mfd_add_devices(ab8500->dev, 0, ab8505_devs,
ARRAY_SIZE(ab8505_devs), NULL,
ab8500->irq_base, ab8500->domain);
diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
index fb1bf7d..e330ad3 100644
--- a/include/linux/mfd/abx500/ab8500.h
+++ b/include/linux/mfd/abx500/ab8500.h
@@ -291,6 +291,8 @@ enum ab8500_version {
#define AB8540_INT_FSYNC2R 213
#define AB8540_INT_BITCLK2F 214
#define AB8540_INT_BITCLK2R 215
+/* ab8540_irq_regoffset[27] -> IT[Source|Latch|Mask]33 */
+#define AB8540_INT_RTC_1S 216
/*
* AB8500_AB9540_NR_IRQS is used when configuring the IRQ numbers for the
--
1.8.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] rtc: ab8540: add second resolution to rtc driver
2013-05-24 9:59 [PATCH 0/2] ab8540 cut2: new rtc second resolution Alexandre Torgue
2013-05-24 9:59 ` [PATCH 1/2] mfd: ab8540: add device for new rtc version on ab8540 cut2 Alexandre Torgue
@ 2013-05-24 9:59 ` Alexandre Torgue
1 sibling, 0 replies; 4+ messages in thread
From: Alexandre Torgue @ 2013-05-24 9:59 UTC (permalink / raw)
To: Alessandro Zummo, rtc-linux, linux-kernel
Cc: Lee Jones, Samuel Ortiz, Alexandre Torgue, Julien Delacou
From: Alexandre Torgue <alexandre.torgue@st.com>
Android expects the RTC to have second resolution. On ab8540 cut2 RTC
block has a new register which allows setting seconds for wakeup
alarms.
Existing registers (minutes hi, mid and low) have seen their offsets
changed. Here is the new mapping:
* AlarmSec (A) 0x22
* AlarmMinLow (M) from 0x8 to 0x23
* AlarmMinMid (M) from 0x9 to 0x24
* AlarmMinHigh (M) from 0xA to 0x25
Signed-off-by: Julien Delacou <julien.delacou@stericsson.com>
Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c
index 63cfa31..4de5cd9 100644
--- a/drivers/rtc/rtc-ab8500.c
+++ b/drivers/rtc/rtc-ab8500.c
@@ -35,6 +35,10 @@
#define AB8500_RTC_FORCE_BKUP_REG 0x0D
#define AB8500_RTC_CALIB_REG 0x0E
#define AB8500_RTC_SWITCH_STAT_REG 0x0F
+#define AB8540_RTC_ALRM_SEC 0x22
+#define AB8540_RTC_ALRM_MIN_LOW_REG 0x23
+#define AB8540_RTC_ALRM_MIN_MID_REG 0x24
+#define AB8540_RTC_ALRM_MIN_HI_REG 0x25
/* RtcReadRequest bits */
#define RTC_READ_REQUEST 0x01
@@ -58,6 +62,11 @@ static const u8 ab8500_rtc_alarm_regs[] = {
AB8500_RTC_ALRM_MIN_LOW_REG
};
+static const u8 ab8540_rtc_alarm_regs[] = {
+ AB8540_RTC_ALRM_MIN_HI_REG, AB8540_RTC_ALRM_MIN_MID_REG,
+ AB8540_RTC_ALRM_MIN_LOW_REG, AB8540_RTC_ALRM_SEC
+};
+
/* Calculate the seconds from 1970 to 01-01-2000 00:00:00 */
static unsigned long get_elapsed_seconds(int year)
{
@@ -267,6 +276,42 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
return ab8500_rtc_irq_enable(dev, alarm->enabled);
}
+static int ab8540_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
+{
+ int retval, i;
+ unsigned char buf[ARRAY_SIZE(ab8540_rtc_alarm_regs)];
+ unsigned long mins, secs = 0;
+
+ if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) {
+ dev_dbg(dev, "year should be equal to or greater than %d\n",
+ AB8500_RTC_EPOCH);
+ return -EINVAL;
+ }
+
+ /* Get the number of seconds since 1970 */
+ rtc_tm_to_time(&alarm->time, &secs);
+
+ /*
+ * Convert it to the number of seconds since 01-01-2000 00:00:00
+ */
+ secs -= get_elapsed_seconds(AB8500_RTC_EPOCH);
+ mins = secs / 60;
+
+ buf[3] = secs % 60;
+ buf[2] = mins & 0xFF;
+ buf[1] = (mins >> 8) & 0xFF;
+ buf[0] = (mins >> 16) & 0xFF;
+
+ /* Set the alarm time */
+ for (i = 0; i < ARRAY_SIZE(ab8540_rtc_alarm_regs); i++) {
+ retval = abx500_set_register_interruptible(dev, AB8500_RTC,
+ ab8540_rtc_alarm_regs[i], buf[i]);
+ if (retval < 0)
+ return retval;
+ }
+
+ return ab8500_rtc_irq_enable(dev, alarm->enabled);
+}
static int ab8500_rtc_set_calibration(struct device *dev, int calibration)
{
@@ -389,8 +434,22 @@ static const struct rtc_class_ops ab8500_rtc_ops = {
.alarm_irq_enable = ab8500_rtc_irq_enable,
};
+static const struct rtc_class_ops ab8540_rtc_ops = {
+ .read_time = ab8500_rtc_read_time,
+ .set_time = ab8500_rtc_set_time,
+ .read_alarm = ab8500_rtc_read_alarm,
+ .set_alarm = ab8540_rtc_set_alarm,
+ .alarm_irq_enable = ab8500_rtc_irq_enable,
+};
+
+static struct platform_device_id ab85xx_rtc_ids[] = {
+ { "ab8500-rtc", (kernel_ulong_t)&ab8500_rtc_ops, },
+ { "ab8540-rtc", (kernel_ulong_t)&ab8540_rtc_ops, },
+};
+
static int ab8500_rtc_probe(struct platform_device *pdev)
{
+ const struct platform_device_id *platid = platform_get_device_id(pdev);
int err;
struct rtc_device *rtc;
u8 rtc_ctrl;
@@ -423,7 +482,8 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, true);
rtc = devm_rtc_device_register(&pdev->dev, "ab8500-rtc",
- &ab8500_rtc_ops, THIS_MODULE);
+ (struct rtc_class_ops *)platid->driver_data,
+ THIS_MODULE);
if (IS_ERR(rtc)) {
dev_err(&pdev->dev, "Registration failed\n");
err = PTR_ERR(rtc);
@@ -463,6 +523,7 @@ static struct platform_driver ab8500_rtc_driver = {
},
.probe = ab8500_rtc_probe,
.remove = ab8500_rtc_remove,
+ .id_table = ab85xx_rtc_ids,
};
module_platform_driver(ab8500_rtc_driver);
--
1.8.2.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mfd: ab8540: add device for new rtc version on ab8540 cut2
2013-05-24 9:59 ` [PATCH 1/2] mfd: ab8540: add device for new rtc version on ab8540 cut2 Alexandre Torgue
@ 2013-05-28 9:47 ` Lee Jones
0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2013-05-28 9:47 UTC (permalink / raw)
To: Alexandre Torgue
Cc: Alessandro Zummo, rtc-linux, linux-kernel, Samuel Ortiz,
Alexandre Torgue, Julien Delacou
On Fri, 24 May 2013, Alexandre Torgue wrote:
> From: Alexandre Torgue <alexandre.torgue@st.com>
>
> AB8540 rtc have changed between AB8540_cut1 and AB8540_cut2.Different
> ressources to define for those two version.
>
> Signed-off-by: Julien Delacou <julien.delacou@stericsson.com>
> Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com>
>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Applied, thanks.
--
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-05-28 9:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-24 9:59 [PATCH 0/2] ab8540 cut2: new rtc second resolution Alexandre Torgue
2013-05-24 9:59 ` [PATCH 1/2] mfd: ab8540: add device for new rtc version on ab8540 cut2 Alexandre Torgue
2013-05-28 9:47 ` Lee Jones
2013-05-24 9:59 ` [PATCH 2/2] rtc: ab8540: add second resolution to rtc driver Alexandre Torgue
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.