Commit Graph

3141 Commits

Author SHA1 Message Date
Colin Ian King
e422808860 rtc: pm8xxx: fix unintended sign extension
Shifting a u8 by 24 will cause the value to be promoted to an integer. If
the top bit of the u8 is set then the following conversion to an unsigned
long will sign extend the value causing the upper 32 bits to be set in
the result.

Fix this by casting the u8 value to an unsigned long before the shift.

Detected by CoverityScan, CID#1309693 ("Unintended sign extension")

Fixes: 9a9a54ad7a ("drivers/rtc: add support for Qualcomm PMIC8xxx RTC")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-08 09:30:13 +01:00
Colin Ian King
fb0b322537 rtc: 88pm80x: fix unintended sign extension
Shifting a u8 by 24 will cause the value to be promoted to an integer. If
the top bit of the u8 is set then the following conversion to an unsigned
long will sign extend the value causing the upper 32 bits to be set in
the result.

Fix this by casting the u8 value to an unsigned long before the shift.

Detected by CoverityScan, CID#714646-714649 ("Unintended sign extension")

Fixes: 2985c29c19 ("rtc: Add rtc support to 88PM80X PMIC")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-08 09:30:13 +01:00
Colin Ian King
dc9e471606 rtc: 88pm860x: fix unintended sign extension
Shifting a u8 by 24 will cause the value to be promoted to an integer. If
the top bit of the u8 is set then the following conversion to an unsigned
long will sign extend the value causing the upper 32 bits to be set in
the result.

Fix this by casting the u8 value to an unsigned long before the shift.

Detected by CoverityScan, CID#144925-144928 ("Unintended sign extension")

Fixes: 008b30408c ("mfd: Add rtc support to 88pm860x")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-08 09:30:13 +01:00
Uwe Kleine-König
3f929cad94 rtc: ds1307: rx8130: Fix alarm handling
When the EXTENSION.WADA bit is set, register 0x19 contains a bitmap of
week days, not a day of month. As Linux only handles a single alarm
without repetition using day of month is more flexible, so clear this
bit. (Otherwise a value depending on time.tm_wday would have to be
written to register 0x19.)

Also optimize setting the AIE bit to use a single register write instead
of a bulk write of three registers.

Fixes: ee0981be77 ("rtc: ds1307: Add support for Epson RX8130CE")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-07 20:55:48 +01:00
Uwe Kleine-König
501f98266c rtc: ds1307: rx8130: honor Voltage Loss Flag when reading the time
When voltage dropped since the RTC was last set the reported time is not
reliable. In this case return an error indicator instead of a bogus
time.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-07 20:55:46 +01:00
Uwe Kleine-König
3ffd4a2fcf rtc: ds1307: correct register offset for rx8130
While rx8130 has a register offset of 0x10 in its chip_desc, this isn't
used when regmap accesses are done. So add 0x10 to access the right
locations.

Fixes: ee0981be77 ("rtc: ds1307: Add support for Epson RX8130CE")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-07 20:55:44 +01:00
Uwe Kleine-König
d0e3f61b08 rtc: ds1307: forward declare chips array instead of a bunch of functions
There used to be 16 declarations for static functions. By just adding a
declaration for the chips array and reordering the functions the 16
function declarations can be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-07 20:55:41 +01:00
Uwe Kleine-König
92cbf12fc2 rtc: ds1307: Move register definitions to start of file
This allows to use the register offsets in all functions
which is needed in one of the next patches.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-07 20:55:39 +01:00
Anson Huang
13a929f38a rtc: imx-sc: add rtc set time support
This patch adds i.MX system controller RTC set time support, the
RTC set time is implemented via SIP(silicon provider) runtime
service call and ARM-Trusted-Firmware will communicate with system
controller via MU(message unit) IPC to set RTC time.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-07 20:45:39 +01:00
Oliver.Rohe@wago.com
761acdda5c rtc: rs5c372: r2221: fix to use the correct XSTP bit
The Ricoh chips have slightly different register layouts
and the r2221 chip uses bit 5 as the oscillator halt sensor bit.

Signed-off-by: Olive Rohe <oliver.rohe@wago.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-05 23:11:31 +01:00
Anson Huang
edb190cb17 rtc: snvs: make sure clock is enabled for interrupt handle
During system suspend, the SNVS RTC's clock will be disabled in
noirq suspend phase, but SNVS RTC's alarm interrupt could still
arrive, system will hang if SNVS RTC driver tries to access register
without clock enabled, this patch fixes the issue of this scenario.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-05 23:11:31 +01:00
Colin Ian King
f0c04c2767 rtc: ds1672: fix unintended sign extension
Shifting a u8 by 24 will cause the value to be promoted to an integer. If
the top bit of the u8 is set then the following conversion to an unsigned
long will sign extend the value causing the upper 32 bits to be set in
the result.

Fix this by casting the u8 value to an unsigned long before the shift.

Detected by CoverityScan, CID#138801 ("Unintended sign extension")

