X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=blobdiff_plain;f=target%2Flinux%2Fatheros%2Fpatches-3.10%2F130-watchdog.patch;h=13eca59edab90a43b95367d20b587968bace00f7;hp=2ae6dcc0f0e8455666fe03331c056f5c5064cd22;hb=c7629cdb4844f8db31bf0ef9d63889011c02e14c;hpb=974b09d6b245379bc54327cdf8ba1b92283466a4 diff --git a/target/linux/atheros/patches-3.10/130-watchdog.patch b/target/linux/atheros/patches-3.10/130-watchdog.patch index 2ae6dcc0f0..13eca59eda 100644 --- a/target/linux/atheros/patches-3.10/130-watchdog.patch +++ b/target/linux/atheros/patches-3.10/130-watchdog.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/drivers/watchdog/ar2315-wtd.c -@@ -0,0 +1,197 @@ +@@ -0,0 +1,209 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by @@ -35,26 +35,37 @@ +#include +#include + -+#include -+#include -+#include ++#define DRIVER_NAME "ar2315-wdt" + +#define CLOCK_RATE 40000000 +#define HEARTBEAT(x) (x < 1 || x > 90 ? 20 : x) + ++#define WDT_REG_TIMER 0x00 ++#define WDT_REG_CTRL 0x04 ++ ++#define WDT_CTRL_ACT_NONE 0x00000000 /* No action */ ++#define WDT_CTRL_ACT_NMI 0x00000001 /* NMI on watchdog */ ++#define WDT_CTRL_ACT_RESET 0x00000002 /* reset on watchdog */ ++ +static int wdt_timeout = 20; +static int started; +static int in_use; ++static void __iomem *wdt_base; ++ ++static inline void ar2315_wdt_wr(unsigned reg, u32 val) ++{ ++ iowrite32(val, wdt_base + reg); ++} + +static void +ar2315_wdt_enable(void) +{ -+ ar231x_write_reg(AR2315_WD, wdt_timeout * CLOCK_RATE); -+ ar231x_write_reg(AR2315_ISR, 0x80); ++ ar2315_wdt_wr(WDT_REG_TIMER, wdt_timeout * CLOCK_RATE); +} + +static ssize_t -+ar2315_wdt_write(struct file *file, const char __user *data, size_t len, loff_t *ppos) ++ar2315_wdt_write(struct file *file, const char __user *data, size_t len, ++ loff_t *ppos) +{ + if (len) + ar2315_wdt_enable(); @@ -87,9 +98,8 @@ + dev_crit(&pdev->dev, "watchdog expired, rebooting system\n"); + emergency_restart(); + } else { -+ ar231x_write_reg(AR2315_WDC, 0); -+ ar231x_write_reg(AR2315_WD, 0); -+ ar231x_write_reg(AR2315_ISR, 0x80); ++ ar2315_wdt_wr(WDT_REG_CTRL, 0); ++ ar2315_wdt_wr(WDT_REG_TIMER, 0); + } + return IRQ_HANDLED; +} @@ -128,7 +138,7 @@ + return ret; +} + -+static struct file_operations ar2315_wdt_fops = { ++static const struct file_operations ar2315_wdt_fops = { + .owner = THIS_MODULE, + .llseek = no_llseek, + .write = ar2315_wdt_write, @@ -146,11 +156,25 @@ +static int +ar2315_wdt_probe(struct platform_device *dev) +{ ++ struct resource *mem_res, *irq_res; + int ret = 0; + -+ ar2315_wdt_enable(); -+ ret = request_irq(AR531X_MISC_IRQ_WATCHDOG, ar2315_wdt_interrupt, -+ IRQF_DISABLED, "ar2315_wdt", dev); ++ if (wdt_base) ++ return -EBUSY; ++ ++ irq_res = platform_get_resource(dev, IORESOURCE_IRQ, 0); ++ if (!irq_res) { ++ dev_err(&dev->dev, "no IRQ resource\n"); ++ return -ENOENT; ++ } ++ ++ mem_res = platform_get_resource(dev, IORESOURCE_MEM, 0); ++ wdt_base = devm_ioremap_resource(&dev->dev, mem_res); ++ if (IS_ERR(wdt_base)) ++ return PTR_ERR(wdt_base); ++ ++ ret = devm_request_irq(&dev->dev, irq_res->start, ar2315_wdt_interrupt, ++ IRQF_DISABLED, DRIVER_NAME, dev); + if (ret) { + dev_err(&dev->dev, "failed to register inetrrupt\n"); + goto out; @@ -168,7 +192,6 @@ +ar2315_wdt_remove(struct platform_device *dev) +{ + misc_deregister(&ar2315_wdt_miscdev); -+ free_irq(AR531X_MISC_IRQ_WATCHDOG, NULL); + return 0; +} + @@ -176,39 +199,29 @@ + .probe = ar2315_wdt_probe, + .remove = ar2315_wdt_remove, + .driver = { -+ .name = "ar2315_wdt", ++ .name = DRIVER_NAME, + .owner = THIS_MODULE, + }, +}; + -+static int __init -+init_ar2315_wdt(void) -+{ -+ int ret = platform_driver_register(&ar2315_wdt_driver); -+ if (ret) -+ pr_err("ar2315_wdt: error registering platfom driver!\n"); -+ return ret; -+} -+ -+static void __exit -+exit_ar2315_wdt(void) -+{ -+ platform_driver_unregister(&ar2315_wdt_driver); -+} ++module_platform_driver(ar2315_wdt_driver); + -+module_init(init_ar2315_wdt); -+module_exit(exit_ar2315_wdt); ++MODULE_DESCRIPTION("Atheros AR2315 hardware watchdog driver"); ++MODULE_AUTHOR("John Crispin "); ++MODULE_LICENSE("GPL"); ++MODULE_ALIAS("platform:" DRIVER_NAME); --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig -@@ -1113,6 +1113,12 @@ config LANTIQ_WDT +@@ -1113,6 +1113,13 @@ config LANTIQ_WDT help Hardware driver for the Lantiq SoC Watchdog Timer. -+config ATHEROS_WDT -+ tristate "Atheros wisoc Watchdog Timer" ++config AR2315_WDT ++ tristate "Atheros AR2315+ WiSoCs Watchdog Timer" + depends on ATHEROS_AR231X + help -+ Hardware driver for the Atheros wisoc Watchdog Timer. ++ Hardware driver for the built-in watchdog timer on the Atheros ++ AR2315/AR2316 WiSoCs. + # PARISC Architecture @@ -219,7 +232,7 @@ obj-$(CONFIG_PNX833X_WDT) += pnx833x_wdt.o obj-$(CONFIG_SIBYTE_WDOG) += sb_wdog.o obj-$(CONFIG_AR7_WDT) += ar7_wdt.o -+obj-$(CONFIG_ATHEROS_WDT) += ar2315-wtd.o ++obj-$(CONFIG_AR2315_WDT) += ar2315-wtd.o obj-$(CONFIG_TXX9_WDT) += txx9wdt.o obj-$(CONFIG_OCTEON_WDT) += octeon-wdt.o octeon-wdt-y := octeon-wdt-main.o octeon-wdt-nmi.o