drivers: rtc: add system calls
rtc_set_config() omitted since it registers a callback. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
2e60b24a80
commit
9ca42fb033
3 changed files with 41 additions and 6 deletions
|
@ -1 +1,2 @@
|
|||
obj-$(CONFIG_RTC_QMSI) += rtc_qmsi.o
|
||||
obj-$(CONFIG_USERSPACE) += rtc_handlers.o
|
||||
|
|
23
drivers/rtc/rtc_handlers.c
Normal file
23
drivers/rtc/rtc_handlers.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <syscall_handler.h>
|
||||
#include <rtc.h>
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE(rtc_read, K_OBJ_DRIVER_RTC, struct device *);
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE_VOID(rtc_enable, K_OBJ_DRIVER_RTC, struct device *);
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE_VOID(rtc_disable, K_OBJ_DRIVER_RTC, struct device *);
|
||||
|
||||
_SYSCALL_HANDLER(rtc_set_alarm, dev, alarm_val)
|
||||
{
|
||||
_SYSCALL_OBJ(dev, K_OBJ_DRIVER_RTC);
|
||||
return _impl_rtc_set_alarm((struct device *)dev, alarm_val);
|
||||
}
|
||||
|
||||
_SYSCALL_HANDLER1_SIMPLE(rtc_get_pending_int, K_OBJ_DRIVER_RTC,
|
||||
struct device *);
|
|
@ -78,22 +78,27 @@ struct rtc_driver_api {
|
|||
rtc_api_get_pending_int get_pending_int;
|
||||
};
|
||||
|
||||
static inline u32_t rtc_read(struct device *dev)
|
||||
__syscall u32_t rtc_read(struct device *dev);
|
||||
|
||||
static inline u32_t _impl_rtc_read(struct device *dev)
|
||||
{
|
||||
const struct rtc_driver_api *api = dev->driver_api;
|
||||
|
||||
return api->read(dev);
|
||||
}
|
||||
|
||||
static inline void rtc_enable(struct device *dev)
|
||||
__syscall void rtc_enable(struct device *dev);
|
||||
|
||||
static inline void _impl_rtc_enable(struct device *dev)
|
||||
{
|
||||
const struct rtc_driver_api *api = dev->driver_api;
|
||||
|
||||
api->enable(dev);
|
||||
}
|
||||
|
||||
__syscall void rtc_disable(struct device *dev);
|
||||
|
||||
static inline void rtc_disable(struct device *dev)
|
||||
static inline void _impl_rtc_disable(struct device *dev)
|
||||
{
|
||||
const struct rtc_driver_api *api = dev->driver_api;
|
||||
|
||||
|
@ -108,7 +113,9 @@ static inline int rtc_set_config(struct device *dev,
|
|||
return api->set_config(dev, cfg);
|
||||
}
|
||||
|
||||
static inline int rtc_set_alarm(struct device *dev,
|
||||
__syscall int rtc_set_alarm(struct device *dev, const u32_t alarm_val);
|
||||
|
||||
static inline int _impl_rtc_set_alarm(struct device *dev,
|
||||
const u32_t alarm_val)
|
||||
{
|
||||
const struct rtc_driver_api *api = dev->driver_api;
|
||||
|
@ -129,7 +136,9 @@ static inline int rtc_set_alarm(struct device *dev,
|
|||
* @retval 1 if the rtc interrupt is pending.
|
||||
* @retval 0 if no rtc interrupt is pending.
|
||||
*/
|
||||
static inline int rtc_get_pending_int(struct device *dev)
|
||||
__syscall int rtc_get_pending_int(struct device *dev);
|
||||
|
||||
static inline int _impl_rtc_get_pending_int(struct device *dev)
|
||||
{
|
||||
struct rtc_driver_api *api;
|
||||
|
||||
|
@ -141,4 +150,6 @@ static inline int rtc_get_pending_int(struct device *dev)
|
|||
}
|
||||
#endif
|
||||
|
||||
#include <syscalls/rtc.h>
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue