History log of /linux-master/drivers/rtc/rtc-ds1307.c
Revision Date Author Comments
# 737055e1 09-Aug-2023 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

rtc: ds1307: fix Wvoid-pointer-to-enum-cast warning

'type' is an enum, thus cast of pointer on 64-bit compile test with W=1
causes:

rtc-ds1307.c:1747:18: error: cast to smaller integer type 'enum ds_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20230810103902.151145-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 31b0cecb 05-May-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

rtc: Switch i2c drivers back to use .probe()

After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498b5 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230505121136.1185653-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 4cd0ca1f 18-Nov-2022 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

rtc: ds1307: Convert to i2c's .probe_new()

.probe_new() doesn't get the i2c_device_id * parameter, so determine
that explicitly in the probe function.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20221118224540.619276-561-uwe@kleine-koenig.org
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 0feebdeb 04-Dec-2022 ye xingchen <ye.xingchen@zte.com.cn>

rtc: ds1307: use sysfs_emit() to instead of scnprintf()

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Link: https://lore.kernel.org/r/202212051134455911470@zte.com.cn
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# e59b3c73 06-Nov-2022 Christophe JAILLET <christophe.jaillet@wanadoo.fr>

rtc: Include <linux/kstrtox.h> when appropriate

The kstrto<something>() functions have been moved from kernel.h to
kstrtox.h.

So, include the latter directly in the appropriate files.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/786421fd0435a32206288904a1f879436a717529.1667721637.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 000bf045 09-Mar-2022 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: switch to RTC_FEATURE_UPDATE_INTERRUPT

Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead.

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


# 204756f0 19-Apr-2021 Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>

rtc: ds1307: Fix wday settings for rx8130

rx8130 wday specifies the bit position, not BCD.

