History log of /linux-master/drivers/rtc/rtc-pcf8523.c
Revision Date Author Comments
# 787bcc98 27-Feb-2024 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: add suspend handlers for alarm IRQ

Ensure the RTC is able to wake up the system from suspend.

Link: https://lore.kernel.org/r/20240227211833.1820800-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 31b0cecb 05-May-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

rtc: Switch i2c drivers back to use .probe()

After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230505121136.1185653-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# dc87fad6 15-Mar-2023 Javier Carrasco <javier.carrasco@wolfvision.net>

rtc: pcf8523: remove unnecessary OR operation

The value variable is initialized to 0 and it is not used to set any
other bits rather than the one that defines the capacitor value. Setting
this capacitor value is the only purpose of the function where the
variable is defined and therefore the OR operation does not apply as a
way to foresee functionality extensions either.

Signed-off-by: Javier Carrasco <javier.carrasco@wolfvision.net>
Link: https://lore.kernel.org/r/20230315082021.2104452-3-javier.carrasco@wolfvision.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# b48cc753 15-Mar-2023 Javier Carrasco <javier.carrasco@wolfvision.net>

rtc: pcf8523: fix coding-style issues

Minor modifications for coding-style correctness (tabs, spaces and blank
lines before and after brackets). In total 7 errors, 3 warnings and 1
check where removed from the checkpatch output without damaging code
readability.

Signed-off-by: Javier Carrasco <javier.carrasco@wolfvision.net>
Link: https://lore.kernel.org/r/20230315082021.2104452-2-javier.carrasco@wolfvision.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 3542db1d 23-Jan-2023 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: use IRQ flags obtained from fwnode

Allow the IRQ type to be passed from the device tree if available as there
may be components changing the trigger type of the interrupt between the
RTC and the IRQ controller.

Link: https://lore.kernel.org/r/20230123200217.1236011-7-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# fe0157ba 29-Aug-2022 paulmn <paulmn@axis.com>

rtc: pcf8523: fix for stop bit

Bugfix for an issue detected when a goldcap capacitor gets
fully discharged due to a long absence of the power supply,
and then recharges again. The RTC failed to continue to keep
the real-time clock.

This was caused by the incorrect handling of the STOP bit in
the RTC internal register. This fix solves the problem.

Signed-off-by: paulmn <paulmn@axis.com>
Link: https://lore.kernel.org/r/20220829124639.10906-1-paulmn@axis.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 3f4a3322 10-Jun-2022 Stephen Kitt <steve@sk2.org>

rtc: use simple i2c probe

All these drivers have an i2c probe function which doesn't use the
"struct i2c_device_id *id" parameter, so they can trivially be
converted to the "probe_new" style of probe with a single argument.

This change was done using the following Coccinelle script, and fixed
up for whitespace changes:

@ rule1 @
identifier fn;
identifier client, id;
@@

- static int fn(struct i2c_client *client, const struct i2c_device_id *id)
+ static int fn(struct i2c_client *client)
{
...when != id
}

@ rule2 depends on rule1 @
identifier rule1.fn;
identifier driver;
@@

struct i2c_driver driver = {
- .probe
+ .probe_new
=
(
fn
|
- &fn
+ fn
)
,
};

Signed-off-by: Stephen Kitt <steve@sk2.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220610162346.4134094-1-steve@sk2.org


# e51cdef0 09-Mar-2022 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: let the core handle the alarm resolution

Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a
resolution of a minute. Also, the core will properly round down the alarm
instead of up.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220309162301.61679-15-alexandre.belloni@bootlin.com


# c1325e73 09-Mar-2022 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: switch to RTC_FEATURE_UPDATE_INTERRUPT

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20220309162301.61679-14-alexandre.belloni@bootlin.com


# 85bcb01f 09-Feb-2022 Victor Erminpour <victor.erminpour@oracle.com>

rtc: pcf8523: Fix GCC 12 warning

When building with automatic stack variable initialization, GCC 12
complains about variables defined outside of switch case statements.
Move variables outside the switch, which silences warnings:

./drivers/rtc/rtc-pcf8523.c:284:20: error: statement will never be executed [-Werror=switch-unreachable]
284 | u8 mode;
|

