Commit graph

3906 commits

Author SHA1 Message Date
Uwe Kleine-König
5d78533a0c rtc: pcf2127: move watchdog initialisation to a separate function
The obvious advantages are:

 - The linker can drop the watchdog functions if CONFIG_WATCHDOG is off.
 - All watchdog stuff grouped together with only a single function call
   left in generic code.
 - Watchdog register is only read when it is actually used.
 - Less #ifdefery

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200924105256.18162-2-u.kleine-koenig@pengutronix.de
2020-10-27 12:18:28 +01:00
Linus Torvalds
b7769c45b8 RTC for 5.10
Subsystem:
  - new generic DT properties: aux-voltage-chargeable, trickle-voltage-millivolt
 
 New driver:
  - Microcrystal RV-3032
 
 Drivers:
  - ds1307: use aux-voltage-chargeable
  - r9701, rx8010: modernization of the driver
  - rv3028: fix clock output, trickle resistor values, RAM configuration
    registers
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAl+OCzsACgkQ2wIijOdR
 NOUtNg/+IyHLMgD/VzXWLKwbtBXk6bMgVBf2sqnMjEodEjt2nHryb3Rw5ndn41EC
 2rCILJK6atF8ZRJPUSLHUK/XHuPvrLSXdheHbTGZIOIiKE10DAKnwZ61AOhRDgsN
 9J2wbs6QhxDjRg5nSETPkBp7/iXC2M4hggpi86/VUNZ7bil8P8u76at16uh0phS2
 uCWXVqQZMR7nzwb6kIBSSrNsO0k1N0246NVPesGlz/cOGpVPkCP8SU8aGzOqjzLm
 GKmQkjlN5EjvBTw9mfdr2ZghHTx0NH/E004rkLy/XiszGrK9Urev2FAdAnYWkSff
 BMPmyTKVwnvguysgv+PEfr0M1NnAc4k6EJkMOFndaigYoXHJ6M0RFJPtsEavjkR/
 c4H82Q1VDtFuayXSYy/ovgmDYJA9OFQSkHCAzkt4cmBTYSM8QDmUpQnnBYGWvef+
 nBpCQUfy7R6cJglByCsJmqCIdy+p5AdBuy4ssalA9flZ9Vg+D3rGySJ/XCP2EDb+
 ezbSckK9FCC6PmajO6Ds4FD+UrBM5CyZl3mSMiNIA32kHBNEfGntxwrHlEu2LlDL
 fpgJa1WBKWATHc2jpfeLLqeP3qciPX32bfn70AbBmLZcxHtuEQ1W5gPkOK25bYP5
 nDrEzq9F9MW32KELOjdhKQu/8vrTIZuwqv7gg8WX+6gvgZjs3MQ=
 =o9I0
 -----END PGP SIGNATURE-----

Merge tag 'rtc-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "A new driver this cycle is making the bulk of the changes and the
  rx8010 driver has been rework to use the modern APIs.

  Summary:

  Subsystem:
   - new generic DT properties: aux-voltage-chargeable,
     trickle-voltage-millivolt

  New driver:
   - Microcrystal RV-3032

  Drivers:
   - ds1307: use aux-voltage-chargeable
   - r9701, rx8010: modernization of the driver
   - rv3028: fix clock output, trickle resistor values, RAM
     configuration registers"

* tag 'rtc-5.10' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (50 commits)
  rtc: r9701: set range
  rtc: r9701: convert to devm_rtc_allocate_device
  rtc: r9701: stop setting RWKCNT
  rtc: r9701: remove useless memset
  rtc: r9701: stop setting a default time
  rtc: r9701: remove leftover comment
  rtc: rv3032: Add a driver for Microcrystal RV-3032
  dt-bindings: rtc: rv3032: add RV-3032 bindings
  dt-bindings: rtc: add trickle-voltage-millivolt
  rtc: rv3028: ensure ram configuration registers are saved
  rtc: rv3028: factorize EERD bit handling
  rtc: rv3028: fix trickle resistor values
  rtc: rv3028: fix clock output support
  rtc: mt6397: Remove unused member dev
  rtc: rv8803: simplify the return expression of rv8803_nvram_write
  rtc: meson: simplify the return expression of meson_vrtc_probe
  rtc: rx8010: rename rx8010_init_client() to rx8010_init()
  rtc: ds1307: enable rx8130's backup battery, make it chargeable optionally
  rtc: ds1307: consider aux-voltage-chargeable
  rtc: ds1307: store previous charge default per chip
  ...
2020-10-21 11:22:08 -07:00
Alexandre Belloni
35331b506f rtc: r9701: set range
Set range and remove the set_time check. This is a classic BCD RTC.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201015191135.471249-6-alexandre.belloni@bootlin.com
2020-10-19 22:48:55 +02:00
Alexandre Belloni
dfe13cf2ae rtc: r9701: convert to devm_rtc_allocate_device
This allows further improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201015191135.471249-5-alexandre.belloni@bootlin.com
2020-10-19 22:48:55 +02:00
Alexandre Belloni
8b34134907 rtc: r9701: stop setting RWKCNT
tm_wday is never checked for validity and it is not read back in
r9701_get_datetime. Avoid setting it to stop tripping static checkers:

        drivers/rtc/rtc-r9701.c:109 r9701_set_datetime()
        error: undefined (user controlled) shift '1 << dt->tm_wday'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201015191135.471249-4-alexandre.belloni@bootlin.com
2020-10-19 22:48:55 +02:00
Alexandre Belloni
2a8f3380c9 rtc: r9701: remove useless memset
The RTC core already sets to zero the struct rtc_tie it passes to the
driver, avoid doing it a second time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201015191135.471249-3-alexandre.belloni@bootlin.com
2020-10-19 22:48:55 +02:00
Alexandre Belloni
7390bec4ed rtc: r9701: stop setting a default time
It doesn't make sense to set the RTC to a default value at probe time. Let
the core handle invalid date and time.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201015191135.471249-2-alexandre.belloni@bootlin.com
2020-10-19 22:48:55 +02:00
Alexandre Belloni
92c6dcfbd1 rtc: r9701: remove leftover comment
Commit 22652ba724 ("rtc: stop validating rtc_time in .read_time") removed
the code but not the associated comment.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201015191135.471249-1-alexandre.belloni@bootlin.com
2020-10-19 22:48:55 +02:00
Alexandre Belloni
2eeaa532ac rtc: rv3032: Add a driver for Microcrystal RV-3032
New driver for the Microcrystal RV-3032, including support for:
 - Date/time
 - Alarms
 - Low voltage detection
 - Trickle charge
 - Trimming
 - Clkout
 - RAM
 - EEPROM
 - Temperature sensor

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201013144110.1942218-3-alexandre.belloni@bootlin.com
2020-10-19 22:47:56 +02:00
Alexandre Belloni
024e6f3dce rtc: rv3028: ensure ram configuration registers are saved
If RV3028_CTRL1_EERD is not set (this is the default), the RTC will refresh
the RAM configuration registers from the EEPROM at midnight. It is
necessary to save the RAM registers back to EEPROM after modifying them.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201009153101.721149-4-alexandre.belloni@bootlin.com
2020-10-15 12:09:35 +02:00
Alexandre Belloni
de0ad60e79 rtc: rv3028: factorize EERD bit handling
Both rv3028_eeprom_write and rv3028_eeprom_read enable EERD before sending
commands to the EEPROM and restore it afterwards. Factorize this code.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201009153101.721149-3-alexandre.belloni@bootlin.com
2020-10-15 12:09:35 +02:00
Alexandre Belloni
c1efae1432 rtc: rv3028: fix trickle resistor values
Version 1.0 of the application manual had the wrong resistor values. Fix
them according to version 1.1

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201009153101.721149-2-alexandre.belloni@bootlin.com
2020-10-15 12:09:35 +02:00
Alexandre Belloni
00e8e87f10 rtc: rv3028: fix clock output support
rv3028_clkout_set_rate unconditionally sets RV3028_CLKOUT_CLKOE but
clk_set_rate may be called with the clock disabled. Ensure the clock is
kept disabled if it was not yet enabled.

Also, the actual rate was overwritten when enabling the clock, properly
write to the register only once.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201009153101.721149-1-alexandre.belloni@bootlin.com
2020-10-15 12:09:34 +02:00
Fei Shao
770c03e6da rtc: mt6397: Remove unused member dev
Removing the struct member "dev" in mt6397 RTC driver because it's not
initialized and the only usage is for one debugging message.

Also fixed a typo in the error message.

Signed-off-by: Fei Shao <fshao@chromium.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201008093414.1911699-1-fshao@chromium.org
2020-10-15 12:01:29 +02:00
Liu Shixin
179b4bcc4c rtc: rv8803: simplify the return expression of rv8803_nvram_write
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
2020-09-29 22:20:10 +02:00
Liu Shixin
9ce42e8e03 rtc: meson: simplify the return expression of meson_vrtc_probe
Simplify the return expression.

Signed-off-by: Liu Shixin <liushixin2@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Kevin Hilman <khilman@baylibre.com>
Link: https://lore.kernel.org/r/20200919100856.1639319-1-liushixin2@huawei.com
2020-09-29 22:19:15 +02:00
Bartosz Golaszewski
ba1bcafb29 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
2020-09-29 22:18:10 +02:00
Bastian Krause
0026f1604c rtc: ds1307: enable rx8130's backup battery, make it chargeable optionally
The ds1307 charger infrastructure now allows to add a rx8130 charger
setup that..

- does not depend on trickle-resistor-ohms
- does not use DS13XX_TRICKLE_CHARGER_MAGIC trickle-charge select (TCS)
  bits
- keeps previous no-charge behavior for device trees without
  aux-voltage-chargeable

Make that happen.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-9-bst@pengutronix.de
2020-09-24 09:56:04 +02:00
Bastian Krause
0874734e09 rtc: ds1307: consider aux-voltage-chargeable
Prefer aux-voltage-chargeable over trickle-diode-disable and set diode
accordingly. This is then passed to the chip's appropriate charge setup
function.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-8-bst@pengutronix.de
2020-09-24 09:56:04 +02:00
Bastian Krause
95a74cbb21 rtc: ds1307: store previous charge default per chip
Some RTC's batteries and supercaps were charged by default until now.
In contrast other RTCs allow charging but the driver did not configure
them to do so until now. These must not be charged by default to stay
backwards compatible.

In order to do that, store the charge default per chip.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-7-bst@pengutronix.de
2020-09-24 09:56:04 +02:00
Bastian Krause
1b5b6af788 rtc: ds1307: introduce requires_trickle_resistor per chip
Make trickle-resistor-ohms optional for charging setups that do not
require specifying ROUT bits (specifying the resistor value between Vcc
and Vbackup). In order to allow specifying that, introduce
requires_trickle_resistor per chip.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-6-bst@pengutronix.de
2020-09-24 09:56:04 +02:00
Bastian Krause
462eb736db rtc: ds1307: apply DS13XX_TRICKLE_CHARGER_MAGIC only conditionally
DS13XX_TRICKLE_CHARGER_MAGIC sets the trickle-charge select (TCS) bits
(7..4). The datasheet of Maxim Integrated's DS1339 [1] for instance
reads:

"To prevent accidental enabling, only a pattern on 1010 enables the
trickle charger. All other patterns disable the trickle charger."

Since not all RTCs connected to a backup battery or supercap use these
bits DS13XX_TRICKLE_CHARGER_MAGIC should not get applied for all charger
setups unconditionally.
Epson's RX8130 is such an example: Instead of TCS bits "SMPTSEL1",
"SMPTSEL0",  "CHGEN" and "INIEN" are expected as bit 7..4.

DS1339 and DS1340 are currently the only RTCs in the ds1307 driver that
apply DS13XX_TRICKLE_CHARGER_MAGIC to their setup register value. So
apply DS13XX_TRICKLE_CHARGER_MAGIC in do_trickle_setup_ds1339() which
is used by both RTCs.

