Commit Graph

131 Commits

Author SHA1 Message Date
Nobuhiro Iwamatsu 3dd2cd6446 rtc: ds1307: Fix wday settings for rx8130
[ Upstream commit 204756f016726a380bafe619438ed979088bd04a ]

rx8130 wday specifies the bit position, not BCD.

Fixes: ee0981be77 ("rtc: ds1307: Add support for Epson RX8130CE")
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210420023917.1949066-1-nobuhiro1.iwamatsu@toshiba.co.jp
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-05-19 10:08:26 +02:00
Linus Torvalds edafb6fe42 RTC for 5.3
Drivers:
  - ds1307: properly handle oscillator failure flags
  - imx-sc: alarm support
  - pcf2123: alarm support, correct offset handling
  - sun6i: add R40 support
  - simplify getting the adapter of an i2c client
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAl0tl5UACgkQ2wIijOdR
 NOVMig/8C7o1tBpm1Kfs3GYjZ5o2SI7m6425OypONOa9U2rFVnFHxVogtIHTC7wa
 SXVFdV+L/MT/xHEbQ3Mfv36cRB0h3Q89NqcVWFkjSGvoqliTIA2F2zsLDHYLDyEO
 AdOc8ztzrTCmlPjrg7d64qxA/l/dPChIhDW1nsMTJY7EXO0lBywcEP0KQsnOrjzD
 lNDskhLuYaL0h1OL2KSrx/81ZZW1MXEyTU5nl4e2JowVYFB0f75P7h79MChmjM35
 wE5WVDH8LqhYHOoVR9fW5sjRpNgdKfFsH8Sh5DGVU3jLGA72v0Eo/c1BHHegumoI
 6X+09nv9D3j4l2z5on5TzXMhvwuLdZQ2VRBdpI1XcVjtYA18UTIXZA8wDRgLTb3b
 MZE31s1WM0vxSiGyaL+hfI9APfX0xSd+BIqVvxhUVPvCGCwWvfLJgQfmlsW4eWOk
 LdmifkLb0Mjf+ym+WH8GvXND+ZeNJ9eUUwVZkGHPhb6SfkLiEAnw3f1czOT1fLDR
 q6i0hG9/+BsiwZMCJt86rDZd1D51FjkNzUH1d///iURvaDhoi41nKaFR45kc5Foc
 WVmnWDWw1yg7K6kUQ3kXsyBkbw0jhdCXGN539rrvbElyL5e5XDUo+3gAEi25CkVe
 DCpxICWO+jvOrjJBHdH3T3HJDa7NbFXWkXOwLXe5M42q7rrgZwY=
 =aJ54
 -----END PGP SIGNATURE-----

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

Pull RTC updates from Alexandre Belloni:
 "A quiet cycle this time.

   - ds1307: properly handle oscillator failure flags

   - imx-sc: alarm support

   - pcf2123: alarm support, correct offset handling

   - sun6i: add R40 support

   - simplify getting the adapter of an i2c client"

* tag 'rtc-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (37 commits)
  rtc: wm831x: Add IRQF_ONESHOT flag
  rtc: stm32: remove one condition check in stm32_rtc_set_alarm()
  rtc: pcf2123: Fix build error
  rtc: interface: Change type of 'count' from int to u64
  rtc: pcf8563: Clear event flags and disable interrupts before requesting irq
  rtc: pcf8563: Fix interrupt trigger method
  rtc: pcf2123: fix negative offset rounding
  rtc: pcf2123: add alarm support
  rtc: pcf2123: use %ptR
  rtc: pcf2123: port to regmap
  rtc: pcf2123: remove sysfs register view
  rtc: rx8025: simplify getting the adapter of a client
  rtc: rx8010: simplify getting the adapter of a client
  rtc: rv8803: simplify getting the adapter of a client
  rtc: m41t80: simplify getting the adapter of a client
  rtc: fm3130: simplify getting the adapter of a client
  rtc: tegra: Drop MODULE_ALIAS
  rtc: sun6i: Add R40 compatible
  dt-bindings: rtc: sun6i: Add the R40 RTC compatible
  dt-bindings: rtc: Convert Allwinner A31 RTC to a schema
  ...
2019-07-17 10:03:50 -07:00
Thomas Gleixner d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
Based on 2 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:55 +02:00
Alexandre Belloni b3a5016976 rtc: ds1307: properly handle oscillator failure flags
Stop enabling the oscillator and removing the oscillator failure flags in
probe. Instead, return -EINVAL in .read_time when the oscillaotr is not
start or when it failed at some point. The oscillator gets enabled on the
first .set_time after failure and the failure flags are cleared.

