Commit graph

144 commits

Author SHA1 Message Date
Anas Nashif a08bfeb49c syscall: rename Z_OOPS -> K_OOPS
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 1a9de05767 syscall: rename Z_SYSCALL_DRIVER_ -> K_SYSCALL_DRIVER_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 9c4d881183 syscall: rename Z_SYSCALL_ to K_SYSCALL_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4e396174ce kernel: move syscall_handler.h to internal include directory
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Benedikt Schmidt a03f1010b8 drivers: fix thread function signatures
Fix thread function signatures to avoid stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Arunmani Alagarsamy e9ecc83eea drivers: rtc: new maxim ds1307 rtc driver
Added rtc driver for ds1307. It allows to read and set the date and time

Signed-off-by: Arunmani Alagarsamy <arunmani27100@gmail.com>
2023-10-27 10:50:46 +02:00
Bjarki Arge Andreasen 99ce7d071f drivers: rtc: Add atmel sam series RTC driver
This commit adds an RTC device driver for the atmel SAM
series chips.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-10-23 10:49:11 +01:00
Ioannis Karachalios 9f76879a0b drivers: rtc: smartbond: Support RTC peripheral.
Add support for the RTC peripheral.

Signed-off-by: Ioannis Karachalios <ioannis.karachalios.px@renesas.com>
2023-10-20 15:10:44 +02:00
Anas Nashif 85c4703a46 drivers: fake: now just check for CONFIG_ZTEST
Old ztest API is deprecated, so only check for CONFIG_ZTEST.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Sri Surya 049aaac696 drivers: rtc: new ambiq am1805 rtc driver
Added RTC driver for am1805 with rtc time, alarm set/get,
callback and calibration.

Signed-off-by: Sri Surya <srisurya@linumiz.com>
2023-09-25 09:47:46 +02:00
Johan Lafon 469ba4e367 driver: rtc: stm23: fix build for STM32L1 Cat.1
The Cat.1 STM32L1 MCUs do not provide the subsecond feature. This disable
subsecond related code for these MCUs.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-20 11:34:52 +01:00
Johan Lafon a63bb6317c drivers: rtc: stm32: allow new RTC driver to work with BBRAM
STM32 BBRAM depends on RTC to work. This changes STM32 RTC init stage to
PRE_KERNEL_1 to allow RTC driver to initialize before BBRAM driver.

Some adjustments are made so that kernel API is not used during the init
procedure.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-20 11:34:52 +01:00
Brett Witherspoon e363c5e26d drivers: rtc: stm32: use single instance driver
This driver only supports a single instance. This commit cleans up the
device definition and indicates this.

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
2023-09-18 10:54:04 +01:00
Brett Witherspoon 462a7262be drivers: rtc: stm32: add build assertion for source clock
Assert the source clock is defined in the device tree to ensure the
reference is valid.

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
2023-09-18 10:54:04 +01:00
Brett Witherspoon 0e8e7a0189 drivers: rtc: stm32: fix cell index of source clock
The DT_INST_CLOCKS_CELL macro takes as the first argument the device
instance and not the cell index. This change correctly gets the second
index of the first device as intended.

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
2023-09-18 10:54:04 +01:00
Benjamin Cabé 6be960ae71 drivers: rtc: drop printk statement from RTC Shell
Remove a printk forgotten in rtc get command.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2023-09-15 12:11:24 +01:00
Johan Lafon 24a2b6b004 drivers: rtc: stm32: fix build warning
Use a mem_addr_t cast to avoid build warning.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-14 14:35:19 +02:00
Johan Lafon 244b437a0d drivers: rtc: stm32: disable calibration for STM32F2 and some STM32L1
STM32F2 and STM32L1 Cat. 1 only provide the coarse calibration feature
which is not supported by the code yet.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon b06a119f2f drivers: rtc: stm32: fill all rtc_time fields
Set tm_yday and tm_isdst to -1 as theses values are unknown.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon 961c465efb drivers: rtc: stm32: use Zephyr BCD<->bin conversion functions
This replaces the verbose LL_RTC_CONVERT_BCD2BIN and LL_RTC_CONVERT_BIN2BCD
by the bcd2bin and bin2bcd Zephyr provided equivalent

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon a8b7076099 drivers: rtc: stm32: ensure thread safe operations
This adds mutex a lock in rtc_stm32_set_time and rtc_stm32_get_time to
ensure consistent data reading. Also performs register reading in a single
operation in rtc_stm32_get_calibration for the same reason.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon e46aff5902 drivers: rtc: stm32: avoid using LL_RTC_Init
LL_RTC_Init() internally uses LL_RTC_EnterInitMode() wich uses a blocking
while loop. This rewrite uses the less CPU time wasteful local
rtc_stm32_enter_initialization_mode() instead. As a side effect
LL_RTC_InitTypeDef in rtc_stm32_config is not needed anymore.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon a4f5f87e29 drivers: rtc: stm32: avoid infinite blocking loop
Use the less CPU intensive and timeout capable WAIT_FOR zephyr provided
macro

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon cdab80eece drivers: rtc: stm32: avoid reset induced time drift
Calling LL_RTC_Init causes the RTC to stop while being configured thus
inducing time drift. This commit avoids doing it at each reset if the RTC
is already properly configured.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon 9e202e57e9 drivers: rtc: stm32: avoid potential erroneous readings
As shadow registers bypass is enabled, an erroneous reading may occur at
each day or second increment. This commit fixes this issue.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon 4eac3db1b9 drivers: rtc: stm32: check if tm_wday is set
tm/rtc_time structure allow for tm_wday to be set to -1 if unknown but RTC
is expecting it

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon f0b3e4e850 drivers: rtc: stm32: check if year is supported by RTC
RTC does not support year before 2000 while tm/rtc_time structure
reference year is 1900

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon 16de401e79 drivers: rtc: stm32: fix day of the week conversion
The conversion used was working but not consistent with values given by
reference manuals.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon 29fa718941 drivers: rtc: stm32: fix wrong nanosecond value
SSR register does not contain direct nanosecond value. This adds the
necessary conversion.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Johan Lafon 8aa6531aed drivers: rtc: stm32: add calibration feature
This adds the set_calibration and get_calibration API functions to the
STM32 RTC driver

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2023-09-12 17:23:47 +01:00
Kim Bøndergaard 44e18e8d47 drivers: rtc: rtc_fake: fff rtc driver added
Can be valuable for unit testing modules accessing the RTC

Signed-off-by: Kim Bøndergaard <kim.bondergaard@prevas.dk>
2023-08-24 22:06:51 +01:00
Kim Bøndergaard eed23e8cb3 drivers: rtc: rtc_shell: rtc shell command suite
For now clock can be read and written.

Clock can be set in full iso8601 time format, like 2023-12-24T12:45:56
or by just providing either data or time

Alarms not accessible

Signed-off-by: Kim Bøndergaard <kim.bondergaard@prevas.dk>
2023-08-24 22:06:51 +01:00
Bjarki Arge Andreasen 2c2f1c4576 drivers/rtc/rtc_mc146818.c: Add input clock config to driver
This commit adds input clock selection to the RTC driver. This
is required to allow for the real hardware to operate. The
QEMU emulated hardware ignores the input clock settings.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-08-09 07:27:40 -04:00
Bjarki Arge Andreasen 588d39112d drivers/rtc/mc146818: Patch MC146818 driver
The MC146818 driver was not properly initialized
by the driver, interrupts where not handled correctly,
and the alarm feature was not implemented properly.

This commit fixes these issues, while removing some
code which became redundant as the MC146818 driver
was patched.

Signed-off-by: Bjarki Arge Andreasen <bjarkix123@gmail.com>
2023-08-09 07:27:40 -04:00
Erwan Gouriou 00a9cb81c0 drivers: rtc: stm32: Exclude STM32F1 from current RTC driver
STM32F1 series RTC is not compatible with other STM32F1 series,
and it uses a different LL API.
Current implementation of the driver doesn't take this into account,
so we need to explicitly exclude STM32F1 series support until
some changes are made.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-07-24 14:38:47 +00:00
Kim Bøndergaard b3c46083fb drivers: rtc: stm32: New stm32 RTC driver
STM32 RTC driver for the new RTC API.
Can't coexist with old COUNTER based RTC

Though supported by HW, RTC_ALARM still to be supported by driver

