Skip to contentSkip to conversation

rtc: Add support for Intersil ISL12057 I2C RTC chip

PATCH Superseded Arnaud Ebalard 2 participants 4 messages Nov 18, 2013 – Nov 22, 2013

Subsystems (3)

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 rtc: Add support for Intersil ISL12057 I2C RTC chip

Intersil ISL12057 I2C RTC chip also supports two alarms. This patch only adds support for basic RTC functionalities (i.e. getting and setting time). Tests have been performed on NETGEAR ReadyNAS 102 w/ startup/shutdown scripts, hwclock, ntpdate and openntpd.

---
Hi,

In order to get at least some initial support for the chip available in mainline kernel (3.14 will have three users waiting for it: ReadyNAS 102, 104 and 2120), I decided to temporarily remove the alarm and IRQ related code I pushed earlier (see [1] below). I will submit a patch later to add back Alarm/IRQ support once I have understood how to correctly handle my use case described via existing RTC logic.

Anyway, comments are welcome on the patch!

Changes since previous v1:
- fixed return values for isl12057_i2c_{read,set}_regs()
- checked associated return paths

Changes since previous v0:
- removed alarm and IRQ related code
- Switched to isl for intersil (no existing driver has any reference to isil, even though this would be the recommended choice)
- Added intersil info in vendor-prefixes.txt file
- Added entry for ISL 12057 in I2C trivial-devices.txt file
- Added mutex protection for non atomic read/write

Now, regarding later submission of Alarm/IRQ functionality, here is the use case: on all 3 NETGEAR NAS above (102, 104 and RN2120), the Alarm interrupt pins of the ISL 12057 are not connected to the SoC, i.e. Linux kernel never gets warned via an interrupt when the alarm goes off. The reason is that the alarm interrupt pin is connected to some regulator which will power up the (previously off) device when the alarm goes off. It raises some questions for which I am looking for some supports from RTC maintainer and people familiar w/ RTC framework:

- Are there no previous example of such need from existing platform?
- How can this use case be supported? Tested?
- in usual context, what is the purpose of having an IRQ handler for such an alarm event: just acknowledge it and remove the alarm? Or are there other reasons?

As a side note, I want to repeat that previous code (the one I dropped from current patch) worked fine to get alarm installed (i.e. once the device powered off, it woke up as expected using the alarm). I was just unable to test the interrupt handling part, for the reason described above.

Cheers,

a+

[1]: http://thread.gmane.org/gmane.linux.drivers.devicetree/46581

 .../devicetree/bindings/i2c/trivial-devices.txt    |   1 +
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 drivers/rtc/Kconfig                                |   9 +
 drivers/rtc/Makefile                               |   1 +
 drivers/rtc/rtc-isl12057.c                         | 397 +++++++++++++++++++++
 5 files changed, 409 insertions(+)
 create mode 100644 drivers/rtc/rtc-isl12057.c
Documentation/devicetree/bindings/i2c/trivial-devices.txt +1 -0
index ad6a738..b57c71e 100644
@@ -37,6 +37,7 @@ fsl,mpr121		MPR121: Proximity Capacitive Touch Sensor Controller
 fsl,sgtl5000		SGTL5000: Ultra Low-Power Audio Codec
 infineon,slb9635tt	Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz)
 infineon,slb9645tt	Infineon SLB9645 I2C TPM (new protocol, max 400khz)
+isl,isl12057		Intersil ISL12057 I2C RTC Chip
 maxim,ds1050		5 Bit Programmable, Pulse-Width Modulator
 maxim,max1237		Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs
 maxim,max6625		9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index ce95ed1..507761a 100644
@@ -38,6 +38,7 @@ ibm	International Business Machines (IBM)
 idt	Integrated Device Technologies, Inc.
 img	Imagination Technologies Ltd.
 intercontrol	Inter Control Group
+isl	Intersil
 linux	Linux-specific binding
 lsi	LSI Corp. (LSI Logic)
 marvell	Marvell Technology Group Ltd.
drivers/rtc/Kconfig +9 -0
index 15f166a..bcc0c17 100644
@@ -304,6 +304,15 @@ config RTC_DRV_ISL12022
 	  This driver can also be built as a module. If so, the module
 	  will be called rtc-isl12022.
 