This also removes the possibility of an infinite loop at probe where a
failing RTC will make the goto read_rtc to be taken every time.

Tested on mcp79411.

Reported-by: Mastro Gippo <gipmad@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2019-05-23 17:53:03 +02: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
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
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
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
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
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
Andrea Greco 51ed73eb99 rtc: ds1340: Add support for trickle charger.
Add support Dallas DS1340 trickle charger function.

Signed-off-by: Andrea Greco <a.greco@4sigma.it>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-03 22:46:25 +02:00
Alexandre Belloni 22652ba724 rtc: stop validating rtc_time in .read_time
The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-02 10:09:58 +01:00
Alexandre Belloni 409baf1785 rtc: ds1307: put struct nvmem_config on the stack
Avoid allocating memory for struct nvmem_config as it is only necessary at
the nvmem registration.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01 10:49:17 +01:00
Alexandre Belloni e9fb7682fa rtc: ds1307: call rtc_nvmem_register()
Call rtc_nvmem_register instead of letting the core do it and stop using
the nvmem_config member of struct rtc_device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-01 10:49:16 +01:00
Bastian Stender 47dd472928 rtc: ds1307: add OF and ACPI entries for Epson RX8130
Make Epson RX8130 device tree and ACPI aware.

Fixes: ee0981be77 ("rtc: ds1307: Add support for Epson RX8130CE")
Signed-off-by: Bastian Stender <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-10-26 23:00:24 +02:00
Heiner Kallweit 584ce30c72 rtc: ds1307: improve weekday handling
The current code for checking and fixing the weekday in ds1307_probe
faces some issues:
- This check is applied to all chips even if its applicable (AFAIK)
  to mcp794xx only
- The check uses MCP794XX constants for registers and bits even though
  it's executed also on other chips (ok, this could be fixed easily)
- It relies on tm_wday being properly populated when core calls set_time
  and set_alarm. This is not guaranteed at all.

First two issue we could solve by moving the check to the
mcp794xx-specific initialization (where also VBATEN flag is set).

The proposed alternative is in the set_alarm path for mcp794xx only and
calculates the alarm weekday based on the current weekday in the RTC
timekeeping regs and the difference between alarm date and current date.
So we are fine with any weekday even if it doesn't match the date.

Still there are cases where this could fail, e.g.:
- rtc date/time + weekday have power-on-reset default values
- alarm is set to actual date/time + x
- set_time is called (may change diff between rtc weekday and actual
  weekday)

But similar issues we have with the current code too:
- rtc date/time + weekday have power-on-reset default values
- alarm is set to rtc date/time + x
- set_time is called before the alarm triggers

Using random rtc date/time with relative alarms simply can interfere
with set_time. I'm not totally convinced of either option yet.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-10-12 14:16:09 +02:00
Linus Torvalds 561a8eb3e1 RTC for 4.14
Subsystem:
  - Remove .open() and .release() RTC ops
  - constify i2c_device_id
 
 New driver:
  - Realtek RTD1295
  - Android emulator (goldfish) RTC
 
 Drivers:
  - ds1307: Beginning of a huge cleanup
  - s35390a: handle invalid RTC time
  - sun6i: external oscillator gate support
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEXx9Viay1+e7J/aM4AyWl4gNJNJIFAlm5YTcACgkQAyWl4gNJ
 NJKetg//Xz4zK3O1uhfz1/yWOSqbBwYxUvHzSDFuD3FtAskFPPFACgJENkj98DMF
 w6nCqq/TXOY+BpqPTebzc68vvHGCvZ/AEKPzvCV1KciQ+ACMFGxH8xHCLox9AdyL
 VtcWftPPwu3W6oNN1azV++XgVtComzfEi4pTcTXdw9EDA5yBK/Xyg3xWZ1QV/Xs5
 /DFCcY69nhaJxmD/To0csmI1KbMbiprvN0vJHtF589Y4KhBfnlZnq3bAx2Coo1kv
 PpPy0e0kLzzlWMtMsiM6I3w5iwuf5o1Vajcg5ylAK0Wjvfgh7DqYX0ZQySw/5eZT
 f1OCqP0GVSugmJ8SFMVxYbXPGgpUETtT6ztB9fsAYdUye3I/xfqmip3A7vcFlrAb
 /R1gTZOyx/uwv3qVRsx0LJVxJQJ7vq/3dJYFiQo80AbPyY+GQT3xPr3z33DcJYJt
 2CL0pd6NfEzgesuVCnpZxF+wNJ+449Jzmxge5klqH1rYQ/IjOXS0qAg5pQRUaRjC
 CGNkjBWT82HN1Y8G++4FpdmHLUjkO07QyAAZiYvHNXX3aMcyl8Az/2kcrl+yq7tl
 03CxveLD8kP1bVsRMEIbx24l4lB93U5HyFTeli9xjBMbxDrBK2NZXCD7g/yI/sbs
 ryUe5W33Xgxm0DJ9CXts0qOf/ommiBoogYk+oxe+AGWdLR1weRo=
 =Xkx1
 -----END PGP SIGNATURE-----

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

