linux/drivers/watchdog/apple_wdt.c

// SPDX-License-Identifier: GPL-2.0-only OR MIT
/*
 * Apple SoC Watchdog driver
 *
 * Copyright (C) The Asahi Linux Contributors
 */

#include <linux/bits.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/limits.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/watchdog.h>

/*
 * Apple Watchdog MMIO registers
 *
 * This HW block has three separate watchdogs. WD0 resets the machine
 * to recovery mode and is not very useful for us. WD1 and WD2 trigger a normal
 * machine reset. WD0 additionally supports a configurable interrupt.
 * This information can be used to implement pretimeout support at a later time.
 *
 * APPLE_WDT_WDx_CUR_TIME is a simple counter incremented for each tick of the
 * reference clock. It can also be overwritten to any value.
 * Whenever APPLE_WDT_CTRL_RESET_EN is set in APPLE_WDT_WDx_CTRL and
 * APPLE_WDT_WDx_CUR_TIME >= APPLE_WDT_WDx_BITE_TIME the entire machine is
 * reset.
 * Whenever APPLE_WDT_CTRL_IRQ_EN is set and APPLE_WDTx_WD1_CUR_TIME >=
 * APPLE_WDTx_WD1_BARK_TIME an interrupt is triggered and
 * APPLE_WDT_CTRL_IRQ_STATUS is set. The interrupt can be cleared by writing
 * 1 to APPLE_WDT_CTRL_IRQ_STATUS.
 */
#define APPLE_WDT_WD0_CUR_TIME
#define APPLE_WDT_WD0_BITE_TIME
#define APPLE_WDT_WD0_BARK_TIME
#define APPLE_WDT_WD0_CTRL

#define APPLE_WDT_WD1_CUR_TIME
#define APPLE_WDT_WD1_BITE_TIME
#define APPLE_WDT_WD1_CTRL

#define APPLE_WDT_WD2_CUR_TIME
#define APPLE_WDT_WD2_BITE_TIME
#define APPLE_WDT_WD2_CTRL

#define APPLE_WDT_CTRL_IRQ_EN
#define APPLE_WDT_CTRL_IRQ_STATUS
#define APPLE_WDT_CTRL_RESET_EN

#define APPLE_WDT_TIMEOUT_DEFAULT

struct apple_wdt {};

static struct apple_wdt *to_apple_wdt(struct watchdog_device *wdd)
{}

static int apple_wdt_start(struct watchdog_device *wdd)
{}

static int apple_wdt_stop(struct watchdog_device *wdd)
{}

static int apple_wdt_ping(struct watchdog_device *wdd)
{}

static int apple_wdt_set_timeout(struct watchdog_device *wdd, unsigned int s)
{}

static unsigned int apple_wdt_get_timeleft(struct watchdog_device *wdd)
{}

static int apple_wdt_restart(struct watchdog_device *wdd, unsigned long mode,
			     void *cmd)
{}

static struct watchdog_ops apple_wdt_ops =;

static struct watchdog_info apple_wdt_info =;

static int apple_wdt_probe(struct platform_device *pdev)
{}

static int apple_wdt_resume(struct device *dev)
{}

static int apple_wdt_suspend(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(apple_wdt_pm_ops, apple_wdt_suspend, apple_wdt_resume);

static const struct of_device_id apple_wdt_of_match[] =;
MODULE_DEVICE_TABLE(of, apple_wdt_of_match);

static struct platform_driver apple_wdt_driver =;
module_platform_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();