summaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-rv8803.c
AgeCommit message (Collapse)Author
2021-12-02rtc: rv8803: Add support for the Epson RX8804 RTCFabio Estevam
The Epson RX8804 RTC has the same programming model as RV8803. Add support for it in the driver. Signed-off-by: Fabio Estevam <festevam@gmail.com> Reviewed-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20211130125830.1166194-2-festevam@gmail.com
2021-11-10rtc: rv8803: fix writing back ctrl in flag registerDominique Martinet
ctrl is set from read_regs(..FLAG, 2, ctrl), so ctrl[0] is FLAG and ctrl[1] is the CTRL register. Use ctrl[0] to write back to the FLAG register as appropriate. Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20211101013400.325855-1-dominique.martinet@atmark-techno.com
2021-02-06rtc: rv8803: quiet maybe-unused variable warningAlexandre Belloni
When CONFIG_OF is disabled then the matching table is not referenced. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210202112219.3610853-18-alexandre.belloni@bootlin.com
2021-01-16rtc: rv8803: constify rv8803_rtc_opsAlexandre Belloni
Use RTC_FEATURE_ALARM to signal to the core whether alarms are available instead of changing the global struct rtc_class_ops, allowing to make it const. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210110231752.1418816-17-alexandre.belloni@bootlin.com
2020-11-19rtc: rework rtc_register_device() resource managementBartosz Golaszewski
rtc_register_device() is a managed interface but it doesn't use devres by itself - instead it marks an rtc_device as "registered" and the devres callback for devm_rtc_allocate_device() takes care of resource release. This doesn't correspond with the design behind devres where managed structures should not be aware of being managed. The correct solution here is to register a separate devres callback for unregistering the device. While at it: rename rtc_register_device() to devm_rtc_register_device() and add it to the list of managed interfaces in devres.rst. This way we can avoid any potential confusion of driver developers who may expect there to exist a corresponding unregister function. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20201109163409.24301-8-brgl@bgdev.pl
2020-11-19rtc: add devm_ prefix to rtc_nvmem_register()Bartosz Golaszewski
rtc_nvmem_register() is a managed interface. It doesn't require any release function to be called at driver detach. To avoid confusing driver authors, let's rename it to devm_rtc_nvmem_register() and add it to the list of managed interfaces in Documentation/. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20201109163409.24301-6-brgl@bgdev.pl
2020-11-19rtc: nvmem: remove nvram ABIAlexandre Belloni
The nvram sysfs attributes have been deprecated at least since v4.13, more than 3 years ago and nobody ever complained about the deprecation warning. Remove the sysfs attributes now. [Bartosz: remove the declaration of rtc_nvmem_unregister()] Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Link: https://lore.kernel.org/r/20201109163409.24301-5-brgl@bgdev.pl
2020-09-29rtc: rv8803: simplify the return expression of rv8803_nvram_writeLiu Shixin
Simplify the return expression. Signed-off-by: Liu Shixin <liushixin2@huawei.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20200921082449.2591981-1-liushixin2@huawei.com
2019-12-18rtc: rv8803: return meaningful value for RTC_VL_READAlexandre Belloni
RV8803_FLAG_V1F means the voltage is too low to keep the temperature compensation running and the accuracy of the RTC is affected. RV8803_FLAG_V2F means the voltage dropped so low that data is now invalid. Link: https://lore.kernel.org/r/20191214220259.621996-16-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18rtc: rv8803: avoid clearing RV8803_FLAG_V2F in RTC_VL_CLRAlexandre Belloni
Stop clearing RV8803_FLAG_V2F in RTC_VL_CLR because it is a disservice to userspace as it removes the important information that the RTC data is invalid. This may lead userspace to set an invalid system time later on. Link: https://lore.kernel.org/r/20191214220259.621996-15-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-08-21rtc: remove superfluous error messageAlexandre Belloni
The RTC core now has error messages in case of registration failure, there is no need to have other messages in the drivers. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20190818220041.17833-2-alexandre.belloni@bootlin.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-06-09rtc: rv8803: simplify getting the adapter of a clientWolfram Sang
We have a dedicated pointer for that, so use it. Much easier to read and less computation involved. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-03-04rtc: update my email addressAlexandre Belloni
Use my current email address. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-03-04rtc: rv8803: convert to SPDX identifierAlexandre Belloni
Use SPDX-License-Identifier instead of a verbose license text. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-03-04rtc: rv8803: let the core handle rangeAlexandre Belloni
Let the core handle the RTC range instead of open coding it. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27rtc: rv8803: add Epson RX8803 supportAlexandre Belloni
The Epson rx8803 is mostly similar to the Microcrystal RV8803 but the size of the offset register is 4 bits vs 6 bits but it has a configurable temperature compensation. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27rtc: rv8803: fix the rv8803 id in the OF tableAlexandre Belloni
The ID for RV8803 must be rv_8803 Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01rtc: rv8803: fix possible race conditionAlexandre Belloni
The probe function is not allowed to fail after registering the RTC. Call rtc_register_device() at the end. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01rtc: rv8803: put struct nvmem_config on the stackAlexandre Belloni
Avoid allocating memory for struct nvmem_config. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01rtc: rv8803: call rtc_nvmem_register()Alexandre Belloni
Call rtc_nvmem_register instead of letting the core do it and stop using the nvmem_config member of struct rtc_device. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2017-07-07rtc: rv8803: remove rv8803_removeAlexandre Belloni
rv8803_remove() is now empty, remove it. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-07rtc: rv8803: use generic nvmem supportAlexandre Belloni
Instead of adding a binary sysfs attribute from the driver (which suffers from a race condition as the attribute appears after the device), use the core to register an nvmem device. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-07rtc: rv8803: switch to rtc_register_deviceAlexandre Belloni
This removes a possible race condition and allows for further improvement of the driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-03-09rtc: rv8803: Add OF device ID tableJavier Martinez Canillas
The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:<device>. But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-10-12rtc: rv8803: set VDETOFF and SWOFF via device treeOleksij Rempel
There might be designs where the power supply circuit is designed in a way that VDETOFF and SWOFF is required to be set. Otherwise the RTC detects a power loss. Add a device tree interface for this. Signed-off-by: Carsten Resch <Carsten.Resch@de.bosch.com> Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com> Signed-off-by: Oleksij Rempel <fixed-term.Oleksij.Rempel@de.bosch.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-07-28rtc: rv8803: Clear V1F when setting the timeBenoît Thébaudeau
V1F indicates that the time accuracy may have been compromised because of a voltage drop (possibly only temporary) below VLOW1, which stops the temperature compensation. When the time is set, the accuracy is restored, so V1F should be cleared in order to indicate this and to be able to detect the next temperature compensation loss. This is the same principle as for V2F, which is cleared when the time is set to indicate that the time is no longer invalid and to be able to detect the next data loss. Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-07-28rtc: rv8803: Stop the clock while setting the timeBenoît Thébaudeau
According to the application manual of the RX8900, the RESET bit must be set to 1 to prevent a timer update while setting the time. This also resets the subsecond counter. The application manual of the RV-8803 does not mention such a requirement, and it says that the 100th Seconds register is cleared when writing to the Seconds register, but using the RESET bit for the RV-8803 too should not be an issue and is probably safer. This change also ensures that the RESET bit is initialized properly in all cases. Indeed, all the registers must be initialized if the voltage has been lower than VLOW2 (triggering V2F), but not low enough to trigger a POR. Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-07-28rtc: rv8803: Always apply the I²C workaroundBenoît Thébaudeau
The I²C NACK issue of the RV-8803 may occur after any I²C START condition, depending on the timings. Consequently, the workaround must be applied for all the I²C transfers. This commit abstracts the I²C transfer code into register access functions. This avoids duplicating the I²C workaround everywhere. This also avoids the duplication of the code handling the return value of i2c_smbus_read_i2c_block_data(). Error messages are issued in case of definitive register access failures (if the workaround fails). This change also makes the I²C transfer return value checks consistent. Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-07-28rtc: rv8803: Fix read day of weekBenoît Thébaudeau
The Weekday register is encoded as 2^tm_wday, with tm_wday in 0..6, so using tm_wday = ffs(reg) to fill tm_wday from the register value is wrong because this gives the expected value + 1. This could be fixed as tm_wday = ffs(reg) - 1, but tm_wday = ilog2(reg) works as well and is more direct. Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-07-28rtc: rv8803: Remove the check for valid timeBenoît Thébaudeau
The RTC core always calls rtc_valid_tm() after ->read_time() in case of success (in __rtc_read_time()), so do not call it twice. Signed-off-by: Benoît Thébaudeau <benoit@wsystem.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-07-09rtc: simplify implementations of read_alarmUwe Kleine-König
Since commit d68778b80dd7 ("rtc: initialize output parameter for read alarm to "uninitialized"") there is no need to explicitly set unsupported members to -1. So drop the respective assignments from drivers. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-06-26rtc: rv8803: broaden workaroundAlexandre Belloni
The previous workaround may still fail as there are actually 4 retries to be done to ensure the communication succeed. Also, some I2C adapter drivers may return -EIO instead of -ENXIO. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-25rtc: rv8803: workaround i2c HW issueAlexandre Belloni
The rv8803 has a 60µs window where it will not answer on the i2c bus. It also means there will be no ack for the communication. Make sure communication is tried multiple times when this happens (the i2c subsystem mandates -ENXIO is that case but the number of retries is host specific). The critical parts are the probe function and the alarm callback so make sure we handle the failure there. Cc: stable@vger.kernel.org # v4.4 Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-14rtc: rv8803: convert spin_lock to mutex_lockOleksij Rempel
Fix a scheduling while atomic issue caused by rv8803_set_time() holding a spinlock during the call to i2c_smbus_read_byte_data(). Signed-off-by: Oleksij Rempel <fixed-term.Oleksij.Rempel@de.bosch.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: rv8803: Extend compatibility with the rx8900Gregory CLEMENT
The Seiko Epson's RTC RX8900 layout register is compatible with the RV8803. So let's add its ID in order to reuse the same driver. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: rv8803: fix handling return value of i2c_smbus_read_byte_dataAndrzej Hajda
The function can return negative values, so its result should be assigned to signed variable. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: Add a driver for Micro Crystal RV8803Alexandre Belloni
This driver supports the following functions: - reading and settings time - alarms when connected to an IRQ - reading and clearing the voltage low flags - nvram Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>