summaryrefslogtreecommitdiffstats
path: root/drivers
AgeCommit message (Collapse)AuthorFilesLines
2018-05-31rtc: sun6i: Fix bit_idx value for clk_register_gateMichael Trimarchi1-2/+2
clk-gate core will take bit_idx through clk_register_gate and then do clk_gate_ops by using BIT(bit_idx), but rtc-sun6i is passing bit_idx as BIT(bit_idx) it becomes BIT(BIT(bit_idx) which is wrong and eventually external gate clock is not enabling. This patch fixed by passing bit index and the original change introduced from below commit. "rtc: sun6i: Add support for the external oscillator gate" (sha1: 17ecd246414b3a0fe0cb248c86977a8bda465b7b) Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com> Fixes: 17ecd246414b ("rtc: sun6i: Add support for the external oscillator gate") Cc: stable@vger.kernel.org Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> Acked-by: Maxime Ripard <maxime.ripard@bootlin.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-31rtc: jz4740: Fix a typo in KconfigMathieu Malaterre1-1/+1
Fix typo introduced for RTC_DRV_JZ4740 in commit 586655d278ba ("rtc: jz4740: make the driver buildable as a module again"). Signed-off-by: Mathieu Malaterre <malat@debian.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-26rtc: test: remove obsolete .set_mmssAlexandre Belloni1-17/+2
There is no point in testing .set_mmss versus .set_mmss64 as there are both taking the exact same argument (truncated for set_mmss though). Also, this allows to constify struct rtc_ops. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-23rtc: st-lpc: add rangeAlexandre Belloni1-0/+2
The RTC has a 64 bit counter. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-23rtc: st-lpc: fix possible race conditionAlexandre Belloni1-15/+9
The IRQ is requested before the struct rtc is allocated and registered, but this struct is used in the IRQ handler. This may lead to a NULL pointer dereference. Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc before requesting the IRQ. Acked-by: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-22rtc: stm32: add stm32mp1 rtc supportAmelie Delaunay1-14/+89
This patch adds support for stm32mp1 RTC. Some common registers with previous RTC version have a different offset. It is the case for Control Register (CR) and ALaRMA Register (ALRMAR). There are also new registers regarding event flags: now, Alarm event flag is in Status Register (SR) and write 1 in Status Clear Register (SCR) is required to clear the event. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-22rtc: stm32: rework register management to prepare other version of RTCAmelie Delaunay1-57/+127
This patch reworks register/bits management because next version of RTC uses the same way of working but with different register's offset or bits moved in new registers. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-22rtc: stm32: fix misspelling and misalignment issuesAmelie Delaunay1-2/+2
This patch cleans the following checkpatch complaints: CHECK: 'initalized' may be misspelled - perhaps 'initialized'? #644: FILE: drivers/rtc/rtc-stm32.c:644: + * the calendar has been initalized or not. INITS flag is reset by a CHECK: Alignment should match open parenthesis #669: FILE: drivers/rtc/rtc-stm32.c:669: + rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, pdev->name, + &stm32_rtc_ops, THIS_MODULE); Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-22rtc: mxc: Switch to SPDX identifierFabio Estevam1-10/+3
Adopt the SPDX license identifier headers to ease license compliance management. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-22rtc: snvs: Switch to SPDX identifierFabio Estevam1-10/+3
Adopt the SPDX license identifier headers to ease license compliance management. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-21rtc: nvmem: don't use IS_ERR_OR_NULLUwe Kleine-König1-1/+1
nvmem_register() never returns NULL, so IS_ERR is good enough here. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-21rtc: ds1742: don't explicitly specify word_size and stride of nvmemUwe Kleine-König1-2/+0
nvmem_register() assumes these values to be 1 if unset, so they don't need to be set explicitly. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-21rtc: brcmstb-waketimer: add rangeAlexandre Belloni1-6/+1
Let the core handle the range. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-21rtc: brcmstb-waketimer: switch to rtc_register_deviceAlexandre Belloni1-5/+8
Switch to devm_rtc_allocate_device/rtc_register_device. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-19rtc: mxc_v2: use rtc_time64_to_tm in mxc_rtc_read_alarmAlexandre Belloni1-1/+1
Use the 64-bit version of rtc_time_to_tm in mxc_rtc_read_alarm Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-19rtc: mxc_v2: let the core handle rtc rangeAlexandre Belloni1-10/+1
This RTC is a 32-bit second counter. This also solves an issue where mxc_rtc_set_alarm() can return with the lock taken. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-19rtc: mxc_v2: fix possible race conditionAlexandre Belloni1-7/+9
The IRQ is requested before the struct rtc is allocated and registered, but this struct is used in the IRQ handler. This may lead to a NULL pointer dereference. Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc before requesting the IRQ. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-18rtc: ls1x: add rangeAlexandre Belloni1-0/+2
While the year is encoded on 32 bits in SYS_TOYWRITE1i/SYS_TOYREAD1. The Loongson 1c datasheet states that the range is from 0 to 99. The current code exceeds this range and seems to be working, I deduce that the leap year algorithm will fail in 2100. Anyway, alarm registers only encode the year on 14 bits so with alarm support, the range will always be limited to 0 to 16383. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: ls1x: remove useless label and gotoAlexandre Belloni1-8/+3
The error handling in ls1x_rtc_probe used to release resources but since it is using devm functions, it only returns a value. Make the code clearer by returning directly instead of using goto. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: ls1x: switch to rtc_register_deviceAlexandre Belloni1-7/+7
This allows for future improvement of the driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: tps6586x: let the core handle rtc rangeAlexandre Belloni1-22/+5
Let the core handle offsetting and windowing the RTC range. The RTC has a 40-bit counter counting at 1024 Hz. So its maximum value is 2^(40-10) - 1. Also, let the core handle the offset instead of coding it in the callbacks. Keep the default epoch at the beginning of 2009 (this will fail in 2043). Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: tps6586x: fix possible race conditionAlexandre Belloni1-3/+11
The probe function is not allowed to fail after the RTC is registered because the following may happen: CPU0: CPU1: sys_load_module() do_init_module() do_one_initcall() cmos_do_probe() rtc_device_register() __register_chrdev() cdev->owner = struct module* open("/dev/rtc0") rtc_device_unregister() module_put() free_module() module_free(mod->module_core) /* struct module *module is now freed */ chrdev_open() spin_lock(cdev_lock) cdev_get() try_module_get() module_is_live() /* dereferences already freed struct module* */ Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: vr41xx: add rangeAlexandre Belloni1-0/+2
The vr41xx RTC is a 48-bit counter counting at 32.768 kHz, giving a maximum value of 2^(48-15)-1 seconds. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: vr41xx: fix possible race conditionAlexandre Belloni1-2/+7
The probe function is not allowed to fail after the RTC is registered because the following may happen: CPU0: CPU1: sys_load_module() do_init_module() do_one_initcall() cmos_do_probe() rtc_device_register() __register_chrdev() cdev->owner = struct module* open("/dev/rtc0") rtc_device_unregister() module_put() free_module() module_free(mod->module_core) /* struct module *module is now freed */ chrdev_open() spin_lock(cdev_lock) cdev_get() try_module_get() module_is_live() /* dereferences already freed struct module* */ Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: rx8581: switch to regmapAlexandre Belloni1-113/+42
Switch to regmap to simplify handling block read/write. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: rx8581: error out when time invalidAlexandre Belloni1-4/+6
Return an error when the date is unreliable because the battery is low. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: rx8581: remove useless declarationAlexandre Belloni1-18/+15
The rx8581_driver forward declaration is useless, remove it. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: rx8581: remove useless indirectionAlexandre Belloni1-12/+4
rx8581_get_datetime and rx8581_set_datetime are only used after casting dev to an i2c_client. Remove that useless indirection. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: rx8581: let the core handle rtc rangeAlexandre Belloni1-5/+4
Let the core handle offsetting and windowing the RTC range. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: rx8581: add RTC rangeAlexandre Belloni1-0/+2
The rx8581 can support dates from 01/01/2000 to 31/12/2099. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: rx8581: switch to rtc_register_deviceAlexandre Belloni1-8/+5
This allows for future improvement of the driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: tps65910: add rangeAlexandre Belloni1-0/+2
The tps65910 RTC can support dates from 01/01/2000 to 31/12/2099. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: tps65910: allow platform power upAlexandre Belloni1-12/+0
Currently, the IRQs are disabled when the rtc driver is removed (e.g. when shutting down the platform). This means that the RTC will be unable to power up the platform. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: tps65910: fix possible race conditionAlexandre Belloni1-4/+8
The IRQ is requested before the struct rtc is allocated and registered, but this struct is used in the IRQ handler. This may lead to a NULL pointer dereference. Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc before requesting the IRQ. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: ab-b5ze-s3: let the core handle the RTC rangeAlexandre Belloni1-9/+2
The ab-b5ze-s3 RTC is storing the year in an 8bit bcd coded register so it can handle dates from year 2000 to year 2099. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: ab-b5ze-s3: fix possible race conditionsAlexandre Belloni1-8/+11
The IRQ is requested before the struct rtc is allocated and registered, but this struct is used in the IRQ handler. This may lead to a NULL pointer dereference. Also, the probe function is not allowed to fail after the RTC is registered because the following may happen: CPU0: CPU1: sys_load_module() do_init_module() do_one_initcall() cmos_do_probe() rtc_device_register() __register_chrdev() cdev->owner = struct module* open("/dev/rtc0") rtc_device_unregister() module_put() free_module() module_free(mod->module_core) /* struct module *module is now freed */ chrdev_open() spin_lock(cdev_lock) cdev_get() try_module_get() module_is_live() /* dereferences already freed struct module* */ Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc before requesting the IRQ and register the RTC as late as possible. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: 88pm80x: convert to rtc_tm_to_time64/rtc_time64_to_tmAlexandre Belloni1-8/+8
Now that the RTC range is properly checked, convert the driver to rtc_tm_to_time64/rtc_time64_to_tm Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: 88pm80x: let the core handle the RTC rangeAlexandre Belloni1-6/+2
The 88pm80x RTC is storing the time as a 32bit offset from a 32bit counter so it can handle dates from 0 to U32_MAX. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: 88pm80x: fix possible race conditionAlexandre Belloni1-4/+8
The IRQ is requested before the struct rtc is allocated and registered, but this struct is used in the IRQ handler. This may lead to a NULL pointer dereference. Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc before requesting the IRQ. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: 88pm80x: remove unused pm80x_rtc_info membersAlexandre Belloni1-2/+0
pm80x_rtc_info.calib_work and pm80x_rtc_info.vrtc are never used, remove them. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: 88pm80x: stop setting a default timeAlexandre Belloni1-22/+0
It doesn't make sense to set the RTC to a default value at probe time. Let the core handle invalid date and time. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-17rtc: at91rm9200: add rangeAlexandre Belloni1-0/+2
The at91rm9200 RTC can support dates from 1900-01-01 00:00:00 to 2099-12-31 23:59:59. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-06rtc: stm32: get DBP register and mask from DT st, syscfg propertyAmelie Delaunay1-22/+37
RTC driver should not be aware of the PWR registers offset and bits position. Furthermore, we can imagine that DBP relative register and bit mask could change depending on the SoC. So this patch introduces 2 parameters, dbp_reg and dbp_mask, allowing to get PWR_CR and PWR_CR_DBP from device tree. And it prepares next RTC version, backup domain write protection is disabled only if needed. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-06rtc: stm32: fix alarm interrupt flags by removing IRQF_TRIGGER_RISINGAmelie Delaunay1-2/+1
RTC alarm interrupt is active high and already configured by device tree. So remove IRQF_TRIGGER_RISING from driver. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-06rtc: stm32: fix copyright and adopt SPDX identifierAmelie Delaunay1-3/+3
Fix copyright by removing "SA" and "for STMicroelectronics", not required. Adopt SPDX identifier. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-03rtc: tps6586x: remove mktime usageArnd Bergmann1-9/+9
The tps6586x use a 64-bit 'epoch_start' value, but then computes that value using an 'mktime()', which has a smaller range and overflows in 2106 at the latest. As both the hardware and the subsystem interface support wider than 32-bit ranges for rtc times here, let's change all the operations on 'seconds' to time64_t. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-03rtc: ls1x: remove mktime usageArnd Bergmann1-3/+4
The loongson1 platform is 32-bit, so storing a time value in 32 bits suffers from limited range. In this case it is likely to be correct until 2106, but it's better to avoid the limitation and just use the time64_t based mktime64() and rtc_time64_to_tm() interfaces. The hardware uses a 32-bit year number, and time64_t can cover that entire range. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-03rtc: vr41xx: remove mktime usageArnd Bergmann1-12/+12
This driver uses mktime() and rtc_time_to_tm() to convert between time values. This works fine on 64-bit kernels over the whole supported range, and the vr41xx chip is a 64-bit MIPS implementation, but it is inconsistent because it doesn't do the same thing on 32-bit kernels that overflow in 2106 or 2038. Changing it to use mktime64/rtc_time64_to_tm() should have no visible impact on vr41xx but gets us closer to removing the 32-bit interfaces. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-03rtc: ds1340: Add support for trickle charger.Andrea Greco1-0/+2
Add support Dallas DS1340 trickle charger function. Signed-off-by: Andrea Greco <a.greco@4sigma.it> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-05-03rtc: sprd: Add RTC hardware rangeBaolin Wang1-0/+2
The SC27xx RTC can support dates from 1970-01-01 00:00:00 to 2149-06-06 23:59:59. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>