Skip to contentSkip to conversation

rtc: ds3232: rename rtc-ds3232.c to rtc-ds3232-core.c for preparation

PATCH Superseded Akinobu Mita 1 participant 4 messages Feb 11, 2016 Real time clock (RTC)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 rtc: ds3232: rename rtc-ds3232.c to rtc-ds3232-core.c for preparation

This is preparation for splitting into core module and i2c driver. This will make it a lot easier to review the real changes.

Cc Alessandro Zummo <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Jack Lan <[email protected]>
Cc Srikanth Srinivasan <[email protected]>
Cc Dennis Aberilla <[email protected]>
---
 drivers/rtc/Makefile          |   1 +
 drivers/rtc/rtc-ds3232-core.c | 517 ++++++++++++++++++++++++++++++++++++++++++
 drivers/rtc/rtc-ds3232.c      | 517 ------------------------------------------
 3 files changed, 518 insertions(+), 517 deletions(-)
 create mode 100644 drivers/rtc/rtc-ds3232-core.c
 delete mode 100644 drivers/rtc/rtc-ds3232.c
drivers/rtc/Makefile +1 -0
index 62d61b2..0b8cb6c 100644
@@ -59,6 +59,7 @@ obj-$(CONFIG_RTC_DRV_DS1685_FAMILY)	+= rtc-ds1685.o
 obj-$(CONFIG_RTC_DRV_DS1742)	+= rtc-ds1742.o
 obj-$(CONFIG_RTC_DRV_DS2404)	+= rtc-ds2404.o
 obj-$(CONFIG_RTC_DRV_DS3232)	+= rtc-ds3232.o
+rtc-ds3232-objs			:= rtc-ds3232-core.o
 obj-$(CONFIG_RTC_DRV_DS3234)	+= rtc-ds3234.o
 obj-$(CONFIG_RTC_DRV_EFI)	+= rtc-efi.o
 obj-$(CONFIG_RTC_DRV_EM3027)	+= rtc-em3027.o
drivers/rtc/rtc-ds3232-core.c new file +517 -0

517 lines not on this page · raw message

drivers/rtc/rtc-ds3232.c deleted +0 -517

517 lines not on this page · raw message

Signature · 12 lines
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
#1 lore raw

PATCH 2/4 rtc: ds3232: split into core module and i2c driver