Signed-off-by: Kim Bøndergaard <kim.bondergaard@prevas.dk>
2023-07-18 11:05:23 +00:00
Florian Grandel 5c4ec518ab driver: rtc: rtc_emul: remove redundant brackets
Change due to review comment: remove redundant brackets for pointer
value access.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-12 09:26:16 +02:00
Florian Grandel ff2b5cebb7 drivers: rtc: rtc_emul: replace mutex with spinlock
Replaces the mutex with a lightweight spinlock.

Fixes: #59901

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
2023-07-12 09:26:16 +02:00
Alvaro Garcia b7f9fb8f82 drivers: added support for clock PCF8563
Added driver support

Signed-off-by: Alvaro Garcia <maxpowel@gmail.com>
2023-07-11 16:14:49 +02:00
Christopher Friedt bf4977e41b drivers: rtc: mc146818: changes for y2k test
The year needs to be corrected to an offset from 1900.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-21 08:20:45 -04:00
Christopher Friedt c8e0022d4b drivers: rtc: mc146818: fix y2k bug
That's correct. We are still fixing the Y2K bug in 2023 \o/

* write century to RAM register 0x32
* ensure year register is in [0,99] (inclusive)

Aside from that, there were a few other errors in the driver.

* translate epoch-centric RTC API year to begin at 1900
* fix off-by-one error with month limit
* fix off-by-one error with wday
* fix off-by-one-hundred error with year limit
* adjust timeptr values in rtc_mc146818_validate_time()
* adjust timeptr values in rtc_mc146818_validate_alarm()

With the above, the testsuite passes!

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-06-20 15:14:08 +02:00
Daniel Leung 26ecaba4af drivers: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Anisetti Avinash Krishna bfeb5043ac drivers: rtc: rtc_mc146818: Added RTC driver for Motorola MC146818B
Added RTC driver that supports Motorola MC146818B
Enabled RTC set/get time and alarm, alarm callback
and update callback.

Counter and RTC uses same hardware in case of
Motorola MC146818, so they can't be used at a time.

Updated stand-alone mc146818 counter dts instances
to support rtc and counter with same compatible
string of "motorola,mc146818" on ia32, atom,
apollo_lake, elhart_lake and raptor_lake platforms.

Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
2023-04-27 14:15:22 +02:00
Henrik Brix Andersen 11fc5d03d1 drivers: rtc: add driver for the nxp pcf8523 rtc
Add RTC device driver for the NXP PCF8523 Real-Time Clock (RTC) and
calendar.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2023-04-27 09:51:42 +02:00
Henrik Brix Andersen 8640f7be8b drivers: rtc: add RTC driver log level configuration
Add Kconfig for setting the RTC driver log level.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2023-04-27 09:51:42 +02:00
Henrik Brix Andersen 29d112c0ff drivers: rtc: allow configuring the RTC initialization priority
Add Kconfig to allow configuring the RTC device driver initialization
priority.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2023-04-27 09:51:42 +02:00
Henrik Brix Andersen 36249451ba drivers: rtc: update the RTC menuconfig title to unified format
Update the RTC driver menuconfig title to match the unified format
introduced in c41dd36de2.

Move the RTC driver menuconfig entry so the menuconfig list is still
(mostly) alphabetically sorted.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-04-17 16:34:46 +02:00
Bjarki Arge Andreasen ae36da516a boards/posix/native_posix: Add emulated RTC device driver
The emulated RTC device driver is used to emulate a real
RTC device. Note that it is not a replacement for the
native_rtc module, which is used to control simulated time,
get time from the host system, etc.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-04-04 17:03:38 +02:00
Bjarki Arge Andreasen ac697d153d tests/drivers/rtc: Add unit tests for RTC devices
This test suite adds tests for the following:

- Setting and getting time
- Validating time is incrementing correctly
- Validating behavior of alarms with callback disabled
- Validating behavior of alarms with callback enabled
- Validating update callback

The test suite uses the devicetree  alias rtc to find
the device to test.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-04-04 17:03:38 +02:00
Bjarki Arge Andreasen b557a1d711 include/drivers: Add RTC API header and handlers
This commit adds the rtc.h header file which contains
API functions for real-time-clocks, which are low power
devices which track and represent broken-down time.

It also changes one line of doxygen documentation in the
maxim_ds3132.h file to place it in its own group.

The handlers for use of the API from userspace is also
added with this commit.

The API is split into one mandatory section, setting and
getting time, and three optional sections, alarms, update
event callback, and clock calibration.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-04-04 17:03:38 +02:00