Skip to contentSkip to conversation

Add Dallas DS1390/93/94 RTC chips

PATCH In review Mark Jackson 3 participants 3 messages Nov 6, 2008 – Nov 10, 2008

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

PATCH v6 1/1 Add Dallas DS1390/93/94 RTC chips

v6 (!!) of this patch with even more code tidying as per previous comments. Also only a single tx/rx buffer is used.
Now uses spi_write_then_read()
Comments changed to include extra chips in the family

This patch adds support for the Dallas DS1390/93/94 SPI RTC chip.

---
 drivers/rtc/Kconfig      |   11 +++
 drivers/rtc/Makefile     |    1 +
 drivers/rtc/rtc-ds1390.c |  220 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 232 insertions(+), 0 deletions(-)
drivers/rtc/Kconfig +11 -0
index 814f49f..6e921e7 100644
@@ -292,6 +292,17 @@ 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_DS1390
+	tristate "Dallas/Maxim DS1390/93/94"
+	help
+	  If you say yes here you get support for the DS1390/93/94 chips.
+
+	  This driver only supports the RTC feature, and not other chip
+	  features such as alarms and trickle charging.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-ds1390.
+
 config RTC_DRV_MAX6902
 	tristate "Maxim MAX6902"
 	help
drivers/rtc/Makefile +1 -0
index d6a9ac7..316c3ce 100644
@@ -28,6 +28,7 @@ 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_DS1374)	+= rtc-ds1374.o
+obj-$(CONFIG_RTC_DRV_DS1390)	+= rtc-ds1390.o
 obj-$(CONFIG_RTC_DRV_DS1511)	+= rtc-ds1511.o
 obj-$(CONFIG_RTC_DRV_DS1553)	+= rtc-ds1553.o
 obj-$(CONFIG_RTC_DRV_DS1672)	+= rtc-ds1672.o
drivers/rtc/rtc-ds1390.c new file +220 -0

220 lines not on this page · raw message

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

#1 lore raw
Quoted 1 line · On Thu, 06 Nov 2008 09:09:45 +0000 Mark Jackson <[email protected]> wrote:

v6 (!!) of this patch with even more code tidying as per previous comments.

I know.. I'm becoming stricter and stricter as the time goes by..

Quoted 5 lines

Also only a single tx/rx buffer is used.
Now uses spi_write_then_read()
Comments changed to include extra chips in the family

This patch adds support for the Dallas DS1390/93/94 SPI RTC chip.

There's still one printk left that you can avoid :)

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
Acked-by on v6 1/1
#2 lore raw
In reply to Mark Jackson
Quoted 8 lines · Mark Jackson

v6 (!!) of this patch with even more code tidying as per previous comments. Also only a single tx/rx buffer is used.
Now uses spi_write_then_read()
Comments changed to include extra chips in the family

This patch adds support for the Dallas DS1390/93/94 SPI RTC chip.

Although I wouldn't bother using the "wday" field at all. Linux doesn't use that field, so trying to maintain it isn't useful ... though it probably doesn't hurt, assuming the chip behaves OK when invalid data is written there.

Also, in probe():

Quoted 1 line

+       printk(KERN_INFO "DS1390 SPI RTC driver\n");

I dislike those banners in general. Best to remove that, since the RTC framework announces the registration. Or at least, dev_info().

drivers/rtc/rtc-ds1390.c line 162

Quoted 3 lines
drivers/rtc/rtc-ds1390.c new file +3 -0
+	spi->mode = SPI_MODE_3;
+	spi->bits_per_word = 8;
+	spi_setup(spi);

Unlikely to fail ... but

	res = spi_setup(spi);
	if (res < 0) {
		/* or do it before the kzalloc, no kfree
		 * ... likewise with reading the register
		 * as an "is it there" check:  do it earlier
		 * and get a similar minor codeshrink.
		 */
		kfree(chip);
		return res;
	}

drivers/rtc/rtc-ds1390.c line 174

Quoted 12 lines
drivers/rtc/rtc-ds1390.c new file +12 -0
+
+	dev_set_drvdata(&spi->dev, chip);
+
+	res = ds1390_get_reg(&spi->dev, DS1390_REG_SECONDS, &tmp);
+	if (res) {
+		dev_err(&spi->dev, "DS1390: unable to read device\n");
+		kfree(chip);
+		return res;
+	}
+
+	rtc = rtc_device_register("ds1390",
+				&spi->dev, &ds1390_rtc_ops, THIS_MODULE);

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/