With commit 8bc2a40730 ("rtc: ds1307: add support for the
DT property 'wakeup-source'") we lost the ability for rtc irq
functionality for devices that are actually hooked on a real IRQ
line and have capability to wakeup as well. This is not an expected
behavior. So, instead of just not requesting IRQ, skip the IRQ
requirement only if interrupts are not defined for the device.
Fixes: 8bc2a40730 ("rtc: ds1307: add support for the DT property 'wakeup-source'")
Reported-by: Tony Lindgren <tony@atomide.com>
Cc: Michael Lange <linuxstuff@milaw.biz>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
while retrieving temperature from ds3231, the result may be overflow
since s16 is too small for a multiplication with 250.
ie. if temp_buf[0] == 0x2d, the result (s16 temp) will be negative.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Tested-by: Michael Tatarinov <kukabu@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Drivers:
- abx80x: handle both XT and RC oscillators, XT failure bit and autocalibration
- m41t80: avoid out of range year values
- rv8803: workaround an i2c HW issue
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAABCAAGBQJW9JdpAAoJEKbNnwlvZCyz9hYP/RU/8fJtdO2veoY+xLVta7UV
mJahSrMn7CMkZeVh7vy/T8tIJDNB+G4TqkG6V8kT41yltzTZszn/Qm/t6vrEcwY3
GXj11NtIiOeo6UgGeEKj0feM9Imy/OtHvCfXc7XmTV78f0DYE5MvH+7rTXmFzNm0
qHE+aGPfp2CGYS8HhDYwedvXo9qphSCfbU3akm2PSdFfOkoCuIBndJgLkKsqdKXY
St9hN0Z7xo3FayxtTbELftnW1xkvgsJiGcU19b3Uo89V3NS1L+5eJkhI7cx/kQxz
bMlBBKkvpdmRwy2ng42NGipLXEXwTTOqx4ZlhKLjwhGAF1m4R9ThrCrrXrBT01LM
8TwO5HNqUEViQYXMSK95UF2F5ldE5S+kfYUjopdoV1N6/04Uz+X03o9+zMAJq4JH
ZWjcLIYXb1lvmt8KzUD847O69001NtWC0zVgHoQJ3CldguyGX11BYzkRCxRn/u9y
OWEivF8K0hXYw0Dcmnls6/lrDP1xQc7s6BiFg00UTEjGAmlZVR3eSNBxCXXUneyR
nsv1dlvB9+mcVFFpEQI/MFFNdoBBx3KLRIE+pFJIadQ4yaWkUhrOJpTW4Y646QAj
1VMDV5Z6961sMqVkyqNMZqaqnVgrZY0DZWS9PMzYlNnrDSIXu3svu78xq+foBy0+
OuOHjLcIIKxFSRysMZu7
=PMVI
-----END PGP SIGNATURE-----
Merge tag 'rtc-4.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull more RTC updates from Alexandre Belloni:
"A second pull request for v4.6 with a few fixesi before -rc1. The new
features for abx80x actually make the RTC behave correctly.
Drivers:
- abx80x: handle both XT and RC oscillators, XT failure bit and
autocalibration
- m41t80: avoid out of range year values
- rv8803: workaround an i2c HW issue"
* tag 'rtc-4.6-2' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux:
rtc: abx80x: handle the oscillator failure bit
rtc: abx80x: handle autocalibration
rtc: rv8803: workaround i2c HW issue
rtc: mcp795: add devicetree support
rtc: asm9260: remove incorrect __init/__exit annotations
rtc: m41t80: avoid out of range year values
rtc: s3c: Don't print an error on probe deferral
rtc: rv3029: stop mentioning rv3029c2
Handle the Oscillator Failure ('OF') bit from Oscillator Status register
(0x1D). This bit is cleared on set_time function and is read each time the
date/time is read, but only in case of XT Oscillator selection.
In RC mode, this bit is always set.
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The autocalibration is separated in two bits to set in Oscillator
Control register (0x1c) :
- OSEL bit to select the oscillator type (XT or RC).
- ACAL bit to select the autocalibration type.
These functionnalities are exported in sysfs entries : "oscillator"
and "autocalibration". Respectively, the values are "xtal" for XT
oscillator and "rc" for RC oscillator and 0 to disable the
autocalibration cycle, 512 for a 512 seconds autocalibration cycle
and 1024 for a cycle of 1024 seconds.
Examples :
Set to XT Oscillator
echo xtal > /sys/class/rtc/rtc0/device/oscillator
Activate an autocalibration every 512 seconds
echo 512 > /sys/class/rtc/rtc0/device/autocalibration
Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The rv8803 has a 60µs window where it will not answer on the i2c bus.
It also means there will be no ack for the communication. Make sure
communication is tried multiple times when this happens (the i2c subsystem
mandates -ENXIO is that case but the number of retries is host specific).
The critical parts are the probe function and the alarm callback so make
sure we handle the failure there.
Cc: stable@vger.kernel.org # v4.4
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Add device tree support to the rtc-mcp795 driver.
Signed-off-by: Emil Bartczak <emilbart@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The probe and remove callbacks of the platform driver are marked __init
and __exit, respectively. However, this is not a correct way to annotate
them, as it will result in those sections to be discarded at link time
or after boot, while we can actually call them again based on manual
unbinding, or deferred probing.
Kbuild warns about the problem:
WARNING: drivers/rtc/rtc-asm9260.o(.data+0x0): Section mismatch in reference from the variable asm9260_rtc_driver to the function .init.text:asm9260_rtc_probe()
This removes the annotations, so we no longer branch into missing
code and avoid the warning.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 125e550fd2 ("rtc: add Alphascale asm9260 driver")
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Avoid saving an out of range year value to the RTC. Reading that value
from the RTC again returns a totally wrong time value. For Example
$ timedatectl set-ntp no
$ timedatectl set-time "1990-01-01 12:12:00"
# Reboot
rtc-m41t80 0-0068: setting system clock to 2090-01-01 12:12:35 UTC (3786955955)
Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The clock and source clock looked up by the driver may not be available
just because the clock controller driver was not probed yet so printing
an error in this case is not correct and only adds confusion to users.
However, knowing that a driver's probe was deferred may be useful so it
can be printed as a debug information.
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Pull trivial tree updates from Jiri Kosina.
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial:
drivers/rtc: broken link fix
drm/i915 Fix typos in i915_gem_fence.c
Docs: fix missing word in REPORTING-BUGS
lib+mm: fix few spelling mistakes
MAINTAINERS: add git URL for APM driver
treewide: Fix typo in printk
There are only a few differences between PCF2127 and PCF2129 (PCF2127
has 512 bytes of general purpose SRAM and count-down timer).
The rtc-pcf2127 driver currently doesn't use the PCF2127 specific
functionality and Kconfig help text already says this driver supports
PCF2127/29, so we can simply add pcf2129 to device id list.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
pcf2127 has selectable I2C-bus and SPI-bus interface support.
This adds support for SPI interface.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
pcf2127 has selectable I2C-bus and SPI-bus interface support.
Currently rtc-pcf2127 driver only supports I2C.
This is preparation for support for SPI interface.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
This adds support to
- enable/disable the thermometer
- set the temperature scanning interval
- read the current temperature that is used for temp compensation.
via hwmon interface
Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
This simplifies the update of single bits in the eeprom.
Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
objtool reports the following warnings:
drivers/rtc/rtc-ds1685.o: warning: objtool: ds1685_rtc_work_queue()+0x0: duplicate frame pointer save
drivers/rtc/rtc-ds1685.o: warning: objtool: ds1685_rtc_work_queue()+0x3: duplicate frame pointer setup
drivers/rtc/rtc-ds1685.o: warning: objtool: ds1685_rtc_work_queue()+0x0: frame pointer state mismatch
The warning message needs to be improved, but what it really means in
this case is that ds1685_rtc_poweroff() has a possible code path where
it can actually fall through to the next function in the object code,
ds1685_rtc_work_queue().
The bug is caused by the use of the unreachable() macro in a place which
is actually reachable. That causes gcc to assume that the printk()
immediately before the unreachable() macro never returns, when in fact
it does. So gcc places the printk() at the very end of the function's
object code. When the printk() returns, the next function starts
executing.
The surrounding comment and printk message state that the code should
spin forever, which explains the unreachable() statement. However the
actual spin code is missing.
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Year field must be in BCD format, according to
hym8563 datasheet.
Due to the bug year 2016 became 2010.
Fixes: dcaf038493 ("rtc: add hym8563 rtc-driver")
Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
ds3232->mutex is used to protect for alarm operations which
need to access status and control registers.
But we can use rtc->ops_lock instead. rtc->ops_lock is held when most
of rtc_class_ops methods are called, so we only need to explicitly
acquire it from irq handler in order to protect form concurrent
accesses.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
ds3232-core requests irq with IRQF_SHARED, so irq can be shared by
several devices. But the irq handler for ds3232 unconditionally
disables the irq at first and the irq is re-enabled only when the
interrupt source was the ds3232's alarm. This behaviour breaks the
devices sharing the same irq in the various scenarios.
This converts to use threaded irq and remove outdated code in
suspend/resume paths.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Suggested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
UIE mode irqs are handled by the generic rtc core now. But there are
remaining unused code fragments for it.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Add missing register access error checks and make it return error code
or print error message.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The rtctest (tools/testing/selftests/timers/rtctest.c) found that
reading ds3232 rtc device immediately return the value 0x20 (RTC_AF)
without waiting alarm interrupt.
This is because alarm_irq_enable() of ds3232 driver changes RTC_AF
flag in rtc->irq_data. So calling ioctl with RTC_AIE_ON generates
invalid value in rtc device.
The lower-level driver should not touch rtc->irq_data directly.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
According to "Feature Comparison of the DS323x Real-Time Clocks"
(http://pdfserv.maximintegrated.com/en/an/AN5143.pdf), DS3232 and
DS3234 are very similar.
This merges rtc-ds3232 and rtc-ds3234 with using regmap.
This change also enables to support alarm for ds3234.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Suggested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The trickle charger resistor can be enabled via device tree
property trickle-resistor-ohms.
Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
This adds functions for access to the EEPROM memory on the rv3029.
Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
This adds all (according to the data sheet) missing register and bit
definitions.
It also fixes the definition of the trickle charger bit masks.
Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The C2 suffix does not appear in the latest datasheet, so add
a device ID without it.
Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The C2 suffix does not appear anymore in the latest device and
data sheet versions.
Signed-off-by: Michael Buesch <m@bues.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
There are several arch-specific RTC drivers that can be successfully
compiled on other platforms. Add a COMPILE_TEST dependency for those.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
There are four architectures using this driver, but since we can
build it with COMPILE_TEST, we should try dealing with the absence
of the asm/rtc.h header file, to avoid getting a build error:
drivers/rtc/rtc-generic.c:12:21: fatal error: asm/rtc.h: No such file or directory
This creates an alternative use of the driver, allowing architectures
to pass a set of rtc_class_ops in platform data. We can convert the
four architectures to use this and then remove the original
code.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The time and date register of the pcf8223 are undefined after a power
reset. Properly handle the OS bit and return -EINVAL when that bit is set.
It is properly removed when setting the time.
This solves an issue where the time and date may be valid for
rtc_valid_tm() but is not the current time.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
No members of struct pcf85063 are used anymore, remove the whole structure.
Reviewed-by: Juergen Borleis <jbe@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
We call spin_lock_irqrestore with "flags" set to zero instead of to the
value from spin_lock_irqsave().
Fixes: aaaf5fbf56 ('rtc: add driver for DS1685 family of real time clocks')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Use macro REGMAP_IRQ_REG from regmap.h to initialise the
regmap irq table for max77686 to have better coding style
and improve readability.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Maxim Semiconductor's PMIC MAX77686 has RTC IP which is
reused in the MAX77620/MAX20024 PMICs.
Add support for these devices in MAX77686 RTC driver. This
device does not have RTC alarm pending status outside of
RTC IP. The RTC IP is having separate I2C address for its
register access.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The driver uses the MODULE_ALIAS() macro to export a platform module alias
to allow the module to be autoloaded if the device is registered using the
legacy platform registration mechanism but the driver is always used by OF
only machines so the alias is not needed and should just be removed.
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
pcf85063_get_datetime() tries to handle a century bit but that bit is not
documented and the final value is never used anywhere else in the kernel.
Reviewed-by: Juergen Borleis <jbe@pengutronix.de>
Tested-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
drivers/rtc/rtc-vr41xx.c:229: warning: ‘vr41xx_rtc_alarm_irq_enable’ defined but not used
Apparently the conversion to alarm_irq_enable forgot to wire up the
callback.
Fixes: 16380c153a ("RTC: Convert rtc drivers to use the alarm_irq_enable method")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
The Kconfig option for rv3029 is not mentioning any part number, explicitly
show rv3029.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
as3722 RTC IRQ is nested threaded and wired to the as3722 inerrupt
controller. So, this flag is not required for nested irqs anymore,
since commit 3c646f2c6a ("genirq: Don't suspend nested_thread irqs
over system suspend") was merged.
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Nishanth Menon <nm@ti.com>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
tps80031 RTC IRQ is nested threaded and wired to the tps80031
inerrupt controller. So, this flag is not required for nested irqs
anymore, since commit 3c646f2c6a ("genirq: Don't suspend
nested_thread irqs over system suspend") was merged.
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
tps65910 RTC IRQ is nested threaded and wired to the tps65910 inerrupt
controller. So, this flag is not required for nested irqs anymore,
since commit 3c646f2c6a ("genirq: Don't suspend nested_thread irqs
over system suspend") was merged.
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
tps6586x RTC IRQ is nested threaded and wired to the tps6586x inerrupt
controller. So, this flag is not required for nested irqs anymore,
since commit 3c646f2c6a ("genirq: Don't suspend nested_thread irqs
over system suspend") was merged.
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Nishanth Menon <nm@ti.com>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>