RTC for 5.5
Subsystem: - fix warnings and errors with make W=1 - UIE are now disabled while setting the RTC time - UIE are now disallowed when the RTC time is not set. Drivers: - remove unecessary .remove callbacks - Set RTC range for cros-ec, ds1343, ds1347, m41t80, s35390a, vt8500 - Use devm_platform_ioremap_resource where applicable - rv3028: add clock out support -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEycoQi/giopmpPgB12wIijOdRNOUFAl3k7FMACgkQ2wIijOdR NOX63hAAqeoBWKVHgh5kltmtd7RCWD3cazleYvPPfCyoNUOz1YB6Gblp4R+5ImNT pFfbhk44baMDBSy5zlJV4yLkdsBYx5Yx7Su56zAqMYhpnVbvwGeNOsoWLaJThc3o b8NK9Za9CwwZNm3CDoPdJNeHNOce20Hj9JKCeOyS3Gl7IuMP+0xGXlPVpM0yX4EW 7iwuGhnQNWFM1GQQ8WWgEr4mQB+8xwjy2hKQ2FnKfVk6cqq2wxgrY+XGjV1h1jCM x/KlmAY9sbntwEZA3ZOqk0LQvMMaKqUEfMpd24joGvo7JGseN/e4aapRXoang3vp h/mkeW3MnrsGs+YPsSQqdOSrIJ/Qou25QnMXEzRPgkBCXw0lpHkqmF3GdF6CPEFG xnGZVLrCA1W8ysJNq9ZkavZCEaG9ay6Qd8sOh7Tfl2UkPDArOC1PiKvfzVmkcYZ+ TOwgB7/Yyp9Y1l9asBQnOEzg2AZ0Rq8KlFk5vAxiyQOBpivWEw8AuNMG+W8B16NE bsc6rteNYzfLJusxuEQTdG7/AsLNun+YQoASAYaoIxnnzcslUwMRLl/JoNRQOt7D sdaTHd10I99+282hWPnFSkb3Xm44+01tX2apGPQt5Duv8ojQYHTRoPhHYmIvCkLJ HM8HWNae6bNKyUhsxDG8iFHfbAhL6ojr/AEiXw58TZjfPe3i5iw= =gBQF -----END PGP SIGNATURE----- Merge tag 'rtc-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux Pull RTC updates from Alexandre Belloni: "A lot of unnecessary code removal in here that ends up decreasing the number of lines in the subsystem. The ds1343 and ds1347 drivers got cleaned up. The rest are the usual fixes and new features. Subsystem: - fix warnings and errors with make W=1 - UIE are now disabled while setting the RTC time - UIE are now disallowed when the RTC time is not set. Drivers: - remove unecessary .remove callbacks - Set RTC range for cros-ec, ds1343, ds1347, m41t80, s35390a, vt8500 - Use devm_platform_ioremap_resource where applicable - rv3028: add clock out support" * tag 'rtc-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (81 commits) rtc: Fix Kconfig indentation rtc: xgene: Remove unused struct device in struct xgene_rtc_dev rtc: sun6i: Remove struct device from sun6i_rtc_dev rtc: st-lpc: Remove struct resource from struct st_rtc rtc: pcf8523: Remove struct pcf8523 rtc: meson: remove redundant assignment to variable retries rtc: v3020: remove set but unused variable rtc: tegra: remove set but unused variable rtc: pm8xxx: update kerneldoc for struct pm8xxx_rtc rtc: m41t80: remove excess kerneldoc rtc: ds1685: fix build error with make W=1 rtc: ds1685: remove set but unused variables rtc: ds1374: remove unused variable rtc: sysfs: fix hctosys_show kerneldoc rtc: interface: fix kerneldoc comments rtc: msm6242: Remove unneeded msm6242_set()/msm6242_clear() functions rtc: msm6242: Fix reading of 10-hour digit rtc: tps65910: allow using RTC without alarm interrupt rtc: fsl-ftm-alarm: remove select FSL_RCPM and default y from Kconfig rtc: pcf8563: Constify clkout_rates ...
This commit is contained in:
commit
4672c2f202
|
@ -115,7 +115,7 @@ ip32_rtc_platform_data[] = {
|
||||||
.bcd_mode = true,
|
.bcd_mode = true,
|
||||||
.no_irq = false,
|
.no_irq = false,
|
||||||
.uie_unsupported = false,
|
.uie_unsupported = false,
|
||||||
.alloc_io_resources = true,
|
.access_type = ds1685_reg_direct,
|
||||||
.plat_prepare_poweroff = ip32_prepare_poweroff,
|
.plat_prepare_poweroff = ip32_prepare_poweroff,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -373,17 +373,6 @@ config RTC_DRV_MAX77686
|
||||||
This driver can also be built as a module. If so, the module
|
This driver can also be built as a module. If so, the module
|
||||||
will be called rtc-max77686.
|
will be called rtc-max77686.
|
||||||
|
|
||||||
config RTC_DRV_MESON_VRTC
|
|
||||||
tristate "Amlogic Meson Virtual RTC"
|
|
||||||
depends on ARCH_MESON || COMPILE_TEST
|
|
||||||
default m if ARCH_MESON
|
|
||||||
help
|
|
||||||
If you say yes here you will get support for the
|
|
||||||
Virtual RTC of Amlogic SoCs.
|
|
||||||
|
|
||||||
This driver can also be built as a module. If so, the module
|
|
||||||
will be called rtc-meson-vrtc.
|
|
||||||
|
|
||||||
config RTC_DRV_RK808
|
config RTC_DRV_RK808
|
||||||
tristate "Rockchip RK805/RK808/RK809/RK817/RK818 RTC"
|
tristate "Rockchip RK805/RK808/RK809/RK817/RK818 RTC"
|
||||||
depends on MFD_RK808
|
depends on MFD_RK808
|
||||||
|
@ -1337,8 +1326,6 @@ config RTC_DRV_IMXDI
|
||||||
config RTC_DRV_FSL_FTM_ALARM
|
config RTC_DRV_FSL_FTM_ALARM
|
||||||
tristate "Freescale FlexTimer alarm timer"
|
tristate "Freescale FlexTimer alarm timer"
|
||||||
depends on ARCH_LAYERSCAPE || SOC_LS1021A
|
depends on ARCH_LAYERSCAPE || SOC_LS1021A
|
||||||
select FSL_RCPM
|
|
||||||
default y
|
|
||||||
help
|
help
|
||||||
For the FlexTimer in LS1012A, LS1021A, LS1028A, LS1043A, LS1046A,
|
For the FlexTimer in LS1012A, LS1021A, LS1028A, LS1043A, LS1046A,
|
||||||
LS1088A, LS208xA, we can use FTM as the wakeup source.
|
LS1088A, LS208xA, we can use FTM as the wakeup source.
|
||||||
|
@ -1360,6 +1347,17 @@ config RTC_DRV_MESON
|
||||||
This driver can also be built as a module, if so, the module
|
This driver can also be built as a module, if so, the module
|
||||||
will be called "rtc-meson".
|
will be called "rtc-meson".
|
||||||
|
|
||||||
|
config RTC_DRV_MESON_VRTC
|
||||||
|
tristate "Amlogic Meson Virtual RTC"
|
||||||
|
depends on ARCH_MESON || COMPILE_TEST
|
||||||
|
default m if ARCH_MESON
|
||||||
|
help
|
||||||
|
If you say yes here you will get support for the
|
||||||
|
Virtual RTC of Amlogic SoCs.
|
||||||
|
|
||||||
|
This driver can also be built as a module. If so, the module
|
||||||
|
will be called rtc-meson-vrtc.
|
||||||
|
|
||||||
config RTC_DRV_OMAP
|
config RTC_DRV_OMAP
|
||||||
tristate "TI OMAP Real Time Clock"
|
tristate "TI OMAP Real Time Clock"
|
||||||
depends on ARCH_OMAP || ARCH_DAVINCI || COMPILE_TEST
|
depends on ARCH_OMAP || ARCH_DAVINCI || COMPILE_TEST
|
||||||
|
@ -1459,6 +1457,7 @@ config RTC_DRV_PL031
|
||||||
config RTC_DRV_AT91RM9200
|
config RTC_DRV_AT91RM9200
|
||||||
tristate "AT91RM9200 or some AT91SAM9 RTC"
|
tristate "AT91RM9200 or some AT91SAM9 RTC"
|
||||||
depends on ARCH_AT91 || COMPILE_TEST
|
depends on ARCH_AT91 || COMPILE_TEST
|
||||||
|
depends on OF
|
||||||
help
|
help
|
||||||
Driver for the internal RTC (Realtime Clock) module found on
|
Driver for the internal RTC (Realtime Clock) module found on
|
||||||
Atmel AT91RM9200's and some AT91SAM9 chips. On AT91SAM9 chips
|
Atmel AT91RM9200's and some AT91SAM9 chips. On AT91SAM9 chips
|
||||||
|
@ -1510,9 +1509,9 @@ config RTC_DRV_PXA
|
||||||
depends on ARCH_PXA
|
depends on ARCH_PXA
|
||||||
select RTC_DRV_SA1100
|
select RTC_DRV_SA1100
|
||||||
help
|
help
|
||||||
If you say Y here you will get access to the real time clock
|
If you say Y here you will get access to the real time clock
|
||||||
built into your PXA27x or PXA3xx CPU. This RTC is actually 2 RTCs
|
built into your PXA27x or PXA3xx CPU. This RTC is actually 2 RTCs
|
||||||
consisting of an SA1100 compatible RTC and the extended PXA RTC.
|
consisting of an SA1100 compatible RTC and the extended PXA RTC.
|
||||||
|
|
||||||
This RTC driver uses PXA RTC registers available since pxa27x
|
This RTC driver uses PXA RTC registers available since pxa27x
|
||||||
series (RDxR, RYxR) instead of legacy RCNR, RTAR.
|
series (RDxR, RYxR) instead of legacy RCNR, RTAR.
|
||||||
|
|
|
@ -70,7 +70,7 @@ static int rtc_valid_range(struct rtc_device *rtc, struct rtc_time *tm)
|
||||||
time64_t time = rtc_tm_to_time64(tm);
|
time64_t time = rtc_tm_to_time64(tm);
|
||||||
time64_t range_min = rtc->set_start_time ? rtc->start_secs :
|
time64_t range_min = rtc->set_start_time ? rtc->start_secs :
|
||||||
rtc->range_min;
|
rtc->range_min;
|
||||||
time64_t range_max = rtc->set_start_time ?
|
timeu64_t range_max = rtc->set_start_time ?
|
||||||
(rtc->start_secs + rtc->range_max - rtc->range_min) :
|
(rtc->start_secs + rtc->range_max - rtc->range_min) :
|
||||||
rtc->range_max;
|
rtc->range_max;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ EXPORT_SYMBOL_GPL(rtc_read_time);
|
||||||
|
|
||||||
int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
|
int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
|
||||||
{
|
{
|
||||||
int err;
|
int err, uie;
|
||||||
|
|
||||||
err = rtc_valid_tm(tm);
|
err = rtc_valid_tm(tm);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
|
@ -137,6 +137,17 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
|
||||||
|
|
||||||
rtc_subtract_offset(rtc, tm);
|
rtc_subtract_offset(rtc, tm);
|
||||||
|
|
||||||
|
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
|
||||||
|
uie = rtc->uie_rtctimer.enabled || rtc->uie_irq_active;
|
||||||
|
#else
|
||||||
|
uie = rtc->uie_rtctimer.enabled;
|
||||||
|
#endif
|
||||||
|
if (uie) {
|
||||||
|
err = rtc_update_irq_enable(rtc, 0);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
err = mutex_lock_interruptible(&rtc->ops_lock);
|
err = mutex_lock_interruptible(&rtc->ops_lock);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@ -153,6 +164,12 @@ int rtc_set_time(struct rtc_device *rtc, struct rtc_time *tm)
|
||||||
/* A timer might have just expired */
|
/* A timer might have just expired */
|
||||||
schedule_work(&rtc->irqwork);
|
schedule_work(&rtc->irqwork);
|
||||||
|
|
||||||
|
if (uie) {
|
||||||
|
err = rtc_update_irq_enable(rtc, 1);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
trace_rtc_set_time(rtc_tm_to_time64(tm), err);
|
trace_rtc_set_time(rtc_tm_to_time64(tm), err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +545,7 @@ EXPORT_SYMBOL_GPL(rtc_alarm_irq_enable);
|
||||||
|
|
||||||
int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
|
int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
|
||||||
{
|
{
|
||||||
int err;
|
int rc = 0, err;
|
||||||
|
|
||||||
err = mutex_lock_interruptible(&rtc->ops_lock);
|
err = mutex_lock_interruptible(&rtc->ops_lock);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -553,7 +570,9 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
|
||||||
struct rtc_time tm;
|
struct rtc_time tm;
|
||||||
ktime_t now, onesec;
|
ktime_t now, onesec;
|
||||||
|
|
||||||
__rtc_read_time(rtc, &tm);
|
rc = __rtc_read_time(rtc, &tm);
|
||||||
|
if (rc)
|
||||||
|
goto out;
|
||||||
onesec = ktime_set(1, 0);
|
onesec = ktime_set(1, 0);
|
||||||
now = rtc_tm_to_ktime(tm);
|
now = rtc_tm_to_ktime(tm);
|
||||||
rtc->uie_rtctimer.node.expires = ktime_add(now, onesec);
|
rtc->uie_rtctimer.node.expires = ktime_add(now, onesec);
|
||||||
|
@ -565,6 +584,16 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&rtc->ops_lock);
|
mutex_unlock(&rtc->ops_lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* __rtc_read_time() failed, this probably means that the RTC time has
|
||||||
|
* never been set or less probably there is a transient error on the
|
||||||
|
* bus. In any case, avoid enabling emulation has this will fail when
|
||||||
|
* reading the time too.
|
||||||
|
*/
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
|
#ifdef CONFIG_RTC_INTF_DEV_UIE_EMUL
|
||||||
/*
|
/*
|
||||||
* Enable emulation if the driver returned -EINVAL to signal that it has
|
* Enable emulation if the driver returned -EINVAL to signal that it has
|
||||||
|
@ -581,6 +610,8 @@ EXPORT_SYMBOL_GPL(rtc_update_irq_enable);
|
||||||
/**
|
/**
|
||||||
* rtc_handle_legacy_irq - AIE, UIE and PIE event hook
|
* rtc_handle_legacy_irq - AIE, UIE and PIE event hook
|
||||||
* @rtc: pointer to the rtc device
|
* @rtc: pointer to the rtc device
|
||||||
|
* @num: number of occurence of the event
|
||||||
|
* @mode: type of the event, RTC_AF, RTC_UF of RTC_PF
|
||||||
*
|
*
|
||||||
* This function is called when an AIE, UIE or PIE mode interrupt
|
* This function is called when an AIE, UIE or PIE mode interrupt
|
||||||
* has occurred (or been emulated).
|
* has occurred (or been emulated).
|
||||||
|
@ -761,8 +792,8 @@ int rtc_irq_set_freq(struct rtc_device *rtc, int freq)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rtc_timer_enqueue - Adds a rtc_timer to the rtc_device timerqueue
|
* rtc_timer_enqueue - Adds a rtc_timer to the rtc_device timerqueue
|
||||||
* @rtc rtc device
|
* @rtc: rtc device
|
||||||
* @timer timer being added.
|
* @timer: timer being added.
|
||||||
*
|
*
|
||||||
* Enqueues a timer onto the rtc devices timerqueue and sets
|
* Enqueues a timer onto the rtc devices timerqueue and sets
|
||||||
* the next alarm event appropriately.
|
* the next alarm event appropriately.
|
||||||
|
@ -821,8 +852,8 @@ static void rtc_alarm_disable(struct rtc_device *rtc)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
|
* rtc_timer_remove - Removes a rtc_timer from the rtc_device timerqueue
|
||||||
* @rtc rtc device
|
* @rtc: rtc device
|
||||||
* @timer timer being removed.
|
* @timer: timer being removed.
|
||||||
*
|
*
|
||||||
* Removes a timer onto the rtc devices timerqueue and sets
|
* Removes a timer onto the rtc devices timerqueue and sets
|
||||||
* the next alarm event appropriately.
|
* the next alarm event appropriately.
|
||||||
|
@ -859,8 +890,7 @@ static void rtc_timer_remove(struct rtc_device *rtc, struct rtc_timer *timer)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rtc_timer_do_work - Expires rtc timers
|
* rtc_timer_do_work - Expires rtc timers
|
||||||
* @rtc rtc device
|
* @work: work item
|
||||||
* @timer timer being removed.
|
|
||||||
*
|
*
|
||||||
* Expires rtc timers. Reprograms next alarm event if needed.
|
* Expires rtc timers. Reprograms next alarm event if needed.
|
||||||
* Called via worktask.
|
* Called via worktask.
|
||||||
|
@ -993,8 +1023,8 @@ void rtc_timer_cancel(struct rtc_device *rtc, struct rtc_timer *timer)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rtc_read_offset - Read the amount of rtc offset in parts per billion
|
* rtc_read_offset - Read the amount of rtc offset in parts per billion
|
||||||
* @ rtc: rtc device to be used
|
* @rtc: rtc device to be used
|
||||||
* @ offset: the offset in parts per billion
|
* @offset: the offset in parts per billion
|
||||||
*
|
*
|
||||||
* see below for details.
|
* see below for details.
|
||||||
*
|
*
|
||||||
|
@ -1022,8 +1052,8 @@ int rtc_read_offset(struct rtc_device *rtc, long *offset)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rtc_set_offset - Adjusts the duration of the average second
|
* rtc_set_offset - Adjusts the duration of the average second
|
||||||
* @ rtc: rtc device to be used
|
* @rtc: rtc device to be used
|
||||||
* @ offset: the offset in parts per billion
|
* @offset: the offset in parts per billion
|
||||||
*
|
*
|
||||||
* Some rtc's allow an adjustment to the average duration of a second
|
* Some rtc's allow an adjustment to the average duration of a second
|
||||||
* to compensate for differences in the actual clock rate due to temperature,
|
* to compensate for differences in the actual clock rate due to temperature,
|
||||||
|
|
|
@ -900,16 +900,6 @@ err:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int abb5zes3_remove(struct i2c_client *client)
|
|
||||||
{
|
|
||||||
struct abb5zes3_rtc_data *rtc_data = dev_get_drvdata(&client->dev);
|
|
||||||
|
|
||||||
if (rtc_data->irq > 0)
|
|
||||||
device_init_wakeup(&client->dev, false);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
static int abb5zes3_rtc_suspend(struct device *dev)
|
static int abb5zes3_rtc_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
|
@ -956,7 +946,6 @@ static struct i2c_driver abb5zes3_driver = {
|
||||||
.of_match_table = of_match_ptr(abb5zes3_dt_match),
|
.of_match_table = of_match_ptr(abb5zes3_dt_match),
|
||||||
},
|
},
|
||||||
.probe = abb5zes3_probe,
|
.probe = abb5zes3_probe,
|
||||||
.remove = abb5zes3_remove,
|
|
||||||
.id_table = abb5zes3_id,
|
.id_table = abb5zes3_id,
|
||||||
};
|
};
|
||||||
module_i2c_driver(abb5zes3_driver);
|
module_i2c_driver(abb5zes3_driver);
|
||||||
|
|
|
@ -74,7 +74,7 @@ struct armada38x_rtc {
|
||||||
int irq;
|
int irq;
|
||||||
bool initialized;
|
bool initialized;
|
||||||
struct value_to_freq *val_to_freq;
|
struct value_to_freq *val_to_freq;
|
||||||
struct armada38x_rtc_data *data;
|
const struct armada38x_rtc_data *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ALARM1 0
|
#define ALARM1 0
|
||||||
|
@ -501,17 +501,14 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
struct armada38x_rtc *rtc;
|
struct armada38x_rtc *rtc;
|
||||||
const struct of_device_id *match;
|
|
||||||
|
|
||||||
match = of_match_device(armada38x_rtc_of_match_table, &pdev->dev);
|
|
||||||
if (!match)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
|
rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc),
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
if (!rtc)
|
if (!rtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
rtc->data = of_device_get_match_data(&pdev->dev);
|
||||||
|
|
||||||
rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR,
|
rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR,
|
||||||
sizeof(struct value_to_freq), GFP_KERNEL);
|
sizeof(struct value_to_freq), GFP_KERNEL);
|
||||||
if (!rtc->val_to_freq)
|
if (!rtc->val_to_freq)
|
||||||
|
@ -553,7 +550,6 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev)
|
||||||
*/
|
*/
|
||||||
rtc->rtc_dev->ops = &armada38x_rtc_ops_noirq;
|
rtc->rtc_dev->ops = &armada38x_rtc_ops_noirq;
|
||||||
}
|
}
|
||||||
rtc->data = (struct armada38x_rtc_data *)match->data;
|
|
||||||
|
|
||||||
/* Update RTC-MBUS bridge timing parameters */
|
/* Update RTC-MBUS bridge timing parameters */
|
||||||
rtc->data->update_mbus_timing(rtc);
|
rtc->data->update_mbus_timing(rtc);
|
||||||
|
|
|
@ -245,7 +245,6 @@ static int asm9260_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct asm9260_rtc_priv *priv;
|
struct asm9260_rtc_priv *priv;
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct resource *res;
|
|
||||||
int irq_alarm, ret;
|
int irq_alarm, ret;
|
||||||
u32 ccr;
|
u32 ccr;
|
||||||
|
|
||||||
|
@ -260,8 +259,7 @@ static int asm9260_rtc_probe(struct platform_device *pdev)
|
||||||
if (irq_alarm < 0)
|
if (irq_alarm < 0)
|
||||||
return irq_alarm;
|
return irq_alarm;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
priv->iobase = devm_platform_ioremap_resource(pdev, 0);
|
||||||
priv->iobase = devm_ioremap_resource(dev, res);
|
|
||||||
if (IS_ERR(priv->iobase))
|
if (IS_ERR(priv->iobase))
|
||||||
return PTR_ERR(priv->iobase);
|
return PTR_ERR(priv->iobase);
|
||||||
|
|
||||||
|
|
|
@ -85,14 +85,12 @@ static const struct rtc_class_ops aspeed_rtc_ops = {
|
||||||
static int aspeed_rtc_probe(struct platform_device *pdev)
|
static int aspeed_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct aspeed_rtc *rtc;
|
struct aspeed_rtc *rtc;
|
||||||
struct resource *res;
|
|
||||||
|
|
||||||
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
|
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
|
||||||
if (!rtc)
|
if (!rtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(rtc->base))
|
if (IS_ERR(rtc->base))
|
||||||
return PTR_ERR(rtc->base);
|
return PTR_ERR(rtc->base);
|
||||||
|
|
||||||
|
|
|
@ -319,7 +319,6 @@ static const struct at91_rtc_config at91sam9x5_config = {
|
||||||
.use_shadow_imr = true,
|
.use_shadow_imr = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
|
||||||
static const struct of_device_id at91_rtc_dt_ids[] = {
|
static const struct of_device_id at91_rtc_dt_ids[] = {
|
||||||
{
|
{
|
||||||
.compatible = "atmel,at91rm9200-rtc",
|
.compatible = "atmel,at91rm9200-rtc",
|
||||||
|
@ -332,22 +331,6 @@ static const struct of_device_id at91_rtc_dt_ids[] = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids);
|
MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids);
|
||||||
#endif
|
|
||||||
|
|
||||||
static const struct at91_rtc_config *
|
|
||||||
at91_rtc_get_config(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
const struct of_device_id *match;
|
|
||||||
|
|
||||||
if (pdev->dev.of_node) {
|
|
||||||
match = of_match_node(at91_rtc_dt_ids, pdev->dev.of_node);
|
|
||||||
if (!match)
|
|
||||||
return NULL;
|
|
||||||
return (const struct at91_rtc_config *)match->data;
|
|
||||||
}
|
|
||||||
|
|
||||||
return &at91rm9200_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct rtc_class_ops at91_rtc_ops = {
|
static const struct rtc_class_ops at91_rtc_ops = {
|
||||||
.read_time = at91_rtc_readtime,
|
.read_time = at91_rtc_readtime,
|
||||||
|
@ -367,7 +350,7 @@ static int __init at91_rtc_probe(struct platform_device *pdev)
|
||||||
struct resource *regs;
|
struct resource *regs;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
at91_rtc_config = at91_rtc_get_config(pdev);
|
at91_rtc_config = of_device_get_match_data(&pdev->dev);
|
||||||
if (!at91_rtc_config)
|
if (!at91_rtc_config)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
|
|
@ -334,7 +334,6 @@ static const struct rtc_class_ops at91_rtc_ops = {
|
||||||
*/
|
*/
|
||||||
static int at91_rtc_probe(struct platform_device *pdev)
|
static int at91_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *r;
|
|
||||||
struct sam9_rtc *rtc;
|
struct sam9_rtc *rtc;
|
||||||
int ret, irq;
|
int ret, irq;
|
||||||
u32 mr;
|
u32 mr;
|
||||||
|
@ -358,8 +357,7 @@ static int at91_rtc_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
platform_set_drvdata(pdev, rtc);
|
platform_set_drvdata(pdev, rtc);
|
||||||
|
|
||||||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->rtt = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->rtt = devm_ioremap_resource(&pdev->dev, r);
|
|
||||||
if (IS_ERR(rtc->rtt))
|
if (IS_ERR(rtc->rtt))
|
||||||
return PTR_ERR(rtc->rtt);
|
return PTR_ERR(rtc->rtt);
|
||||||
|
|
||||||
|
|
|
@ -491,3 +491,4 @@ module_platform_driver(bd70528_rtc);
|
||||||
MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
|
MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
|
||||||
MODULE_DESCRIPTION("BD70528 RTC driver");
|
MODULE_DESCRIPTION("BD70528 RTC driver");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_ALIAS("platform:bd70528-rtc");
|
||||||
|
|
|
@ -200,7 +200,6 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct brcmstb_waketmr *timer;
|
struct brcmstb_waketmr *timer;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
timer = devm_kzalloc(dev, sizeof(*timer), GFP_KERNEL);
|
timer = devm_kzalloc(dev, sizeof(*timer), GFP_KERNEL);
|
||||||
|
@ -210,8 +209,7 @@ static int brcmstb_waketmr_probe(struct platform_device *pdev)
|
||||||
platform_set_drvdata(pdev, timer);
|
platform_set_drvdata(pdev, timer);
|
||||||
timer->dev = dev;
|
timer->dev = dev;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
timer->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
timer->base = devm_ioremap_resource(dev, res);
|
|
||||||
if (IS_ERR(timer->base))
|
if (IS_ERR(timer->base))
|
||||||
return PTR_ERR(timer->base);
|
return PTR_ERR(timer->base);
|
||||||
|
|
||||||
|
@ -277,6 +275,7 @@ static int brcmstb_waketmr_remove(struct platform_device *pdev)
|
||||||
struct brcmstb_waketmr *timer = dev_get_drvdata(&pdev->dev);
|
struct brcmstb_waketmr *timer = dev_get_drvdata(&pdev->dev);
|
||||||
|
|
||||||
unregister_reboot_notifier(&timer->reboot_notifier);
|
unregister_reboot_notifier(&timer->reboot_notifier);
|
||||||
|
clk_disable_unprepare(timer->clk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,6 @@ static const struct rtc_class_ops cdns_rtc_ops = {
|
||||||
static int cdns_rtc_probe(struct platform_device *pdev)
|
static int cdns_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct cdns_rtc *crtc;
|
struct cdns_rtc *crtc;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
unsigned long ref_clk_freq;
|
unsigned long ref_clk_freq;
|
||||||
|
|
||||||
|
@ -263,8 +262,7 @@ static int cdns_rtc_probe(struct platform_device *pdev)
|
||||||
if (!crtc)
|
if (!crtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
crtc->regs = devm_platform_ioremap_resource(pdev, 0);
|
||||||
crtc->regs = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(crtc->regs))
|
if (IS_ERR(crtc->regs))
|
||||||
return PTR_ERR(crtc->regs);
|
return PTR_ERR(crtc->regs);
|
||||||
|
|
||||||
|
|
|
@ -164,15 +164,13 @@ static int __init coh901331_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct coh901331_port *rtap;
|
struct coh901331_port *rtap;
|
||||||
struct resource *res;
|
|
||||||
|
|
||||||
rtap = devm_kzalloc(&pdev->dev,
|
rtap = devm_kzalloc(&pdev->dev,
|
||||||
sizeof(struct coh901331_port), GFP_KERNEL);
|
sizeof(struct coh901331_port), GFP_KERNEL);
|
||||||
if (!rtap)
|
if (!rtap)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtap->virtbase = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtap->virtbase = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(rtap->virtbase))
|
if (IS_ERR(rtap->virtbase))
|
||||||
return PTR_ERR(rtap->virtbase);
|
return PTR_ERR(rtap->virtbase);
|
||||||
|
|
||||||
|
|
|
@ -107,11 +107,7 @@ static int cros_ec_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
||||||
struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(dev);
|
struct cros_ec_rtc *cros_ec_rtc = dev_get_drvdata(dev);
|
||||||
struct cros_ec_device *cros_ec = cros_ec_rtc->cros_ec;
|
struct cros_ec_device *cros_ec = cros_ec_rtc->cros_ec;
|
||||||
int ret;
|
int ret;
|
||||||
time64_t time;
|
time64_t time = rtc_tm_to_time64(tm);
|
||||||
|
|
||||||
time = rtc_tm_to_time64(tm);
|
|
||||||
if (time < 0 || time > U32_MAX)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_VALUE, (u32)time);
|
ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_VALUE, (u32)time);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -348,14 +344,16 @@ static int cros_ec_rtc_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
cros_ec_rtc->rtc = devm_rtc_device_register(&pdev->dev, DRV_NAME,
|
cros_ec_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
|
||||||
&cros_ec_rtc_ops,
|
if (IS_ERR(cros_ec_rtc->rtc))
|
||||||
THIS_MODULE);
|
return PTR_ERR(cros_ec_rtc->rtc);
|
||||||
if (IS_ERR(cros_ec_rtc->rtc)) {
|
|
||||||
ret = PTR_ERR(cros_ec_rtc->rtc);
|
cros_ec_rtc->rtc->ops = &cros_ec_rtc_ops;
|
||||||
dev_err(&pdev->dev, "failed to register rtc device\n");
|
cros_ec_rtc->rtc->range_max = U32_MAX;
|
||||||
|
|
||||||
|
ret = rtc_register_device(cros_ec_rtc->rtc);
|
||||||
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
/* Get RTC events from the EC. */
|
/* Get RTC events from the EC. */
|
||||||
cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event;
|
cros_ec_rtc->notifier.notifier_call = cros_ec_rtc_event;
|
||||||
|
|
|
@ -483,6 +483,9 @@ static int da9063_rtc_probe(struct platform_device *pdev)
|
||||||
rtc->rtc_dev->uie_unsupported = 1;
|
rtc->rtc_dev->uie_unsupported = 1;
|
||||||
|
|
||||||
irq_alarm = platform_get_irq_byname(pdev, "ALARM");
|
irq_alarm = platform_get_irq_byname(pdev, "ALARM");
|
||||||
|
if (irq_alarm < 0)
|
||||||
|
return irq_alarm;
|
||||||
|
|
||||||
ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL,
|
ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL,
|
||||||
da9063_alarm_event,
|
da9063_alarm_event,
|
||||||
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
|
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
|
||||||
|
|
|
@ -469,7 +469,6 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct davinci_rtc *davinci_rtc;
|
struct davinci_rtc *davinci_rtc;
|
||||||
struct resource *res;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
davinci_rtc = devm_kzalloc(&pdev->dev, sizeof(struct davinci_rtc), GFP_KERNEL);
|
davinci_rtc = devm_kzalloc(&pdev->dev, sizeof(struct davinci_rtc), GFP_KERNEL);
|
||||||
|
@ -480,8 +479,7 @@ static int __init davinci_rtc_probe(struct platform_device *pdev)
|
||||||
if (davinci_rtc->irq < 0)
|
if (davinci_rtc->irq < 0)
|
||||||
return davinci_rtc->irq;
|
return davinci_rtc->irq;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
davinci_rtc->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
davinci_rtc->base = devm_ioremap_resource(dev, res);
|
|
||||||
if (IS_ERR(davinci_rtc->base))
|
if (IS_ERR(davinci_rtc->base))
|
||||||
return PTR_ERR(davinci_rtc->base);
|
return PTR_ERR(davinci_rtc->base);
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,6 @@ static irqreturn_t dc_rtc_irq(int irq, void *dev_id)
|
||||||
|
|
||||||
static int __init dc_rtc_probe(struct platform_device *pdev)
|
static int __init dc_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
struct dc_rtc *rtc;
|
struct dc_rtc *rtc;
|
||||||
int irq, ret;
|
int irq, ret;
|
||||||
|
|
||||||
|
@ -183,8 +182,7 @@ static int __init dc_rtc_probe(struct platform_device *pdev)
|
||||||
if (!rtc)
|
if (!rtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->regs = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->regs = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(rtc->regs))
|
if (IS_ERR(rtc->regs))
|
||||||
return PTR_ERR(rtc->regs);
|
return PTR_ERR(rtc->regs);
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,6 @@ static const struct rtc_class_ops ds1216_rtc_ops = {
|
||||||
|
|
||||||
static int __init ds1216_rtc_probe(struct platform_device *pdev)
|
static int __init ds1216_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
struct ds1216_priv *priv;
|
struct ds1216_priv *priv;
|
||||||
u8 dummy[8];
|
u8 dummy[8];
|
||||||
|
|
||||||
|
@ -147,8 +146,7 @@ static int __init ds1216_rtc_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
platform_set_drvdata(pdev, priv);
|
platform_set_drvdata(pdev, priv);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
priv->ioaddr = devm_platform_ioremap_resource(pdev, 0);
|
||||||
priv->ioaddr = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(priv->ioaddr))
|
if (IS_ERR(priv->ioaddr))
|
||||||
return PTR_ERR(priv->ioaddr);
|
return PTR_ERR(priv->ioaddr);
|
||||||
|
|
||||||
|
|
|
@ -323,15 +323,13 @@ static const struct rtc_class_ops ds1286_ops = {
|
||||||
static int ds1286_probe(struct platform_device *pdev)
|
static int ds1286_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
struct resource *res;
|
|
||||||
struct ds1286_priv *priv;
|
struct ds1286_priv *priv;
|
||||||
|
|
||||||
priv = devm_kzalloc(&pdev->dev, sizeof(struct ds1286_priv), GFP_KERNEL);
|
priv = devm_kzalloc(&pdev->dev, sizeof(struct ds1286_priv), GFP_KERNEL);
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
priv->rtcregs = devm_platform_ioremap_resource(pdev, 0);
|
||||||
priv->rtcregs = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(priv->rtcregs))
|
if (IS_ERR(priv->rtcregs))
|
||||||
return PTR_ERR(priv->rtcregs);
|
return PTR_ERR(priv->rtcregs);
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
#include <linux/rtc.h>
|
#include <linux/rtc.h>
|
||||||
#include <linux/spi/spi.h>
|
#include <linux/spi/spi.h>
|
||||||
|
|
||||||
#define DRV_NAME "rtc-ds1302"
|
|
||||||
|
|
||||||
#define RTC_CMD_READ 0x81 /* Read command */
|
#define RTC_CMD_READ 0x81 /* Read command */
|
||||||
#define RTC_CMD_WRITE 0x80 /* Write command */
|
#define RTC_CMD_WRITE 0x80 /* Write command */
|
||||||
|
|
||||||
|
|
|
@ -78,42 +78,19 @@ struct ds1343_priv {
|
||||||
struct spi_device *spi;
|
struct spi_device *spi;
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
struct regmap *map;
|
struct regmap *map;
|
||||||
struct mutex mutex;
|
|
||||||
unsigned int irqen;
|
|
||||||
int irq;
|
int irq;
|
||||||
int alarm_sec;
|
|
||||||
int alarm_min;
|
|
||||||
int alarm_hour;
|
|
||||||
int alarm_mday;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ds1343_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
|
|
||||||
{
|
|
||||||
switch (cmd) {
|
|
||||||
#ifdef RTC_SET_CHARGE
|
|
||||||
case RTC_SET_CHARGE:
|
|
||||||
{
|
|
||||||
int val;
|
|
||||||
|
|
||||||
if (copy_from_user(&val, (int __user *)arg, sizeof(int)))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
return regmap_write(priv->map, DS1343_TRICKLE_REG, val);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return -ENOIOCTLCMD;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t ds1343_show_glitchfilter(struct device *dev,
|
static ssize_t ds1343_show_glitchfilter(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
|
||||||
int glitch_filt_status, data;
|
int glitch_filt_status, data;
|
||||||
|
int res;
|
||||||
|
|
||||||
regmap_read(priv->map, DS1343_CONTROL_REG, &data);
|
res = regmap_read(priv->map, DS1343_CONTROL_REG, &data);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
|
||||||
glitch_filt_status = !!(data & DS1343_EGFIL);
|
glitch_filt_status = !!(data & DS1343_EGFIL);
|
||||||
|
|
||||||
|
@ -127,21 +104,19 @@ static ssize_t ds1343_store_glitchfilter(struct device *dev,
|
||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
|
||||||
int data;
|
int data = 0;
|
||||||
|
int res;
|
||||||
regmap_read(priv->map, DS1343_CONTROL_REG, &data);
|
|
||||||
|
|
||||||
if (strncmp(buf, "enabled", 7) == 0)
|
if (strncmp(buf, "enabled", 7) == 0)
|
||||||
data |= DS1343_EGFIL;
|
data = DS1343_EGFIL;
|
||||||
|
else if (strncmp(buf, "disabled", 8))
|
||||||
else if (strncmp(buf, "disabled", 8) == 0)
|
|
||||||
data &= ~(DS1343_EGFIL);
|
|
||||||
|
|
||||||
else
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
regmap_write(priv->map, DS1343_CONTROL_REG, data);
|
res = regmap_update_bits(priv->map, DS1343_CONTROL_REG,
|
||||||
|
DS1343_EGFIL, data);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -168,11 +143,13 @@ static int ds1343_nvram_read(void *priv, unsigned int off, void *val,
|
||||||
static ssize_t ds1343_show_tricklecharger(struct device *dev,
|
static ssize_t ds1343_show_tricklecharger(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
struct ds1343_priv *priv = dev_get_drvdata(dev->parent);
|
||||||
int data;
|
int res, data;
|
||||||
char *diodes = "disabled", *resistors = " ";
|
char *diodes = "disabled", *resistors = " ";
|
||||||
|
|
||||||
regmap_read(priv->map, DS1343_TRICKLE_REG, &data);
|
res = regmap_read(priv->map, DS1343_TRICKLE_REG, &data);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
|
||||||
if ((data & 0xf0) == DS1343_TRICKLE_MAGIC) {
|
if ((data & 0xf0) == DS1343_TRICKLE_MAGIC) {
|
||||||
switch (data & 0x0c) {
|
switch (data & 0x0c) {
|
||||||
|
@ -209,28 +186,15 @@ static ssize_t ds1343_show_tricklecharger(struct device *dev,
|
||||||
|
|
||||||
static DEVICE_ATTR(trickle_charger, S_IRUGO, ds1343_show_tricklecharger, NULL);
|
static DEVICE_ATTR(trickle_charger, S_IRUGO, ds1343_show_tricklecharger, NULL);
|
||||||
|
|
||||||
static int ds1343_sysfs_register(struct device *dev)
|
static struct attribute *ds1343_attrs[] = {
|
||||||
{
|
&dev_attr_glitch_filter.attr,
|
||||||
int err;
|
&dev_attr_trickle_charger.attr,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
err = device_create_file(dev, &dev_attr_glitch_filter);
|
static const struct attribute_group ds1343_attr_group = {
|
||||||
if (err)
|
.attrs = ds1343_attrs,
|
||||||
return err;
|
};
|
||||||
|
|
||||||
err = device_create_file(dev, &dev_attr_trickle_charger);
|
|
||||||
if (!err)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
device_remove_file(dev, &dev_attr_glitch_filter);
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ds1343_sysfs_unregister(struct device *dev)
|
|
||||||
{
|
|
||||||
device_remove_file(dev, &dev_attr_glitch_filter);
|
|
||||||
device_remove_file(dev, &dev_attr_trickle_charger);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ds1343_read_time(struct device *dev, struct rtc_time *dt)
|
static int ds1343_read_time(struct device *dev, struct rtc_time *dt)
|
||||||
{
|
{
|
||||||
|
@ -256,144 +220,78 @@ static int ds1343_read_time(struct device *dev, struct rtc_time *dt)
|
||||||
static int ds1343_set_time(struct device *dev, struct rtc_time *dt)
|
static int ds1343_set_time(struct device *dev, struct rtc_time *dt)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
||||||
int res;
|
u8 buf[7];
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_SECONDS_REG,
|
buf[0] = bin2bcd(dt->tm_sec);
|
||||||
bin2bcd(dt->tm_sec));
|
buf[1] = bin2bcd(dt->tm_min);
|
||||||
if (res)
|
buf[2] = bin2bcd(dt->tm_hour) & 0x3F;
|
||||||
return res;
|
buf[3] = bin2bcd(dt->tm_wday + 1);
|
||||||
|
buf[4] = bin2bcd(dt->tm_mday);
|
||||||
|
buf[5] = bin2bcd(dt->tm_mon + 1);
|
||||||
|
buf[6] = bin2bcd(dt->tm_year - 100);
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_MINUTES_REG,
|
return regmap_bulk_write(priv->map, DS1343_SECONDS_REG,
|
||||||
bin2bcd(dt->tm_min));
|
buf, sizeof(buf));
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_HOURS_REG,
|
|
||||||
bin2bcd(dt->tm_hour) & 0x3F);
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_DAY_REG,
|
|
||||||
bin2bcd(dt->tm_wday + 1));
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_DATE_REG,
|
|
||||||
bin2bcd(dt->tm_mday));
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_MONTH_REG,
|
|
||||||
bin2bcd(dt->tm_mon + 1));
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
dt->tm_year %= 100;
|
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_YEAR_REG,
|
|
||||||
bin2bcd(dt->tm_year));
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ds1343_update_alarm(struct device *dev)
|
|
||||||
{
|
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
|
||||||
unsigned int control, stat;
|
|
||||||
unsigned char buf[4];
|
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
res = regmap_read(priv->map, DS1343_CONTROL_REG, &control);
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
res = regmap_read(priv->map, DS1343_STATUS_REG, &stat);
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
control &= ~(DS1343_A0IE);
|
|
||||||
stat &= ~(DS1343_IRQF0);
|
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_CONTROL_REG, control);
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
res = regmap_write(priv->map, DS1343_STATUS_REG, stat);
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
buf[0] = priv->alarm_sec < 0 || (priv->irqen & RTC_UF) ?
|
|
||||||
0x80 : bin2bcd(priv->alarm_sec) & 0x7F;
|
|
||||||
buf[1] = priv->alarm_min < 0 || (priv->irqen & RTC_UF) ?
|
|
||||||
0x80 : bin2bcd(priv->alarm_min) & 0x7F;
|
|
||||||
buf[2] = priv->alarm_hour < 0 || (priv->irqen & RTC_UF) ?
|
|
||||||
0x80 : bin2bcd(priv->alarm_hour) & 0x3F;
|
|
||||||
buf[3] = priv->alarm_mday < 0 || (priv->irqen & RTC_UF) ?
|
|
||||||
0x80 : bin2bcd(priv->alarm_mday) & 0x7F;
|
|
||||||
|
|
||||||
res = regmap_bulk_write(priv->map, DS1343_ALM0_SEC_REG, buf, 4);
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
if (priv->irqen) {
|
|
||||||
control |= DS1343_A0IE;
|
|
||||||
res = regmap_write(priv->map, DS1343_CONTROL_REG, control);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ds1343_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
|
static int ds1343_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
||||||
int res = 0;
|
unsigned char buf[4];
|
||||||
unsigned int stat;
|
unsigned int val;
|
||||||
|
int res;
|
||||||
|
|
||||||
if (priv->irq <= 0)
|
if (priv->irq <= 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&priv->mutex);
|
res = regmap_read(priv->map, DS1343_STATUS_REG, &val);
|
||||||
|
|
||||||
res = regmap_read(priv->map, DS1343_STATUS_REG, &stat);
|
|
||||||
if (res)
|
if (res)
|
||||||
goto out;
|
return res;
|
||||||
|
|
||||||
alarm->enabled = !!(priv->irqen & RTC_AF);
|
alarm->pending = !!(val & DS1343_IRQF0);
|
||||||
alarm->pending = !!(stat & DS1343_IRQF0);
|
|
||||||
|
|
||||||
alarm->time.tm_sec = priv->alarm_sec < 0 ? 0 : priv->alarm_sec;
|
res = regmap_read(priv->map, DS1343_CONTROL_REG, &val);
|
||||||
alarm->time.tm_min = priv->alarm_min < 0 ? 0 : priv->alarm_min;
|
if (res)
|
||||||
alarm->time.tm_hour = priv->alarm_hour < 0 ? 0 : priv->alarm_hour;
|
return res;
|
||||||
alarm->time.tm_mday = priv->alarm_mday < 0 ? 0 : priv->alarm_mday;
|
alarm->enabled = !!(val & DS1343_A0IE);
|
||||||
|
|
||||||
out:
|
res = regmap_bulk_read(priv->map, DS1343_ALM0_SEC_REG, buf, 4);
|
||||||
mutex_unlock(&priv->mutex);
|
if (res)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
alarm->time.tm_sec = bcd2bin(buf[0]) & 0x7f;
|
||||||
|
alarm->time.tm_min = bcd2bin(buf[1]) & 0x7f;
|
||||||
|
alarm->time.tm_hour = bcd2bin(buf[2]) & 0x3f;
|
||||||
|
alarm->time.tm_mday = bcd2bin(buf[3]) & 0x3f;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ds1343_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
|
static int ds1343_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
||||||
|
unsigned char buf[4];
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (priv->irq <= 0)
|
if (priv->irq <= 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&priv->mutex);
|
res = regmap_update_bits(priv->map, DS1343_CONTROL_REG, DS1343_A0IE, 0);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
|
||||||
priv->alarm_sec = alarm->time.tm_sec;
|
buf[0] = bin2bcd(alarm->time.tm_sec);
|
||||||
priv->alarm_min = alarm->time.tm_min;
|
buf[1] = bin2bcd(alarm->time.tm_min);
|
||||||
priv->alarm_hour = alarm->time.tm_hour;
|
buf[2] = bin2bcd(alarm->time.tm_hour);
|
||||||
priv->alarm_mday = alarm->time.tm_mday;
|
buf[3] = bin2bcd(alarm->time.tm_mday);
|
||||||
|
|
||||||
|
res = regmap_bulk_write(priv->map, DS1343_ALM0_SEC_REG, buf, 4);
|
||||||
|
if (res)
|
||||||
|
return res;
|
||||||
|
|
||||||
if (alarm->enabled)
|
if (alarm->enabled)
|
||||||
priv->irqen |= RTC_AF;
|
res = regmap_update_bits(priv->map, DS1343_CONTROL_REG,
|
||||||
|
DS1343_A0IE, DS1343_A0IE);
|
||||||
res = ds1343_update_alarm(dev);
|
|
||||||
|
|
||||||
mutex_unlock(&priv->mutex);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -401,32 +299,21 @@ static int ds1343_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
|
||||||
static int ds1343_alarm_irq_enable(struct device *dev, unsigned int enabled)
|
static int ds1343_alarm_irq_enable(struct device *dev, unsigned int enabled)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
struct ds1343_priv *priv = dev_get_drvdata(dev);
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
if (priv->irq <= 0)
|
if (priv->irq <= 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&priv->mutex);
|
return regmap_update_bits(priv->map, DS1343_CONTROL_REG,
|
||||||
|
DS1343_A0IE, enabled ? DS1343_A0IE : 0);
|
||||||
if (enabled)
|
|
||||||
priv->irqen |= RTC_AF;
|
|
||||||
else
|
|
||||||
priv->irqen &= ~RTC_AF;
|
|
||||||
|
|
||||||
res = ds1343_update_alarm(dev);
|
|
||||||
|
|
||||||
mutex_unlock(&priv->mutex);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t ds1343_thread(int irq, void *dev_id)
|
static irqreturn_t ds1343_thread(int irq, void *dev_id)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = dev_id;
|
struct ds1343_priv *priv = dev_id;
|
||||||
unsigned int stat, control;
|
unsigned int stat;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
mutex_lock(&priv->mutex);
|
rtc_lock(priv->rtc);
|
||||||
|
|
||||||
res = regmap_read(priv->map, DS1343_STATUS_REG, &stat);
|
res = regmap_read(priv->map, DS1343_STATUS_REG, &stat);
|
||||||
if (res)
|
if (res)
|
||||||
|
@ -436,23 +323,18 @@ static irqreturn_t ds1343_thread(int irq, void *dev_id)
|
||||||
stat &= ~DS1343_IRQF0;
|
stat &= ~DS1343_IRQF0;
|
||||||
regmap_write(priv->map, DS1343_STATUS_REG, stat);
|
regmap_write(priv->map, DS1343_STATUS_REG, stat);
|
||||||
|
|
||||||
res = regmap_read(priv->map, DS1343_CONTROL_REG, &control);
|
|
||||||
if (res)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
control &= ~DS1343_A0IE;
|
|
||||||
regmap_write(priv->map, DS1343_CONTROL_REG, control);
|
|
||||||
|
|
||||||
rtc_update_irq(priv->rtc, 1, RTC_AF | RTC_IRQF);
|
rtc_update_irq(priv->rtc, 1, RTC_AF | RTC_IRQF);
|
||||||
|
|
||||||
|
regmap_update_bits(priv->map, DS1343_CONTROL_REG,
|
||||||
|
DS1343_A0IE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
mutex_unlock(&priv->mutex);
|
rtc_unlock(priv->rtc);
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct rtc_class_ops ds1343_rtc_ops = {
|
static const struct rtc_class_ops ds1343_rtc_ops = {
|
||||||
.ioctl = ds1343_ioctl,
|
|
||||||
.read_time = ds1343_read_time,
|
.read_time = ds1343_read_time,
|
||||||
.set_time = ds1343_set_time,
|
.set_time = ds1343_set_time,
|
||||||
.read_alarm = ds1343_read_alarm,
|
.read_alarm = ds1343_read_alarm,
|
||||||
|
@ -481,7 +363,6 @@ static int ds1343_probe(struct spi_device *spi)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
priv->spi = spi;
|
priv->spi = spi;
|
||||||
mutex_init(&priv->mutex);
|
|
||||||
|
|
||||||
/* RTC DS1347 works in spi mode 3 and
|
/* RTC DS1347 works in spi mode 3 and
|
||||||
* its chip select is active high
|
* its chip select is active high
|
||||||
|
@ -520,6 +401,13 @@ static int ds1343_probe(struct spi_device *spi)
|
||||||
|
|
||||||
priv->rtc->nvram_old_abi = true;
|
priv->rtc->nvram_old_abi = true;
|
||||||
priv->rtc->ops = &ds1343_rtc_ops;
|
priv->rtc->ops = &ds1343_rtc_ops;
|
||||||
|
priv->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||||
|
priv->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||||
|
|
||||||
|
res = rtc_add_group(priv->rtc, &ds1343_attr_group);
|
||||||
|
if (res)
|
||||||
|
dev_err(&spi->dev,
|
||||||
|
"unable to create sysfs entries for rtc ds1343\n");
|
||||||
|
|
||||||
res = rtc_register_device(priv->rtc);
|
res = rtc_register_device(priv->rtc);
|
||||||
if (res)
|
if (res)
|
||||||
|
@ -544,31 +432,12 @@ static int ds1343_probe(struct spi_device *spi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res = ds1343_sysfs_register(&spi->dev);
|
|
||||||
if (res)
|
|
||||||
dev_err(&spi->dev,
|
|
||||||
"unable to create sysfs entries for rtc ds1343\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ds1343_remove(struct spi_device *spi)
|
static int ds1343_remove(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct ds1343_priv *priv = spi_get_drvdata(spi);
|
dev_pm_clear_wake_irq(&spi->dev);
|
||||||
|
|
||||||
if (spi->irq) {
|
|
||||||
mutex_lock(&priv->mutex);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
spi_set_drvdata(spi, NULL);
|
|
||||||
|
|
||||||
ds1343_sysfs_unregister(&spi->dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,15 @@
|
||||||
#define DS1347_DAY_REG 0x0B
|
#define DS1347_DAY_REG 0x0B
|
||||||
#define DS1347_YEAR_REG 0x0D
|
#define DS1347_YEAR_REG 0x0D
|
||||||
#define DS1347_CONTROL_REG 0x0F
|
#define DS1347_CONTROL_REG 0x0F
|
||||||
|
#define DS1347_CENTURY_REG 0x13
|
||||||
#define DS1347_STATUS_REG 0x17
|
#define DS1347_STATUS_REG 0x17
|
||||||
#define DS1347_CLOCK_BURST 0x3F
|
#define DS1347_CLOCK_BURST 0x3F
|
||||||
|
|
||||||
|
#define DS1347_WP_BIT BIT(7)
|
||||||
|
|
||||||
|
#define DS1347_NEOSC_BIT BIT(7)
|
||||||
|
#define DS1347_OSF_BIT BIT(2)
|
||||||
|
|
||||||
static const struct regmap_range ds1347_ranges[] = {
|
static const struct regmap_range ds1347_ranges[] = {
|
||||||
{
|
{
|
||||||
.range_min = DS1347_SECONDS_REG,
|
.range_min = DS1347_SECONDS_REG,
|
||||||
|
@ -43,35 +49,54 @@ static const struct regmap_access_table ds1347_access_table = {
|
||||||
|
|
||||||
static int ds1347_read_time(struct device *dev, struct rtc_time *dt)
|
static int ds1347_read_time(struct device *dev, struct rtc_time *dt)
|
||||||
{
|
{
|
||||||
struct spi_device *spi = to_spi_device(dev);
|
struct regmap *map = dev_get_drvdata(dev);
|
||||||
struct regmap *map;
|
unsigned int status, century, secs;
|
||||||
int err;
|
|
||||||
unsigned char buf[8];
|
unsigned char buf[8];
|
||||||
|
int err;
|
||||||
|
|
||||||
map = spi_get_drvdata(spi);
|
err = regmap_read(map, DS1347_STATUS_REG, &status);
|
||||||
|
|
||||||
err = regmap_bulk_read(map, DS1347_CLOCK_BURST, buf, 8);
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
if (status & DS1347_OSF_BIT)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
do {
|
||||||
|
err = regmap_bulk_read(map, DS1347_CLOCK_BURST, buf, 8);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = regmap_read(map, DS1347_CENTURY_REG, ¢ury);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = regmap_read(map, DS1347_SECONDS_REG, &secs);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
} while (buf[0] != secs);
|
||||||
|
|
||||||
dt->tm_sec = bcd2bin(buf[0]);
|
dt->tm_sec = bcd2bin(buf[0]);
|
||||||
dt->tm_min = bcd2bin(buf[1]);
|
dt->tm_min = bcd2bin(buf[1] & 0x7f);
|
||||||
dt->tm_hour = bcd2bin(buf[2] & 0x3F);
|
dt->tm_hour = bcd2bin(buf[2] & 0x3F);
|
||||||
dt->tm_mday = bcd2bin(buf[3]);
|
dt->tm_mday = bcd2bin(buf[3]);
|
||||||
dt->tm_mon = bcd2bin(buf[4]) - 1;
|
dt->tm_mon = bcd2bin(buf[4]) - 1;
|
||||||
dt->tm_wday = bcd2bin(buf[5]) - 1;
|
dt->tm_wday = bcd2bin(buf[5]) - 1;
|
||||||
dt->tm_year = bcd2bin(buf[6]) + 100;
|
dt->tm_year = (bcd2bin(century) * 100) + bcd2bin(buf[6]) - 1900;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ds1347_set_time(struct device *dev, struct rtc_time *dt)
|
static int ds1347_set_time(struct device *dev, struct rtc_time *dt)
|
||||||
{
|
{
|
||||||
struct spi_device *spi = to_spi_device(dev);
|
struct regmap *map = dev_get_drvdata(dev);
|
||||||
struct regmap *map;
|
unsigned int century;
|
||||||
unsigned char buf[8];
|
unsigned char buf[8];
|
||||||
|
int err;
|
||||||
|
|
||||||
map = spi_get_drvdata(spi);
|
err = regmap_update_bits(map, DS1347_STATUS_REG,
|
||||||
|
DS1347_NEOSC_BIT, DS1347_NEOSC_BIT);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
buf[0] = bin2bcd(dt->tm_sec);
|
buf[0] = bin2bcd(dt->tm_sec);
|
||||||
buf[1] = bin2bcd(dt->tm_min);
|
buf[1] = bin2bcd(dt->tm_min);
|
||||||
|
@ -79,16 +104,20 @@ static int ds1347_set_time(struct device *dev, struct rtc_time *dt)
|
||||||
buf[3] = bin2bcd(dt->tm_mday);
|
buf[3] = bin2bcd(dt->tm_mday);
|
||||||
buf[4] = bin2bcd(dt->tm_mon + 1);
|
buf[4] = bin2bcd(dt->tm_mon + 1);
|
||||||
buf[5] = bin2bcd(dt->tm_wday + 1);
|
buf[5] = bin2bcd(dt->tm_wday + 1);
|
||||||
|
buf[6] = bin2bcd(dt->tm_year % 100);
|
||||||
/* year in linux is from 1900 i.e in range of 100
|
|
||||||
in rtc it is from 00 to 99 */
|
|
||||||
dt->tm_year = dt->tm_year % 100;
|
|
||||||
|
|
||||||
buf[6] = bin2bcd(dt->tm_year);
|
|
||||||
buf[7] = bin2bcd(0x00);
|
buf[7] = bin2bcd(0x00);
|
||||||
|
|
||||||
/* write the rtc settings */
|
err = regmap_bulk_write(map, DS1347_CLOCK_BURST, buf, 8);
|
||||||
return regmap_bulk_write(map, DS1347_CLOCK_BURST, buf, 8);
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
century = (dt->tm_year / 100) + 19;
|
||||||
|
err = regmap_write(map, DS1347_CENTURY_REG, century);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return regmap_update_bits(map, DS1347_STATUS_REG,
|
||||||
|
DS1347_NEOSC_BIT | DS1347_OSF_BIT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct rtc_class_ops ds1347_rtc_ops = {
|
static const struct rtc_class_ops ds1347_rtc_ops = {
|
||||||
|
@ -101,8 +130,7 @@ static int ds1347_probe(struct spi_device *spi)
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
struct regmap_config config;
|
struct regmap_config config;
|
||||||
struct regmap *map;
|
struct regmap *map;
|
||||||
unsigned int data;
|
int err;
|
||||||
int res;
|
|
||||||
|
|
||||||
memset(&config, 0, sizeof(config));
|
memset(&config, 0, sizeof(config));
|
||||||
config.reg_bits = 8;
|
config.reg_bits = 8;
|
||||||
|
@ -125,36 +153,20 @@ static int ds1347_probe(struct spi_device *spi)
|
||||||
|
|
||||||
spi_set_drvdata(spi, map);
|
spi_set_drvdata(spi, map);
|
||||||
|
|
||||||
/* RTC Settings */
|
|
||||||
res = regmap_read(map, DS1347_SECONDS_REG, &data);
|
|
||||||
if (res)
|
|
||||||
return res;
|
|
||||||
|
|
||||||
/* Disable the write protect of rtc */
|
/* Disable the write protect of rtc */
|
||||||
regmap_read(map, DS1347_CONTROL_REG, &data);
|
err = regmap_update_bits(map, DS1347_CONTROL_REG, DS1347_WP_BIT, 0);
|
||||||
data = data & ~(1<<7);
|
if (err)
|
||||||
regmap_write(map, DS1347_CONTROL_REG, data);
|
return err;
|
||||||
|
|
||||||
/* Enable the oscillator , disable the oscillator stop flag,
|
|
||||||
and glitch filter to reduce current consumption */
|
|
||||||
regmap_read(map, DS1347_STATUS_REG, &data);
|
|
||||||
data = data & 0x1B;
|
|
||||||
regmap_write(map, DS1347_STATUS_REG, data);
|
|
||||||
|
|
||||||
/* display the settings */
|
|
||||||
regmap_read(map, DS1347_CONTROL_REG, &data);
|
|
||||||
dev_info(&spi->dev, "DS1347 RTC CTRL Reg = 0x%02x\n", data);
|
|
||||||
|
|
||||||
regmap_read(map, DS1347_STATUS_REG, &data);
|
|
||||||
dev_info(&spi->dev, "DS1347 RTC Status Reg = 0x%02x\n", data);
|
|
||||||
|
|
||||||
rtc = devm_rtc_device_register(&spi->dev, "ds1347",
|
|
||||||
&ds1347_rtc_ops, THIS_MODULE);
|
|
||||||
|
|
||||||
|
rtc = devm_rtc_allocate_device(&spi->dev);
|
||||||
if (IS_ERR(rtc))
|
if (IS_ERR(rtc))
|
||||||
return PTR_ERR(rtc);
|
return PTR_ERR(rtc);
|
||||||
|
|
||||||
return 0;
|
rtc->ops = &ds1347_rtc_ops;
|
||||||
|
rtc->range_min = RTC_TIMESTAMP_BEGIN_0000;
|
||||||
|
rtc->range_max = RTC_TIMESTAMP_END_9999;
|
||||||
|
|
||||||
|
return rtc_register_device(rtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct spi_driver ds1347_driver = {
|
static struct spi_driver ds1347_driver = {
|
||||||
|
|
|
@ -439,14 +439,13 @@ static void ds1374_wdt_ping(void)
|
||||||
|
|
||||||
static void ds1374_wdt_disable(void)
|
static void ds1374_wdt_disable(void)
|
||||||
{
|
{
|
||||||
int ret = -ENOIOCTLCMD;
|
|
||||||
int cr;
|
int cr;
|
||||||
|
|
||||||
cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
|
cr = i2c_smbus_read_byte_data(save_client, DS1374_REG_CR);
|
||||||
/* Disable watchdog timer */
|
/* Disable watchdog timer */
|
||||||
cr &= ~DS1374_REG_CR_WACE;
|
cr &= ~DS1374_REG_CR_WACE;
|
||||||
|
|
||||||
ret = i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
|
i2c_smbus_write_byte_data(save_client, DS1374_REG_CR, cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -414,7 +414,6 @@ static int ds1511_nvram_write(void *priv, unsigned int pos, void *buf,
|
||||||
|
|
||||||
static int ds1511_rtc_probe(struct platform_device *pdev)
|
static int ds1511_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
struct rtc_plat_data *pdata;
|
struct rtc_plat_data *pdata;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct nvmem_config ds1511_nvmem_cfg = {
|
struct nvmem_config ds1511_nvmem_cfg = {
|
||||||
|
@ -431,8 +430,7 @@ static int ds1511_rtc_probe(struct platform_device *pdev)
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
ds1511_base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
ds1511_base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(ds1511_base))
|
if (IS_ERR(ds1511_base))
|
||||||
return PTR_ERR(ds1511_base);
|
return PTR_ERR(ds1511_base);
|
||||||
pdata->ioaddr = ds1511_base;
|
pdata->ioaddr = ds1511_base;
|
||||||
|
|
|
@ -249,7 +249,6 @@ static int ds1553_nvram_write(void *priv, unsigned int pos, void *val,
|
||||||
|
|
||||||
static int ds1553_rtc_probe(struct platform_device *pdev)
|
static int ds1553_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
unsigned int cen, sec;
|
unsigned int cen, sec;
|
||||||
struct rtc_plat_data *pdata;
|
struct rtc_plat_data *pdata;
|
||||||
void __iomem *ioaddr;
|
void __iomem *ioaddr;
|
||||||
|
@ -268,8 +267,7 @@ static int ds1553_rtc_probe(struct platform_device *pdev)
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
ioaddr = devm_platform_ioremap_resource(pdev, 0);
|
||||||
ioaddr = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(ioaddr))
|
if (IS_ERR(ioaddr))
|
||||||
return PTR_ERR(ioaddr);
|
return PTR_ERR(ioaddr);
|
||||||
pdata->ioaddr = ioaddr;
|
pdata->ioaddr = ioaddr;
|
||||||
|
|
|
@ -31,7 +31,10 @@
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Standard read/write functions if platform does not provide overrides */
|
/*
|
||||||
|
* Standard read/write
|
||||||
|
* all registers are mapped in CPU address space
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ds1685_read - read a value from an rtc register.
|
* ds1685_read - read a value from an rtc register.
|
||||||
|
@ -59,6 +62,35 @@ ds1685_write(struct ds1685_priv *rtc, int reg, u8 value)
|
||||||
}
|
}
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Indirect read/write functions
|
||||||
|
* access happens via address and data register mapped in CPU address space
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ds1685_indirect_read - read a value from an rtc register.
|
||||||
|
* @rtc: pointer to the ds1685 rtc structure.
|
||||||
|
* @reg: the register address to read.
|
||||||
|
*/
|
||||||
|
static u8
|
||||||
|
ds1685_indirect_read(struct ds1685_priv *rtc, int reg)
|
||||||
|
{
|
||||||
|
writeb(reg, rtc->regs);
|
||||||
|
return readb(rtc->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ds1685_indirect_write - write a value to an rtc register.
|
||||||
|
* @rtc: pointer to the ds1685 rtc structure.
|
||||||
|
* @reg: the register address to write.
|
||||||
|
* @value: value to write to the register.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
ds1685_indirect_write(struct ds1685_priv *rtc, int reg, u8 value)
|
||||||
|
{
|
||||||
|
writeb(reg, rtc->regs);
|
||||||
|
writeb(value, rtc->data);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
/* Inlined functions */
|
/* Inlined functions */
|
||||||
|
@ -229,7 +261,7 @@ static int
|
||||||
ds1685_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
ds1685_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||||
{
|
{
|
||||||
struct ds1685_priv *rtc = dev_get_drvdata(dev);
|
struct ds1685_priv *rtc = dev_get_drvdata(dev);
|
||||||
u8 ctrlb, century;
|
u8 century;
|
||||||
u8 seconds, minutes, hours, wday, mday, month, years;
|
u8 seconds, minutes, hours, wday, mday, month, years;
|
||||||
|
|
||||||
/* Fetch the time info from the RTC registers. */
|
/* Fetch the time info from the RTC registers. */
|
||||||
|
@ -242,7 +274,6 @@ ds1685_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||||
month = rtc->read(rtc, RTC_MONTH);
|
month = rtc->read(rtc, RTC_MONTH);
|
||||||
years = rtc->read(rtc, RTC_YEAR);
|
years = rtc->read(rtc, RTC_YEAR);
|
||||||
century = rtc->read(rtc, RTC_CENTURY);
|
century = rtc->read(rtc, RTC_CENTURY);
|
||||||
ctrlb = rtc->read(rtc, RTC_CTRL_B);
|
|
||||||
ds1685_rtc_end_data_access(rtc);
|
ds1685_rtc_end_data_access(rtc);
|
||||||
|
|
||||||
/* bcd2bin if needed, perform fixups, and store to rtc_time. */
|
/* bcd2bin if needed, perform fixups, and store to rtc_time. */
|
||||||
|
@ -723,7 +754,7 @@ static int
|
||||||
ds1685_rtc_proc(struct device *dev, struct seq_file *seq)
|
ds1685_rtc_proc(struct device *dev, struct seq_file *seq)
|
||||||
{
|
{
|
||||||
struct ds1685_priv *rtc = dev_get_drvdata(dev);
|
struct ds1685_priv *rtc = dev_get_drvdata(dev);
|
||||||
u8 ctrla, ctrlb, ctrlc, ctrld, ctrl4a, ctrl4b, ssn[8];
|
u8 ctrla, ctrlb, ctrld, ctrl4a, ctrl4b, ssn[8];
|
||||||
char *model;
|
char *model;
|
||||||
|
|
||||||
/* Read all the relevant data from the control registers. */
|
/* Read all the relevant data from the control registers. */
|
||||||
|
@ -731,7 +762,6 @@ ds1685_rtc_proc(struct device *dev, struct seq_file *seq)
|
||||||
ds1685_rtc_get_ssn(rtc, ssn);
|
ds1685_rtc_get_ssn(rtc, ssn);
|
||||||
ctrla = rtc->read(rtc, RTC_CTRL_A);
|
ctrla = rtc->read(rtc, RTC_CTRL_A);
|
||||||
ctrlb = rtc->read(rtc, RTC_CTRL_B);
|
ctrlb = rtc->read(rtc, RTC_CTRL_B);
|
||||||
ctrlc = rtc->read(rtc, RTC_CTRL_C);
|
|
||||||
ctrld = rtc->read(rtc, RTC_CTRL_D);
|
ctrld = rtc->read(rtc, RTC_CTRL_D);
|
||||||
ctrl4a = rtc->read(rtc, RTC_EXT_CTRL_4A);
|
ctrl4a = rtc->read(rtc, RTC_EXT_CTRL_4A);
|
||||||
ctrl4b = rtc->read(rtc, RTC_EXT_CTRL_4B);
|
ctrl4b = rtc->read(rtc, RTC_EXT_CTRL_4B);
|
||||||
|
@ -1009,7 +1039,7 @@ ds1685_rtc_sysfs_serial_show(struct device *dev,
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(serial, S_IRUGO, ds1685_rtc_sysfs_serial_show, NULL);
|
static DEVICE_ATTR(serial, S_IRUGO, ds1685_rtc_sysfs_serial_show, NULL);
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* struct ds1685_rtc_sysfs_misc_attrs - list for misc RTC features.
|
* struct ds1685_rtc_sysfs_misc_attrs - list for misc RTC features.
|
||||||
*/
|
*/
|
||||||
static struct attribute*
|
static struct attribute*
|
||||||
|
@ -1020,7 +1050,7 @@ ds1685_rtc_sysfs_misc_attrs[] = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* struct ds1685_rtc_sysfs_misc_grp - attr group for misc RTC features.
|
* struct ds1685_rtc_sysfs_misc_grp - attr group for misc RTC features.
|
||||||
*/
|
*/
|
||||||
static const struct attribute_group
|
static const struct attribute_group
|
||||||
|
@ -1040,7 +1070,6 @@ static int
|
||||||
ds1685_rtc_probe(struct platform_device *pdev)
|
ds1685_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct rtc_device *rtc_dev;
|
struct rtc_device *rtc_dev;
|
||||||
struct resource *res;
|
|
||||||
struct ds1685_priv *rtc;
|
struct ds1685_priv *rtc;
|
||||||
struct ds1685_rtc_platform_data *pdata;
|
struct ds1685_rtc_platform_data *pdata;
|
||||||
u8 ctrla, ctrlb, hours;
|
u8 ctrla, ctrlb, hours;
|
||||||
|
@ -1063,35 +1092,29 @@ ds1685_rtc_probe(struct platform_device *pdev)
|
||||||
if (!rtc)
|
if (!rtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
/*
|
/* Setup resources and access functions */
|
||||||
* Allocate/setup any IORESOURCE_MEM resources, if required. Not all
|
switch (pdata->access_type) {
|
||||||
* platforms put the RTC in an easy-access place. Like the SGI Octane,
|
case ds1685_reg_direct:
|
||||||
* which attaches the RTC to a "ByteBus", hooked to a SuperIO chip
|
rtc->regs = devm_platform_ioremap_resource(pdev, 0);
|
||||||
* that sits behind the IOC3 PCI metadevice.
|
if (IS_ERR(rtc->regs))
|
||||||
*/
|
return PTR_ERR(rtc->regs);
|
||||||
if (pdata->alloc_io_resources) {
|
rtc->read = ds1685_read;
|
||||||
/* Get the platform resources. */
|
rtc->write = ds1685_write;
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
break;
|
||||||
if (!res)
|
case ds1685_reg_indirect:
|
||||||
return -ENXIO;
|
rtc->regs = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->size = resource_size(res);
|
if (IS_ERR(rtc->regs))
|
||||||
|
return PTR_ERR(rtc->regs);
|
||||||
/* Request a memory region. */
|
rtc->data = devm_platform_ioremap_resource(pdev, 1);
|
||||||
/* XXX: mmio-only for now. */
|
if (IS_ERR(rtc->data))
|
||||||
if (!devm_request_mem_region(&pdev->dev, res->start, rtc->size,
|
return PTR_ERR(rtc->data);
|
||||||
pdev->name))
|
rtc->read = ds1685_indirect_read;
|
||||||
return -EBUSY;
|
rtc->write = ds1685_indirect_write;
|
||||||
|
break;
|
||||||
/*
|
|
||||||
* Set the base address for the rtc, and ioremap its
|
|
||||||
* registers.
|
|
||||||
*/
|
|
||||||
rtc->baseaddr = res->start;
|
|
||||||
rtc->regs = devm_ioremap(&pdev->dev, res->start, rtc->size);
|
|
||||||
if (!rtc->regs)
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
rtc->alloc_io_resources = pdata->alloc_io_resources;
|
|
||||||
|
if (!rtc->read || !rtc->write)
|
||||||
|
return -ENXIO;
|
||||||
|
|
||||||
/* Get the register step size. */
|
/* Get the register step size. */
|
||||||
if (pdata->regstep > 0)
|
if (pdata->regstep > 0)
|
||||||
|
@ -1099,24 +1122,6 @@ ds1685_rtc_probe(struct platform_device *pdev)
|
||||||
else
|
else
|
||||||
rtc->regstep = 1;
|
rtc->regstep = 1;
|
||||||
|
|
||||||
/* Platform read function, else default if mmio setup */
|
|
||||||
if (pdata->plat_read)
|
|
||||||
rtc->read = pdata->plat_read;
|
|
||||||
else
|
|
||||||
if (pdata->alloc_io_resources)
|
|
||||||
rtc->read = ds1685_read;
|
|
||||||
else
|
|
||||||
return -ENXIO;
|
|
||||||
|
|
||||||
/* Platform write function, else default if mmio setup */
|
|
||||||
if (pdata->plat_write)
|
|
||||||
rtc->write = pdata->plat_write;
|
|
||||||
else
|
|
||||||
if (pdata->alloc_io_resources)
|
|
||||||
rtc->write = ds1685_write;
|
|
||||||
else
|
|
||||||
return -ENXIO;
|
|
||||||
|
|
||||||
/* Platform pre-shutdown function, if defined. */
|
/* Platform pre-shutdown function, if defined. */
|
||||||
if (pdata->plat_prepare_poweroff)
|
if (pdata->plat_prepare_poweroff)
|
||||||
rtc->prepare_poweroff = pdata->plat_prepare_poweroff;
|
rtc->prepare_poweroff = pdata->plat_prepare_poweroff;
|
||||||
|
@ -1271,7 +1276,6 @@ ds1685_rtc_probe(struct platform_device *pdev)
|
||||||
/* See if the platform doesn't support UIE. */
|
/* See if the platform doesn't support UIE. */
|
||||||
if (pdata->uie_unsupported)
|
if (pdata->uie_unsupported)
|
||||||
rtc_dev->uie_unsupported = 1;
|
rtc_dev->uie_unsupported = 1;
|
||||||
rtc->uie_unsupported = pdata->uie_unsupported;
|
|
||||||
|
|
||||||
rtc->dev = rtc_dev;
|
rtc->dev = rtc_dev;
|
||||||
|
|
||||||
|
@ -1351,7 +1355,7 @@ ds1685_rtc_remove(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* ds1685_rtc_driver - rtc driver properties.
|
* ds1685_rtc_driver - rtc driver properties.
|
||||||
*/
|
*/
|
||||||
static struct platform_driver ds1685_rtc_driver = {
|
static struct platform_driver ds1685_rtc_driver = {
|
||||||
|
|
|
@ -71,7 +71,7 @@ static int em3027_get_time(struct device *dev, struct rtc_time *tm)
|
||||||
tm->tm_hour = bcd2bin(buf[2]);
|
tm->tm_hour = bcd2bin(buf[2]);
|
||||||
tm->tm_mday = bcd2bin(buf[3]);
|
tm->tm_mday = bcd2bin(buf[3]);
|
||||||
tm->tm_wday = bcd2bin(buf[4]);
|
tm->tm_wday = bcd2bin(buf[4]);
|
||||||
tm->tm_mon = bcd2bin(buf[5]);
|
tm->tm_mon = bcd2bin(buf[5]) - 1;
|
||||||
tm->tm_year = bcd2bin(buf[6]) + 100;
|
tm->tm_year = bcd2bin(buf[6]) + 100;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -94,7 +94,7 @@ static int em3027_set_time(struct device *dev, struct rtc_time *tm)
|
||||||
buf[3] = bin2bcd(tm->tm_hour);
|
buf[3] = bin2bcd(tm->tm_hour);
|
||||||
buf[4] = bin2bcd(tm->tm_mday);
|
buf[4] = bin2bcd(tm->tm_mday);
|
||||||
buf[5] = bin2bcd(tm->tm_wday);
|
buf[5] = bin2bcd(tm->tm_wday);
|
||||||
buf[6] = bin2bcd(tm->tm_mon);
|
buf[6] = bin2bcd(tm->tm_mon + 1);
|
||||||
buf[7] = bin2bcd(tm->tm_year % 100);
|
buf[7] = bin2bcd(tm->tm_year % 100);
|
||||||
|
|
||||||
/* write time/date registers */
|
/* write time/date registers */
|
||||||
|
|
|
@ -122,15 +122,13 @@ static const struct attribute_group ep93xx_rtc_sysfs_files = {
|
||||||
static int ep93xx_rtc_probe(struct platform_device *pdev)
|
static int ep93xx_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct ep93xx_rtc *ep93xx_rtc;
|
struct ep93xx_rtc *ep93xx_rtc;
|
||||||
struct resource *res;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL);
|
ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL);
|
||||||
if (!ep93xx_rtc)
|
if (!ep93xx_rtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
ep93xx_rtc->mmio_base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
ep93xx_rtc->mmio_base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(ep93xx_rtc->mmio_base))
|
if (IS_ERR(ep93xx_rtc->mmio_base))
|
||||||
return PTR_ERR(ep93xx_rtc->mmio_base);
|
return PTR_ERR(ep93xx_rtc->mmio_base);
|
||||||
|
|
||||||
|
|
|
@ -180,10 +180,7 @@ static int ftm_rtc_alarm_irq_enable(struct device *dev,
|
||||||
*/
|
*/
|
||||||
static int ftm_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
static int ftm_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||||
{
|
{
|
||||||
struct timespec64 ts64;
|
rtc_time64_to_tm(ktime_get_real_seconds(), tm);
|
||||||
|
|
||||||
ktime_get_real_ts64(&ts64);
|
|
||||||
rtc_time_to_tm(ts64.tv_sec, tm);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -206,16 +203,14 @@ static int ftm_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
|
||||||
*/
|
*/
|
||||||
static int ftm_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
|
static int ftm_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
|
||||||
{
|
{
|
||||||
struct rtc_time tm;
|
time64_t alm_time;
|
||||||
unsigned long now, alm_time, cycle;
|
unsigned long long cycle;
|
||||||
struct ftm_rtc *rtc = dev_get_drvdata(dev);
|
struct ftm_rtc *rtc = dev_get_drvdata(dev);
|
||||||
|
|
||||||
ftm_rtc_read_time(dev, &tm);
|
alm_time = rtc_tm_to_time64(&alm->time);
|
||||||
rtc_tm_to_time(&tm, &now);
|
|
||||||
rtc_tm_to_time(&alm->time, &alm_time);
|
|
||||||
|
|
||||||
ftm_clean_alarm(rtc);
|
ftm_clean_alarm(rtc);
|
||||||
cycle = (alm_time - now) * rtc->alarm_freq;
|
cycle = (alm_time - ktime_get_real_seconds()) * rtc->alarm_freq;
|
||||||
if (cycle > MAX_COUNT_VAL) {
|
if (cycle > MAX_COUNT_VAL) {
|
||||||
pr_err("Out of alarm range {0~262} seconds.\n");
|
pr_err("Out of alarm range {0~262} seconds.\n");
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
@ -248,7 +243,6 @@ static const struct rtc_class_ops ftm_rtc_ops = {
|
||||||
static int ftm_rtc_probe(struct platform_device *pdev)
|
static int ftm_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
struct resource *r;
|
|
||||||
int irq;
|
int irq;
|
||||||
int ret;
|
int ret;
|
||||||
struct ftm_rtc *rtc;
|
struct ftm_rtc *rtc;
|
||||||
|
@ -265,13 +259,7 @@ static int ftm_rtc_probe(struct platform_device *pdev)
|
||||||
if (IS_ERR(rtc->rtc_dev))
|
if (IS_ERR(rtc->rtc_dev))
|
||||||
return PTR_ERR(rtc->rtc_dev);
|
return PTR_ERR(rtc->rtc_dev);
|
||||||
|
|
||||||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (!r) {
|
|
||||||
dev_err(&pdev->dev, "cannot get resource for rtc\n");
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc->base = devm_ioremap_resource(&pdev->dev, r);
|
|
||||||
if (IS_ERR(rtc->base)) {
|
if (IS_ERR(rtc->base)) {
|
||||||
dev_err(&pdev->dev, "cannot ioremap resource for rtc\n");
|
dev_err(&pdev->dev, "cannot ioremap resource for rtc\n");
|
||||||
return PTR_ERR(rtc->base);
|
return PTR_ERR(rtc->base);
|
||||||
|
|
|
@ -165,7 +165,6 @@ static const struct rtc_class_ops goldfish_rtc_ops = {
|
||||||
static int goldfish_rtc_probe(struct platform_device *pdev)
|
static int goldfish_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct goldfish_rtc *rtcdrv;
|
struct goldfish_rtc *rtcdrv;
|
||||||
struct resource *r;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
rtcdrv = devm_kzalloc(&pdev->dev, sizeof(*rtcdrv), GFP_KERNEL);
|
rtcdrv = devm_kzalloc(&pdev->dev, sizeof(*rtcdrv), GFP_KERNEL);
|
||||||
|
@ -173,12 +172,7 @@ static int goldfish_rtc_probe(struct platform_device *pdev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, rtcdrv);
|
platform_set_drvdata(pdev, rtcdrv);
|
||||||
|
rtcdrv->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
||||||
if (!r)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
rtcdrv->base = devm_ioremap_resource(&pdev->dev, r);
|
|
||||||
if (IS_ERR(rtcdrv->base))
|
if (IS_ERR(rtcdrv->base))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,6 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct jz4740_rtc *rtc;
|
struct jz4740_rtc *rtc;
|
||||||
struct resource *mem;
|
|
||||||
const struct platform_device_id *id = platform_get_device_id(pdev);
|
const struct platform_device_id *id = platform_get_device_id(pdev);
|
||||||
const struct of_device_id *of_id = of_match_device(
|
const struct of_device_id *of_id = of_match_device(
|
||||||
jz4740_rtc_of_match, &pdev->dev);
|
jz4740_rtc_of_match, &pdev->dev);
|
||||||
|
@ -326,8 +325,7 @@ static int jz4740_rtc_probe(struct platform_device *pdev)
|
||||||
if (rtc->irq < 0)
|
if (rtc->irq < 0)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
|
|
||||||
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->base = devm_ioremap_resource(&pdev->dev, mem);
|
|
||||||
if (IS_ERR(rtc->base))
|
if (IS_ERR(rtc->base))
|
||||||
return PTR_ERR(rtc->base);
|
return PTR_ERR(rtc->base);
|
||||||
|
|
||||||
|
|
|
@ -194,15 +194,13 @@ static const struct rtc_class_ops lpc24xx_rtc_ops = {
|
||||||
static int lpc24xx_rtc_probe(struct platform_device *pdev)
|
static int lpc24xx_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct lpc24xx_rtc *rtc;
|
struct lpc24xx_rtc *rtc;
|
||||||
struct resource *res;
|
|
||||||
int irq, ret;
|
int irq, ret;
|
||||||
|
|
||||||
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
|
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
|
||||||
if (!rtc)
|
if (!rtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->rtc_base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->rtc_base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(rtc->rtc_base))
|
if (IS_ERR(rtc->rtc_base))
|
||||||
return PTR_ERR(rtc->rtc_base);
|
return PTR_ERR(rtc->rtc_base);
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,6 @@ static const struct rtc_class_ops lpc32xx_rtc_ops = {
|
||||||
|
|
||||||
static int lpc32xx_rtc_probe(struct platform_device *pdev)
|
static int lpc32xx_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
struct lpc32xx_rtc *rtc;
|
struct lpc32xx_rtc *rtc;
|
||||||
int err;
|
int err;
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
|
@ -194,8 +193,7 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev)
|
||||||
if (unlikely(!rtc))
|
if (unlikely(!rtc))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->rtc_base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->rtc_base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(rtc->rtc_base))
|
if (IS_ERR(rtc->rtc_base))
|
||||||
return PTR_ERR(rtc->rtc_base);
|
return PTR_ERR(rtc->rtc_base);
|
||||||
|
|
||||||
|
@ -266,16 +264,6 @@ static int lpc32xx_rtc_probe(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lpc32xx_rtc_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
struct lpc32xx_rtc *rtc = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
if (rtc->irq >= 0)
|
|
||||||
device_init_wakeup(&pdev->dev, 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
static int lpc32xx_rtc_suspend(struct device *dev)
|
static int lpc32xx_rtc_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
|
@ -357,7 +345,6 @@ MODULE_DEVICE_TABLE(of, lpc32xx_rtc_match);
|
||||||
|
|
||||||
static struct platform_driver lpc32xx_rtc_driver = {
|
static struct platform_driver lpc32xx_rtc_driver = {
|
||||||
.probe = lpc32xx_rtc_probe,
|
.probe = lpc32xx_rtc_probe,
|
||||||
.remove = lpc32xx_rtc_remove,
|
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "rtc-lpc32xx",
|
.name = "rtc-lpc32xx",
|
||||||
.pm = LPC32XX_RTC_PM_OPS,
|
.pm = LPC32XX_RTC_PM_OPS,
|
||||||
|
|
|
@ -235,9 +235,6 @@ static int m41t80_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
||||||
unsigned char buf[8];
|
unsigned char buf[8];
|
||||||
int err, flags;
|
int err, flags;
|
||||||
|
|
||||||
if (tm->tm_year < 100 || tm->tm_year > 199)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
buf[M41T80_REG_SSEC] = 0;
|
buf[M41T80_REG_SSEC] = 0;
|
||||||
buf[M41T80_REG_SEC] = bin2bcd(tm->tm_sec);
|
buf[M41T80_REG_SEC] = bin2bcd(tm->tm_sec);
|
||||||
buf[M41T80_REG_MIN] = bin2bcd(tm->tm_min);
|
buf[M41T80_REG_MIN] = bin2bcd(tm->tm_min);
|
||||||
|
@ -705,7 +702,6 @@ static ssize_t wdt_read(struct file *file, char __user *buf,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wdt_ioctl:
|
* wdt_ioctl:
|
||||||
* @inode: inode of the device
|
|
||||||
* @file: file handle to the device
|
* @file: file handle to the device
|
||||||
* @cmd: watchdog command
|
* @cmd: watchdog command
|
||||||
* @arg: argument pointer
|
* @arg: argument pointer
|
||||||
|
@ -926,6 +922,8 @@ static int m41t80_probe(struct i2c_client *client,
|
||||||
}
|
}
|
||||||
|
|
||||||
m41t80_data->rtc->ops = &m41t80_rtc_ops;
|
m41t80_data->rtc->ops = &m41t80_rtc_ops;
|
||||||
|
m41t80_data->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||||
|
m41t80_data->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||||
|
|
||||||
if (client->irq <= 0) {
|
if (client->irq <= 0) {
|
||||||
/* We cannot support UIE mode if we do not have an IRQ line */
|
/* We cannot support UIE mode if we do not have an IRQ line */
|
||||||
|
|
|
@ -218,7 +218,6 @@ static bool m48t86_verify_chip(struct platform_device *pdev)
|
||||||
static int m48t86_rtc_probe(struct platform_device *pdev)
|
static int m48t86_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct m48t86_rtc_info *info;
|
struct m48t86_rtc_info *info;
|
||||||
struct resource *res;
|
|
||||||
unsigned char reg;
|
unsigned char reg;
|
||||||
int err;
|
int err;
|
||||||
struct nvmem_config m48t86_nvmem_cfg = {
|
struct nvmem_config m48t86_nvmem_cfg = {
|
||||||
|
@ -235,17 +234,11 @@ static int m48t86_rtc_probe(struct platform_device *pdev)
|
||||||
if (!info)
|
if (!info)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
info->index_reg = devm_platform_ioremap_resource(pdev, 0);
|
||||||
if (!res)
|
|
||||||
return -ENODEV;
|
|
||||||
info->index_reg = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(info->index_reg))
|
if (IS_ERR(info->index_reg))
|
||||||
return PTR_ERR(info->index_reg);
|
return PTR_ERR(info->index_reg);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
info->data_reg = devm_platform_ioremap_resource(pdev, 1);
|
||||||
if (!res)
|
|
||||||
return -ENODEV;
|
|
||||||
info->data_reg = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(info->data_reg))
|
if (IS_ERR(info->data_reg))
|
||||||
return PTR_ERR(info->data_reg);
|
return PTR_ERR(info->data_reg);
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,20 @@ int mc146818_set_time(struct rtc_time *time)
|
||||||
save_control = CMOS_READ(RTC_CONTROL);
|
save_control = CMOS_READ(RTC_CONTROL);
|
||||||
CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
|
CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
|
||||||
save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
|
save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
|
||||||
CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
|
|
||||||
|
#ifdef CONFIG_X86
|
||||||
|
if ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
|
||||||
|
boot_cpu_data.x86 == 0x17) ||
|
||||||
|
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) {
|
||||||
|
CMOS_WRITE((save_freq_select & (~RTC_DIV_RESET2)),
|
||||||
|
RTC_FREQ_SELECT);
|
||||||
|
save_freq_select &= ~RTC_DIV_RESET2;
|
||||||
|
} else
|
||||||
|
CMOS_WRITE((save_freq_select | RTC_DIV_RESET2),
|
||||||
|
RTC_FREQ_SELECT);
|
||||||
|
#else
|
||||||
|
CMOS_WRITE((save_freq_select | RTC_DIV_RESET2), RTC_FREQ_SELECT);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_MACH_DECSTATION
|
#ifdef CONFIG_MACH_DECSTATION
|
||||||
CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
|
CMOS_WRITE(real_yrs, RTC_DEC_YEAR);
|
||||||
|
|
|
@ -131,7 +131,7 @@ static u32 meson_rtc_get_data(struct meson_rtc *rtc)
|
||||||
|
|
||||||
static int meson_rtc_get_bus(struct meson_rtc *rtc)
|
static int meson_rtc_get_bus(struct meson_rtc *rtc)
|
||||||
{
|
{
|
||||||
int ret, retries = 3;
|
int ret, retries;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
/* prepare bus for transfers, set all lines low */
|
/* prepare bus for transfers, set all lines low */
|
||||||
|
@ -292,7 +292,6 @@ static int meson_rtc_probe(struct platform_device *pdev)
|
||||||
};
|
};
|
||||||
struct device *dev = &pdev->dev;
|
struct device *dev = &pdev->dev;
|
||||||
struct meson_rtc *rtc;
|
struct meson_rtc *rtc;
|
||||||
struct resource *res;
|
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
int ret;
|
int ret;
|
||||||
u32 tm;
|
u32 tm;
|
||||||
|
@ -312,8 +311,7 @@ static int meson_rtc_probe(struct platform_device *pdev)
|
||||||
rtc->rtc->ops = &meson_rtc_ops;
|
rtc->rtc->ops = &meson_rtc_ops;
|
||||||
rtc->rtc->range_max = U32_MAX;
|
rtc->rtc->range_max = U32_MAX;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
base = devm_ioremap_resource(dev, res);
|
|
||||||
if (IS_ERR(base))
|
if (IS_ERR(base))
|
||||||
return PTR_ERR(base);
|
return PTR_ERR(base);
|
||||||
|
|
||||||
|
|
|
@ -88,28 +88,16 @@ static inline void msm6242_write(struct msm6242_priv *priv, unsigned int val,
|
||||||
__raw_writel(val, &priv->regs[reg]);
|
__raw_writel(val, &priv->regs[reg]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void msm6242_set(struct msm6242_priv *priv, unsigned int val,
|
|
||||||
unsigned int reg)
|
|
||||||
{
|
|
||||||
msm6242_write(priv, msm6242_read(priv, reg) | val, reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void msm6242_clear(struct msm6242_priv *priv, unsigned int val,
|
|
||||||
unsigned int reg)
|
|
||||||
{
|
|
||||||
msm6242_write(priv, msm6242_read(priv, reg) & ~val, reg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void msm6242_lock(struct msm6242_priv *priv)
|
static void msm6242_lock(struct msm6242_priv *priv)
|
||||||
{
|
{
|
||||||
int cnt = 5;
|
int cnt = 5;
|
||||||
|
|
||||||
msm6242_set(priv, MSM6242_CD_HOLD, MSM6242_CD);
|
msm6242_write(priv, MSM6242_CD_HOLD|MSM6242_CD_IRQ_FLAG, MSM6242_CD);
|
||||||
|
|
||||||
while ((msm6242_read(priv, MSM6242_CD) & MSM6242_CD_BUSY) && cnt) {
|
while ((msm6242_read(priv, MSM6242_CD) & MSM6242_CD_BUSY) && cnt) {
|
||||||
msm6242_clear(priv, MSM6242_CD_HOLD, MSM6242_CD);
|
msm6242_write(priv, MSM6242_CD_IRQ_FLAG, MSM6242_CD);
|
||||||
udelay(70);
|
udelay(70);
|
||||||
msm6242_set(priv, MSM6242_CD_HOLD, MSM6242_CD);
|
msm6242_write(priv, MSM6242_CD_HOLD|MSM6242_CD_IRQ_FLAG, MSM6242_CD);
|
||||||
cnt--;
|
cnt--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +108,7 @@ static void msm6242_lock(struct msm6242_priv *priv)
|
||||||
|
|
||||||
static void msm6242_unlock(struct msm6242_priv *priv)
|
static void msm6242_unlock(struct msm6242_priv *priv)
|
||||||
{
|
{
|
||||||
msm6242_clear(priv, MSM6242_CD_HOLD, MSM6242_CD);
|
msm6242_write(priv, MSM6242_CD_IRQ_FLAG, MSM6242_CD);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int msm6242_read_time(struct device *dev, struct rtc_time *tm)
|
static int msm6242_read_time(struct device *dev, struct rtc_time *tm)
|
||||||
|
@ -133,7 +121,8 @@ static int msm6242_read_time(struct device *dev, struct rtc_time *tm)
|
||||||
msm6242_read(priv, MSM6242_SECOND1);
|
msm6242_read(priv, MSM6242_SECOND1);
|
||||||
tm->tm_min = msm6242_read(priv, MSM6242_MINUTE10) * 10 +
|
tm->tm_min = msm6242_read(priv, MSM6242_MINUTE10) * 10 +
|
||||||
msm6242_read(priv, MSM6242_MINUTE1);
|
msm6242_read(priv, MSM6242_MINUTE1);
|
||||||
tm->tm_hour = (msm6242_read(priv, MSM6242_HOUR10 & 3)) * 10 +
|
tm->tm_hour = (msm6242_read(priv, MSM6242_HOUR10) &
|
||||||
|
MSM6242_HOUR10_HR_MASK) * 10 +
|
||||||
msm6242_read(priv, MSM6242_HOUR1);
|
msm6242_read(priv, MSM6242_HOUR1);
|
||||||
tm->tm_mday = msm6242_read(priv, MSM6242_DAY10) * 10 +
|
tm->tm_mday = msm6242_read(priv, MSM6242_DAY10) * 10 +
|
||||||
msm6242_read(priv, MSM6242_DAY1);
|
msm6242_read(priv, MSM6242_DAY1);
|
||||||
|
|
|
@ -303,7 +303,6 @@ MODULE_DEVICE_TABLE(of, mtk_rtc_match);
|
||||||
static int mtk_rtc_probe(struct platform_device *pdev)
|
static int mtk_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct mtk_rtc *hw;
|
struct mtk_rtc *hw;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
|
hw = devm_kzalloc(&pdev->dev, sizeof(*hw), GFP_KERNEL);
|
||||||
|
@ -312,8 +311,7 @@ static int mtk_rtc_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
platform_set_drvdata(pdev, hw);
|
platform_set_drvdata(pdev, hw);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
hw->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
hw->base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(hw->base))
|
if (IS_ERR(hw->base))
|
||||||
return PTR_ERR(hw->base);
|
return PTR_ERR(hw->base);
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,6 @@ static const struct rtc_class_ops mv_rtc_alarm_ops = {
|
||||||
|
|
||||||
static int __init mv_rtc_probe(struct platform_device *pdev)
|
static int __init mv_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
struct rtc_plat_data *pdata;
|
struct rtc_plat_data *pdata;
|
||||||
u32 rtc_time;
|
u32 rtc_time;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -221,8 +220,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev)
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
pdata->ioaddr = devm_platform_ioremap_resource(pdev, 0);
|
||||||
pdata->ioaddr = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(pdata->ioaddr))
|
if (IS_ERR(pdata->ioaddr))
|
||||||
return PTR_ERR(pdata->ioaddr);
|
return PTR_ERR(pdata->ioaddr);
|
||||||
|
|
||||||
|
|
|
@ -727,7 +727,6 @@ static struct nvmem_config omap_rtc_nvmem_config = {
|
||||||
static int omap_rtc_probe(struct platform_device *pdev)
|
static int omap_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct omap_rtc *rtc;
|
struct omap_rtc *rtc;
|
||||||
struct resource *res;
|
|
||||||
u8 reg, mask, new_ctrl;
|
u8 reg, mask, new_ctrl;
|
||||||
const struct platform_device_id *id_entry;
|
const struct platform_device_id *id_entry;
|
||||||
const struct of_device_id *of_id;
|
const struct of_device_id *of_id;
|
||||||
|
@ -764,8 +763,7 @@ static int omap_rtc_probe(struct platform_device *pdev)
|
||||||
if (!IS_ERR(rtc->clk))
|
if (!IS_ERR(rtc->clk))
|
||||||
clk_prepare_enable(rtc->clk);
|
clk_prepare_enable(rtc->clk);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(rtc->base)) {
|
if (IS_ERR(rtc->base)) {
|
||||||
clk_disable_unprepare(rtc->clk);
|
clk_disable_unprepare(rtc->clk);
|
||||||
return PTR_ERR(rtc->base);
|
return PTR_ERR(rtc->base);
|
||||||
|
|
|
@ -417,6 +417,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||||
const char *name, bool has_nvmem)
|
const char *name, bool has_nvmem)
|
||||||
{
|
{
|
||||||
struct pcf2127 *pcf2127;
|
struct pcf2127 *pcf2127;
|
||||||
|
u32 wdd_timeout;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
dev_dbg(dev, "%s\n", __func__);
|
dev_dbg(dev, "%s\n", __func__);
|
||||||
|
@ -459,7 +460,6 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||||
/*
|
/*
|
||||||
* Watchdog timer enabled and reset pin /RST activated when timed out.
|
* Watchdog timer enabled and reset pin /RST activated when timed out.
|
||||||
* Select 1Hz clock source for watchdog timer.
|
* Select 1Hz clock source for watchdog timer.
|
||||||
* Timer is not started until WD_VAL is loaded with a valid value.
|
|
||||||
* Note: Countdown timer disabled and not available.
|
* Note: Countdown timer disabled and not available.
|
||||||
*/
|
*/
|
||||||
ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
|
ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL,
|
||||||
|
@ -475,6 +475,14 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Test if watchdog timer is started by bootloader */
|
||||||
|
ret = regmap_read(pcf2127->regmap, PCF2127_REG_WD_VAL, &wdd_timeout);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (wdd_timeout)
|
||||||
|
set_bit(WDOG_HW_RUNNING, &pcf2127->wdd.status);
|
||||||
|
|
||||||
#ifdef CONFIG_WATCHDOG
|
#ifdef CONFIG_WATCHDOG
|
||||||
ret = devm_watchdog_register_device(dev, &pcf2127->wdd);
|
ret = devm_watchdog_register_device(dev, &pcf2127->wdd);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -35,10 +35,6 @@
|
||||||
#define REG_OFFSET 0x0e
|
#define REG_OFFSET 0x0e
|
||||||
#define REG_OFFSET_MODE BIT(7)
|
#define REG_OFFSET_MODE BIT(7)
|
||||||
|
|
||||||
struct pcf8523 {
|
|
||||||
struct rtc_device *rtc;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int pcf8523_read(struct i2c_client *client, u8 reg, u8 *valuep)
|
static int pcf8523_read(struct i2c_client *client, u8 reg, u8 *valuep)
|
||||||
{
|
{
|
||||||
struct i2c_msg msgs[2];
|
struct i2c_msg msgs[2];
|
||||||
|
@ -345,16 +341,12 @@ static const struct rtc_class_ops pcf8523_rtc_ops = {
|
||||||
static int pcf8523_probe(struct i2c_client *client,
|
static int pcf8523_probe(struct i2c_client *client,
|
||||||
const struct i2c_device_id *id)
|
const struct i2c_device_id *id)
|
||||||
{
|
{
|
||||||
struct pcf8523 *pcf;
|
struct rtc_device *rtc;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
|
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
pcf = devm_kzalloc(&client->dev, sizeof(*pcf), GFP_KERNEL);
|
|
||||||
if (!pcf)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
err = pcf8523_load_capacitance(client);
|
err = pcf8523_load_capacitance(client);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
dev_warn(&client->dev, "failed to set xtal load capacitance: %d",
|
dev_warn(&client->dev, "failed to set xtal load capacitance: %d",
|
||||||
|
@ -364,12 +356,10 @@ static int pcf8523_probe(struct i2c_client *client,
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
pcf->rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME,
|
rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME,
|
||||||
&pcf8523_rtc_ops, THIS_MODULE);
|
&pcf8523_rtc_ops, THIS_MODULE);
|
||||||
if (IS_ERR(pcf->rtc))
|
if (IS_ERR(rtc))
|
||||||
return PTR_ERR(pcf->rtc);
|
return PTR_ERR(rtc);
|
||||||
|
|
||||||
i2c_set_clientdata(client, pcf);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -390,7 +390,7 @@ static int pcf8563_irq_enable(struct device *dev, unsigned int enabled)
|
||||||
|
|
||||||
#define clkout_hw_to_pcf8563(_hw) container_of(_hw, struct pcf8563, clkout_hw)
|
#define clkout_hw_to_pcf8563(_hw) container_of(_hw, struct pcf8563, clkout_hw)
|
||||||
|
|
||||||
static int clkout_rates[] = {
|
static const int clkout_rates[] = {
|
||||||
32768,
|
32768,
|
||||||
1024,
|
1024,
|
||||||
32,
|
32,
|
||||||
|
|
|
@ -298,7 +298,6 @@ static int pic32_rtc_remove(struct platform_device *pdev)
|
||||||
static int pic32_rtc_probe(struct platform_device *pdev)
|
static int pic32_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct pic32_rtc_dev *pdata;
|
struct pic32_rtc_dev *pdata;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
||||||
|
@ -311,8 +310,7 @@ static int pic32_rtc_probe(struct platform_device *pdev)
|
||||||
if (pdata->alarm_irq < 0)
|
if (pdata->alarm_irq < 0)
|
||||||
return pdata->alarm_irq;
|
return pdata->alarm_irq;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
pdata->reg_base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
pdata->reg_base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(pdata->reg_base))
|
if (IS_ERR(pdata->reg_base))
|
||||||
return PTR_ERR(pdata->reg_base);
|
return PTR_ERR(pdata->reg_base);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct pm8xxx_rtc_regs {
|
||||||
* @regmap: regmap used to access RTC registers
|
* @regmap: regmap used to access RTC registers
|
||||||
* @allow_set_time: indicates whether writing to the RTC is allowed
|
* @allow_set_time: indicates whether writing to the RTC is allowed
|
||||||
* @rtc_alarm_irq: rtc alarm irq number.
|
* @rtc_alarm_irq: rtc alarm irq number.
|
||||||
* @ctrl_reg: rtc control register.
|
* @regs: rtc registers description.
|
||||||
* @rtc_dev: device structure.
|
* @rtc_dev: device structure.
|
||||||
* @ctrl_reg_lock: spinlock protecting access to ctrl_reg.
|
* @ctrl_reg_lock: spinlock protecting access to ctrl_reg.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -354,21 +354,16 @@ static void rtc7301_init(struct rtc7301_priv *priv)
|
||||||
|
|
||||||
static int __init rtc7301_rtc_probe(struct platform_device *dev)
|
static int __init rtc7301_rtc_probe(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
void __iomem *regs;
|
void __iomem *regs;
|
||||||
struct rtc7301_priv *priv;
|
struct rtc7301_priv *priv;
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
res = platform_get_resource(dev, IORESOURCE_MEM, 0);
|
|
||||||
if (!res)
|
|
||||||
return -ENODEV;
|
|
||||||
|
|
||||||
priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
|
priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
regs = devm_ioremap_resource(&dev->dev, res);
|
regs = devm_platform_ioremap_resource(dev, 0);
|
||||||
if (IS_ERR(regs))
|
if (IS_ERR(regs))
|
||||||
return PTR_ERR(regs);
|
return PTR_ERR(regs);
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,6 @@ static const struct of_device_id rtd119x_rtc_dt_ids[] = {
|
||||||
static int rtd119x_rtc_probe(struct platform_device *pdev)
|
static int rtd119x_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct rtd119x_rtc *data;
|
struct rtd119x_rtc *data;
|
||||||
struct resource *res;
|
|
||||||
u32 val;
|
u32 val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -178,8 +177,7 @@ static int rtd119x_rtc_probe(struct platform_device *pdev)
|
||||||
platform_set_drvdata(pdev, data);
|
platform_set_drvdata(pdev, data);
|
||||||
data->base_year = 2014;
|
data->base_year = 2014;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
data->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
data->base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(data->base))
|
if (IS_ERR(data->base))
|
||||||
return PTR_ERR(data->base);
|
return PTR_ERR(data->base);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <linux/clk-provider.h>
|
||||||
#include <linux/bcd.h>
|
#include <linux/bcd.h>
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
|
@ -52,6 +53,11 @@
|
||||||
#define RV3028_STATUS_CLKF BIT(6)
|
#define RV3028_STATUS_CLKF BIT(6)
|
||||||
#define RV3028_STATUS_EEBUSY BIT(7)
|
#define RV3028_STATUS_EEBUSY BIT(7)
|
||||||
|
|
||||||
|
#define RV3028_CLKOUT_FD_MASK GENMASK(2, 0)
|
||||||
|
#define RV3028_CLKOUT_PORIE BIT(3)
|
||||||
|
#define RV3028_CLKOUT_CLKSY BIT(6)
|
||||||
|
#define RV3028_CLKOUT_CLKOE BIT(7)
|
||||||
|
|
||||||
#define RV3028_CTRL1_EERD BIT(3)
|
#define RV3028_CTRL1_EERD BIT(3)
|
||||||
#define RV3028_CTRL1_WADA BIT(5)
|
#define RV3028_CTRL1_WADA BIT(5)
|
||||||
|
|
||||||
|
@ -84,6 +90,9 @@ struct rv3028_data {
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
enum rv3028_type type;
|
enum rv3028_type type;
|
||||||
|
#ifdef CONFIG_COMMON_CLK
|
||||||
|
struct clk_hw clkout_hw;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static u16 rv3028_trickle_resistors[] = {1000, 3000, 6000, 11000};
|
static u16 rv3028_trickle_resistors[] = {1000, 3000, 6000, 11000};
|
||||||
|
@ -581,6 +590,140 @@ restore_eerd:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_COMMON_CLK
|
||||||
|
#define clkout_hw_to_rv3028(hw) container_of(hw, struct rv3028_data, clkout_hw)
|
||||||
|
|
||||||
|
static int clkout_rates[] = {
|
||||||
|
32768,
|
||||||
|
8192,
|
||||||
|
1024,
|
||||||
|
64,
|
||||||
|
32,
|
||||||
|
1,
|
||||||
|
};
|
||||||
|
|
||||||
|
static unsigned long rv3028_clkout_recalc_rate(struct clk_hw *hw,
|
||||||
|
unsigned long parent_rate)
|
||||||
|
{
|
||||||
|
int clkout, ret;
|
||||||
|
struct rv3028_data *rv3028 = clkout_hw_to_rv3028(hw);
|
||||||
|
|
||||||
|
ret = regmap_read(rv3028->regmap, RV3028_CLKOUT, &clkout);
|
||||||
|
if (ret < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
clkout &= RV3028_CLKOUT_FD_MASK;
|
||||||
|
return clkout_rates[clkout];
|
||||||
|
}
|
||||||
|
|
||||||
|
static long rv3028_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
|
||||||
|
unsigned long *prate)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(clkout_rates); i++)
|
||||||
|
if (clkout_rates[i] <= rate)
|
||||||
|
return clkout_rates[i];
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rv3028_clkout_set_rate(struct clk_hw *hw, unsigned long rate,
|
||||||
|
unsigned long parent_rate)
|
||||||
|
{
|
||||||
|
int i, ret;
|
||||||
|
struct rv3028_data *rv3028 = clkout_hw_to_rv3028(hw);
|
||||||
|
|
||||||
|
ret = regmap_write(rv3028->regmap, RV3028_CLKOUT, 0x0);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(clkout_rates); i++) {
|
||||||
|
if (clkout_rates[i] == rate) {
|
||||||
|
ret = regmap_update_bits(rv3028->regmap,
|
||||||
|
RV3028_CLKOUT,
|
||||||
|
RV3028_CLKOUT_FD_MASK, i);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return regmap_write(rv3028->regmap, RV3028_CLKOUT,
|
||||||
|
RV3028_CLKOUT_CLKSY | RV3028_CLKOUT_CLKOE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rv3028_clkout_prepare(struct clk_hw *hw)
|
||||||
|
{
|
||||||
|
struct rv3028_data *rv3028 = clkout_hw_to_rv3028(hw);
|
||||||
|
|
||||||
|
return regmap_write(rv3028->regmap, RV3028_CLKOUT,
|
||||||
|
RV3028_CLKOUT_CLKSY | RV3028_CLKOUT_CLKOE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rv3028_clkout_unprepare(struct clk_hw *hw)
|
||||||
|
{
|
||||||
|
struct rv3028_data *rv3028 = clkout_hw_to_rv3028(hw);
|
||||||
|
|
||||||
|
regmap_write(rv3028->regmap, RV3028_CLKOUT, 0x0);
|
||||||
|
regmap_update_bits(rv3028->regmap, RV3028_STATUS,
|
||||||
|
RV3028_STATUS_CLKF, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int rv3028_clkout_is_prepared(struct clk_hw *hw)
|
||||||
|
{
|
||||||
|
int clkout, ret;
|
||||||
|
struct rv3028_data *rv3028 = clkout_hw_to_rv3028(hw);
|
||||||
|
|
||||||
|
ret = regmap_read(rv3028->regmap, RV3028_CLKOUT, &clkout);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
return !!(clkout & RV3028_CLKOUT_CLKOE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct clk_ops rv3028_clkout_ops = {
|
||||||
|
.prepare = rv3028_clkout_prepare,
|
||||||
|
.unprepare = rv3028_clkout_unprepare,
|
||||||
|
.is_prepared = rv3028_clkout_is_prepared,
|
||||||
|
.recalc_rate = rv3028_clkout_recalc_rate,
|
||||||
|
.round_rate = rv3028_clkout_round_rate,
|
||||||
|
.set_rate = rv3028_clkout_set_rate,
|
||||||
|
};
|
||||||
|
|
||||||
|
static int rv3028_clkout_register_clk(struct rv3028_data *rv3028,
|
||||||
|
struct i2c_client *client)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct clk *clk;
|
||||||
|
struct clk_init_data init;
|
||||||
|
struct device_node *node = client->dev.of_node;
|
||||||
|
|
||||||
|
ret = regmap_update_bits(rv3028->regmap, RV3028_STATUS,
|
||||||
|
RV3028_STATUS_CLKF, 0);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
init.name = "rv3028-clkout";
|
||||||
|
init.ops = &rv3028_clkout_ops;
|
||||||
|
init.flags = 0;
|
||||||
|
init.parent_names = NULL;
|
||||||
|
init.num_parents = 0;
|
||||||
|
rv3028->clkout_hw.init = &init;
|
||||||
|
|
||||||
|
/* optional override of the clockname */
|
||||||
|
of_property_read_string(node, "clock-output-names", &init.name);
|
||||||
|
|
||||||
|
/* register the clock */
|
||||||
|
clk = devm_clk_register(&client->dev, &rv3028->clkout_hw);
|
||||||
|
if (!IS_ERR(clk))
|
||||||
|
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct rtc_class_ops rv3028_rtc_ops = {
|
static struct rtc_class_ops rv3028_rtc_ops = {
|
||||||
.read_time = rv3028_get_time,
|
.read_time = rv3028_get_time,
|
||||||
.set_time = rv3028_set_time,
|
.set_time = rv3028_set_time,
|
||||||
|
@ -708,6 +851,9 @@ static int rv3028_probe(struct i2c_client *client)
|
||||||
|
|
||||||
rv3028->rtc->max_user_freq = 1;
|
rv3028->rtc->max_user_freq = 1;
|
||||||
|
|
||||||
|
#ifdef CONFIG_COMMON_CLK
|
||||||
|
rv3028_clkout_register_clk(rv3028, client);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
/*
|
/*
|
||||||
* Driver for the Epson RTC module RX-6110 SA
|
* Driver for the Epson RTC module RX-6110 SA
|
||||||
*
|
*
|
||||||
* Copyright(C) 2015 Pengutronix, Steffen Trumtrar <kernel@pengutronix.de>
|
* Copyright(C) 2015 Pengutronix, Steffen Trumtrar <kernel@pengutronix.de>
|
||||||
* Copyright(C) SEIKO EPSON CORPORATION 2013. All rights reserved.
|
* Copyright(C) SEIKO EPSON CORPORATION 2013. All rights reserved.
|
||||||
*
|
|
||||||
* This driver software is distributed as is, without any warranty of any kind,
|
|
||||||
* either express or implied as further specified in the GNU Public License.
|
|
||||||
* This software may be used and distributed according to the terms of the GNU
|
|
||||||
* Public License, version 2 as published by the Free Software Foundation.
|
|
||||||
* See the file COPYING in the main directory of this archive for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <linux/bcd.h>
|
#include <linux/bcd.h>
|
||||||
|
@ -370,11 +362,6 @@ static int rx6110_probe(struct spi_device *spi)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rx6110_remove(struct spi_device *spi)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct spi_device_id rx6110_id[] = {
|
static const struct spi_device_id rx6110_id[] = {
|
||||||
{ "rx6110", 0 },
|
{ "rx6110", 0 },
|
||||||
{ }
|
{ }
|
||||||
|
@ -393,7 +380,6 @@ static struct spi_driver rx6110_driver = {
|
||||||
.of_match_table = of_match_ptr(rx6110_spi_of_match),
|
.of_match_table = of_match_ptr(rx6110_spi_of_match),
|
||||||
},
|
},
|
||||||
.probe = rx6110_probe,
|
.probe = rx6110_probe,
|
||||||
.remove = rx6110_remove,
|
|
||||||
.id_table = rx6110_id,
|
.id_table = rx6110_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -423,8 +423,6 @@ static const struct rtc_class_ops s35390a_rtc_ops = {
|
||||||
.ioctl = s35390a_rtc_ioctl,
|
.ioctl = s35390a_rtc_ioctl,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct i2c_driver s35390a_driver;
|
|
||||||
|
|
||||||
static int s35390a_probe(struct i2c_client *client,
|
static int s35390a_probe(struct i2c_client *client,
|
||||||
const struct i2c_device_id *id)
|
const struct i2c_device_id *id)
|
||||||
{
|
{
|
||||||
|
@ -456,6 +454,10 @@ static int s35390a_probe(struct i2c_client *client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s35390a->rtc = devm_rtc_allocate_device(dev);
|
||||||
|
if (IS_ERR(s35390a->rtc))
|
||||||
|
return PTR_ERR(s35390a->rtc);
|
||||||
|
|
||||||
err_read = s35390a_read_status(s35390a, &status1);
|
err_read = s35390a_read_status(s35390a, &status1);
|
||||||
if (err_read < 0) {
|
if (err_read < 0) {
|
||||||
dev_err(dev, "error resetting chip\n");
|
dev_err(dev, "error resetting chip\n");
|
||||||
|
@ -485,11 +487,9 @@ static int s35390a_probe(struct i2c_client *client,
|
||||||
|
|
||||||
device_set_wakeup_capable(dev, 1);
|
device_set_wakeup_capable(dev, 1);
|
||||||
|
|
||||||
s35390a->rtc = devm_rtc_device_register(dev, s35390a_driver.driver.name,
|
s35390a->rtc->ops = &s35390a_rtc_ops;
|
||||||
&s35390a_rtc_ops, THIS_MODULE);
|
s35390a->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||||
|
s35390a->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||||
if (IS_ERR(s35390a->rtc))
|
|
||||||
return PTR_ERR(s35390a->rtc);
|
|
||||||
|
|
||||||
/* supports per-minute alarms only, therefore set uie_unsupported */
|
/* supports per-minute alarms only, therefore set uie_unsupported */
|
||||||
s35390a->rtc->uie_unsupported = 1;
|
s35390a->rtc->uie_unsupported = 1;
|
||||||
|
@ -497,7 +497,7 @@ static int s35390a_probe(struct i2c_client *client,
|
||||||
if (status1 & S35390A_FLAG_INT2)
|
if (status1 & S35390A_FLAG_INT2)
|
||||||
rtc_update_irq(s35390a->rtc, 1, RTC_AF);
|
rtc_update_irq(s35390a->rtc, 1, RTC_AF);
|
||||||
|
|
||||||
return 0;
|
return rtc_register_device(s35390a->rtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct i2c_driver s35390a_driver = {
|
static struct i2c_driver s35390a_driver = {
|
||||||
|
|
|
@ -444,7 +444,6 @@ static int s3c_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct s3c_rtc *info = NULL;
|
struct s3c_rtc *info = NULL;
|
||||||
struct rtc_time rtc_tm;
|
struct rtc_time rtc_tm;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
|
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
|
||||||
|
@ -475,8 +474,7 @@ static int s3c_rtc_probe(struct platform_device *pdev)
|
||||||
info->irq_tick, info->irq_alarm);
|
info->irq_tick, info->irq_alarm);
|
||||||
|
|
||||||
/* get the memory region */
|
/* get the memory region */
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
info->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
info->base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(info->base))
|
if (IS_ERR(info->base))
|
||||||
return PTR_ERR(info->base);
|
return PTR_ERR(info->base);
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,6 @@ EXPORT_SYMBOL_GPL(sa1100_rtc_init);
|
||||||
static int sa1100_rtc_probe(struct platform_device *pdev)
|
static int sa1100_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct sa1100_rtc *info;
|
struct sa1100_rtc *info;
|
||||||
struct resource *iores;
|
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
int irq_1hz, irq_alarm;
|
int irq_1hz, irq_alarm;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -281,8 +280,7 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
base = devm_ioremap_resource(&pdev->dev, iores);
|
|
||||||
if (IS_ERR(base))
|
if (IS_ERR(base))
|
||||||
return PTR_ERR(base);
|
return PTR_ERR(base);
|
||||||
|
|
||||||
|
|
|
@ -661,12 +661,6 @@ static int sprd_rtc_probe(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sprd_rtc_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
device_init_wakeup(&pdev->dev, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct of_device_id sprd_rtc_of_match[] = {
|
static const struct of_device_id sprd_rtc_of_match[] = {
|
||||||
{ .compatible = "sprd,sc2731-rtc", },
|
{ .compatible = "sprd,sc2731-rtc", },
|
||||||
{ },
|
{ },
|
||||||
|
@ -679,7 +673,6 @@ static struct platform_driver sprd_rtc_driver = {
|
||||||
.of_match_table = sprd_rtc_of_match,
|
.of_match_table = sprd_rtc_of_match,
|
||||||
},
|
},
|
||||||
.probe = sprd_rtc_probe,
|
.probe = sprd_rtc_probe,
|
||||||
.remove = sprd_rtc_remove,
|
|
||||||
};
|
};
|
||||||
module_platform_driver(sprd_rtc_driver);
|
module_platform_driver(sprd_rtc_driver);
|
||||||
|
|
||||||
|
|
|
@ -365,13 +365,6 @@ static int sirfsoc_rtc_probe(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sirfsoc_rtc_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
device_init_wakeup(&pdev->dev, 0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
static int sirfsoc_rtc_suspend(struct device *dev)
|
static int sirfsoc_rtc_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
|
@ -450,7 +443,6 @@ static struct platform_driver sirfsoc_rtc_driver = {
|
||||||
.of_match_table = sirfsoc_rtc_of_match,
|
.of_match_table = sirfsoc_rtc_of_match,
|
||||||
},
|
},
|
||||||
.probe = sirfsoc_rtc_probe,
|
.probe = sirfsoc_rtc_probe,
|
||||||
.remove = sirfsoc_rtc_remove,
|
|
||||||
};
|
};
|
||||||
module_platform_driver(sirfsoc_rtc_driver);
|
module_platform_driver(sirfsoc_rtc_driver);
|
||||||
|
|
||||||
|
|
|
@ -347,7 +347,6 @@ static const struct rtc_class_ops spear_rtc_ops = {
|
||||||
|
|
||||||
static int spear_rtc_probe(struct platform_device *pdev)
|
static int spear_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
struct spear_rtc_config *config;
|
struct spear_rtc_config *config;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
int irq;
|
int irq;
|
||||||
|
@ -369,8 +368,7 @@ static int spear_rtc_probe(struct platform_device *pdev)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
config->ioaddr = devm_platform_ioremap_resource(pdev, 0);
|
||||||
config->ioaddr = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(config->ioaddr))
|
if (IS_ERR(config->ioaddr))
|
||||||
return PTR_ERR(config->ioaddr);
|
return PTR_ERR(config->ioaddr);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
struct st_rtc {
|
struct st_rtc {
|
||||||
struct rtc_device *rtc_dev;
|
struct rtc_device *rtc_dev;
|
||||||
struct rtc_wkalrm alarm;
|
struct rtc_wkalrm alarm;
|
||||||
struct resource *res;
|
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
unsigned long clkrate;
|
unsigned long clkrate;
|
||||||
void __iomem *ioaddr;
|
void __iomem *ioaddr;
|
||||||
|
@ -186,7 +185,6 @@ static int st_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct device_node *np = pdev->dev.of_node;
|
struct device_node *np = pdev->dev.of_node;
|
||||||
struct st_rtc *rtc;
|
struct st_rtc *rtc;
|
||||||
struct resource *res;
|
|
||||||
uint32_t mode;
|
uint32_t mode;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
@ -210,8 +208,7 @@ static int st_rtc_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
spin_lock_init(&rtc->lock);
|
spin_lock_init(&rtc->lock);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->ioaddr = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->ioaddr = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(rtc->ioaddr))
|
if (IS_ERR(rtc->ioaddr))
|
||||||
return PTR_ERR(rtc->ioaddr);
|
return PTR_ERR(rtc->ioaddr);
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,6 @@ static int stk17ta8_nvram_write(void *priv, unsigned int pos, void *val,
|
||||||
|
|
||||||
static int stk17ta8_rtc_probe(struct platform_device *pdev)
|
static int stk17ta8_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
unsigned int cal;
|
unsigned int cal;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
struct rtc_plat_data *pdata;
|
struct rtc_plat_data *pdata;
|
||||||
|
@ -275,8 +274,7 @@ static int stk17ta8_rtc_probe(struct platform_device *pdev)
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
ioaddr = devm_platform_ioremap_resource(pdev, 0);
|
||||||
ioaddr = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(ioaddr))
|
if (IS_ERR(ioaddr))
|
||||||
return PTR_ERR(ioaddr);
|
return PTR_ERR(ioaddr);
|
||||||
pdata->ioaddr = ioaddr;
|
pdata->ioaddr = ioaddr;
|
||||||
|
|
|
@ -693,15 +693,13 @@ static int stm32_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct stm32_rtc *rtc;
|
struct stm32_rtc *rtc;
|
||||||
const struct stm32_rtc_registers *regs;
|
const struct stm32_rtc_registers *regs;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
|
rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
|
||||||
if (!rtc)
|
if (!rtc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
rtc->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
rtc->base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(rtc->base))
|
if (IS_ERR(rtc->base))
|
||||||
return PTR_ERR(rtc->base);
|
return PTR_ERR(rtc->base);
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,6 @@ struct sun6i_rtc_clk_data {
|
||||||
|
|
||||||
struct sun6i_rtc_dev {
|
struct sun6i_rtc_dev {
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
struct device *dev;
|
|
||||||
const struct sun6i_rtc_clk_data *data;
|
const struct sun6i_rtc_clk_data *data;
|
||||||
void __iomem *base;
|
void __iomem *base;
|
||||||
int irq;
|
int irq;
|
||||||
|
@ -669,7 +668,6 @@ static int sun6i_rtc_probe(struct platform_device *pdev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, chip);
|
platform_set_drvdata(pdev, chip);
|
||||||
chip->dev = &pdev->dev;
|
|
||||||
|
|
||||||
chip->irq = platform_get_irq(pdev, 0);
|
chip->irq = platform_get_irq(pdev, 0);
|
||||||
if (chip->irq < 0)
|
if (chip->irq < 0)
|
||||||
|
|
|
@ -422,7 +422,6 @@ MODULE_DEVICE_TABLE(of, sunxi_rtc_dt_ids);
|
||||||
static int sunxi_rtc_probe(struct platform_device *pdev)
|
static int sunxi_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct sunxi_rtc_dev *chip;
|
struct sunxi_rtc_dev *chip;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
|
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
|
||||||
|
@ -436,8 +435,7 @@ static int sunxi_rtc_probe(struct platform_device *pdev)
|
||||||
if (IS_ERR(chip->rtc))
|
if (IS_ERR(chip->rtc))
|
||||||
return PTR_ERR(chip->rtc);
|
return PTR_ERR(chip->rtc);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
chip->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
chip->base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(chip->base))
|
if (IS_ERR(chip->base))
|
||||||
return PTR_ERR(chip->base);
|
return PTR_ERR(chip->base);
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ static int tegra_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||||
{
|
{
|
||||||
struct tegra_rtc_info *info = dev_get_drvdata(dev);
|
struct tegra_rtc_info *info = dev_get_drvdata(dev);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u32 sec, msec;
|
u32 sec;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RTC hardware copies seconds to shadow seconds when a read of
|
* RTC hardware copies seconds to shadow seconds when a read of
|
||||||
|
@ -111,7 +111,7 @@ static int tegra_rtc_read_time(struct device *dev, struct rtc_time *tm)
|
||||||
*/
|
*/
|
||||||
spin_lock_irqsave(&info->lock, flags);
|
spin_lock_irqsave(&info->lock, flags);
|
||||||
|
|
||||||
msec = readl(info->base + TEGRA_RTC_REG_MILLI_SECONDS);
|
readl(info->base + TEGRA_RTC_REG_MILLI_SECONDS);
|
||||||
sec = readl(info->base + TEGRA_RTC_REG_SHADOW_SECONDS);
|
sec = readl(info->base + TEGRA_RTC_REG_SHADOW_SECONDS);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&info->lock, flags);
|
spin_unlock_irqrestore(&info->lock, flags);
|
||||||
|
@ -277,15 +277,13 @@ MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match);
|
||||||
static int tegra_rtc_probe(struct platform_device *pdev)
|
static int tegra_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct tegra_rtc_info *info;
|
struct tegra_rtc_info *info;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
|
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
|
||||||
if (!info)
|
if (!info)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
info->base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
info->base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(info->base))
|
if (IS_ERR(info->base))
|
||||||
return PTR_ERR(info->base);
|
return PTR_ERR(info->base);
|
||||||
|
|
||||||
|
|
|
@ -361,6 +361,13 @@ static const struct rtc_class_ops tps65910_rtc_ops = {
|
||||||
.set_offset = tps65910_set_offset,
|
.set_offset = tps65910_set_offset,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct rtc_class_ops tps65910_rtc_ops_noirq = {
|
||||||
|
.read_time = tps65910_rtc_read_time,
|
||||||
|
.set_time = tps65910_rtc_set_time,
|
||||||
|
.read_offset = tps65910_read_offset,
|
||||||
|
.set_offset = tps65910_set_offset,
|
||||||
|
};
|
||||||
|
|
||||||
static int tps65910_rtc_probe(struct platform_device *pdev)
|
static int tps65910_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct tps65910 *tps65910 = NULL;
|
struct tps65910 *tps65910 = NULL;
|
||||||
|
@ -414,14 +421,16 @@ static int tps65910_rtc_probe(struct platform_device *pdev)
|
||||||
ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
|
ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
|
||||||
tps65910_rtc_interrupt, IRQF_TRIGGER_LOW,
|
tps65910_rtc_interrupt, IRQF_TRIGGER_LOW,
|
||||||
dev_name(&pdev->dev), &pdev->dev);
|
dev_name(&pdev->dev), &pdev->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
dev_err(&pdev->dev, "IRQ is not free.\n");
|
irq = -1;
|
||||||
return ret;
|
|
||||||
}
|
tps_rtc->irq = irq;
|
||||||
tps_rtc->irq = irq;
|
if (irq != -1) {
|
||||||
device_set_wakeup_capable(&pdev->dev, 1);
|
device_set_wakeup_capable(&pdev->dev, 1);
|
||||||
|
tps_rtc->rtc->ops = &tps65910_rtc_ops;
|
||||||
|
} else
|
||||||
|
tps_rtc->rtc->ops = &tps65910_rtc_ops_noirq;
|
||||||
|
|
||||||
tps_rtc->rtc->ops = &tps65910_rtc_ops;
|
|
||||||
tps_rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
tps_rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||||
tps_rtc->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
tps_rtc->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,6 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
struct tx4939rtc_plat_data *pdata;
|
struct tx4939rtc_plat_data *pdata;
|
||||||
struct resource *res;
|
|
||||||
int irq, ret;
|
int irq, ret;
|
||||||
struct nvmem_config nvmem_cfg = {
|
struct nvmem_config nvmem_cfg = {
|
||||||
.name = "tx4939_nvram",
|
.name = "tx4939_nvram",
|
||||||
|
@ -253,8 +252,7 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
platform_set_drvdata(pdev, pdata);
|
platform_set_drvdata(pdev, pdata);
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
pdata->rtcreg = devm_platform_ioremap_resource(pdev, 0);
|
||||||
pdata->rtcreg = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(pdata->rtcreg))
|
if (IS_ERR(pdata->rtcreg))
|
||||||
return PTR_ERR(pdata->rtcreg);
|
return PTR_ERR(pdata->rtcreg);
|
||||||
|
|
||||||
|
|
|
@ -284,7 +284,6 @@ static int rtc_probe(struct platform_device *pdev)
|
||||||
struct v3020 *chip;
|
struct v3020 *chip;
|
||||||
int retval = -EBUSY;
|
int retval = -EBUSY;
|
||||||
int i;
|
int i;
|
||||||
int temp;
|
|
||||||
|
|
||||||
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
|
chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
|
||||||
if (!chip)
|
if (!chip)
|
||||||
|
@ -302,7 +301,7 @@ static int rtc_probe(struct platform_device *pdev)
|
||||||
/* Make sure the v3020 expects a communication cycle
|
/* Make sure the v3020 expects a communication cycle
|
||||||
* by reading 8 times */
|
* by reading 8 times */
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
temp = chip->ops->read_bit(chip);
|
chip->ops->read_bit(chip);
|
||||||
|
|
||||||
/* Test chip by doing a write/read sequence
|
/* Test chip by doing a write/read sequence
|
||||||
* to the chip ram */
|
* to the chip ram */
|
||||||
|
|
|
@ -122,12 +122,6 @@ static int vt8500_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
||||||
{
|
{
|
||||||
struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev);
|
struct vt8500_rtc *vt8500_rtc = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (tm->tm_year < 100) {
|
|
||||||
dev_warn(dev, "Only years 2000-2199 are supported by the "
|
|
||||||
"hardware!\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
writel((bin2bcd(tm->tm_year % 100) << DATE_YEAR_S)
|
writel((bin2bcd(tm->tm_year % 100) << DATE_YEAR_S)
|
||||||
| (bin2bcd(tm->tm_mon + 1) << DATE_MONTH_S)
|
| (bin2bcd(tm->tm_mon + 1) << DATE_MONTH_S)
|
||||||
| (bin2bcd(tm->tm_mday))
|
| (bin2bcd(tm->tm_mday))
|
||||||
|
@ -200,7 +194,6 @@ static const struct rtc_class_ops vt8500_rtc_ops = {
|
||||||
static int vt8500_rtc_probe(struct platform_device *pdev)
|
static int vt8500_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct vt8500_rtc *vt8500_rtc;
|
struct vt8500_rtc *vt8500_rtc;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
vt8500_rtc = devm_kzalloc(&pdev->dev,
|
vt8500_rtc = devm_kzalloc(&pdev->dev,
|
||||||
|
@ -215,8 +208,7 @@ static int vt8500_rtc_probe(struct platform_device *pdev)
|
||||||
if (vt8500_rtc->irq_alarm < 0)
|
if (vt8500_rtc->irq_alarm < 0)
|
||||||
return vt8500_rtc->irq_alarm;
|
return vt8500_rtc->irq_alarm;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
vt8500_rtc->regbase = devm_platform_ioremap_resource(pdev, 0);
|
||||||
vt8500_rtc->regbase = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(vt8500_rtc->regbase))
|
if (IS_ERR(vt8500_rtc->regbase))
|
||||||
return PTR_ERR(vt8500_rtc->regbase);
|
return PTR_ERR(vt8500_rtc->regbase);
|
||||||
|
|
||||||
|
@ -224,27 +216,23 @@ static int vt8500_rtc_probe(struct platform_device *pdev)
|
||||||
writel(VT8500_RTC_CR_ENABLE,
|
writel(VT8500_RTC_CR_ENABLE,
|
||||||
vt8500_rtc->regbase + VT8500_RTC_CR);
|
vt8500_rtc->regbase + VT8500_RTC_CR);
|
||||||
|
|
||||||
vt8500_rtc->rtc = devm_rtc_device_register(&pdev->dev, "vt8500-rtc",
|
vt8500_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
|
||||||
&vt8500_rtc_ops, THIS_MODULE);
|
if (IS_ERR(vt8500_rtc->rtc))
|
||||||
if (IS_ERR(vt8500_rtc->rtc)) {
|
return PTR_ERR(vt8500_rtc->rtc);
|
||||||
ret = PTR_ERR(vt8500_rtc->rtc);
|
|
||||||
dev_err(&pdev->dev,
|
vt8500_rtc->rtc->ops = &vt8500_rtc_ops;
|
||||||
"Failed to register RTC device -> %d\n", ret);
|
vt8500_rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||||
goto err_return;
|
vt8500_rtc->rtc->range_max = RTC_TIMESTAMP_END_2199;
|
||||||
}
|
|
||||||
|
|
||||||
ret = devm_request_irq(&pdev->dev, vt8500_rtc->irq_alarm,
|
ret = devm_request_irq(&pdev->dev, vt8500_rtc->irq_alarm,
|
||||||
vt8500_rtc_irq, 0, "rtc alarm", vt8500_rtc);
|
vt8500_rtc_irq, 0, "rtc alarm", vt8500_rtc);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "can't get irq %i, err %d\n",
|
dev_err(&pdev->dev, "can't get irq %i, err %d\n",
|
||||||
vt8500_rtc->irq_alarm, ret);
|
vt8500_rtc->irq_alarm, ret);
|
||||||
goto err_return;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return rtc_register_device(vt8500_rtc->rtc);
|
||||||
|
|
||||||
err_return:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vt8500_rtc_remove(struct platform_device *pdev)
|
static int vt8500_rtc_remove(struct platform_device *pdev)
|
||||||
|
|
|
@ -110,10 +110,12 @@ static int wilco_ec_rtc_read(struct device *dev, struct rtc_time *tm)
|
||||||
tm->tm_mday = rtc.day;
|
tm->tm_mday = rtc.day;
|
||||||
tm->tm_mon = rtc.month - 1;
|
tm->tm_mon = rtc.month - 1;
|
||||||
tm->tm_year = rtc.year + (rtc.century * 100) - 1900;
|
tm->tm_year = rtc.year + (rtc.century * 100) - 1900;
|
||||||
tm->tm_yday = rtc_year_days(tm->tm_mday, tm->tm_mon, tm->tm_year);
|
/* Ignore other tm fields, man rtc says userspace shouldn't use them. */
|
||||||
|
|
||||||
/* Don't compute day of week, we don't need it. */
|
if (rtc_valid_tm(tm)) {
|
||||||
tm->tm_wday = -1;
|
dev_err(dev, "Time from RTC is invalid: %ptRr\n", tm);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
struct xgene_rtc_dev {
|
struct xgene_rtc_dev {
|
||||||
struct rtc_device *rtc;
|
struct rtc_device *rtc;
|
||||||
struct device *dev;
|
|
||||||
void __iomem *csr_base;
|
void __iomem *csr_base;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
unsigned int irq_wake;
|
unsigned int irq_wake;
|
||||||
|
@ -137,7 +136,6 @@ static irqreturn_t xgene_rtc_interrupt(int irq, void *id)
|
||||||
static int xgene_rtc_probe(struct platform_device *pdev)
|
static int xgene_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct xgene_rtc_dev *pdata;
|
struct xgene_rtc_dev *pdata;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
int irq;
|
int irq;
|
||||||
|
|
||||||
|
@ -145,10 +143,8 @@ static int xgene_rtc_probe(struct platform_device *pdev)
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
platform_set_drvdata(pdev, pdata);
|
platform_set_drvdata(pdev, pdata);
|
||||||
pdata->dev = &pdev->dev;
|
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
pdata->csr_base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
pdata->csr_base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(pdata->csr_base))
|
if (IS_ERR(pdata->csr_base))
|
||||||
return PTR_ERR(pdata->csr_base);
|
return PTR_ERR(pdata->csr_base);
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct xlnx_rtc_dev {
|
||||||
void __iomem *reg_base;
|
void __iomem *reg_base;
|
||||||
int alarm_irq;
|
int alarm_irq;
|
||||||
int sec_irq;
|
int sec_irq;
|
||||||
int calibval;
|
unsigned int calibval;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int xlnx_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
static int xlnx_rtc_set_time(struct device *dev, struct rtc_time *tm)
|
||||||
|
@ -195,7 +195,6 @@ static irqreturn_t xlnx_rtc_interrupt(int irq, void *id)
|
||||||
static int xlnx_rtc_probe(struct platform_device *pdev)
|
static int xlnx_rtc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct xlnx_rtc_dev *xrtcdev;
|
struct xlnx_rtc_dev *xrtcdev;
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
xrtcdev = devm_kzalloc(&pdev->dev, sizeof(*xrtcdev), GFP_KERNEL);
|
xrtcdev = devm_kzalloc(&pdev->dev, sizeof(*xrtcdev), GFP_KERNEL);
|
||||||
|
@ -211,9 +210,7 @@ static int xlnx_rtc_probe(struct platform_device *pdev)
|
||||||
xrtcdev->rtc->ops = &xlnx_rtc_ops;
|
xrtcdev->rtc->ops = &xlnx_rtc_ops;
|
||||||
xrtcdev->rtc->range_max = U32_MAX;
|
xrtcdev->rtc->range_max = U32_MAX;
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
xrtcdev->reg_base = devm_platform_ioremap_resource(pdev, 0);
|
||||||
|
|
||||||
xrtcdev->reg_base = devm_ioremap_resource(&pdev->dev, res);
|
|
||||||
if (IS_ERR(xrtcdev->reg_base))
|
if (IS_ERR(xrtcdev->reg_base))
|
||||||
return PTR_ERR(xrtcdev->reg_base);
|
return PTR_ERR(xrtcdev->reg_base);
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,11 @@ static DEVICE_ATTR_RW(max_user_freq);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rtc_sysfs_show_hctosys - indicate if the given RTC set the system time
|
* rtc_sysfs_show_hctosys - indicate if the given RTC set the system time
|
||||||
|
* @dev: The device that the attribute belongs to.
|
||||||
|
* @attr: The attribute being read.
|
||||||
|
* @buf: The result buffer.
|
||||||
*
|
*
|
||||||
* Returns 1 if the system clock was set by this RTC at the last
|
* buf is "1" if the system clock was set by this RTC at the last
|
||||||
* boot or resume event.
|
* boot or resume event.
|
||||||
*/
|
*/
|
||||||
static ssize_t
|
static ssize_t
|
||||||
|
|
|
@ -159,11 +159,16 @@ struct rtc_device {
|
||||||
};
|
};
|
||||||
#define to_rtc_device(d) container_of(d, struct rtc_device, dev)
|
#define to_rtc_device(d) container_of(d, struct rtc_device, dev)
|
||||||
|
|
||||||
|
#define rtc_lock(d) mutex_lock(&d->ops_lock)
|
||||||
|
#define rtc_unlock(d) mutex_unlock(&d->ops_lock)
|
||||||
|
|
||||||
/* useful timestamps */
|
/* useful timestamps */
|
||||||
|
#define RTC_TIMESTAMP_BEGIN_0000 -62167219200ULL /* 0000-01-01 00:00:00 */
|
||||||
#define RTC_TIMESTAMP_BEGIN_1900 -2208988800LL /* 1900-01-01 00:00:00 */
|
#define RTC_TIMESTAMP_BEGIN_1900 -2208988800LL /* 1900-01-01 00:00:00 */
|
||||||
#define RTC_TIMESTAMP_BEGIN_2000 946684800LL /* 2000-01-01 00:00:00 */
|
#define RTC_TIMESTAMP_BEGIN_2000 946684800LL /* 2000-01-01 00:00:00 */
|
||||||
#define RTC_TIMESTAMP_END_2063 2966371199LL /* 2063-12-31 23:59:59 */
|
#define RTC_TIMESTAMP_END_2063 2966371199LL /* 2063-12-31 23:59:59 */
|
||||||
#define RTC_TIMESTAMP_END_2099 4102444799LL /* 2099-12-31 23:59:59 */
|
#define RTC_TIMESTAMP_END_2099 4102444799LL /* 2099-12-31 23:59:59 */
|
||||||
|
#define RTC_TIMESTAMP_END_2199 7258118399LL /* 2199-12-31 23:59:59 */
|
||||||
#define RTC_TIMESTAMP_END_9999 253402300799LL /* 9999-12-31 23:59:59 */
|
#define RTC_TIMESTAMP_END_9999 253402300799LL /* 9999-12-31 23:59:59 */
|
||||||
|
|
||||||
extern struct rtc_device *devm_rtc_device_register(struct device *dev,
|
extern struct rtc_device *devm_rtc_device_register(struct device *dev,
|
||||||
|
|
|
@ -42,14 +42,11 @@
|
||||||
struct ds1685_priv {
|
struct ds1685_priv {
|
||||||
struct rtc_device *dev;
|
struct rtc_device *dev;
|
||||||
void __iomem *regs;
|
void __iomem *regs;
|
||||||
|
void __iomem *data;
|
||||||
u32 regstep;
|
u32 regstep;
|
||||||
resource_size_t baseaddr;
|
|
||||||
size_t size;
|
|
||||||
int irq_num;
|
int irq_num;
|
||||||
bool bcd_mode;
|
bool bcd_mode;
|
||||||
bool no_irq;
|
bool no_irq;
|
||||||
bool uie_unsupported;
|
|
||||||
bool alloc_io_resources;
|
|
||||||
u8 (*read)(struct ds1685_priv *, int);
|
u8 (*read)(struct ds1685_priv *, int);
|
||||||
void (*write)(struct ds1685_priv *, int, u8);
|
void (*write)(struct ds1685_priv *, int, u8);
|
||||||
void (*prepare_poweroff)(void);
|
void (*prepare_poweroff)(void);
|
||||||
|
@ -74,12 +71,13 @@ struct ds1685_rtc_platform_data {
|
||||||
const bool bcd_mode;
|
const bool bcd_mode;
|
||||||
const bool no_irq;
|
const bool no_irq;
|
||||||
const bool uie_unsupported;
|
const bool uie_unsupported;
|
||||||
const bool alloc_io_resources;
|
|
||||||
u8 (*plat_read)(struct ds1685_priv *, int);
|
|
||||||
void (*plat_write)(struct ds1685_priv *, int, u8);
|
|
||||||
void (*plat_prepare_poweroff)(void);
|
void (*plat_prepare_poweroff)(void);
|
||||||
void (*plat_wake_alarm)(void);
|
void (*plat_wake_alarm)(void);
|
||||||
void (*plat_post_ram_clear)(void);
|
void (*plat_post_ram_clear)(void);
|
||||||
|
enum {
|
||||||
|
ds1685_reg_direct,
|
||||||
|
ds1685_reg_indirect
|
||||||
|
} access_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue