#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/sysctl.h>
#include <linux/interrupt.h>
#include <linux/workqueue.h>
#include <linux/platform_device.h>
#include <linux/proc_fs.h>
#include <linux/suspend.h>
#include <linux/io.h>
#include <asm/ioctl.h>
#include <linux/spinlock.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
#include <linux/ktime.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/of_gpio.h>
#include <linux/uaccess.h>
#include <linux/notifier.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/miscdevice.h>
#define FEED_DOG_TIMER
typedef struct {
struct device *dev;
struct mutex wdt_lock;
struct work_struct wdt_wq;
struct timer_list wdt_timer;
int wake_up_gp; //wake up gpio, irq;
int feed_dog_gp; // done gpio for feeding watchdog before the next rising edge of wake up gpio
int irq;
int timer_flag;
}tpl5010_wdt_data;
static ssize_t tpl5010_wdt_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
int val;
unsigned int ret;
tpl5010_wdt_data *priv = dev_get_drvdata(dev);
ret = kstrtouint(buf, 16, &val);
if (!priv || ret != 0) {
return ret;
}
switch (val) {
//stop feeding watchdog
case 0:
#ifdef FEED_DOG_TIMER
del_timer(&priv->wdt_timer);
#else
disabled_irq_nosync(priv->irq);
#endif
break;
default:
break;
}
return 0;
}
static DEVICE_ATTR(tp5010_wdt
linux 驱动 demo---笔记
最新推荐文章于 2025-02-26 14:40:16 发布