* [rtc-linux] [PATCH 0/2] add Alphascale asm9260 RTC driver
@ 2016-01-29 8:40 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-01-29 8:40 UTC (permalink / raw)
To: devicetree, robh+dt, a.zummo, alexandre.belloni, rtc-linux; +Cc: Oleksij Rempel
This patch set provide support for RTC controller found on Alphascale
ASM9260 SoC.
Oleksij Rempel (2):
rtc: add rtc-asm9260 driver
doc: dt: add documentation for alphascale,asm9260-rtc
.../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++
drivers/rtc/Kconfig | 10 +
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-asm9260.c | 391 +++++++++++++++++++++
4 files changed, 427 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
create mode 100644 drivers/rtc/rtc-asm9260.c
--
2.5.0
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 0/2] add Alphascale asm9260 RTC driver
@ 2016-01-29 8:40 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-01-29 8:40 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: Oleksij Rempel
This patch set provide support for RTC controller found on Alphascale
ASM9260 SoC.
Oleksij Rempel (2):
rtc: add rtc-asm9260 driver
doc: dt: add documentation for alphascale,asm9260-rtc
.../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++
drivers/rtc/Kconfig | 10 +
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-asm9260.c | 391 +++++++++++++++++++++
4 files changed, 427 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
create mode 100644 drivers/rtc/rtc-asm9260.c
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] [PATCH 1/2] rtc: add rtc-asm9260 driver
@ 2016-01-29 8:40 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-01-29 8:40 UTC (permalink / raw)
To: devicetree, robh+dt, a.zummo, alexandre.belloni, rtc-linux; +Cc: Oleksij Rempel
Add support for RTC controller found on Alphascale asm9260
SoC.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/rtc/Kconfig | 10 ++
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-asm9260.c | 391 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 402 insertions(+)
create mode 100644 drivers/rtc/rtc-asm9260.c
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 376322f..733b6aa 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1144,6 +1144,16 @@ config RTC_DRV_ZYNQMP
comment "on-CPU RTC drivers"
+config RTC_DRV_ASM9260
+ tristate "Alphascale asm9260 RTC"
+ depends on MACH_ASM9260
+ help
+ If you say yes here you get support for the RTC on the
+ Alphascale asm9260 SoC.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-asm9260.
+
config RTC_DRV_DAVINCI
tristate "TI DaVinci RTC"
depends on ARCH_DAVINCI_DM365
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 62d61b2..f4d841b 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_RTC_DRV_ABB5ZES3) += rtc-ab-b5ze-s3.o
obj-$(CONFIG_RTC_DRV_ABX80X) += rtc-abx80x.o
obj-$(CONFIG_RTC_DRV_ARMADA38X) += rtc-armada38x.o
obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o
+obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o
obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o
obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
diff --git a/drivers/rtc/rtc-asm9260.c b/drivers/rtc/rtc-asm9260.c
new file mode 100644
index 0000000..0287ae9
--- /dev/null
+++ b/drivers/rtc/rtc-asm9260.c
@@ -0,0 +1,391 @@
+/*
+ * Copyright (C) 2014 Oleksij Rempel <linux@rempel-privat.de>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ */
+
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+
+/* Miscellaneous registers */
+/* Interrupt Location Register */
+#define HW_ILR 0x00
+#define BM_RTCALF BIT(1)
+#define BM_RTCCIF BIT(0)
+
+/* Clock Control Register */
+#define HW_CCR 0x08
+/* Calibration counter disable */
+#define BM_CCALOFF BIT(4)
+/* Reset internal oscillator divider */
+#define BM_CTCRST BIT(1)
+/* Clock Enable */
+#define BM_CLKEN BIT(0)
+
+/* Counter Increment Interrupt Register */
+#define HW_CIIR 0x0C
+#define BM_CIIR_IMYEAR BIT(7)
+#define BM_CIIR_IMMON BIT(6)
+#define BM_CIIR_IMDOY BIT(5)
+#define BM_CIIR_IMDOW BIT(4)
+#define BM_CIIR_IMDOM BIT(3)
+#define BM_CIIR_IMHOUR BIT(2)
+#define BM_CIIR_IMMIN BIT(1)
+#define BM_CIIR_IMSEC BIT(0)
+
+/* Alarm Mask Register */
+#define HW_AMR 0x10
+#define BM_AMR_IMYEAR BIT(7)
+#define BM_AMR_IMMON BIT(6)
+#define BM_AMR_IMDOY BIT(5)
+#define BM_AMR_IMDOW BIT(4)
+#define BM_AMR_IMDOM BIT(3)
+#define BM_AMR_IMHOUR BIT(2)
+#define BM_AMR_IMMIN BIT(1)
+#define BM_AMR_IMSEC BIT(0)
+#define BM_AMR_OFF 0xff
+
+/* Consolidated time registers */
+#define HW_CTIME0 0x14
+#define BM_CTIME0_DOW_S 24
+#define BM_CTIME0_DOW_M 0x7
+#define BM_CTIME0_HOUR_S 16
+#define BM_CTIME0_HOUR_M 0x1f
+#define BM_CTIME0_MIN_S 8
+#define BM_CTIME0_MIN_M 0x3f
+#define BM_CTIME0_SEC_S 0
+#define BM_CTIME0_SEC_M 0x3f
+
+#define HW_CTIME1 0x18
+#define BM_CTIME1_YEAR_S 16
+#define BM_CTIME1_YEAR_M 0xfff
+#define BM_CTIME1_MON_S 8
+#define BM_CTIME1_MON_M 0xf
+#define BM_CTIME1_DOM_S 0
+#define BM_CTIME1_DOM_M 0x1f
+
+#define HW_CTIME2 0x1C
+#define BM_CTIME2_DOY_S 0
+#define BM_CTIME2_DOY_M 0xfff
+
+/* Time counter registers */
+#define HW_SEC 0x20
+#define HW_MIN 0x24
+#define HW_HOUR 0x28
+#define HW_DOM 0x2C
+#define HW_DOW 0x30
+#define HW_DOY 0x34
+#define HW_MONTH 0x38
+#define HW_YEAR 0x3C
+
+#define HW_CALIBRATION 0x40
+#define BM_CALDIR_BACK BIT(17)
+#define BM_CALVAL_M 0x1ffff
+
+/* General purpose registers */
+#define HW_GPREG0 0x44
+#define HW_GPREG1 0x48
+#define HW_GPREG2 0x4C
+#define HW_GPREG3 0x50
+#define HW_GPREG4 0x54
+
+/* RTC Auxiliary control register */
+#define HW_RTC_AUX 0x5C
+/*
+ * RTC Oscillator Fail detect flag.
+ * Read: this bit is set if the RTC oscillator stops, and when RTC power is
+ * first turned on. An interrupt will occur when this bit is set, the
+ * RTC_OSCFEN bit in RTC_AUXEN is a 1, and the RTC interrupt is enabled
+ * in the NVIC.
+ * Write: writing a 1 to this bit clears the flag.
+ */
+#define BM_RTC_OSCF BIT(4)
+/* RTC Auxiliary Enable register */
+#define HW_RTC_AUXEN 0x58
+/* Oscillator Fail Detect interrupt enable. */
+#define BM_RTC_OSCFEN BIT(4)
+
+/* Alarm register group */
+#define HW_ALSEC 0x60
+#define HW_ALMIN 0x64
+#define HW_ALHOUR 0x68
+#define HW_ALDOM 0x6C
+#define HW_ALDOW 0x70
+#define HW_ALDOY 0x74
+#define HW_ALMON 0x78
+#define HW_ALYEAR 0x7C
+
+struct asm9260_rtc_priv {
+ struct device *dev;
+ void __iomem *iobase;
+ struct rtc_device *rtc;
+ struct clk *clk;
+ /* io lock */
+ spinlock_t lock;
+};
+
+static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
+{
+ struct asm9260_rtc_priv *priv = dev_id;
+ u32 isr;
+ unsigned long events = 0;
+
+ isr = ioread32(priv->iobase + HW_CIIR);
+ if (!isr)
+ return IRQ_NONE;
+
+ iowrite32(0, priv->iobase + HW_CIIR);
+
+ events |= RTC_AF | RTC_IRQF;
+
+ rtc_update_irq(priv->rtc, 1, events);
+
+ return IRQ_HANDLED;
+}
+
+static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ u32 ctime0, ctime1, ctime2;
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ ctime0 = ioread32(priv->iobase + HW_CTIME0);
+ ctime1 = ioread32(priv->iobase + HW_CTIME1);
+ ctime2 = ioread32(priv->iobase + HW_CTIME2);
+
+ if (ctime1 != ioread32(priv->iobase + HW_CTIME1)) {
+ /*
+ * woops, counter flipped right now. Now we are safe
+ * to reread.
+ */
+ ctime0 = ioread32(priv->iobase + HW_CTIME0);
+ ctime1 = ioread32(priv->iobase + HW_CTIME1);
+ ctime2 = ioread32(priv->iobase + HW_CTIME2);
+ }
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
+ tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
+ tm->tm_hour = (ctime0 >> BM_CTIME0_HOUR_S) & BM_CTIME0_HOUR_M;
+ tm->tm_wday = (ctime0 >> BM_CTIME0_DOW_S) & BM_CTIME0_DOW_M;
+
+ tm->tm_mday = (ctime1 >> BM_CTIME1_DOM_S) & BM_CTIME1_DOM_M;
+ tm->tm_mon = (ctime1 >> BM_CTIME1_MON_S) & BM_CTIME1_MON_M;
+ tm->tm_year = (ctime1 >> BM_CTIME1_YEAR_S) & BM_CTIME1_YEAR_M;
+
+ tm->tm_yday = (ctime2 >> BM_CTIME2_DOY_S) & BM_CTIME2_DOY_M;
+
+ return 0;
+}
+
+static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ /*
+ * make sure SEC counter will not flip other counter on write time,
+ * real value will be written at the enf of sequence.
+ */
+ iowrite32(0, priv->iobase + HW_SEC);
+
+ iowrite32(tm->tm_year, priv->iobase + HW_YEAR);
+ iowrite32(tm->tm_mon, priv->iobase + HW_MONTH);
+ iowrite32(tm->tm_mday, priv->iobase + HW_DOM);
+ iowrite32(tm->tm_wday, priv->iobase + HW_DOW);
+ iowrite32(tm->tm_yday, priv->iobase + HW_DOY);
+ iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
+ iowrite32(tm->tm_min, priv->iobase + HW_MIN);
+ iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return 0;
+}
+
+static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ alrm->time.tm_year = ioread32(priv->iobase + HW_ALYEAR);
+ alrm->time.tm_mon = ioread32(priv->iobase + HW_ALMON);
+ alrm->time.tm_mday = ioread32(priv->iobase + HW_ALDOM);
+ alrm->time.tm_wday = ioread32(priv->iobase + HW_ALDOW);
+ alrm->time.tm_yday = ioread32(priv->iobase + HW_ALDOY);
+ alrm->time.tm_hour = ioread32(priv->iobase + HW_ALHOUR);
+ alrm->time.tm_min = ioread32(priv->iobase + HW_ALMIN);
+ alrm->time.tm_sec = ioread32(priv->iobase + HW_ALSEC);
+
+ alrm->enabled = ioread32(priv->iobase + HW_AMR) ? 1 : 0;
+ alrm->pending = ioread32(priv->iobase + HW_CIIR) ? 1 : 0;
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return rtc_valid_tm(&alrm->time);
+}
+
+static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ iowrite32(alrm->time.tm_year, priv->iobase + HW_ALYEAR);
+ iowrite32(alrm->time.tm_mon, priv->iobase + HW_ALMON);
+ iowrite32(alrm->time.tm_mday, priv->iobase + HW_ALDOM);
+ iowrite32(alrm->time.tm_wday, priv->iobase + HW_ALDOW);
+ iowrite32(alrm->time.tm_yday, priv->iobase + HW_ALDOY);
+ iowrite32(alrm->time.tm_hour, priv->iobase + HW_ALHOUR);
+ iowrite32(alrm->time.tm_min, priv->iobase + HW_ALMIN);
+ iowrite32(alrm->time.tm_sec, priv->iobase + HW_ALSEC);
+
+ iowrite32(alrm->enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return 0;
+}
+
+static int asm9260_alarm_irq_enable(struct device *dev, unsigned int enabled)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+
+ iowrite32(enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
+ return 0;
+}
+
+static const struct rtc_class_ops asm9260_rtc_ops = {
+ .read_time = asm9260_rtc_read_time,
+ .set_time = asm9260_rtc_set_time,
+ .read_alarm = asm9260_rtc_read_alarm,
+ .set_alarm = asm9260_rtc_set_alarm,
+ .alarm_irq_enable = asm9260_alarm_irq_enable,
+};
+
+static int __init asm9260_rtc_probe(struct platform_device *pdev)
+{
+ struct asm9260_rtc_priv *priv;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ int irq_alarm, ret;
+ s32 calibvalue;
+ u32 ccr, cal;
+
+ priv = devm_kzalloc(dev, sizeof(struct asm9260_rtc_priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->dev = &pdev->dev;
+ platform_set_drvdata(pdev, priv);
+
+ irq_alarm = platform_get_irq(pdev, 0);
+ if (irq_alarm < 0) {
+ dev_err(dev, "No alarm IRQ resource defined\n");
+ return irq_alarm;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ priv->iobase = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->iobase))
+ return PTR_ERR(priv->iobase);
+
+ priv->clk = devm_clk_get(dev, "ahb");
+ ret = clk_prepare_enable(priv->clk);
+ if (ret) {
+ dev_err(dev, "Failed to enable clk!\n");
+ return ret;
+ }
+
+ ccr = ioread32(priv->iobase + HW_CCR);
+ /* if dev is not enabled, reset it */
+ if ((ccr & (BM_CLKEN | BM_CTCRST)) != BM_CLKEN) {
+ iowrite32(BM_CTCRST, priv->iobase + HW_CCR);
+ ccr = 0;
+ }
+
+ ret = of_property_read_s32(pdev->dev.of_node, "calibration",
+ &calibvalue);
+ if (ret) {
+ ccr |= BM_CCALOFF;
+ cal = 0;
+ } else {
+ ccr &= ~BM_CCALOFF;
+
+ cal = abs(calibvalue);
+ if (cal > BM_CALVAL_M) {
+ dev_err(dev, "calibration value is to big: %d\n",
+ cal);
+ goto err_return;
+ }
+
+ if (calibvalue < 0)
+ cal |= BM_CALDIR_BACK;
+ }
+
+ iowrite32(BM_CLKEN | ccr, priv->iobase + HW_CCR);
+ iowrite32(cal, priv->iobase + HW_CALIBRATION);
+ iowrite32(0, priv->iobase + HW_CIIR);
+ iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
+
+ priv->rtc = devm_rtc_device_register(dev, dev_name(dev),
+ &asm9260_rtc_ops, THIS_MODULE);
+ if (IS_ERR(priv->rtc)) {
+ ret = PTR_ERR(priv->rtc);
+ dev_err(dev, "Failed to register RTC device: %d\n", ret);
+ goto err_return;
+ }
+
+ ret = devm_request_threaded_irq(dev, irq_alarm, NULL,
+ asm9260_rtc_irq, IRQF_ONESHOT,
+ dev_name(dev), priv);
+ if (ret < 0) {
+ dev_err(dev, "can't get irq %i, err %d\n",
+ irq_alarm, ret);
+ goto err_return;
+ }
+
+ return 0;
+
+err_return:
+ clk_disable_unprepare(priv->clk);
+ return ret;
+}
+
+static int __exit asm9260_rtc_remove(struct platform_device *pdev)
+{
+ struct asm9260_rtc_priv *priv = platform_get_drvdata(pdev);
+
+ /* Disable alarm matching */
+ iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
+ clk_disable_unprepare(priv->clk);
+ return 0;
+}
+
+static const struct of_device_id asm9260_dt_ids[] = {
+ { .compatible = "alphascale,asm9260-rtc", },
+ {}
+};
+
+static struct platform_driver asm9260_rtc_driver = {
+ .probe = asm9260_rtc_probe,
+ .remove = asm9260_rtc_remove,
+ .driver = {
+ .name = "asm9260-rtc",
+ .owner = THIS_MODULE,
+ .of_match_table = asm9260_dt_ids,
+ },
+};
+
+module_platform_driver(asm9260_rtc_driver);
+
+MODULE_AUTHOR("Oleksij Rempel <linux@rempel-privat.de>");
+MODULE_DESCRIPTION("Alphascale asm9260 SoC Realtime Clock Driver (RTC)");
+MODULE_LICENSE("GPL");
--
2.5.0
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 1/2] rtc: add rtc-asm9260 driver
@ 2016-01-29 8:40 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-01-29 8:40 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: Oleksij Rempel
Add support for RTC controller found on Alphascale asm9260
SoC.
Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
---
drivers/rtc/Kconfig | 10 ++
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-asm9260.c | 391 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 402 insertions(+)
create mode 100644 drivers/rtc/rtc-asm9260.c
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 376322f..733b6aa 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1144,6 +1144,16 @@ config RTC_DRV_ZYNQMP
comment "on-CPU RTC drivers"
+config RTC_DRV_ASM9260
+ tristate "Alphascale asm9260 RTC"
+ depends on MACH_ASM9260
+ help
+ If you say yes here you get support for the RTC on the
+ Alphascale asm9260 SoC.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-asm9260.
+
config RTC_DRV_DAVINCI
tristate "TI DaVinci RTC"
depends on ARCH_DAVINCI_DM365
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 62d61b2..f4d841b 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_RTC_DRV_ABB5ZES3) += rtc-ab-b5ze-s3.o
obj-$(CONFIG_RTC_DRV_ABX80X) += rtc-abx80x.o
obj-$(CONFIG_RTC_DRV_ARMADA38X) += rtc-armada38x.o
obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o
+obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o
obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o
obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
diff --git a/drivers/rtc/rtc-asm9260.c b/drivers/rtc/rtc-asm9260.c
new file mode 100644
index 0000000..0287ae9
--- /dev/null
+++ b/drivers/rtc/rtc-asm9260.c
@@ -0,0 +1,391 @@
+/*
+ * Copyright (C) 2014 Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ */
+
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+
+/* Miscellaneous registers */
+/* Interrupt Location Register */
+#define HW_ILR 0x00
+#define BM_RTCALF BIT(1)
+#define BM_RTCCIF BIT(0)
+
+/* Clock Control Register */
+#define HW_CCR 0x08
+/* Calibration counter disable */
+#define BM_CCALOFF BIT(4)
+/* Reset internal oscillator divider */
+#define BM_CTCRST BIT(1)
+/* Clock Enable */
+#define BM_CLKEN BIT(0)
+
+/* Counter Increment Interrupt Register */
+#define HW_CIIR 0x0C
+#define BM_CIIR_IMYEAR BIT(7)
+#define BM_CIIR_IMMON BIT(6)
+#define BM_CIIR_IMDOY BIT(5)
+#define BM_CIIR_IMDOW BIT(4)
+#define BM_CIIR_IMDOM BIT(3)
+#define BM_CIIR_IMHOUR BIT(2)
+#define BM_CIIR_IMMIN BIT(1)
+#define BM_CIIR_IMSEC BIT(0)
+
+/* Alarm Mask Register */
+#define HW_AMR 0x10
+#define BM_AMR_IMYEAR BIT(7)
+#define BM_AMR_IMMON BIT(6)
+#define BM_AMR_IMDOY BIT(5)
+#define BM_AMR_IMDOW BIT(4)
+#define BM_AMR_IMDOM BIT(3)
+#define BM_AMR_IMHOUR BIT(2)
+#define BM_AMR_IMMIN BIT(1)
+#define BM_AMR_IMSEC BIT(0)
+#define BM_AMR_OFF 0xff
+
+/* Consolidated time registers */
+#define HW_CTIME0 0x14
+#define BM_CTIME0_DOW_S 24
+#define BM_CTIME0_DOW_M 0x7
+#define BM_CTIME0_HOUR_S 16
+#define BM_CTIME0_HOUR_M 0x1f
+#define BM_CTIME0_MIN_S 8
+#define BM_CTIME0_MIN_M 0x3f
+#define BM_CTIME0_SEC_S 0
+#define BM_CTIME0_SEC_M 0x3f
+
+#define HW_CTIME1 0x18
+#define BM_CTIME1_YEAR_S 16
+#define BM_CTIME1_YEAR_M 0xfff
+#define BM_CTIME1_MON_S 8
+#define BM_CTIME1_MON_M 0xf
+#define BM_CTIME1_DOM_S 0
+#define BM_CTIME1_DOM_M 0x1f
+
+#define HW_CTIME2 0x1C
+#define BM_CTIME2_DOY_S 0
+#define BM_CTIME2_DOY_M 0xfff
+
+/* Time counter registers */
+#define HW_SEC 0x20
+#define HW_MIN 0x24
+#define HW_HOUR 0x28
+#define HW_DOM 0x2C
+#define HW_DOW 0x30
+#define HW_DOY 0x34
+#define HW_MONTH 0x38
+#define HW_YEAR 0x3C
+
+#define HW_CALIBRATION 0x40
+#define BM_CALDIR_BACK BIT(17)
+#define BM_CALVAL_M 0x1ffff
+
+/* General purpose registers */
+#define HW_GPREG0 0x44
+#define HW_GPREG1 0x48
+#define HW_GPREG2 0x4C
+#define HW_GPREG3 0x50
+#define HW_GPREG4 0x54
+
+/* RTC Auxiliary control register */
+#define HW_RTC_AUX 0x5C
+/*
+ * RTC Oscillator Fail detect flag.
+ * Read: this bit is set if the RTC oscillator stops, and when RTC power is
+ * first turned on. An interrupt will occur when this bit is set, the
+ * RTC_OSCFEN bit in RTC_AUXEN is a 1, and the RTC interrupt is enabled
+ * in the NVIC.
+ * Write: writing a 1 to this bit clears the flag.
+ */
+#define BM_RTC_OSCF BIT(4)
+/* RTC Auxiliary Enable register */
+#define HW_RTC_AUXEN 0x58
+/* Oscillator Fail Detect interrupt enable. */
+#define BM_RTC_OSCFEN BIT(4)
+
+/* Alarm register group */
+#define HW_ALSEC 0x60
+#define HW_ALMIN 0x64
+#define HW_ALHOUR 0x68
+#define HW_ALDOM 0x6C
+#define HW_ALDOW 0x70
+#define HW_ALDOY 0x74
+#define HW_ALMON 0x78
+#define HW_ALYEAR 0x7C
+
+struct asm9260_rtc_priv {
+ struct device *dev;
+ void __iomem *iobase;
+ struct rtc_device *rtc;
+ struct clk *clk;
+ /* io lock */
+ spinlock_t lock;
+};
+
+static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
+{
+ struct asm9260_rtc_priv *priv = dev_id;
+ u32 isr;
+ unsigned long events = 0;
+
+ isr = ioread32(priv->iobase + HW_CIIR);
+ if (!isr)
+ return IRQ_NONE;
+
+ iowrite32(0, priv->iobase + HW_CIIR);
+
+ events |= RTC_AF | RTC_IRQF;
+
+ rtc_update_irq(priv->rtc, 1, events);
+
+ return IRQ_HANDLED;
+}
+
+static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ u32 ctime0, ctime1, ctime2;
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ ctime0 = ioread32(priv->iobase + HW_CTIME0);
+ ctime1 = ioread32(priv->iobase + HW_CTIME1);
+ ctime2 = ioread32(priv->iobase + HW_CTIME2);
+
+ if (ctime1 != ioread32(priv->iobase + HW_CTIME1)) {
+ /*
+ * woops, counter flipped right now. Now we are safe
+ * to reread.
+ */
+ ctime0 = ioread32(priv->iobase + HW_CTIME0);
+ ctime1 = ioread32(priv->iobase + HW_CTIME1);
+ ctime2 = ioread32(priv->iobase + HW_CTIME2);
+ }
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
+ tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
+ tm->tm_hour = (ctime0 >> BM_CTIME0_HOUR_S) & BM_CTIME0_HOUR_M;
+ tm->tm_wday = (ctime0 >> BM_CTIME0_DOW_S) & BM_CTIME0_DOW_M;
+
+ tm->tm_mday = (ctime1 >> BM_CTIME1_DOM_S) & BM_CTIME1_DOM_M;
+ tm->tm_mon = (ctime1 >> BM_CTIME1_MON_S) & BM_CTIME1_MON_M;
+ tm->tm_year = (ctime1 >> BM_CTIME1_YEAR_S) & BM_CTIME1_YEAR_M;
+
+ tm->tm_yday = (ctime2 >> BM_CTIME2_DOY_S) & BM_CTIME2_DOY_M;
+
+ return 0;
+}
+
+static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ /*
+ * make sure SEC counter will not flip other counter on write time,
+ * real value will be written at the enf of sequence.
+ */
+ iowrite32(0, priv->iobase + HW_SEC);
+
+ iowrite32(tm->tm_year, priv->iobase + HW_YEAR);
+ iowrite32(tm->tm_mon, priv->iobase + HW_MONTH);
+ iowrite32(tm->tm_mday, priv->iobase + HW_DOM);
+ iowrite32(tm->tm_wday, priv->iobase + HW_DOW);
+ iowrite32(tm->tm_yday, priv->iobase + HW_DOY);
+ iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
+ iowrite32(tm->tm_min, priv->iobase + HW_MIN);
+ iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return 0;
+}
+
+static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ alrm->time.tm_year = ioread32(priv->iobase + HW_ALYEAR);
+ alrm->time.tm_mon = ioread32(priv->iobase + HW_ALMON);
+ alrm->time.tm_mday = ioread32(priv->iobase + HW_ALDOM);
+ alrm->time.tm_wday = ioread32(priv->iobase + HW_ALDOW);
+ alrm->time.tm_yday = ioread32(priv->iobase + HW_ALDOY);
+ alrm->time.tm_hour = ioread32(priv->iobase + HW_ALHOUR);
+ alrm->time.tm_min = ioread32(priv->iobase + HW_ALMIN);
+ alrm->time.tm_sec = ioread32(priv->iobase + HW_ALSEC);
+
+ alrm->enabled = ioread32(priv->iobase + HW_AMR) ? 1 : 0;
+ alrm->pending = ioread32(priv->iobase + HW_CIIR) ? 1 : 0;
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return rtc_valid_tm(&alrm->time);
+}
+
+static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ iowrite32(alrm->time.tm_year, priv->iobase + HW_ALYEAR);
+ iowrite32(alrm->time.tm_mon, priv->iobase + HW_ALMON);
+ iowrite32(alrm->time.tm_mday, priv->iobase + HW_ALDOM);
+ iowrite32(alrm->time.tm_wday, priv->iobase + HW_ALDOW);
+ iowrite32(alrm->time.tm_yday, priv->iobase + HW_ALDOY);
+ iowrite32(alrm->time.tm_hour, priv->iobase + HW_ALHOUR);
+ iowrite32(alrm->time.tm_min, priv->iobase + HW_ALMIN);
+ iowrite32(alrm->time.tm_sec, priv->iobase + HW_ALSEC);
+
+ iowrite32(alrm->enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return 0;
+}
+
+static int asm9260_alarm_irq_enable(struct device *dev, unsigned int enabled)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+
+ iowrite32(enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
+ return 0;
+}
+
+static const struct rtc_class_ops asm9260_rtc_ops = {
+ .read_time = asm9260_rtc_read_time,
+ .set_time = asm9260_rtc_set_time,
+ .read_alarm = asm9260_rtc_read_alarm,
+ .set_alarm = asm9260_rtc_set_alarm,
+ .alarm_irq_enable = asm9260_alarm_irq_enable,
+};
+
+static int __init asm9260_rtc_probe(struct platform_device *pdev)
+{
+ struct asm9260_rtc_priv *priv;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ int irq_alarm, ret;
+ s32 calibvalue;
+ u32 ccr, cal;
+
+ priv = devm_kzalloc(dev, sizeof(struct asm9260_rtc_priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->dev = &pdev->dev;
+ platform_set_drvdata(pdev, priv);
+
+ irq_alarm = platform_get_irq(pdev, 0);
+ if (irq_alarm < 0) {
+ dev_err(dev, "No alarm IRQ resource defined\n");
+ return irq_alarm;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ priv->iobase = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->iobase))
+ return PTR_ERR(priv->iobase);
+
+ priv->clk = devm_clk_get(dev, "ahb");
+ ret = clk_prepare_enable(priv->clk);
+ if (ret) {
+ dev_err(dev, "Failed to enable clk!\n");
+ return ret;
+ }
+
+ ccr = ioread32(priv->iobase + HW_CCR);
+ /* if dev is not enabled, reset it */
+ if ((ccr & (BM_CLKEN | BM_CTCRST)) != BM_CLKEN) {
+ iowrite32(BM_CTCRST, priv->iobase + HW_CCR);
+ ccr = 0;
+ }
+
+ ret = of_property_read_s32(pdev->dev.of_node, "calibration",
+ &calibvalue);
+ if (ret) {
+ ccr |= BM_CCALOFF;
+ cal = 0;
+ } else {
+ ccr &= ~BM_CCALOFF;
+
+ cal = abs(calibvalue);
+ if (cal > BM_CALVAL_M) {
+ dev_err(dev, "calibration value is to big: %d\n",
+ cal);
+ goto err_return;
+ }
+
+ if (calibvalue < 0)
+ cal |= BM_CALDIR_BACK;
+ }
+
+ iowrite32(BM_CLKEN | ccr, priv->iobase + HW_CCR);
+ iowrite32(cal, priv->iobase + HW_CALIBRATION);
+ iowrite32(0, priv->iobase + HW_CIIR);
+ iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
+
+ priv->rtc = devm_rtc_device_register(dev, dev_name(dev),
+ &asm9260_rtc_ops, THIS_MODULE);
+ if (IS_ERR(priv->rtc)) {
+ ret = PTR_ERR(priv->rtc);
+ dev_err(dev, "Failed to register RTC device: %d\n", ret);
+ goto err_return;
+ }
+
+ ret = devm_request_threaded_irq(dev, irq_alarm, NULL,
+ asm9260_rtc_irq, IRQF_ONESHOT,
+ dev_name(dev), priv);
+ if (ret < 0) {
+ dev_err(dev, "can't get irq %i, err %d\n",
+ irq_alarm, ret);
+ goto err_return;
+ }
+
+ return 0;
+
+err_return:
+ clk_disable_unprepare(priv->clk);
+ return ret;
+}
+
+static int __exit asm9260_rtc_remove(struct platform_device *pdev)
+{
+ struct asm9260_rtc_priv *priv = platform_get_drvdata(pdev);
+
+ /* Disable alarm matching */
+ iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
+ clk_disable_unprepare(priv->clk);
+ return 0;
+}
+
+static const struct of_device_id asm9260_dt_ids[] = {
+ { .compatible = "alphascale,asm9260-rtc", },
+ {}
+};
+
+static struct platform_driver asm9260_rtc_driver = {
+ .probe = asm9260_rtc_probe,
+ .remove = asm9260_rtc_remove,
+ .driver = {
+ .name = "asm9260-rtc",
+ .owner = THIS_MODULE,
+ .of_match_table = asm9260_dt_ids,
+ },
+};
+
+module_platform_driver(asm9260_rtc_driver);
+
+MODULE_AUTHOR("Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>");
+MODULE_DESCRIPTION("Alphascale asm9260 SoC Realtime Clock Driver (RTC)");
+MODULE_LICENSE("GPL");
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [rtc-linux] [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-01-29 8:40 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-01-29 8:40 UTC (permalink / raw)
To: devicetree, robh+dt, a.zummo, alexandre.belloni, rtc-linux; +Cc: Oleksij Rempel
Document Alphascale asm9260 RTC bindings
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
.../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
new file mode 100644
index 0000000..2c0ff3c
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
@@ -0,0 +1,25 @@
+* Alphascale asm9260 SoC Real Time Clock
+
+Required properties:
+- compatible: Should be "alphascale,asm9260-rtc"
+- reg: Physical base address of the controller and length
+ of memory mapped region.
+- interrupts: IRQ line for the RTC.
+- clocks: Reference to the clock entry.
+- clock-names: should contain:
+ * "ahb" for the SoC RTC clock
+
+Optional:
+- calibration: calibration value for 1 sec period.
+ Max value for forward calibration is 0x1ffff (131071),
+ Min value for backward calibration is 0xfffe0001 (-131071).
+
+Example:
+rtc0: rtc@800a0000 {
+ compatible = "alphascale,asm9260-rtc";
+ reg = <0x800a0000 0x100>;
+ clocks = <&acc CLKID_AHB_RTC>;
+ clock-names = "ahb";
+ interrupts = <2>;
+ calibration = <0x129c>;
+};
--
2.5.0
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-01-29 8:40 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-01-29 8:40 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: Oleksij Rempel
Document Alphascale asm9260 RTC bindings
Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
---
.../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
1 file changed, 25 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
new file mode 100644
index 0000000..2c0ff3c
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
@@ -0,0 +1,25 @@
+* Alphascale asm9260 SoC Real Time Clock
+
+Required properties:
+- compatible: Should be "alphascale,asm9260-rtc"
+- reg: Physical base address of the controller and length
+ of memory mapped region.
+- interrupts: IRQ line for the RTC.
+- clocks: Reference to the clock entry.
+- clock-names: should contain:
+ * "ahb" for the SoC RTC clock
+
+Optional:
+- calibration: calibration value for 1 sec period.
+ Max value for forward calibration is 0x1ffff (131071),
+ Min value for backward calibration is 0xfffe0001 (-131071).
+
+Example:
+rtc0: rtc@800a0000 {
+ compatible = "alphascale,asm9260-rtc";
+ reg = <0x800a0000 0x100>;
+ clocks = <&acc CLKID_AHB_RTC>;
+ clock-names = "ahb";
+ interrupts = <2>;
+ calibration = <0x129c>;
+};
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-01 15:27 ` Rob Herring
0 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2016-02-01 15:27 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: devicetree, a.zummo, alexandre.belloni, rtc-linux
On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
> Document Alphascale asm9260 RTC bindings
>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
> .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>
> diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> new file mode 100644
> index 0000000..2c0ff3c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> @@ -0,0 +1,25 @@
> +* Alphascale asm9260 SoC Real Time Clock
> +
> +Required properties:
> +- compatible: Should be "alphascale,asm9260-rtc"
> +- reg: Physical base address of the controller and length
> + of memory mapped region.
> +- interrupts: IRQ line for the RTC.
> +- clocks: Reference to the clock entry.
> +- clock-names: should contain:
> + * "ahb" for the SoC RTC clock
> +
> +Optional:
> +- calibration: calibration value for 1 sec period.
> + Max value for forward calibration is 0x1ffff (131071),
> + Min value for backward calibration is 0xfffe0001 (-131071).
This should be prefixed with 'alphascale,'
How is this value determined?
Rob
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-01 15:27 ` Rob Herring
0 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2016-02-01 15:27 UTC (permalink / raw)
To: Oleksij Rempel
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
> Document Alphascale asm9260 RTC bindings
>
> Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
> ---
> .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>
> diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> new file mode 100644
> index 0000000..2c0ff3c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> @@ -0,0 +1,25 @@
> +* Alphascale asm9260 SoC Real Time Clock
> +
> +Required properties:
> +- compatible: Should be "alphascale,asm9260-rtc"
> +- reg: Physical base address of the controller and length
> + of memory mapped region.
> +- interrupts: IRQ line for the RTC.
> +- clocks: Reference to the clock entry.
> +- clock-names: should contain:
> + * "ahb" for the SoC RTC clock
> +
> +Optional:
> +- calibration: calibration value for 1 sec period.
> + Max value for forward calibration is 0x1ffff (131071),
> + Min value for backward calibration is 0xfffe0001 (-131071).
This should be prefixed with 'alphascale,'
How is this value determined?
Rob
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
2016-02-01 15:27 ` Rob Herring
@ 2016-02-01 15:55 ` Alexandre Belloni
-1 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2016-02-01 15:55 UTC (permalink / raw)
To: Rob Herring; +Cc: Oleksij Rempel, devicetree, a.zummo, rtc-linux
On 01/02/2016 at 09:27:50 -0600, Rob Herring wrote :
> On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
> > Document Alphascale asm9260 RTC bindings
> >
> > Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> > ---
> > .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> >
> > diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> > new file mode 100644
> > index 0000000..2c0ff3c
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> > @@ -0,0 +1,25 @@
> > +* Alphascale asm9260 SoC Real Time Clock
> > +
> > +Required properties:
> > +- compatible: Should be "alphascale,asm9260-rtc"
> > +- reg: Physical base address of the controller and length
> > + of memory mapped region.
> > +- interrupts: IRQ line for the RTC.
> > +- clocks: Reference to the clock entry.
> > +- clock-names: should contain:
> > + * "ahb" for the SoC RTC clock
> > +
> > +Optional:
> > +- calibration: calibration value for 1 sec period.
> > + Max value for forward calibration is 0x1ffff (131071),
> > + Min value for backward calibration is 0xfffe0001 (-131071).
>
> This should be prefixed with 'alphascale,'
>
> How is this value determined?
>
I think this should stay in userspace, see that series:
https://groups.google.com/forum/#!topic/rtc-linux/HGQqiHnMiuw
It quite often depends on environmental things like temperature so it may be updated at runtime.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-01 15:55 ` Alexandre Belloni
0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2016-02-01 15:55 UTC (permalink / raw)
To: Rob Herring
Cc: Oleksij Rempel, devicetree-u79uwXL29TY76Z2rM5mHXA,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, rtc-linux-/JYPxA39Uh5TLH3MbocFFw
On 01/02/2016 at 09:27:50 -0600, Rob Herring wrote :
> On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
> > Document Alphascale asm9260 RTC bindings
> >
> > Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
> > ---
> > .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
> > 1 file changed, 25 insertions(+)
> > create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> >
> > diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> > new file mode 100644
> > index 0000000..2c0ff3c
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> > @@ -0,0 +1,25 @@
> > +* Alphascale asm9260 SoC Real Time Clock
> > +
> > +Required properties:
> > +- compatible: Should be "alphascale,asm9260-rtc"
> > +- reg: Physical base address of the controller and length
> > + of memory mapped region.
> > +- interrupts: IRQ line for the RTC.
> > +- clocks: Reference to the clock entry.
> > +- clock-names: should contain:
> > + * "ahb" for the SoC RTC clock
> > +
> > +Optional:
> > +- calibration: calibration value for 1 sec period.
> > + Max value for forward calibration is 0x1ffff (131071),
> > + Min value for backward calibration is 0xfffe0001 (-131071).
>
> This should be prefixed with 'alphascale,'
>
> How is this value determined?
>
I think this should stay in userspace, see that series:
https://groups.google.com/forum/#!topic/rtc-linux/HGQqiHnMiuw
It quite often depends on environmental things like temperature so it may be updated at runtime.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH 1/2] rtc: add rtc-asm9260 driver
@ 2016-02-01 16:05 ` Alexandre Belloni
0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2016-02-01 16:05 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: devicetree, robh+dt, a.zummo, rtc-linux
On 29/01/2016 at 09:40:01 +0100, Oleksij Rempel wrote :
> +static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
> +{
> + struct asm9260_rtc_priv *priv = dev_id;
> + u32 isr;
> + unsigned long events = 0;
> +
> + isr = ioread32(priv->iobase + HW_CIIR);
> + if (!isr)
> + return IRQ_NONE;
> +
> + iowrite32(0, priv->iobase + HW_CIIR);
> +
> + events |= RTC_AF | RTC_IRQF;
> +
> + rtc_update_irq(priv->rtc, 1, events);
> +
> + return IRQ_HANDLED;
> +}
> +
> +static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
> +{
> + struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
> + u32 ctime0, ctime1, ctime2;
> + unsigned long irq_flags;
> +
It would be nice to actually use BM_RTC_OSCF and return -EINVAL if it is
set.
> + spin_lock_irqsave(&priv->lock, irq_flags);
> + ctime0 = ioread32(priv->iobase + HW_CTIME0);
> + ctime1 = ioread32(priv->iobase + HW_CTIME1);
> + ctime2 = ioread32(priv->iobase + HW_CTIME2);
> +
> + if (ctime1 != ioread32(priv->iobase + HW_CTIME1)) {
> + /*
> + * woops, counter flipped right now. Now we are safe
> + * to reread.
> + */
> + ctime0 = ioread32(priv->iobase + HW_CTIME0);
> + ctime1 = ioread32(priv->iobase + HW_CTIME1);
> + ctime2 = ioread32(priv->iobase + HW_CTIME2);
> + }
> + spin_unlock_irqrestore(&priv->lock, irq_flags);
> +
> + tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
> + tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
> + tm->tm_hour = (ctime0 >> BM_CTIME0_HOUR_S) & BM_CTIME0_HOUR_M;
> + tm->tm_wday = (ctime0 >> BM_CTIME0_DOW_S) & BM_CTIME0_DOW_M;
> +
> + tm->tm_mday = (ctime1 >> BM_CTIME1_DOM_S) & BM_CTIME1_DOM_M;
> + tm->tm_mon = (ctime1 >> BM_CTIME1_MON_S) & BM_CTIME1_MON_M;
> + tm->tm_year = (ctime1 >> BM_CTIME1_YEAR_S) & BM_CTIME1_YEAR_M;
> +
> + tm->tm_yday = (ctime2 >> BM_CTIME2_DOY_S) & BM_CTIME2_DOY_M;
> +
> + return 0;
> +}
> +
> +static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
> +{
> + struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
> + unsigned long irq_flags;
> +
> + spin_lock_irqsave(&priv->lock, irq_flags);
> + /*
> + * make sure SEC counter will not flip other counter on write time,
> + * real value will be written at the enf of sequence.
> + */
> + iowrite32(0, priv->iobase + HW_SEC);
> +
> + iowrite32(tm->tm_year, priv->iobase + HW_YEAR);
> + iowrite32(tm->tm_mon, priv->iobase + HW_MONTH);
> + iowrite32(tm->tm_mday, priv->iobase + HW_DOM);
> + iowrite32(tm->tm_wday, priv->iobase + HW_DOW);
> + iowrite32(tm->tm_yday, priv->iobase + HW_DOY);
> + iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
> + iowrite32(tm->tm_min, priv->iobase + HW_MIN);
> + iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
That would be a good time to reset BM_RTC_OSCF. Maybe it can also be
useful to enable the interrupt but there isn't much more to do than
print an error message.
> + spin_unlock_irqrestore(&priv->lock, irq_flags);
> +
> + return 0;
> +}
> +
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/2] rtc: add rtc-asm9260 driver
@ 2016-02-01 16:05 ` Alexandre Belloni
0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2016-02-01 16:05 UTC (permalink / raw)
To: Oleksij Rempel
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
On 29/01/2016 at 09:40:01 +0100, Oleksij Rempel wrote :
> +static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
> +{
> + struct asm9260_rtc_priv *priv = dev_id;
> + u32 isr;
> + unsigned long events = 0;
> +
> + isr = ioread32(priv->iobase + HW_CIIR);
> + if (!isr)
> + return IRQ_NONE;
> +
> + iowrite32(0, priv->iobase + HW_CIIR);
> +
> + events |= RTC_AF | RTC_IRQF;
> +
> + rtc_update_irq(priv->rtc, 1, events);
> +
> + return IRQ_HANDLED;
> +}
> +
> +static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
> +{
> + struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
> + u32 ctime0, ctime1, ctime2;
> + unsigned long irq_flags;
> +
It would be nice to actually use BM_RTC_OSCF and return -EINVAL if it is
set.
> + spin_lock_irqsave(&priv->lock, irq_flags);
> + ctime0 = ioread32(priv->iobase + HW_CTIME0);
> + ctime1 = ioread32(priv->iobase + HW_CTIME1);
> + ctime2 = ioread32(priv->iobase + HW_CTIME2);
> +
> + if (ctime1 != ioread32(priv->iobase + HW_CTIME1)) {
> + /*
> + * woops, counter flipped right now. Now we are safe
> + * to reread.
> + */
> + ctime0 = ioread32(priv->iobase + HW_CTIME0);
> + ctime1 = ioread32(priv->iobase + HW_CTIME1);
> + ctime2 = ioread32(priv->iobase + HW_CTIME2);
> + }
> + spin_unlock_irqrestore(&priv->lock, irq_flags);
> +
> + tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
> + tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
> + tm->tm_hour = (ctime0 >> BM_CTIME0_HOUR_S) & BM_CTIME0_HOUR_M;
> + tm->tm_wday = (ctime0 >> BM_CTIME0_DOW_S) & BM_CTIME0_DOW_M;
> +
> + tm->tm_mday = (ctime1 >> BM_CTIME1_DOM_S) & BM_CTIME1_DOM_M;
> + tm->tm_mon = (ctime1 >> BM_CTIME1_MON_S) & BM_CTIME1_MON_M;
> + tm->tm_year = (ctime1 >> BM_CTIME1_YEAR_S) & BM_CTIME1_YEAR_M;
> +
> + tm->tm_yday = (ctime2 >> BM_CTIME2_DOY_S) & BM_CTIME2_DOY_M;
> +
> + return 0;
> +}
> +
> +static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
> +{
> + struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
> + unsigned long irq_flags;
> +
> + spin_lock_irqsave(&priv->lock, irq_flags);
> + /*
> + * make sure SEC counter will not flip other counter on write time,
> + * real value will be written at the enf of sequence.
> + */
> + iowrite32(0, priv->iobase + HW_SEC);
> +
> + iowrite32(tm->tm_year, priv->iobase + HW_YEAR);
> + iowrite32(tm->tm_mon, priv->iobase + HW_MONTH);
> + iowrite32(tm->tm_mday, priv->iobase + HW_DOM);
> + iowrite32(tm->tm_wday, priv->iobase + HW_DOW);
> + iowrite32(tm->tm_yday, priv->iobase + HW_DOY);
> + iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
> + iowrite32(tm->tm_min, priv->iobase + HW_MIN);
> + iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
That would be a good time to reset BM_RTC_OSCF. Maybe it can also be
useful to enable the interrupt but there isn't much more to do than
print an error message.
> + spin_unlock_irqrestore(&priv->lock, irq_flags);
> +
> + return 0;
> +}
> +
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH 1/2] rtc: add rtc-asm9260 driver
@ 2016-02-02 8:24 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 8:24 UTC (permalink / raw)
To: Alexandre Belloni; +Cc: devicetree, robh+dt, a.zummo, rtc-linux
[-- Attachment #1: Type: text/plain, Size: 3944 bytes --]
Am 01.02.2016 um 17:05 schrieb Alexandre Belloni:
> On 29/01/2016 at 09:40:01 +0100, Oleksij Rempel wrote :
>> +static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
>> +{
>> + struct asm9260_rtc_priv *priv = dev_id;
>> + u32 isr;
>> + unsigned long events = 0;
>> +
>> + isr = ioread32(priv->iobase + HW_CIIR);
>> + if (!isr)
>> + return IRQ_NONE;
>> +
>> + iowrite32(0, priv->iobase + HW_CIIR);
>> +
>> + events |= RTC_AF | RTC_IRQF;
>> +
>> + rtc_update_irq(priv->rtc, 1, events);
>> +
>> + return IRQ_HANDLED;
>> +}
>> +
>> +static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
>> +{
>> + struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
>> + u32 ctime0, ctime1, ctime2;
>> + unsigned long irq_flags;
>> +
>
> It would be nice to actually use BM_RTC_OSCF and return -EINVAL if it is
> set.
Hm... this register was described in reference driver, but not in the
documentation. Now i did some testing but i can't confirm that it is
working. BM_RTC_OSCF is never set, even after completely reseted clock
removed battery or shortened XTAL.
So, i will remove this register from the driver.
>> + spin_lock_irqsave(&priv->lock, irq_flags);
>> + ctime0 = ioread32(priv->iobase + HW_CTIME0);
>> + ctime1 = ioread32(priv->iobase + HW_CTIME1);
>> + ctime2 = ioread32(priv->iobase + HW_CTIME2);
>> +
>> + if (ctime1 != ioread32(priv->iobase + HW_CTIME1)) {
>> + /*
>> + * woops, counter flipped right now. Now we are safe
>> + * to reread.
>> + */
>> + ctime0 = ioread32(priv->iobase + HW_CTIME0);
>> + ctime1 = ioread32(priv->iobase + HW_CTIME1);
>> + ctime2 = ioread32(priv->iobase + HW_CTIME2);
>> + }
>> + spin_unlock_irqrestore(&priv->lock, irq_flags);
>> +
>> + tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
>> + tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
>> + tm->tm_hour = (ctime0 >> BM_CTIME0_HOUR_S) & BM_CTIME0_HOUR_M;
>> + tm->tm_wday = (ctime0 >> BM_CTIME0_DOW_S) & BM_CTIME0_DOW_M;
>> +
>> + tm->tm_mday = (ctime1 >> BM_CTIME1_DOM_S) & BM_CTIME1_DOM_M;
>> + tm->tm_mon = (ctime1 >> BM_CTIME1_MON_S) & BM_CTIME1_MON_M;
>> + tm->tm_year = (ctime1 >> BM_CTIME1_YEAR_S) & BM_CTIME1_YEAR_M;
>> +
>> + tm->tm_yday = (ctime2 >> BM_CTIME2_DOY_S) & BM_CTIME2_DOY_M;
>> +
>> + return 0;
>> +}
>> +
>> +static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
>> +{
>> + struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
>> + unsigned long irq_flags;
>> +
>> + spin_lock_irqsave(&priv->lock, irq_flags);
>> + /*
>> + * make sure SEC counter will not flip other counter on write time,
>> + * real value will be written at the enf of sequence.
>> + */
>> + iowrite32(0, priv->iobase + HW_SEC);
>> +
>> + iowrite32(tm->tm_year, priv->iobase + HW_YEAR);
>> + iowrite32(tm->tm_mon, priv->iobase + HW_MONTH);
>> + iowrite32(tm->tm_mday, priv->iobase + HW_DOM);
>> + iowrite32(tm->tm_wday, priv->iobase + HW_DOW);
>> + iowrite32(tm->tm_yday, priv->iobase + HW_DOY);
>> + iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
>> + iowrite32(tm->tm_min, priv->iobase + HW_MIN);
>> + iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
>
> That would be a good time to reset BM_RTC_OSCF. Maybe it can also be
> useful to enable the interrupt but there isn't much more to do than
> print an error message.
>
>> + spin_unlock_irqrestore(&priv->lock, irq_flags);
>> +
>> + return 0;
>> +}
>> +
>
Thank you for review :)
--
Regards,
Oleksij
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 1/2] rtc: add rtc-asm9260 driver
@ 2016-02-02 8:24 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 8:24 UTC (permalink / raw)
To: Alexandre Belloni
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1: Type: text/plain, Size: 3531 bytes --]
Am 01.02.2016 um 17:05 schrieb Alexandre Belloni:
> On 29/01/2016 at 09:40:01 +0100, Oleksij Rempel wrote :
>> +static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
>> +{
>> + struct asm9260_rtc_priv *priv = dev_id;
>> + u32 isr;
>> + unsigned long events = 0;
>> +
>> + isr = ioread32(priv->iobase + HW_CIIR);
>> + if (!isr)
>> + return IRQ_NONE;
>> +
>> + iowrite32(0, priv->iobase + HW_CIIR);
>> +
>> + events |= RTC_AF | RTC_IRQF;
>> +
>> + rtc_update_irq(priv->rtc, 1, events);
>> +
>> + return IRQ_HANDLED;
>> +}
>> +
>> +static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
>> +{
>> + struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
>> + u32 ctime0, ctime1, ctime2;
>> + unsigned long irq_flags;
>> +
>
> It would be nice to actually use BM_RTC_OSCF and return -EINVAL if it is
> set.
Hm... this register was described in reference driver, but not in the
documentation. Now i did some testing but i can't confirm that it is
working. BM_RTC_OSCF is never set, even after completely reseted clock
removed battery or shortened XTAL.
So, i will remove this register from the driver.
>> + spin_lock_irqsave(&priv->lock, irq_flags);
>> + ctime0 = ioread32(priv->iobase + HW_CTIME0);
>> + ctime1 = ioread32(priv->iobase + HW_CTIME1);
>> + ctime2 = ioread32(priv->iobase + HW_CTIME2);
>> +
>> + if (ctime1 != ioread32(priv->iobase + HW_CTIME1)) {
>> + /*
>> + * woops, counter flipped right now. Now we are safe
>> + * to reread.
>> + */
>> + ctime0 = ioread32(priv->iobase + HW_CTIME0);
>> + ctime1 = ioread32(priv->iobase + HW_CTIME1);
>> + ctime2 = ioread32(priv->iobase + HW_CTIME2);
>> + }
>> + spin_unlock_irqrestore(&priv->lock, irq_flags);
>> +
>> + tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
>> + tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
>> + tm->tm_hour = (ctime0 >> BM_CTIME0_HOUR_S) & BM_CTIME0_HOUR_M;
>> + tm->tm_wday = (ctime0 >> BM_CTIME0_DOW_S) & BM_CTIME0_DOW_M;
>> +
>> + tm->tm_mday = (ctime1 >> BM_CTIME1_DOM_S) & BM_CTIME1_DOM_M;
>> + tm->tm_mon = (ctime1 >> BM_CTIME1_MON_S) & BM_CTIME1_MON_M;
>> + tm->tm_year = (ctime1 >> BM_CTIME1_YEAR_S) & BM_CTIME1_YEAR_M;
>> +
>> + tm->tm_yday = (ctime2 >> BM_CTIME2_DOY_S) & BM_CTIME2_DOY_M;
>> +
>> + return 0;
>> +}
>> +
>> +static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
>> +{
>> + struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
>> + unsigned long irq_flags;
>> +
>> + spin_lock_irqsave(&priv->lock, irq_flags);
>> + /*
>> + * make sure SEC counter will not flip other counter on write time,
>> + * real value will be written at the enf of sequence.
>> + */
>> + iowrite32(0, priv->iobase + HW_SEC);
>> +
>> + iowrite32(tm->tm_year, priv->iobase + HW_YEAR);
>> + iowrite32(tm->tm_mon, priv->iobase + HW_MONTH);
>> + iowrite32(tm->tm_mday, priv->iobase + HW_DOM);
>> + iowrite32(tm->tm_wday, priv->iobase + HW_DOW);
>> + iowrite32(tm->tm_yday, priv->iobase + HW_DOY);
>> + iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
>> + iowrite32(tm->tm_min, priv->iobase + HW_MIN);
>> + iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
>
> That would be a good time to reset BM_RTC_OSCF. Maybe it can also be
> useful to enable the interrupt but there isn't much more to do than
> print an error message.
>
>> + spin_unlock_irqrestore(&priv->lock, irq_flags);
>> +
>> + return 0;
>> +}
>> +
>
Thank you for review :)
--
Regards,
Oleksij
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
2016-02-01 15:27 ` Rob Herring
@ 2016-02-02 8:42 ` Oleksij Rempel
-1 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 8:42 UTC (permalink / raw)
To: Rob Herring; +Cc: devicetree, a.zummo, alexandre.belloni, rtc-linux
[-- Attachment #1: Type: text/plain, Size: 2211 bytes --]
Am 01.02.2016 um 16:27 schrieb Rob Herring:
> On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
>> Document Alphascale asm9260 RTC bindings
>>
>> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
>> ---
>> .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
>> 1 file changed, 25 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>>
>> diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>> new file mode 100644
>> index 0000000..2c0ff3c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>> @@ -0,0 +1,25 @@
>> +* Alphascale asm9260 SoC Real Time Clock
>> +
>> +Required properties:
>> +- compatible: Should be "alphascale,asm9260-rtc"
>> +- reg: Physical base address of the controller and length
>> + of memory mapped region.
>> +- interrupts: IRQ line for the RTC.
>> +- clocks: Reference to the clock entry.
>> +- clock-names: should contain:
>> + * "ahb" for the SoC RTC clock
>> +
>> +Optional:
>> +- calibration: calibration value for 1 sec period.
>> + Max value for forward calibration is 0x1ffff (131071),
>> + Min value for backward calibration is 0xfffe0001 (-131071).
>
> This should be prefixed with 'alphascale,'
ok,
> How is this value determined?
To each second the counter value will be increased to decreased by
calibration value - if google translated it correctly from chinese :)
It is RAW value which will be written to register. Since DT compiler do
not support signed values i converted it to HEX.
--
Regards,
Oleksij
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 8:42 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 8:42 UTC (permalink / raw)
To: Rob Herring
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1: Type: text/plain, Size: 1764 bytes --]
Am 01.02.2016 um 16:27 schrieb Rob Herring:
> On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
>> Document Alphascale asm9260 RTC bindings
>>
>> Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
>> ---
>> .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
>> 1 file changed, 25 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>>
>> diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>> new file mode 100644
>> index 0000000..2c0ff3c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>> @@ -0,0 +1,25 @@
>> +* Alphascale asm9260 SoC Real Time Clock
>> +
>> +Required properties:
>> +- compatible: Should be "alphascale,asm9260-rtc"
>> +- reg: Physical base address of the controller and length
>> + of memory mapped region.
>> +- interrupts: IRQ line for the RTC.
>> +- clocks: Reference to the clock entry.
>> +- clock-names: should contain:
>> + * "ahb" for the SoC RTC clock
>> +
>> +Optional:
>> +- calibration: calibration value for 1 sec period.
>> + Max value for forward calibration is 0x1ffff (131071),
>> + Min value for backward calibration is 0xfffe0001 (-131071).
>
> This should be prefixed with 'alphascale,'
ok,
> How is this value determined?
To each second the counter value will be increased to decreased by
calibration value - if google translated it correctly from chinese :)
It is RAW value which will be written to register. Since DT compiler do
not support signed values i converted it to HEX.
--
Regards,
Oleksij
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 8:46 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 8:46 UTC (permalink / raw)
To: Alexandre Belloni, Rob Herring; +Cc: devicetree, a.zummo, rtc-linux
[-- Attachment #1: Type: text/plain, Size: 2408 bytes --]
Am 01.02.2016 um 16:55 schrieb Alexandre Belloni:
> On 01/02/2016 at 09:27:50 -0600, Rob Herring wrote :
>> On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
>>> Document Alphascale asm9260 RTC bindings
>>>
>>> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
>>> ---
>>> .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
>>> 1 file changed, 25 insertions(+)
>>> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>>>
>>> diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>>> new file mode 100644
>>> index 0000000..2c0ff3c
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>>> @@ -0,0 +1,25 @@
>>> +* Alphascale asm9260 SoC Real Time Clock
>>> +
>>> +Required properties:
>>> +- compatible: Should be "alphascale,asm9260-rtc"
>>> +- reg: Physical base address of the controller and length
>>> + of memory mapped region.
>>> +- interrupts: IRQ line for the RTC.
>>> +- clocks: Reference to the clock entry.
>>> +- clock-names: should contain:
>>> + * "ahb" for the SoC RTC clock
>>> +
>>> +Optional:
>>> +- calibration: calibration value for 1 sec period.
>>> + Max value for forward calibration is 0x1ffff (131071),
>>> + Min value for backward calibration is 0xfffe0001 (-131071).
>>
>> This should be prefixed with 'alphascale,'
>>
>> How is this value determined?
>>
>
> I think this should stay in userspace, see that series:
> https://groups.google.com/forum/#!topic/rtc-linux/HGQqiHnMiuw
>
> It quite often depends on environmental things like temperature so it may be updated at runtime.
>
I partially agree. IMO default configuration should work properly by
20C. My devkit provide terrible results without default offset.
--
Regards,
Oleksij
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 8:46 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 8:46 UTC (permalink / raw)
To: Alexandre Belloni, Rob Herring
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, rtc-linux-/JYPxA39Uh5TLH3MbocFFw
[-- Attachment #1: Type: text/plain, Size: 1964 bytes --]
Am 01.02.2016 um 16:55 schrieb Alexandre Belloni:
> On 01/02/2016 at 09:27:50 -0600, Rob Herring wrote :
>> On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
>>> Document Alphascale asm9260 RTC bindings
>>>
>>> Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
>>> ---
>>> .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
>>> 1 file changed, 25 insertions(+)
>>> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>>>
>>> diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>>> new file mode 100644
>>> index 0000000..2c0ff3c
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
>>> @@ -0,0 +1,25 @@
>>> +* Alphascale asm9260 SoC Real Time Clock
>>> +
>>> +Required properties:
>>> +- compatible: Should be "alphascale,asm9260-rtc"
>>> +- reg: Physical base address of the controller and length
>>> + of memory mapped region.
>>> +- interrupts: IRQ line for the RTC.
>>> +- clocks: Reference to the clock entry.
>>> +- clock-names: should contain:
>>> + * "ahb" for the SoC RTC clock
>>> +
>>> +Optional:
>>> +- calibration: calibration value for 1 sec period.
>>> + Max value for forward calibration is 0x1ffff (131071),
>>> + Min value for backward calibration is 0xfffe0001 (-131071).
>>
>> This should be prefixed with 'alphascale,'
>>
>> How is this value determined?
>>
>
> I think this should stay in userspace, see that series:
> https://groups.google.com/forum/#!topic/rtc-linux/HGQqiHnMiuw
>
> It quite often depends on environmental things like temperature so it may be updated at runtime.
>
I partially agree. IMO default configuration should work properly by
20C. My devkit provide terrible results without default offset.
--
Regards,
Oleksij
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 10:28 ` Alexandre Belloni
0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2016-02-02 10:28 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: Rob Herring, devicetree, a.zummo, rtc-linux
On 02/02/2016 at 09:46:02 +0100, Oleksij Rempel wrote :
> Am 01.02.2016 um 16:55 schrieb Alexandre Belloni:
> > On 01/02/2016 at 09:27:50 -0600, Rob Herring wrote :
> >> On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
> >>> Document Alphascale asm9260 RTC bindings
> >>>
> >>> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> >>> ---
> >>> .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
> >>> 1 file changed, 25 insertions(+)
> >>> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> >>>
> >>> diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> >>> new file mode 100644
> >>> index 0000000..2c0ff3c
> >>> --- /dev/null
> >>> +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> >>> @@ -0,0 +1,25 @@
> >>> +* Alphascale asm9260 SoC Real Time Clock
> >>> +
> >>> +Required properties:
> >>> +- compatible: Should be "alphascale,asm9260-rtc"
> >>> +- reg: Physical base address of the controller and length
> >>> + of memory mapped region.
> >>> +- interrupts: IRQ line for the RTC.
> >>> +- clocks: Reference to the clock entry.
> >>> +- clock-names: should contain:
> >>> + * "ahb" for the SoC RTC clock
> >>> +
> >>> +Optional:
> >>> +- calibration: calibration value for 1 sec period.
> >>> + Max value for forward calibration is 0x1ffff (131071),
> >>> + Min value for backward calibration is 0xfffe0001 (-131071).
> >>
> >> This should be prefixed with 'alphascale,'
> >>
> >> How is this value determined?
> >>
> >
> > I think this should stay in userspace, see that series:
> > https://groups.google.com/forum/#!topic/rtc-linux/HGQqiHnMiuw
> >
> > It quite often depends on environmental things like temperature so it may be updated at runtime.
> >
>
> I partially agree. IMO default configuration should work properly by
> 20C. My devkit provide terrible results without default offset.
>
I'm not against having a sane default. What I would do is set a default
hardcoded value from the driver at the time the RTC is reset (that is: it
has never been set yet) then let the user adjust that calibration
through sysfs.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 10:28 ` Alexandre Belloni
0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2016-02-02 10:28 UTC (permalink / raw)
To: Oleksij Rempel
Cc: Rob Herring, devicetree-u79uwXL29TY76Z2rM5mHXA,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ, rtc-linux-/JYPxA39Uh5TLH3MbocFFw
On 02/02/2016 at 09:46:02 +0100, Oleksij Rempel wrote :
> Am 01.02.2016 um 16:55 schrieb Alexandre Belloni:
> > On 01/02/2016 at 09:27:50 -0600, Rob Herring wrote :
> >> On Fri, Jan 29, 2016 at 09:40:02AM +0100, Oleksij Rempel wrote:
> >>> Document Alphascale asm9260 RTC bindings
> >>>
> >>> Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
> >>> ---
> >>> .../bindings/rtc/alphascale,asm9260-rtc.txt | 25 ++++++++++++++++++++++
> >>> 1 file changed, 25 insertions(+)
> >>> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> >>>
> >>> diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> >>> new file mode 100644
> >>> index 0000000..2c0ff3c
> >>> --- /dev/null
> >>> +++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> >>> @@ -0,0 +1,25 @@
> >>> +* Alphascale asm9260 SoC Real Time Clock
> >>> +
> >>> +Required properties:
> >>> +- compatible: Should be "alphascale,asm9260-rtc"
> >>> +- reg: Physical base address of the controller and length
> >>> + of memory mapped region.
> >>> +- interrupts: IRQ line for the RTC.
> >>> +- clocks: Reference to the clock entry.
> >>> +- clock-names: should contain:
> >>> + * "ahb" for the SoC RTC clock
> >>> +
> >>> +Optional:
> >>> +- calibration: calibration value for 1 sec period.
> >>> + Max value for forward calibration is 0x1ffff (131071),
> >>> + Min value for backward calibration is 0xfffe0001 (-131071).
> >>
> >> This should be prefixed with 'alphascale,'
> >>
> >> How is this value determined?
> >>
> >
> > I think this should stay in userspace, see that series:
> > https://groups.google.com/forum/#!topic/rtc-linux/HGQqiHnMiuw
> >
> > It quite often depends on environmental things like temperature so it may be updated at runtime.
> >
>
> I partially agree. IMO default configuration should work properly by
> 20C. My devkit provide terrible results without default offset.
>
I'm not against having a sane default. What I would do is set a default
hardcoded value from the driver at the time the RTC is reset (that is: it
has never been set yet) then let the user adjust that calibration
through sysfs.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] [PATCH v2 0/2] add Alphascale asm9260 RTC driver
@ 2016-02-02 19:56 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 19:56 UTC (permalink / raw)
To: devicetree, robh+dt, a.zummo, alexandre.belloni, rtc-linux; +Cc: Oleksij Rempel
This patch set provide support for RTC controller found on Alphascale
ASM9260 SoC.
v2:
- change license to GPLv2 and later
- remove HW_RTC_AUX and HW_RTC_AUXEN. Thay was taken from reference driver.
Documentation do not provide any info about it. According to my tests
this regs are not available on asm9260.
- remove calibration from DT. It will be beter to set it over sysfs.
Oleksij Rempel (2):
rtc: add rtc-asm9260 driver
doc: dt: add documentation for alphascale,asm9260-rtc
.../bindings/rtc/alphascale,asm9260-rtc.txt | 19 ++
drivers/rtc/Kconfig | 10 +
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-asm9260.c | 355 +++++++++++++++++++++
4 files changed, 385 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
create mode 100644 drivers/rtc/rtc-asm9260.c
--
2.5.0
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH v2 0/2] add Alphascale asm9260 RTC driver
@ 2016-02-02 19:56 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 19:56 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: Oleksij Rempel
This patch set provide support for RTC controller found on Alphascale
ASM9260 SoC.
v2:
- change license to GPLv2 and later
- remove HW_RTC_AUX and HW_RTC_AUXEN. Thay was taken from reference driver.
Documentation do not provide any info about it. According to my tests
this regs are not available on asm9260.
- remove calibration from DT. It will be beter to set it over sysfs.
Oleksij Rempel (2):
rtc: add rtc-asm9260 driver
doc: dt: add documentation for alphascale,asm9260-rtc
.../bindings/rtc/alphascale,asm9260-rtc.txt | 19 ++
drivers/rtc/Kconfig | 10 +
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-asm9260.c | 355 +++++++++++++++++++++
4 files changed, 385 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
create mode 100644 drivers/rtc/rtc-asm9260.c
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] [PATCH v2 1/2] rtc: add rtc-asm9260 driver
@ 2016-02-02 19:56 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 19:56 UTC (permalink / raw)
To: devicetree, robh+dt, a.zummo, alexandre.belloni, rtc-linux; +Cc: Oleksij Rempel
Add support for RTC controller found on Alphascale asm9260
SoC.
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
drivers/rtc/Kconfig | 10 ++
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-asm9260.c | 355 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 366 insertions(+)
create mode 100644 drivers/rtc/rtc-asm9260.c
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 376322f..733b6aa 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1144,6 +1144,16 @@ config RTC_DRV_ZYNQMP
comment "on-CPU RTC drivers"
+config RTC_DRV_ASM9260
+ tristate "Alphascale asm9260 RTC"
+ depends on MACH_ASM9260
+ help
+ If you say yes here you get support for the RTC on the
+ Alphascale asm9260 SoC.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-asm9260.
+
config RTC_DRV_DAVINCI
tristate "TI DaVinci RTC"
depends on ARCH_DAVINCI_DM365
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 62d61b2..f4d841b 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_RTC_DRV_ABB5ZES3) += rtc-ab-b5ze-s3.o
obj-$(CONFIG_RTC_DRV_ABX80X) += rtc-abx80x.o
obj-$(CONFIG_RTC_DRV_ARMADA38X) += rtc-armada38x.o
obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o
+obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o
obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o
obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
diff --git a/drivers/rtc/rtc-asm9260.c b/drivers/rtc/rtc-asm9260.c
new file mode 100644
index 0000000..14e08c4
--- /dev/null
+++ b/drivers/rtc/rtc-asm9260.c
@@ -0,0 +1,355 @@
+/*
+ * Copyright (C) 2016 Oleksij Rempel <linux@rempel-privat.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ */
+
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+
+/* Miscellaneous registers */
+/* Interrupt Location Register */
+#define HW_ILR 0x00
+#define BM_RTCALF BIT(1)
+#define BM_RTCCIF BIT(0)
+
+/* Clock Control Register */
+#define HW_CCR 0x08
+/* Calibration counter disable */
+#define BM_CCALOFF BIT(4)
+/* Reset internal oscillator divider */
+#define BM_CTCRST BIT(1)
+/* Clock Enable */
+#define BM_CLKEN BIT(0)
+
+/* Counter Increment Interrupt Register */
+#define HW_CIIR 0x0C
+#define BM_CIIR_IMYEAR BIT(7)
+#define BM_CIIR_IMMON BIT(6)
+#define BM_CIIR_IMDOY BIT(5)
+#define BM_CIIR_IMDOW BIT(4)
+#define BM_CIIR_IMDOM BIT(3)
+#define BM_CIIR_IMHOUR BIT(2)
+#define BM_CIIR_IMMIN BIT(1)
+#define BM_CIIR_IMSEC BIT(0)
+
+/* Alarm Mask Register */
+#define HW_AMR 0x10
+#define BM_AMR_IMYEAR BIT(7)
+#define BM_AMR_IMMON BIT(6)
+#define BM_AMR_IMDOY BIT(5)
+#define BM_AMR_IMDOW BIT(4)
+#define BM_AMR_IMDOM BIT(3)
+#define BM_AMR_IMHOUR BIT(2)
+#define BM_AMR_IMMIN BIT(1)
+#define BM_AMR_IMSEC BIT(0)
+#define BM_AMR_OFF 0xff
+
+/* Consolidated time registers */
+#define HW_CTIME0 0x14
+#define BM_CTIME0_DOW_S 24
+#define BM_CTIME0_DOW_M 0x7
+#define BM_CTIME0_HOUR_S 16
+#define BM_CTIME0_HOUR_M 0x1f
+#define BM_CTIME0_MIN_S 8
+#define BM_CTIME0_MIN_M 0x3f
+#define BM_CTIME0_SEC_S 0
+#define BM_CTIME0_SEC_M 0x3f
+
+#define HW_CTIME1 0x18
+#define BM_CTIME1_YEAR_S 16
+#define BM_CTIME1_YEAR_M 0xfff
+#define BM_CTIME1_MON_S 8
+#define BM_CTIME1_MON_M 0xf
+#define BM_CTIME1_DOM_S 0
+#define BM_CTIME1_DOM_M 0x1f
+
+#define HW_CTIME2 0x1C
+#define BM_CTIME2_DOY_S 0
+#define BM_CTIME2_DOY_M 0xfff
+
+/* Time counter registers */
+#define HW_SEC 0x20
+#define HW_MIN 0x24
+#define HW_HOUR 0x28
+#define HW_DOM 0x2C
+#define HW_DOW 0x30
+#define HW_DOY 0x34
+#define HW_MONTH 0x38
+#define HW_YEAR 0x3C
+
+#define HW_CALIBRATION 0x40
+#define BM_CALDIR_BACK BIT(17)
+#define BM_CALVAL_M 0x1ffff
+
+/* General purpose registers */
+#define HW_GPREG0 0x44
+#define HW_GPREG1 0x48
+#define HW_GPREG2 0x4C
+#define HW_GPREG3 0x50
+#define HW_GPREG4 0x54
+
+/* Alarm register group */
+#define HW_ALSEC 0x60
+#define HW_ALMIN 0x64
+#define HW_ALHOUR 0x68
+#define HW_ALDOM 0x6C
+#define HW_ALDOW 0x70
+#define HW_ALDOY 0x74
+#define HW_ALMON 0x78
+#define HW_ALYEAR 0x7C
+
+struct asm9260_rtc_priv {
+ struct device *dev;
+ void __iomem *iobase;
+ struct rtc_device *rtc;
+ struct clk *clk;
+ /* io lock */
+ spinlock_t lock;
+};
+
+static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
+{
+ struct asm9260_rtc_priv *priv = dev_id;
+ u32 isr;
+ unsigned long events = 0;
+
+ isr = ioread32(priv->iobase + HW_CIIR);
+ if (!isr)
+ return IRQ_NONE;
+
+ iowrite32(0, priv->iobase + HW_CIIR);
+
+ events |= RTC_AF | RTC_IRQF;
+
+ rtc_update_irq(priv->rtc, 1, events);
+
+ return IRQ_HANDLED;
+}
+
+static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ u32 ctime0, ctime1, ctime2;
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ ctime0 = ioread32(priv->iobase + HW_CTIME0);
+ ctime1 = ioread32(priv->iobase + HW_CTIME1);
+ ctime2 = ioread32(priv->iobase + HW_CTIME2);
+
+ if (ctime1 != ioread32(priv->iobase + HW_CTIME1)) {
+ /*
+ * woops, counter flipped right now. Now we are safe
+ * to reread.
+ */
+ ctime0 = ioread32(priv->iobase + HW_CTIME0);
+ ctime1 = ioread32(priv->iobase + HW_CTIME1);
+ ctime2 = ioread32(priv->iobase + HW_CTIME2);
+ }
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
+ tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
+ tm->tm_hour = (ctime0 >> BM_CTIME0_HOUR_S) & BM_CTIME0_HOUR_M;
+ tm->tm_wday = (ctime0 >> BM_CTIME0_DOW_S) & BM_CTIME0_DOW_M;
+
+ tm->tm_mday = (ctime1 >> BM_CTIME1_DOM_S) & BM_CTIME1_DOM_M;
+ tm->tm_mon = (ctime1 >> BM_CTIME1_MON_S) & BM_CTIME1_MON_M;
+ tm->tm_year = (ctime1 >> BM_CTIME1_YEAR_S) & BM_CTIME1_YEAR_M;
+
+ tm->tm_yday = (ctime2 >> BM_CTIME2_DOY_S) & BM_CTIME2_DOY_M;
+
+ return 0;
+}
+
+static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ /*
+ * make sure SEC counter will not flip other counter on write time,
+ * real value will be written at the enf of sequence.
+ */
+ iowrite32(0, priv->iobase + HW_SEC);
+
+ iowrite32(tm->tm_year, priv->iobase + HW_YEAR);
+ iowrite32(tm->tm_mon, priv->iobase + HW_MONTH);
+ iowrite32(tm->tm_mday, priv->iobase + HW_DOM);
+ iowrite32(tm->tm_wday, priv->iobase + HW_DOW);
+ iowrite32(tm->tm_yday, priv->iobase + HW_DOY);
+ iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
+ iowrite32(tm->tm_min, priv->iobase + HW_MIN);
+ iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return 0;
+}
+
+static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ alrm->time.tm_year = ioread32(priv->iobase + HW_ALYEAR);
+ alrm->time.tm_mon = ioread32(priv->iobase + HW_ALMON);
+ alrm->time.tm_mday = ioread32(priv->iobase + HW_ALDOM);
+ alrm->time.tm_wday = ioread32(priv->iobase + HW_ALDOW);
+ alrm->time.tm_yday = ioread32(priv->iobase + HW_ALDOY);
+ alrm->time.tm_hour = ioread32(priv->iobase + HW_ALHOUR);
+ alrm->time.tm_min = ioread32(priv->iobase + HW_ALMIN);
+ alrm->time.tm_sec = ioread32(priv->iobase + HW_ALSEC);
+
+ alrm->enabled = ioread32(priv->iobase + HW_AMR) ? 1 : 0;
+ alrm->pending = ioread32(priv->iobase + HW_CIIR) ? 1 : 0;
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return rtc_valid_tm(&alrm->time);
+}
+
+static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ iowrite32(alrm->time.tm_year, priv->iobase + HW_ALYEAR);
+ iowrite32(alrm->time.tm_mon, priv->iobase + HW_ALMON);
+ iowrite32(alrm->time.tm_mday, priv->iobase + HW_ALDOM);
+ iowrite32(alrm->time.tm_wday, priv->iobase + HW_ALDOW);
+ iowrite32(alrm->time.tm_yday, priv->iobase + HW_ALDOY);
+ iowrite32(alrm->time.tm_hour, priv->iobase + HW_ALHOUR);
+ iowrite32(alrm->time.tm_min, priv->iobase + HW_ALMIN);
+ iowrite32(alrm->time.tm_sec, priv->iobase + HW_ALSEC);
+
+ iowrite32(alrm->enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return 0;
+}
+
+static int asm9260_alarm_irq_enable(struct device *dev, unsigned int enabled)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+
+ iowrite32(enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
+ return 0;
+}
+
+static const struct rtc_class_ops asm9260_rtc_ops = {
+ .read_time = asm9260_rtc_read_time,
+ .set_time = asm9260_rtc_set_time,
+ .read_alarm = asm9260_rtc_read_alarm,
+ .set_alarm = asm9260_rtc_set_alarm,
+ .alarm_irq_enable = asm9260_alarm_irq_enable,
+};
+
+static int __init asm9260_rtc_probe(struct platform_device *pdev)
+{
+ struct asm9260_rtc_priv *priv;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ int irq_alarm, ret;
+ u32 ccr;
+
+ priv = devm_kzalloc(dev, sizeof(struct asm9260_rtc_priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->dev = &pdev->dev;
+ platform_set_drvdata(pdev, priv);
+
+ irq_alarm = platform_get_irq(pdev, 0);
+ if (irq_alarm < 0) {
+ dev_err(dev, "No alarm IRQ resource defined\n");
+ return irq_alarm;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ priv->iobase = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->iobase))
+ return PTR_ERR(priv->iobase);
+
+ priv->clk = devm_clk_get(dev, "ahb");
+ ret = clk_prepare_enable(priv->clk);
+ if (ret) {
+ dev_err(dev, "Failed to enable clk!\n");
+ return ret;
+ }
+
+ ccr = ioread32(priv->iobase + HW_CCR);
+ /* if dev is not enabled, reset it */
+ if ((ccr & (BM_CLKEN | BM_CTCRST)) != BM_CLKEN) {
+ iowrite32(BM_CTCRST, priv->iobase + HW_CCR);
+ ccr = 0;
+ }
+
+ iowrite32(BM_CLKEN | ccr, priv->iobase + HW_CCR);
+ iowrite32(0, priv->iobase + HW_CIIR);
+ iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
+
+ priv->rtc = devm_rtc_device_register(dev, dev_name(dev),
+ &asm9260_rtc_ops, THIS_MODULE);
+ if (IS_ERR(priv->rtc)) {
+ ret = PTR_ERR(priv->rtc);
+ dev_err(dev, "Failed to register RTC device: %d\n", ret);
+ goto err_return;
+ }
+
+ ret = devm_request_threaded_irq(dev, irq_alarm, NULL,
+ asm9260_rtc_irq, IRQF_ONESHOT,
+ dev_name(dev), priv);
+ if (ret < 0) {
+ dev_err(dev, "can't get irq %i, err %d\n",
+ irq_alarm, ret);
+ goto err_return;
+ }
+
+ return 0;
+
+err_return:
+ clk_disable_unprepare(priv->clk);
+ return ret;
+}
+
+static int __exit asm9260_rtc_remove(struct platform_device *pdev)
+{
+ struct asm9260_rtc_priv *priv = platform_get_drvdata(pdev);
+
+ /* Disable alarm matching */
+ iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
+ clk_disable_unprepare(priv->clk);
+ return 0;
+}
+
+static const struct of_device_id asm9260_dt_ids[] = {
+ { .compatible = "alphascale,asm9260-rtc", },
+ {}
+};
+
+static struct platform_driver asm9260_rtc_driver = {
+ .probe = asm9260_rtc_probe,
+ .remove = asm9260_rtc_remove,
+ .driver = {
+ .name = "asm9260-rtc",
+ .owner = THIS_MODULE,
+ .of_match_table = asm9260_dt_ids,
+ },
+};
+
+module_platform_driver(asm9260_rtc_driver);
+
+MODULE_AUTHOR("Oleksij Rempel <linux@rempel-privat.de>");
+MODULE_DESCRIPTION("Alphascale asm9260 SoC Realtime Clock Driver (RTC)");
+MODULE_LICENSE("GPL");
--
2.5.0
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v2 1/2] rtc: add rtc-asm9260 driver
@ 2016-02-02 19:56 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 19:56 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: Oleksij Rempel
Add support for RTC controller found on Alphascale asm9260
SoC.
Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
---
drivers/rtc/Kconfig | 10 ++
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-asm9260.c | 355 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 366 insertions(+)
create mode 100644 drivers/rtc/rtc-asm9260.c
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 376322f..733b6aa 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1144,6 +1144,16 @@ config RTC_DRV_ZYNQMP
comment "on-CPU RTC drivers"
+config RTC_DRV_ASM9260
+ tristate "Alphascale asm9260 RTC"
+ depends on MACH_ASM9260
+ help
+ If you say yes here you get support for the RTC on the
+ Alphascale asm9260 SoC.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-asm9260.
+
config RTC_DRV_DAVINCI
tristate "TI DaVinci RTC"
depends on ARCH_DAVINCI_DM365
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 62d61b2..f4d841b 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_RTC_DRV_ABB5ZES3) += rtc-ab-b5ze-s3.o
obj-$(CONFIG_RTC_DRV_ABX80X) += rtc-abx80x.o
obj-$(CONFIG_RTC_DRV_ARMADA38X) += rtc-armada38x.o
obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o
+obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o
obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o
obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
diff --git a/drivers/rtc/rtc-asm9260.c b/drivers/rtc/rtc-asm9260.c
new file mode 100644
index 0000000..14e08c4
--- /dev/null
+++ b/drivers/rtc/rtc-asm9260.c
@@ -0,0 +1,355 @@
+/*
+ * Copyright (C) 2016 Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License,
+ * or (at your option) any later version.
+ */
+
+#include <linux/clk.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/rtc.h>
+
+/* Miscellaneous registers */
+/* Interrupt Location Register */
+#define HW_ILR 0x00
+#define BM_RTCALF BIT(1)
+#define BM_RTCCIF BIT(0)
+
+/* Clock Control Register */
+#define HW_CCR 0x08
+/* Calibration counter disable */
+#define BM_CCALOFF BIT(4)
+/* Reset internal oscillator divider */
+#define BM_CTCRST BIT(1)
+/* Clock Enable */
+#define BM_CLKEN BIT(0)
+
+/* Counter Increment Interrupt Register */
+#define HW_CIIR 0x0C
+#define BM_CIIR_IMYEAR BIT(7)
+#define BM_CIIR_IMMON BIT(6)
+#define BM_CIIR_IMDOY BIT(5)
+#define BM_CIIR_IMDOW BIT(4)
+#define BM_CIIR_IMDOM BIT(3)
+#define BM_CIIR_IMHOUR BIT(2)
+#define BM_CIIR_IMMIN BIT(1)
+#define BM_CIIR_IMSEC BIT(0)
+
+/* Alarm Mask Register */
+#define HW_AMR 0x10
+#define BM_AMR_IMYEAR BIT(7)
+#define BM_AMR_IMMON BIT(6)
+#define BM_AMR_IMDOY BIT(5)
+#define BM_AMR_IMDOW BIT(4)
+#define BM_AMR_IMDOM BIT(3)
+#define BM_AMR_IMHOUR BIT(2)
+#define BM_AMR_IMMIN BIT(1)
+#define BM_AMR_IMSEC BIT(0)
+#define BM_AMR_OFF 0xff
+
+/* Consolidated time registers */
+#define HW_CTIME0 0x14
+#define BM_CTIME0_DOW_S 24
+#define BM_CTIME0_DOW_M 0x7
+#define BM_CTIME0_HOUR_S 16
+#define BM_CTIME0_HOUR_M 0x1f
+#define BM_CTIME0_MIN_S 8
+#define BM_CTIME0_MIN_M 0x3f
+#define BM_CTIME0_SEC_S 0
+#define BM_CTIME0_SEC_M 0x3f
+
+#define HW_CTIME1 0x18
+#define BM_CTIME1_YEAR_S 16
+#define BM_CTIME1_YEAR_M 0xfff
+#define BM_CTIME1_MON_S 8
+#define BM_CTIME1_MON_M 0xf
+#define BM_CTIME1_DOM_S 0
+#define BM_CTIME1_DOM_M 0x1f
+
+#define HW_CTIME2 0x1C
+#define BM_CTIME2_DOY_S 0
+#define BM_CTIME2_DOY_M 0xfff
+
+/* Time counter registers */
+#define HW_SEC 0x20
+#define HW_MIN 0x24
+#define HW_HOUR 0x28
+#define HW_DOM 0x2C
+#define HW_DOW 0x30
+#define HW_DOY 0x34
+#define HW_MONTH 0x38
+#define HW_YEAR 0x3C
+
+#define HW_CALIBRATION 0x40
+#define BM_CALDIR_BACK BIT(17)
+#define BM_CALVAL_M 0x1ffff
+
+/* General purpose registers */
+#define HW_GPREG0 0x44
+#define HW_GPREG1 0x48
+#define HW_GPREG2 0x4C
+#define HW_GPREG3 0x50
+#define HW_GPREG4 0x54
+
+/* Alarm register group */
+#define HW_ALSEC 0x60
+#define HW_ALMIN 0x64
+#define HW_ALHOUR 0x68
+#define HW_ALDOM 0x6C
+#define HW_ALDOW 0x70
+#define HW_ALDOY 0x74
+#define HW_ALMON 0x78
+#define HW_ALYEAR 0x7C
+
+struct asm9260_rtc_priv {
+ struct device *dev;
+ void __iomem *iobase;
+ struct rtc_device *rtc;
+ struct clk *clk;
+ /* io lock */
+ spinlock_t lock;
+};
+
+static irqreturn_t asm9260_rtc_irq(int irq, void *dev_id)
+{
+ struct asm9260_rtc_priv *priv = dev_id;
+ u32 isr;
+ unsigned long events = 0;
+
+ isr = ioread32(priv->iobase + HW_CIIR);
+ if (!isr)
+ return IRQ_NONE;
+
+ iowrite32(0, priv->iobase + HW_CIIR);
+
+ events |= RTC_AF | RTC_IRQF;
+
+ rtc_update_irq(priv->rtc, 1, events);
+
+ return IRQ_HANDLED;
+}
+
+static int asm9260_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ u32 ctime0, ctime1, ctime2;
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ ctime0 = ioread32(priv->iobase + HW_CTIME0);
+ ctime1 = ioread32(priv->iobase + HW_CTIME1);
+ ctime2 = ioread32(priv->iobase + HW_CTIME2);
+
+ if (ctime1 != ioread32(priv->iobase + HW_CTIME1)) {
+ /*
+ * woops, counter flipped right now. Now we are safe
+ * to reread.
+ */
+ ctime0 = ioread32(priv->iobase + HW_CTIME0);
+ ctime1 = ioread32(priv->iobase + HW_CTIME1);
+ ctime2 = ioread32(priv->iobase + HW_CTIME2);
+ }
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ tm->tm_sec = (ctime0 >> BM_CTIME0_SEC_S) & BM_CTIME0_SEC_M;
+ tm->tm_min = (ctime0 >> BM_CTIME0_MIN_S) & BM_CTIME0_MIN_M;
+ tm->tm_hour = (ctime0 >> BM_CTIME0_HOUR_S) & BM_CTIME0_HOUR_M;
+ tm->tm_wday = (ctime0 >> BM_CTIME0_DOW_S) & BM_CTIME0_DOW_M;
+
+ tm->tm_mday = (ctime1 >> BM_CTIME1_DOM_S) & BM_CTIME1_DOM_M;
+ tm->tm_mon = (ctime1 >> BM_CTIME1_MON_S) & BM_CTIME1_MON_M;
+ tm->tm_year = (ctime1 >> BM_CTIME1_YEAR_S) & BM_CTIME1_YEAR_M;
+
+ tm->tm_yday = (ctime2 >> BM_CTIME2_DOY_S) & BM_CTIME2_DOY_M;
+
+ return 0;
+}
+
+static int asm9260_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ /*
+ * make sure SEC counter will not flip other counter on write time,
+ * real value will be written at the enf of sequence.
+ */
+ iowrite32(0, priv->iobase + HW_SEC);
+
+ iowrite32(tm->tm_year, priv->iobase + HW_YEAR);
+ iowrite32(tm->tm_mon, priv->iobase + HW_MONTH);
+ iowrite32(tm->tm_mday, priv->iobase + HW_DOM);
+ iowrite32(tm->tm_wday, priv->iobase + HW_DOW);
+ iowrite32(tm->tm_yday, priv->iobase + HW_DOY);
+ iowrite32(tm->tm_hour, priv->iobase + HW_HOUR);
+ iowrite32(tm->tm_min, priv->iobase + HW_MIN);
+ iowrite32(tm->tm_sec, priv->iobase + HW_SEC);
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return 0;
+}
+
+static int asm9260_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ alrm->time.tm_year = ioread32(priv->iobase + HW_ALYEAR);
+ alrm->time.tm_mon = ioread32(priv->iobase + HW_ALMON);
+ alrm->time.tm_mday = ioread32(priv->iobase + HW_ALDOM);
+ alrm->time.tm_wday = ioread32(priv->iobase + HW_ALDOW);
+ alrm->time.tm_yday = ioread32(priv->iobase + HW_ALDOY);
+ alrm->time.tm_hour = ioread32(priv->iobase + HW_ALHOUR);
+ alrm->time.tm_min = ioread32(priv->iobase + HW_ALMIN);
+ alrm->time.tm_sec = ioread32(priv->iobase + HW_ALSEC);
+
+ alrm->enabled = ioread32(priv->iobase + HW_AMR) ? 1 : 0;
+ alrm->pending = ioread32(priv->iobase + HW_CIIR) ? 1 : 0;
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return rtc_valid_tm(&alrm->time);
+}
+
+static int asm9260_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+ unsigned long irq_flags;
+
+ spin_lock_irqsave(&priv->lock, irq_flags);
+ iowrite32(alrm->time.tm_year, priv->iobase + HW_ALYEAR);
+ iowrite32(alrm->time.tm_mon, priv->iobase + HW_ALMON);
+ iowrite32(alrm->time.tm_mday, priv->iobase + HW_ALDOM);
+ iowrite32(alrm->time.tm_wday, priv->iobase + HW_ALDOW);
+ iowrite32(alrm->time.tm_yday, priv->iobase + HW_ALDOY);
+ iowrite32(alrm->time.tm_hour, priv->iobase + HW_ALHOUR);
+ iowrite32(alrm->time.tm_min, priv->iobase + HW_ALMIN);
+ iowrite32(alrm->time.tm_sec, priv->iobase + HW_ALSEC);
+
+ iowrite32(alrm->enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
+ spin_unlock_irqrestore(&priv->lock, irq_flags);
+
+ return 0;
+}
+
+static int asm9260_alarm_irq_enable(struct device *dev, unsigned int enabled)
+{
+ struct asm9260_rtc_priv *priv = dev_get_drvdata(dev);
+
+ iowrite32(enabled ? 0 : BM_AMR_OFF, priv->iobase + HW_AMR);
+ return 0;
+}
+
+static const struct rtc_class_ops asm9260_rtc_ops = {
+ .read_time = asm9260_rtc_read_time,
+ .set_time = asm9260_rtc_set_time,
+ .read_alarm = asm9260_rtc_read_alarm,
+ .set_alarm = asm9260_rtc_set_alarm,
+ .alarm_irq_enable = asm9260_alarm_irq_enable,
+};
+
+static int __init asm9260_rtc_probe(struct platform_device *pdev)
+{
+ struct asm9260_rtc_priv *priv;
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ int irq_alarm, ret;
+ u32 ccr;
+
+ priv = devm_kzalloc(dev, sizeof(struct asm9260_rtc_priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ priv->dev = &pdev->dev;
+ platform_set_drvdata(pdev, priv);
+
+ irq_alarm = platform_get_irq(pdev, 0);
+ if (irq_alarm < 0) {
+ dev_err(dev, "No alarm IRQ resource defined\n");
+ return irq_alarm;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ priv->iobase = devm_ioremap_resource(dev, res);
+ if (IS_ERR(priv->iobase))
+ return PTR_ERR(priv->iobase);
+
+ priv->clk = devm_clk_get(dev, "ahb");
+ ret = clk_prepare_enable(priv->clk);
+ if (ret) {
+ dev_err(dev, "Failed to enable clk!\n");
+ return ret;
+ }
+
+ ccr = ioread32(priv->iobase + HW_CCR);
+ /* if dev is not enabled, reset it */
+ if ((ccr & (BM_CLKEN | BM_CTCRST)) != BM_CLKEN) {
+ iowrite32(BM_CTCRST, priv->iobase + HW_CCR);
+ ccr = 0;
+ }
+
+ iowrite32(BM_CLKEN | ccr, priv->iobase + HW_CCR);
+ iowrite32(0, priv->iobase + HW_CIIR);
+ iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
+
+ priv->rtc = devm_rtc_device_register(dev, dev_name(dev),
+ &asm9260_rtc_ops, THIS_MODULE);
+ if (IS_ERR(priv->rtc)) {
+ ret = PTR_ERR(priv->rtc);
+ dev_err(dev, "Failed to register RTC device: %d\n", ret);
+ goto err_return;
+ }
+
+ ret = devm_request_threaded_irq(dev, irq_alarm, NULL,
+ asm9260_rtc_irq, IRQF_ONESHOT,
+ dev_name(dev), priv);
+ if (ret < 0) {
+ dev_err(dev, "can't get irq %i, err %d\n",
+ irq_alarm, ret);
+ goto err_return;
+ }
+
+ return 0;
+
+err_return:
+ clk_disable_unprepare(priv->clk);
+ return ret;
+}
+
+static int __exit asm9260_rtc_remove(struct platform_device *pdev)
+{
+ struct asm9260_rtc_priv *priv = platform_get_drvdata(pdev);
+
+ /* Disable alarm matching */
+ iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
+ clk_disable_unprepare(priv->clk);
+ return 0;
+}
+
+static const struct of_device_id asm9260_dt_ids[] = {
+ { .compatible = "alphascale,asm9260-rtc", },
+ {}
+};
+
+static struct platform_driver asm9260_rtc_driver = {
+ .probe = asm9260_rtc_probe,
+ .remove = asm9260_rtc_remove,
+ .driver = {
+ .name = "asm9260-rtc",
+ .owner = THIS_MODULE,
+ .of_match_table = asm9260_dt_ids,
+ },
+};
+
+module_platform_driver(asm9260_rtc_driver);
+
+MODULE_AUTHOR("Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>");
+MODULE_DESCRIPTION("Alphascale asm9260 SoC Realtime Clock Driver (RTC)");
+MODULE_LICENSE("GPL");
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [rtc-linux] [PATCH v2 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 19:56 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 19:56 UTC (permalink / raw)
To: devicetree, robh+dt, a.zummo, alexandre.belloni, rtc-linux; +Cc: Oleksij Rempel
Document Alphascale asm9260 RTC bindings
Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
.../bindings/rtc/alphascale,asm9260-rtc.txt | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
new file mode 100644
index 0000000..76ebca5
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
@@ -0,0 +1,19 @@
+* Alphascale asm9260 SoC Real Time Clock
+
+Required properties:
+- compatible: Should be "alphascale,asm9260-rtc"
+- reg: Physical base address of the controller and length
+ of memory mapped region.
+- interrupts: IRQ line for the RTC.
+- clocks: Reference to the clock entry.
+- clock-names: should contain:
+ * "ahb" for the SoC RTC clock
+
+Example:
+rtc0: rtc@800a0000 {
+ compatible = "alphascale,asm9260-rtc";
+ reg = <0x800a0000 0x100>;
+ clocks = <&acc CLKID_AHB_RTC>;
+ clock-names = "ahb";
+ interrupts = <2>;
+};
--
2.5.0
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH v2 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 19:56 ` Oleksij Rempel
0 siblings, 0 replies; 30+ messages in thread
From: Oleksij Rempel @ 2016-02-02 19:56 UTC (permalink / raw)
To: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: Oleksij Rempel
Document Alphascale asm9260 RTC bindings
Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
---
.../bindings/rtc/alphascale,asm9260-rtc.txt | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
diff --git a/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
new file mode 100644
index 0000000..76ebca5
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
@@ -0,0 +1,19 @@
+* Alphascale asm9260 SoC Real Time Clock
+
+Required properties:
+- compatible: Should be "alphascale,asm9260-rtc"
+- reg: Physical base address of the controller and length
+ of memory mapped region.
+- interrupts: IRQ line for the RTC.
+- clocks: Reference to the clock entry.
+- clock-names: should contain:
+ * "ahb" for the SoC RTC clock
+
+Example:
+rtc0: rtc@800a0000 {
+ compatible = "alphascale,asm9260-rtc";
+ reg = <0x800a0000 0x100>;
+ clocks = <&acc CLKID_AHB_RTC>;
+ clock-names = "ahb";
+ interrupts = <2>;
+};
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH v2 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 21:12 ` Rob Herring
0 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2016-02-02 21:12 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: devicetree, a.zummo, alexandre.belloni, rtc-linux
On Tue, Feb 02, 2016 at 08:56:11PM +0100, Oleksij Rempel wrote:
> Document Alphascale asm9260 RTC bindings
>
> Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
> ---
> .../bindings/rtc/alphascale,asm9260-rtc.txt | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
Acked-by: Rob Herring <robh@kernel.org>
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v2 2/2] doc: dt: add documentation for alphascale,asm9260-rtc
@ 2016-02-02 21:12 ` Rob Herring
0 siblings, 0 replies; 30+ messages in thread
From: Rob Herring @ 2016-02-02 21:12 UTC (permalink / raw)
To: Oleksij Rempel
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
On Tue, Feb 02, 2016 at 08:56:11PM +0100, Oleksij Rempel wrote:
> Document Alphascale asm9260 RTC bindings
>
> Signed-off-by: Oleksij Rempel <linux-YEK0n+YFykbzxQdaRaTXBw@public.gmane.org>
> ---
> .../bindings/rtc/alphascale,asm9260-rtc.txt | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
* [rtc-linux] Re: [PATCH v2 0/2] add Alphascale asm9260 RTC driver
@ 2016-02-20 4:38 ` Alexandre Belloni
0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2016-02-20 4:38 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: devicetree, robh+dt, a.zummo, rtc-linux
On 02/02/2016 at 20:56:09 +0100, Oleksij Rempel wrote :
> This patch set provide support for RTC controller found on Alphascale
> ASM9260 SoC.
>
> v2:
> - change license to GPLv2 and later
> - remove HW_RTC_AUX and HW_RTC_AUXEN. Thay was taken from reference driver.
> Documentation do not provide any info about it. According to my tests
> this regs are not available on asm9260.
> - remove calibration from DT. It will be beter to set it over sysfs.
>
> Oleksij Rempel (2):
> rtc: add rtc-asm9260 driver
> doc: dt: add documentation for alphascale,asm9260-rtc
>
> .../bindings/rtc/alphascale,asm9260-rtc.txt | 19 ++
> drivers/rtc/Kconfig | 10 +
> drivers/rtc/Makefile | 1 +
> drivers/rtc/rtc-asm9260.c | 355 +++++++++++++++++++++
> 4 files changed, 385 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> create mode 100644 drivers/rtc/rtc-asm9260.c
>
Applied, thanks!
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH v2 0/2] add Alphascale asm9260 RTC driver
@ 2016-02-20 4:38 ` Alexandre Belloni
0 siblings, 0 replies; 30+ messages in thread
From: Alexandre Belloni @ 2016-02-20 4:38 UTC (permalink / raw)
To: Oleksij Rempel
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A, a.zummo-BfzFCNDTiLLj+vYz1yj4TQ,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
On 02/02/2016 at 20:56:09 +0100, Oleksij Rempel wrote :
> This patch set provide support for RTC controller found on Alphascale
> ASM9260 SoC.
>
> v2:
> - change license to GPLv2 and later
> - remove HW_RTC_AUX and HW_RTC_AUXEN. Thay was taken from reference driver.
> Documentation do not provide any info about it. According to my tests
> this regs are not available on asm9260.
> - remove calibration from DT. It will be beter to set it over sysfs.
>
> Oleksij Rempel (2):
> rtc: add rtc-asm9260 driver
> doc: dt: add documentation for alphascale,asm9260-rtc
>
> .../bindings/rtc/alphascale,asm9260-rtc.txt | 19 ++
> drivers/rtc/Kconfig | 10 +
> drivers/rtc/Makefile | 1 +
> drivers/rtc/rtc-asm9260.c | 355 +++++++++++++++++++++
> 4 files changed, 385 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/rtc/alphascale,asm9260-rtc.txt
> create mode 100644 drivers/rtc/rtc-asm9260.c
>
Applied, thanks!
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2016-02-20 4:38 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-29 8:40 [rtc-linux] [PATCH 0/2] add Alphascale asm9260 RTC driver Oleksij Rempel
2016-01-29 8:40 ` Oleksij Rempel
2016-01-29 8:40 ` [rtc-linux] [PATCH 1/2] rtc: add rtc-asm9260 driver Oleksij Rempel
2016-01-29 8:40 ` Oleksij Rempel
2016-02-01 16:05 ` [rtc-linux] " Alexandre Belloni
2016-02-01 16:05 ` Alexandre Belloni
2016-02-02 8:24 ` [rtc-linux] " Oleksij Rempel
2016-02-02 8:24 ` Oleksij Rempel
2016-01-29 8:40 ` [rtc-linux] [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc Oleksij Rempel
2016-01-29 8:40 ` Oleksij Rempel
2016-02-01 15:27 ` [rtc-linux] " Rob Herring
2016-02-01 15:27 ` Rob Herring
2016-02-01 15:55 ` [rtc-linux] " Alexandre Belloni
2016-02-01 15:55 ` Alexandre Belloni
2016-02-02 8:46 ` [rtc-linux] " Oleksij Rempel
2016-02-02 8:46 ` Oleksij Rempel
2016-02-02 10:28 ` [rtc-linux] " Alexandre Belloni
2016-02-02 10:28 ` Alexandre Belloni
2016-02-02 19:56 ` [rtc-linux] [PATCH v2 0/2] add Alphascale asm9260 RTC driver Oleksij Rempel
2016-02-02 19:56 ` Oleksij Rempel
2016-02-02 19:56 ` [rtc-linux] [PATCH v2 1/2] rtc: add rtc-asm9260 driver Oleksij Rempel
2016-02-02 19:56 ` Oleksij Rempel
2016-02-02 19:56 ` [rtc-linux] [PATCH v2 2/2] doc: dt: add documentation for alphascale,asm9260-rtc Oleksij Rempel
2016-02-02 19:56 ` Oleksij Rempel
2016-02-02 21:12 ` [rtc-linux] " Rob Herring
2016-02-02 21:12 ` Rob Herring
2016-02-20 4:38 ` [rtc-linux] Re: [PATCH v2 0/2] add Alphascale asm9260 RTC driver Alexandre Belloni
2016-02-20 4:38 ` Alexandre Belloni
2016-02-02 8:42 ` [rtc-linux] Re: [PATCH 2/2] doc: dt: add documentation for alphascale,asm9260-rtc Oleksij Rempel
2016-02-02 8:42 ` Oleksij Rempel
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.