Skip to contentSkip to conversation

rtc: isl12026: Add driver.

PATCH In review David Daney 3 participants 4 messages Feb 22, 2018 – Mar 2, 2018

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

PATCH v6 1/1 rtc: isl12026: Add driver.

The ISL12026 is a combination RTC and EEPROM device with I2C interface. The standard RTC driver interface is provided. The EEPROM is accessed via the NVMEM interface via the "eeprom0" directory in the sysfs entry for the device.

---

Changes from v5:

o removed obsolete call to rtc_valid_tm().

Changes from v4:

o Rebased to rtc-next

o Improvements suggested by Alexandre Belloni

o Added Reviewed-by Rob Herring

Changes from v3:

o Add Reviewed-by

o s/dev_err/dev_warn/ in one place

o Remove redundant ','

Changes from v2:

o More code cleanups suggested by reviewers.

Changes from v1:

o Fixed device tree bindings document example.

o Use RTC_NVMEM facility for eeprom support.

o Small code cleanups suggested by reviewers.

 .../devicetree/bindings/rtc/isil,isl12026.txt      |  28 ++
 drivers/rtc/Kconfig                                |  10 +
 drivers/rtc/Makefile                               |   1 +
 drivers/rtc/rtc-isl12026.c                         | 505 +++++++++++++++++++++
 4 files changed, 544 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/isil,isl12026.txt
 create mode 100644 drivers/rtc/rtc-isl12026.c
Documentation/devicetree/bindings/rtc/isil,isl12026.txt new file +28 -0
new file mode 100644
index 000000000000..2e0be45193bb
@@ -0,0 +1,28 @@
+ISL12026 I2C RTC/EEPROM
+
+ISL12026 is an I2C RTC/EEPROM combination device.  The RTC and control
+registers respond at bus address 0x6f, and the EEPROM array responds
+at bus address 0x57.  The canonical "reg" value will be for the RTC portion.
+
+Required properties supported by the device:
+
+ - "compatible": must be "isil,isl12026"
+ - "reg": I2C bus address of the device (always 0x6f)
+
+Optional properties:
+
+ - "isil,pwr-bsw": If present PWR.BSW bit must be set to the specified
+                   value for proper operation.
+
+ - "isil,pwr-sbib": If present PWR.SBIB bit must be set to the specified
+                    value for proper operation.
+
+
+Example:
+
+	rtc@6f {
+		compatible = "isil,isl12026";
+		reg = <0x6f>;
+		isil,pwr-bsw = <0>;
+		isil,pwr-sbib = <1>;
+	}
drivers/rtc/Kconfig +10 -0
index f6d7e490e714..3bf649cd7b83 100644
@@ -407,6 +407,16 @@ 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_ISL12026
+	tristate "Intersil ISL12026"
+	depends on OF || COMPILE_TEST
+	help
+	  If you say yes here you get support for the
+	  Intersil ISL12026 RTC chip.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rtc-isl12026.
+
 config RTC_DRV_X1205
 	tristate "Xicor/Intersil X1205"
 	help
drivers/rtc/Makefile +1 -0
index 4fbf87e45a7c..f481661a6eae 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o
 obj-$(CONFIG_RTC_DRV_HYM8563)	+= rtc-hym8563.o
 obj-$(CONFIG_RTC_DRV_IMXDI)	+= rtc-imxdi.o
 obj-$(CONFIG_RTC_DRV_ISL12022)	+= rtc-isl12022.o
+obj-$(CONFIG_RTC_DRV_ISL12026)	+= rtc-isl12026.o
 obj-$(CONFIG_RTC_DRV_ISL1208)	+= rtc-isl1208.o
 obj-$(CONFIG_RTC_DRV_JZ4740)	+= rtc-jz4740.o
 obj-$(CONFIG_RTC_DRV_LP8788)	+= rtc-lp8788.o
drivers/rtc/rtc-isl12026.c new file +505 -0

505 lines not on this page · raw message

