watchdog: Add WDT driver for Atmel SAM SoCs

Basic Watchdog driver for Atmel SAM family MCUs. Currently only
disabling the watchdog is supported.

Tested on Atmel SAMV71 Xplained Ultra Evaluation Kit.

Origin: Original

Jira: ZEP-1684

Change-Id: I8f717c7f53aa290c944b7935e0570c2a6f53956e
Signed-off-by: Souvik K Chakravarty <souvik.k.chakravarty@intel.com>
This commit is contained in:
Souvik K Chakravarty 2017-03-07 08:56:58 +05:30 committed by Maureen Helm
commit 8fa2f82524
5 changed files with 126 additions and 0 deletions

View file

@ -43,6 +43,8 @@ features:
+-----------+------------+-------------------------------------+
| ETHERNET | on-chip | ethernet |
+-----------+------------+-------------------------------------+
| WATCHDOG | on-chip | watchdog |
+-----------+------------+-------------------------------------+
Other hardware features are not currently supported by Zephyr.

View file

@ -24,4 +24,6 @@ source "drivers/watchdog/Kconfig.stm32"
source "drivers/watchdog/Kconfig.cmsdk_apb"
source "drivers/watchdog/Kconfig.sam"
endif

View file

@ -0,0 +1,27 @@
# Kconfig - Atmel SAM WDT configuration
#
# Copyright (C) 2017 Intel Deutschland GmbH
#
# SPDX-License-Identifier: Apache-2.0
#
menuconfig WDT_SAM
bool "Atmel SAM MCU Family Watchdog (WDT) Driver"
depends on SOC_FAMILY_SAM
default y
help
Enable WDT driver for Atmel SAM MCUs.
config WDT_SAM_DISABLE_AT_BOOT
bool "Disable WDT during boot"
depends on WDT_SAM
default y
help
Select this option to disable the WDT during boot.
config WDT_SAM_DEVICE_NAME
string "Device name for Watchdog (WDT)"
depends on WDT_SAM
default "WDT"
help
Set the name used by WDT device during registration.

View file

@ -1,3 +1,4 @@
obj-$(CONFIG_WDT_QMSI) += wdt_qmsi.o
obj-$(CONFIG_IWDG_STM32) += iwdg_stm32.o
obj-$(CONFIG_WDOG_CMSDK_APB) += wdog_cmsdk_apb.o
obj-$(CONFIG_WDT_SAM) += wdt_sam.o

View file

@ -0,0 +1,94 @@
/*
* Copyright (C) 2017 Intel Deutschland GmbH
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @brief Watchdog (WDT) Driver for Atmel SAM MCUs
*
* Note:
* - Once the watchdog disable bit is set, it cannot be cleared till next
* power reset, i.e, the watchdog cannot be started once stopped.
* - Since the MCU boots with WDT enabled, only basic feature (disable) is
* currently implemented for systems that don't need watchdog functionality.
*
*/
#include <watchdog.h>
#include <soc.h>
#define SYS_LOG_DOMAIN "dev/wdt_sam"
#include <logging/sys_log.h>
/* Device constant configuration parameters */
struct wdt_sam_dev_cfg {
Wdt *regs;
};
#define DEV_CFG(dev) \
((const struct wdt_sam_dev_cfg *const)(dev)->config->config_info)
static void wdt_sam_enable(struct device *dev)
{
ARG_UNUSED(dev);
SYS_LOG_ERR("Function not implemented!");
}
static void wdt_sam_disable(struct device *dev)
{
Wdt *const wdt = DEV_CFG(dev)->regs;
wdt->WDT_MR |= WDT_MR_WDDIS;
}
static int wdt_sam_set_config(struct device *dev, struct wdt_config *config)
{
ARG_UNUSED(dev);
ARG_UNUSED(config);
SYS_LOG_ERR("Function not implemented!");
return -ENOTSUP;
}
static void wdt_sam_get_config(struct device *dev, struct wdt_config *config)
{
ARG_UNUSED(dev);
ARG_UNUSED(config);
SYS_LOG_ERR("Function not implemented!");
}
static void wdt_sam_reload(struct device *dev)
{
ARG_UNUSED(dev);
SYS_LOG_ERR("Function not implemented!");
}
static const struct wdt_driver_api wdt_sam_api = {
.enable = wdt_sam_enable,
.disable = wdt_sam_disable,
.get_config = wdt_sam_get_config,
.set_config = wdt_sam_set_config,
.reload = wdt_sam_reload
};
static int wdt_sam_init(struct device *dev)
{
#ifdef CONFIG_WDT_SAM_DISABLE_AT_BOOT
wdt_sam_disable(dev);
#endif
return 0;
}
static const struct wdt_sam_dev_cfg wdt_sam_config = {
.regs = WDT
};
DEVICE_AND_API_INIT(wdt_sam, CONFIG_WDT_SAM_DEVICE_NAME, wdt_sam_init,
NULL, &wdt_sam_config,
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
&wdt_sam_api);