History log of /linux-master/drivers/rtc/rtc-rx8010.c
Revision Date Author Comments
# 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>


# 4bbdced5 23-Jan-2023 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: rx8010: 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-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 782d3ebf 01-Feb-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: rx8010: quiet maybe-unused variable warning

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-19-alexandre.belloni@bootlin.com


# 2dbbedb9 19-Jan-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: rx8010: use rtc_lock/rtc_unlock

Avoid accessing directly rtc->ops_lock and use the RTC core helpers.

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


# aaaea29c 10-Jan-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: rx8010: drop a struct rtc_class_ops

Merge both struct rtc_class_ops in a single one and use RTC_FEATURE_ALARM
to signal to the core whether alarms are available.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210110231752.1418816-10-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


# ba1bcafb 17-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: rename rx8010_init_client() to rx8010_init()

Since the switch to using regmap this function no longer takes the
I2C client struct as argument nor do we even interact with the client
anywhere other than when creating the regmap.

Rename it to a less misleading name: "rx8010_init()".

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917114656.9036-1-brgl@bgdev.pl


# 2fc1af30 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: use range checking provided by core RTC code

We don't need to check the time range manually in set_time(), we can
use range_min and range_max exposed by struct rtc_device.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-15-brgl@bgdev.pl


# 9868bc1c 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: convert to using regmap

This driver requires SMBUS to work. We can relax this requirement if we
switch to using i2c regmap and let the regmap sub-system figure out how
to talk to the bus.

This also has the advantage of shrinking the code for register updates.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-14-brgl@bgdev.pl


# cee015d9 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: switch to using the preferred i2c API

We should generally use probe_new instead of probe when registering i2c
drivers. Convert rx8010 to using it.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-13-brgl@bgdev.pl


# 0ce62778 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: switch to using the preferred RTC API

Use devm_rtc_allocate_device() + rtc_register_device() instead of the
deprecated devm_rtc_device_register().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-12-brgl@bgdev.pl


# 666f2141 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: prefer sizeof(*val) over sizeof(struct type_of_val)

Using the size of the variable is preferred over using the size of its
type when allocating memory. Convert the call to devm_kzalloc() in
probe().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-11-brgl@bgdev.pl


# 955a123c 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: use a helper variable for client->dev in probe()

Simple 'dev' looks better then repeated &client->dev and has the added
benefit of avoiding unnecessary line breaks.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-10-brgl@bgdev.pl


# b3ff7fd6 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: drop unnecessary initialization

The 'err' local variable in rx8010_init_client() doesn't need to be
initialized.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-9-brgl@bgdev.pl


# f702699c 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: don't use magic values for time buffer length

The time buffer len is used directly in this driver. For readability
it's better to define it as the difference between the date register
offsets and use sizeof() whenever referencing it.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-8-brgl@bgdev.pl


# 13952c9e 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: rename ret to err in rx8010_set_time()

All other functions in this driver use 'err' for integer return values.
Do the same in rx8010_set_time() for consistency.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-7-brgl@bgdev.pl


# e9e4c2da 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: use tabs instead of spaces for code formatting

The define values in this driver are close to their names and they are
separated by spaces. Use tabs instead and align all defines.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-6-brgl@bgdev.pl


# 75677971 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: consolidate local variables of the same type

Move local variables of the same type into a single line for better
readability.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-5-brgl@bgdev.pl


# 28c86f30 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: remove unnecessary brackets

Remove brackets wherever they guard a single line.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-4-brgl@bgdev.pl


# 2e0ce569 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: remove a stray newline

Remove an unnecessary newline after requesting the interrupt.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200914154601.32245-3-brgl@bgdev.pl


# d3b14296 14-Sep-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rx8010: don't modify the global rtc ops

The way the driver is implemented is buggy for the (admittedly unlikely)
use case where there are two RTCs with one having an interrupt configured
and the second not. This is caused by the fact that we use a global
rtc_class_ops struct which we modify depending on whether the irq number
is present or not.

Fix it by using two const ops structs with and without alarm operations.
While at it: not being able to request a configured interrupt is an error
so don't ignore it and bail out of probe().

Fixes: ed13d89b08e3 ("rtc: Add Epson RX8010SJ RTC driver")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20200914154601.32245-2-brgl@bgdev.pl


# aeedfe7f 17-Dec-2019 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

rtc: rx8010: Fix return code for rx8010_probe

In the current code, the return value of devm_request_threaded_irq may be
returned. This fixes it.

CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
CC: Akshay Bhat <akshay.bhat@timesys.com>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Link: https://lore.kernel.org/r/20191217121231.2698817-2-iwamatsu@nigauri.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 8049c113 14-Dec-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: rx8010: return meaningful value for RTC_VL_READ

RX8010_FLAG_VLF means the voltage dropped too low and data has been lost.

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


# 894b0432 14-Dec-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: rx8010: remove RTC_VL_CLR handling

Remove RTC_VL_CLR handling 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-17-alexandre.belloni@bootlin.com
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>


# 9d085c54 07-Jun-2019 Wolfram Sang <wsa+renesas@sang-engineering.com>

rtc: rx8010: simplify getting the adapter of a client

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>


# 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>


# 804a6cfe 08-Nov-2017 Akshay Bhat <akshay.bhat@timesys.com>

rtc: rx8010: Fix for incorrect return value

The err variable is not being reset after a successful read. Explicitly
return 0 at the end of function call to account for all return paths.

Reported-by: Jens-Peter Oswald <oswald@lre.de>
Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# abf57f73 03-Nov-2017 Akshay Bhat <akshay.bhat@timesys.com>