Signature · 1 line
2.14.3
#1 lore raw

Hi,

That's mostly good

Review

Quoted 2 lines · David Daney
(quoted diff) +2 -0
+	priv->rtc->ops = &isl12026_rtc_ops;
+	priv->rtc->nvram_old_abi = false;

This allocation is not necessary and I would refer not having t so when the ABI goes away, it is not necessary to change this driver.

Review

Quoted 6 lines
(quoted diff) +6 -0
+	ret = rtc_register_device(priv->rtc);
+	if (ret)
+		return ret;
+
+	memset(&nvm_cfg, 0, sizeof(nvm_cfg));
+	nvm_cfg.name = "eeprom";

You probably need something more descriptive, usually the rtc model name else, it is difficult (but not impossible) to find where this nvmem is actually located when using /sys/bus/nvmem/devices
isl12026- would be a good choice.

Review

Quoted 2 lines
(quoted diff) +2 -0
+	nvm_cfg.read_only = false;
+	nvm_cfg.root_only = true;

any reason to have it root only?

Review

Quoted 9 lines
(quoted diff) +9 -0
+	nvm_cfg.base_dev = &client->dev;
+	nvm_cfg.priv = priv;
+	nvm_cfg.stride = 1;
+	nvm_cfg.word_size = 1;
+	nvm_cfg.size = 512;
+	nvm_cfg.reg_read = isl12026_nvm_read;
+	nvm_cfg.reg_write = isl12026_nvm_write;
+
+	return rtc_nvmem_register(priv->rtc, &nvm_cfg);

The probe function must not fail after rtc_register_device has been called so you must return 0 here.

It is not currently possible to call rtc_nvmem_register before rtc_register_device unless we move the nvmem to the parent device:

