Skip to content

Commit

Permalink
Merge tag 'rtc-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "Core:
   - Fix rtctest error path

  New drivers:
   - Microcrystal RV8803

  Subsystem wide cleanups:
   - remove misuse of IRQF_NO_SUSPEND flag

  Drivers:
   - at91rm9200: clear RTC alarm status flag prior to suspending
   - davinci: remove incorrect reference to probe function
   - ds1307: Fix alarm programming for mcp794xx
   - ds1390: trickle charger support, fix ds1390_get_reg
   - isl1208: Pass the IRQF_ONESHOT flag
   - opal: fix type of token
   - pcf2127: fix RTC_READ_VL, remove useless driver version
   - pcf85063: return an error when date is invalid
   - pcf8563: add CLKOUT to common clock framework
   - rx8025: remove unnecessary braces
   - s3c: Set year, month, day value for setting alarm
   - stmp3xxx: unify register access macros
   - License fixes: pcf2127, da9063
   - wakeup-source support for isl12057 and opal"

* tag 'rtc-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (23 commits)
  rtc: Add a driver for Micro Crystal RV8803
  rtc: s3c: Set year, month, day value for setting alarm
  rtc: ds1307: Fix alarm programming for mcp794xx
  rtc: isl12057: enable support for the standard "wakeup-source" property
  rtc: opal: enable support for the stardard "wakeup-source" property
  rtc: isl1208: Pass the IRQF_ONESHOT flag
  rtc: pcf8563: add CLKOUT to common clock framework
  rtc: davinci: remove incorrect reference to probe function
  rtc: at91rm9200: clear RTC alarm status flag prior to suspending
  rtc: pcf2127: remove useless driver version
  rtc: pcf2127: fix reading uninitialized value on RTC_READ_VL ioctl
  rtc: stmp3xxx: unify register access macros
  rtc: da9063: GPL copyright inconsistency fix
  rtc: pcf85063: return an error when date is invalid
  rtc: rx8025: remove unnecessary braces
  rtc: ds1343: remove misuse of IRQF_NO_SUSPEND flag
  rtc: ab8500: remove misuse of IRQF_NO_SUSPEND flag
  rtc: pl031: remove misuse of IRQF_NO_SUSPEND flag
  rtc: opal: fix type of token
  rtc: ds1390: Add trickle charger device tree binding
  ...
  • Loading branch information
Linus Torvalds committed Nov 10, 2015
2 parents 3b13866 + 1e3929e commit 7d88471
Show file tree
Hide file tree
Showing 23 changed files with 908 additions and 83 deletions.
18 changes: 18 additions & 0 deletions Documentation/devicetree/bindings/rtc/dallas,ds1390.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* Dallas DS1390 SPI Serial Real-Time Clock

Required properties:
- compatible: Should contain "dallas,ds1390".
- reg: SPI address for chip

Optional properties:
- trickle-resistor-ohms : Selected resistor for trickle charger
Values usable for ds1390 are 250, 2000, 4000
Should be given if trickle charger should be enabled
- trickle-diode-disable : Do not use internal trickle charger diode
Should be given if internal trickle charger diode should be disabled
Example:
ds1390: rtc@68 {
compatible = "dallas,ds1390";
trickle-resistor-ohms = <250>;
reg = <0>;
};
25 changes: 25 additions & 0 deletions Documentation/devicetree/bindings/rtc/pcf8563.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
* Philips PCF8563/Epson RTC8564 Real Time Clock

Philips PCF8563/Epson RTC8564 Real Time Clock

Required properties:
see: Documentation/devicetree/bindings/i2c/trivial-devices.txt

Optional property:
- #clock-cells: Should be 0.
- clock-output-names:
overwrite the default clock name "pcf8563-clkout"

Example:

pcf8563: pcf8563@51 {
compatible = "nxp,pcf8563";
reg = <0x51>;
#clock-cells = <0>;
};

device {
...
clocks = <&pcf8563>;
...
};
13 changes: 11 additions & 2 deletions drivers/rtc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,15 @@ config RTC_DRV_RV3029C2
This driver can also be built as a module. If so, the module
will be called rtc-rv3029c2.

config RTC_DRV_RV8803
tristate "Micro Crystal RV8803"
help
If you say yes here you get support for the Micro Crystal
RV8803 RTC chips.

This driver can also be built as a module. If so, the module
will be called rtc-rv8803.

config RTC_DRV_S5M
tristate "Samsung S2M/S5M series"
depends on MFD_SEC_CORE
Expand Down Expand Up @@ -666,8 +675,8 @@ config RTC_DRV_DS1390
If you say yes here you get support for the
Dallas/Maxim DS1390/93/94 chips.

This driver only supports the RTC feature, and not other chip
features such as alarms and trickle charging.
This driver supports the RTC feature and trickle charging but not
other chip features such as alarms.

This driver can also be built as a module. If so, the module
will be called rtc-ds1390.
Expand Down
1 change: 1 addition & 0 deletions drivers/rtc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
obj-$(CONFIG_RTC_DRV_RV3029C2) += rtc-rv3029c2.o
obj-$(CONFIG_RTC_DRV_RV8803) += rtc-rv8803.o
obj-$(CONFIG_RTC_DRV_RX4581) += rtc-rx4581.o
obj-$(CONFIG_RTC_DRV_RX8025) += rtc-rx8025.o
obj-$(CONFIG_RTC_DRV_RX8581) += rtc-rx8581.o
Expand Down
6 changes: 5 additions & 1 deletion drivers/rtc/rtc-ab8500.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/mfd/abx500/ab8500.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/pm_wakeirq.h>

#define AB8500_RTC_SOFF_STAT_REG 0x00
#define AB8500_RTC_CC_CONF_REG 0x01
Expand Down Expand Up @@ -493,11 +494,12 @@ static int ab8500_rtc_probe(struct platform_device *pdev)
}

err = devm_request_threaded_irq(&pdev->dev, irq, NULL,
rtc_alarm_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT,
rtc_alarm_handler, IRQF_ONESHOT,
"ab8500-rtc", rtc);
if (err < 0)
return err;

dev_pm_set_wake_irq(&pdev->dev, irq);
platform_set_drvdata(pdev, rtc);

err = ab8500_sysfs_rtc_register(&pdev->dev);
Expand All @@ -513,6 +515,8 @@ static int ab8500_rtc_probe(struct platform_device *pdev)

