History log of /linux-master/drivers/rtc/rtc-da9063.c
Revision Date Author Comments
# f5334aa8 05-Jan-2024 Biju Das <biju.das.jz@bp.renesas.com>

rtc: da9063: Use dev_err_probe()

Replace dev_err()->dev_err_probe() to simpilfy probe().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240105145344.204453-4-biju.das.jz@bp.renesas.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 4b60c32e 05-Jan-2024 Biju Das <biju.das.jz@bp.renesas.com>

rtc: da9063: Use device_get_match_data()

Replace of_match_node()->device_get_match_data() for
the data associated with device match.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240105145344.204453-3-biju.das.jz@bp.renesas.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 8681de64 05-Jan-2024 Biju Das <biju.das.jz@bp.renesas.com>

rtc: da9063: Make IRQ as optional

On some platforms (eg: RZ/{G2UL,Five} SMARC EVK), there is no IRQ
populated by default. Add irq optional support.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20240105145344.204453-2-biju.das.jz@bp.renesas.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# ed17a2bc 17-Jul-2023 Samuel Holland <samuel.holland@sifive.com>

rtc: da9063: Mark the alarm IRQ as a wake IRQ

This keeps the IRQ enabled during system suspend, if the RTC's wakeup
source is enabled. Since the IRQ is not required to wake from shutdown,
continue to add the wakeup source even if registering the wakeirq fails.
See commit 029d3a6f2f3c ("rtc: da9063: add as wakeup source").

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Link: https://lore.kernel.org/r/20230717190937.1301509-1-samuel.holland@sifive.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 029d3a6f 29-Nov-2021 Nikita Shubin <nikita.shubin@maquefel.me>

rtc: da9063: add as wakeup source

As da9063 RTC is not a real I2C client, but relies on da9063 MFD
driver, we need to explicitly mark da9063 RTC as a wakeup source
to be able to access class/rtc/rtcN/wakealarm sysfs entry
to set alarms, so we can wakeup from SHUTDOWN/RTC/DELIVERY mode.

As da9063 driver refuses to load without irq, we simply add it
as a wakeup source before registering rtc device.

Signed-off-by: Nikita Shubin <nikita.shubin@maquefel.me>
Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20211129072650.22686-1-nikita.shubin@maquefel.me


# a478c433 09-Nov-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: da9063: switch to RTC_FEATURE_UPDATE_INTERRUPT

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.
Also, let the core know that the alarm will truncate seconds as it only has
a minute resolution.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20211109234750.107115-1-alexandre.belloni@bootlin.com


# fdcfd854 09-Nov-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rework rtc_register_device() resource management

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


# a48c6224 06-Nov-2020 Kaixu Xia <kaixuxia@tencent.com>

rtc: da9063: Simplify bool comparison

Fix the following coccicheck warning:

./drivers/rtc/rtc-da9063.c:246:5-18: WARNING: Comparison to bool

Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1604649637-1014-1-git-send-email-kaixuxia@tencent.com


# 7da83f1b 04-Oct-2019 Krzysztof Kozlowski <krzk@kernel.org>

rtc: da9063: Handle invalid IRQ from platform_get_irq_byname()

platform_get_irq_byname() might return -errno which later would be
cast to an unsigned int and used in request_irq().

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Tested-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20191004150510.6278-1-krzk@kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# b599db3a 21-Mar-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: da9063: switch to rtc_time64_to_tm/rtc_tm_to_time64

Call the 64bit versions of rtc_tm time conversion now that the range is
enforced by the core.

Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 5ff404d1 21-Mar-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: da9063: set range

The DA9062 and DA9063 have a year register that can go up to 0x3F.

Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 737842e5 18-Mar-2019 Wolfram Sang <wsa+renesas@sang-engineering.com>

rtc: da9063: convert header to SPDX

Covnert the header of the source file to SPDX.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 882c5e55 01-Apr-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: da9063: set uie_unsupported when relevant

The DA9063AD doesn't support alarms on any seconds and its granularity is
the minute. Set uie_unsupported in that case.

Reported-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# bb54be13 02-Mar-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: diasemi: 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 before returning from the callback.

Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 2ad2c174 27-Nov-2015 Enrico Scholz <enrico.scholz@sigma-chemnitz.de>

rtc: da9063: avoid writing undefined data to rtc

driver did