./drivers/rtc/rtc-pcf8523.c:245:21: error: statement will never be executed [-Werror=switch-unreachable]
245 | u32 value;
| ^~~~~

Signed-off-by: Victor Erminpour <victor.erminpour@oracle.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1644453027-886-1-git-send-email-victor.erminpour@oracle.com


# f8d4e4fa 18-Oct-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: add BSM support

Backup Switch Mode allows to select the strategy to use to switch from the
main power supply to the backup power supply. As before, the driver will
switch from standby mode to level mode but now only when it has never been
set.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211018153651.82069-5-alexandre.belloni@bootlin.com


# ebf48cbe 18-Oct-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: allow usage on ACPI platforms

Always provide an OF table to ensure ACPI platforms can also use this
driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211018153651.82069-4-alexandre.belloni@bootlin.com


# 7c176119 18-Oct-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: remove unecessary ifdefery

If CONFIG_OF is not defined, of_property_read_bool will return false which
is our default value

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211018153651.82069-3-alexandre.belloni@bootlin.com


# 5537752c 18-Oct-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: always compile pcf8523_rtc_ioctl

Compiling out pcf8523_rtc_ioctl saves about 5% of the generated machine
code. However, it certainly never happens as the RTC character device
interface is the most useful one and is probably always compiled in.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211018153651.82069-2-alexandre.belloni@bootlin.com


# 91f3849d 18-Oct-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: switch to regmap

Use regmap to access the RTC registers, this is a huge reduction in code
lines and generated code. Values on ARMv7:

text data bss dec hex
5180 132 0 5312 14c0 before
3900 132 0 4032 fc0 after

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211018153651.82069-1-alexandre.belloni@bootlin.com


# 7d7234a4 15-Oct-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: avoid reading BLF in pcf8523_rtc_read_time

BLF, battery low doesn't mean the time is imprecise or invalid, it simply mean
the backup battery has to be replaced. This information can be read using the
VL_READ ioctl.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211015192400.818254-1-alexandre.belloni@bootlin.com


# 4aa90c03 10-Jul-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: rename register and bit defines

arch/arm/mach-ixp4xx/include/mach/platform.h now gets included indirectly
and defines REG_OFFSET. Rename the register and bit definition to something
specific to the driver.

Fixes: 7fd70c65faac ("ARM: irqstat: Get rid of duplicated declaration")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210710211431.1393589-1-alexandre.belloni@bootlin.com


# a1cfe7cc 17-Apr-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: report oscillator failures

Report oscillator failures and invalid date/time on RTC_VL_READ.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210418002023.1000265-3-alexandre.belloni@bootlin.com


# 13e37b7f 17-Apr-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: add alarm support

Alarm support requires unconditionally disabling clock out because it is
using the int1 pin.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210418002023.1000265-2-alexandre.belloni@bootlin.com


# 94959a3a 17-Apr-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: remove useless define

Drop DRIVER_NAME as it is only used once

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210418002023.1000265-1-alexandre.belloni@bootlin.com


# 673536cc 17-Nov-2020 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: use BIT

Use the BIT macro to define register bits.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201118002747.1346504-3-alexandre.belloni@bootlin.com


# 219cc0f9 17-Nov-2020 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: set range

Set the th RTC range, it is a classic BCD RTC, considering 00 as a leap
year. Let the core handle range checking.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201118002747.1346504-2-alexandre.belloni@bootlin.com


# 88614405 17-Nov-2020 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: switch to devm_rtc_allocate_device

Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows
for further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201118002747.1346504-1-alexandre.belloni@bootlin.com


# df561f66 23-Aug-2020 Gustavo A. R. Silva <gustavoars@kernel.org>

treewide: Use fallthrough pseudo-keyword

Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>


# 244cf8f0 14-Dec-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: return meaningful value for RTC_VL_READ

REG_CONTROL3_BLF indicates the battery is low and needs to be replaced
soon.

Link: https://lore.kernel.org/r/20191214220259.621996-6-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 93966243 23-Nov-2019 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

rtc: pcf8523: Remove struct pcf8523

struct pcf8523 is referenced only by pcf8523_probe(). And member variable in
this is not referenced by any function. Remove struct pcf8523.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Link: https://lore.kernel.org/r/20191123090838.1619-1-nobuhiro1.iwamatsu@toshiba.co.jp
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