Fixes: ee0981be7704 ("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


# 4bf84b44 17-Apr-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: remove flags

flags is now unused, drop it.

Tested-by: Łukasz Stelmach <l.stelmach@samsung.com>
Reviewed-by: Łukasz Stelmach <l.stelmach@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210418000023.995758-2-alexandre.belloni@bootlin.com


# 64e9d8e4 17-Apr-2021 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: replace HAS_ALARM by RTC_FEATURE_ALARM

The core now has RTC_FEATURE_ALARM for the driver to indicate whether
alarms are available. Use that instead of HAS_ALARM to ensure the alarm
callbacks are not even called.

Tested-by: Łukasz Stelmach <l.stelmach@samsung.com>
Reviewed-by: Łukasz Stelmach <l.stelmach@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210418000023.995758-1-alexandre.belloni@bootlin.com


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

rtc: ds1307: use rtc_lock/rtc_unlock

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

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


# fdcfd854 09-Nov-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: rework rtc_register_device() resource management

rtc_register_device() is a managed interface but it doesn't use devres
by itself - instead it marks an rtc_device as "registered" and the devres
callback for devm_rtc_allocate_device() takes care of resource release.

This doesn't correspond with the design behind devres where managed
structures should not be aware of being managed. The correct solution
here is to register a separate devres callback for unregistering the
device.

While at it: rename rtc_register_device() to devm_rtc_register_device()
and add it to the list of managed interfaces in devres.rst. This way we
can avoid any potential confusion of driver developers who may expect
there to exist a corresponding unregister function.

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


# 3a905c2d 09-Nov-2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>

rtc: add devm_ prefix to rtc_nvmem_register()

rtc_nvmem_register() is a managed interface. It doesn't require any
release function to be called at driver detach. To avoid confusing
driver authors, let's rename it to devm_rtc_nvmem_register() and add it
to the list of managed interfaces in Documentation/.

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


# 25ece305 09-Nov-2020 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: nvmem: remove nvram ABI

The nvram sysfs attributes have been deprecated at least since v4.13, more
than 3 years ago and nobody ever complained about the deprecation warning.

Remove the sysfs attributes now.

[Bartosz: remove the declaration of rtc_nvmem_unregister()]

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


# 698fffc2 16-Nov-2020 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

rtc: ds1307: Drop of_match_ptr and CONFIG_OF protections

These prevent use of this driver with ACPI via PRP0001.
Drop them to remove this restriction.

Also added mod_devicetable.h include given use of struct of_device_id.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201116142859.31257-3-andriy.shevchenko@linux.intel.com


# 227ec129 16-Nov-2020 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

rtc: ds1307: Make use of device properties

Device property API allows to gather device resources from different sources,
such as ACPI. Convert the drivers to unleash the power of device property API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20201116142859.31257-2-andriy.shevchenko@linux.intel.com


# a3111118 16-Nov-2020 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

rtc: ds1307: Remove non-valid ACPI IDs

The commit 9c19b8930d2c ("rtc: ds1307: Add ACPI support") added invalid
ACPI IDs (all of them are abusing ACPI specification). Moreover there is
not even a single evidence that vendor registered any of such devices.

Remove broken ACPI IDs from the driver. For prototyping one may use PRP0001
with device properties adhering to a DT binding. The following patches
will add support of that to the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Tin Huynh <tnhuynh@apm.com>
Link: https://uefi.org/PNP_ACPI_Registry
Link: https://lore.kernel.org/r/20201116142859.31257-1-andriy.shevchenko@linux.intel.com


# 0026f160 17-Sep-2020 Bastian Krause <bst@pengutronix.de>

rtc: ds1307: enable rx8130's backup battery, make it chargeable optionally

The ds1307 charger infrastructure now allows to add a rx8130 charger
setup that..

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

Make that happen.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-9-bst@pengutronix.de


# 0874734e 17-Sep-2020 Bastian Krause <bst@pengutronix.de>

rtc: ds1307: consider aux-voltage-chargeable

Prefer aux-voltage-chargeable over trickle-diode-disable and set diode
accordingly. This is then passed to the chip's appropriate charge setup
function.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-8-bst@pengutronix.de


# 95a74cbb 17-Sep-2020 Bastian Krause <bst@pengutronix.de>

rtc: ds1307: store previous charge default per chip

Some RTC's batteries and supercaps were charged by default until now.
In contrast other RTCs allow charging but the driver did not configure
them to do so until now. These must not be charged by default to stay
backwards compatible.

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

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-7-bst@pengutronix.de


# 1b5b6af7 17-Sep-2020 Bastian Krause <bst@pengutronix.de>

rtc: ds1307: introduce requires_trickle_resistor per chip

Make trickle-resistor-ohms optional for charging setups that do not
require specifying ROUT bits (specifying the resistor value between Vcc
and Vbackup). In order to allow specifying that, introduce
requires_trickle_resistor per chip.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-6-bst@pengutronix.de


# 462eb736 17-Sep-2020 Bastian Krause <bst@pengutronix.de>

rtc: ds1307: apply DS13XX_TRICKLE_CHARGER_MAGIC only conditionally

DS13XX_TRICKLE_CHARGER_MAGIC sets the trickle-charge select (TCS) bits
(7..4). The datasheet of Maxim Integrated's DS1339 [1] for instance
reads:

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

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

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

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

Signed-off-by: Bastian Krause <bst@pengutronix.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200917183246.19446-5-bst@pengutronix.de


# f471b05f 17-Aug-2020 Chris Packham <chris.packham@alliedtelesis.co.nz>

rtc: ds1307: Clear OSF flag on DS1388 when setting time

Ensure the OSF flag is cleared on the DS1388 when the clock is set.

Fixes: df11b323b16f ("rtc: ds1307: handle oscillator failure flags for ds1388 variant")
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200818013543.4283-1-chris.packham@alliedtelesis.co.nz


# 59ed0127 16-Aug-2020 Chris Packham <chris.packham@alliedtelesis.co.nz>

rtc: ds1307: Ensure oscillator is enabled for DS1388

Similar to the other variants the DS1388 has a bit to stop the
oscillator to reduce the power consumption from VBAT. Ensure that the
oscillator is enabled when the system is up.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20200816235731.21071-1-chris.packham@alliedtelesis.co.nz


# 9bf13062 26-Jul-2020 Chris Packham <chris.packham@alliedtelesis.co.nz>

rtc: ds1307: provide an indication that the watchdog has fired

There's not much feedback when the ds1388 watchdog fires. Generally it
yanks on the reset line and the board reboots. Capture the fact that the
watchdog has fired in the past so that userspace can retrieve it via
WDIOC_GETBOOTSTATUS. This should help distinguish a watchdog triggered
reset from a power interruption.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200727034615.19755-1-chris.packham@alliedtelesis.co.nz


# 1821b79d 02-Apr-2020 Colin Ian King <colin.king@canonical.com>

rtc: ds1307: check for failed memory allocation on wdt

Currently a failed memory allocation will lead to a null pointer
dereference on point wdt. Fix this by checking for a failed
allocation and just returning.

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

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20200403110437.57420-1-colin.king@canonical.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# fd90d48d 29-Mar-2020 Chris Packham <chris.packham@alliedtelesis.co.nz>

rtc: ds1307: add support for watchdog timer on ds1388

The DS1388 variant has watchdog timer capabilities. When using a DS1388
and having enabled CONFIG_WATCHDOG_CORE register a watchdog device for
the DS1388.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200330025500.6991-1-chris.packham@alliedtelesis.co.nz
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# df11b323 06-Feb-2020 Chris Packham <chris.packham@alliedtelesis.co.nz>

rtc: ds1307: handle oscillator failure flags for ds1388 variant

The FLAG register is at a different location to the other supported RTCs
so this requires an extra case in the existing switch statement.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Link: https://lore.kernel.org/r/20200207031812.14424-2-chris.packham@alliedtelesis.co.nz
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# d2912cb1 04-Jun-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500

Based on 2 normalized pattern(s):

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

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

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-only

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# b3a50169 10-Apr-2019 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# 3f929cad 25-Jan-2019 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

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: ee0981be7704 ("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>


# 501f9826 25-Jan-2019 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

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>


# 3ffd4a2f 25-Jan-2019 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

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: ee0981be7704 ("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>


# d0e3f61b 25-Jan-2019 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

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>


# 92cbf12f 25-Jan-2019 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

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>


# 7dceef78 22-Oct-2018 Soeren Moch <smoch@web.de>

rtc: ds1307: fix ds1339 wakealarm support

Commit 51ed73eb998a1c79a2b0e9bed68f75a8a2c93b9b ("rtc: ds1340: Add support
for trickle charger.") breaks ds1339 wakealarm support by limiting
accessible registers. Fix this.

Fixes: 51ed73eb998a ("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>


# 6a5f2a1f 20-Sep-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# b41c23e1 25-Jul-2018 Giulio Benetti <giulio.benetti@micronovasrl.com>

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>


# 79230ff6 25-Jul-2018 Giulio Benetti <giulio.benetti@micronovasrl.com>

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>


# 6b583a64 27-Sep-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 7e580769 16-May-2018 Giulio Benetti <giulio.benetti@micronovasrl.com>

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>


# 146a552c 16-May-2018 Giulio Benetti <giulio.benetti@micronovasrl.com>

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>


# 51ed73eb 20-Apr-2018 Andrea Greco <a.greco@4sigma.it>

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>


# 22652ba7 19-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: stop validating rtc_time in .read_time

The RTC core is always calling rtc_valid_tm after the read_time callback.
It is not necessary to call it just before returning from the callback.

Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>


# 409baf17 12-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# e9fb7682 12-Feb-2018 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# 47dd4729 17-Oct-2017 Bastian Stender <bst@pengutronix.de>

rtc: ds1307: add OF and ACPI entries for Epson RX8130

Make Epson RX8130 device tree and ACPI aware.

Fixes: ee0981be7704 ("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>


# 584ce30c 29-Aug-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# b4be271c 04-Sep-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: use octal permissions

Octal permissions are preferred over symbolic permissions.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# e69c0567 04-Sep-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: fix braces

Fix unnecessary or unbalanced braces.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 4057a66e 04-Sep-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# eb4fd190 04-Sep-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: use BIT

Use the BIT macro were possbiel.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 57ec2d95 04-Sep-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: use u32

u32 should be used instead of uint32_t

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# f2b48012 04-Sep-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# 042fa8c7 04-Sep-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# 0759c886 24-Aug-2017 Nikita Yushchenko <nikita.yoush@cogentembedded.com>

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>


# 969fa07b 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# e553170a 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 1efb98ba 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 45947127 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 82e2d43f 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 7624df48 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# d8490fd5 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 0b6ee805 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 340fd7bc 11-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 03619844 25-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

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: 11e5890b5342 "rtc: ds1307: convert driver to regmap"
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 11909f0b 06-Jul-2017 Heiner Kallweit <hkallweit1@gmail.com>

rtc: ds1307: remove legacy check for "isil, irq2-can-wakeup-machine" property

Commit 8b44f5be20fd ("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>


# bed8e280 06-Jul-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: remove ds1307_remove

ds1307_remove() is now empty, remove it

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# abc925f7 06-Jul-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# 69b119a6 06-Jul-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# 300a7735 07-Jun-2017 Sean Nyekjaer <sean@geanix.com>

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>


# e48585de 05-Jun-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# 078f3f64 05-Jun-2017 Heiner Kallweit <hkallweit1@gmail.com>

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>


# ee0981be 18-Jun-2017 Marek Vasut <marex@denx.de>

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>


# 4b9e2a0c 02-Jun-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

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>


# 80663607 22-Apr-2017 David Lowe <dave-lowe@ntlworld.com>

rtc: rtc-ds1307: enable support for mcp794xx as a wakeup source without IRQ

This patch extends the fixes for ds1337, ds1339, ds3231 in commit
8bc2a40730ec ("rtc: ds1307: add support for the DT property
'wakeup-source'") to mcp794xx devices, so that those parts can similarly be
used as a wakeup source without an IRQ to the processor.

Tested on Raspberry Pi ZeroW with MCP79400.

Signed-off-by: David Lowe <dave-lowe@ntlworld.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 11e5890b 10-Mar-2017 Heiner Kallweit <hkallweit1@gmail.com>

rtc: ds1307: convert driver to regmap

This patch converts the ds1307 driver to using regmap. It's a rather
big patch and I can test with DS3231 only. With this chip it's
working fine.

I'd appreciate if people with other supported hardware could test as
well.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# db2f8141 08-Apr-2017 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: Add m41t0 to OF device ID table

m41t0 was added to the I2C device ID table but not the OF table. Fix that.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 8566f70c 23-Mar-2017 Stefan Agner <stefan@agner.ch>

rtc: ds1307: support m41t0 variant

The m41t0 variant is very similar to the already supported m41t00
variant, with the notable exception of the oscillator fail bit.
The data sheet notes:

If the oscillator fail (OF) bit is internally set to a '1,' this
indicates that the oscillator has either stopped, or was stopped
for some period of time and can be used to judge the validity of
the clock and date data.

The bit will get cleared with a regular write of the system time,
so no changes are needed to clear it.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


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

rtc: ds1307: Add OF device ID table

The driver doesn't have a struct of_device_id table but supported devices
are registered via Device Trees. This is working on the assumption that a
I2C device registered via OF will always match a legacy I2C device ID and
that the MODALIAS reported will always be of the form i2c:<device>.

But this could change in the future so the correct approach is to have an
OF device ID table if the devices are registered via OF.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 9c19b893 29-Nov-2016 Tin Huynh <tnhuynh@apm.com>

rtc: ds1307: Add ACPI support

This patch enables ACPI support for rtc-ds1307 driver.

Signed-off-by: Tin Huynh <tnhuynh@apm.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 78aaa06d 12-Jul-2016 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: add Intersil ISL12057 support

Intersil ISL12057 is a drop-in replacement for DS1337. It can be supported
by the ds1307 driver.

Acked-by: Arnaud Ebalard <arno@natisbad.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 50d6c0ea 12-Jul-2016 Alexandre Belloni <alexandre.belloni@bootlin.com>

rtc: ds1307: fix century bit support

Add an option to properly support the century bit of ds1337 and compatibles
and ds1340.
Because the driver had a bug until now, it is not possible to switch users
to the fixed code directly as RTCs in the field will wrongly have the
century bit set.

Acked-by: Arnaud Ebalard <arno@natisbad.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


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

rtc: simplify implementations of read_alarm

Since commit d68778b80dd7 ("rtc: initialize output parameter for read
alarm to "uninitialized"") there is no need to explicitly set
unsupported members to -1. So drop the respective assignments from
drivers.

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# e29385fa 01-Jun-2016 Keerthy <j-keerthy@ti.com>

rtc: ds1307: Fix relying on reset value for weekday

The reset value of weekday is 0x1. This is wrong since
the reset values of the day/month/year make up to Jan 1 2001.
When computed weekday comes out to be Monday. On a scale
of 1-7(Sunday - Saturday) it should be 0x2. So we should not
be relying on the reset value.

Hence compute the wday using the current date/month/year values.
Check if reset wday is any different from the computed wday,
If different then set the wday which we computed using
date/month/year values.

Document Referred:
http://ww1.microchip.com/downloads/en/DeviceDoc/20002266F.pdf

Fixes: 1d1945d261a2af "drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips"
Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 7457d5f5 19-Apr-2016 Stephen Boyd <sboyd@codeaurora.org>

rtc: ds1307: Remove CLK_IS_ROOT

This flag is a no-op now (see commit 47b0eeb3dc8a "clk: Deprecate
CLK_IS_ROOT", 2016-02-02) so remove it.

Cc: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Michael Tatarinov <kukabu@gmail.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 5919fb97 10-Apr-2016 Nicolas Boullis <nboullis@debian.org>

rtc: ds1307: ensure that any pending alarm is cleared before a new alarm is enabled

If a previously-set alarm was disabled and then triggered, it may still
be pending when a new alarm is configured.

Then, if the alarm is enabled before the pending alarm is cleared, then
an interrupt is immediately raised.

Unfortunately, when the alarm is cleared and enabled during the same I²C
block write, the chip (at least the DS1339 I have) considers that the
alarm is enabled before it is cleared, and raises an interrupt.

This patch ensures that the pending alarm is cleared before the alarm is
enabled.

Signed-off-by: Nicolas Boullis <nboullis@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 1d87951c 02-Apr-2016 Nicolas Boullis <nboullis@debian.org>

rtc: ds1307: fix ds1307_native_smbus_read_block_data function

The i2c_smbus_read_i2c_block_data function returns 0 on success, not the
number of bytes written.

Hence, when there are 32 bytes or less to send, the
ds1307_native_smbus_write_block_data function returns 0 on success,
while it returns the number of bytes when there are more than 32.

The ds1307_write_block_data always returns the number of bytes on
success.

Signed-off-by: Nicolas Boullis <nboullis@debian.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 38a7a73e 19-Apr-2016 Nishanth Menon <nm@ti.com>

rtc: ds1307: Use irq when available for wakeup-source device

With commit 8bc2a40730ec ("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: 8bc2a40730ec ("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>


# 9a3dce62 17-Apr-2016 Zhuang Yuyao <mlistz@gmail.com>

rtc: ds1307: ds3231 temperature s16 overflow

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>


# 6c6ff145 31-Jan-2016 Akinobu Mita <akinobu.mita@gmail.com>

rtc: ds1307: add clock provider support for DS3231

DS3231 has programmable square-wave output signal.
This enables to use this feature as a clock provider of
common clock framework.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Michael Turquette <mturquette@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 445c0207 24-Jan-2016 Akinobu Mita <akinobu.mita@gmail.com>

rtc: ds1307: add temperature sensor support for ds3231

DS3231 has the temperature registers with a resolution of 0.25
degree celsius. This enables to get the value through hwmon.

# cat /sys/class/i2c-adapter/i2c-2/2-0068/hwmon/hwmon0/temp1_input
21000

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 8bc2a407 21-Jan-2016 Michael Lange <linuxstuff@milaw.biz>

rtc: ds1307: add support for the DT property 'wakeup-source'

For RTC chips with no IRQ directly connected to the SoC, the RTC chip
can be forced as a wakeup source by stating that explicitly in
the device's .dts file using the "wakeup-source" boolean property.
This will guarantee the 'wakealarm' sysfs entry is available on the
device, if supported by the RTC.

With these changes to the driver rtc-ds1307 and the necessary entries
in the .dts file, I get an working ds1337 RTC on the Witty Pi extension
board by UUGear for the Raspberry Pi.

An example for the entry in the .dts file:

rtc: ds1337@68 {
compatible = "dallas,ds1337";
reg = <0x68>;
wakeup-source;

If the "wakeup-source" property is set, do not request an IRQ.
Set also UIE mode to unsupported, to get a working 'hwclock' binary.

Signed-off-by: Michael Lange <linuxstuff@milaw.biz>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# ff67abd2 24-Nov-2015 Rasmus Villemoes <linux@rasmusvillemoes.dk>

rtc: use %ph for short hex dumps

This makes the generated code slightly smaller.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 3abb1ada 26-Nov-2015 Simon Guinot <simon.guinot@sequanux.org>

rtc: ds1307: fix alarm reading at probe time

With the actual code, read_alarm() always returns -EINVAL when called
during the RTC device registration. This prevents from retrieving an
already configured alarm in hardware.

This patch fixes the issue by moving the HAS_ALARM bit configuration
(if supported by the hardware) above the rtc_device_register() call.

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 51c4cfef 11-Nov-2015 Felipe Balbi <balbi@ti.com>

rtc: ds1307: fix kernel splat due to wakeup irq handling

Since commit 3fffd1283927 ("i2c: allow specifying
separate wakeup interrupt in device tree") we have
automatic wakeup irq support for i2c devices. That
commit missed the fact that rtc-1307 had its own
wakeup irq handling and ended up introducing a
kernel splat for at least Beagle x15 boards.

Fix that by reverting original commit _and_ passing
correct interrupt names on DTS so i2c-core can
choose correct IRQ as wakeup.

Now that we have automatic wakeirq support, we can
revert the original commit which did it manually.

Fixes the following warning:

[ 10.346582] WARNING: CPU: 1 PID: 263 at linux/drivers/base/power/wakeirq.c:43 dev_pm_attach_wake_irq+0xbc/0xd4()
[ 10.359244] rtc-ds1307 2-006f: wake irq already initialized

Cc: Tony Lindgren <tony@atomide.com>
Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 62c8c20a 23-Oct-2015 Tero Kristo <t-kristo@ti.com>

rtc: ds1307: Fix alarm programming for mcp794xx

mcp794xx alarm registers must be written in BCD format. However, the
alarm programming logic neglected this by adding one to the value
after bin2bcd conversion has been already done, writing bad values
to month register in case the alarm being set is in October. In this
case, the alarm month value becomes 0x0a instead of the expected 0x10.

Fix by moving the +1 addition within the bin2bcd call also.

Fixes: 1d1945d261a2 ("drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips")

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# ca7c14d3 26-Jul-2015 Vladimir Zapolskiy <vz@mleia.com>

rtc: ds1307: clean up ds1307_nvram_read()/ds1307_nvram_write()

The change removes redundant sysfs binary file boundary checks, since
this task is already done on caller side in fs/sysfs/file.c

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# b2884543 10-Jul-2015 Krzysztof Kozlowski <krzk@kernel.org>

rtc: Drop owner assignment from i2c_driver

i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 7abea617 24-Jun-2015 Nishanth Menon <nm@ti.com>

rtc: ds1307: Support optional wakeup interrupt source

With the recent pinctrl-single changes, SoCs such as Texas
Instrument's OMAP processors can treat wake-up events from deeper idle
states as interrupts.

Let's add support for the optional second interrupt for wake-up using
the generic wakeirq support added in commit 4990d4fe327b ("PM /
Wakeirq: Add automated device wake IRQ handling")

Finally, to pass the wake-up interrupt in the dts file,
interrupts-extended property needs to be passed.

This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
support for optional wake-up") + ee83bd3b6483 ("serial: omap: Switch
wake-up interrupt to generic wakeirq")

Signed-off-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# eac7237f 23-Jun-2015 Nishanth Menon <nm@ti.com>

rtc: ds1307: Sort the headers

It is always a good practice to keep the #includes sorted

Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# c5983191 23-Jun-2015 Nishanth Menon <nm@ti.com>

rtc: ds1307: Switch to managed irq allocation

Since we are not doing anything fancy in remove function that requires
us to sequence IRQ free operation, we might as well switch over to devm_
equivalent of managed IRQ allocation and remove the explicit free_irq
since it'd be done automatically at remove.

Signed-off-by: Nishanth Menon <nm@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# 2fb07a10 23-Jun-2015 Felipe Balbi <balbi@ti.com>

rtc: ds1307: Convert to threaded IRQ

The driver currently emulates the concept of threaded IRQ using a
workqueue, which it really does not need to. Instead, switch over to
threaded_irq handlers which is meant precisely for the same purpose.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# e3edd671 20-Apr-2015 Nishanth Menon <nm@ti.com>

rtc: ds1307: Enable the mcp794xx alarm after programming time

Alarm interrupt enable register is at offset 0x7, while the time
registers for the alarm follow that. When we program Alarm interrupt
enable prior to programming the time, it is possible that previous
time value could be close or match at the time of alarm enable
resulting in interrupt trigger which is unexpected (and does not match
the time we expect it to trigger).

To prevent this scenario from occuring, program the ALM0_EN bit only
after the alarm time is appropriately programmed.

Ofcourse, I2C programming is non-atomic, so there are loopholes where
the interrupt wont trigger if the time requested is in the past at
the time of programming the ALM0_EN bit. However, we will not have
unexpected interrupts while the time is programmed after the interrupt
are enabled.

Signed-off-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@linaro.org>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


# f4199f85 10-Dec-2014 Tomas Novotny <tomas@novotny.cz>

rtc: ds1307: add support for mcp7940x chips

MCP7940x is same RTC as MCP7941x. The difference is that MCP7941x chips
contain additional EEPROM on a different i2c address.

DS1307 driver already supports MCP7941x, so just add a new i2c device id
and rename functions and defines accordingly.

Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 33b04b7b 13-Oct-2014 Matti Vaittinen <matti.vaittinen@nsn.com>

rtc: ds1307: add trickle charger device tree binding

Some DS13XX devices have "trickle chargers". Introduce a device tree
binding for specifying the trickle charger configuration for ds1339.

Only ds1339 dt binding is supported because this is the only chip I have.
I _assume_ the code would have worked on other allready supported chips.
However I cannot check the resistor values for the other chips or test
them. For other chips the driver code works as earlier Eg. it does not
check the dt bindings at all

Signed-off-by: Matti Vaittinen <matti.vaittinen@nsn.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Pavel Machek <pavel@denx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 1d1945d2 03-Apr-2014 Simon Guinot <simon.guinot@sequanux.org>

drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips

Add alarm support for the Microchip RTC devices MCP794xx. Note that two
programmable alarms are provided by the chip but only one is used by the
driver.

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@free-electrons.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 5ea73514 03-Apr-2014 Simon Guinot <simon.guinot@sequanux.org>

drivers/rtc/rtc-ds1307.c: fix sysfs wakealarm attribute creation

In order to allow the creation of the sysfs attribute wakealarm, this
patch moves the device_set_wakeup_capable() call above the RTC device
registration.

Signed-off-by: Simon Guinot <simon.guinot@sequanux.org>
Cc: Jason Cooper <jason@lakedaemon.net>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@free-electrons.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 4071ea25 03-Apr-2014 Alessandro Zummo <a.zummo@towertech.it>

rtc: fix potential race condition

RTC drivers must not return an error after device registration.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Reported-by: Ales Novak <alnovak@suse.cz>
Cc: Alexander Shiyan <shc_work@mail.ru>
Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# c8b18da7 12-Nov-2013 Peter Senna Tschudin <peter.senna@gmail.com>

drivers/rtc/rtc-ds1307.c: change variable type to bool

The variable want_irq is only assigned the values true and false.
Change its type to bool.

The simplified semantic patch that find this problem is as
follows (http://coccinelle.lip6.fr/):

@exists@
type T;
identifier b;
@@
- T
+ bool
b = ...;
... when any
b = \(true\|false\)

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 01ce893d 12-Nov-2013 Jingoo Han <jg1.han@samsung.com>

drivers/rtc/rtc-ds1307.c: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly. This is a cosmetic change to make
the code simpler and enhance the readability.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 50ccf045 12-Nov-2013 Sachin Kamat <sachin.kamat@linaro.org>

drivers/rtc/rtc-ds1307.c: release irq on error

'client->irq' was not released on error. Fix it.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# edca66d2 03-Jul-2013 Jingoo Han <jg1.han@samsung.com>

rtc: rtc-ds1307: use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# b9c35707 29-Apr-2013 Steffen Trumtrar <s.trumtrar@pengutronix.de>

drivers/rtc/rtc-ds1307.c: change sysfs function pointer assignment

The current usage of commas instead of semicolons is not wrong, but
affects the readability of the code.

Also, the code would break, if someone puts something between those two
assignments.

Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Cc: Austin Boyle <Austin.Boyle@aviatnet.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 6df80e21 29-Apr-2013 Jingoo Han <jg1.han@samsung.com>

rtc: rtc-ds1307: use dev_dbg() instead of pr_debug()

dev_dbg() is preferred to pr_debug().

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# bc48b902 29-Apr-2013 Bertrand Achard <ba@cykian.net>

drivers/rtc/rtc-ds1307.c: long block operations bugfix

The rtc-ds1307 driver does not properly handle block operations bigger
than 32 bytes in either of the two modes supported (SMbus native, or
emulated if not supported by the SMbus platform driver).

It also does not properly handle userland-supplied input (block
operation length) through sysfs and may suffer a type of buffer overrun.

The driver has been modified with proper input validation, buffer sizes,
and now splits block transfers bigger than 32 bytes into separate
transfers.

Explanation : Buffer size allocated is I2C_SMBUS_BLOCK_MAX which equals
to 32 as per the SMbus spec. Reads and write may be up to 56 bytes (to
the NVRAM). This patch allocated a 255 byte buffer, the maximum
allowable (address is an u8). It's not only a buffer problem, SMbus
only supports up to 32 bytes transfer at once, so it's needed to split
bigger transfers.

Patch successfully tested on 3.2.27; cleanly applies on 3.7-rc4.

[akpm@linux-foundation.org: rework code to avoid 80-column overflows]
Signed-off-by: Bertrand Achard <ba@cykian.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 01a4ca16 21-Feb-2013 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

drivers/rtc: dump small buffers via %*ph

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 5a167f45 21-Dec-2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Drivers: rtc: remove __dev* attributes.

CONFIG_HOTPLUG is going away as an option. As a result, the __dev*
markings need to be removed.

This change removes the use of __devinit, __devexit_p, __devinitdata,
__devinitconst, and __devexit from these drivers.

Based on patches originally written by Bill Pemberton, but redone by me
in order to handle some of the coding style issues better, by hand.

Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Mike Frysinger <vapier.adi@gmail.com>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# eb86c306 29-May-2012 Wolfram Sang <wsa@kernel.org>

rtc: ds1307: add trickle charger support

Some DS13XX devices have "trickle chargers". Its configuration register
is at different locations, the setup is the same, though. Since the
configuration is board specific, introduce a platform_data to this driver.
Tested with a DS1339 on a custom board.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# f8ae9701 29-May-2012 Wolfram Sang <wsa@kernel.org>

rtc: ds1307: remove superfluous initialization

ds1307 was kzalloced, so no need to zero members of the struct.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 3f5ec5e0 25-Apr-2012 Anatolij Gustschin <agust@denx.de>

drivers/rtc/rtc-ds1307.c: fix BUG shown with lock debugging enabled

Add struct bin_attribute initialization to fix the following bug:

rtc-ds1307 3-0068: rtc core: registered ds1307 as rtc0
BUG: key cfb14fcc not in .data!
------------[ cut here ]------------
WARNING: at kernel/lockdep.c:2986 sysfs_add_file_mode+0x84/0xdc()
Modules linked in:
[<c0018d94>] (unwind_backtrace+0x0/0xf8) from [<c0031f7c>] (warn_slowpath_common+0x4c/0x64)
[<c0031f7c>] (warn_slowpath_common+0x4c/0x64) from [<c0031fb0>] (warn_slowpath_null+0x1c/0x24)
[<c0031fb0>] (warn_slowpath_null+0x1c/0x24) from [<c012f7ac>] (sysfs_add_file_mode+0x84/0xdc)
[<c012f7ac>] (sysfs_add_file_mode+0x84/0xdc) from [<c04b11e4>] (ds1307_probe+0x5e4/0x6ac)
[<c04b11e4>] (ds1307_probe+0x5e4/0x6ac) from [<c036e600>] (i2c_device_probe+0xdc/0x108)
[<c036e600>] (i2c_device_probe+0xdc/0x108) from [<c02cdf84>] (driver_probe_device+0x90/0x210)
[<c02cdf84>] (driver_probe_device+0x90/0x210) from [<c02ce198>] (__driver_attach+0x94/0x98)
[<c02ce198>] (__driver_attach+0x94/0x98) from [<c02cc824>] (bus_for_each_dev+0x50/0x7c)
[<c02cc824>] (bus_for_each_dev+0x50/0x7c) from [<c02cd780>] (bus_add_driver+0x184/0x244)
[<c02cd780>] (bus_add_driver+0x184/0x244) from [<c02ce43c>] (driver_register+0x78/0x12c)
[<c02ce43c>] (driver_register+0x78/0x12c) from [<c03701ac>] (i2c_register_driver+0x2c/0xb4)
[<c03701ac>] (i2c_register_driver+0x2c/0xb4) from [<c0008798>] (do_one_initcall+0x34/0x178)
[<c0008798>] (do_one_initcall+0x34/0x178) from [<c0691860>] (kernel_init+0xdc/0x194)
[<c0691860>] (kernel_init+0xdc/0x194) from [<c0013cf0>] (kernel_thread_exit+0x0/0x8)

Since commit 6992f5334995af4 ("sysfs: Use one lockdep class per sysfs
attribute") this initialization is required.

Reported-by: Stefano Babic <sbabic@denx.de>
Tested-by: Stefano Babic <sbabic@denx.de>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 9eab0a78 23-Mar-2012 Austin Boyle <Austin.Boyle@aviatnet.com>

rtc: ds1307: generalise ram size and offset

Generalise NVRAM to support RAM with other size and offset, such as the
64 bytes of SRAM on the mcp7941x.

[rdunlap@xenotime.net: fix printk format warning]
Signed-off-by: Austin Boyle <Austin.Boyle@aviatnet.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
Cc: David Anders <danders.dev@gmail.com>
Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 40ce972d 23-Mar-2012 David Anders <x0132446@ti.com>

rtc: ds1307: comment and format cleanup

Do some cleanup of the comment sections as well as correct some
formatting issues reported by checkpatch.pl.

Signed-off-by: David Anders <x0132446@ti.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Austin Boyle <Austin.Boyle@aviatnet.com>
Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# b24a7267 23-Mar-2012 Wolfram Sang <wsa@kernel.org>

rtc: ds1307: simplify irq setup code

No need to have two seperate if-blocks for setting up the irq.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Tested-by: David Anders <danders.dev@gmail.com>
Cc: Austin Boyle <Austin.Boyle@aviatnet.com>
Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 32d322bc 23-Mar-2012 Wolfram Sang <wsa@kernel.org>

rtc: ds1307: refactor chip_desc table

The chip_desc table is suboptimal. Currently it requires an entry for
every new chip type, even if it is empty. This has already been
forgotten for the ds1388. Refactor the code, so new entries are only
needed, when they chip type really needs a (non-empty) description.
Also make the table visually more appealing.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: Austin Boyle <Austin.Boyle@aviatnet.com>
Cc: David Anders <danders.dev@gmail.com>
Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 0abc9201 23-Mar-2012 Axel Lin <axel.lin@gmail.com>

rtc: convert rtc i2c drivers to module_i2c_driver

Factor out some boilerplate code for i2c driver registration into
module_i2c_driver.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: Piotr Ziecik <kosmo@semihalf.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
Cc: Mike Rapoport <mike@compulab.co.il>
Cc: Sergey Lapin <slapin@ossfans.org>
Cc: Roman Fietze <roman.fietze@telemotive.de>
Cc: Herbert Valerio Riedel <hvr@gnu.org>
Cc: Alexander Bigga <ab@mycable.de>
Cc: Dale Farnsworth <dale@farnsworth.org>
Cc: Gregory Hermant <gregory.hermant@calao-systems.com>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Martyn Welch <martyn.welch@ge.com>
Cc: Byron Bradley <byron.bbradley@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 43fcb815 02-Nov-2011 David Anders <danders.dev@gmail.com>

rtc: add initial support for mcp7941x parts

Add initial support for the microchip mcp7941x series of real time clocks.

The mcp7941x series is generally compatible with the ds1307 and ds1337 rtc
devices from dallas semiconductor. minor differences include a backup
battery enable bit, and the polarity of the oscillator enable bit.

Signed-off-by: David Anders <danders.dev@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 31c1771c 27-Jun-2011 Priyanka Jain <Priyanka.Jain@freescale.com>

drivers/rtc/rtc-ds1307.c: add support for RTC device pt7c4338

PT7C4338 chip is being manufactured by Pericom Technology Inc. It is a
serial real-time clock which provides:

1) Low-power clock/calendar.
2) Programmable square-wave output.

It has 56 bytes of nonvolatile RAM. Its register set is same as that of
rtc device: DS1307.

Signed-off-by: Priyanka Jain <Priyanka.Jain@freescale.com>
Acked-by: Timur Tabi <timur@freescale.com>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 16380c15 02-Feb-2011 John Stultz <john.stultz@linaro.org>

RTC: Convert rtc drivers to use the alarm_irq_enable method

Some rtc drivers use the ioctl method instead of the alarm_irq_enable
method for enabling alarm interupts. With the new virtualized RTC
rework, its important for drivers to use the alarm_irq_enable instead.

This patch converts the drivers that use the AIE ioctl method to
use the alarm_irq_enable method. Other ioctl cmds are left untouched.

I have not been able to test or even compile most of these drivers.
Any help to make sure this change is correct would be appreciated!

CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br>
Reported-by: Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br>
Tested-by: Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br>
Signed-off-by: John Stultz <john.stultz@linaro.org>


# 0cc43a18 10-Jan-2011 Jean Delvare <khali@linux-fr.org>

i2c: Constify i2c_client where possible

Helper functions for I2C and SMBus transactions don't modify the
i2c_client that is passed to them, so it can be marked const.

Signed-off-by: Jean Delvare <khali@linux-fr.org>


# 96fc3a45 29-Jun-2010 Joakim Tjernlund <Joakim.Tjernlund@transmode.se>

rtc: fix ds1388 time corruption

The ds1307 driver misreads the ds1388 registers when checking for 12 or 24
hour mode. Instead of checking the hour register it reads the minute
register. Therefore the driver thinks minutes >= 40 has the 12HR bit set
and resets the minute register by zeroing the high bits. This results in
minutes are reset to 0-9, jumping back in time 40 or 50 minutes. The time
jump is also written back to the RTC.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Paul Gortmaker <p_gortmaker@yahoo.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 2c3c8bea 12-May-2010 Chris Wright <chrisw@sous-sol.org>

sysfs: add struct file* to bin_attr callbacks

This allows bin_attr->read,write,mmap callbacks to check file specific data
(such as inode owner) as part of any privilege validation.

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>


# 26b3c01f 17-Dec-2009 Anton Vorontsov <avorontsov@ru.mvista.com>

rtc: set wakeup capability for I2C and SPI RTC drivers

RTC core won't allow wakeup alarms to be set if RTC devices' parent (i.e.
i2c_client or spi_device) isn't wakeup capable.

For I2C devices there is I2C_CLIENT_WAKE flag exists that we can pass via
board info, and if set, I2C core will initialize wakeup capability. For
SPI devices there is no such flag at all.

I believe that it's not platform code responsibility to allow or disallow
wakeups, instead, drivers themselves should set the capability if a device
can trigger wakeups.

That's what drivers/base/power/sysfs.c says:

* It is the responsibility of device drivers to enable (or disable)
* wakeup signaling as part of changing device power states, respecting
* the policy choices provided through the driver model.

I2C and SPI RTC devices send wakeup events via interrupt lines, so we
should set the wakeup capability if IRQ is routed.

Ideally we should also check irq for wakeup capability before setting
device's capability, i.e.

if (can_irq_wake(irq))
device_set_wakeup_capable(&client->dev, 1);

But there is no can_irq_wake() call exist, and it is not that trivial to
implement it for all interrupts controllers and complex/cascaded setups.

drivers/base/power/sysfs.c also covers these cases:

* Devices may not be able to generate wakeup events from all power
* states. Also, the events may be ignored in some configurations;
* for example, they might need help from other devices that aren't
* active

So there is no guarantee that wakeup will actually work, and so I think
there is no point in being pedantic wrt checking IRQ wakeup capability.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 43d15bcd 15-Dec-2009 Dmitry Baryshkov <dbaryshkov@gmail.com>

rtc: ds1307 make it possible to share an irq

It's possible to have RTC irq shared with other device (e.g.
mpc8349e-mitx board shares ds1339 irq with phy one). Handle this in
driver.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 72445af8 22-Sep-2009 Julia Lawall <julia@diku.dk>

drivers/rtc: correct error-handling code

This code is not executed before ds1307->rtc has been successfully
initialized to the result of calling rtc_device_register. Thus the test
that ds1307->rtc is not NULL is always true.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@match exists@
expression x, E;
statement S1, S2;
@@

x = rtc_device_register(...)
... when != x = E
(
* if (x == NULL || ...) S1 else S2
|
* if (x == NULL && ...) S1 else S2
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Wolfram Sang <w.sang@pengutronix.de>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# e6229bec 18-Jun-2009 Atsushi Nemoto <anemo@mba.ocn.ne.jp>

rtc: make rtc_update_irq callable with irqs enabled

The rtc_update_irq() might be called with irqs enabled, if a interrupt
handler was registered without IRQF_DISABLED. Use
spin_lock_irqsave/spin_unlock_irqrestore instead of spin_lock/spin_unlock.

Also update kerneldoc and drivers which do extra work to follow the
current interface spec, as suggestted by David Brownell.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 97f902b7 17-Jun-2009 Wolfram Sang <wsa@kernel.org>

rtc: rtc-ds1307 add ds3231

Add ds3231 variant. For that, the BBSQI bit position was changed from a
simple define into a lookup-array as it differs. This also removes
writing to an unused bit in case of the ds1337.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 33df2ee1 17-Jun-2009 Joakim Tjernlund <Joakim.Tjernlund@transmode.se>

rtc: rtc-ds1307 add ds1388

Extend the ds1307 driver to support ds1388 too.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# a2166858 31-Mar-2009 Matthias Fuchs <matthias.fuchs@esd-electronics.com>

rtc: add EPSON RX8025 support to DS1307 RTC driver

Add support for the EPSON RX8025 RTC. The date/time registers of this
chip are compatible with the DS1307.

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 30e7b039 31-Mar-2009 Ed Swierk <eswierk@aristanetworks.com>

rtc-ds1307: true SMBus compatibility

Allow the rtc-ds1307 driver to work with SMBus controllers like nforce2
that do not support i2c block transfers.

Signed-off-by: Ed Swierk <eswierk@aristanetworks.com>
Acked-by: Jean Delvare <khali@linux-fr.org>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: BARRE Sebastien <sbarre@sdelcc.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 74d88eb2 07-Jan-2009 Jüri Reitel <juri.reitel@liewenthal.ee>

rtc-ds1307: remove legacy probe() checks

Remove RTC register value checks from the rtc-ds1307 probe() function.
They were left over from the legacy style I2C driver, which had to defend
against finding a non-RTC chip when the driver was probed.

Also fix a minor glitch in the alarm support: DS1307 chips don't have
alarms, so name those methods after one of the chips which actually *do*
have alarms (DS1337).

Signed-off-by: Jüri Reitel <juri.reitel@liewenthal.ee>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Sebastien Barre <sbarre@sdelcc.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Acked-by: Jean Delvare <khali@linux-fr.org>
Cc: Rodolfo Giometti <giometti@enneenne.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# fed40b73 07-Jan-2009 BARRE Sebastien <sbarre@sdelcc.com>

rtc-ds1307: SMBus compatibility

Change i2c access functions to SMBus access functions in order to use the
ds1307 with SMBus adapter.

Signed-off-by: Sebastien Barre <sbarre@sdelcc.com>
Acked-by: David Brownell <david-b@pacbell.net>
Tested-by: David Brownell <david-b@pacbell.net>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Acked-by: Jean Delvare <khali@linux-fr.org>
Cc: Rodolfo Giometti <giometti@enneenne.com>
Tested-by: Sebastien Barre <sbarre@sdelcc.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 01e8ef11 18-Oct-2008 Parag Warudkar <parag.lkml@gmail.com>

x86: sysfs: kill owner field from attribute

Tejun's commit 7b595756ec1f49e0049a9e01a1298d53a7faaa15 made sysfs
attribute->owner unnecessary. But the field was left in the structure to
ease the merge. It's been over a year since that change and it is now
time to start killing attribute->owner along with its users - one arch at
a time!

This patch is attempt #1 to get rid of attribute->owner only for
CONFIG_X86_64 or CONFIG_X86_32 . We will deal with other arches later on
as and when possible - avr32 will be the next since that is something I
can test. Compile (make allyesconfig / make allmodconfig / custom config)
and boot tested.

akpm: the idea is that we put the declaration of sttribute.owner inside
`#ifndef CONFIG_X86'. But that proved to be too ambitious for now because
new usages kept on turning up in subsystem trees.

[akpm: remove the ifdef for now]
Signed-off-by: Parag Warudkar <parag.lkml@gmail.com>
Cc: Greg KH <greg@kroah.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Len Brown <lenb@kernel.org>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: David Brownell <david-b@pacbell.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# fe20ba70 18-Oct-2008 Adrian Bunk <bunk@kernel.org>

drivers/rtc/: use bcd2bin/bin2bcd

Change drivers/rtc/ to use the new bcd2bin/bin2bcd functions instead of
the obsolete BCD_TO_BIN/BIN_TO_BCD/BCD2BIN/BIN2BCD macros.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# cb49a5e9 15-Oct-2008 Rodolfo Giometti <giometti@linux.it>

rtc-ds1307: alarm support for ds1337/ds1339

Update the ds1307 driver with alarm support for ds1337/ds1339. This uses
the first alarm (there are two), and matches on seconds, minutes, hours,
and day-of-month. Tested on ds1339.

[dbrownell@users.sourceforge.net: add comments; fixup style, valid irq
checks, debug dumps; lock; more careful IRQ shutdown; switch BCD2BIN to
bcd2bin (and vice versa); ENOTTY not EINVAL.]
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Rodolfo Giometti <giometti@linux.it>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 3760f736 29-Apr-2008 Jean Delvare <khali@linux-fr.org>

i2c: Convert most new-style drivers to use module aliasing

Based on earlier work by Jon Smirl and Jochen Friedrich.

Update most new-style i2c drivers to use standard module aliasing
instead of the old driver_name/type driver matching scheme. I've
left the video drivers apart (except for SoC camera drivers) as
they're a bit more diffcult to deal with, they'll have their own
patch later.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jon Smirl <jonsmirl@gmail.com>
Cc: Jochen Friedrich <jochen@scram.de>


# d2653e92 29-Apr-2008 Jean Delvare <khali@linux-fr.org>

i2c: Add support for device alias names

Based on earlier work by Jon Smirl and Jochen Friedrich.

This patch allows new-style i2c chip drivers to have alias names using
the official kernel aliasing system and MODULE_DEVICE_TABLE(). At this
point, the old i2c driver binding scheme (driver_name/type) is still
supported.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jochen Friedrich <jochen@scram.de>
Cc: Jon Smirl <jonsmirl@gmail.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>


# fcd8db00 06-Feb-2008 frederic Rodo <f.rodo@til-technologies.fr>

rtc ds1307: ds_1340 change init

For DS140, clear the oscillator fault flag as needed.

Signed-off-by: Frederic RODO <f.rodo@til-technologies.fr>
[ And remove some "sparse" warnings. ]
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 682d73f6 14-Nov-2007 David Brownell <david-b@pacbell.net>

rtc-ds1307 exports NVRAM

Export the NVRAM on DS1307 and DS1338 chips, like several of the
other drivers do for such combination RTC-and-NVRAM chips.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# bd16f9eb 26-Jul-2007 David Brownell <david-b@pacbell.net>

rtc-ds1307: typo fix found by coverity

Fix a typo turned up by a Coverity check: referring to the wrong register,
which could cause problems with DS1338 RTCs whose oscillators halted.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# c065f35c 17-Jul-2007 David Brownell <david-b@pacbell.net>

rtc-ds1307 becomes new-style i2c driver

Convert the rtc-ds1307 driver into a "new style" driver.

Also improve probe() checks: be more correct about switching out of
AM/PM mode, and issue a (debug) diagnostic when failing due to bogus
register values.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Andrew Victor <andrew@sanpeople.com>
Cc: Bill Gatliff <bgat@billgatliff.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@gate.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# be5f59f4 17-Jul-2007 Rodolfo Giometti <giometti@enneenne.com>

rtc-ds1307: oscillator restart for ds13{37,38,39,40}

When we find a ds1337 or ds1339 with the oscillator powered off, turn it
on. If the oscillator fault flag was set, clear it and warn that the clock
needs to be set.

David Brownell: Bugfixes; provide corresponding update for ds1338, and the
core of the fix for ds1340. Use a common warning message ("SET TIME!")
whenever the clock needs to be set after oscillator fault (or oscillator
enable, if fault is not a separate status).

Signed-off-by: Rodolfo Giometti <giometti@linux.it>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 045e0e85 17-Jul-2007 David Brownell <david-b@pacbell.net>

rtc-ds1307 cleanups

This updates the rtc-ds1307 driver so that converting it to a "new style"
driver (driver model, not legacy i2c model) will involve fewer changes.

- Use pointer to i2c_client almost everywhere, so that it's easy
to let the i2c core create that object;

- Avoid using i2c_client.adapter, since that field is redundant and
thus may go away (same object as i2c_client.dev.parent).

- Extend type enum to include various RTCs this is expected to
work with, and include register support for them.

It also cleans up the support for multiple chip types, and fixes a
glitch that could appear with an un-initialized RTC.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 11966adc 04-Oct-2006 Jeff Garzik <jeff@garzik.org>

[PATCH] RTC: build fixes

Fix obvious build breakage revealed by 'make allyesconfig'
in current -git.

Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# ff8371ac 01-Oct-2006 David Brownell <david-b@pacbell.net>

[PATCH] constify rtc_class_ops: update drivers

Update RTC framework so that drivers can constify their method tables, moving
them from ".data" to ".rodata". Then update the drivers.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 1abb0dc9 25-Jun-2006 David Brownell <david-b@pacbell.net>

[PATCH] "RTC-framework" driver for DS1307 and similar RTC chips

This is an "RTC-framework" driver for DS1307 and similar RTC chips,

It should be a full replacement for the existing ds1337.c driver (using the
older RTC glue), giving a net increase in the number of RTC chips that work
out-of-the-box. There's a whole cluster of RTCs that are very similar, but
the 1337 driver was a bit too picky to work with most of them.

Still no support for RTC alarm IRQs (on chips that support them).

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: James Chapman <jchapman@katalix.com>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>