[PATCH 0/2 v3 ] watchdog: driver for BCM7038 and newer chips.
This driver is for a watchdog block contained in all Broadcom Set-top Box chips since BCM7038. BCM7038 was made public during the 2004 CES, and since then, many chips use this watchdog block including some cable modem chips. Changes since v2: Added clk_disable_unprepare if watchdog fails to register. Changes since v1: Removed clock-frequency because it brought unnecessary complexity to the driver. Renamed a few variables. Patch 1: watchdog device tree binding documentation Patch 2: watchdog driver Justin Chen (2): watchdog: bcm7038: add device tree binding documentation watchdog: Watchdog driver for Broadcom Set-Top Box .../bindings/watchdog/brcm,bcm7038-wdt.txt | 19 ++ drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm7038_wdt.c | 237 + 4 files changed, 265 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt create mode 100644 drivers/watchdog/bcm7038_wdt.c -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2 v3] watchdog: Watchdog driver for Broadcom Set-Top Box
Watchdog driver for Broadcom 7038 and newer chips. Signed-off-by: Justin Chen Reviewed-by: Guenter Roeck --- drivers/watchdog/Kconfig | 8 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm7038_wdt.c | 237 + 3 files changed, 246 insertions(+) create mode 100644 drivers/watchdog/bcm7038_wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 55c4b5b..b9b 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1292,6 +1292,14 @@ config BCM_KONA_WDT_DEBUG If in doubt, say 'N'. +config BCM7038_WDT + tristate "BCM7038 Watchdog" + select WATCHDOG_CORE + help +Watchdog driver for the built-in hardware in Broadcom 7038 SoCs. + +Say 'Y or 'M' here to enable the driver. + config IMGPDC_WDT tristate "Imagination Technologies PDC Watchdog Timer" depends on HAS_IOMEM diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 59ea9a1..65d4169 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_TEGRA_WATCHDOG) += tegra_wdt.o obj-$(CONFIG_MESON_WATCHDOG) += meson_wdt.o obj-$(CONFIG_MEDIATEK_WATCHDOG) += mtk_wdt.o obj-$(CONFIG_DIGICOLOR_WATCHDOG) += digicolor_wdt.o +obj-$(CONFIG_BCM7038_WDT) += bcm7038_wdt.o # AVR32 Architecture obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o diff --git a/drivers/watchdog/bcm7038_wdt.c b/drivers/watchdog/bcm7038_wdt.c new file mode 100644 index 000..4245b65 --- /dev/null +++ b/drivers/watchdog/bcm7038_wdt.c @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2015 Broadcom Corporation + * + * 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 the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define WDT_START_10xff00 +#define WDT_START_20x00ff +#define WDT_STOP_1 0xee00 +#define WDT_STOP_2 0x00ee + +#define WDT_TIMEOUT_REG0x0 +#define WDT_CMD_REG0x4 + +#define WDT_MIN_TIMEOUT1 /* seconds */ +#define WDT_DEFAULT_TIMEOUT30 /* seconds */ +#define WDT_DEFAULT_RATE 2700 + +struct bcm7038_watchdog { + void __iomem*base; + struct watchdog_device wdd; + u32 rate; + struct clk *clk; +}; + +static bool nowayout = WATCHDOG_NOWAYOUT; + +static void bcm7038_wdt_set_timeout_reg(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + u32 timeout; + + timeout = wdt->rate * wdog->timeout; + + writel(timeout, wdt->base + WDT_TIMEOUT_REG); +} + +static int bcm7038_wdt_ping(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + + writel(WDT_START_1, wdt->base + WDT_CMD_REG); + writel(WDT_START_2, wdt->base + WDT_CMD_REG); + + return 0; +} + +static int bcm7038_wdt_start(struct watchdog_device *wdog) +{ + bcm7038_wdt_set_timeout_reg(wdog); + bcm7038_wdt_ping(wdog); + + return 0; +} + +static int bcm7038_wdt_stop(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + + writel(WDT_STOP_1, wdt->base + WDT_CMD_REG); + writel(WDT_STOP_2, wdt->base + WDT_CMD_REG); + + return 0; +} + +static int bcm7038_wdt_set_timeout(struct watchdog_device *wdog, + unsigned int t) +{ + /* Can't modify timeout value if watchdog timer is running */ + bcm7038_wdt_stop(wdog); + wdog->timeout = t; + bcm7038_wdt_start(wdog); + + return 0; +} + +static unsigned int bcm7038_wdt_get_timeleft(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + u32 time_left; + + time_left = readl(wdt->base + WDT_CMD_REG); + + return time_left / wdt->rate; +} + +static struct watchdog_info bcm7038_wdt_info = { + .identity = "Broadcom BCM7038 Watchdog Timer", + .options= WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | + WDIOF_MAGICCLOSE +}; + +static struct watchdog_ops bcm7038_wdt_ops = { + .owner = THIS_MODULE, + .start = bcm7038_wdt_start, + .stop = bcm7038_wdt_stop, + .set_timeout= bcm7038_wdt_set_timeout, + .get_timelef
[PATCH 1/2 v3] watchdog: bcm7038: add device tree binding documentation
Add device tree binding documentation for the watchdog hardware block on bcm7038 and newer SoCs. Signed-off-by: Justin Chen Acked-by: Guenter Roeck --- .../devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt | 19 +++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt new file mode 100644 index 000..39e5cf5 --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt @@ -0,0 +1,19 @@ +BCM7038 Watchdog timer + +Required properties: + +- compatible : should be "brcm,bcm7038-wdt" +- reg : Specifies base physical address and size of the registers. + +Optional properties: + +- clocks: The clock running the watchdog. If no clock is found the + driver will default to 2700 HZ. + +Example: + +watchdog { + compatible = "brcm,bcm7038-wdt"; + clocks = <&upg_fixed>; + reg = <0xf040a7e8 0x16>; +}; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/2] watchdog: bcm7038: add device tree binding documentation
Add device tree binding documentation for the watchdog hardware block on bcm7038 and newer SoCs. Signed-off-by: Justin Chen Acked-by: Guenter Roeck --- .../devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt | 19 +++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt new file mode 100644 index 000..39e5cf5 --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt @@ -0,0 +1,19 @@ +BCM7038 Watchdog timer + +Required properties: + +- compatible : should be "brcm,bcm7038-wdt" +- reg : Specifies base physical address and size of the registers. + +Optional properties: + +- clocks: The clock running the watchdog. If no clock is found the + driver will default to 2700 HZ. + +Example: + +watchdog { + compatible = "brcm,bcm7038-wdt"; + clocks = <&upg_fixed>; + reg = <0xf040a7e8 0x16>; +}; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 0/2] watchdog: driver for BCM7038 and newer chips.
This driver is for a watchdog block contained in all Broadcom Set-top Box chips since BCM7038. BCM7038 was made public during the 2004 CES, and since then, many chips use this watchdog block including some cable modem chips. Changes since v2: Added clk_disable_unprepare if watchdog fails to register. Changes since v1: Removed clock-frequency because it brought unnecessary complexity to the driver. Renamed a few variables. Patch 1: watchdog device tree binding documentation Patch 2: watchdog driver Justin Chen (2): watchdog: bcm7038: add device tree binding documentation watchdog: Watchdog driver for Broadcom Set-Top Box .../bindings/watchdog/brcm,bcm7038-wdt.txt | 19 ++ drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm7038_wdt.c | 237 + 4 files changed, 265 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt create mode 100644 drivers/watchdog/bcm7038_wdt.c -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/2] watchdog: Watchdog driver for Broadcom Set-Top Box
Watchdog driver for Broadcom 7038 and newer chips. Signed-off-by: Justin Chen --- drivers/watchdog/Kconfig | 8 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm7038_wdt.c | 237 + 3 files changed, 246 insertions(+) create mode 100644 drivers/watchdog/bcm7038_wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 241fafd..4fbe8ab 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1291,6 +1291,14 @@ config BCM_KONA_WDT_DEBUG If in doubt, say 'N'. +config BCM7038_WDT + tristate "BCM7038 Watchdog" + select WATCHDOG_CORE + help +Watchdog driver for the built-in hardware in Broadcom 7038 SoCs. + +Say 'Y or 'M' here to enable the driver. + config IMGPDC_WDT tristate "Imagination Technologies PDC Watchdog Timer" depends on HAS_IOMEM diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 59ea9a1..65d4169 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_TEGRA_WATCHDOG) += tegra_wdt.o obj-$(CONFIG_MESON_WATCHDOG) += meson_wdt.o obj-$(CONFIG_MEDIATEK_WATCHDOG) += mtk_wdt.o obj-$(CONFIG_DIGICOLOR_WATCHDOG) += digicolor_wdt.o +obj-$(CONFIG_BCM7038_WDT) += bcm7038_wdt.o # AVR32 Architecture obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o diff --git a/drivers/watchdog/bcm7038_wdt.c b/drivers/watchdog/bcm7038_wdt.c new file mode 100644 index 000..4245b65 --- /dev/null +++ b/drivers/watchdog/bcm7038_wdt.c @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2015 Broadcom Corporation + * + * 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 the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define WDT_START_10xff00 +#define WDT_START_20x00ff +#define WDT_STOP_1 0xee00 +#define WDT_STOP_2 0x00ee + +#define WDT_TIMEOUT_REG0x0 +#define WDT_CMD_REG0x4 + +#define WDT_MIN_TIMEOUT1 /* seconds */ +#define WDT_DEFAULT_TIMEOUT30 /* seconds */ +#define WDT_DEFAULT_RATE 2700 + +struct bcm7038_watchdog { + void __iomem*base; + struct watchdog_device wdd; + u32 rate; + struct clk *clk; +}; + +static bool nowayout = WATCHDOG_NOWAYOUT; + +static void bcm7038_wdt_set_timeout_reg(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + u32 timeout; + + timeout = wdt->rate * wdog->timeout; + + writel(timeout, wdt->base + WDT_TIMEOUT_REG); +} + +static int bcm7038_wdt_ping(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + + writel(WDT_START_1, wdt->base + WDT_CMD_REG); + writel(WDT_START_2, wdt->base + WDT_CMD_REG); + + return 0; +} + +static int bcm7038_wdt_start(struct watchdog_device *wdog) +{ + bcm7038_wdt_set_timeout_reg(wdog); + bcm7038_wdt_ping(wdog); + + return 0; +} + +static int bcm7038_wdt_stop(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + + writel(WDT_STOP_1, wdt->base + WDT_CMD_REG); + writel(WDT_STOP_2, wdt->base + WDT_CMD_REG); + + return 0; +} + +static int bcm7038_wdt_set_timeout(struct watchdog_device *wdog, + unsigned int t) +{ + /* Can't modify timeout value if watchdog timer is running */ + bcm7038_wdt_stop(wdog); + wdog->timeout = t; + bcm7038_wdt_start(wdog); + + return 0; +} + +static unsigned int bcm7038_wdt_get_timeleft(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + u32 time_left; + + time_left = readl(wdt->base + WDT_CMD_REG); + + return time_left / wdt->rate; +} + +static struct watchdog_info bcm7038_wdt_info = { + .identity = "Broadcom BCM7038 Watchdog Timer", + .options= WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | + WDIOF_MAGICCLOSE +}; + +static struct watchdog_ops bcm7038_wdt_ops = { + .owner = THIS_MODULE, + .start = bcm7038_wdt_start, + .stop = bcm7038_wdt_stop, + .set_timeout= bcm7038_wdt_set_timeout, + .get_timeleft = bcm7038_wdt_get_tim
[PATCH v2 2/2] watchdog: Watchdog driver for Broadcom Set-Top Box
Watchdog driver for Broadcom 7038 and newer chips. Signed-off-by: Justin Chen --- drivers/watchdog/Kconfig | 8 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm7038_wdt.c | 235 + 3 files changed, 244 insertions(+) create mode 100644 drivers/watchdog/bcm7038_wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 241fafd..4fbe8ab 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1291,6 +1291,14 @@ config BCM_KONA_WDT_DEBUG If in doubt, say 'N'. +config BCM7038_WDT + tristate "BCM7038 Watchdog" + select WATCHDOG_CORE + help +Watchdog driver for the built-in hardware in Broadcom 7038 SoCs. + +Say 'Y or 'M' here to enable the driver. + config IMGPDC_WDT tristate "Imagination Technologies PDC Watchdog Timer" depends on HAS_IOMEM diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 59ea9a1..65d4169 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_TEGRA_WATCHDOG) += tegra_wdt.o obj-$(CONFIG_MESON_WATCHDOG) += meson_wdt.o obj-$(CONFIG_MEDIATEK_WATCHDOG) += mtk_wdt.o obj-$(CONFIG_DIGICOLOR_WATCHDOG) += digicolor_wdt.o +obj-$(CONFIG_BCM7038_WDT) += bcm7038_wdt.o # AVR32 Architecture obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o diff --git a/drivers/watchdog/bcm7038_wdt.c b/drivers/watchdog/bcm7038_wdt.c new file mode 100644 index 000..5e54c1b --- /dev/null +++ b/drivers/watchdog/bcm7038_wdt.c @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2015 Broadcom Corporation + * + * 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 the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define WDT_START_10xff00 +#define WDT_START_20x00ff +#define WDT_STOP_1 0xee00 +#define WDT_STOP_2 0x00ee + +#define WDT_TIMEOUT_REG0x0 +#define WDT_CMD_REG0x4 + +#define WDT_MIN_TIMEOUT1 /* seconds */ +#define WDT_DEFAULT_TIMEOUT30 /* seconds */ +#define WDT_DEFAULT_RATE 2700 + +struct bcm7038_watchdog { + void __iomem*base; + struct watchdog_device wdd; + u32 rate; + struct clk *clk; +}; + +static bool nowayout = WATCHDOG_NOWAYOUT; + +static void bcm7038_wdt_set_timeout_reg(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + u32 timeout; + + timeout = wdt->rate * wdog->timeout; + + writel(timeout, wdt->base + WDT_TIMEOUT_REG); +} + +static int bcm7038_wdt_ping(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + + writel(WDT_START_1, wdt->base + WDT_CMD_REG); + writel(WDT_START_2, wdt->base + WDT_CMD_REG); + + return 0; +} + +static int bcm7038_wdt_start(struct watchdog_device *wdog) +{ + bcm7038_wdt_set_timeout_reg(wdog); + bcm7038_wdt_ping(wdog); + + return 0; +} + +static int bcm7038_wdt_stop(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + + writel(WDT_STOP_1, wdt->base + WDT_CMD_REG); + writel(WDT_STOP_2, wdt->base + WDT_CMD_REG); + + return 0; +} + +static int bcm7038_wdt_set_timeout(struct watchdog_device *wdog, + unsigned int t) +{ + /* Can't modify timeout value if watchdog timer is running */ + bcm7038_wdt_stop(wdog); + wdog->timeout = t; + bcm7038_wdt_start(wdog); + + return 0; +} + +static unsigned int bcm7038_wdt_get_timeleft(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + u32 time_left; + + time_left = readl(wdt->base + WDT_CMD_REG); + + return time_left / wdt->rate; +} + +static struct watchdog_info bcm7038_wdt_info = { + .identity = "Broadcom BCM7038 Watchdog Timer", + .options= WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | + WDIOF_MAGICCLOSE +}; + +static struct watchdog_ops bcm7038_wdt_ops = { + .owner = THIS_MODULE, + .start = bcm7038_wdt_start, + .stop = bcm7038_wdt_stop, + .set_timeout= bcm7038_wdt_set_timeout, + .get_timeleft = bcm7038_wdt_get_tim
[PATCH v2 1/2] watchdog: bcm7038: add device tree binding documentation
Add device tree binding documentation for the watchdog hardware block on bcm7038 and newer SoCs. Signed-off-by: Justin Chen --- .../devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt | 19 +++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt new file mode 100644 index 000..39e5cf5 --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt @@ -0,0 +1,19 @@ +BCM7038 Watchdog timer + +Required properties: + +- compatible : should be "brcm,bcm7038-wdt" +- reg : Specifies base physical address and size of the registers. + +Optional properties: + +- clocks: The clock running the watchdog. If no clock is found the + driver will default to 2700 HZ. + +Example: + +watchdog { + compatible = "brcm,bcm7038-wdt"; + clocks = <&upg_fixed>; + reg = <0xf040a7e8 0x16>; +}; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/2] watchdog: driver for BCM7038 and newer chips.
This driver is for a watchdog block contained in all Broadcom Set-top Box chips since BCM7038. BCM7038 was made public during the 2004 CES, and since then, many chips use this watchdog block including some cable modem chips. Changes since v1: Removed clock-frequency because it brought unnecessary complexity to the driver. Renamed a few variables. Patch 1: watchdog device tree binding documentation Patch 2: watchdog driver Justin Chen (2): watchdog: bcm7038: add device tree binding documentation watchdog: Watchdog driver for Broadcom Set-Top Box .../bindings/watchdog/brcm,bcm7038-wdt.txt | 19 ++ drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm7038_wdt.c | 235 + 4 files changed, 263 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt create mode 100644 drivers/watchdog/bcm7038_wdt.c -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] watchdog: bcm7038: add device tree binding documentation
On Tue, Aug 25, 2015 at 12:04:48PM -0700, Guenter Roeck wrote: > Justin, > > On Tue, Aug 25, 2015 at 10:55:40AM -0700, Justin Chen wrote: > > > > Hello Guenter, > > > > > Is 'clock-frequency' really needed (and useful), or would it make more > > > sense > > > to expect the user to configure a fixed clock if nothing else is > > > available ? > > > How do other drivers handle this ? > > > > The reason for 'clock-frequency' was for a case where our device tree did > > not > > have clocks. Creating a new fixed clock for a single device seems > > unnecessary > > compared to a 'clock-frequency' property. Their is a use for > > 'clock-frequency', > > but it is not really necessary. However, this is my first linux patch, so I > > do > > not fully trust my judgement on this... > > > > All that is needed for a fixed clock is a devicetree entry for it. Not sure > I understand your line of argument; you add a lot of complexity and code > just to avoid those few lines in the dts file (especially with 500+ > "fixed-clock" nodes in other devicetree files). > > Thanks, > Guenter Ok your argument makes sense. I will remove the clock-frequency property and modify the driver accordingly. Thank you for your feedback! Thanks, Justin -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] watchdog: bcm7038: add device tree binding documentation
On Sun, Aug 23, 2015 at 08:32:21PM -0700, Guenter Roeck wrote: > Hi Justin, > > On 08/20/2015 10:41 AM, Justin Chen wrote: > >Add device tree binding docmentation for the watchdog hardware block > >on bcm7038 and newer SoCs. > > > >Signed-off-by: Justin Chen > >--- > > .../devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt | 19 > > +++ > > 1 file changed, 19 insertions(+) > > create mode 100644 > > Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt > > > >diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt > >b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt > >new file mode 100644 > >index 000..adb8260 > >--- /dev/null > >+++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt > >@@ -0,0 +1,19 @@ > >+BCM7038 Watchdog timer > >+ > >+Required properties: > >+ > >+- compatible : should be "brcm,bcm7038-wdt" > >+- reg : Specifies base physical address and size of the registers. > >+ > >+Optional properties: > >+ > >+- clocks: the clock running the watchdog > >+- clock-frequency: the rate of the clock > > Is 'clock-frequency' really needed (and useful), or would it make more sense > to expect the user to configure a fixed clock if nothing else is available ? > How do other drivers handle this ? > > Thanks, > Guenter > > >+ > >+Example: > >+ > >+watchdog { > >+compatible = "brcm,bcm7038-wdt"; > >+clocks = <&upg_fixed>; > >+reg = <0xf040a7e8 0x16>; > >+}; > > > Hello Guenter, > Is 'clock-frequency' really needed (and useful), or would it make more sense > to expect the user to configure a fixed clock if nothing else is available ? > How do other drivers handle this ? The reason for 'clock-frequency' was for a case where our device tree did not have clocks. Creating a new fixed clock for a single device seems unnecessary compared to a 'clock-frequency' property. Their is a use for 'clock-frequency', but it is not really necessary. However, this is my first linux patch, so I do not fully trust my judgement on this... Looking at other drivers, none of them have both clock and clock-frequency. Thank you for your time on reviewing the patch Guenter. Much appreciated! Thanks, Justin Chen -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/2] watchdog: Watchdog driver for Broadcom Set-Top Box
Watchdog driver for Broadcom 7038 and newer chips. Signed-off-by: Justin Chen --- drivers/watchdog/Kconfig | 8 ++ drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm7038_wdt.c | 253 + 3 files changed, 262 insertions(+) create mode 100644 drivers/watchdog/bcm7038_wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 241fafd..4fbe8ab 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1291,6 +1291,14 @@ config BCM_KONA_WDT_DEBUG If in doubt, say 'N'. +config BCM7038_WDT + tristate "BCM7038 Watchdog" + select WATCHDOG_CORE + help +Watchdog driver for the built-in hardware in Broadcom 7038 SoCs. + +Say 'Y or 'M' here to enable the driver. + config IMGPDC_WDT tristate "Imagination Technologies PDC Watchdog Timer" depends on HAS_IOMEM diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 59ea9a1..65d4169 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_TEGRA_WATCHDOG) += tegra_wdt.o obj-$(CONFIG_MESON_WATCHDOG) += meson_wdt.o obj-$(CONFIG_MEDIATEK_WATCHDOG) += mtk_wdt.o obj-$(CONFIG_DIGICOLOR_WATCHDOG) += digicolor_wdt.o +obj-$(CONFIG_BCM7038_WDT) += bcm7038_wdt.o # AVR32 Architecture obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o diff --git a/drivers/watchdog/bcm7038_wdt.c b/drivers/watchdog/bcm7038_wdt.c new file mode 100644 index 000..a70730b --- /dev/null +++ b/drivers/watchdog/bcm7038_wdt.c @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2015 Broadcom Corporation + * + * 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 the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define WDT_START_10xff00 +#define WDT_START_20x00ff +#define WDT_STOP_1 0xee00 +#define WDT_STOP_2 0x00ee + +#define WDT_TIMEOUT_REG0x0 +#define WDT_CMD_REG0x4 + +#define WDT_MIN_TIMEOUT1 /* seconds */ +#define WDT_DEFAULT_TIMEOUT30 /* seconds */ +#define WDT_DEFAULT_RATE 2700 + +struct bcm7038_watchdog { + void __iomem*reg; + struct clk *wdt_clk; + struct watchdog_device wdd; + u32 hz; +}; + +static bool nowayout = WATCHDOG_NOWAYOUT; + +static unsigned long bcm7038_wdt_get_rate(struct bcm7038_watchdog *wdt) +{ + /* if clock is missing return hz */ + if (!wdt->wdt_clk) + return wdt->hz; + + return clk_get_rate(wdt->wdt_clk); + +} + +static void bcm7038_wdt_set_timeout_reg(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + u32 timeout; + + timeout = bcm7038_wdt_get_rate(wdt) * wdog->timeout; + + writel(timeout, wdt->reg + WDT_TIMEOUT_REG); +} + +static int bcm7038_wdt_ping(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + + writel(WDT_START_1, wdt->reg + WDT_CMD_REG); + writel(WDT_START_2, wdt->reg + WDT_CMD_REG); + + return 0; +} + +static int bcm7038_wdt_start(struct watchdog_device *wdog) +{ + bcm7038_wdt_set_timeout_reg(wdog); + bcm7038_wdt_ping(wdog); + + return 0; +} + +static int bcm7038_wdt_stop(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + + writel(WDT_STOP_1, wdt->reg + WDT_CMD_REG); + writel(WDT_STOP_2, wdt->reg + WDT_CMD_REG); + + return 0; +} + +static int bcm7038_wdt_set_timeout(struct watchdog_device *wdog, + unsigned int t) +{ + if (watchdog_timeout_invalid(wdog, t)) + return -EINVAL; + + /* Can't modify timeout value if watchdog timer is running */ + bcm7038_wdt_stop(wdog); + wdog->timeout = t; + bcm7038_wdt_start(wdog); + + return 0; +} + +static unsigned int bcm7038_wdt_get_timeleft(struct watchdog_device *wdog) +{ + struct bcm7038_watchdog *wdt = watchdog_get_drvdata(wdog); + u32 time_left; + + time_left = readl(wdt->reg + WDT_CMD_REG); + + return time_left / bcm7038_wdt_get_rate(wdt); +} + +static struct watchdog_info bcm7038_wdt_info = { + .identity = "Broadcom Watchdog Timer", + .options= WDIOF_SETTIMEOUT | WDIOF_KEEPA
[PATCH 1/2] watchdog: bcm7038: add device tree binding documentation
Add device tree binding docmentation for the watchdog hardware block on bcm7038 and newer SoCs. Signed-off-by: Justin Chen --- .../devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt | 19 +++ 1 file changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt diff --git a/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt new file mode 100644 index 000..adb8260 --- /dev/null +++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt @@ -0,0 +1,19 @@ +BCM7038 Watchdog timer + +Required properties: + +- compatible : should be "brcm,bcm7038-wdt" +- reg : Specifies base physical address and size of the registers. + +Optional properties: + +- clocks: the clock running the watchdog +- clock-frequency: the rate of the clock + +Example: + +watchdog { + compatible = "brcm,bcm7038-wdt"; + clocks = <&upg_fixed>; + reg = <0xf040a7e8 0x16>; +}; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/2] watchdog: driver for BCM7038 and newer chips.
This driver is for a watchdog block contained in all Broadcom Set-top Box chips since BCM7038. BCM7038 was made public during the 2004 CES, and since then, many chips use this watchdog block including some cable modem chips. Patch 1: watchdog device tree binding documentation Patch 2: watchdog driver Justin Chen (2): watchdog: bcm7038: add device tree binding documentation watchdog: Watchdog driver for Broadcom Set-Top Box .../bindings/watchdog/brcm,bcm7038-wdt.txt | 19 ++ drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/bcm7038_wdt.c | 253 + 4 files changed, 281 insertions(+) create mode 100644 Documentation/devicetree/bindings/watchdog/brcm,bcm7038-wdt.txt create mode 100644 drivers/watchdog/bcm7038_wdt.c -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html