static int ab8500_rtc_remove(struct platform_device *pdev)
{
dev_pm_clear_wake_irq(&pdev->dev);
device_init_wakeup(&pdev->dev, false);
ab8500_sysfs_rtc_unregister(&pdev->dev);

return 0;
Expand Down
2 changes: 2 additions & 0 deletions drivers/rtc/rtc-at91rm9200.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ static int at91_rtc_suspend(struct device *dev)
/* this IRQ is shared with DBGU and other hardware which isn't
* necessarily doing PM like we are...
*/
at91_rtc_write(AT91_RTC_SCCR, AT91_RTC_ALARM);

at91_rtc_imr = at91_rtc_read_imr()
& (AT91_RTC_ALARM|AT91_RTC_SECEV);
if (at91_rtc_imr) {
Expand Down
18 changes: 9 additions & 9 deletions drivers/rtc/rtc-da9063.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* rtc-da9063.c - Real time clock device driver for DA9063
* Copyright (C) 2013-14 Dialog Semiconductor Ltd.
* Copyright (C) 2013-2015 Dialog Semiconductor Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

#include <linux/delay.h>
Expand Down Expand Up @@ -516,5 +516,5 @@ module_platform_driver(da9063_rtc_driver);

MODULE_AUTHOR("S Twiss <stwiss.opensource@diasemi.com>");
MODULE_DESCRIPTION("Real time clock device driver for Dialog DA9063");
MODULE_LICENSE("GPL v2");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:" DA9063_DRVNAME_RTC);
1 change: 0 additions & 1 deletion drivers/rtc/rtc-davinci.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ static int __exit davinci_rtc_remove(struct platform_device *pdev)
}

static struct platform_driver davinci_rtc_driver = {
.probe = davinci_rtc_probe,
.remove = __exit_p(davinci_rtc_remove),
.driver = {
.name = "rtc_davinci",
Expand Down
4 changes: 2 additions & 2 deletions drivers/rtc/rtc-ds1307.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,9 @@ static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t)
regs[3] = bin2bcd(t->time.tm_sec);
regs[4] = bin2bcd(t->time.tm_min);
regs[5] = bin2bcd(t->time.tm_hour);
regs[6] = bin2bcd(t->time.tm_wday) + 1;
regs[6] = bin2bcd(t->time.tm_wday + 1);
regs[7] = bin2bcd(t->time.tm_mday);
regs[8] = bin2bcd(t->time.tm_mon) + 1;
regs[8] = bin2bcd(t->time.tm_mon + 1);

/* Clear the alarm 0 interrupt flag. */
regs[6] &= ~MCP794XX_BIT_ALMX_IF;
Expand Down
9 changes: 6 additions & 3 deletions drivers/rtc/rtc-ds1343.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/rtc.h>
#include <linux/bcd.h>
#include <linux/pm.h>
#include <linux/pm_wakeirq.h>
#include <linux/slab.h>

#define DS1343_DRV_VERSION "01.00"
Expand Down Expand Up @@ -663,15 +664,15 @@ static int ds1343_probe(struct spi_device *spi)

if (priv->irq >= 0) {
res = devm_request_threaded_irq(&spi->dev, spi->irq, NULL,
ds1343_thread,
IRQF_NO_SUSPEND | IRQF_ONESHOT,
ds1343_thread, IRQF_ONESHOT,
"ds1343", priv);
if (res) {
priv->irq = -1;
dev_err(&spi->dev,
"unable to request irq for rtc ds1343\n");
} else {
device_set_wakeup_capable(&spi->dev, 1);
device_init_wakeup(&spi->dev, true);
dev_pm_set_wake_irq(&spi->dev, spi->irq);
}
}

Expand All @@ -692,6 +693,8 @@ static int ds1343_remove(struct spi_device *spi)
priv->irqen &= ~RTC_AF;
mutex_unlock(&priv->mutex);

dev_pm_clear_wake_irq(&spi->dev);
device_init_wakeup(&spi->dev, false);
devm_free_irq(&spi->dev, spi->irq, priv);
}

Expand Down
65 changes: 64 additions & 1 deletion drivers/rtc/rtc-ds1390.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/spi/spi.h>
#include <linux/bcd.h>
#include <linux/slab.h>
#include <linux/of.h>

#define DS1390_REG_100THS 0x00
#define DS1390_REG_SECONDS 0x01
Expand All @@ -40,11 +41,31 @@
#define DS1390_REG_STATUS 0x0E
#define DS1390_REG_TRICKLE 0x0F

#define DS1390_TRICKLE_CHARGER_ENABLE 0xA0
#define DS1390_TRICKLE_CHARGER_250_OHM 0x01
#define DS1390_TRICKLE_CHARGER_2K_OHM 0x02
#define DS1390_TRICKLE_CHARGER_4K_OHM 0x03
#define DS1390_TRICKLE_CHARGER_NO_DIODE 0x04
#define DS1390_TRICKLE_CHARGER_DIODE 0x08

struct ds1390 {
struct rtc_device *rtc;
u8 txrx_buf[9]; /* cmd + 8 registers */
};

static void ds1390_set_reg(struct device *dev, unsigned char address,
unsigned char data)
{
struct spi_device *spi = to_spi_device(dev);
unsigned char buf[2];

/* MSB must be '1' to write */
buf[0] = address | 0x80;
buf[1] = data;

spi_write(spi, buf, 2);
}

static int ds1390_get_reg(struct device *dev, unsigned char address,
unsigned char *data)
{
Expand All @@ -62,11 +83,50 @@ static int ds1390_get_reg(struct device *dev, unsigned char address,
if (status != 0)
return status;

*data = chip->txrx_buf[1];
*data = chip->txrx_buf[0];

return 0;
}

static void ds1390_trickle_of_init(struct spi_device *spi)
{
u32 ohms = 0;
u8 value;

if (of_property_read_u32(spi->dev.of_node, "trickle-resistor-ohms",
&ohms))
goto out;

/* Enable charger */
value = DS1390_TRICKLE_CHARGER_ENABLE;
if (of_property_read_bool(spi->dev.of_node, "trickle-diode-disable"))
value |= DS1390_TRICKLE_CHARGER_NO_DIODE;
else
value |= DS1390_TRICKLE_CHARGER_DIODE;

/* Resistor select */
switch (ohms) {
case 250:
value |= DS1390_TRICKLE_CHARGER_250_OHM;
break;
case 2000:
value |= DS1390_TRICKLE_CHARGER_2K_OHM;
break;
case 4000:
value |= DS1390_TRICKLE_CHARGER_4K_OHM;
break;
default:
dev_warn(&spi->dev,
"Unsupported ohm value %02ux in dt\n", ohms);
return;
}

ds1390_set_reg(&spi->dev, DS1390_REG_TRICKLE, value);

out:
return;
}

static int ds1390_read_time(struct device *dev, struct rtc_time *dt)
{
struct spi_device *spi = to_spi_device(dev);
Expand Down Expand Up @@ -143,6 +203,9 @@ static int ds1390_probe(struct spi_device *spi)
return res;
}

if (spi->dev.of_node)
ds1390_trickle_of_init(spi);

chip->rtc = devm_rtc_device_register(&spi->dev, "ds1390",
&ds1390_rtc_ops, THIS_MODULE);
if (IS_ERR(chip->rtc)) {
Expand Down
10 changes: 5 additions & 5 deletions drivers/rtc/rtc-isl12057.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,8 @@ static int isl12057_check_rtc_status(struct device *dev, struct regmap *regmap)
* is for instance the case on ReadyNAS 102, 104 and 2120. On those
* devices with no IRQ driectly 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 "isil,irq2-can-wakeup-machine"
* boolean property. This will guarantee 'wakealarm' sysfs entry is
* available on the device.
* the device's .dts file using the "wakeup-source" boolean property.
* This will guarantee 'wakealarm' sysfs entry is available on the device.
*
* The function below returns 1, i.e. the capability of the chip to
* wakeup the device, based on IRQ availability or if the boolean
Expand All @@ -479,8 +478,9 @@ static bool isl12057_can_wakeup_machine(struct device *dev)
{
struct isl12057_rtc_data *data = dev_get_drvdata(dev);

return (data->irq || of_property_read_bool(dev->of_node,
"isil,irq2-can-wakeup-machine"));
return data->irq || of_property_read_bool(dev->of_node, "wakeup-source")
|| of_property_read_bool(dev->of_node, /* legacy */
"isil,irq2-can-wakeup-machine");
}
#else
static bool isl12057_can_wakeup_machine(struct device *dev)
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-isl1208.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (client->irq > 0) {
rc = devm_request_threaded_irq(&client->dev, client->irq, NULL,
isl1208_rtc_interrupt,
IRQF_SHARED,
IRQF_SHARED | IRQF_ONESHOT,
isl1208_driver.driver.name,
client);
if (!rc) {
Expand Down
9 changes: 5 additions & 4 deletions drivers/rtc/rtc-opal.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ static int opal_get_tpo_time(struct device *dev, struct rtc_wkalrm *alarm)
/* Set Timed Power-On */
static int opal_set_tpo_time(struct device *dev, struct rtc_wkalrm *alarm)
{
u64 h_m_s_ms = 0, token;
u64 h_m_s_ms = 0;
struct opal_msg msg;
u32 y_m_d = 0;
int rc;
int token, rc;

tm_to_opal(&alarm->time, &y_m_d, &h_m_s_ms);

Expand Down Expand Up @@ -199,8 +199,9 @@ static int opal_rtc_probe(struct platform_device *pdev)
{
struct rtc_device *rtc;

if (pdev->dev.of_node && of_get_property(pdev->dev.of_node, "has-tpo",
NULL)) {
if (pdev->dev.of_node &&
(of_property_read_bool(pdev->dev.of_node, "wakeup-source") ||
of_property_read_bool(pdev->dev.of_node, "has-tpo")/* legacy */)) {
device_set_wakeup_capable(&pdev->dev, true);
opal_rtc_ops.read_alarm = opal_get_tpo_time;
opal_rtc_ops.set_alarm = opal_set_tpo_time;
Expand Down
Loading

0 comments on commit 7d88471

Please sign in to comment.