According to "Feature Comparison of the DS323x Real-Time Clocks"
(http://pdfserv.maximintegrated.com/en/an/AN5143.pdf), DS3232 and DS3234 are very similar.

In order to share common code between rtc-ds3232 and rtc-ds3234, this splits rtc-ds3232 driver into core module and i2c driver.

Cc Alessandro Zummo <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Jack Lan <[email protected]>
Cc Srikanth Srinivasan <[email protected]>
Cc Dennis Aberilla <[email protected]>
---
 drivers/rtc/Kconfig           |   4 +
 drivers/rtc/Makefile          |   2 +-
 drivers/rtc/rtc-ds3232-core.c | 168 ++++++++++++++++++------------------------
 drivers/rtc/rtc-ds3232.c      | 105 ++++++++++++++++++++++++++
 drivers/rtc/rtc-ds3232.h      |  28 +++++++
 5 files changed, 208 insertions(+), 99 deletions(-)
 create mode 100644 drivers/rtc/rtc-ds3232.c
 create mode 100644 drivers/rtc/rtc-ds3232.h
drivers/rtc/Kconfig +4 -0
index a9a2185..4a59f45 100644
@@ -248,8 +248,12 @@ config RTC_DRV_DS1672
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-ds1672.
 
+config RTC_DRV_DS3232_CORE
+	tristate
+
 config RTC_DRV_DS3232
 	tristate "Dallas/Maxim DS3232"
+	select RTC_DRV_DS3232_CORE
 	help
 	  If you say yes here you get support for Dallas Semiconductor
 	  DS3232 real-time clock chips. If an interrupt is associated
drivers/rtc/Makefile +1 -1
index 0b8cb6c..f2d236f 100644
@@ -58,8 +58,8 @@ obj-$(CONFIG_RTC_DRV_DS1672)	+= rtc-ds1672.o
 obj-$(CONFIG_RTC_DRV_DS1685_FAMILY)	+= rtc-ds1685.o
 obj-$(CONFIG_RTC_DRV_DS1742)	+= rtc-ds1742.o
 obj-$(CONFIG_RTC_DRV_DS2404)	+= rtc-ds2404.o
+obj-$(CONFIG_RTC_DRV_DS3232_CORE)	+= rtc-ds3232-core.o
 obj-$(CONFIG_RTC_DRV_DS3232)	+= rtc-ds3232.o
-rtc-ds3232-objs			:= rtc-ds3232-core.o
 obj-$(CONFIG_RTC_DRV_DS3234)	+= rtc-ds3234.o
 obj-$(CONFIG_RTC_DRV_EFI)	+= rtc-efi.o
 obj-$(CONFIG_RTC_DRV_EM3027)	+= rtc-em3027.o
drivers/rtc/rtc-ds3232-core.c +70 -98

439 lines not on this page · raw message

drivers/rtc/rtc-ds3232.c new file +105 -0

105 lines not on this page · raw message

drivers/rtc/rtc-ds3232.h new file +28 -0
new file mode 100644
index 0000000..923944d
@@ -0,0 +1,28 @@
+/*
+ * RTC client/driver for the Maxim/Dallas DS3232/DS3234 Real-Time Clock
+ *
+ * Copyright (C) 2009-2011 Freescale Semiconductor.
+ * Author: Jack Lan <[email protected]>
+ *
+ * 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.
+ */
+#ifndef __RTC_DS3232_H__
+#define __RTC_DS3232_H__
+
+struct ds3232_ops {
+	int (*read_byte)(struct device *, u8);
+	int (*write_byte)(struct device *, u8, u8);
+	int (*read_block)(struct device *, u8, void *, int);
+	int (*write_block)(struct device *, u8, const void *, int);
+	int (*irq)(struct device *);
+};
+
+int ds3232_probe(struct device *dev, const struct ds3232_ops *ops,
+		const char *name);
+int ds3232_remove(struct device *dev);
+extern const struct dev_pm_ops ds3232_pm_ops;
+
+#endif
Signature · 12 lines
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
#2 lore raw

PATCH 3/4 rtc: ds3234: use rtc-ds3232 core and support alarm

In reply to Akinobu Mita

Use rtc-ds3232 core module. This change enables to support alarm for rtc-ds3234.

Cc Alessandro Zummo <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Jack Lan <[email protected]>
Cc Srikanth Srinivasan <[email protected]>
Cc Dennis Aberilla <[email protected]>
---
 drivers/rtc/Kconfig      |   1 +
 drivers/rtc/rtc-ds3234.c | 148 +++++++++++++++++++++++++----------------------
 2 files changed, 80 insertions(+), 69 deletions(-)
drivers/rtc/Kconfig +1 -0
index 4a59f45..61c67ce 100644
@@ -733,6 +733,7 @@ config RTC_DRV_RS5C348
 
 config RTC_DRV_DS3234
 	tristate "Maxim/Dallas DS3234"
+	select RTC_DRV_DS3232_CORE
 	help
 	  If you say yes here you get support for the
 	  Maxim/Dallas DS3234 SPI RTC chip.
drivers/rtc/rtc-ds3234.c +79 -69

213 lines not on this page · raw message

Signature · 12 lines
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 [email protected].
For more options, visit https://groups.google.com/d/optout.
#3 lore raw

PATCH 4/4 rtc: ds3232-core: fix read on /dev/rtc after RTC_AIE_ON

In reply to Akinobu Mita

The rtctest (tools/testing/selftests/timers/rtctest.c) found that reading ds3232 rtc device immediately return the value 0x20 (RTC_AF) without waiting alarm interrupt.

This is because alarm_irq_enable() of ds3232 driver changes RTC_AF flag in rtc->irq_data. So calling ioctl with RTC_AIE_ON generates invalid value in rtc device.

The lower-level driver should not touch rtc->irq_data directly.

Cc Alessandro Zummo <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Jack Lan <[email protected]>
Cc Srikanth Srinivasan <[email protected]>
Cc Dennis Aberilla <[email protected]>
---
 drivers/rtc/rtc-ds3232-core.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/rtc/rtc-ds3232-core.c +3 -7
index a45a755..b4e8be8 100644
@@ -273,7 +273,7 @@ out:
 	return ret;
 }
 
-static void ds3232_update_alarm(struct device *dev)
+static void ds3232_update_alarm(struct device *dev, unsigned int enabled)
 {
 	struct ds3232 *ds3232 = dev_get_drvdata(dev);
 	int control;
@@ -303,7 +303,7 @@ static void ds3232_update_alarm(struct device *dev)
 	if (control < 0)
 		goto unlock;
 
-	if (ds3232->rtc->irq_data & (RTC_AF | RTC_UF))
+	if (enabled || (ds3232->rtc->irq_data & RTC_UF))
 		/* enable alarm1 interrupt */
 		control |= DS3232_REG_CR_A1IE;
 	else
@@ -322,12 +322,8 @@ static int ds3232_alarm_irq_enable(struct device *dev, unsigned int enabled)
 	if (ds3232->ops->irq(dev) <= 0)
 		return -EINVAL;
 
-	if (enabled)
-		ds3232->rtc->irq_data |= RTC_AF;
-	else
-		ds3232->rtc->irq_data &= ~RTC_AF;
+	ds3232_update_alarm(dev, enabled);
 
-	ds3232_update_alarm(dev);
 	return 0;
 }
 
Signature · 12 lines
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 [email protected].
For more options, visit https://groups.google.com/d/optout.