drivers/rtc/nvmem.c +1 -1
index 3a02357eb783..17ec4c8d0fad 100644
@@ -91,7 +91,7 @@ int rtc_nvmem_register(struct rtc_device *rtc,
        if (!nvmem_config)
                return -ENODEV;
 
-       nvmem_config->dev = &rtc->dev;
+       nvmem_config->dev = rtc->dev.parent;
        nvmem_config->owner = rtc->owner;
        rtc->nvmem = nvmem_register(nvmem_config);
        if (IS_ERR_OR_NULL(rtc->nvmem))

I'll submit this patch for this cycle before there are many users of the interface (converted drivers are still exposing the old ABI).

If you prefer, you can depend on it.

Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

I am no longer able to test this patch as I lost access to the hardware.

If someone else wants to take charge of the patch, that would be great.

Sorry I couldn't drive this to completion,
David Daney

Quoted 72 lines · Alexandre Belloni

Hi,

That's mostly good

Review

Quoted 2 lines · David Daney
(quoted diff) +2 -0
+     priv->rtc->ops = &isl12026_rtc_ops;
+     priv->rtc->nvram_old_abi = false;

This allocation is not necessary and I would refer not having t so when the ABI goes away, it is not necessary to change this driver.

Review

Quoted 6 lines
(quoted diff) +6 -0
+     ret = rtc_register_device(priv->rtc);
+     if (ret)
+             return ret;
+
+     memset(&nvm_cfg, 0, sizeof(nvm_cfg));
+     nvm_cfg.name = "eeprom";

You probably need something more descriptive, usually the rtc model name else, it is difficult (but not impossible) to find where this nvmem is actually located when using /sys/bus/nvmem/devices
isl12026- would be a good choice.

Review

Quoted 2 lines
(quoted diff) +2 -0
+     nvm_cfg.read_only = false;
+     nvm_cfg.root_only = true;

any reason to have it root only?

Review

Quoted 9 lines
(quoted diff) +9 -0
+     nvm_cfg.base_dev = &client->dev;
+     nvm_cfg.priv = priv;
+     nvm_cfg.stride = 1;
+     nvm_cfg.word_size = 1;
+     nvm_cfg.size = 512;
+     nvm_cfg.reg_read = isl12026_nvm_read;
+     nvm_cfg.reg_write = isl12026_nvm_write;
+
+     return rtc_nvmem_register(priv->rtc, &nvm_cfg);

The probe function must not fail after rtc_register_device has been called so you must return 0 here.

It is not currently possible to call rtc_nvmem_register before rtc_register_device unless we move the nvmem to the parent device:

drivers/rtc/nvmem.c +1 -1
index 3a02357eb783..17ec4c8d0fad 100644
@@ -91,7 +91,7 @@ int rtc_nvmem_register(struct rtc_device *rtc,
        if (!nvmem_config)
                return -ENODEV;
 
-       nvmem_config->dev = &rtc->dev;
+       nvmem_config->dev = rtc->dev.parent;
        nvmem_config->owner = rtc->owner;
        rtc->nvmem = nvmem_register(nvmem_config);
        if (IS_ERR_OR_NULL(rtc->nvmem))

I'll submit this patch for this cycle before there are many users of the interface (converted drivers are still exposing the old ABI).

If you prefer, you can depend on it.

--
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering
https://bootlin.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 2 lines · David Daney

I am no longer able to test this patch as I lost access to the hardware.

Ah, too bad. I will take your patch as-is and then add a small patch to fixup the nvmem registration.

Quoted 80 lines

If someone else wants to take charge of the patch, that would be great.

Sorry I couldn't drive this to completion,
David Daney

Quoted 72 lines · Alexandre Belloni

Hi,

That's mostly good

Review

Quoted 2 lines · David Daney
(quoted diff) +2 -0
+     priv->rtc->ops = &isl12026_rtc_ops;
+     priv->rtc->nvram_old_abi = false;

This allocation is not necessary and I would refer not having t so when the ABI goes away, it is not necessary to change this driver.

Review

Quoted 6 lines
(quoted diff) +6 -0
+     ret = rtc_register_device(priv->rtc);
+     if (ret)
+             return ret;
+
+     memset(&nvm_cfg, 0, sizeof(nvm_cfg));
+     nvm_cfg.name = "eeprom";

You probably need something more descriptive, usually the rtc model name else, it is difficult (but not impossible) to find where this nvmem is actually located when using /sys/bus/nvmem/devices
isl12026- would be a good choice.

Review

Quoted 2 lines
(quoted diff) +2 -0
+     nvm_cfg.read_only = false;
+     nvm_cfg.root_only = true;

any reason to have it root only?

Review

Quoted 9 lines
(quoted diff) +9 -0
+     nvm_cfg.base_dev = &client->dev;
+     nvm_cfg.priv = priv;
+     nvm_cfg.stride = 1;
+     nvm_cfg.word_size = 1;
+     nvm_cfg.size = 512;
+     nvm_cfg.reg_read = isl12026_nvm_read;
+     nvm_cfg.reg_write = isl12026_nvm_write;
+
+     return rtc_nvmem_register(priv->rtc, &nvm_cfg);

The probe function must not fail after rtc_register_device has been called so you must return 0 here.

It is not currently possible to call rtc_nvmem_register before rtc_register_device unless we move the nvmem to the parent device:

drivers/rtc/nvmem.c +1 -1
index 3a02357eb783..17ec4c8d0fad 100644
@@ -91,7 +91,7 @@ int rtc_nvmem_register(struct rtc_device *rtc,
        if (!nvmem_config)
                return -ENODEV;
 
-       nvmem_config->dev = &rtc->dev;
+       nvmem_config->dev = rtc->dev.parent;
        nvmem_config->owner = rtc->owner;
        rtc->nvmem = nvmem_register(nvmem_config);
        if (IS_ERR_OR_NULL(rtc->nvmem))

I'll submit this patch for this cycle before there are many users of the interface (converted drivers are still exposing the old ABI).

If you prefer, you can depend on it.

--
Alexandre Belloni, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering
https://bootlin.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Alexandre Belloni, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com