drivers: wdog: Update CMSDK Wdog driver
The commit 0c2ef4ea3d
"drivers:
watchdog: Watchdog API redesign" introduced an API redesign for the
watchdog drivers compliant with Zephyr.
This patch updated the CMSDK Watchdog driver to be compliant with the
new API.
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@linaro.org>
This commit is contained in:
parent
e5460c6bcc
commit
03c7d9bd49
1 changed files with 19 additions and 25 deletions
|
@ -64,9 +64,9 @@ struct device *wdog_r;
|
||||||
|
|
||||||
/* watchdog reload value in sec */
|
/* watchdog reload value in sec */
|
||||||
static unsigned int reload_s = CMSDK_APB_WDOG_RELOAD;
|
static unsigned int reload_s = CMSDK_APB_WDOG_RELOAD;
|
||||||
static unsigned int mode;
|
static u8_t flags;
|
||||||
|
|
||||||
static void (*user_cb)(struct device *dev);
|
static void (*user_cb)(struct device *dev, int channel_id);
|
||||||
|
|
||||||
static void wdog_cmsdk_apb_unlock(struct device *dev)
|
static void wdog_cmsdk_apb_unlock(struct device *dev)
|
||||||
{
|
{
|
||||||
|
@ -77,14 +77,17 @@ static void wdog_cmsdk_apb_unlock(struct device *dev)
|
||||||
wdog->lock = CMSDK_APB_WDOG_UNLOCK_VALUE;
|
wdog->lock = CMSDK_APB_WDOG_UNLOCK_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wdog_cmsdk_apb_enable(struct device *dev)
|
static int wdog_cmsdk_apb_setup(struct device *dev, u8_t options)
|
||||||
{
|
{
|
||||||
volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT;
|
volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT;
|
||||||
|
|
||||||
ARG_UNUSED(dev);
|
ARG_UNUSED(dev);
|
||||||
|
ARG_UNUSED(options);
|
||||||
|
|
||||||
/* Start the watchdog counter with INTEN bit */
|
/* Start the watchdog counter with INTEN bit */
|
||||||
wdog->ctrl = (CMSDK_APB_WDOG_CTRL_RESEN | CMSDK_APB_WDOG_CTRL_INTEN);
|
wdog->ctrl = (CMSDK_APB_WDOG_CTRL_RESEN | CMSDK_APB_WDOG_CTRL_INTEN);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wdog_cmsdk_apb_disable(struct device *dev)
|
static int wdog_cmsdk_apb_disable(struct device *dev)
|
||||||
|
@ -99,55 +102,46 @@ static int wdog_cmsdk_apb_disable(struct device *dev)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wdog_cmsdk_apb_set_config(struct device *dev,
|
static int wdog_cmsdk_apb_install_timeout(struct device *dev,
|
||||||
struct wdt_config *config)
|
const struct wdt_timeout_cfg *config)
|
||||||
{
|
{
|
||||||
volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT;
|
volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT;
|
||||||
|
|
||||||
ARG_UNUSED(dev);
|
ARG_UNUSED(dev);
|
||||||
|
|
||||||
/* Reload value */
|
/* Reload value */
|
||||||
reload_s = config->timeout * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
|
reload_s = config->window.max * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
|
||||||
mode = config->mode;
|
flags = config->flags;
|
||||||
|
|
||||||
wdog->load = reload_s;
|
wdog->load = reload_s;
|
||||||
|
|
||||||
/* Configure only the callback */
|
/* Configure only the callback */
|
||||||
user_cb = config->interrupt_fn;
|
user_cb = config->callback;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wdog_cmsdk_apb_get_config(struct device *dev,
|
static int wdog_cmsdk_apb_feed(struct device *dev, int channel_id)
|
||||||
struct wdt_config *config)
|
|
||||||
{
|
|
||||||
ARG_UNUSED(dev);
|
|
||||||
|
|
||||||
/* Return stored configuration */
|
|
||||||
config->timeout = reload_s / CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
|
|
||||||
config->mode = mode;
|
|
||||||
config->interrupt_fn = user_cb;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wdog_cmsdk_apb_reload(struct device *dev)
|
|
||||||
{
|
{
|
||||||
volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT;
|
volatile struct wdog_cmsdk_apb *wdog = WDOG_STRUCT;
|
||||||
|
|
||||||
ARG_UNUSED(dev);
|
ARG_UNUSED(dev);
|
||||||
|
ARG_UNUSED(channel_id);
|
||||||
|
|
||||||
/* Clear the interrupt */
|
/* Clear the interrupt */
|
||||||
wdog->intclr = CMSDK_APB_WDOG_INTCLR;
|
wdog->intclr = CMSDK_APB_WDOG_INTCLR;
|
||||||
|
|
||||||
/* Reload */
|
/* Reload */
|
||||||
wdog->load = reload_s;
|
wdog->load = reload_s;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wdt_driver_api wdog_cmsdk_apb_api = {
|
static const struct wdt_driver_api wdog_cmsdk_apb_api = {
|
||||||
.enable = wdog_cmsdk_apb_enable,
|
.setup = wdog_cmsdk_apb_setup,
|
||||||
.disable = wdog_cmsdk_apb_disable,
|
.disable = wdog_cmsdk_apb_disable,
|
||||||
.get_config = wdog_cmsdk_apb_get_config,
|
.install_timeout = wdog_cmsdk_apb_install_timeout,
|
||||||
.set_config = wdog_cmsdk_apb_set_config,
|
.feed = wdog_cmsdk_apb_feed,
|
||||||
.reload = wdog_cmsdk_apb_reload,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_RUNTIME_NMI
|
#ifdef CONFIG_RUNTIME_NMI
|
||||||
|
@ -172,7 +166,7 @@ static void wdog_cmsdk_apb_isr(void)
|
||||||
sys_reboot(0);
|
sys_reboot(0);
|
||||||
} else {
|
} else {
|
||||||
if (user_cb != NULL) {
|
if (user_cb != NULL) {
|
||||||
user_cb(wdog_r);
|
user_cb(wdog_r, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue