Skip to contentSkip to conversation

rtc: add support for maxim dallas rtc ds1343 and ds1344

PATCH In review RAGHAVENDRA GANIGA 2 participants 2 messages Apr 13, 2014 – Apr 14, 2014 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: add support for maxim dallas rtc ds1343 and ds1344

Quoted 1 line

From 54dad3ebbce5aba4d749a14d8173e94297e14b1a Mon Sep 17 00:00:00 2001

From: Raghavendra Ganiga <[email protected]>
Date: Sun, 13 Apr 2014 20:02:59 +0530
Subject: [PATCH] rtc: add support for maxim dallas rtc ds1343 and ds1344

This is patch to add support for
maxim dallas rtc ds1343 and ds1344

---
 drivers/rtc/Kconfig      |   10 +
 drivers/rtc/Makefile     |    1 +
 drivers/rtc/rtc-ds1343.c |  619 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 630 insertions(+)
 create mode 100644 drivers/rtc/rtc-ds1343.c
drivers/rtc/Kconfig +10 -0
index 2e565f8..eb5cdcb 100644
@@ -573,6 +573,16 @@ config RTC_DRV_DS1305
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-ds1305.
 
+config RTC_DRV_DS1343
+	tristate "Dallas/Maxim DS1343/DS1344"
+	help
+	  If you say yes here you get support for the
+	  Dallas/Maxim DS1343 and DS1344 real time clock chips.
+	  Support for trickle charger, alarm is provided.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-ds1343.
+
 config RTC_DRV_DS1347
 	tristate "Dallas/Maxim DS1347"
 	help
drivers/rtc/Makefile +1 -0
index 40a0991..a8daf6c 100644
@@ -40,6 +40,7 @@ obj-$(CONFIG_RTC_DRV_DS1286)	+= rtc-ds1286.o
 obj-$(CONFIG_RTC_DRV_DS1302)	+= rtc-ds1302.o
 obj-$(CONFIG_RTC_DRV_DS1305)	+= rtc-ds1305.o
 obj-$(CONFIG_RTC_DRV_DS1307)	+= rtc-ds1307.o
+obj-$(CONFIG_RTC_DRV_DS1343)	+= rtc-ds1343.o
 obj-$(CONFIG_RTC_DRV_DS1347)	+= rtc-ds1347.o
 obj-$(CONFIG_RTC_DRV_DS1374)	+= rtc-ds1374.o
 obj-$(CONFIG_RTC_DRV_DS1390)	+= rtc-ds1390.o
drivers/rtc/rtc-ds1343.c new file +619 -0

619 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#1 lore raw

drivers/rtc/rtc-ds1343.c line 73

Quoted 6 lines · RAGHAVENDRA GANIGA
drivers/rtc/rtc-ds1343.c new file +6 -0
+static const struct spi_device_id ds1343_id[] = {
+	{ "ds1343", 0 },
+	{ "ds1344", 1 },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, ds1343_id);

If the 0 and 1 mean anything there they should have #defines, otherwise just omit them.

drivers/rtc/rtc-ds1343.c line 97

Quoted 11 lines
drivers/rtc/rtc-ds1343.c new file +11 -0
+static int ds1343_get_reg(struct device *dev, unsigned char address,
+				unsigned char *buf)
+{
+	struct spi_device *spi = to_spi_device(dev);
+
+	/* MSB of the spi address                        _
+	   in this rtc should be zero for read operation R/W */
+	*buf = address;
+
+	return spi_write_then_read(spi, buf, 1, buf, 1);
+}

This and the set_reg() function look like you should be using regmap.

Quoted 6 lines
drivers/rtc/rtc-ds1343.c new file +6 -0
+static int ds1343_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
+{
+	switch (cmd) {
+#ifdef RTC_SET_CHARGE
+	case RTC_SET_CHARGE:
+	{

drivers/rtc/rtc-ds1343.c line 128

Quoted 10 lines
drivers/rtc/rtc-ds1343.c new file +10 -0
+		int val;
+
+		if (copy_from_user(&val, (int __user *)arg, sizeof(int)))
+			return -EFAULT;
+
+		return ds1343_set_reg(dev, DS1343_TRICKLE_REG, val);
+	}
+	break;
+#endif
+	}

What defines this? I notice that ds1302 also does this - is this device different enouh to need a separate driver?

drivers/rtc/rtc-ds1343.c line 454

Quoted 8 lines
drivers/rtc/rtc-ds1343.c new file +8 -0
+static irqreturn_t ds1343_irq(int irq, void *dev_id)
+{
+	struct ds1343_priv *priv = dev_id;
+
+	disable_irq_nosync(irq);
+	schedule_work(&priv->work);
+	return IRQ_HANDLED;
+}

Use request_threaded_irq() rather than open coding it.