Fixes: edf1aaa31f ("[PATCH] RTC subsystem: DS1672 driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-02-05 23:11:31 +01:00
Marek Vasut
75455e258e rtc: abx80x: Configure reserved bits in RV1805
The RV1805 uses smaller package than the AB1805, discern those two
chips based on the compatible value and configure reserved bits in
the RV1805 to prevent current leakage and accidental test mode entry.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: linux-rtc@vger.kernel.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-30 16:09:36 +01:00
YueHaibing
a3b8bcbafa rtc: sd3078: fix platform_no_drv_owner.cocci warnings
Remove .owner field if calls are used which set it automatically
Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-23 15:42:31 +01:00
Jan Kotas
42986fb811 rtc: Add Cadence RTC driver
This patch adds a driver for Cadence RTC controller.

It can be enabled with RTC_DRV_CADENCE Kconfig option.
It supports waking system from sleep modes.

Signed-off-by: Jan Kotas <jank@cadence.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 19:18:27 +01:00
Eric Wong
2a4daadd4d rtc: cmos: ignore bogus century byte
Older versions of Libreboot and Coreboot had an invalid value
(`3' in my case) in the century byte affecting the GM45 in
the Thinkpad X200.  Not everybody's updated their firmwares,
and Linux <= 4.2 was able to read the RTC without problems,
so workaround this by ignoring invalid values.

Fixes: 3c217e51d8 ("rtc: cmos: century support")

Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Sylvain Chouleur <sylvain.chouleur@intel.com>
Cc: Patrick McDermott <patrick.mcdermott@libiquity.com>
Cc: linux-rtc@vger.kernel.org
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 19:05:32 +01:00
Kangjie Lu
9a20b5e35a rtc: hym8563: fix a missing check of block data read
When i2c_smbus_read_i2c_block_data() fails, the read data in "buf" could
be incorrect and should not be used. The fix checks if
i2c_smbus_read_i2c_block_data fails, and if so, return its error code
upstream.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 19:03:43 +01:00
Kangjie Lu
5910fa0d0d rtc: coh901331: fix a missing check of clk_prepare
clk_prepare() could fail, so let's check its status and if it fails
return its error code upstream.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 19:01:19 +01:00
Sam Ravnborg
bbb4383826 rtc: pcf85063: set xtal load capacitance from DT
Add support for specifying the xtal load capacitance in the DT node.
The pcf85063 supports xtal load capacitance of 7pF or 12.5pF.
If the rtc has the wrong configuration the time will
drift several hours/week.

The driver use the default value 7pF.

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

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Urs Fässler <urs.fassler@bbv.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 18:57:10 +01:00
Sam Ravnborg
189927e719 rtc: pcf8523: set xtal load capacitance from DT
Add support for specifying the xtal load capacitance in the DT node.
The pcf8523 supports xtal load capacitance of 7pF or 12.5pF.
If the rtc has the wrong configuration the time will
drift several hours/week.

The driver use the default value 12.5pF.

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

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 18:57:08 +01:00
Marek Szyprowski
64704c92fd rtc: s3c: Use generic helper to get driver data
Replace of_match_node() with of_device_get_match_data(), which removes a
few lines of code from the driver.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 18:36:27 +01:00
Marek Szyprowski
5a5b614ba6 rtc: s3c: Rewrite clock handling
s3c_rtc_enable/disable_clk() functions were designed to be called multiple
times without reference counting, because they were initially only used in
alarm setting/clearing functions, which can be called both when alarm is
already set or not. Later however, calls to those functions have been added to
other places in the driver - like time and /proc reading callbacks, what
results in broken alarm if any of such events happens after the alarm has
been set. Fix this by simplifying s3c_rtc_enable/disable_clk() functions
to rely on proper reference counting in clock core and move alarm enable
counter to s3c_rtc_setaie() function.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 18:34:42 +01:00
Wei Yongjun
f724c6bee1 rtc: sd3078: make symbol 'sd3078_driver' static
Fixes the following sparse warning:

drivers/rtc/rtc-sd3078.c:218:19: warning:
 symbol 'sd3078_driver' was not declared. Should it be static?

Fixes: 1d67a23210 ("rtc: sd3078: new driver.")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-22 17:53:19 +01:00
Trent Piepho
c8c97a4fb5 rtc: isl1208: fix negative digital trim reporting
isl1208_i2c_get_dtr() was returning the dtr value directly, but could
also return a negative error code.  Negative trimming values, e.g. -20,
would get interpreted as an error code, e.g. -ENOTDIR.

This patch offsets the dtr value by 100 so it's positive and won't alias
an error code.

Also fix check that considered a return value of -1 to be success.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-10 22:27:06 +01:00
ZhangXiaoxu
074b01a51d rtc: Fix UBSAN overflow warning
Users may call 'ioctl' and pass a very big value on 'tm->tm_year'.
It can be overflowed in 'int' after add 1900.
In function 'rtc_month_days' and 'mktime64', also treated it as an
'unsigned' parameter.

UBSAN: Undefined behaviour in drivers/rtc/rtc-lib.c:103:59
signed integer overflow:
2147483647 + 1900 cannot be represented in type 'int'

UBSAN: Undefined behaviour in drivers/rtc/rtc-lib.c:119:30
signed integer overflow:
2147483647 + 1900 cannot be represented in type 'int'

So, covert it to 'unsigned' explicitly.

Signed-off-by: ZhangXiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-10 22:02:44 +01:00
Alexandre Belloni
7c617e0c5f rtc: pcf8523: Add rv8523 compatible
The Microcrystal RV-8523 is compatible with the PCF8523.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-10 21:51:24 +01:00
Dianlong Li
1d67a23210 rtc: sd3078: new driver.
The sd3078 is a combination RTC and SRAM device with I2C interface.

Signed-off-by: Dianlong Li <long17.cool@163.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-01-10 21:51:22 +01:00
Linus Torvalds
28e8c4bc8e RTC for 4.21
Subsystem:
  - new %ptR printk format
  - rename core files
  - allow registration of multiple nvmem devices
 
 New driver:
  - i.MX system controller RTC
 
 Drivers:
  - abx80x: handle voltage ioctls, correct binding doc
  - m41t80: correct month in alarm reads
  - pcf85363: add pcf85263 support
  - pcf8523: properly handle battery low flag
  - s3c: limit alarm to one year in the future as ALMYEAR is broken
  - sun6i: rework clock output binding
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEXx9Viay1+e7J/aM4AyWl4gNJNJIFAlwqU44ACgkQAyWl4gNJ
 NJJjGxAAgQMTkarMx16icKpN35iuXgwZdIKKmWIHGyCJeB1ykHS8TgwkP+4pE1aN
 UwTw6x9TBxa9KpuexCgrx8/zppM0i1jacaxJkDbrj1OBPAlGrbJrwcSH029qHAu6
 N1Oo0GvAIPlEmIJkKVWkgZhGqUwvMvcy2amk06S92PPOIfr5zJsRzNmduEE7bpcl
 86EckuFOp9c1p4IayeQhIT+GHPtum4WkmGVw3+j0j/E6aCUD3thLohT+KuGfzzKn
 jHbtZ+/d17etKtxxI26YrmixH603t66ZSuc64rSvKRKYR8u/qqR3ZTotYVonsPHj
 NNQsWiNRzwkpiN9n1Big0tLJyXJ6qbYQIrJLMc19Jr10tS815WF5rjmNinfdSazX
 4xucIJpMh7VgA3W5BpvN1+UEahiznp2QGiLjauoruMrB7XUUSLPv6VohFiKAfd9S
 7SyV2moPWVnj4pJPH6Af2zVLE9YyPoWGvUSwosLZKhpoFNLOnVZAU0vo32M/23wv
 ejv4YPhtqxqT94XUyrWKE1DaTpxMqBHcHj2ThV+NGCWe4C0+KfW0zmbKm1X588UJ
 ZhmGODV9acU+46It5mFoE2Zb9WPyEwljjxbvXKQZhdONKIoZ6lz1i7nzy6C2qerQ
 ZW5baiaCvQ5e/NyWLxEZwvHukBo2OBxkXe8isuk/wz+7Qyw3l34=
 =5He5
 -----END PGP SIGNATURE-----

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

Pull RTC updates from Alexandre Belloni:
 "Subsystem:
   - new %ptR printk format
   - rename core files
   - allow registration of multiple nvmem devices

  New driver:
   - i.MX system controller RTC

  Driver updates:
   - abx80x: handle voltage ioctls, correct binding doc
   - m41t80: correct month in alarm reads
   - pcf85363: add pcf85263 support
   - pcf8523: properly handle battery low flag
   - s3c: limit alarm to one year in the future as ALMYEAR is broken
   - sun6i: rework clock output binding"

* tag 'rtc-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (54 commits)
  rtc: rename core files
  rtc: nvmem: fix possible use after free
  rtc: add i.MX system controller RTC support
  dt-bindings: fsl: scu: add rtc binding
  rtc: pcf2123: Add Microcrystal rv2123
  rtc: class: reimplement devm_rtc_device_register
  rtc: enforce rtc_timer_init private_data type
  rtc: abx80x: Implement RTC_VL_READ,CLR ioctls
  rtc: pcf85363: Add support for NXP pcf85263 rtc
  dt-bindings: rtc: pcf85363: Document pcf85263 real-time clock
  rtc: pcf8523: don't return invalid date when battery is low
  dt-bindings: rtc: use a generic node name for ds1307
  PM: Switch to use %ptR
  m68k/mac: Switch to use %ptR
  Input: hp_sdc_rtc - Switch to use %ptR
  rtc: tegra: Switch to use %ptR
  rtc: s5m: Switch to use %ptR
  rtc: s3c: Switch to use %ptR
  rtc: rx8025: Switch to use %ptR
  rtc: rx6110: Switch to use %ptR
  ...
2019-01-01 13:24:31 -08:00
Alexandre Belloni
36e14f5fdf rtc: rename core files
Rename core files so there is a clearer separation between the RTC core and
the RTC drivers.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-31 11:36:16 +01:00
Alexandre Belloni
bba3d2daa8 rtc: nvmem: fix possible use after free
In cas of probe failure, devres may free the memory allocated for
rtc->nvram before devm_rtc_release_device() is called. This leads to
rtc_nvram_unregister using it after being freed which may lead to a crash.

This has been shown to happen after commit 461e557b97 ("rtc: nvmem: use
devm_nvmem_register()")

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-31 00:49:36 +01:00
Anson Huang
e01b578195 rtc: add i.MX system controller RTC support
i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
inside, the system controller is in charge of controlling power,
clock and secure rtc etc..

This patch adds i.MX system controller RTC driver support,
Linux kernel has to communicate with system controller via MU
(message unit) IPC to set/get RTC time and other alarm functions,
since the RTC set time needs to be done in secure EL3 mode (required
by system controller firmware) and alarm functions needs to be done
with general MU IRQ handle, these depend on other components which
are NOT ready, so this patch ONLY enables the RTC time read.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-20 12:47:40 +01:00
Alexandre Belloni
3c3d71013c rtc: pcf2123: Add Microcrystal rv2123
Add a compatible string for Microcrystal rv2123 as the reset procedure seem
to be differing. However, the current driver works just fine.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-18 22:53:35 +01:00
Alexandre Belloni
a269441493 rtc: class: reimplement devm_rtc_device_register
Implement devm_rtc_device_register using devm_rtc_allocate_device and
__rtc_register_device so there is only one path left to register rtc
devices.

Also mark it as deprecated so new drivers will hopefully use
devm_rtc_allocate_device and rtc_register_device that are less race prone
and allow avoiding the 2038, 2070, 2100 and 2106 bugs properly.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-18 22:53:32 +01:00
Alexandre Belloni
9a03201170 rtc: enforce rtc_timer_init private_data type
All the remaining users of rtc_timers are passing the rtc_device as private
data. Enforce that and rename private_data to rtc.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-18 22:53:29 +01:00
Marek Vasut
ffe1c5a2d4 rtc: abx80x: Implement RTC_VL_READ,CLR ioctls
Implement standard ioctls for polling the battery status and clearing
the battery low indication from userspace.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-18 22:53:27 +01:00
Biju Das
fc979933bc rtc: pcf85363: Add support for NXP pcf85263 rtc
Add support for NXP pcf85263 real-time clock. pcf85263 rtc is compatible
with pcf85363,except that pcf85363 has additional 64 bytes of RAM.

1 byte of nvmem is supported and exposed in sysfs (# is the instance
number,starting with 0): /sys/bus/nvmem/devices/pcf85x63-#/nvmem

Signed-off-by: Biju Das <biju.das@bp.renesas.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-11 00:48:17 +01:00
Baruch Siach
ecb4a353d3 rtc: pcf8523: don't return invalid date when battery is low
The RTC_VL_READ ioctl reports the low battery condition. Still,
pcf8523_rtc_read_time() happily returns invalid dates in this case.
Check the battery health on pcf8523_rtc_read_time() to avoid that.

Reported-by: Erik Čuk <erik.cuk@domel.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-11 00:46:53 +01:00
Andy Shevchenko
d54fb48616 rtc: tegra: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Jonathan Hunter <jonathanh@nvidia.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:40:12 +01:00
Andy Shevchenko
5527842eab rtc: s5m: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:40:10 +01:00
Andy Shevchenko
9a1bacf423 rtc: s3c: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:40:08 +01:00
Andy Shevchenko
1921cab117 rtc: rx8025: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:40:07 +01:00
Andy Shevchenko
a3f60bb35f rtc: rx6110: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:40:05 +01:00
Andy Shevchenko
0991e754b9 rtc: rk808: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:40:03 +01:00
Andy Shevchenko
b2db0a291a rtc: puv3: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:40:01 +01:00
Andy Shevchenko
4f5ef6eec4 rtc: pm8xxx: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:59 +01:00
Andy Shevchenko
93206f9315 rtc: pic32: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:57 +01:00
Andy Shevchenko
8d2e6b22bb rtc: pcf50633: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:54 +01:00
Andy Shevchenko
1481376072 rtc: mcp795: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:52 +01:00
Andy Shevchenko
ad78343e40 rtc: m48t59: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:49 +01:00
Andy Shevchenko
22b844ae33 rtc: m41t80: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:47 +01:00
Andy Shevchenko
285166cb8c rtc: at91sam9: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:44 +01:00
Andy Shevchenko
d422f8835d rtc: at91rm9200: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:39 +01:00
Andy Shevchenko
5548cbf7f1 rtc: Switch to use %ptR
Use %ptR instead of open coded variant to print content of
struct rtc_time in human readable format.

Note, we drop the validation option. This is only used in
a deprecated ABI and is mostly wrong as many RTCs will still be valid
after 2100.

Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-10 22:39:37 +01:00
Chen-Yu Tsai
c56afc1844 rtc: sun6i: Expose internal oscillator through device tree
The bindings have been updated to expose the RTC's internal oscillator,
for some SoCs that have it directly feeding the PRCM block. The changes
include the index 2 for the clock outputs, as well as the clock output
names.

This patch adds the internal oscillator to the list of clocks exposed
through of_clk_add_hw_provider(), and also have the driver optionally
fetch the name of the clock from the device tree if it's available.

Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-06 18:13:46 +01:00
Chen-Yu Tsai
7cd1acaeea rtc: sun6i: Add support for all known pre-H6 variants
There are different variants to the RTC hardware first seen on sun6i
(A31). The differences we care about in this driver are the clock rate
for the internal oscillator, prescalers, and the presence of an external
clock output.

This patch adds support for all the known pre-H6 base compatibles using
the variants data structure previously introduced.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-06 18:13:44 +01:00
Chen-Yu Tsai
403a3c3dd0 rtc: sun6i: Add support for different variants
Amongst the Allwinner SoCs that have seen some kind of coverage by the
linux-sunxi community, whether it be mainline Linux or U-boot support,
or just available datasheets, most newer chips use the RTC design first
seen in the A31 (sun6i).

Overall there have been some minor differences. This patch covers the
following:

  - average clock rate of the internal RC oscillator
    + presence of fixed and adjustable prescaler for this clock
  - availability of an external (to the SoC) clock output

One major difference regarding the H6 is the 24 MHz crystal is now
routed through the RTC, as a digitally compensated oscillator (DCXO).
This is not covered in this patch and will be supported later.

Other differences are either unrelated to RTC or clock functionality,
such as boot or crypto related registers, or the driver simply doesn't
use the feature in question. One example of the latter is the
calibration function for the RC oscillator. We consider this clock to
be very bad and avoid using it.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-06 18:13:43 +01:00
Chen-Yu Tsai
459b6ea00a rtc: sun6i: Add default clock name for LOSC
The RTC's main clock, used internally and exported to the rest of the
SoC, is called "LOSC" (low speed oscillator) through the hardware
documentation.

This patch adds a default name for this clock, in case the device tree
does not provide one. This shouldn't happen, but lets play it safe.

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-12-06 18:13:41 +01:00
Linus Torvalds
cd9a043323 Staging and IIO driver fixes for 4.20-rc5
Here are some small IIO and Staging driver fixes for 4.20-rc5.
 
 Nothing major, the IIO fix ended up touching the HID drivers at the same
 time, but the HID maintainer acked it.  The staging fixes are all minor
 patches for reported issues and regressions, full details are in the
 shortlog.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCXAFeeA8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ykZSQCgm8wafCzK2b9YjeUmAxFJQCKkK7YAnjHSqa8N
 FwSpP/zei0mtZgw6Rzj9
 =cBhw
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging and IIO driver fixes from Greg KH:
 "Here are some small IIO and staging driver fixes for 4.20-rc5.

  Nothing major, the IIO fix ended up touching the HID drivers at the
  same time, but the HID maintainer acked it. The staging fixes are all
  minor patches for reported issues and regressions, full details are in
  the shortlog.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'staging-4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers
  staging: vchiq_arm: fix compat VCHIQ_IOC_AWAIT_COMPLETION
  staging: mt7621-pinctrl: fix uninitialized variable ngroups
  staging: rtl8723bs: Add missing return for cfg80211_rtw_get_station
  staging: most: use format specifier "%s" in snprintf
  staging: rtl8723bs: Fix incorrect sense of ether_addr_equal
  staging: mt7621-dma: fix potentially dereferencing uninitialized 'tx_desc'
  staging: comedi: clarify/unify macros for NI macro-defined terminals
  drivers: staging: cedrus: find ctx before dereferencing it ctx
  staging: rtl8723bs: Fix the return value in case of error in 'rtw_wx_read32()'
  staging: comedi: ni_mio_common: scale ao INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS
  iio:st_magn: Fix enable device after trigger
2018-11-30 12:23:44 -08:00
Trent Piepho
facc23b8ff rtc: isl1208: Use i2c block read/write routines
The Linux i2c layer has functions to execute common SMBUS/I2C
transactions.  The register access code here is identical to the I2C
read/write block data routines.

Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-22 18:11:37 +01:00
Christophe JAILLET
41ef387820 rtc: max8997: Fix the returned value in case of error in 'max8997_rtc_read_alarm()'
In case of error, we return 0.
This is spurious and not consistent with the other functions of the driver.
Propagate the error code instead.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-22 18:11:35 +01:00
Alexandre Belloni
41c9e132c5 rtc: nvmem: remove nvmem from struct rtc_device
Using devm_nvmem_register allows to avoid tracking the nvmem pointer in the
rtc_device structure.
This ultimately allows to register multiple nvmem devices from an RTC
driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-22 18:10:07 +01:00
Alexandre Belloni
461e557b97 rtc: nvmem: use devm_nvmem_register()
Use the resource managed variant of nvmem_register().

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-22 18:10:04 +01:00
Hans de Goede
0145b50566 iio/hid-sensors: Fix IIO_CHAN_INFO_RAW returning wrong values for signed numbers
Before this commit sensor_hub_input_attr_get_raw_value() failed to take
the signedness of 16 and 8 bit values into account, returning e.g.
65436 instead of -100 for the z-axis reading of an accelerometer.

This commit adds a new is_signed parameter to the function and makes all
callers pass the appropriate value for this.

While at it, this commit also fixes up some neighboring lines where
statements were needlessly split over 2 lines to improve readability.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 11:42:12 +00:00
Christophe JAILLET
b28cc6cec3 rtc: max77686: Fix the returned value in case of error in 'max77686_rtc_read_time()'
In case of error, we return 0.
This is spurious and not consistent with the other functions of the driver.
Commit e115a2bf14 has modified more than what is said in the commit
message. Reverse part of it znd return an error when needed, as it was
previously.

Fixes: e115a2bf14 ("rtc: max77686: stop validating rtc_time in .read_time")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-14 10:44:43 +01:00
Marek Szyprowski
50c8aec421 rtc: s3c-rtc: Avoid using broken ALMYEAR register
(RTC,ALM)YEAR registers of Exynos built-in RTC device contains 3 BCD
characters. s3c-rtc driver uses only 2 lower of them and supports years
from 2000..2099 range. The third BCD value is typically set to 0, but it
looks that handling of it is broken in the hardware. It sometimes
defaults to a random (even non-BCD) value. This is not an issue
for handling RTCYEAR register, because bcd2bin() properly handles only
8bit values (2 BCD characters, the third one is skipped). The problem
is however with ALMYEAR register and proper RTC alarm operation. When
YEAREN bit is set for the configured alarm, RTC hardware triggers alarm
only when ALMYEAR and RTCYEAR matches. This usually doesn't happen
because of the random noise on the third BCD character.

Fix this by simply skipping setting ALMYEAR register in alarm
configuration. This workaround fixes broken alarm operation on Exynos
built-in rtc device. My tests revealed that the issue happens on the
following Exynos series: 3250, 4210, 4412, 5250 and 5410.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-14 10:44:36 +01:00
Maciej W. Rozycki
f1bd154d88 rtc: m41t80: Complete error propagation from SMBus calls
Complement commit 85d77047c4 ("drivers/rtc/rtc-m41t80.c: propagate
error value from smbus functions") and correct the remaining places that
fail to propagate the error code from SMBus calls.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
References: 85d77047c4 ("drivers/rtc/rtc-m41t80.c: propagate error value from smbus functions")
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-14 10:44:34 +01:00
Maciej W. Rozycki
3cc9ffbb1f rtc: m41t80: Correct alarm month range with RTC reads
Add the missing adjustment of the month range on alarm reads from the
RTC, correcting an issue coming from commit 9c6dfed92c ("rtc: m41t80:
add alarm functionality").  The range is 1-12 for hardware and 0-11 for
`struct rtc_time', and is already correctly handled on alarm writes to
the RTC.

It was correct up until commit 48e9766726 ("drivers/rtc/rtc-m41t80.c:
remove disabled alarm functionality") too, which removed the previous
implementation of alarm support.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: 9c6dfed92c ("rtc: m41t80: add alarm functionality")
References: 48e9766726 ("drivers/rtc/rtc-m41t80.c: remove disabled alarm functionality")
Cc: stable@vger.kernel.org # 4.7+
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-14 10:44:32 +01:00
Alexandre Belloni
03f39f47dc rtc: class: remove devm_rtc_device_unregister
devm_rtc_device_unregister is not used by any driver and should not be used
by any new driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-12 23:14:10 +01:00
Kuninori Morimoto
4ff6f0249e rtc: sh: convert to SPDX identifiers
This patch updates license to use SPDX-License-Identifier
instead of verbose license text.

As original license mentioned, it is GPL-2.0 in SPDX.
Then, MODULE_LICENSE() should be "GPL v2" instead of "GPL".
See ${LINUX}/include/linux/module.h

	"GPL"		[GNU Public License v2 or later]
	"GPL v2"	[GNU Public License v2]

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-12 23:14:09 +01:00
Colin Ian King
725412d9e0 rtc: clean up indentation issues, remove extraneous space, add missing tabs
Trivial fix to clean up indentation issues, remove spaces, add missing
tabs

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-12 23:14:07 +01:00
Nathan Chancellor
c50156526a rtc: omap: Use define directive for PIN_CONFIG_ACTIVE_HIGH
Clang warns when one enumerated type is implicitly converted to another:

drivers/rtc/rtc-omap.c:574:21: warning: implicit conversion from
enumeration type 'enum rtc_pin_config_param' to different enumeration
type 'enum pin_config_param' [-Wenum-conversion]
        {"ti,active-high", PIN_CONFIG_ACTIVE_HIGH, 0},
        ~                  ^~~~~~~~~~~~~~~~~~~~~~
drivers/rtc/rtc-omap.c:579:12: warning: implicit conversion from
enumeration type 'enum rtc_pin_config_param' to different enumeration
type 'enum pin_config_param' [-Wenum-conversion]
        PCONFDUMP(PIN_CONFIG_ACTIVE_HIGH, "input active high", NULL, false),
        ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/pinctrl/pinconf-generic.h:163:11: note: expanded from
macro 'PCONFDUMP'
        .param = a, .display = b, .format = c, .has_arg = d     \
                 ^
2 warnings generated.

It is expected that pinctrl drivers can extend pin_config_param because
of the gap between PIN_CONFIG_END and PIN_CONFIG_MAX so this conversion
isn't an issue. Most drivers that take advantage of this define the
PIN_CONFIG variables as constants, rather than enumerated values. Do the
same thing here so that Clang no longer warns.

Link: https://github.com/ClangBuiltLinux/linux/issues/144
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-12 23:14:06 +01:00
Xulin Sun
9bde0afb7a rtc: pcf2127: fix a kmemleak caused in pcf2127_i2c_gather_write
pcf2127_i2c_gather_write() allocates memory as local variable
for i2c_master_send(), after finishing the master transfer,
the allocated memory should be freed. The kmemleak is reported:

unreferenced object 0xffff80231e7dba80 (size 64):
  comm "hwclock", pid 27762, jiffies 4296880075 (age 356.944s)
  hex dump (first 32 bytes):
    03 00 12 03 19 02 11 13 00 80 98 18 00 00 ff ff ................
    00 50 00 00 00 00 00 00 02 00 00 00 00 00 00 00 .P..............
  backtrace:
    [<ffff000008221398>] create_object+0xf8/0x278
    [<ffff000008a96264>] kmemleak_alloc+0x74/0xa0
    [<ffff00000821070c>] __kmalloc+0x1ac/0x348
    [<ffff0000087ed1dc>] pcf2127_i2c_gather_write+0x54/0xf8
    [<ffff0000085fd9d4>] _regmap_raw_write+0x464/0x850
    [<ffff0000085fe3f4>] regmap_bulk_write+0x1a4/0x348
    [<ffff0000087ed32c>] pcf2127_rtc_set_time+0xac/0xe8
    [<ffff0000087eaad8>] rtc_set_time+0x80/0x138
    [<ffff0000087ebfb0>] rtc_dev_ioctl+0x398/0x610
    [<ffff00000823f2c0>] do_vfs_ioctl+0xb0/0x848
    [<ffff00000823fae4>] SyS_ioctl+0x8c/0xa8
    [<ffff000008083ac0>] el0_svc_naked+0x34/0x38
    [<ffffffffffffffff>] 0xffffffffffffffff

Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-07 17:13:56 +01:00
Maciej W. Rozycki
7ce9a992ff rtc: hctosys: Add missing range error reporting
Fix an issue with the 32-bit range error path in `rtc_hctosys' where no
error code is set and consequently the successful preceding call result
from `rtc_read_time' is propagated to `rtc_hctosys_ret'.  This in turn
makes any subsequent call to `hctosys_show' incorrectly report in sysfs
that the system time has been set from this RTC while it has not.

Set the error to ERANGE then if we can't express the result due to an
overflow.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: b3a5ac42ab ("rtc: hctosys: Ensure system time doesn't overflow time_t")
Cc: stable@vger.kernel.org # 4.17+
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-07 17:13:55 +01:00
Hans de Goede
fbb974ba69 rtc: cmos: Do not export alarm rtc_ops when we do not support alarms
When there is no IRQ configured for the RTC, the rtc-cmos code does not
support alarms, all alarm rtc_ops fail with -EIO / -EINVAL.

The rtc-core expects a rtc driver which does not support rtc alarms to
not have alarm ops at all. Otherwise the wakealarm sysfs attr will read
as empty rather then returning an error, making it impossible for
userspace to find out beforehand if alarms are supported.

A system without an IRQ for the RTC before this patch:
[root@localhost ~]# cat /sys/class/rtc/rtc0/wakealarm
[root@localhost ~]#

After this patch:
[root@localhost ~]# cat /sys/class/rtc/rtc0/wakealarm
cat: /sys/class/rtc/rtc0/wakealarm: No such file or directory
[root@localhost ~]#

This fixes gnome-session + systemd trying to use suspend-then-hibernate,
which causes systemd to abort the suspend when writing the RTC alarm fails.

BugLink: https://github.com/systemd/systemd/issues/9988
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-11-07 17:13:55 +01:00
Baolin Wang
3822d1bb0d rtc: sc27xx: Always read normal alarm when registering RTC device
When registering one RTC device, it will check to see if there is an
alarm already set in RTC hardware by reading RTC alarm, at this time
we should always read the normal alarm put in always-on region by
checking the rtc->registered flag.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-25 02:35:42 +02:00
Baolin Wang
bf2c532b67 rtc: sc27xx: Add check to see if need to enable the alarm interrupt
The RTC interrupt enable register is not put in always-power-on region
supplied by VDDRTC, so we should check if we need enable the alarm
interrupt when system booting.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-25 02:35:40 +02:00
Baolin Wang
b2ddc48582 rtc: sc27xx: Remove interrupts disable and clear in probe()
When registering one rtc device, it will check to see if there is an
alarm already set in rtc hardware by issuing __rtc_read_alarm(). So
we should not disable the RTC interrupts and clear the interrupts
status in probe() function.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-25 02:35:39 +02:00
Baolin Wang
7db5adfa63 rtc: sc27xx: Clear SPG value update interrupt status
We should clear the SPG value update interrupt status once the SPG value
is updated successfully, in case incorrect status validation for next time.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-25 02:35:38 +02:00
Baolin Wang
a86d6b23ed rtc: sc27xx: Set wakeup capability before registering rtc device
Set wakeup capability before registering rtc device, in case the alarmtimer
can find one available rtc device.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-25 02:35:36 +02:00
Nathan Chancellor
ef0f02fd69 rtc: s35390a: Change buf's type to u8 in s35390a_init
Clang warns:

drivers/rtc/rtc-s35390a.c:124:27: warning: implicit conversion from
'int' to 'char' changes value from 192 to -64 [-Wconstant-conversion]
        buf = S35390A_FLAG_RESET | S35390A_FLAG_24H;
            ~ ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
1 warning generated.

Update buf to be an unsigned 8-bit integer, which matches the buf member
in struct i2c_msg.

https://github.com/ClangBuiltLinux/linux/issues/145
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-22 19:29:43 +02:00
Soeren Moch
7dceef78f3 rtc: ds1307: fix ds1339 wakealarm support
Commit 51ed73eb99 ("rtc: ds1340: Add support
for trickle charger.") breaks ds1339 wakealarm support by limiting
accessible registers. Fix this.

Fixes: 51ed73eb99 ("rtc: ds1340: Add support for trickle charger.")
Cc: stable@vger.kernel.org
Signed-off-by: Soeren Moch <smoch@web.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-22 17:53:14 +02:00
Wolfram Sang
6f5b390b3a rtc: ds1685: simplify getting .driver_data
We should get 'driver_data' from 'struct device' directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-22 17:53:12 +02:00
Gustavo A. R. Silva
c3e04915b8 rtc: m41t80: mark expected switch fall-through
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Notice that in this particular case, I replaced "Fall" with a proper
"Fall through" comment.

Addresses-Coverity-ID: 1373875 ("Missing break in switch")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-16 12:56:58 +02:00
Thierry Reding
fe0b5cedc2 rtc: tegra: Propagate errors from platform_get_irq()
Instead of confusingly returning -EBUSY on failure to obtain an
interrupt, propagate the real error code. While at it, let the user know
why the interrupt could not be acquired.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-16 12:56:56 +02:00
Maciej W. Rozycki
bc51098cdd rtc: cmos: Remove the `use_acpi_alarm' module parameter for !ACPI
Fix a problem with commit 311ee9c151 ("rtc: cmos: allow using ACPI for
RTC alarm instead of HPET") defining `use_acpi_alarm' module parameter
even for non-ACPI platforms, which ignore it.  Wrap the definition into
#ifdef CONFIG_ACPI and use a static inline wrapper function, hardcoded
to return 0 and consequently optimized away for !ACPI, following the
existing pattern with HPET handling functions.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: 311ee9c151 ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET")
Cc: stable@vger.kernel.org # 4.18+
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-04 11:15:57 +02:00
Maciej W. Rozycki
d197a25385 rtc: cmos: Fix non-ACPI undefined reference to `hpet_rtc_interrupt'
Fix a commit 311ee9c151 ("rtc: cmos: allow using ACPI for RTC alarm
instead of HPET") `rtc-cmos' regression causing a link error:

drivers/rtc/rtc-cmos.o: In function `cmos_platform_probe':
rtc-cmos.c:(.init.text+0x33c): undefined reference to `hpet_rtc_interrupt'
rtc-cmos.c:(.init.text+0x3f4): undefined reference to `hpet_rtc_interrupt'

with non-ACPI platforms using this driver.  The cause is the change of
the condition guarding the use of `hpet_rtc_interrupt'.

Previously it was a call to `is_hpet_enabled'.  That function is static
inline and has a hardcoded 0 result for non-ACPI platforms, which imply
!HPET_EMULATE_RTC.  Consequently the compiler optimized the whole block
away including the reference to `hpet_rtc_interrupt', which never made
it to the link stage.

Now the guarding condition is a call to `use_hpet_alarm', which is not
static inline and therefore the compiler may not be able to prove that
it actually always returns 0 for non-ACPI platforms.  Consequently the
build breaks with an unsatisfied reference, because `hpet_rtc_interrupt'
is nowhere defined at link time.

Fix the problem by marking `use_hpet_alarm' inline.  As the `inline'
keyword serves as an optimization hint rather than a requirement the
compiler is still free to choose whether inlining will be beneficial or
not for ACPI platforms.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Fixes: 311ee9c151 ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET")
Cc: stable@vger.kernel.org # 4.18+
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-04 11:15:55 +02:00
Alexandre Belloni
959e8b77bf rtc: mv: let the core handle invalid alarms
Instead of lying to the core when the alarm is invalid, let it handle that
by returning the error.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Tested-by: Gregory CLEMENT <gregory.clement@bootlin.com>  (on Armada 375 DB)
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-03 11:07:24 +02:00
Alexandre Belloni
89e27ce498 rtc: vr41xx: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_time_to_tm now that the range is enforced by
the core.
Also remove the open coded rtc_tm_to_time64.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-10-03 11:07:22 +02:00
Alexandre Belloni
9a90a5bcc7 rtc: ab8500: remove useless check
rtc_time_to_tm always rturns a valid tm, there is no need to validate it.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:36:49 +02:00
Alexandre Belloni
38ab97aebe rtc: ab8500: let the core handle range
Let the core handle offsetting and windowing the RTC range.
The RTC has a 24 bit counter for minutes plus a seconds counter.
Keep the epoch at the beginning of 2000.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:36:47 +02:00
Alexandre Belloni
b56295dd33 rtc: ab8500: use rtc_add_group
Use rtc_add_group to add the sysfs group in a race free manner.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:36:44 +02:00
Alexandre Belloni
1654a2b06b rtc: rs5c348: report error when time is invalid
Instead of resetting the RTC to an bogus valid time, let userspace know
that the time is invalid when XSTP is set. Reset XSTP when setting the time
again.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:03 +02:00
Alexandre Belloni
2d7be4ed7a rtc: rs5c348: remove forward declaration
The name passed to devm_rtc_device_register is now unused. anyway, switch
to devm_rtc_allocate_device to avoid forward declaring rs5c348_driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:03 +02:00
Alexandre Belloni
02a6e12932 rtc: rs5c348: remove useless label
Since commit 8fb1ecb36f ("rtc: rtc-rs5c348: use devm_*() functions") the
kfree_exit label simply returns ret.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:03 +02:00
Alexandre Belloni
f6e3d773e1 rtc: armada38x: switch to rtc_time64_to_tm/rtc_tm_to_time64
Call the 64bit versions of rtc_time_to_tm and rtc_tm_to_time now that the
range is enforced by the core.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:03 +02:00
Alexandre Belloni
ef2a7176c8 rtc: armada38x: add range
The RTC is a 32bit seconds counter.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Tested-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:02 +02:00
Alexandre Belloni
7d61cbb945 rtc: armada38x: fix possible race condition
The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:02 +02:00
Alexandre Belloni
0ae3f24ded rtc: lib: correct documentation typo
rtc_time64_to_tm has not been called rtc_time_to_tm64

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:02 +02:00
Alexandre Belloni
6a5f2a1f4d rtc: ds1307: use rtc_add_group
Register frequency test using rtc_add_group to avoid a possible race
condition and simplify the code.

This also moves the attribute to its proper location under the rtc device
instead of the i2c parent device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:01 +02:00
Alexandre Belloni
cfb74916e2 rtc: ds1685: use rtc_add_group
Use rtc_add_group to add the sysfs group in a race free manner.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:01 +02:00
Alexandre Belloni
482419e120 rtc: ds1685: use generic nvmem
Instead of adding a binary sysfs attribute from the driver, use the core to
register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:01 +02:00
Alexandre Belloni
8ddeb09de1 rtc: ds1685: drop RTC_DS1685_PROC_REGS
/proc is not the correct ABI to display debugging info. Remove
RTC_DS1685_PROC_REGS as the driver hasn't seen any real development since
it was included.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:00 +02:00
Alexandre Belloni
c7080e2016 rtc: test: Switch to SPDX identifier
Replace the license boilerplate by an SPDX identifier

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:00 +02:00
Alexandre Belloni
fd13c930fe rtc: test: make license text and module license match.
The license text is specifying GPL v2 only but the MODULE_LICENSE is set to
GPL which means GNU Public License v2 or later. When MODULE_LICENSE and
boiler plate does not match, go for boiler plate license.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:21:00 +02:00
Alexandre Belloni
2ab78755e9 rtc: tx4939: fixup nvmem name and register size
The default word_size and stride of 1 are correct for the tx4939. Also fix
the nvmem folder name.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:20:59 +02:00
Alexandre Belloni
4b3a6a3ac5 rtc: isl1208: don't include core header file
The core header file is reserved for the core, stop including it.

Also reorder includes alphabetically.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:20:59 +02:00
Alexandre Belloni
eb2bccb70b rtc: move rtc_add_group/s definitions
Move rtc_add_group and rtc_add_groups definition to rtc.h that is available
for all RTC drivers.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:20:59 +02:00
Alexandre Belloni
db7a67b9c3 rtc: reorder Makefile entries
A few entries are not placed correctly, reorder them.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:20:58 +02:00
Giulio Benetti
b41c23e152 rtc: ds1307: add frequency_test_enable attribute on m41txx
On m41txx you can enable open-drain OUT pin to check if offset is ok.
Enabling OUT pin with frequency_test_enable attribute, OUT pin will tick
512 times faster than 1s tick base.

Enable or Disable FT bit on CONTROL register if freq_test is 1 or 0.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:20:58 +02:00
Giulio Benetti
79230ff641 rtc: ds1307: add offset sysfs for mt41txx chips.
m41txx chips can hold a calibration value to get correct clock bias.

Add offset handling (ranging between -63ppm and 126ppm) via sysfs.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-28 14:20:58 +02:00
Alexandre Belloni
1b4c794fda rtc: isl1208: avoid possible sysfs race
Use rtc_add_group to add the common sysfs group to avoid a possible race
condition.

[Denis.Osterland@diehl.com: use to_i2c_client(dev->parent)]
Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

The move of atrim, dtrim usr sysfs properties from i2c device
to rtc device require to access them via dev->parent.
This patch also aligns timestamp0.
2018-09-28 14:14:38 +02:00
Alexandre Belloni
f1c8bc332e rtc: remove irq_task from kerneldoc
Stale mentions of irq_task are left in the kerneldoc after its removal.
Remove them.

There is still one indirect mention left but commit 3c8bb90efb ("rtc: Fix
hrtimer deadlock") can probably be reverted now.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-13 15:43:07 +02:00
Alexandre Belloni
1e479c619b rtc: unexport non devm managed registration
Ensure the non managed version of the un/registration functions is not used
anymore. No driver is using it anymore and they should not be necessary.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-13 15:43:05 +02:00
Jeremy Gebben
749e36d0a0 rtc: abx80x: add basic watchdog support
The abx804 and abx805 chips have support for a simple watchdog
function that can trigger an external reset.

Signed-off-by: Jeremy Gebben <jgebben@sweptlaser.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-12 12:02:21 +02:00
Jeremy Gebben
af69f9a787 rtc: abx80x: use a 'priv' struct for client data
This will allow additional data to be tracked, for future
improvements.

Signed-off-by: Jeremy Gebben <jgebben@sweptlaser.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-12 12:02:19 +02:00
Alexandre Belloni
b7aff107f3 rtc: pl031: switch to devm_rtc_allocate_device/rtc_register_device
Switch to devm_rtc_allocate_device to simplify the erro and driver removal
paths.

Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-11 13:56:35 +02:00
Alexandre Belloni
c778ec8582 rtc: pl030: fix possible race condition
The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-11 13:56:35 +02:00
Alexandre Belloni
babab2f864 rtc: mt6397: fix possible race condition
The IRQ is requested before the struct rtc is allocated and registered, but
this struct is used in the IRQ handler. This may lead to a NULL pointer
dereference.

Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc
before requesting the IRQ.

Acked-by: Eddie Huang <eddie.huang@mediatek.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-09-11 13:56:20 +02:00
YueHaibing
de96bc3995 rtc: mrst: remove set but not used variable 'valid'
Fixes gcc '-Wunused-but-set-variable' warning:

drivers/rtc/rtc-mrst.c: In function 'mrst_procfs':
drivers/rtc/rtc-mrst.c:264:29: warning:
 variable 'valid' set but not used [-Wunused-but-set-variable]
  unsigned char rtc_control, valid;

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-31 11:17:41 +02:00
Alexandre Belloni
ac771ed746 rtc: rv8803: add Epson RX8803 support
The Epson rx8803 is mostly similar to the Microcrystal RV8803 but the size
of the offset register is 4 bits vs 6 bits but it has a configurable
temperature compensation.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27 23:24:36 +02:00
Alexandre Belloni
c856618d20 rtc: rv8803: fix the rv8803 id in the OF table
The ID for RV8803 must be rv_8803

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27 23:24:35 +02:00
Dan Carpenter
777d8ae56d rtc: sysfs: fix NULL check in rtc_add_groups()
devm_kcalloc() returns NULL, it never returns error pointers.  In the
current code we would return PTR_ERR(NULL) which is success, instead of
returning the -ENOMEM error code.

Fixes: a0a1a1ba30 ("rtc: sysfs: facilitate attribute add to rtc device")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27 23:03:34 +02:00
Gustavo A. R. Silva
725e0e15f8 rtc: sun6i: Use struct_size() in kzalloc()
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
	int stuff;
        void *entry[];
};

instance = kzalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL);

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27 23:02:18 +02:00
Paul Cercueil
1e6e4e169a rtc: jz4740: Drop dependency on MACH_INGENIC
Depending on MACH_INGENIC prevent us from creating a generic kernel that
works on more than one MIPS board. Instead, we just depend on MIPS being
set.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27 22:59:37 +02:00
Keerthy
09058eab4b rtc: omap: Cut down the shutdown time from 2 seconds to 1 sec
Cut down the shutdown time from 2 seconds to 1 sec. In case of roll
over try again.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27 22:51:57 +02:00
Keerthy
0438002ac5 rtc: omap: use of_device_is_system_power_controller function
Use of_device_is_system_power_controller instead of manually reading
the system-power-controller property from the device tree node.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27 22:51:56 +02:00
Jia-Ju Bai
c6b5eb8dd3 rtc: rtc-mrst: Replace mdelay() with msleep() in mrst_read_time()
mrst_read_time() is never called in atomic context.
It calls mdelay() to busily wait, which is not necessary.
mdelay() can be replaced with msleep().

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-27 22:51:54 +02:00
Linus Torvalds
bfebeb1672 RTC for 4.19
Subsystem:
  - new helpers to add custom sysfs attributes
  - struct rtc_task removal along with rtc_irq_register/rtc_irq_unregister
  - rtc_irq_set_state and rtc_irq_set_freq are not exported anymore
 
 Drivers:
  - armada38x: reset after rtc power loss
  - ds1307: now supports m41t11
  - isl1208: now supports isl1219 and tamper detection
  - pcf2127: internal SRAM support
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEXx9Viay1+e7J/aM4AyWl4gNJNJIFAlt7L0oACgkQAyWl4gNJ
 NJIB3w/+Mo5moMRnjDe+MiFzbLxe9lv3Wtdmqq0AdHQpxxOVu7LQ2O5oHQBjdMsz
 nCYPy7sIWBXzJWI+X5OByukZheWmhmsORtZw14MrmhMCY7Xt0lCHAsmHzs0yyqXT
 KnF0RL9HtSfYr4ftcOGrnY/8VZCPjI0I08AP1naVYTcX34PPGRL7KWwyxYBuwyOL
 Za2eH8snhI/QkEKx9enPsXeMvB87hkhCEFM0oTyyS5bY6L68PGzErWO4J8mWvFSH
 w1GWOvaNAg74lSe1Kgq9QtXRmhl67vwPLUX3QdxKb0HRuEInfdwDifdwU14HixE/
 t2Vj0HNpn9xZwRhCvC/LnwtQGr+53R2Ase5NSwpZvpvM8e2LgoN/W7NxoD4BGSMi
 Aal0lPUFLbzayFQC5MOIZVazrf7PzWowSFNWO66uQR3Cmt/voGtRDGbfTPHn6nvs
 kLl5kb8j0KdJOsVeDDmnVmEU0ZEmGZSqxX7oE0QiL8QMim76yZtqwy1Y13xE5nI9
 6fDA2MyQADNn5JDFMC/deL/d8hgI4Yv19tNOxNuj9yW/wFbctCG4tkremQoXHZ4n
 zLg/pdS2/iHSGKYW6ejWIS7VxwEWDbJp60Tx02LWQz40xXiUtgYh0/eYCzdfBVU/
 wXla023DFerg1irguOrSPTLLDddvOz8fW6Gh7DMT+nxjuxdh+lw=
 =cAQ9
 -----END PGP SIGNATURE-----

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

Pull RTC updates from Alexandre Belloni:
 "It is now possible to add custom sysfs attributes while avoiding a
  possible race condition. Unused code has been removed resulting in a
  nice reduction of the code base. And more drivers have been switched
  to SPDX by their maintainers.

 Summary:

  Subsystem:
   - new helpers to add custom sysfs attributes
   - struct rtc_task removal along with rtc_irq_[un]register()
   - rtc_irq_set_state and rtc_irq_set_freq are not exported anymore

  Drivers:
   - armada38x: reset after rtc power loss
   - ds1307: now supports m41t11
   - isl1208: now supports isl1219 and tamper detection
   - pcf2127: internal SRAM support"

* tag 'rtc-4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (34 commits)
  rtc: ds1307: simplify hwmon config
  rtc: s5m: Add SPDX license identifier
  rtc: maxim: Add SPDX license identifiers
  rtc: isl1219: add device tree documentation
  rtc: isl1208: set ev-evienb bit from device tree
  rtc: isl1208: Add "evdet" interrupt source for isl1219
  rtc: isl1208: add support for isl1219 with tamper detection
  rtc: sysfs: facilitate attribute add to rtc device
  rtc: remove struct rtc_task
  char: rtc: remove task handling
  rtc: pcf85063: preserve control register value between stop and start
  rtc: sh: remove unused variable rtc_dev
  rtc: unexport rtc_irq_set_*
  rtc: simplify rtc_irq_set_state/rtc_irq_set_freq
  rtc: remove irq_task and irq_task_lock
  rtc: remove rtc_irq_register/rtc_irq_unregister
  rtc: sh: remove dead code
  rtc: sa1100: don't set PIE frequency
  rtc: ds1307: support m41t11 variant
  rtc: ds1307: fix data pointer to m41t0
  ...
2018-08-20 16:30:27 -07:00
Heiner Kallweit
6b583a64fd rtc: ds1307: simplify hwmon config
We don't have to define an extra config symbol, IS_REACHABLE does
what we need. And having this config symbol just to save the few
bytes of hwmon support on non-DS3231 chips isn't worth it IMO
(especially as the symbol is set per default).

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-16 07:46:41 +02:00
Krzysztof Kozlowski
26dcc12c00 rtc: s5m: Add SPDX license identifier
Replace GPL v2.0+ license statement with SPDX license
identifier.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-14 23:38:47 +02:00
Krzysztof Kozlowski
734c5cd5bc rtc: maxim: Add SPDX license identifiers
Replace GPL v2.0+ license statements with SPDX license
identifiers.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-14 23:38:45 +02:00
Denis Osterland
cfa30622c8 rtc: isl1208: set ev-evienb bit from device tree
Add support to disable event in pull-up.

Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-14 23:22:27 +02:00
Denis Osterland
9ece7cd833 rtc: isl1208: Add "evdet" interrupt source for isl1219
Add support for "evdet" named interrupt source.

The check if i2c client irq matches evdet irq is needed
for the case that there is only one interrupt named "evdet".
In this case i2c client code handles this like an unnamed
interrupt souce and assigns the value.

Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-14 23:03:19 +02:00
Michael Grzeschik
dd35bdb076 rtc: isl1208: add support for isl1219 with tamper detection
We add support for the ISL1219 chip that got an integrated tamper
detection function. This patch implements the feature by adding
an additional timestamp0 file to sysfs device path.
This file contains seconds since epoch, if an event occurred,
or is empty, if none occurred.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-14 23:00:58 +02:00
Denis Osterland
a0a1a1ba30 rtc: sysfs: facilitate attribute add to rtc device
This patches addresses following problem:
rtc_allocate_device
devm_device_add_group  <-- kernel oops / null pointer, because
			sysfs entry does not yet exist
rtc_register_device
rc = devm_device_add_group
if (rc)
	return rc;     <-- forbidden to return error code
			after device register

This patch adds rtc_add_group(s) functions.
The functions store the sum of attribute groups as device resource.

Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-14 22:56:27 +02:00
Alexandre Belloni
5a5ba10f44 rtc: remove struct rtc_task
Include rtc_task members directly in rtc_timer member.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-08-02 17:16:05 +02:00
Alvin Šipraga
ec9cf1b7a6 rtc: pcf85063: preserve control register value between stop and start
Fix a bug that caused the Control_1 register to get zeroed whenever the
RTC time is set. The problem occurred between stopping and starting the
RTC clock, wherein the return value of a successful I2C write function
would get written to the register.

Also update variables of the start and stop functions to be more
consistent with the rest of the driver.

Signed-off-by: Alvin Šipraga <alvin@airtame.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-28 14:49:25 +02:00
Anders Roxell
8856541557 rtc: sh: remove unused variable rtc_dev
When building rtc-sh, rtc_dev isn't used in function __sh_rtc_periodic.
drivers/rtc/rtc-sh.c: In function ‘__sh_rtc_periodic’:
drivers/rtc/rtc-sh.c:146:21: warning: unused variable ‘rtc_dev’ [-Wunused-variable]
  struct rtc_device *rtc_dev = rtc->rtc_dev;
                     ^~~~~~~
Remove the declaration of rtc_dev to dispose the warning.

Fixes: ec623ff014 ("rtc: sh: remove dead code")
Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-27 17:27:40 +02:00
Alexandre Belloni
c842697c74 rtc: unexport rtc_irq_set_*
Make the rtc_irq_set interface internale to the RTC subsystem.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-26 15:08:53 +02:00
Alexandre Belloni
8719d3c918 rtc: simplify rtc_irq_set_state/rtc_irq_set_freq
The PIE doesn't handle tasks anymore, remove the pointer from the
interface.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-26 15:08:53 +02:00
Alexandre Belloni
acecb3ad8b rtc: remove irq_task and irq_task_lock
There is no way to set a periodic task anymore, remove task pointer and
lock.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-26 15:08:53 +02:00
Alexandre Belloni
1560d0848a rtc: remove rtc_irq_register/rtc_irq_unregister
The rtc_irq_* interface is not used from outside the RTC subsytem since
2016.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-26 15:08:50 +02:00
Alexandre Belloni
ec623ff014 rtc: sh: remove dead code
Since commit 80d4bb515b ("RTC: Cleanup rtc_class_ops->irq_set_state") and
commit 696160fec1 ("RTC: Cleanup rtc_class_ops->irq_set_freq()"),
sh_rtc_irq_set_state and sh_rtc_irq_set_freq are never called. Remove them
along with task handling.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-26 15:08:39 +02:00
Alexandre Belloni
1f28231c66 rtc: sa1100: don't set PIE frequency
It doesn't make sense to set the PIE frequency from the driver. Let
userspace do its job.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-25 15:29:43 +02:00
Giulio Benetti
7e580769b7 rtc: ds1307: support m41t11 variant
The m41t11 variant is very similar to the already supported m41t00 and
m41t0, but it has also 56 bytes of NVRAM.

Add it to driver taking into account NVRAM section.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-16 23:36:24 +02:00
Giulio Benetti
146a552c67 rtc: ds1307: fix data pointer to m41t0
data field points to m41t00, instead it should point to m41t0.
Driver works correctly because on both cases(m41t0 and m41t00) chip_desc
are equal.

Point to right enum m41t0 instead of m41t00.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-16 23:36:23 +02:00
Greg Kroah-Hartman
83cf9cd6d5 Merge 4.18-rc5 into char-misc-next
We want the char-misc fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-16 09:04:54 +02:00
Arnd Bergmann
5089ea15ba rtc: use ktime_get_real_ts64() instead of getnstimeofday64()
getnstimeofday64() is just a wrapper around the ktime accessor, so
we should use that directly.

I considered using ktime_get_boottime_ts64() (to avoid leap second
problems) or ktime_get_real_seconds() (to simplify the calculation,
but in the end concluded that the existing interface is probably
the most appropriate in this case.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-13 10:47:18 +02:00
Alexandre Belloni
fd6792bb02 rtc: fix alarm read and set offset
The offset needs to be added after reading the alarm value.

It also needs to be subtracted after the now < alarm test.

Tested-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-13 10:37:54 +02:00
Colin Ian King
fed0b1bd1b rtc: m48t59: remove redundant pointer 'name'
Pointer 'name' is being assigned but is never used hence it is redundant
and can be removed.

Cleans up clang warning:
warning: variable 'name' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-07-12 21:17:36 +02:00