Based on 2 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license version 2 as
published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# 189927e7 19-Jan-2019 Sam Ravnborg <sam@ravnborg.org>

rtc: pcf8523: set xtal load capacitance from DT

Add support for specifying the xtal load capacitance in the DT node.
The pcf8523 supports xtal load capacitance of 7pF or 12.5pF.
If the rtc has the wrong configuration the time will
drift several hours/week.

The driver use the default value 12.5pF.

The DT may specify either 7000fF or 12500fF.
(The DT uses femto Farad to avoid decimal numbers).
Other values are warned and the driver uses the default value.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 7c617e0c 18-Dec-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: Add rv8523 compatible

The Microcrystal RV-8523 is compatible with the PCF8523.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# ecb4a353 05-Dec-2018 Baruch Siach <baruch@tkos.co.il>

rtc: pcf8523: don't return invalid date when battery is low

The RTC_VL_READ ioctl reports the low battery condition. Still,
pcf8523_rtc_read_time() happily returns invalid dates in this case.
Check the battery health on pcf8523_rtc_read_time() to avoid that.

Reported-by: Erik Čuk <erik.cuk@domel.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 22652ba7 19-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# bc3bee02 29-Sep-2017 Russell King <rmk+kernel@armlinux.org.uk>

rtc: pcf8523: add support for trimming the RTC oscillator

Add support for reading and writing the RTC offset register, converting
it to the corresponding parts-per-billion value.

When setting the drift, the PCF8523 has two modes: one applies the
adjustment every two hours, the other applies the adjustment every
minute. We select between these two modes according to which ever
gives the closest PPB value to the one requested.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# ede44c90 03-Mar-2016 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: pcf8523: properly handle oscillator stop bit

The time and date register of the pcf8223 are undefined after a power
reset. Properly handle the OS bit and return -EINVAL when that bit is set.

It is properly removed when setting the time.

This solves an issue where the time and date may be valid for
rtc_valid_tm() but is not the current time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# fbbf53f7 06-Nov-2015 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

rtc: pcf8523: refuse to write dates later than 2099

When the chip increments the YEAR register and it already holds
bin2bcd(99) it reads as 0 afterwards. With this behaviour the last valid
day (without trickery) that has a representation is 2099-12-31 23:59:59.
So refuse to write later dates.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# b2884543 10-Jul-2015 Krzysztof Kozlowski <krzk@kernel.org>

rtc: Drop owner assignment from i2c_driver

i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 35738392 06-May-2014 Chris Cui <chris.wei.cui@gmail.com>

drivers/rtc/rtc-pcf8523.c: fix month definition

PCF8523 uses 1-12 to represent month according to datasheet.
link: www.nxp.com/documents/data_sheet/PCF8523.pdf.

Signed-off-by: Chris Cui <chris.wei.cui@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# af99ef9c 03-Jul-2013 Sachin Kamat <sachin.kamat@linaro.org>

drivers/rtc/rtc-pcf8523.c: remove empty function

After the switch to devm_* functions and the removal of
rtc_device_unregister(), the 'remove' function does not do anything.
Delete it.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 288031bf 29-Apr-2013 Jingoo Han <jg1.han@samsung.com>

rtc: rtc-pcf8523: use devm_rtc_device_register()

devm_rtc_device_register() is device managed and makes cleanup
paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# f32bc70d 21-Feb-2013 Jesper Nilsson <jesper.nilsson@axis.com>

rtc-pcf8523: add low battery voltage support

Implement reading of the battery voltage low signal for rtc-pcf8523.

The bit is read-only and cannot be cleared by software, so no
clear function is implemented.

[akpm@linux-foundation.org: omit pcf8563_rtc_ioctl() if CONFIG_RTC_INTF_DEV=n]
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
Reviewed-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# f803f0d0 17-Dec-2012 Thierry Reding <thierry.reding@avionic-design.de>

rtc: add NXP PCF8523 support

Add an RTC driver for PCF8523 chips by NXP Semiconductors. No support is
currently provided for the alarm and interrupt functions. Only the time
and date functionality is implemented.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>