[1] https://datasheets.maximintegrated.com/en/ds/DS1339-DS1339U.pdf
[2] https://support.epson.biz/td/api/doc_check.php?dl=app_RX8130CE

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-5-bst@pengutronix.de
2020-09-24 09:56:03 +02:00
Biwen Li
35425bafc7 rtc: pcf2127: fix a bug when not specify interrupts property
Fix a bug when not specify interrupts property in dts
as follows,
    rtc-pcf2127-i2c 1-0051: failed to request alarm irq
    rtc-pcf2127-i2c: probe of 1-0051 failed with error -22

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200915073213.12779-1-biwen.li@oss.nxp.com
2020-09-15 12:25:44 +02:00
Thomas Bogendoerfer
9f8010e71f rtc: ds1685: Fix bank switching to avoid endless loop
ds1685_rtc_begin_data_access() tried to access an extended register before
enabling access to it by switching to bank 1. Depending on content in NVRAM
this could lead to an endless loop. While at it fix also switch back to
bank 0 in ds1685_rtc_end_data_access().

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Joshua Kinard <kumba@gentoo.org>
Link: https://lore.kernel.org/r/20200910084124.138560-1-tsbogend@alpha.franken.de
2020-09-15 11:24:29 +02:00
Rikard Falkeborn
d0a3b65052 rtc: st-lpc: Constify st_rtc_ops
The only usage of st_rtc_ops is to assign its address to the ops field
in the rtc_device struct. which is a const pointer. Make it const to
allow the compiler to put it in read-only memory.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200913122644.35515-1-rikard.falkeborn@gmail.com
2020-09-15 11:21:50 +02:00
Bartosz Golaszewski
2fc1af3095 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
2020-09-15 10:50:38 +02:00
Bartosz Golaszewski
9868bc1ce2 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
2020-09-15 10:50:38 +02:00
Bartosz Golaszewski
cee015d90d 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
2020-09-15 10:50:38 +02:00
Bartosz Golaszewski
0ce627785a 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
2020-09-15 10:50:38 +02:00
Bartosz Golaszewski
666f21413b 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
955a123c14 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
b3ff7fd68d 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
f702699c67 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
13952c9e35 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
e9e4c2dae4 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
7567797199 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
28c86f30c9 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
2e0ce56910 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
2020-09-15 10:50:37 +02:00
Bartosz Golaszewski
d3b14296da 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: ed13d89b08 ("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
2020-09-15 10:50:37 +02:00
Krzysztof Kozlowski
c52d270c68 rtc: s3c: Simplify with dev_err_probe()
Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and the error value gets printed.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200830080937.14367-1-krzk@kernel.org
2020-09-15 10:42:36 +02:00
Gustavo A. R. Silva
df561f6688 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>
2020-08-23 17:36:59 -05:00
Peng Ma
0d982de3e2 rtc: fsl-ftm-alarm: update acpi device id
Original device id would conflict with crypto driver, change it.

Signed-off-by: Peng Ma <peng.ma@nxp.com>
Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200818063609.39859-1-ran.wang_1@nxp.com
2020-08-21 00:20:38 +02:00
Chris Packham
f471b05f76 rtc: ds1307: Clear OSF flag on DS1388 when setting time
Ensure the OSF flag is cleared on the DS1388 when the clock is set.

Fixes: df11b323b1 ("rtc: ds1307: handle oscillator failure flags for ds1388 variant")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200818013543.4283-1-chris.packham@alliedtelesis.co.nz
2020-08-21 00:19:55 +02:00
Chris Packham
59ed012715 rtc: ds1307: Ensure oscillator is enabled for DS1388
Similar to the other variants the DS1388 has a bit to stop the
oscillator to reduce the power consumption from VBAT. Ensure that the
oscillator is enabled when the system is up.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200816235731.21071-1-chris.packham@alliedtelesis.co.nz
2020-08-21 00:19:04 +02:00
Geert Uytterhoeven
163a512cd9 rtc: rtc-rs5c313: Convert to module_platform_driver()
Reduce boilerplate by using the module_platform_driver() helper.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200814110731.29029-4-geert+renesas@glider.be
2020-08-21 00:13:44 +02:00
Geert Uytterhoeven
f65e727464 rtc: rtc-rs5c313: Fix late hardware init
rs5c313_rtc_init() calls platform_driver_register(), and initializes the
hardware.  This is wrong because of two reasons:
  1. As soon as the driver has been registered, the device may be
     probed.  If devm_rtc_device_register() is called before hardware
     initialization, reading the current time will fail:

	rs5c313 rs5c313: rs5c313_rtc_read_time: timeout error
	rs5c313 rs5c313: registered as rtc0
	rs5c313 rs5c313: rs5c313_rtc_read_time: timeout error
	rs5c313 rs5c313: hctosys: unable to read the hardware clock

  2. If the platform device does not exist, the driver will still write
     to a hardware device that may not be present.

Fix this by moving the hardware initialization sequence to the driver's
.probe() method.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200814110731.29029-3-geert+renesas@glider.be
2020-08-21 00:13:44 +02:00
Geert Uytterhoeven
fc9656a370 rtc: rtc-rs5c313: Drop obsolete platform_set_drvdata() call
Commit 284e2fa1da ("rtc: rtc-rs5c313: use
devm_rtc_device_register()"), removed the last user of the
driver-specific data.  Hence there is no longer a need to set it.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200814110731.29029-2-geert+renesas@glider.be
2020-08-21 00:13:44 +02:00
Victor Ding
c254bcd723 rtc: cmos: zero-init wkalrm when reading from CMOS
cmos_read_alarm() may leave certain fields of a struct rtc_wkalrm
untouched; therefore, these fields contain garbage if not properly
initialized, leading to inconsistent values when converting into
time64_t. This patch to zero initialize the struct before calling
cmos_read_alarm().

Note that this patch is not intended to produce a correct time64_t, it
is only to produce a consistent value. In the case of suspend/resume, a
correct time64_t is not necessary; a consistent value is sufficient to
correctly perform an equality test for t_current_expires and
t_saved_expires. Logic to deduce a correct time64_t is expensive and
hence should be avoided.

Signed-off-by: Victor Ding <victording@google.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200814191654.v2.1.Iaf7638a2f2a87ff68d85fcb8dec615e41340c97f@changeid
2020-08-21 00:10:33 +02:00
Linus Torvalds
dc06fe51d2 RTC for 5.9
Drivers:
  - ds1374: use watchdog core
  - pcf2127: add alarm and pcf2129 support
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAl80X2sACgkQ2wIijOdR
 NOVP6A//Zbvv9M0NpB84u2LAc4e4C3Al4K4zRNVlM/lb8DHwbaaV54zUhm4YOVzr
 eG7ovpby2p31/YKnheImVlsbhoirM8RUgO1hZzlLPwsCRbAqCDHRlimUsKoAXyhm
 swnDVbaf3X5JTRotmRs+oaokFN5rE88f0BHkVva8hQB/86JJe21fYutEPDMWDe+Q
 DndYMc4KcsfcSvCUFn+N7dYmGtIQPiQXPqWJ4RDTL8PRPVuVz+wPD26pKgMX7ueG
 lExSIwuj8uSojv24z26z3e20ucyF4lDGULCwfcYewgSv81tWAqwQ+LGYMbq/KJmQ
 sSw2JrrOFR30ko6OAnb1QmgEibiPesrcDYTDEhj4XpmoMuHmOemIkdWe0kB5I6Ew
 Fr/mbyUwo0/F6JpwOTJhnk26LzU/BZvTEeneMr9utPPgVREbIUXHacggT5QWZCRL
 q7yZ/25nylHdoqyQVTsZ3SUTSId9VOS+Nq8RT5mUI1sluMa84r5DO8eNv345Gt2b
 m+s+T3vDW0q1P95ZiOeZnLFz5karphPluiQP0Cw84ZN8hXlhMJQWT9C9Pn5hPKfP
 nZf572vGoM2eSo0JavGLL+W6ay54QFS3Vf45zl3OuFwAAtmvRDLlLm6cOIr2qohk
 ddrZgBp+5Xf1LMGNxUy8TgUwqZvtiBfSQ1cI3Mt4wAo8W5tP4/s=
 =ZEHC
 -----END PGP SIGNATURE-----

Merge tag 'rtc-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "Not much this cycle - mostly non urgent driver fixes:

   - ds1374: use watchdog core

   - pcf2127: add alarm and pcf2129 support"

* tag 'rtc-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux:
  rtc: pcf2127: fix alarm handling
  rtc: pcf2127: add alarm support
  rtc: pcf2127: add pca2129 device id
  rtc: max77686: Fix wake-ups for max77620
  rtc: ds1307: provide an indication that the watchdog has fired
  rtc: ds1374: remove unused define
  rtc: ds1374: fix RTC_DRV_DS1374_WDT dependencies
  rtc: cleanup obsolete comment about struct rtc_class_ops
  rtc: pl031: fix set_alarm by adding back call to alarm_irq_enable
  rtc: ds1374: wdt: Use watchdog core for watchdog part
  rtc: Replace HTTP links with HTTPS ones
  rtc: goldfish: Enable interrupt in set_alarm() when necessary
  rtc: max77686: Do not allow interrupt to fire before system resume
  rtc: imxdi: fix trivial typos
  rtc: cpcap: fix range
2020-08-12 17:17:00 -07:00
Alexandre Belloni
27006416be rtc: pcf2127: fix alarm handling
Fix multiple issues when handling alarms:
 - Use threaded interrupt to avoid scheduling when atomic
 - Stop matching on week day as it may not be set correctly
 - Avoid parsing the DT interrupt and use what is provided by the i2c or
   spi subsystem
 - Avoid returning IRQ_NONE in case of error in the interrupt handler
 - Never write WDTF as specified in the datasheet
 - Set uie_unsupported, as for the pcf85063, setting alarms every seconds
   is not working correctly and confuses the RTC.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200812085114.474903-1-alexandre.belloni@bootlin.com
2020-08-12 11:48:29 +02:00
Liam Beguin
8a914bac44 rtc: pcf2127: add alarm support
Add alarm support for the pcf2127 RTC chip family.
Tested on pca2129.

Signed-off-by: Liam Beguin <lvb@xiphos.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Bruno Thomsen <bruno.thomsen@gmail.com>
Link: https://lore.kernel.org/r/20200630024211.12782-3-liambeguin@gmail.com
2020-08-12 11:37:37 +02:00
Liam Beguin
985b30dbe2 rtc: pcf2127: add pca2129 device id
The PCA2129 is the automotive grade version of the PCF2129.
add it to the list of compatibles.

Signed-off-by: Liam Beguin <lvb@xiphos.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Bruno Thomsen <bruno.thomsen@gmail.com>
Link: https://lore.kernel.org/r/20200630024211.12782-2-liambeguin@gmail.com
2020-08-12 11:37:37 +02:00
Jon Hunter
16c2480112 rtc: max77686: Fix wake-ups for max77620
Following commit d8f090dbea ("rtc: max77686: Do not allow interrupt to
fire before system resume"), RTC wake-ups stopped working on Jetson TX2
and Jetson Xavier platforms. The Jetson TX2 uses the max77620 PMIC and
the Jetson Xavier uses max20024 PMIC. Both of these PMICs have the same
max77620 RTC controller.

For the max77620 RTC, the variable 'rtc_irq_from_platform' is defined as
true in the max77686 driver and because of this the IRQ passed to the
max77686 driver for RTC is the PMIC IRQ and not the parent. Hence,
following commit d8f090dbea ("rtc: max77686: Do not allow interrupt to
fire before system resume"), for the max77620 the RTC IRQ within the
PMIC is now getting disabled on entry to suspend and unable to wake the
system up. Fix this by only disabling interrupts on entry to suspend
in the max77686 RTC driver, if the interrupt is the parent interrupt.

Fixes: d8f090dbea ("rtc: max77686: Do not allow interrupt to fire before system resume")
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Tested-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20200806125431.699339-1-jonathanh@nvidia.com
2020-08-07 23:29:47 +02:00
Chris Packham
9bf1306257 rtc: ds1307: provide an indication that the watchdog has fired
There's not much feedback when the ds1388 watchdog fires. Generally it
yanks on the reset line and the board reboots. Capture the fact that the
watchdog has fired in the past so that userspace can retrieve it via
WDIOC_GETBOOTSTATUS. This should help distinguish a watchdog triggered
reset from a power interruption.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200727034615.19755-1-chris.packham@alliedtelesis.co.nz
2020-08-05 01:07:09 +02:00
Alexandre Belloni
3d6cfb36ed rtc: ds1374: remove unused define
Remove unused define and fix typo where it should have been used.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200720075250.1019172-2-alexandre.belloni@bootlin.com
2020-07-21 09:56:46 +02:00
Alexandre Belloni
c7f3be4c94 rtc: ds1374: fix RTC_DRV_DS1374_WDT dependencies
It is not enough to select WATCHDOG_CORE, the watchdog part of the driver
now also depends on WATCHDOG. This is currently the best we can do because
alarm support and watchdog support are mutually exclusive.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Link: https://lore.kernel.org/r/20200720075250.1019172-1-alexandre.belloni@bootlin.com
2020-07-21 09:56:34 +02:00
Sudeep Holla
4df2ef85f0 rtc: pl031: fix set_alarm by adding back call to alarm_irq_enable
Commit c8ff5841a9 ("rtc: pl031: switch to rtc_time64_to_tm/rtc_tm_to_time64")
seemed to have accidentally removed the call to pl031_alarm_irq_enable
from pl031_set_alarm while switching to 64-bit apis.

Let us add back the same to get the set alarm functionality back.

Fixes: c8ff5841a9 ("rtc: pl031: switch to rtc_time64_to_tm/rtc_tm_to_time64")
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Tested-by: Valentin Schneider <valentin.schneider@arm.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200714124556.20294-1-sudeep.holla@arm.com
2020-07-16 11:27:03 +02:00
Johnson CH Chen (陳昭勳)
d3de4beb14 rtc: ds1374: wdt: Use watchdog core for watchdog part
Let ds1374 watchdog use watchdog core functions. It also includes
improving watchdog timer setting and nowayout, and just uses ioctl()
of watchdog core.

Signed-off-by: Johnson Chen <johnsonch.chen@moxa.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/HK2PR01MB328182D5A54BFAA8A22E448AFA640@HK2PR01MB3281.apcprd01.prod.exchangelabs.com
2020-07-16 11:24:06 +02:00
Alexander A. Klimov
3567d3d147 rtc: Replace HTTP links with HTTPS ones
Rationale:
Reduces attack surface on kernel devs opening the links for MITM
as HTTPS traffic is much harder to manipulate.

Deterministic algorithm:
For each file:
  If not .svg:
    For each line:
      If doesn't contain `\bxmlns\b`:
        For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
          If both the HTTP and HTTPS versions
          return 200 OK and serve the same content:
            Replace HTTP with HTTPS.

Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200706062727.18481-1-grandmaster@al2klimov.de
2020-07-16 11:17:52 +02:00
Huacai Chen
22f8d5a1bf rtc: goldfish: Enable interrupt in set_alarm() when necessary
When use goldfish rtc, the "hwclock" command fails with "select() to
/dev/rtc to wait for clock tick timed out". This is because "hwclock"
need the set_alarm() hook to enable interrupt when alrm->enabled is
true. This operation is missing in goldfish rtc (but other rtc drivers,
such as cmos rtc, enable interrupt here), so add it.

Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1592654683-31314-1-git-send-email-chenhc@lemote.com
2020-07-16 11:15:43 +02:00
Krzysztof Kozlowski
d8f090dbea rtc: max77686: Do not allow interrupt to fire before system resume
The rtc-max77686 device shares the main interrupt line with parent MFD
device (max77686 driver).  During the system suspend, the parent MFD
device disables this IRQ to prevent an early event happening before
resuming I2C bus controller.

The same should be done by rtc-max77686 driver because otherwise the
interrupt handler max77686_rtc_alarm_irq() will be called before its
resume function (max77686_rtc_resume()).  Such issue is not fatal but
disabling shared IRQ by all users ensures correct behavior.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200615161455.4420-1-krzk@kernel.org
2020-07-16 11:13:45 +02:00
Tales L. da Aparecida
05513a706b rtc: imxdi: fix trivial typos
Fix typos 'pionter' -> 'pointer' and 'softwere' -> 'software'

Signed-off-by: Tales L. da Aparecida <tales.aparecida@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200624012119.54768-1-tales.aparecida@gmail.com
2020-07-02 22:32:01 +02:00
Sebastian Reichel
3180cfabf6 rtc: cpcap: fix range
Unbreak CPCAP driver, which has one more bit in the day counter
increasing the max. range from 2014 to 2058. The original commit
introducing the range limit was obviously wrong, since the driver
has only been written in 2017 (3 years after 14 bits would have
run out).

Fixes: d2377f8cc5 ("rtc: cpcap: set range")
Reported-by: Sicelo A. Mhlongo <absicsz@gmail.com>
Reported-by: Dev Null <devnull@uvos.xyz>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Tested-by: Merlijn Wajer <merlijn@wizzup.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Merlijn Wajer <merlijn@wizzup.org>
Link: https://lore.kernel.org/r/20200629114123.27956-1-sebastian.reichel@collabora.com
2020-07-02 22:32:00 +02:00
Mike Rapoport
fa4b9519f0 rtc: remove fb-puv3 driver
The unicore32 port is removed from the kernel.
There is no point to keep stale RTC driver for this architecture.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Guenter Roeck <linux@roeck-us.net>
2020-07-01 12:10:59 +03:00
Linus Torvalds
e8dff03aef RTC for 5.8
Subsystem:
  - new VL flag for backup switch over
 
 Drivers:
  - ingenic: only support device tree
  - pcf2127: report battery switch over, handle nowayout
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAl7dWSkACgkQ2wIijOdR
 NOXGbQ//cSTxUJbuYBNi/VCV7J3/khGlyoQQqDsru/tzuEwXHGBoG2LRNQMOauWd
 2Osg61VQj4IY+WCqp4+ivn5H0K26y1PPKkt+UmrlRgkl0eeDFWmY4ejpziZ85D7Z
 kDlzcUi3YWkd6m4YSJJrtdCcKljBMIEXb/PEKKK9y6dkrcG5990N8JchpmkCzrjx
 fTPVIOfxu43msDc5b8egUDzPYnNbFw3ERAeasr6/EGTz+ksCspXtvWDk/mJzum0G
 FiermTkO499Dr66Nf0AS3ex9SvEoqH+kd9KA1CKii5OlYEl7K9sI+eSmTQ1EutZO
 L5WAvvQdW8UkARo6R4HAobhwK27pL+wpzUljbyXxt940/RTeqp82kl7rnH+0ihU7
 tTbR2Vu+uwWrfQbPkCCj0TJmqIHgam5/Vhn1+ZR2f4U2JIlPvvHoLRVKO0oP7XKK
 1ZDcP8zc9V2LQ2G2M1/ec6eOmoGW3EZDnKp4hcv9mnEiePSvVn04t5sa83NjNs4R
 e+awVY1x5pFwoXu99gjlfQTV2kTyaA7Jywp6gIO7BKaw/Ci3+d3tlpowfsDH+UVI
 WwKxNNqmuNXqoIep0zqUhqXHNIizKxGEk8wE4mr8HP2SlGJ+lUHAyrTTdpLeinN1
 5qTEPT3BhjExSFfDZQyWV3+CzKMvxtfFA4/Ca/0iSoaqzMZpm1E=
 =dsKr
 -----END PGP SIGNATURE-----

Merge tag 'rtc-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "Not much this cycle apart from the ingenic rtc driver rework.

  The fixes are mainly minor issues reported by coccinelle rather than
  real world issues.

  Subsystem:

   - new VL flag for backup switch over

  Drivers:

   - ingenic: only support device tree

   - pcf2127: report battery switch over, handle nowayout"

* tag 'rtc-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (29 commits)
  rtc: pcf2127: watchdog: handle nowayout feature
  rtc: fsl-ftm-alarm: fix freeze(s2idle) failed to wake
  rtc: abx80x: Provide debug feedback for invalid dt properties
  rtc: abx80x: Add Device Tree matching table
  rtc: rv3028: Add missed check for devm_regmap_init_i2c()
  rtc: mpc5121: Use correct return value for mpc5121_rtc_probe()
  rtc: goldfish: Use correct return value for goldfish_rtc_probe()
  rtc: snvs: Add necessary clock operations for RTC APIs
  rtc: snvs: Make SNVS clock always prepared
  rtc: ingenic: Reset regulator register in probe
  rtc: ingenic: Fix masking of error code
  rtc: ingenic: Remove unused fields from private structure
  rtc: ingenic: Set wakeup params in probe
  rtc: ingenic: Enable clock in probe
  rtc: ingenic: Use local 'dev' variable in probe
  rtc: ingenic: Only support probing from devicetree
  rtc: mc13xxx: fix a double-unlock issue
  rtc: stmp3xxx: update contact email
  rtc: max77686: Use single-byte writes on MAX77620
  rtc: pcf2127: report battery switch over
  ...
2020-06-07 16:11:23 -07:00
Linus Torvalds
3b69e8b457 Fix for arch/sh build regression with newer binutils, removal of SH5,
fixes for module exports, and misc cleanup.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.12 (GNU/Linux)
 
 iQEcBAABAgAGBQJe28l0AAoJELcQ+SIFb8HaKFMH/0T7tHfWit4+efmeDLhfrewd
 Fq9lLnEGmLy82AZqmd730gvD2ckbjUCm0ikKC79sCd14r3bIB1RCDKfXbY6rB3uI
 EDijbkzsjfOYG9ZAiDYTIbyrM2u2/1PzFiYTxHVDtPLbCPGfacbcfrDL+u143IXP
 ez/RHGLE6uYDvKi0Y0/VDKgMCW9bNlcEkL2/tKFVg2cipDi2Lfmi3Jss/id+5uOI
 N8XeZoyHjyWr7GeRZwN/hNPLDvLY//Uf5q6RB9VrTsN4Vrja7kjWMZkgsGkmGbNo
 f6BbLenq+KMfOSJrIzS3MgTRinoqRF5S518pkbGtgRQn0rZKfd6h85DG15RlPGk=
 =Ktnp
 -----END PGP SIGNATURE-----

Merge tag 'sh-for-5.8' of git://git.libc.org/linux-sh

Pull arch/sh updates from Rich Felker:
 "Fix for arch/sh build regression with newer binutils, removal of SH5,
  fixes for module exports, and misc cleanup"

* tag 'sh-for-5.8' of git://git.libc.org/linux-sh:
  sh: remove sh5 support
  sh: add missing EXPORT_SYMBOL() for __delay
  sh: Convert ins[bwl]/outs[bwl] macros to inline functions
  sh: Convert iounmap() macros to inline functions
  sh: Add missing DECLARE_EXPORT() for __ashiftrt_r4_xx
  sh: configs: Cleanup old Kconfig IO scheduler options
  arch/sh: vmlinux.scr
  sh: Replace CONFIG_MTD_M25P80 with CONFIG_MTD_SPI_NOR in sh7757lcr_defconfig
  sh: sh4a: Bring back tmu3_device early device
2020-06-06 15:22:01 -07:00
Bruno Thomsen
4601e24a6f rtc: pcf2127: watchdog: handle nowayout feature
Driver does not use module parameter for nowayout, so it need to
statically initialize status variable of the watchdog_device based
on CONFIG_WATCHDOG_NOWAYOUT.

Signed-off-by: Bruno Thomsen <bruno.thomsen@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200604162602.76524-1-bruno.thomsen@gmail.com
2020-06-06 00:34:16 +02:00
Ran Wang
3a8ce46ce1 rtc: fsl-ftm-alarm: fix freeze(s2idle) failed to wake
Use dev_pm_set_wake_irq() instead of flag IRQF_NO_SUSPEND to enable
wakeup system feature for both freeze(s2idle) and mem(deep).

Signed-off-by: Ran Wang <ran.wang_1@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200601071914.36444-1-ran.wang_1@nxp.com
2020-06-06 00:31:51 +02:00
Kevin P. Fleming
6e429f6b8c rtc: abx80x: Provide debug feedback for invalid dt properties
When the user provides an invalid value for tc-diode or
tc-resistor generate a debug message instead of silently
ignoring it.

Signed-off-by: Kevin P. Fleming <kevin+linux@km6g.us>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200530122956.360689-1-kevin+linux@km6g.us
2020-06-06 00:16:24 +02:00
Arnd Bergmann
37744feebc sh: remove sh5 support
sh5 never became a product and has probably never really worked.

Remove it by recursively deleting all associated Kconfig options
and all corresponding files.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Rich Felker <dalias@libc.org>
2020-06-01 14:48:52 -04:00
Kevin P. Fleming
ac363ace16 rtc: abx80x: Add Device Tree matching table
Enable automatic loading of the module when a Device Tree overlay
specifies a device supported by this driver.

Signed-off-by: Kevin P. Fleming <kevin+linux@km6g.us>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200528114617.166587-1-kevin+linux@km6g.us
2020-05-30 04:13:46 +02:00
Chuhong Yuan
c3b29bf6f1 rtc: rv3028: Add missed check for devm_regmap_init_i2c()
rv3028_probe() misses a check for devm_regmap_init_i2c().
Add the missed check to fix it.

Fixes: e6e7376cfd ("rtc: rv3028: add new driver")
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200528103950.912353-1-hslester96@gmail.com
2020-05-30 04:12:43 +02:00
Tiezhu Yang
710e4a82d6 rtc: mpc5121: Use correct return value for mpc5121_rtc_probe()
When call function devm_platform_ioremap_resource(), we should use IS_ERR()
to check the return value and return PTR_ERR() if failed.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1590370788-15136-2-git-send-email-yangtiezhu@loongson.cn
2020-05-30 04:12:38 +02:00
Tiezhu Yang
f4c29a09cc rtc: goldfish: Use correct return value for goldfish_rtc_probe()
When call function devm_platform_ioremap_resource(), we should use IS_ERR()
to check the return value and return PTR_ERR() if failed.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1590370788-15136-1-git-send-email-yangtiezhu@loongson.cn
2020-05-30 04:12:34 +02:00
Anson Huang
4b957bde56 rtc: snvs: Add necessary clock operations for RTC APIs
There could be still RTC registers access after RTC suspend
with clock disabled, need to add clock operations for each
RTC API to make sure accessing RTC registers is successfully.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1590113996-31845-2-git-send-email-Anson.Huang@nxp.com
2020-05-30 03:17:48 +02:00
Anson Huang
20af67700b rtc: snvs: Make SNVS clock always prepared
In IRQ handler, ONLY clock enable/disable is called due to
clock prepare can NOT be called in interrupt context, but
clock enable/disable will return failure if prepare count
is 0, to fix this issue, just make SNVS clock always prepared
there, the SNVS clock has no prepare function implemented,
so it won't impact anything.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/1590113996-31845-1-git-send-email-Anson.Huang@nxp.com
2020-05-30 03:17:48 +02:00
Ran Bi
29ee40091e rtc: mt6397: Add support for the MediaTek MT6358 RTC
This add support for the MediaTek MT6358 RTC. Driver using
compatible data to store different RTC_WRTGR address offset.
This replace RTC_WRTGR to RTC_WRTGR_MT6323 in mt6323-poweroff
driver which only needed by armv7 CPU without ATF.

Signed-off-by: Ran Bi <ran.bi@mediatek.com>
Signed-off-by: Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Sebastian Reichel <sre@kernel.org>
Reviewed-by: Yingjoe Chen <yingjoe.chen@mediatek.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2020-05-21 08:55:48 +01:00
Paul Cercueil
378252b6e2 rtc: ingenic: Reset regulator register in probe
The regulator register specifies how many input clock cycles (minus one)
are contained in one tick of the 1 Hz clock.

Since this register can contain bogus values after the system boots, it
needs to be reset in the probe register, otherwise the RTC may count way
to slow or way too fast.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200505221336.222313-7-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:35:05 +02:00
Paul Cercueil
15eeadd801 rtc: ingenic: Fix masking of error code
The code was returning -ENOENT on any error of platform_get_irq(), even
if it returned a different error.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200505221336.222313-6-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:35:03 +02:00
Paul Cercueil
77d8f3c122 rtc: ingenic: Remove unused fields from private structure
The 'clk' and 'irq' fields were only ever used in the probe function.
Therefore they can be moved to be simple local variables of the probe
function.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200505221336.222313-5-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:35:01 +02:00
Paul Cercueil
fe0557f4db rtc: ingenic: Set wakeup params in probe
We can write the wakeup timing parameters as soon as the driver probes,
there's no need to wait the very last moment.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200505221336.222313-4-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:34:59 +02:00
Paul Cercueil
796be8b59d rtc: ingenic: Enable clock in probe
It makes no sense to request a clock and not enable it even though the
hardware is being used. So the driver now enables the clock in the
probe. Besides, now we can properly handle errors.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200505221336.222313-3-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:34:58 +02:00
Paul Cercueil
c61293f147 rtc: ingenic: Use local 'dev' variable in probe
Clean a bit the probe function by adding a local struct device *dev
variable.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200505221336.222313-2-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:34:55 +02:00
Paul Cercueil
24e1f2c938 rtc: ingenic: Only support probing from devicetree
With the recent work on supporting Device Tree on Ingenic SoCs, no
driver ever probes from platform code anymore, so we can clean a bit
this driver by removing the non-devicetree paths.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200505221336.222313-1-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:34:54 +02:00
Qiushi Wu
8816cd726a rtc: mc13xxx: fix a double-unlock issue
In function mc13xxx_rtc_probe, the mc13xxx_unlock() is called
before rtc_register_device(). But in the error path of
rtc_register_device(), the mc13xxx_unlock() is called again,
which causes a double-unlock problem. Thus add a call of the
function “mc13xxx_lock” in an if branch for the completion
of the exception handling.

Fixes: e4ae7023e1 ("rtc: mc13xxx: set range")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Link: https://lore.kernel.org/r/20200503182235.1652-1-wu000273@umn.edu
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:21:50 +02:00
Wolfram Sang
32271efded rtc: stmp3xxx: update contact email
The 'pengutronix' address is defunct for years. Use the proper contact
address.

Signed-off-by: Wolfram Sang <wsa@kernel.org>
Link: https://lore.kernel.org/r/20200502142704.19308-1-wsa@kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:21:49 +02:00
Thierry Reding
63a52f6388 rtc: max77686: Use single-byte writes on MAX77620
The MAX77620 doesn't support bulk writes, so make sure the regmap code
breaks bulk writes into multiple single-byte writes.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Link: https://lore.kernel.org/r/20200417170825.2551367-3-thierry.reding@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:21:47 +02:00
Alexandre Belloni
7d65cf8c1f rtc: pcf2127: report battery switch over
Add support for the RTC_VL_BACKUP_SWITCH flag to report battery switch over
events.

Link: https://lore.kernel.org/r/20200511140335.799133-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:04:44 +02:00
Alexandre Belloni
040e6dc091 rtc: pcf2127: set regmap max_register
Set regmap max_register to ease debugging and enforce the register range.

Link: https://lore.kernel.org/r/20200505201310.255145-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:04:42 +02:00
Alexandre Belloni
664eaf033f rtc: pcf2127: remove unnecessary #ifdef
There is not point in setting .ioctl to NULL when CONFIG_RTC_INTF_DEV is
not defined because it would not be called anyway.

Link: https://lore.kernel.org/r/20200505201310.255145-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:04:40 +02:00
Alexandre Belloni
b139bb5c26 rtc: pcf2127: let the core handle rtc range
Let the core handle offsetting and windowing the RTC range.

Link: https://lore.kernel.org/r/20200505201310.255145-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-05-11 16:04:38 +02:00
Alexandre Belloni
9f210ec65a rtc: 88pm860x: remove useless range check
Because the core is now checking the RTC range, it is unnecessary to check
it again in .set_time/

Link: https://lore.kernel.org/r/20200415200226.157361-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-18 22:42:06 +02:00
Alexandre Belloni
06030d5001 rtc: mt2712: switch to devm_platform_ioremap_resource
Using devm_platform_ioremap_resource instead of open coding it reduces the
size of the binary.

   text	   data	    bss	    dec	    hex	filename
   3728	    216	      0	   3944	    f68	drivers/rtc/rtc-mt2712.o
   3744	    216	      0	   3960	    f78	drivers/rtc/rtc-mt2712.o.old

Link: https://lore.kernel.org/r/20200415200021.157118-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-18 22:42:04 +02:00
Alexandre Belloni
3642b17e9a rtc: mt2712: remove unnecessary error string
Remove the unnecessary error string as the core will already display error
messages when registration fails (i.e. never).

Link: https://lore.kernel.org/r/20200415200021.157118-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-18 22:42:03 +02:00
Dan Carpenter
11ddbdfb68 rtc: rc5t619: Fix an ERR_PTR vs NULL check
The devm_kzalloc() function returns NULL on error, it doesn't return
error pointers so this check doesn't work.

Fixes: 540d1e1539 ("rtc: rc5t619: Add Ricoh RC5T619 RTC driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200407092852.GI68494@mwanda
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-15 09:58:24 +02:00
Markus Elfring
944ed452eb rtc: remove unnecessary error message after platform_get_irq
The function “platform_get_irq” can log an error already.
Thus omit redundant messages for the exception handling in the
calling functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Vladimir Zapolskiy <vz@mleia.com>
Link: https://lore.kernel.org/r/04116352-b464-041c-1939-96440133aa6f@web.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-15 09:56:17 +02:00
Linus Torvalds
8645f09bad - New Drivers
- Add support for IQS620A/621/622/624/625 Azoteq IQS62X Sensors
 
  - New Device Support
    - Add support for ADC, IRQ, Regulator, RTC and WDT to Ricoh RN5T618 PMIC
    - Add support for Comet Lake to Intel LPSS
 
  - New Functionality
    - Add support for Charger Detection to Spreadtrum SC27xx PMICs
    - Add support for Interrupt Polarity to Dialog Semi DA9062/61 PMIC
    - Add ACPI enumeration support to Diolan DLN2 USB Adaptor
 
  - Fix-ups
    - Device Tree; iqs62x, rn5t618, cros_ec_dev, stm32-lptimer, rohm,bd71837, rohm,bd71847
    - I2C registration; rn5t618
    - Kconfig; MFD_CPCAP, AB8500_CORE, MFD_WM8994, MFD_WM97xx, MFD_STPMIC1
    - Use flexible-array members; omap-usb-tll, qcom-pm8xxx
    - Remove unnecessary casts; omap-usb-host, omap-usb-tll
    - Power (suspend/resume/poweroff) enhancements; rk808
    - Improve error/sanity checking; dln2
    - Use snprintf(); aat2870-core
 
  - Bug Fixes
    - Fix PCI IDs; intel-lpss-pci
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAl6MSwsACgkQUa+KL4f8
 d2GklhAAk1e0tYu1w4yS0IE40mReDk5ycOE1O8Q75qWw5Af2dK48qvSHGDwaU4ES
 WNYZ3Mr/OUrvd+/XU8EXI6NXAi9W75ye2J2KmmDDL6yXnDuHbzBZF8ifEtXQKSOp
 rElzCJVnXehpjSfwa4cp5f1Msox/rFg1Kpmaas48j8U2JYCmn51GsQCCG6qMIx2i
 0ZvXNZuz+eTY3V7l6pRLfTYqwR8E5Y11ryWJaeliyDcVpUlZaykiXuxD7pbqLjJo
 8v9ISm67rzf6X5zmi6YhdvpIAzpomdRaaxHfVDkeCKqDgpuWGiq0xXA86vDKwjah
 qVx6rK/wg4YM5uSEomxIgVj9uvvLSytDqvRlPe7vFKgkR0Xhl5SdkiwadI4P9zkr
 zrRGNRAUHsZ4ZrlObD0QJWOQYnIg5oCmRouRKcHtQVZYP3rSdRz/1oC6FN8LVqUw
 3NfLB/S6uBCJ3uahckrgnjQughnvmsAzlflcNV2t+P8di8Cwyh2A5N9qkT/oI67o
 Xf7NODSdu0JzzTgsM+EJ2JphSLMYaekWs06qAXyibPrrS2SoThE79igCmNOkyyR7
 obJfN2SM5k4LkhMGlYbPfbRT2Hoa+9OJozBe3WgiW3kwTdFVB9aen2U230tHplbB
 g/NuVS+PrReR5lfzT+O8dodH7lj5/GhmGsapdguFVhXYIE+2CMg=
 =hJ2o
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull mfd updates from Lee Jones:
 "New Drivers:
   - Add support for IQS620A/621/622/624/625 Azoteq IQS62X Sensors

  New Device Support:
   - Add support for ADC, IRQ, Regulator, RTC and WDT to Ricoh RN5T618 PMIC
   - Add support for Comet Lake to Intel LPSS

  New Functionality:
   - Add support for Charger Detection to Spreadtrum SC27xx PMICs
   - Add support for Interrupt Polarity to Dialog Semi DA9062/61 PMIC
   - Add ACPI enumeration support to Diolan DLN2 USB Adaptor

  Fix-ups:
   - Device Tree; iqs62x, rn5t618, cros_ec_dev, stm32-lptimer, rohm,bd71837, rohm,bd71847
   - I2C registration; rn5t618
   - Kconfig; MFD_CPCAP, AB8500_CORE, MFD_WM8994, MFD_WM97xx, MFD_STPMIC1
   - Use flexible-array members; omap-usb-tll, qcom-pm8xxx
   - Remove unnecessary casts; omap-usb-host, omap-usb-tll
   - Power (suspend/resume/poweroff) enhancements; rk808
   - Improve error/sanity checking; dln2
   - Use snprintf(); aat2870-core

  Bug Fixes:
   - Fix PCI IDs in intel-lpss-pci"

* tag 'mfd-next-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (33 commits)
  mfd: intel-lpss: Fix Intel Elkhart Lake LPSS I2C input clock
  mfd: aat2870: Use scnprintf() for avoiding potential buffer overflow
  mfd: dln2: Allow to be enumerated via ACPI
  mfd: da9062: Add support for interrupt polarity defined in device tree
  dt-bindings: bd718x7: Yamlify and add BD71850
  mfd: dln2: Fix sanity checking for endpoints
  mfd: intel-lpss: Add Intel Comet Lake PCH-V PCI IDs
  mfd: sc27xx: Add USB charger type detection support
  dt-bindings: mfd: Document STM32 low power timer bindings
  mfd: rk808: Convert RK805 to shutdown/suspend hooks
  mfd: rk808: Reduce shutdown duplication
  mfd: rk808: Stop using syscore ops
  mfd: rk808: Ensure suspend/resume hooks always work
  mfd: rk808: Always use poweroff when requested
  mfd: omap: Remove useless cast for driver.name
  mfd: Kconfig: Fix some misspelling of the word functionality
  mfd: pm8xxx: Replace zero-length array with flexible-array member
  mfd: omap-usb-tll: Replace zero-length array with flexible-array member
  mfd: cpcap: Fix compile if MFD_CORE is not selected
  mfd: cros_ec: Check DT node for usbpd-notify add
  ...
2020-04-07 19:48:52 -07:00
Linus Torvalds
bdabb68931 RTC for 5.7
Subsystem:
  - The rtc_time_to_tm and rtc_tm_to_time wrappers have finally been removed and
    only the 64bit version remain.
  - hctosys now works with drivers compiled as modules
 
 New driver:
  - MediaTek MT2712 SoC based RTC
 
 Drivers:
  - set range for 88pm860x, au1xxx, cpcap, da9052, davinci, ds1305, ds1374,
    mcp5121, pl030, pl031, pm8xxx, puv3, sa1100, sirfsoc, starfire, sun6i
  - ds1307: DS1388 oscillator failure detection and watchdog support
  - jz4740: JZ4760 support
  - pcf85063: clock out pin support
  - sun6i: external 32k oscillator is now optional, the range is now handled by
    the core, providing a solution for 2034.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAl6IgdAACgkQ2wIijOdR
 NOVH9Q//evfZmRDQb9Lm8YuSOt+U6lBaCuvRP8H4s7i02jsw0tt1oT6+rGo+1N+k
 pi64+iwPqDj7h+eds06jVur7yWZDNNfCSywlMU8ODGLQcc/hXMTvaIeJtdXG+I+7
 dpIVTs9Artiey2Qb3qZalSMYzrE2rQG6Yuyb/tHx7Pohvje1wKnAE3T64W6sfvir
 zjAwAr/+s9n82mjGtGLapz0onao7dSN4p6b3UIkph9KxPdeHjItd7cRiJuzioysj
 LE8WRUek++uha32PzghK9MoUpRKf8PJtGbsAIRhdwvmwub1Pqs6Uvk5IHQvdiFZx
 af1Qnw/4qUH03HVUuq8VdEkwa8mdthcZ72b8uzUWOqP+uPkeTTlQOGOd1dRECijK
 Qic+SKlEznwgKC9WuDufUQg5i2WjFBnBlA+dCE12/t91SbSlZdYjb53nQLHve1b9
 e4VfyKnS5Ghn/dfizzzSPdcWuPW1rqq2dHTiOvFVqlLn1Fkt1AKaJzGAeCe6PWp4
 AJVqPu+D1eQ/qmvEPXI7dQpCxdI+p6FNJgQvQLMssaq7mpf2fiRoLx23ikFG0v0k
 BeNkNWpLz2ACwHpsOa/RWLwa/FC2+KBHaRWf+As7te63byeDQC8hUEi7F5K78lSS
 yhfZ8SJR04SIIGKjuwAzPmaaIJ0hJT+eaxkFAJU7P5hD7KElsuM=
 =6Veu
 -----END PGP SIGNATURE-----

Merge tag 'rtc-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "More cleanup this cycle, with the final goal of removing the
  rtc_time_to_tm and rtc_tm_to_time wrappers. All the drivers that have
  been modified for this now are ready for the end of times (whether it
  happens in 2033, 2038, 2106, 2127 or even 4052). There is also a
  single new driver and the usual fixes and features.

  Summary:

  Subsystem:

   - The rtc_time_to_tm and rtc_tm_to_time wrappers have finally been
     removed and only the 64bit version remain.

   - hctosys now works with drivers compiled as modules

  New driver:

   - MediaTek MT2712 SoC based RTC

  Drivers:

   - set range for 88pm860x, au1xxx, cpcap, da9052, davinci, ds1305,
     ds1374, mcp5121, pl030, pl031, pm8xxx, puv3, sa1100, sirfsoc,
     starfire, sun6i

   - ds1307: DS1388 oscillator failure detection and watchdog support

   - jz4740: JZ4760 support

   - pcf85063: clock out pin support

   - sun6i: external 32k oscillator is now optional, the range is now
     handled by the core, providing a solution for 2034"

* tag 'rtc-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (87 commits)
  rtc: ds1307: check for failed memory allocation on wdt
  rtc: class: remove redundant assignment to variable err
  rtc: remove rtc_time_to_tm and rtc_tm_to_time
  rtc: sun6i: let the core handle rtc range
  rtc: sun6i: switch to rtc_time64_to_tm/rtc_tm_to_time64
  rtc: ds1307: add support for watchdog timer on ds1388
  rtc: da9052: switch to rtc_time64_to_tm/rtc_tm_to_time64
  rtc: da9052: set range
  rtc: da9052: convert to devm_rtc_allocate_device
  rtc: imx-sc: Align imx sc msg structs to 4
  rtc: fsl-ftm-alarm: report alarm to core
  rtc: pcf85063: Add pcf85063 clkout control to common clock framework
  rtc: make definitions in include/uapi/linux/rtc.h actually useful for user space
  rtc: class: avoid unnecessary lookup in hctosys
  dt-bindings: rtc: Convert and update jz4740-rtc doc to YAML
  rtc: jz4740: Rename vendor-specific DT properties
  rtc: jz4740: Add support for JZ4760 SoC
  rtc: class: support hctosys from modular RTC drivers
  rtc: pm8xxx: clear alarm register when alarm is not enabled
  rtc: omap: drop unused dt-bindings header
  ...
2020-04-04 10:38:01 -07:00
Colin Ian King
1821b79d6a rtc: ds1307: check for failed memory allocation on wdt
Currently a failed memory allocation will lead to a null pointer
dereference on point wdt.  Fix this by checking for a failed
allocation and just returning.

Addresses-Coverity: ("Dereference null return")
Fixes: fd90d48db0 ("rtc: ds1307: add support for watchdog timer on ds1388")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200403110437.57420-1-colin.king@canonical.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-03 13:38:24 +02:00
Colin Ian King
3edf29d9d5 rtc: class: remove redundant assignment to variable err
The variable err is being initialized with a value that is never read
and it is being updated later with a new value. The initialization
is redundant and can be removed.

Addresses-Coverity: ("Unused value")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200402110411.508534-1-colin.king@canonical.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-02 18:47:30 +02:00
Alexandre Belloni
8ae79be79b rtc: sun6i: let the core handle rtc range
Let the rtc core check the date/time against the RTC range.

Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Link: https://lore.kernel.org/r/20200330201226.860967-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-02 18:47:29 +02:00
Alexandre Belloni
99b7ac9c68 rtc: sun6i: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Tested-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Link: https://lore.kernel.org/r/20200330201226.860967-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-02 18:47:22 +02:00
Chris Packham
fd90d48db0 rtc: ds1307: add support for watchdog timer on ds1388
The DS1388 variant has watchdog timer capabilities. When using a DS1388
and having enabled CONFIG_WATCHDOG_CORE register a watchdog device for
the DS1388.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200330025500.6991-1-chris.packham@alliedtelesis.co.nz
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-01 12:33:44 +02:00
Alexandre Belloni
06c4e103bf rtc: da9052: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200306073548.57579-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-01 12:33:43 +02:00
Alexandre Belloni
23af616ca4 rtc: da9052: set range
The da9052 is an rtc valid from 2000 to 2063 (max year is 63).

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200306073548.57579-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-01 12:33:43 +02:00
Alexandre Belloni
d17077e570 rtc: da9052: convert to devm_rtc_allocate_device
This allows further improvement of the driver.

Acked-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Link: https://lore.kernel.org/r/20200329224240.776568-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-04-01 12:33:34 +02:00
Linus Torvalds
a776c270a0 Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull EFI updates from Ingo Molnar:
 "The EFI changes in this cycle are much larger than usual, for two
  (positive) reasons:

   - The GRUB project is showing signs of life again, resulting in the
     introduction of the generic Linux/UEFI boot protocol, instead of
     x86 specific hacks which are increasingly difficult to maintain.
     There's hope that all future extensions will now go through that
     boot protocol.

   - Preparatory work for RISC-V EFI support.

  The main changes are:

   - Boot time GDT handling changes

   - Simplify handling of EFI properties table on arm64

   - Generic EFI stub cleanups, to improve command line handling, file
     I/O, memory allocation, etc.

   - Introduce a generic initrd loading method based on calling back
     into the firmware, instead of relying on the x86 EFI handover
     protocol or device tree.

   - Introduce a mixed mode boot method that does not rely on the x86
     EFI handover protocol either, and could potentially be adopted by
     other architectures (if another one ever surfaces where one
     execution mode is a superset of another)

   - Clean up the contents of 'struct efi', and move out everything that
     doesn't need to be stored there.

   - Incorporate support for UEFI spec v2.8A changes that permit
     firmware implementations to return EFI_UNSUPPORTED from UEFI
     runtime services at OS runtime, and expose a mask of which ones are
     supported or unsupported via a configuration table.

   - Partial fix for the lack of by-VA cache maintenance in the
     decompressor on 32-bit ARM.

   - Changes to load device firmware from EFI boot service memory
     regions

   - Various documentation updates and minor code cleanups and fixes"

* 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (114 commits)
  efi/libstub/arm: Fix spurious message that an initrd was loaded
  efi/libstub/arm64: Avoid image_base value from efi_loaded_image
  partitions/efi: Fix partition name parsing in GUID partition entry
  efi/x86: Fix cast of image argument
  efi/libstub/x86: Use ULONG_MAX as upper bound for all allocations
  efi: Fix a mistype in comments mentioning efivar_entry_iter_begin()
  efi/libstub: Avoid linking libstub/lib-ksyms.o into vmlinux
  efi/x86: Preserve %ebx correctly in efi_set_virtual_address_map()
  efi/x86: Ignore the memory attributes table on i386
  efi/x86: Don't relocate the kernel unless necessary
  efi/x86: Remove extra headroom for setup block
  efi/x86: Add kernel preferred address to PE header
  efi/x86: Decompress at start of PE image load address
  x86/boot/compressed/32: Save the output address instead of recalculating it
  efi/libstub/x86: Deal with exit() boot service returning
  x86/boot: Use unsigned comparison for addresses
  efi/x86: Avoid using code32_start
  efi/x86: Make efi32_pe_entry() more readable
  efi/x86: Respect 32-bit ABI in efi32_pe_entry()
  efi/x86: Annotate the LOADED_IMAGE_PROTOCOL_GUID with SYM_DATA
  ...
2020-03-30 16:13:08 -07:00
Linus Torvalds
2ce94bc4e0 PNP subsystem updates for 5.7-rc1
Update MAINTAINERS to cover include/linux/pnp.h and add the linux-acpi
 list to the PNP entry in it, add the const modifier to the name field
 definition in struct pnp_driver and drop a pointer case in the RTC
 CMOS driver that has become redundant (Corentin Labbe).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAl6CCnwSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRxJ/oP/2lBsEiasuEGPBtMMjruJVvHPNVop+vY
 lemr/7Fv6M06OwIpo9u2ZU/0PaQAU/pCtj7qQAbbt3llu77kbuTkGJrYhTHhkNS+
 XkpVw9GHntUu8t/mBzs+6eCPoL3n58UQwPvu2AuSZjMrVAN9Qpmyd8uNe76l8Kwx
 LFYRyCdork2phFlouLsj/U3MKIN+m4MMyeNMWkGiZnFMra1XuQwLln2XUDtmnf9L
 G2tIapyVNmUGrDZogiwPCCjeizJY3JPLawFihDX3cj2SXw6+rhISvaHB5fwamG+m
 S1xPWVBOYwOydIqScOzyJ98UQqlU21/LrA2KOHz69zj1//fTT6sx9KjFPJRS4F+E
 5dyKBVAVcrTj0ZHMd4H7cKhR6kRgy7E9Iew7pnWnYn16X6mlTdEtSFTUffbSbtL7
 IQlt8ae1yzsX3E1cMM+PAFPTAekI5uyDsVKxzy+RtZEs0ND+6JxFDDb2jG2ovvx1
 DOrHCMZeBFd11ZNVNJpwBrdIALHRhMqdcScDqw09t1/pZVeUy811zZD0hUpuvemJ
 wl6YP9IBonWmi+eVroSgKsH1f8KPLzKP7Vh/OUFatb8RWIYn2SQkc+5cJIXQmiTH
 SuyZu0yIMtXbnPVLUp3Dg2pq1q05no0IXqO3sNQa0EbzcrY87LogXuyB3Bm6OPVp
 b052qB/2yqop
 =PLMG
 -----END PGP SIGNATURE-----

Merge tag 'pnp-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull PNP subsystem updates from Rafael Wysocki:

 - Update MAINTAINERS to cover include/linux/pnp.h and add the
   linux-acpi list to the PNP entry in it

 - add the const modifier to the name field definition in struct
   pnp_driver

 - drop a pointer case in the RTC CMOS driver that has become redundant

All by Corentin Labbe.

* tag 'pnp-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  MAINTAINERS: Add linux-acpi list to PNP
  rtc: cmos: remove useless cast for driver_name
  PNP: constify driver name
  PNP: add missing include/linux/pnp.h to MAINTAINERS
2020-03-30 15:28:12 -07:00
Leonard Crestez
a29de86521 rtc: imx-sc: Align imx sc msg structs to 4
The imx SC api strongly assumes that messages are composed out of
4-bytes words but some of our message structs have odd sizeofs.

This produces many oopses with CONFIG_KASAN=y.

Fix by marking with __aligned(4).

Fixes: a3094fc1a1 ("rtc: imx-sc: add rtc alarm support")
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Link: https://lore.kernel.org/r/13404bac8360852d86c61fad5ae5f0c91ffc4cb6.1582216144.git.leonard.crestez@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-29 22:08:35 +02:00
Biwen Li
9c328c9dd8 rtc: fsl-ftm-alarm: report alarm to core
Report interrupt state to the RTC core.

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Link: https://lore.kernel.org/r/20200327084457.45161-1-biwen.li@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-29 22:01:49 +02:00
Andreas Kemnade
540d1e1539 rtc: rc5t619: Add Ricoh RC5T619 RTC driver
Add an RTC driver for the RTC device on Ricoh MFD RC5T619,
which is implemented as a variant of RN5T618.

rtc-range output:
Testing 2000-02-28 23:59:59.
OK

Testing 2038-01-19 03:14:07.
OK

Testing 2069-12-31 23:59:59.
OK

Testing 2099-12-31 23:59:59.
KO RTC_RD_TIME returned 22 (line 138)

Testing 2100-02-28 23:59:59.
KO RTC_SET_TIME returned 34 (line 122)

Testing 2106-02-07 06:28:15.
KO RTC_SET_TIME returned 34 (line 122)

Testing 2262-04-11 23:47:16.
KO RTC_SET_TIME returned 34 (line 122)

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2020-03-27 09:42:30 +00:00
Michael McCormick
8c229ab604 rtc: pcf85063: Add pcf85063 clkout control to common clock framework
The PCF85063 has a configurable clock output signal. Add support for it
using in the CCF.

Signed-off-by: Michael McCormick <michael.mccormick@enatel.net>
Link: https://lore.kernel.org/r/20200124015239.24662-1-michael.mccormick@enatel.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-26 22:49:53 +01:00
Alexandre Belloni
5614a4a3ca rtc: class: avoid unnecessary lookup in hctosys
rtc_hctosys is only called when the relevant RTC is found, avoid looking it
up while we already have a pinter to the proper struct rtc_device.

Link: https://lore.kernel.org/r/20200323213039.297458-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-24 22:48:04 +01:00
Paul Cercueil
91b298f5dc rtc: jz4740: Rename vendor-specific DT properties
These properties are never set anywhere within any of the upstream
devicetree files, so I assume I'm not breaking the ABI with this change.

Rename vendor-specific DT properties to have the 'ingenic,' prefix,
which they should have had from the start.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200311182318.22154-2-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-24 11:03:23 +01:00
Paul Cercueil
5840748520 rtc: jz4740: Add support for JZ4760 SoC
The WENR feature (set a magic value to enable RTC registers read-write)
first appeared on the JZ4760; the JZ4780 came much later.

Since it would be dangerous to specify a newer SoC's compatible string as
the fallback of an older SoC's compatible string, we add support for the
"ingenic,jz4760-rtc" compatible string in the driver.

This will permit to support the JZ4770 by having:
compatible = "ingenic,jz4770-rtc", "ingenic,jz4760-rtc";

Instead of doing:
compatible = "ingenic,jz4770-rtc", "ingenic,jz4780-rtc";

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20200311182318.22154-1-paul@crapouillou.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-24 11:03:22 +01:00
Steve Muckle
f9b2a4d6a5 rtc: class: support hctosys from modular RTC drivers
Due to distribution constraints it may not be possible to statically
compile the required RTC driver into the kernel.

Expand RTC_HCTOSYS support to cover all RTC devices (statically compiled
or not) by checking at the end of RTC device registration whether the
time should be synced.

Signed-off-by: Steve Muckle <smuckle@google.com>
Link: https://lore.kernel.org/r/20191106194625.116692-1-smuckle@google.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-23 21:14:34 +01:00
韩科才
34ce29774d rtc: pm8xxx: clear alarm register when alarm is not enabled
Clear alarm register when alarm is not enabled otherwise the consumer
may still start alarm timer if it find the alarm register is not zero.

Signed-off-by: hankecai <hankecai@vivo.com>
Link: https://lore.kernel.org/r/APoAZgAaCEiRpKG6PlzreaqE.1.1584791417367.Hmail.hankecai@vivo.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-23 09:27:17 +01:00
Uwe Kleine-König
4828a82e29 rtc: omap: drop unused dt-bindings header
The definitons in the dt-binding's gpio header only contains some
constants to be used in device trees. It is not relevant for rtc-omap
(as the gpio API hides the details) and in fact unused so it can just be
dropped.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20200321203737.29850-1-uwe@kleine-koenig.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-23 09:27:17 +01:00
Keyur Patel
6e7af45102 rtc: bd70528: Avoid double error messaging when IRQ absent
Since the commit 7723f4c ("driver core: platform: Add an error message
to platform_get_irq*()") platform_get_irq() started issuing an error message.
Thus, there is no need to have the same in the driver.

Signed-off-by: Keyur Patel <iamkeyur96@gmail.com>
Link: https://lore.kernel.org/r/20200321180838.12729-1-iamkeyur96@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-23 09:27:17 +01:00
Corentin Labbe
c05a31f4d1 rtc: max8907: add missing select REGMAP_IRQ
I have hit the following build error:
armv7a-hardfloat-linux-gnueabi-ld: drivers/rtc/rtc-max8907.o: in function `max8907_rtc_probe':
rtc-max8907.c:(.text+0x400): undefined reference to `regmap_irq_get_virq'

max8907 should select REGMAP_IRQ

Fixes: 94c01ab6d7 ("rtc: add MAX8907 RTC driver")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Link: https://lore.kernel.org/r/1584545209-20433-1-git-send-email-clabbe@baylibre.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-23 09:27:16 +01:00
Peng Ma
929a327048 rtc: fsl-ftm-alarm: enable acpi support
This patch enables ACPI support in Rtc Flex timer driver.

Signed-off-by: Peng Ma <peng.ma@nxp.com>
Link: https://lore.kernel.org/r/20200318025354.6447-1-peng.ma@nxp.com
Link: https://lore.kernel.org/r/20200323072956.38263-1-peng.ma@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-23 09:26:47 +01:00
Anson Huang
fdc9f0eace rtc: mxc: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()
Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling, and .remove callback can be dropped.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1584349785-27042-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-22 22:10:41 +01:00
Chris Packham
df11b323b1 rtc: ds1307: handle oscillator failure flags for ds1388 variant
The FLAG register is at a different location to the other supported RTCs
so this requires an extra case in the existing switch statement.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20200207031812.14424-2-chris.packham@alliedtelesis.co.nz
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-22 21:40:01 +01:00
Corentin Labbe
5d892919fd rtc: max8907: add missing select REGMAP_IRQ
I have hit the following build error:

  armv7a-hardfloat-linux-gnueabi-ld: drivers/rtc/rtc-max8907.o: in function `max8907_rtc_probe':
  rtc-max8907.c:(.text+0x400): undefined reference to `regmap_irq_get_virq'

max8907 should select REGMAP_IRQ

Fixes: 94c01ab6d7 ("rtc: add MAX8907 RTC driver")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-03-19 09:55:25 -07:00
Corentin Labbe
8d4e59ec94 rtc: cmos: remove useless cast for driver_name
Now the pnp_driver name is "const char *", there are no need to cast
driver_name.

Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-03-17 18:32:07 +01:00
Alexandre Belloni
30a790653d rtc: mt2712: fix build without PM_SLEEP
Fix this build error when PM_SLEEP is not selected:

drivers/rtc/rtc-mt2712.c:412:10: error: ‘mt2712_pm_ops’ undeclared here (not in a function); did you mean ‘mt2712_rtc_ops’?
  412 |   .pm = &mt2712_pm_ops,
      |          ^~~~~~~~~~~~~

Link: https://lore.kernel.org/r/20200317143421.9551-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-17 15:34:47 +01:00
Alexandre Belloni
ccf1441db9 rtc: 88pm860x: remove platform data support
There is no users of the rtc platform data left, remove its support.

Link: https://lore.kernel.org/r/20200316102537.180398-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:56 +01:00
Alexandre Belloni
b2a2aa63f9 rtc: 88pm860x: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200311223956.51352-6-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:56 +01:00
Alexandre Belloni
3b45cc522e rtc: 88pm860x: stop mangling alarm time
The RTC core always passes a valid alarm time there is no need to modify
it.

Link: https://lore.kernel.org/r/20200311223956.51352-5-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:56 +01:00
Alexandre Belloni
a3e4937112 rtc: 88pm860x: set range
The 88pm860x RTC is a 32bit read only seconds counter with a 32bit offset.

Link: https://lore.kernel.org/r/20200311223956.51352-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:56 +01:00
Alexandre Belloni
1c9fe6d6d2 rtc: 88pm860x: stop calling unused callback
pdata->sync is not defined by any platform, stop calling it.

Link: https://lore.kernel.org/r/20200311223956.51352-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:55 +01:00
Alexandre Belloni
b773f2a97f rtc: 88pm860x: stop setting a default time
It doesn't make sense to set the RTC to a default value at probe time. Let
the core handle invalid date and time.

Link: https://lore.kernel.org/r/20200311223956.51352-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:55 +01:00
Alexandre Belloni
9cf4789e6e rtc: 88pm860x: fix possible race condition
The RTC IRQ is requested before the struct rtc_device is allocated,
this may lead to a NULL pointer dereference in the IRQ handler.

To fix this issue, allocating the rtc_device struct before requesting
the RTC IRQ using devm_rtc_allocate_device, and use rtc_register_device
to register the RTC device.

Also remove the unnecessary error message as the core already prints the
info.

Link: https://lore.kernel.org/r/20200311223956.51352-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:55 +01:00
Anson Huang
7863bd076b rtc: snvs: Use devm_add_action_or_reset() for calls to clk_disable_unprepare()
Use devm_add_action_or_reset() for calls to clk_disable_unprepare(),
which can simplify the error handling.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1584109849-21402-1-git-send-email-Anson.Huang@nxp.com
Link: https://lore.kernel.org/r/1584233264-26025-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:55 +01:00
Ran Bi
64823360a8 rtc: add support for the MediaTek MT2712 RTC
This add support for the MediaTek MT2712 RTC. It was SoC based RTC, but
had different architecture compared with MT7622 RTC.

Signed-off-by: Ran Bi <ran.bi@mediatek.com>
Link: https://lore.kernel.org/r/20200226051303.22560-3-ran.bi@mediatek.com
Link: https://lore.kernel.org/r/20200316104701.209293-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:55:40 +01:00
Thomas Bogendoerfer
eac1c3fc55 rtc: m48t35: remove SGI-IP27 kludge
With the IOC3 MFD driver it's no longer necessary to special case SGI-IP27.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Link: https://lore.kernel.org/r/20200309123514.15543-1-tsbogend@alpha.franken.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:11 +01:00
Jernej Skrabec
ec98a87509 rtc: sun6i: Make external 32k oscillator optional
Some boards, like OrangePi PC2 (H5), OrangePi Plus 2E (H3) and Tanix TX6
(H6) don't have external 32kHz oscillator. Till H6, it didn't really
matter if external oscillator was enabled because HW detected error and
fall back to internal one. H6 has same functionality but it's the first
SoC which have "auto switch bypass" bit documented and always enabled in
driver. This prevents RTC to work correctly if external crystal is not
present on board. There are other side effects - all peripherals which
depends on this clock also don't work (HDMI CEC for example).

Make clocks property optional. If it is present, select external
oscillator. If not, stay on internal.

Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net>
Acked-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20200308135849.106333-2-jernej.skrabec@siol.net
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:11 +01:00
Alexandre Belloni
0155b54774 rtc: puv3: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306010240.40056-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:11 +01:00
Alexandre Belloni
a04b3b965f rtc: puv3: set range
This RTC is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306010240.40056-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:11 +01:00
Alexandre Belloni
a5965a3101 rtc: ab8500: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200306010101.39517-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:11 +01:00
Alexandre Belloni
c8ff5841a9 rtc: pl031: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion to allow extending
support after 2106 and properly supporting the STv2 range.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200306005809.38530-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:11 +01:00
Alexandre Belloni
03f2a0e45f rtc: pl031: set range
The PL031 and ST v1 RTC are 32bit seconds counters. STv2 is a BCD RTC
apparently going from 0000 to 9999, hopefully handling the leap days
properly until then.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200306005809.38530-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:11 +01:00
Alexandre Belloni
61c9fbff9d rtc: pl031: remove useless invalid alarm handling
The core will never pass an invalid alarm to .set_alarm, it is not
necessary to check for its validity.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20200306005809.38530-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:11 +01:00
Alexandre Belloni
7098f53682 rtc: fsl-ftm-alarm: allow COMPILE_TEST
Allow building building the driver with COMPILE_TEST.

Link: https://lore.kernel.org/r/20200306131629.18837-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
3d5a49545a rtc: mpc5121: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306074404.58909-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
3905d1c02d rtc: mpc5121: set range
The datasheet states that 4052 is the maximum value for year. However, the
mpc5121 read_time and set_time function abuse the target time register
instead of using the broken down time so it is limited to 2106.

Link: https://lore.kernel.org/r/20200306074404.58909-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
fffbe10e2f rtc: mpc5121: convert to devm_rtc_allocate_device
This simplifies the path for the rtc_ops selection.

Link: https://lore.kernel.org/r/20200306074404.58909-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
d53d4ae981 rtc: mpc5121: simplify probe
Use devm managed function to simplify probe and remove.

Link: https://lore.kernel.org/r/20200306074404.58909-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
c47cf9d6bb rtc: pm8xxx: stop validating valid alarm time
rtc_time64_to_tm never generates an invalid rtc_tm, stop validating it.

Link: https://lore.kernel.org/r/20200306073758.58050-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
4c470b2f12 rtc: pm8xxx: : switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306073758.58050-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
3cfe526077 rtc: pm8xxx: set range
The pm8xxx are 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306073758.58050-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
d5d55b7098 rtc: pm8xxx: convert to devm_rtc_allocate_device
This allows further improvement of the driver. Also remove the unnecessary
error string as the core will already display error messages.

Link: https://lore.kernel.org/r/20200306073758.58050-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
f2adcb9c3a rtc: ds1305: switch to rtc_tm_to_time64
Call the 64bit version of rtc_tm to time conversion.

Link: https://lore.kernel.org/r/20200306073459.57197-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
9869a93c82 rtc: ds1305: set range
The ds1305 is a BCD rtc valid from 2000 to 2099.

Link: https://lore.kernel.org/r/20200306073459.57197-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
ca824be9b3 rtc: ds1374: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306073404.56921-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
4136ff3a51 rtc: ds1374: set range
The ds1374 is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306073404.56921-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
c11af8131a rtc: ds1374: fix possible race condition
The RTC IRQ is requested before the struct rtc_device is allocated,
this may lead to a NULL pointer dereference in the IRQ handler.

To fix this issue, allocating the rtc_device struct before requesting
the RTC IRQ using devm_rtc_allocate_device, and use rtc_register_device
to register the RTC device.

Link: https://lore.kernel.org/r/20200306073404.56921-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
d238df15e5 rtc: cpcap: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306015703.42101-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
d2377f8cc5 rtc: cpcap: set range
The CPCAP rtc is a 14bit day counter plus a 17bit seconds counter.

Note that this failed on Nov 10 2014 so it is very likely this driver as
never been used since.

Link: https://lore.kernel.org/r/20200306015703.42101-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
05b38d182c rtc: cpcap: convert to devm_rtc_allocate_device
This allows further improvement of the driver.

Link: https://lore.kernel.org/r/20200306015703.42101-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:10 +01:00
Alexandre Belloni
eb8d942032 rtc: sa1100: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306010146.39762-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
e877ab7302 rtc: sa1100: set range
The SA1100 RTC is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306010146.39762-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
f2997775b1 rtc: sa1100: fix possible race condition
Both RTC IRQs are requested before the struct rtc_device is allocated,
this may lead to a NULL pointer dereference in the IRQ handler.

To fix this issue, allocating the rtc_device struct before requesting
the IRQs using devm_rtc_allocate_device, and use rtc_register_device
to register the RTC device.

Link: https://lore.kernel.org/r/20200306010146.39762-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
0a22bd6fe4 rtc: au1xxx: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306005958.39203-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
b1b686e4b0 rtc: au1xxx: set range
The Alchemy counter0 is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306005958.39203-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
9cf71edb02 rtc: au1xxx: remove goto label
Simplify the driver by removing the goto label as it only does return ret.

Link: https://lore.kernel.org/r/20200306005958.39203-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
7fc9790aa3 rtc: au1xxx: convert to devm_rtc_allocate_device
This allows further improvement of the driver.

Link: https://lore.kernel.org/r/20200306005958.39203-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
326bce078a rtc: starfire: switch to rtc_time64_to_tm
Call the 64bit version of rtc_tm time conversion.

Link: https://lore.kernel.org/r/20200306005910.38939-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
166b13325c rtc: starfire: set range
The starfire RTC is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306005910.38939-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
c33c4713cd rtc: pl030: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion to avoid the y2106 issue.

Link: https://lore.kernel.org/r/20200306005730.38268-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
b303b2fe5d rtc: pl030: remove useless invalid alarm handling
The core will never pass an invalid alarm to .set_alarm, it is not
necessary to check for its validity.

Link: https://lore.kernel.org/r/20200306005730.38268-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
9896169a12 rtc: pl030: set range
This RTC is a 32bit seconds counter.

Link: https://lore.kernel.org/r/20200306005730.38268-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
6a5bbad586 rtc: davinci: remove useless error handling
convertfromdays and convert2days never return errors, stop handling non
existent errors.

Link: https://lore.kernel.org/r/20200305215022.32533-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
b6d8f58920 rtc: davinci: let the core handle rtc range
Let the core handle offsetting and windowing the RTC range.

This rtc has hours, minutes, seconds and 16bit days. As the driver has the
RTC epoch set to year 2000, this means that the end of the range is 2^16
days minus one second later. This is Sun Jun  6 23:59:59 UTC 2179. This
is better than the currently set year 2099.

Link: https://lore.kernel.org/r/20200305215022.32533-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
dc924ce9a1 rtc: davinci: remove useless 24h alarm handling
The code handling invalid alarms meaning the alarm is in the next 24 hours
is not necessary since commit f8245c2688 ("rtc: remove "RTC_ALM_SET mode"
bugs") which actually predates this driver. Since then, .set_alarm is never
called with an invalid alarm and this handling is not necessary in the
driver.

Link: https://lore.kernel.org/r/20200305215022.32533-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
b1c67e0b07 rtc: davinci: convert to devm_rtc_allocate_device
This allows further improvement of the driver. Also remove the unnecessary
error string as the core will already display error messages.

Link: https://lore.kernel.org/r/20200305215022.32533-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
09b875a426 rtc: sirfsoc: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_tm time conversion to avoid the y2106 issue.

Link: https://lore.kernel.org/r/20200305160452.27808-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
cd65dd4180 rtc: sirfsoc: set range
This RTC is a 32bit counter running at 16Hz. This overflows every eight
years and a half. However, the driver uses the SW_VALUE register to store
the overflow, extending the counter to 64bit as long as the update happens
before the overflow.

Link: https://lore.kernel.org/r/20200305160452.27808-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:09 +01:00
Alexandre Belloni
2911ee9e60 rtc: sirfsoc: convert to devm_rtc_allocate_device
This allows further improvement of the driver. Also remove the unnecessary
error string as the core will already display error messages.

Link: https://lore.kernel.org/r/20200305160452.27808-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:08 +01:00
Anson Huang
b427ca8c66 rtc: snvs: Improve Kconfig dependency
i.MX SNVS RTC should depend on ARCH_MXC or COMPILE_TEST.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1583136785-4973-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:08 +01:00
suguosong
ae243ef0af rtc: sysfs: use kobj_to_dev
use kobj_to_dev instead of open-conding it

Signed-off-by: suguosong <suguosong@xiaomi.com>
Link: https://lore.kernel.org/r/20200225021923.8570-1-guosongsu@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-16 11:12:08 +01:00
Ville Syrjälä
66e4f4a9cc rtc: cmos: Use spin_lock_irqsave() in cmos_interrupt()
cmos_interrupt() isn't always called from hardirq context, so
we must use spin_lock_irqsave() & co.

================================
WARNING: inconsistent lock state
5.6.0-rc2-CI-CI_DRM_7981+ #1 Tainted: G     U
--------------------------------
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
rtcwake/4315 [HC0[0]:SC0[0]:HE1:SE1] takes:
ffffffff82635198 (rtc_lock){?...}, at: cmos_interrupt+0x18/0x100
{IN-HARDIRQ-W} state was registered at:
  lock_acquire+0xa7/0x1c0
  _raw_spin_lock+0x2a/0x40
  cmos_interrupt+0x18/0x100
  rtc_handler+0x75/0xc0
  acpi_ev_fixed_event_detect+0xf9/0x132
  acpi_ev_sci_xrupt_handler+0xb/0x28
  acpi_irq+0x13/0x30
  __handle_irq_event_percpu+0x41/0x2c0
  handle_irq_event_percpu+0x2b/0x70
  handle_irq_event+0x2f/0x50
  handle_fasteoi_irq+0x8e/0x150
  do_IRQ+0x7e/0x160
  ret_from_intr+0x0/0x35
  mwait_idle+0x7e/0x200
  do_idle+0x1bb/0x260
  cpu_startup_entry+0x14/0x20
  start_secondary+0x15f/0x1b0
  secondary_startup_64+0xa4/0xb0
irq event stamp: 42003
hardirqs last  enabled at (42003): [<ffffffff81a36567>] _raw_spin_unlock_irqrestore+0x47/0x60
hardirqs last disabled at (42002): [<ffffffff81a362ed>] _raw_spin_lock_irqsave+0xd/0x50
softirqs last  enabled at (41848): [<ffffffff81e00385>] __do_softirq+0x385/0x47f
softirqs last disabled at (41841): [<ffffffff810bab3a>] irq_exit+0xba/0xc0

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(rtc_lock);
  <Interrupt>
    lock(rtc_lock);

 *** DEADLOCK ***

6 locks held by rtcwake/4315:
 #0: ffff888175dc9408 (sb_writers#5){.+.+}, at: vfs_write+0x1a4/0x1d0
 #1: ffff88817406ca80 (&of->mutex){+.+.}, at: kernfs_fop_write+0xdd/0x1b0
 #2: ffff888179be85e0 (kn->count#236){.+.+}, at: kernfs_fop_write+0xe6/0x1b0
 #3: ffffffff82641e00 (system_transition_mutex){+.+.}, at: pm_suspend+0xb3/0x3b0
 #4: ffffffff826b3ee0 (acpi_scan_lock){+.+.}, at: acpi_suspend_begin+0x47/0x80
 #5: ffff888178fc3960 (&dev->mutex){....}, at: device_resume+0x92/0x1c0

stack backtrace:
CPU: 3 PID: 4315 Comm: rtcwake Tainted: G     U            5.6.0-rc2-CI-CI_DRM_7981+ #1
Hardware name: Google Soraka/Soraka, BIOS MrChromebox-4.10 08/25/2019
Call Trace:
 dump_stack+0x71/0x9b
 mark_lock+0x49a/0x500
 ? print_shortest_lock_dependencies+0x200/0x200
 __lock_acquire+0x6d4/0x15d0
 ? __lock_acquire+0x460/0x15d0
 lock_acquire+0xa7/0x1c0
 ? cmos_interrupt+0x18/0x100
 _raw_spin_lock+0x2a/0x40
 ? cmos_interrupt+0x18/0x100
 cmos_interrupt+0x18/0x100
 cmos_resume+0x1fd/0x290
 ? __acpi_pm_set_device_wakeup+0x24/0x100
 pnp_bus_resume+0x5e/0x90
 ? pnp_bus_suspend+0x10/0x10
 dpm_run_callback+0x64/0x280
 device_resume+0xd4/0x1c0
 ? dpm_watchdog_set+0x60/0x60
 dpm_resume+0x106/0x410
 ? dpm_resume_early+0x38c/0x3e0
 dpm_resume_end+0x8/0x10
 suspend_devices_and_enter+0x16f/0xbe0
 ? rcu_read_lock_sched_held+0x4d/0x80
 pm_suspend+0x344/0x3b0
 state_store+0x78/0xe0
 kernfs_fop_write+0x112/0x1b0
 vfs_write+0xb9/0x1d0
 ksys_write+0x9f/0xe0
 do_syscall_64+0x4f/0x220
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7ff934307154
Code: 89 02 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 8d 05 b1 07 2e 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 f3 c3 66 90 41 54 55 49 89 d4 53 48 89 f5
RSP: 002b:00007ffe2647c168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007ff934307154
RDX: 0000000000000004 RSI: 000055de3ec4e5a0 RDI: 000000000000000a
RBP: 000055de3ec4e5a0 R08: 000055de3ec4c5e0 R09: 00007ff9349f3740
R10: 000055de3ec4a010 R11: 0000000000000246 R12: 000055de3ec4c500
R13: 0000000000000004 R14: 00007ff9345df2a0 R15: 00007ff9345de760

Fixes: c6d3a278cc ("rtc: cmos: acknowledge ACPI driven wake alarms upon resume")
Fixes: 311ee9c151 ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://lore.kernel.org/r/20200221144739.11746-1-ville.syrjala@linux.intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-03-03 11:56:42 +01:00
Ard Biesheuvel
e5c3b1cc99 efi: Register EFI rtc platform device only when available
Drop the separate driver that registers the EFI rtc on all EFI
systems that have runtime services available, and instead, move
the registration into the core EFI code, and make it conditional
on whether the actual time related services are available.

Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
2020-02-23 21:59:42 +01:00
Anson Huang
a137e9b620 rtc: snvs: Remove unused include of of_device.h
There is nothing in use from of_device.h, remove it.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Link: https://lore.kernel.org/r/1581823666-16944-1-git-send-email-Anson.Huang@nxp.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-02-18 22:39:23 +01:00
Srinivas Neeli
4594d082db rtc: zynqmp: Clear alarm interrupt status before interrupt enable
Fix multiple occurring interrupts for alarm interrupt. RTC module doesn't
clear the alarm interrupt status bit immediately after the interrupt is
triggered.This is due to the sticky nature of the alarm interrupt status
register. The alarm interrupt status register can be cleared only after
the second counter outruns the set alarm value. To fix multiple spurious
interrupts, disable alarm interrupt in the handler and clear the status
bit before enabling the alarm interrupt.

Fixes: 11143c19eb ("rtc: add xilinx zynqmp rtc driver")
Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
Link: https://lore.kernel.org/r/1581503079-387-1-git-send-email-srinivas.neeli@xilinx.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-02-12 12:21:42 +01:00
Geert Uytterhoeven
38a49742de rtc: sh: Restore devm_ioremap() alignment
The alignment of the continuation of the devm_ioremap() call in
sh_rtc_probe() was broken.  Join the lines, as all parameters can fit on
a single line.

Fixes: 4bdc0d676a ("remove ioremap_nocache and devm_ioremap_nocache")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20200212084836.9511-1-geert+renesas@glider.be
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-02-12 12:21:40 +01:00
Linus Torvalds
79703e014b chrome platform changes for 5.6
* CrOS EC
 - Refactoring of some of cros_ec's headers. include/linux/mfd/cros_ec.h now
   removed, new cros_ec.h added drivers/platform/chrome which contains shared
   operations of cros_ec transport drivers.
 - Response tracing in cros_ec_proto
 
 * Wilco EC
 - Fix unregistration order.
 - Fix keyboard backlight probing on systems without keyboard backlight
 - Minor cleanup (newlines in printks, COMPILE_TEST)
 
 * Misc
 - chromeos_laptop converted to use i2c_new_scanned_device instead of
   i2c_new_probed_device
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQQCtZK6p/AktxXfkOlzbaomhzOwwgUCXjij4AAKCRBzbaomhzOw
 wrFjAP0bU5PFkxprCOTY9kF/cMgHPDljEPES4FVV11eGyYr3HgD/StpuIhFGrh7+
 Fz96dDdNu1melyGjmMqSN/M9JFo+Hw4=
 =FB/I
 -----END PGP SIGNATURE-----

Merge tag 'tag-chrome-platform-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux

Pull chrome platform updates from Benson Leung:
 "CrOS EC:

   - Refactoring of some of cros_ec's headers:

     include/linux/mfd/cros_ec.h now removed, new cros_ec.h added to
     drivers/platform/chrome which contains shared operations of cros_ec
     transport drivers.

   - Response tracing in cros_ec_proto

  Wilco EC:

   - Fix unregistration order.

   - Fix keyboard backlight probing on systems without keyboard
     backlight

   - Minor cleanup (newlines in printks, COMPILE_TEST)

  Misc:

   - chromeos_laptop converted to use i2c_new_scanned_device instead of
     i2c_new_probed_device"

* tag 'tag-chrome-platform-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux:
  platform/chrome: cros_ec: Match implementation with headers
  platform/chrome: cros_ec: Drop unaligned.h include
  platform/chrome: wilco_ec: Allow wilco to be compiled in COMPILE_TEST
  platform/chrome: wilco_ec: Add newlines to printks
  platform/chrome: wilco_ec: Fix unregistration order
  cros_ec: treewide: Remove 'include/linux/mfd/cros_ec.h'
  platform/chrome: cros_ec_ishtp: Make init_lock static
  platform/chrome: chromeos_laptop: Convert to i2c_new_scanned_device
  platform/chrome: cros_ec_lpc: Use platform_get_irq_optional() for optional IRQs
  platform/chrome: cros_ec_proto: Add response tracing
  platform/chrome: cros_ec_trace: Match trace commands with EC commands
2020-02-04 07:17:41 +00:00
Linus Torvalds
eadc4e40e6 RTC for 5.6
Subsystem:
  - the VL_READ and VL_CLR ioctls are now documented and their behavior is
    unified across all the drivers.
  - RTC_I2C_AND_SPI Kconfig option rework to avoid selecting both REGMAP_I2C and
    REGMAP_SPI unecessarily.
 
 Drivers:
  - at91rm9200: remove deprecated procfs, add sam9x60, sama5d4 and sama5d2
    compatibles.
  - cmos: solve lost interrupts issue on MS Surface 3
  - hym8563: return proper errno when time is invalid
  - rv3029: many fixes, nvram support
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAl44lxsACgkQ2wIijOdR
 NOVF3BAAlQVFDklLqkS6MJplgZ06lgv4ZIbfxCHYFJPUNt/X/gTcHS1OSTwctmor
 3qQamySGc74/GAI6lmNSSzDUz9vi2hwcwvLtR/e6+Kgdhg9EuWWvgsqKYRGAn573
 TzHWsYY8bDpZ/mN5K+qqadGlzsP58gsEaw0fzcsPkZQQdq4mNSIrB5RILvsHX8cN
 +RviYOqR+ZvAegfQrAfb/9SCwxQAstUqRDaZXodQDEeIk5CEDWyr31+U9eLDdYoN
 1FOHYp6uwUy6Vnl0ym7WU42L95tVWx9XOc/PEq8dZ1m09nfrMhqeIoQC8SUtxG9+
 FWXN87lkLSlDaLUwVE8T22QII6jP+7Lc2t6SbI4fwwJdNDoPg+5hhabGjQbM2We9
 nG1x7TsVwKjeUglfhqeVgGWYzmIhAeOEBXQhqCdtfVi13ocecVFJxOG6oolQGtlZ
 M+/t91hID6il7/nxGembcHKapMf9c41CXBPesEg0QjkvGvKj1Z8L9a5vYigzbxWW
 zb8m9cjIhY3bb8mns3aCs773PSXavsycLk1Hupw6RWrN1XnEXVMHQZDtvzCJe7EV
 8CY40LI0VN6x5HC/d0EnqyrMvQbkgTBPXjLBhj54edCZM3vAny3xkYc03oDU8cKc
 0PbLUXKpFmzFbTQB4w0sE2FgT0uZmL2SCXiFemUwxbl+/ZACkoc=
 =e1Xr
 -----END PGP SIGNATURE-----

Merge tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "The VL_READ and VL_CLR ioctls have been reworked to be more useful.
  This will not break userspace as there are very few users and they are
  using the integer value as a boolean.

  Apart from that, two drivers were reworked and a few fixes here and
  there for a net reduction of number of lines.

  Summary:

  Subsystem:
   - the VL_READ and VL_CLR ioctls are now documented and their behavior
     is unified across all the drivers.
   - RTC_I2C_AND_SPI Kconfig option rework to avoid selecting both
     REGMAP_I2C and REGMAP_SPI unecessarily.

  Drivers:
   - at91rm9200: remove deprecated procfs, add sam9x60, sama5d4 and
     sama5d2 compatibles.
   - cmos: solve lost interrupts issue on MS Surface 3
   - hym8563: return proper errno when time is invalid
   - rv3029: many fixes, nvram support"

* tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (63 commits)
  dt-bindings: rtc: at91rm9200: document clocks property
  rtc: i2c/spi: Avoid inclusion of REGMAP support when not needed
  rtc: Kconfig: select REGMAP_I2C when necessary
  rtc: Kconfig: properly indent sd3078 entry
  rtc: cmos: Refactor code by using the new dmi_get_bios_year() helper
  rtc: cmos: Use predefined value for RTC IRQ on legacy x86
  rtc: cmos: Stop using shared IRQ
  rtc: tps6586x: Use IRQ_NOAUTOEN flag
  rtc: at91rm9200: use FIELD_PREP/FIELD_GET
  rtc: at91rm9200: avoid time readout in at91_rtc_setalarm
  rtc: at91rm9200: move register definitions to C file
  rtc: at91rm9200: add sama5d4 and sama5d2 compatibles
  dt-bindings: rtc: at91rm9200: convert bindings to json-schema
  rtc: at91rm9200: remove procfs information
  dt-bindings: atmel, at91rm9200-rtc: add microchip, sam9x60-rtc
  rtc: pcf8563: Use BIT
  rtc: moxart: Convert to SPDX identifier
  rtc: ds1343: Remove unused struct spi_device in struct ds1343_priv
  rtc: rx8025: Remove struct i2c_client from struct rx8025_data
  rtc: hym8563: Read the valid flag directly instead of caching it
  ...
2020-02-04 07:03:40 +00:00
Linus Torvalds
af32f3a414 - New Drivers
- Add support for ROHM BD71828 PMICs and GPIOs
    - Add support for Qualcomm Aqstic Audio Codecs WCD9340 and WCD9341
 
 - New Device Support
    - Add support for BD71828 to BD70528 RTC driver
    - Add support for Intel's Jasper Lake to LPSS PCI
 
  - New Functionality
    - Add support for Power Key to ROHM BD71828
    - Add support for Clocks to ROHM BD71828
    - Add support for GPIOs to Dialog DA9062
    - Add support for USB PD Notify to ChromiumOS EC
    - Allow callers to specify args when requesting regmap lookup; syscon
 
  - Fix-ups
    - Improve error handling and sanity checking; atmel-hlcdc, dln2
    - Device Tree support/documentation; bd71828, da9062, xylon,logicvc,
                                         ab8500, max14577, atmel-usart
    - Match devices using platform IDs; bd7xxxx
    - Refactor BD718x7 regulator component; bd718x7-regulator
    - Use standard interfaces/helpers; syscon, sm501
    - Trivial (whitespace, spelling, etc); ab8500-core, Kconfig
    - Remove unused code; db8500-prcmu, tqmx86
    - Wait until boot has finished before accessing registers; madera-core
    - Provide missing register value defaults; cs47l15-tables
    - Allow more time for hardware to reset; madera-core
 
  - Bug Fixes
    - Fix erroneous register values; rohm-bd70528
    - Fix register volatility; axp20x, rn5t618
    - Fix Kconfig dependencies; MFD_MAX77650
    - Fix incorrect compatible string; da9062-core
    - Fix syscon_regmap_lookup_by_phandle_args() stub; syscon
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAl44Ga0ACgkQUa+KL4f8
 d2HRJg//VdigHgOTX/eJggI67n36kTgho+VzwRwLuSedDBFIkh5S8NWO7bFyf1Y4
 Qn+MybJtCvPQeUVmqO6cUi0/VqXgwW4mUe5L6oQKIsPYzfmhuc/XF+DA2S8ulOBj
 CckAM15i4WARCtNtFH12EaGGekLPAkik9nZE5EH7vS89TUxLMKbir72U+qFju6mu
 o2F8B7QbDe2jxaooxZ11zPjECwJfzgdXe+FipmogL1itLT+1phpirlttY4R5/4LV
 t3jKb3GI5xN+YWqyXHFF1EKtQEHTkYyKcby2It+8ksYAKiueY0hAuX7+pt1KXWjb
 ReM/hYH5dqjJSz6MjajrInHlpAf8iqtzNdXznSm/hQ9X+YHpaqmdYBt9bTg3pbR/
 z5F0q32e716K/XcJIv2igizT2EZDZIb2AG9oh0D93Z10tPgTpp0CTkcSsSw4CpnP
 MM60B2RN6RI/1MVK1eWRfWVSLbopsForetlnwXhTxY0Zr/7Hd+l+2ndz8IJE+vya
 86jq9yXv7kndwcKNIuUy5jIE2XV9JIbjwwDd4a8tbQgOMkSWHuV3pN+qnT6+/kRh
 TS/LFI49rjJauB85XdqhZc2+i0Eo78ctIdxQebKNZe6wz+r5Y5NTMMCZ5TjScxJX
 aSKRepOEtSbnKloUi5HZ71zfX/waTxzgyodkF7UJk3eEtzlDF8o=
 =t4+B
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "New Drivers:
   - Add support for ROHM BD71828 PMICs and GPIOs
   - Add support for Qualcomm Aqstic Audio Codecs WCD9340 and WCD9341

  New Device Support:
   - Add support for BD71828 to BD70528 RTC driver
   - Add support for Intel's Jasper Lake to LPSS PCI

  New Functionality:
   - Add support for Power Key to ROHM BD71828
   - Add support for Clocks to ROHM BD71828
   - Add support for GPIOs to Dialog DA9062
   - Add support for USB PD Notify to ChromiumOS EC
   - Allow callers to specify args when requesting regmap lookup; syscon

  Fix-ups:
   - Improve error handling and sanity checking; atmel-hlcdc, dln2
   - Device Tree support/documentation; bd71828, da9062, xylon,logicvc,
     ab8500, max14577, atmel-usart
   - Match devices using platform IDs; bd7xxxx
   - Refactor BD718x7 regulator component; bd718x7-regulator
   - Use standard interfaces/helpers; syscon, sm501
   - Trivial (whitespace, spelling, etc); ab8500-core, Kconfig
   - Remove unused code; db8500-prcmu, tqmx86
   - Wait until boot has finished before accessing registers;
     madera-core
   - Provide missing register value defaults; cs47l15-tables
   - Allow more time for hardware to reset; madera-core

  Bug Fixes:
   - Fix erroneous register values; rohm-bd70528
   - Fix register volatility; axp20x, rn5t618
   - Fix Kconfig dependencies; MFD_MAX77650
   - Fix incorrect compatible string; da9062-core
   - Fix syscon_regmap_lookup_by_phandle_args() stub; syscon"

* tag 'mfd-next-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (41 commits)
  mfd: syscon: Fix syscon_regmap_lookup_by_phandle_args() dummy
  mfd: wcd934x: Add support to wcd9340/wcd9341 codec
  mfd: syscon: Add arguments support for syscon reference
  mfd: rn5t618: Mark ADC control register volatile
  dt-bindings: atmel-usart: Add microchip,sam9x60-{usart, dbgu}
  dt-bindings: atmel-usart: Remove wildcard
  mfd: cros_ec: Add cros-usbpd-notify subdevice
  mfd: da9062: Fix watchdog compatible string
  mfd: madera: Allow more time for hardware reset
  mfd: cs47l15: Add missing register default
  mfd: madera: Wait for boot done before accessing any other registers
  mfd: Kconfig: Rename Samsung to lowercase
  mfd: tqmx86: remove set but not used variable 'i2c_ien'
  mfd: dbx500-prcmu: Drop DSI pll clock functions
  mfd: dbx500-prcmu: Drop set_display_clocks()
  mfd: max77650: Select REGMAP_IRQ in Kconfig
  mfd: axp20x: Mark AXP20X_VBUS_IPSOUT_MGMT as volatile
  mfd: ab8500: Fix ab8500-clk typo
  mfd: intel-lpss: Add Intel Jasper Lake PCI IDs
  dt-bindings: mfd: max14577: Add reference to max14040_battery.txt descriptions
  ...
2020-02-03 14:51:57 +00:00
Linus Torvalds
c5951e7c8e The main MIPS changes for 5.6:
- Support mremap() for the VDSO, primarily to allow CRIU to restore the
   VDSO to its checkpointed location.
 
 - Restore the MIPS32 cBPF JIT, after having reverted the enablement of
   the eBPF JIT for MIPS32 systems in the 5.5 cycle.
 
 - Improve cop0 counter synchronization behaviour whilst onlining CPUs by
   running with interrupts disabled.
 
 - Better match FPU behaviour when emulating multiply-accumulate
   instructions on pre-r6 systems that implement IEEE754-2008 style MACs.
 
 - Loongson64 kernels now build using the MIPS64r2 ISA, allowing them to
   take advantage of instructions introduced by r2.
 
 - Support for the Ingenic X1000 SoC & the really nice little CU Neo
   development board that's using it.
 
 - Support for WMAC on GARDENA Smart Gateway devices.
 
 - Lots of cleanup & refactoring of SGI IP27 (Origin 2*) support in
   preparation for introducing IP35 (Origin 3*) support.
 
 - Various Kconfig & Makefile cleanups.
 -----BEGIN PGP SIGNATURE-----
 
 iIwEABYIADQWIQRgLjeFAZEXQzy86/s+p5+stXUA3QUCXjRnpxYccGF1bGJ1cnRv
 bkBrZXJuZWwub3JnAAoJED6nn6y1dQDdNYoA/3ZhgKX1L/hwvkPKwu7FxbL41pjB
 WAm8IYDaxPvgxkcSAP9FNNepHK+oBPM8I2e3DvDvmcuYjumztdikzYbJ5HuMBA==
 =MV2S
 -----END PGP SIGNATURE-----

Merge tag 'mips_5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux

Pull MIPS changes from Paul Burton:
 "Nothing too big or scary in here:

   - Support mremap() for the VDSO, primarily to allow CRIU to restore
     the VDSO to its checkpointed location.

   - Restore the MIPS32 cBPF JIT, after having reverted the enablement
     of the eBPF JIT for MIPS32 systems in the 5.5 cycle.

   - Improve cop0 counter synchronization behaviour whilst onlining CPUs
     by running with interrupts disabled.

   - Better match FPU behaviour when emulating multiply-accumulate
     instructions on pre-r6 systems that implement IEEE754-2008 style
     MACs.

   - Loongson64 kernels now build using the MIPS64r2 ISA, allowing them
     to take advantage of instructions introduced by r2.

   - Support for the Ingenic X1000 SoC & the really nice little CU Neo
     development board that's using it.

   - Support for WMAC on GARDENA Smart Gateway devices.

   - Lots of cleanup & refactoring of SGI IP27 (Origin 2*) support in
     preparation for introducing IP35 (Origin 3*) support.

   - Various Kconfig & Makefile cleanups"

* tag 'mips_5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (60 commits)
  MIPS: PCI: Add detection of IOC3 on IO7, IO8, IO9 and Fuel
  MIPS: Loongson64: Disable exec hazard
  MIPS: Loongson64: Bump ISA level to MIPSR2
  MIPS: Make DIEI support as a config option
  MIPS: OCTEON: octeon-irq: fix spelling mistake "to" -> "too"
  MIPS: asm: local: add barriers for Loongson
  MIPS: Loongson64: Select mac2008 only feature
  MIPS: Add MAC2008 Support
  Revert "MIPS: Add custom serial.h with BASE_BAUD override for generic kernel"
  MIPS: sort MIPS and MIPS_GENERIC Kconfig selects alphabetically (again)
  MIPS: make CPU_HAS_LOAD_STORE_LR opt-out
  MIPS: generic: don't unconditionally select PINCTRL
  MIPS: don't explicitly select LIBFDT in Kconfig
  MIPS: sync-r4k: do slave counter synchronization with disabled HW interrupts
  MIPS: SGI-IP30: Check for valid pointer before using it
  MIPS: syscalls: fix indentation of the 'SYSNR' message
  MIPS: boot: fix typo in 'vmlinux.lzma.its' target
  MIPS: fix indentation of the 'RELOCS' message
  dt-bindings: Document loongson vendor-prefix
  MIPS: CU1000-Neo: Refresh defconfig to support HWMON and WiFi.
  ...
2020-01-31 11:28:31 -08:00
Geert Uytterhoeven
34719de919 rtc: i2c/spi: Avoid inclusion of REGMAP support when not needed
Merely enabling I2C and RTC selects REGMAP_I2C and REGMAP_SPI, even when
no driver needs it.  While the former can be moduler, the latter cannot,
and thus becomes built-in.

Fix this by moving the select statements for REGMAP_I2C and REGMAP_SPI
from the RTC_I2C_AND_SPI helper to the individual drivers that depend on
it.

Note that the comment for RTC_I2C_AND_SPI refers to SND_SOC_I2C_AND_SPI
for more information, but the latter does not select REGMAP_{I2C,SPI}
itself, and defers that to the individual drivers, too.

Fixes: 080481f54e ("rtc: merge ds3232 and ds3234")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: kbuild test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/20200112171349.22268-1-geert@linux-m68k.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-27 23:36:35 +01:00
Alexandre Belloni
578c2b661e rtc: Kconfig: select REGMAP_I2C when necessary
Some i2c RTC drivers are using regmap but are not selecting REGMAP_I2C
which may lead to build failures.

Link: https://lore.kernel.org/r/20200127221724.10160-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-27 23:36:19 +01:00
Alexandre Belloni
c682094107 rtc: Kconfig: properly indent sd3078 entry
The RTC_DRV_SD3078 is indented using spaces, use tabs instead.

Link: https://lore.kernel.org/r/20200127221724.10160-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-27 23:36:17 +01:00
Linus Torvalds
6a1000bd27 ioremap changes for 5.6
- remove ioremap_nocache given that is is equivalent to
    ioremap everywhere
 -----BEGIN PGP SIGNATURE-----
 
 iQI/BAABCgApFiEEgdbnc3r/njty3Iq9D55TZVIEUYMFAl4vKHwLHGhjaEBsc3Qu
 ZGUACgkQD55TZVIEUYMPGBAAuVNUZaZfWYHpiVP2oRcUQUguFiD3NTbknsyzV2oH
 J9P0GfeENSKwE9OOhZ7XIjnCZAJwQgTK/ppQY5yiQ/KAtYyyXjXEJ6jqqjiTDInr
 +3+I3t/LhkgrK7tMrb7ylTGa/d7KhaciljnOXC8+b75iddvM9I1z2pbHDbppZMS9
 wT4RXL/cFtRb85AfOyPLybcka3f5P2gGvQz38qyimhJYEzHDXZu9VO1Bd20f8+Xf
 eLBKX0o6yWMhcaPLma8tm0M0zaXHEfLHUKLSOkiOk+eHTWBZ3b/w5nsOQZYZ7uQp
 25yaClbameAn7k5dHajduLGEJv//ZjLRWcN3HJWJ5vzO111aHhswpE7JgTZJSVWI
 ggCVkytD3ESXapvswmACSeCIDMmiJMzvn6JvwuSMVB7a6e5mcqTuGo/FN+DrBF/R
 IP+/gY/T7zIIOaljhQVkiEIIwiD/akYo0V9fheHTBnqcKEDTHV4WjKbeF6aCwcO+
 b8inHyXZSKSMG//UlDuN84/KH/o1l62oKaB1uDIYrrL8JVyjAxctWt3GOt5KgSFq
 wVz1lMw4kIvWtC/Sy2H4oB+RtODLp6yJDqmvmPkeJwKDUcd/1JKf0KsZ8j3FpGei
 /rEkBEss0KBKyFAgBSRO2jIpdj2epgcBcsdB/r5mlhcn8L77AS6mHbA173kY4pQ/
 Kdg=
 =TUCJ
 -----END PGP SIGNATURE-----

Merge tag 'ioremap-5.6' of git://git.infradead.org/users/hch/ioremap

Pull ioremap updates from Christoph Hellwig:
 "Remove the ioremap_nocache API (plus wrappers) that are always
  identical to ioremap"

* tag 'ioremap-5.6' of git://git.infradead.org/users/hch/ioremap:
  remove ioremap_nocache and devm_ioremap_nocache
  MIPS: define ioremap_nocache to ioremap
2020-01-27 13:03:00 -08:00
Andy Shevchenko
604c521259 rtc: cmos: Refactor code by using the new dmi_get_bios_year() helper
Refactor code by using the new dmi_get_bios_year() helper instead of
open coding its functionality. This also makes logic slightly clearer.

No changes intended.

Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20200123131437.28157-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-25 21:55:14 +01:00
Andy Shevchenko
5848ad2f1b rtc: cmos: Use predefined value for RTC IRQ on legacy x86
When legacy devices are present on x86 machine, the RTC IRQ has
a dedicated pre-defined value. Use it instead of hard coded number.

Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20200123131437.28157-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-25 21:55:12 +01:00
Andy Shevchenko
b6da197a2e rtc: cmos: Stop using shared IRQ
As reported by Guilherme G. Piccoli:

---8<---8<---8<---

The rtc-cmos interrupt setting was changed in the commit 079062b28f
("rtc: cmos: prevent kernel warning on IRQ flags mismatch") in order
to allow shared interrupts; according to that commit's description,
some machine got kernel warnings due to the interrupt line being shared
between rtc-cmos and other hardware, and rtc-cmos didn't allow IRQ sharing
that time.

After the aforementioned commit though it was observed a huge increase
in lost HPET interrupts in some systems, observed through the following
kernel message:

[...] hpet1: lost 35 rtc interrupts

After investigation, it was narrowed down to the shared interrupts
usage when having the kernel option "irqpoll" enabled. In this case,
all IRQ handlers are called for non-timer interrupts, if such handlers
are setup in shared IRQ lines. The rtc-cmos IRQ handler could be set to
hpet_rtc_interrupt(), which will produce the kernel "lost interrupts"
message after doing work - lots of readl/writel to HPET registers, which
are known to be slow.

Although "irqpoll" is not a default kernel option, it's used in some contexts,
one being the kdump kernel (which is an already "impaired" kernel usually
running with 1 CPU available), so the performance burden could be considerable.
Also, the same issue would happen (in a shorter extent though) when using
"irqfixup" kernel option.

In a quick experiment, a virtual machine with uptime of 2 minutes produced
>300 calls to hpet_rtc_interrupt() when "irqpoll" was set, whereas without
sharing interrupts this number reduced to 1 interrupt. Machines with more
hardware than a VM should generate even more unnecessary HPET interrupts
in this scenario.

---8<---8<---8<---

After looking into the rtc-cmos driver history and DSDT table from
the Microsoft Surface 3, we may notice that Hans de Goede submitted
a correct fix (see dependency below). Thus, we simply revert
the culprit commit.

Fixes: 079062b28f ("rtc: cmos: prevent kernel warning on IRQ flags mismatch")
Depends-on: a1e23a42f1 ("rtc: cmos: Do not assume irq 8 for rtc when there are no legacy irqs")
Reported-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20200123131437.28157-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-25 21:54:57 +01:00
Dmitry Osipenko
4c4ab451ae rtc: tps6586x: Use IRQ_NOAUTOEN flag
The IRQ_NOAUTOEN flag tells interrupt core that interrupt shall not be
auto-enabled at the time of requesting interrupt. This is a minor clean-up
change that doesn't fix any problems.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Link: https://lore.kernel.org/r/20200106015615.12602-1-digetx@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-25 21:50:18 +01:00
Matti Vaittinen
fe5a591b78 rtc: bd70528: add BD71828 support
ROHM BD71828 PMIC RTC block is from many parts similar to one
on BD70528. Support BD71828 RTC using BD70528 RTC driver and
avoid re-inventing the wheel.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2020-01-24 07:23:06 +00:00
Alexandre Belloni
3c7b90cb14 rtc: at91rm9200: use FIELD_PREP/FIELD_GET
Use FIELD_PREP and FIELD_GET instead of hardcoding already defined values.

Link: https://lore.kernel.org/r/20191229204421.337612-6-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-15 15:11:10 +01:00
Alexandre Belloni
565205d5ad rtc: at91rm9200: avoid time readout in at91_rtc_setalarm
The current rtc time is read out in at91_rtc_setalarm but it it immediately
overwritten by the alarm time. Remove the readout.

Link: https://lore.kernel.org/r/20191229204421.337612-5-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-15 15:11:08 +01:00
Alexandre Belloni
a1243b099e rtc: at91rm9200: move register definitions to C file
The header was simply moved from the arm mach folder to drivers/rtc but
there is not point in having it separated from the driver.

Also remove unused bit definitions and use BIT and GENMASK.

Link: https://lore.kernel.org/r/20191229204421.337612-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-15 15:11:07 +01:00
Alexandre Belloni
ca3fdc989c rtc: at91rm9200: add sama5d4 and sama5d2 compatibles
Both the sama5d4 and sama5d2 RTCs have more features than the previous
RTCs, add a compatible string for them.

Link: https://lore.kernel.org/r/20191229204421.337612-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-15 12:13:54 +01:00
Alexandre Belloni
b7052876d7 rtc: at91rm9200: remove procfs information
The RTC procfs interface is deprecated and hasn't been used by userspace
for years.

Link: https://lore.kernel.org/r/20191229204421.337612-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-15 12:10:05 +01:00
Thomas Bogendoerfer
10cf8300ec
MIPS: SGI-IP27: fix readb/writeb addressing
Our chosen byte swapping, which is what firmware already uses, is to
do readl/writel by normal lw/sw intructions (data invariance). This
also means we need to mangle addresses for u8 and u16 accesses. The
mangling for 16bit has been done aready, but 8bit one was missing.
Correcting this causes different addresses for accesses to the
SuperIO and local bus of the IOC3 chip. This is fixed by changing
byte order in ioc3 and m48rtc_rtc structs.

Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
Signed-off-by: Paul Burton <paulburton@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: David S. Miller <davem@davemloft.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: linux-rtc@vger.kernel.org
2020-01-09 15:30:56 -08:00
Enric Balletbo i Serra
11f1eabee0 cros_ec: treewide: Remove 'include/linux/mfd/cros_ec.h'
This header file now only includes the cros_ec_dev struct, however, is the
'include/linux/platform_data/cros_ec_proto.h' who contains the definition of
all the Chrome OS EC related structs. There is no reason to have a
separate include for this struct so move to the place where other
structs are defined. That way, we can remove the include itself, but also
simplify the common pattern

    #include <linux/mfd/cros_ec.h>
    #include <linux/platform_data/cros_ec_proto.h>

for a single include

    #include <linux/platform_data/cros_ec_proto.h>

The changes to remove the cros_ec.h include were generated with the
following shell script:

    git grep -l "<linux/mfd/cros_ec.h>" | xargs sed -i '/<linux\/mfd\/cros_ec.h>/d'

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Sebastian Reichel <sre@kernel.org>
Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
2020-01-07 17:36:46 +01:00
Christoph Hellwig
4bdc0d676a remove ioremap_nocache and devm_ioremap_nocache
ioremap has provided non-cached semantics by default since the Linux 2.6
days, so remove the additional ioremap_nocache interface.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
2020-01-06 09:45:59 +01:00
Alexandre Belloni
f01f4ffdfb rtc: cmos: Revert "rtc: Fix the AltCentury value on AMD/Hygon platform"
There are multiple reports of this patch breaking RTC time setting for AMD
platforms.

This reverts commit 7ad295d519.

Cc: Jinke Fan <fanjinke@hygon.cn>
Link: https://lore.kernel.org/r/CABXGCsMLob0DC25JS8wwAYydnDoHBSoMh2_YLPfqm3TTvDE-Zw@mail.gmail.com
Fixes: 7ad295d519 ("rtc: Fix the AltCentury value on AMD/Hygon platform")
Link: https://lore.kernel.org/r/20200104043110.707810-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2020-01-04 05:31:50 +01:00
Nobuhiro Iwamatsu
d53f9b68b3 rtc: pcf8563: Use BIT
Replace (1 << ...) with BIT().

CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Link: https://lore.kernel.org/r/20191218082553.3309554-1-iwamatsu@nigauri.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:23:53 +01:00
Nobuhiro Iwamatsu
7dc679ef25 rtc: moxart: Convert to SPDX identifier
Use SPDX-License-Identifier instead of a verbose license text.

CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
CC: Jonas Jensen <jonas.jensen@gmail.com>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Link: https://lore.kernel.org/r/20191218082836.3309808-1-iwamatsu@nigauri.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:23:49 +01:00
Nobuhiro Iwamatsu
d6e62e7f10 rtc: ds1343: Remove unused struct spi_device in struct ds1343_priv
struct spi_device in struct ds1343_priv is not used, remove it.

CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
CC: Raghavendra Chandra Ganiga <ravi23ganiga@gmail.com>
CC: Ankur Srivastava <sankurece@gmail.com>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Link: https://lore.kernel.org/r/20191218081917.3308211-1-iwamatsu@nigauri.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:22:32 +01:00
Nobuhiro Iwamatsu
47a3c04837 rtc: rx8025: Remove struct i2c_client from struct rx8025_data
struct i2c_client can be referenced from the device structure, so this
doesn't need to have it in struct rx8025_data.
Remove struct i2c_client from struct rx8025_data.

CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Alexandre Belloni <alexandre.belloni@bootlin.com>
CC: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
Link: https://lore.kernel.org/r/20191218081624.3307752-1-iwamatsu@nigauri.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:22:21 +01:00
Paul Kocialkowski
e2ed7507ae rtc: hym8563: Read the valid flag directly instead of caching it
The RTC has a valid bit in the seconds register that indicates whether
power was lost since the pevious time set. This bit is currently read
once at probe time, cached and updated with set_time.

Howeever, caching the bit may prevent detecting power loss at runtime
(which can happen if the RTC's supply is distinct from the the platform's).

Writing the seconds register when setting time will clear the bit,
so there should be no downside in reading the bit directly instead of
caching it.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Link: https://lore.kernel.org/r/20191212153111.966923-2-paul.kocialkowski@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:18:06 +01:00
Paul Kocialkowski
f236a2a2eb rtc: hym8563: Return -EINVAL if the time is known to be invalid
The current code returns -EPERM when the voltage loss bit is set.
Since the bit indicates that the time value is not valid, return
-EINVAL instead, which is the appropriate error code for this
situation.

Fixes: dcaf038493 ("rtc: add hym8563 rtc-driver")
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Link: https://lore.kernel.org/r/20191212153111.966923-1-paul.kocialkowski@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:18:04 +01:00
Nobuhiro Iwamatsu
aeedfe7f89 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>
2019-12-23 11:16:23 +01:00
zhengbin
de0505660f rtc: omap: Remove unneeded semicolon
Fixes coccicheck warning:

drivers/rtc/rtc-omap.c:619:2-3: Unneeded semicolon

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Link: https://lore.kernel.org/r/1576466353-45384-1-git-send-email-zhengbin13@huawei.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:16:23 +01:00
Chuhong Yuan
62cbe63f58 rtc: asm9260: add the missed check for devm_clk_get
The driver misses a check for devm_clk_get().
Add the check to fix it.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Link: https://lore.kernel.org/r/20191214074528.16806-1-hslester96@gmail.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:16:23 +01:00
Alexandre Belloni
bd0d937928 rtc: rv3029: remove useless error messages
Remove redundant messages or messages that would not add any value because
the information is already conveyed properly using errno.

Link: https://lore.kernel.org/r/20191223100108.1083078-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:16:23 +01:00
Alexandre Belloni
fc219291ea rtc: rv3029: annotate init and exit functions
rv30{2,4}9_register_driver and rv30{2,4}9_unregister_driver are only called
from the init and exit functions of the module. Annotate them properly.

Link: https://lore.kernel.org/r/20191223101430.1091572-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:16:23 +01:00
Alexandre Belloni
8e99106c92 rtc: rv3029: drop deprecated compatbiles
The compatibles have been marked obsolete for more that 2 years, drop them
now. Note that this doesn't currently prevent the driver from probing
because the i2c core will still match using the i2c_device_id table.

Link: https://lore.kernel.org/r/20191212230239.65784-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:13:50 +01:00
Alexandre Belloni
ec923fcccf rtc: rv3029: add nvram support
Export the 8 byte RAM using nvmem.

Link: https://lore.kernel.org/r/20191214221022.622482-17-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-23 11:13:49 +01:00
Alexandre Belloni
cbc943eb37 rtc: rv3029: let the core handle rtc range
Despite the comment, the RV3029 uses a 7bit BCD register for the year,
making 2079 the last supported year.

Link: https://lore.kernel.org/r/20191214221022.622482-14-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:38:07 +01:00
Alexandre Belloni
9346f87066 rtc: rv3029: convert to devm_rtc_allocate_device
This allows further improvement of the driver.

Link: https://lore.kernel.org/r/20191214221022.622482-13-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:38:06 +01:00
Alexandre Belloni
cff2e4d278 rtc: rv3029: correctly handle PON and VLOW2
In case the data is invalid (PON or VLOW2 are set in STATUS, explicitly
tell userspace that the time is invalid. Only remove VLOW2 when setting a
new valid time.

Link: https://lore.kernel.org/r/20191214221022.622482-12-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:38:04 +01:00
Alexandre Belloni
f630f728a9 rtc: rv3029: add RTC_VL_READ and RTC_VL_CLEAR support
The RV3029 can report three different conditions: power on, voltage dropped
and data is lost and voltage is low and temperature compensation has
stopped. The first two conditions amount to the same status, the RTC data
is invalid.

VLOW1 has to be cleared manually to resume temperature compensation, this
is achieved using RTC_VL_CLEAR.

Link: https://lore.kernel.org/r/20191214221022.622482-11-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:38:02 +01:00
Alexandre Belloni
7518dd9a93 rtc: rv3029: drop rv3029_read_regs and rv3029_write_regs
rv3029_read_regs and rv3029_write_regs are simply calling
regmap_bulk_{read,write}. Drop them and call regmap_{,bulk}_{read,write} as
appropriate.

Link: https://lore.kernel.org/r/20191214221022.622482-10-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:38:01 +01:00
Alexandre Belloni
8fd3d609a5 rtc: rv3029: simplify rv3029_set_alarm
It is unecessay to test alarm->enabled before calling
rv3029_alarm_irq_enable.

Link: https://lore.kernel.org/r/20191214221022.622482-9-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:59 +01:00
Alexandre Belloni
38ce8e30f3 rtc: rv3029: simplify rv3029_alarm_irq_enable
Use regmap_update_bits instead of open coding it in
rv3029_alarm_irq_enable.

Link: https://lore.kernel.org/r/20191214221022.622482-8-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:57 +01:00
Alexandre Belloni
bb72dbba83 rtc: rv3029: get rid of rv3029_get_sr
There is no point in having 2 indirections before calling regmap_read,
especially since rv3029_get_sr also changes the return value without any
good reason. Call regmap_read directly.

Link: https://lore.kernel.org/r/20191214221022.622482-7-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:56 +01:00
Alexandre Belloni
35c2daaf55 rtc: rv3029: avoid reading the status register uselessly
RV3029_STATUS is read in multiple location but its value is never used
afterwards. Avoid this register access when not necessary.

Link: https://lore.kernel.org/r/20191214221022.622482-6-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:54 +01:00
Alexandre Belloni
54c5970df4 rtc: rv3029: remove race condition when update STATUS
There is no lock preventing concurrent access to the status register from
bth the rtc subsystem and the hwmon subsystem. Use regmap_update_bits to
ensure updating RV3029_STATUS is properly locked.

Link: https://lore.kernel.org/r/20191214221022.622482-5-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:52 +01:00
Alexandre Belloni
609e97fe31 rtc: rv3029: remove open coded regmap_update_bits
rv3029_update_bits open codes regmap_update_bits and forgets to properly
lock the register range while doing so. Use regmap_update_bits instead.

Link: https://lore.kernel.org/r/20191214221022.622482-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:51 +01:00
Alexandre Belloni
c509e4344b rtc: rv3029: let regmap validate the register ranges
Instead of trying to validate the accessed registers in custom functions,
let regmap handle that. This allows to defines all the holes in the
register range and gives access to the regmap debugfs register dump.

Link: https://lore.kernel.org/r/20191214221022.622482-3-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:49 +01:00
Alexandre Belloni
9b45ef9774 rtc: rv3029: use proper name for the driver
The correct name for the rtc is rv3029. c2 is actually the package form
factor rv3029c3 exists and simply has a smaller form factor.

Link: https://lore.kernel.org/r/20191214221022.622482-2-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:47 +01:00
Alexandre Belloni
8049c11399 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>
2019-12-18 10:37:45 +01:00
Alexandre Belloni
894b043200 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>
2019-12-18 10:37:44 +01:00
Alexandre Belloni
bcd17c5082 rtc: rv8803: return meaningful value for RTC_VL_READ
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-18 10:37:42 +01:00
Alexandre Belloni
7e890a0f0e rtc: rv8803: avoid clearing RV8803_FLAG_V2F in RTC_VL_CLR
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-12-18 10:37:40 +01:00
Alexandre Belloni
86e655f9f3 rtc: rv3028: return meaningful value for RTC_VL_READ
RV3028_STATUS_PORF means the voltage dropped too low and data has been
lost.

Link: https://lore.kernel.org/r/20191214220259.621996-14-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:39 +01:00
Alexandre Belloni
92c02daaba rtc: rv3028: 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-13-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:37 +01:00
Alexandre Belloni
f86dc5bde1 rtc: pcf85063: return meaningful value for RTC_VL_READ
PCF85063_REG_SC_OS means the voltage dropped too low and data has been
lost.

Link: https://lore.kernel.org/r/20191214220259.621996-12-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:35 +01:00
Alexandre Belloni
0295c27f90 rtc: pcf85063: 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-11-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:33 +01:00
Alexandre Belloni
b371b10e94 rtc: pcf8563: return meaningful value for RTC_VL_READ
PCF8563_SC_LV means the voltage dropped too low and data has been lost.

Link: https://lore.kernel.org/r/20191214220259.621996-10-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:32 +01:00
Alexandre Belloni
935272aade rtc: pcf8563: stop caching voltage_low
voltage_low is only updated when reading the time, this means that using
RTC_VL_READ will miss the VL flag if the time has not been read before
using the ioctl. Always read the status from the hardware.

Link: https://lore.kernel.org/r/20191214220259.621996-9-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:30 +01:00
Alexandre Belloni
75d26f5c23 rtc: pcf8563: remove conditional compilation
Always compile pcf8563_rtc_ioctl as we are sure that CONFIG_RTC_INTF_DEV is
selected on actual kernel configurations.

Link: https://lore.kernel.org/r/20191214220259.621996-8-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:28 +01:00
Alexandre Belloni
d268f4bd42 rtc: pcf8563: 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-7-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:27 +01:00
Alexandre Belloni
244cf8f0ed 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>
2019-12-18 10:37:25 +01:00
Alexandre Belloni
af4273116d rtc: pcf2127: return meaningful value for RTC_VL_READ
PCF2127_BIT_CTRL3_BLF indicates the battery is low and needs to be replaced
soon.

Link: https://lore.kernel.org/r/20191214220259.621996-5-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:23 +01:00
Alexandre Belloni
9f05342a97 rtc: abx80x: return meaningful value for RTC_VL_READ
ABX8XX_STATUS_BLF indicates the battery is low and needs to be replaced
soon.

Link: https://lore.kernel.org/r/20191214220259.621996-4-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-18 10:37:21 +01:00
Ran Bi
653997eeec rtc: mt6397: fix alarm register overwrite
Alarm registers high byte was reserved for other functions.
This add mask in alarm registers operation functions.
This also fix error condition in interrupt handler.

Fixes: fc2979118f ("rtc: mediatek: Add MT6397 RTC driver")

Signed-off-by: Ran Bi <ran.bi@mediatek.com>
Signed-off-by: Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com>
Link: https://lore.kernel.org/r/1576057435-3561-6-git-send-email-hsin-hsiung.wang@mediatek.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-12-11 13:22:54 +01:00