| static void da9063_tm_to_data(struct rtc_time *tm, u8 *data,
| {
| const struct da9063_compatible_rtc_regmap *config = rtc->config;
|
| data[RTC_SEC] &= ~config->rtc_count_sec_mask;
| data[RTC_SEC] |= tm->tm_sec & config->rtc_count_sec_mask;
| ...
| }
| ...
| static int da9063_rtc_set_time(struct device *dev, struct rtc_time *tm)
| {
| ...
| u8 data[RTC_DATA_LEN];
| int ret;
|
| da9063_tm_to_data(tm, data, rtc);

which means that some bits of stack content (in 'data[]') was masked out
and written to the RTC.

Because da9063_tm_to_data() is used only by da9063_rtc_set_time() and
da9063_rtc_set_alarm(), we can write fields directly.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
Tested-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 77535ace 08-Dec-2015 Steve Twiss <stwiss.opensource@diasemi.com>

rtc: da9063: fix access ordering error during RTC interrupt at system power on

This fix alters the ordering of the IRQ and device registrations in the RTC
driver probe function. This change will apply to the RTC driver that supports
both DA9063 and DA9062 PMICs.

A problem could occur with the existing RTC driver if:

A system is started from a cold boot using the PMIC RTC IRQ to initiate a
power on operation. For instance, if an RTC alarm is used to start a
platform from power off.
The existing driver IRQ is requested before the device has been properly
registered.
i.e.
ret = devm_request_threaded_irq()
comes before
rtc->rtc_dev = devm_rtc_device_register();

In this case, the interrupt can be called before the device has been
registered and the handler can be called immediately. The IRQ handler
da9063_alarm_event() contains the function call

rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF);

which in turn tries to access the unavailable rtc->rtc_dev.

The fix is to reorder the functions inside the RTC probe. The IRQ is
requested after the RTC device resource has been registered so that
get_irq_byname is the last thing to happen.

Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# ce006ca6 02-Oct-2015 Steve Twiss <stwiss.opensource@diasemi.com>

rtc: da9063: GPL copyright inconsistency fix

Fix misleading and inconsistent copyright header wording.

Alter the copyright header text and MODULE_LICENSE macro to ensure the
GPL v2 licence description is correctly represented.

It will remove the incorrectly LGPL worded text. Words such as "Library"
from the line "GNU Library General Public License"; and replace the word
"library" with "program" in several other places.

The copyright should match the GPL v2 description as specified in the GNU
license found here: http://www.gnu.org/licenses/gpl-2.0.html

It should also match this copyright text with the correct MODULE_LICENSE
macro text as found in the kernel: include/linux/module.h
In this case "GNU Public License v2 or later" is linked with "GPL".

Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 73798d5c 27-Aug-2015 Javier Martinez Canillas <javier@osg.samsung.com>

rtc: Fix module autoload for OF platform drivers

These platform drivers have a OF device ID table but the OF module
alias information is not created so module autoloading won't work.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 80ca3277 21-Jul-2015 S Twiss <stwiss.opensource@diasemi.com>

rtc: da9063: Add DA9062 RTC capability to DA9063 RTC driver

Add DA9062 RTC support into the existing DA9063 RTC driver component by
using generic access tables for common register and bit mask definitions.

The following change will add generic register and bit mask support to the
DA9063 RTC. The changes are slightly complicated by requiring support for
three register sets: DA9063-AD, DA9063-BB and DA9062-AA.

The following alterations have been made to the DA9063 RTC:

- Addition of a da9063_compatible_rtc_regmap structure to hold all generic
registers and bitmasks for this type of RTC component.
- A re-write of struct da9063 to use pointers for regmap and compatible
registers/masks definitions
- Addition of a of_device_id table for DA9063 and DA9062 defaults
- Refactoring functions to use struct da9063_compatible_rtc accesses to
generic registers/masks instead of using defines from registers.h
- Re-work of da9063_rtc_probe() to use of_match_node() and dev_get_regmap()
to provide initialisation of generic registers and masks and access to
regmap

Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 0929ae37 20-Oct-2014 Wolfram Sang <wsa@kernel.org>

rtc: drop owner assignment from platform_drivers

A platform_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>


# 9cb42e2a 21-Jul-2014 Opensource [Steve Twiss] <stwiss.opensource@diasemi.com>

mfd: da9063: Add support for AD silicon variant

Add register definitions for DA9063 AD (0x3) silicon variant ID
the ability to choose the silicon variant at run-time using regmap
configuration. This patch also adds RTC support for the AD silicon
changes.

It adds both BB and AD support as regmap ranges and then makes the
distinction between the two tables at run-time. This allows both AD
and BB silicon variants to be supported at the same time.

Suggested-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Opensource [Steve Twiss] <stwiss.opensource@diasemi.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>


# c2a57550 06-Jun-2014 Opensource [Steve Twiss] <stwiss.opensource@diasemi.com>

rtc: da9063: RTC driver

Add the RTC driver for DA9063.

[akpm@linux-foundation.org: coding-style tweaks]
Signed-off-by: Opensource [Steve Twiss] <stwiss.opensource@diasemi.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Mark Brown <broonie@linaro.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Samuel Ortiz <sameo@linux.intel.com>
Cc: David Dajun Chen <david.chen@diasemi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>