Pull RTC updates from Alexandre Belloni:
 "Subsystem:
   - remove .open() and .release() RTC ops
   - constify i2c_device_id

  New driver:
   - Realtek RTD1295
   - Android emulator (goldfish) RTC

  Drivers:
   - ds1307: Beginning of a huge cleanup
   - s35390a: handle invalid RTC time
   - sun6i: external oscillator gate support"

* tag 'rtc-4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (40 commits)
  rtc: ds1307: use octal permissions
  rtc: ds1307: fix braces
  rtc: ds1307: fix alignments and blank lines
  rtc: ds1307: use BIT
  rtc: ds1307: use u32
  rtc: ds1307: use sizeof
  rtc: ds1307: remove regs member
  rtc: Add Realtek RTD1295
  dt-bindings: rtc: Add Realtek RTD1295
  rtc: sun6i: Add support for the external oscillator gate
  rtc: goldfish: Add RTC driver for Android emulator
  dt-bindings: Add device tree binding for Goldfish RTC driver
  rtc: ds1307: add basic support for ds1341 chip
  rtc: ds1307: remove member nvram_offset from struct ds1307
  rtc: ds1307: factor out offset to struct chip_desc
  rtc: ds1307: factor out rtc_ops to struct chip_desc
  rtc: ds1307: factor out irq_handler to struct chip_desc
  rtc: ds1307: improve irq setup
  rtc: ds1307: constify struct chip_desc variables
  rtc: ds1307: improve trickle charger initialization
  ...
2017-09-13 10:56:00 -07:00
Alexandre Belloni b4be271ceb rtc: ds1307: use octal permissions
Octal permissions are preferred over symbolic permissions.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-05 09:55:05 +02:00
Alexandre Belloni e69c056714 rtc: ds1307: fix braces
Fix unnecessary or unbalanced braces.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-05 09:55:05 +02:00
Alexandre Belloni 4057a66e53 rtc: ds1307: fix alignments and blank lines
Alignment should always match open parenthesis.
Also remove two unnecessary blank lines

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-05 09:55:05 +02:00
Alexandre Belloni eb4fd19005 rtc: ds1307: use BIT
Use the BIT macro were possbiel.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-05 09:55:04 +02:00
Alexandre Belloni 57ec2d9580 rtc: ds1307: use u32
u32 should be used instead of uint32_t

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-05 09:55:04 +02:00
Alexandre Belloni f2b4801201 rtc: ds1307: use sizeof
Use sizeof where possible to ensure we don't read/write more than the
allocated buffer.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-05 09:55:03 +02:00
Alexandre Belloni 042fa8c7c0 rtc: ds1307: remove regs member
ds1307->regs is never used before being read or initialized locally. There
is no point in keeping a copy in memory.

Also limit the size of the read buffer to what is really used, rename buf
to regs for consistency and use sizeof() where possible.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-05 09:55:03 +02:00
Nikita Yushchenko 0759c886f4 rtc: ds1307: add basic support for ds1341 chip
This adds support for reading and writing date/time from/to ds1341 chip.