+config RTC_DRV_ISL12057
+       tristate "Intersil ISL12057"
+       help
+	  If you say yes here you get support for the Intersil ISL12057
+	  I2C RTC/Calendar chip.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-isl12057.
+
 config RTC_DRV_X1205
 	tristate "Xicor/Intersil X1205"
 	help
drivers/rtc/Makefile +1 -0
index 27b4bd8..6cd50e5 100644
@@ -58,6 +58,7 @@ obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o
 obj-$(CONFIG_RTC_DRV_IMXDI)	+= rtc-imxdi.o
 obj-$(CONFIG_RTC_DRV_ISL1208)	+= rtc-isl1208.o
 obj-$(CONFIG_RTC_DRV_ISL12022)	+= rtc-isl12022.o
+obj-$(CONFIG_RTC_DRV_ISL12057)  += rtc-isl12057.o
 obj-$(CONFIG_RTC_DRV_JZ4740)	+= rtc-jz4740.o
 obj-$(CONFIG_RTC_DRV_LP8788)	+= rtc-lp8788.o
 obj-$(CONFIG_RTC_DRV_LPC32XX)	+= rtc-lpc32xx.o
drivers/rtc/rtc-isl12057.c new file +397 -0

397 lines not on this page · raw message

Signature · 1 line
1.8.4.rc3
#1 lore raw

drivers/rtc/rtc-isl12057.c line 95

Quoted 3 lines · Arnaud Ebalard
drivers/rtc/rtc-isl12057.c new file +3 -0
+/* Block read. Returns 0 on success, or a negative errno. */
+static int isl12057_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[],
+				  unsigned len)

This looks like the device would work well with regmap (8 bit register, 8 bit data). This would save a bit of code here both for the I/O functions and also for some of the debugging functionality you have below like the proc file.

drivers/rtc/rtc-isl12057.c line 348

Quoted 1 line
drivers/rtc/rtc-isl12057.c new file +1 -0
+	dev_info(dev, "chip found, driver version " DRV_VERSION "\n");

This sort of print is generally frowned upon - it's not adding anything to the message already displayed by the RTC core on registration. It's probably best to remove the driver version too, the kernel is already versioned.

#2 lore raw
In reply to Arnaud Ebalard

Hi Mark,

Sorry for the delay, but I was somehow removed from the recipients in your reply. As I am not subscribed to rtc-linux, can you keep me in Cc:
next time?

Quoted 10 lines · Arnaud Ebalard

drivers/rtc/rtc-isl12057.c line 95

Quoted 4 lines
drivers/rtc/rtc-isl12057.c new file +3 -0
+/* Block read. Returns 0 on success, or a negative errno. */ 
+static int isl12057_i2c_read_regs(struct i2c_client *client, u8 reg, u8 buf[], 
+                                  unsigned len) 

This looks like the device would work well with regmap (8 bit register, 8 bit data). This would save a bit of code here both for the I/O functions and also for some of the debugging functionality you have below like the proc file.

Well, I am not familiar with regmap but if you can point me some simple rtc driver in existing ones which uses regmap, I will take a look and come with a regmap-based v3.

Quoted 6 lines
Quoted 1 line

+ dev_info(dev, "chip found, driver version " DRV_VERSION "\n");

This sort of print is generally frowned upon - it's not adding anything to the message already displayed by the RTC core on registration. It's probably best to remove the driver version too, the kernel is already versioned.

ok, will do.

Cheers,

a+

#3 lore raw
Quoted 3 lines · Arnaud Ebalard

Sorry for the delay, but I was somehow removed from the recipients in your reply. As I am not subscribed to rtc-linux, can you keep me in Cc:
next time?

This is because you're setting Reply-To the list so my mail program replaces your address with the list address (or the list is set to do that which is totally broken).

Quoted 3 lines

Well, I am not familiar with regmap but if you can point me some simple rtc driver in existing ones which uses regmap, I will take a look and come with a regmap-based v3.

include/linux/regmap.h - there's a lot of drivers using regmap in the kernel, I think most of the RTCs using it are doing so as part of MFDs so there's thin wrappers around the I/O functions.