rtc: rx8010: Specify correct address for RX8010_RESV31

Define for reserved register 31 had the incorrect address. Specify
the correct address.

Reported-by: Jens-Peter Oswald <oswald@lre.de>
Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# e0b6576f 03-Nov-2017 Akshay Bhat <akshay.bhat@timesys.com>

rtc: rx8010: Remove duplicate define

Remove duplicate define for RX8010_YEAR

Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 81b779ce 03-Mar-2017 Javier Martinez Canillas <javier@osg.samsung.com>

rtc: rx8010: Add OF device ID table

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>


# 666b5d1e 20-Dec-2016 Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>

rtc: rx8010: change lock mechanism

Remove spinlock and use the "rtc->ops_lock" from RTC subsystem instead.
spin_lock_irqsave() is not needed here because we do not have hard IRQs.

This patch fixes the following issue:

root@GE004097290448 b850v3:~# hwclock --systohc
root@GE004097290448 b850v3:~# hwclock --systohc
root@GE004097290448 b850v3:~# hwclock --systohc
root@GE004097290448 b850v3:~# hwclock --systohc
root@GE004097290448 b850v3:~# hwclock --systohc
[ 82.108175] BUG: spinlock wrong CPU on CPU#0, hwclock/855
[ 82.113660] lock: 0xedb4899c, .magic: dead4ead, .owner: hwclock/855, .owner_cpu: 1
[ 82.121329] CPU: 0 PID: 855 Comm: hwclock Not tainted 4.8.0-00042-g09d5410-dirty #20
[ 82.129078] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[ 82.135609] Backtrace:
[ 82.138090] [<8010d378>] (dump_backtrace) from [<8010d5c0>] (show_stack+0x20/0x24)
[ 82.145664] r7:ec936000 r6:600a0013 r5:00000000 r4:81031680
[ 82.151402] [<8010d5a0>] (show_stack) from [<80401518>] (dump_stack+0xb4/0xe8)
[ 82.158636] [<80401464>] (dump_stack) from [<8017b8b0>] (spin_dump+0x84/0xcc)
[ 82.165775] r10:00000000 r9:ec936000 r8:81056090 r7:600a0013 r6:edb4899c r5:edb4899c
[ 82.173691] r4:e5033e00 r3:00000000
[ 82.177308] [<8017b82c>] (spin_dump) from [<8017bcb0>] (do_raw_spin_unlock+0x108/0x130)
[ 82.185314] r5:edb4899c r4:edb4899c
[ 82.188938] [<8017bba8>] (do_raw_spin_unlock) from [<8094b93c>] (_raw_spin_unlock_irqrestore+0x34/0x54)
[ 82.198333] r5:edb4899c r4:600a0013
[ 82.201953] [<8094b908>] (_raw_spin_unlock_irqrestore) from [<8065b090>] (rx8010_set_time+0x14c/0x188)
[ 82.211261] r5:00000020 r4:edb48990
[ 82.214882] [<8065af44>] (rx8010_set_time) from [<80653fe4>] (rtc_set_time+0x70/0x104)
[ 82.222801] r7:00000051 r6:edb39da0 r5:edb39c00 r4:ec937e8c
[ 82.228535] [<80653f74>] (rtc_set_time) from [<80655774>] (rtc_dev_ioctl+0x3c4/0x674)
[ 82.236368] r7:00000051 r6:7ecf1b74 r5:00000000 r4:edb39c00
[ 82.242106] [<806553b0>] (rtc_dev_ioctl) from [<80284034>] (do_vfs_ioctl+0xa4/0xa6c)
[ 82.249851] r8:00000003 r7:80284a40 r6:ed1e9c80 r5:edb44e60 r4:7ecf1b74
[ 82.256642] [<80283f90>] (do_vfs_ioctl) from [<80284a40>] (SyS_ioctl+0x44/0x6c)
[ 82.263953] r10:00000000 r9:ec936000 r8:7ecf1b74 r7:4024700a r6:ed1e9c80 r5:00000003
[ 82.271869] r4:ed1e9c80
[ 82.274432] [<802849fc>] (SyS_ioctl) from [<80108520>] (ret_fast_syscall+0x0/0x1c)
[ 82.282005] r9:ec936000 r8:801086c4 r7:00000036 r6:00000000 r5:00000003 r4:0008e1bc
root@GE004097290448 b850v3:~#
Message from syslogd@GE004097290448 at Dec 3 11:17:08 ...
kernel:[ 82.108175] BUG: spinlock wrong CPU on CPU#0, hwclock/855

Message from syslogd@GE004097290448 at Dec 3 11:17:08 ...
kernel:[ 82.113660] lock: 0xedb4899c, .magic: dead4ead, .owner: hwclock/855, .owner_cpu: 1
hwclock --systohc
root@GE004097290448 b850v3:~#

Signed-off-by: Fabien Lahoudere <fabien.lahoudere@collabora.co.uk>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 56d86a7e 28-Jun-2016 Uwe Kleine-König <uwe@kleine-koenig.org>

rtc: simplify implementations of read_alarm

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>


# ed13d89b 03-Dec-2015 Akshay Bhat <akshay.bhat@timesys.com>

rtc: Add Epson RX8010SJ RTC driver

This driver supports the following functions:
- reading and setting time
- alarms when connected to an IRQ
- reading and clearing the voltage low flags

Datasheet:
http://www.epsondevice.com/docs/qd/en/DownloadServlet?id=ID000956
Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>