ds1341 chip has other features - alarms, input clock (can be used instead
of intercal oscillator for better accuracy), output clock ("square wave
generation"). However, not all of that is available at the same time.
Same chip pins, CLKIN/nINTA and SQW/nINTB, can be used either for
input/output clocks, or for alarm interrupts. Role of these pins on
particular board depends on hardware wiring.

We can add device tree properties that describe if each of pins is wired
as clock, or as interrupt, or left unconnected, and enable support for
corresponding functionality based on that. But that is cumbersome, requires
hardware for testing, and has to deal with bit enabling/disabling output
clock also affects which pins alarm interrupts are routed to.

Another factor is that there are hardware setups (i.e. ZII RDU2) that
power DS1341 from SuperCap, which makes power saving critical. For such
setups, kernel driver should leave register bits that control mentioned
pins in the state configured by bootloader.

Given all that, it was decided to limit support to "only date/time" for
now. That is enough for common use case. Full (and cumbersome)
implementation can be added later if ever needed.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Tested-by: Aleksander Morgado <aleksander@aleksander.es>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:18 +02:00
Heiner Kallweit 969fa07b94 rtc: ds1307: remove member nvram_offset from struct ds1307
Remove member nvram_offset from struct ds1307 and use the value stored
in struct chip_desc directly.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:17 +02:00
Heiner Kallweit e553170a59 rtc: ds1307: factor out offset to struct chip_desc
Factor out offset to struct chip_desc and remove it from struct ds1307.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:17 +02:00
Heiner Kallweit 1efb98ba5e rtc: ds1307: factor out rtc_ops to struct chip_desc
Factor out rtc_ops to struct chip_desc and use ds13xx_rtc_ops as default.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:16 +02:00
Heiner Kallweit 4594712705 rtc: ds1307: factor out irq_handler to struct chip_desc
Factor out irq_handler to struct chip_desc and use ds1307_irq as default.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:16 +02:00
Heiner Kallweit 82e2d43f63 rtc: ds1307: improve irq setup
Change the usage of variable want_irq to reflect its name. Don't set
it to true in case wakeup is enabled but no interrupt number is given.
In addition set variable ds1307_can_wakeup_device if chip->alarm
is set only.
This allows to simplify the code and make it better understandable.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:15 +02:00
Heiner Kallweit 7624df482d rtc: ds1307: constify struct chip_desc variables
Constify struct chip_desc variables.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:14 +02:00
Heiner Kallweit d8490fd55a rtc: ds1307: improve trickle charger initialization
Instead of storing the trickle_charger_setup value in struct chip_desc
we can let function ds1307_trickle_init return it because it's used
in the probe function only.
This allows us to constify struct chip_desc variables in a next step.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:13 +02:00
Heiner Kallweit 0b6ee80594 rtc: ds1307: factor out bbsqi bit to struct chip_desc
Factor out the bbsqi bit to struct chip_desc.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:13 +02:00
Heiner Kallweit 340fd7bce0 rtc: ds1307: remove member irq from struct ds1307
The irq number is used in the probe function only, so we don't have
to store it in struct ds1307.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-09-01 01:10:12 +02:00
Heiner Kallweit 03619844d8 rtc: ds1307: fix regmap config
Current max_register setting breaks reading nvram on certain chips and
also reading the standard registers on RX8130 where register map starts
at 0x10.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Fixes: 11e5890b53 "rtc: ds1307: convert driver to regmap"
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-08-21 11:08:03 +02:00
Heiner Kallweit 11909f0be7 rtc: ds1307: remove legacy check for "isil, irq2-can-wakeup-machine" property
Commit 8b44f5be20 ("ARM: dts: armada: replace isil,irq2-can-wakeup-machine with wakeup-source property")
removed the last usage of "isil,irq2-can-wakeup-machine" almost
two years ago. So I think we can get rid of supporting this
legacy binding.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-31 00:17:45 +02:00
Alexandre Belloni bed8e28047 rtc: ds1307: remove ds1307_remove
ds1307_remove() is now empty, remove it

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-07 13:14:25 +02:00
Alexandre Belloni abc925f72c rtc: ds1307: use generic nvmem
Instead of adding a binary sysfs attribute from the driver (which suffers
from a race condition as the attribute appears after the device), use the
core to register an nvmem device.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-07 13:14:23 +02:00
Alexandre Belloni 69b119a642 rtc: ds1307: switch to rtc_register_device
This removes a possible race condition and crash and allows for further
improvement of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-07 13:14:21 +02:00
Sean Nyekjaer 300a7735be rtc: ds1307: add ds1308 variant
The ds1308 variant is very similar to the already supported ds1338
variant, it have more debug registers and a square wave clock output.

Signed-off-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-06 22:37:17 +02:00
Heiner Kallweit e48585dec2 rtc: ds1307: factor out century bit handling
The driver has lots of places with chip-specific code what doesn't
necessarily facilitate maintenance.

Let's describe chip-specific differences in century bit handling
in struct chip_desc to improve this.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-06 22:37:08 +02:00
Heiner Kallweit 078f3f6452 rtc: ds1307: use regmap_update_bits where applicable
After the switch to regmap we can now make use of regmap_update_bits
to simplify read/modify/write ops.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-07-05 23:12:34 +02:00
Marek Vasut ee0981be77 rtc: ds1307: Add support for Epson RX8130CE
Add support for yet another RTC chip, Epson RX8130CE. This time around,
the chip has slightly permutated registers and also the register starts
at 0x10 instead of 0x0 .

So far, we only support the RTC and NVRAM parts of the chip, Alarm and
Timer is not supported.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-06-24 22:59:38 +02:00
Alexandre Belloni 4b9e2a0c05 rtc: ds1307: avoid using rtc-name
ds1307->rtc->name is a copy of ds1307->name, use it instead.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-06-03 10:55:26 +02:00