Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1687641 > unrolled thread
| Started by | Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> |
|---|---|
| First post | 2017-07-14 22:10 +0200 |
| Last post | 2017-07-14 22:20 +0200 |
| Articles | 6 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v4 0/8] Add board support for TS-4600 Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> - 2017-07-14 22:10 +0200
[PATCH v4 5/8] ARM: dts: TS-4600: add NBUS support Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> - 2017-07-14 22:20 +0200
[PATCH v4 6/8] dt-bindings: watchdog: add documentation for TS4600 watchdog controller Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> - 2017-07-14 22:20 +0200
[PATCH v4 8/8] ARM: dts: TS-4600: add watchdog support Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> - 2017-07-14 22:20 +0200
[PATCH v4 2/8] ARM: dts: TS-4600: add basic device tree Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> - 2017-07-14 22:20 +0200
[PATCH v4 7/8] watchdog: TS-4600: add driver for TS-4600 watchdog controller Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> - 2017-07-14 22:20 +0200
| From | Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-14 22:10 +0200 |
| Subject | [PATCH v4 0/8] Add board support for TS-4600 |
| Message-ID | <u3f4u-8lt-7@gated-at.bofh.it> |
This patch serie adds support for the TS-4600 boards rev A and B. These
boards, manufactured by Technologic Systems, are based on an i.MX28.
This serie include the support for the watchdog which could be enable
at Linux boot time depending on the bootloader.
The watchdog and few peripherals are implemented in a FPGA, and can
only be access using a custom GPIOs bit-banged bus which is called the
NBUS by Technologic Systems.
A driver for this bus is also included and used by the watchdog.
Sebastien Bourdelin (8):
of: documentation: add bindings documentation for TS-4600
ARM: dts: TS-4600: add basic device tree
dt-bindings: bus: Add documentation for the Technologic Systems NBUS
bus: add driver for the Technologic Systems NBUS
ARM: dts: TS-4600: add NBUS support
dt-bindings: watchdog: add documentation for TS4600 watchdog
controller
watchdog: TS-4600: add driver for TS-4600 watchdog controller
ARM: dts: TS-4600: add watchdog support
.../devicetree/bindings/arm/technologic.txt | 5 +
Documentation/devicetree/bindings/bus/ts-nbus.txt | 50 +++
.../devicetree/bindings/watchdog/ts4600-wdt.txt | 16 +
arch/arm/boot/dts/Makefile | 2 +
arch/arm/boot/dts/imx28-ts4600-common.dtsi | 126 +++++++
arch/arm/boot/dts/imx28-ts4600-rev-a.dts | 22 ++
arch/arm/boot/dts/imx28-ts4600-rev-b.dts | 22 ++
drivers/bus/Kconfig | 8 +
drivers/bus/Makefile | 1 +
drivers/bus/ts-nbus.c | 375 +++++++++++++++++++++
drivers/watchdog/Kconfig | 11 +
drivers/watchdog/Makefile | 1 +
drivers/watchdog/ts4600_wdt.c | 185 ++++++++++
include/linux/ts-nbus.h | 18 +
14 files changed, 842 insertions(+)
create mode 100644 Documentation/devicetree/bindings/bus/ts-nbus.txt
create mode 100644 Documentation/devicetree/bindings/watchdog/ts4600-wdt.txt
create mode 100644 arch/arm/boot/dts/imx28-ts4600-common.dtsi
create mode 100644 arch/arm/boot/dts/imx28-ts4600-rev-a.dts
create mode 100644 arch/arm/boot/dts/imx28-ts4600-rev-b.dts
create mode 100644 drivers/bus/ts-nbus.c
create mode 100644 drivers/watchdog/ts4600_wdt.c
create mode 100644 include/linux/ts-nbus.h
--
2.13.0
[toc] | [next] | [standalone]
| From | Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-14 22:20 +0200 |
| Subject | [PATCH v4 5/8] ARM: dts: TS-4600: add NBUS support |
| Message-ID | <u3fea-8p4-11@gated-at.bofh.it> |
| In reply to | #1687641 |
This commit enables the NBUS on the TS-4600, using the ts-nbus driver.
---
Changes v3 -> v4:
- rebase on master
- fix vendor prefixes for dts properties (suggested by Rob Herring)
- v3 was acked by Linus Walleij
Changes v2 -> v3:
- rebase on master
Changes v1 -> v2:
- rebase on master
- remove the simple-bus compatibility as the root node will now
populate the child nodes (suggested by Rob Herring)
- add the vendor prefix to all gpio (suggested by Rob Herring)
Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
---
arch/arm/boot/dts/imx28-ts4600-common.dtsi | 43 ++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/arch/arm/boot/dts/imx28-ts4600-common.dtsi b/arch/arm/boot/dts/imx28-ts4600-common.dtsi
index 04bd5a5c0cb4..a90bd934e4a3 100644
--- a/arch/arm/boot/dts/imx28-ts4600-common.dtsi
+++ b/arch/arm/boot/dts/imx28-ts4600-common.dtsi
@@ -44,6 +44,28 @@
fsl,pull-up = <MXS_PULL_DISABLE>;
};
+ nbus_pins: nbus_pins {
+ fsl,pinmux-ids = <
+ MX28_PAD_GPMI_D00__GPIO_0_0
+ MX28_PAD_GPMI_D01__GPIO_0_1
+ MX28_PAD_GPMI_D02__GPIO_0_2
+ MX28_PAD_GPMI_D03__GPIO_0_3
+ MX28_PAD_GPMI_D04__GPIO_0_4
+ MX28_PAD_GPMI_D05__GPIO_0_5
+ MX28_PAD_GPMI_D06__GPIO_0_6
+ MX28_PAD_GPMI_D07__GPIO_0_7
+ MX28_PAD_GPMI_CE0N__GPIO_0_16
+ MX28_PAD_GPMI_RDY1__GPIO_0_21
+ MX28_PAD_GPMI_RDN__GPIO_0_24
+ MX28_PAD_GPMI_WRN__GPIO_0_25
+ MX28_PAD_GPMI_ALE__GPIO_0_26
+ >;
+ fsl,drive-strength = <MXS_DRIVE_4mA>;
+ fsl,voltage = <MXS_VOLTAGE_HIGH>;
+ fsl,pull-up = <MXS_PULL_DISABLE>;
+
+ };
+
};
};
@@ -75,4 +97,25 @@
};
};
+ nbus {
+ compatible = "technologic,ts-nbus";
+ pinctrl-0 = <&nbus_pins>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pwms = <&pwm 2 83>;
+ ts,data-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH
+ &gpio0 1 GPIO_ACTIVE_HIGH
+ &gpio0 2 GPIO_ACTIVE_HIGH
+ &gpio0 3 GPIO_ACTIVE_HIGH
+ &gpio0 4 GPIO_ACTIVE_HIGH
+ &gpio0 5 GPIO_ACTIVE_HIGH
+ &gpio0 6 GPIO_ACTIVE_HIGH
+ &gpio0 7 GPIO_ACTIVE_HIGH>;
+ ts,csn-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>;
+ ts,txrx-gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>;
+ ts,strobe-gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
+ ts,ale-gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>;
+ ts,rdy-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;
+ };
+
};
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-14 22:20 +0200 |
| Subject | [PATCH v4 6/8] dt-bindings: watchdog: add documentation for TS4600 watchdog controller |
| Message-ID | <u3fea-8p4-17@gated-at.bofh.it> |
| In reply to | #1687641 |
This patch adds dt-binding documentation for TS4600 watchdog controller.
Acked-by: Rob Herring <robh@kernel.org>
---
v4:
- this documentation was previously merged with the watchdog driver
and had been acked by Rob Herring, no changes have been done since.
Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
---
.../devicetree/bindings/watchdog/ts4600-wdt.txt | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100644 Documentation/devicetree/bindings/watchdog/ts4600-wdt.txt
diff --git a/Documentation/devicetree/bindings/watchdog/ts4600-wdt.txt b/Documentation/devicetree/bindings/watchdog/ts4600-wdt.txt
new file mode 100644
index 000000000000..7de00ceae341
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/ts4600-wdt.txt
@@ -0,0 +1,16 @@
+TS-4600 Technologic Systems Watchdog
+
+Required properties:
+- compatible: must be "technologic,ts4600-wdt"
+- reg: offset to the FPGA's watchdog register
+
+Optional property:
+- timeout-sec: contains the watchdog timeout in seconds.
+
+Example:
+
+watchdog {
+ compatible = "technologic,ts4600-wdt";
+ reg = <0x2a>;
+ timeout-sec = <10>;
+};
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-14 22:20 +0200 |
| Subject | [PATCH v4 8/8] ARM: dts: TS-4600: add watchdog support |
| Message-ID | <u3fea-8p4-19@gated-at.bofh.it> |
| In reply to | #1687641 |
This enables support for the watchdog located in the FPGA.
Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
---
arch/arm/boot/dts/imx28-ts4600-common.dtsi | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/imx28-ts4600-common.dtsi b/arch/arm/boot/dts/imx28-ts4600-common.dtsi
index a90bd934e4a3..9e177d33ba9c 100644
--- a/arch/arm/boot/dts/imx28-ts4600-common.dtsi
+++ b/arch/arm/boot/dts/imx28-ts4600-common.dtsi
@@ -116,6 +116,11 @@
ts,strobe-gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
ts,ale-gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>;
ts,rdy-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>;
+
+ watchdog@2a {
+ compatible = "technologic,ts4600-wdt";
+ reg = <0x2a>;
+ };
};
};
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-14 22:20 +0200 |
| Subject | [PATCH v4 2/8] ARM: dts: TS-4600: add basic device tree |
| Message-ID | <u3fea-8p4-15@gated-at.bofh.it> |
| In reply to | #1687641 |
These device trees add support for the TS-4600 by Technologic Systems.
More details here:
http://wiki.embeddedarm.com/wiki/TS-4600
---
Changes v3 -> v4:
- rebase on master
Changes v2 -> v3:
- rebase on master
Changes v1 -> v2:
- rebase on master
Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
---
arch/arm/boot/dts/Makefile | 2 +
arch/arm/boot/dts/imx28-ts4600-common.dtsi | 78 ++++++++++++++++++++++++++++++
arch/arm/boot/dts/imx28-ts4600-rev-a.dts | 22 +++++++++
arch/arm/boot/dts/imx28-ts4600-rev-b.dts | 22 +++++++++
4 files changed, 124 insertions(+)
create mode 100644 arch/arm/boot/dts/imx28-ts4600-common.dtsi
create mode 100644 arch/arm/boot/dts/imx28-ts4600-rev-a.dts
create mode 100644 arch/arm/boot/dts/imx28-ts4600-rev-b.dts
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 4b17f35dc9a7..a3c8b7af192b 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -525,6 +525,8 @@ dtb-$(CONFIG_ARCH_MXS) += \
imx28-m28cu3.dtb \
imx28-m28evk.dtb \
imx28-sps1.dtb \
+ imx28-ts4600-rev-a.dtb \
+ imx28-ts4600-rev-b.dtb \
imx28-tx28.dtb
dtb-$(CONFIG_ARCH_NOMADIK) += \
ste-nomadik-s8815.dtb \
diff --git a/arch/arm/boot/dts/imx28-ts4600-common.dtsi b/arch/arm/boot/dts/imx28-ts4600-common.dtsi
new file mode 100644
index 000000000000..04bd5a5c0cb4
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-ts4600-common.dtsi
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2016 Savoir-Faire Linux
+ * Author: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx28.dtsi"
+#include "dt-bindings/gpio/gpio.h"
+
+/ {
+
+ compatible = "technologic,imx28-ts4600", "fsl,imx28";
+
+ apb@80000000 {
+ apbh@80000000 {
+ ssp0: ssp@80010000 {
+ compatible = "fsl,imx28-mmc";
+ pinctrl-names = "default";
+ pinctrl-0 = <&mmc0_4bit_pins_a
+ &mmc0_sck_cfg
+ &en_sd_pwr>;
+ broken-cd = <1>;
+ bus-width = <4>;
+ vmmc-supply = <®_vddio_sd0>;
+ status = "okay";
+ };
+
+ pinctrl@80018000 {
+ pinctrl-names = "default";
+
+ en_sd_pwr: en_sd_pwr {
+ fsl,pinmux-ids = <
+ MX28_PAD_PWM3__GPIO_3_28
+ >;
+ fsl,drive-strength = <MXS_DRIVE_4mA>;
+ fsl,voltage = <MXS_VOLTAGE_HIGH>;
+ fsl,pull-up = <MXS_PULL_DISABLE>;
+ };
+
+ };
+ };
+
+ apbx@80040000 {
+ pwm: pwm@80064000 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm2_pins_a>;
+ status = "okay";
+ };
+
+ duart: serial@80074000 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&duart_pins_a>;
+ status = "okay";
+ };
+ };
+ };
+
+ regulators {
+ compatible = "simple-bus";
+
+ reg_vddio_sd0: vddio-sd0 {
+ compatible = "regulator-fixed";
+ regulator-name = "vddio-sd0";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ gpio = <&gpio3 28 0>;
+ };
+ };
+
+};
diff --git a/arch/arm/boot/dts/imx28-ts4600-rev-a.dts b/arch/arm/boot/dts/imx28-ts4600-rev-a.dts
new file mode 100644
index 000000000000..e8cb72988fcf
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-ts4600-rev-a.dts
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2016 Savoir-Faire Linux
+ * Author: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include "imx28-ts4600-common.dtsi"
+
+/ {
+ model = "Technologic Systems i.MX28 TS-4600 Rev A";
+
+ memory {
+ reg = <0x40000000 0x08000000>; /* 128MB */
+ };
+
+};
diff --git a/arch/arm/boot/dts/imx28-ts4600-rev-b.dts b/arch/arm/boot/dts/imx28-ts4600-rev-b.dts
new file mode 100644
index 000000000000..a115f831fe2b
--- /dev/null
+++ b/arch/arm/boot/dts/imx28-ts4600-rev-b.dts
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2016 Savoir-Faire Linux
+ * Author: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include "imx28-ts4600-common.dtsi"
+
+/ {
+ model = "Technologic Systems i.MX28 TS-4600 Rev B";
+
+ memory {
+ reg = <0x40000000 0x10000000>; /* 256MB */
+ };
+
+};
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com> |
|---|---|
| Date | 2017-07-14 22:20 +0200 |
| Subject | [PATCH v4 7/8] watchdog: TS-4600: add driver for TS-4600 watchdog controller |
| Message-ID | <u3fea-8p4-29@gated-at.bofh.it> |
| In reply to | #1687641 |
This watchdog is instantiated in a FPGA and can only be access using a
GPIOs bit-banged bus, called the NBUS by Technologic Systems.
The watchdog is made of only one register, called the feed register.
Writing to this register will re-arm the watchdog for a given time (and
enable it if it was disable). It can be disabled by writing a special
value into it.
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
---
Changes v3 -> v4:
- rebase on master
- remove the dts and the documentation associated from the driver
commit (suggested by Shawn Guo)
- the driver in v3 was acked by Guenter Roeck and no changes on the
driver have been done.
Changes v2 -> v3:
- rebase on master
- remove the timeout table to simplify the logic (suggested by
Guenter Roeck)
- fix the set_timeout function (suggested by Guenter Roeck)
- hardcode the max_hw_heartbeat_ms value based on the ts4600 max
timeout value supported (suggested by Guenter Roeck)
- remove the max_timeout usage and set a default timeout value
(suggested by Guenter Roeck)
- use the devm_watchdog_register_device function instead of
watchdog_register_device (suggested by Guenter Roeck)
- v2 was acked by Rob Herring
Changes v1 -> v2:
- rebase on master
- retrieve the ts_nbus instantiated by the parent node (suggested by
Linus Walleij)
- rename the wdt by watchdog in the device tree and in the
documentation (suggested by Rob Herring)
- add a dependency to the TS_NBUS driver in the Kconfig (suggested by
Guenter Roeck)
- simplify the set_timeout function (suggested by Guenter Roeck)
- use the max_hw_heartbeat_ms callback instead of the max_timeout
callback (suggested by Guenter Roeck)
Signed-off-by: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
---
drivers/watchdog/Kconfig | 11 +++
drivers/watchdog/Makefile | 1 +
drivers/watchdog/ts4600_wdt.c | 185 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
create mode 100644 drivers/watchdog/ts4600_wdt.c
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index c722cbfdc7e6..d50fbc232d9e 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -531,6 +531,17 @@ config NUC900_WATCHDOG
To compile this driver as a module, choose M here: the
module will be called nuc900_wdt.
+config TS4600_WATCHDOG
+ tristate "TS-4600 Watchdog"
+ depends on TS_NBUS
+ depends on HAS_IOMEM && OF
+ depends on SOC_IMX28 || COMPILE_TEST
+ select WATCHDOG_CORE
+ help
+ Technologic Systems TS-4600 has watchdog timer implemented in
+ an external FPGA. Say Y here if you want to support for the
+ watchdog timer on TS-4600 board.
+
config TS4800_WATCHDOG
tristate "TS-4800 Watchdog"
depends on HAS_IOMEM && OF
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 56adf9fa67d0..a95aa4a13b39 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_RN5T618_WATCHDOG) += rn5t618_wdt.o
obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o
obj-$(CONFIG_STMP3XXX_RTC_WATCHDOG) += stmp3xxx_rtc_wdt.o
obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o
+obj-$(CONFIG_TS4600_WATCHDOG) += ts4600_wdt.o
obj-$(CONFIG_TS4800_WATCHDOG) += ts4800_wdt.o
obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
diff --git a/drivers/watchdog/ts4600_wdt.c b/drivers/watchdog/ts4600_wdt.c
new file mode 100644
index 000000000000..ed530dd2f800
--- /dev/null
+++ b/drivers/watchdog/ts4600_wdt.c
@@ -0,0 +1,185 @@
+/*
+ * Watchdog driver for TS-4600 based boards
+ *
+ * Copyright (c) 2016 - Savoir-faire Linux
+ * Author: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ *
+ * The watchdog on the TS-4600 based boards is in an FPGA and can only be
+ * accessed using a GPIO bit-banged bus called the NBUS by Technologic Systems.
+ * The logic for the watchdog is the same then for the TS-4800 SoM, only the way
+ * to access it change, therefore this driver is heavely based on the ts4800_wdt
+ * driver from Damien Riegel <damien.riegel@savoirfairelinux.com>.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/ts-nbus.h>
+#include <linux/watchdog.h>
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout,
+ "Watchdog cannot be stopped once started (default="
+ __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+/*
+ * TS-4600 supports the following timeout values:
+ *
+ * value desc
+ * ---------------------
+ * 0 feed for 338ms
+ * 1 feed for 2.706s
+ * 2 feed for 10.824s
+ * 3 disable watchdog
+ */
+#define TS4600_WDT_FEED_2S 0x1
+#define TS4600_WDT_FEED_10S 0x2
+#define TS4600_WDT_DISABLE 0x3
+
+struct ts4600_wdt {
+ struct watchdog_device wdd;
+ struct ts_nbus *ts_nbus;
+ u32 feed_offset;
+ u32 feed_val;
+};
+
+static void ts4600_write_feed(struct ts4600_wdt *wdt, u32 val)
+{
+ ts_nbus_write(wdt->ts_nbus, wdt->feed_offset, val);
+}
+
+static int ts4600_wdt_start(struct watchdog_device *wdd)
+{
+ struct ts4600_wdt *wdt = watchdog_get_drvdata(wdd);
+
+ ts4600_write_feed(wdt, wdt->feed_val);
+
+ return 0;
+}
+
+static int ts4600_wdt_stop(struct watchdog_device *wdd)
+{
+ struct ts4600_wdt *wdt = watchdog_get_drvdata(wdd);
+
+ ts4600_write_feed(wdt, TS4600_WDT_DISABLE);
+ return 0;
+}
+
+static int ts4600_wdt_set_timeout(struct watchdog_device *wdd,
+ unsigned int timeout)
+{
+ struct ts4600_wdt *wdt = watchdog_get_drvdata(wdd);
+
+ if (timeout <= 2) {
+ wdd->timeout = 2;
+ wdt->feed_val = TS4600_WDT_FEED_2S;
+ } else {
+ wdd->timeout = timeout < 10 ? 10 : timeout;
+ wdt->feed_val = TS4600_WDT_FEED_10S;
+ }
+
+ return 0;
+}
+
+static const struct watchdog_ops ts4600_wdt_ops = {
+ .owner = THIS_MODULE,
+ .start = ts4600_wdt_start,
+ .stop = ts4600_wdt_stop,
+ .set_timeout = ts4600_wdt_set_timeout,
+};
+
+static const struct watchdog_info ts4600_wdt_info = {
+ .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
+ .identity = "TS-4600 Watchdog",
+};
+
+static int ts4600_wdt_probe(struct platform_device *pdev)
+{
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct ts_nbus *ts_nbus;
+ struct watchdog_device *wdd;
+ struct ts4600_wdt *wdt;
+ u32 reg;
+ int ret;
+
+ ret = of_property_read_u32(np, "reg", ®);
+ if (ret < 0) {
+ dev_err(&pdev->dev, "missing reg property\n");
+ return ret;
+ }
+
+ /* allocate memory for watchdog struct */
+ wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
+ if (!wdt)
+ return -ENOMEM;
+
+ /* set offset to know where to write */
+ wdt->feed_offset = reg;
+
+ /* keep a pointer to the ts_nbus instanciated by the parent node */
+ ts_nbus = dev_get_drvdata(dev->parent);
+ if (!ts_nbus) {
+ dev_err(dev, "missing ts-nbus compatible parent node\n");
+ return PTR_ERR(ts_nbus);
+ }
+ wdt->ts_nbus = ts_nbus;
+
+ /* Initialize struct watchdog_device */
+ wdd = &wdt->wdd;
+ wdd->parent = dev;
+ wdd->info = &ts4600_wdt_info;
+ wdd->ops = &ts4600_wdt_ops;
+ wdd->min_timeout = 2;
+ wdd->max_hw_heartbeat_ms = 10824;
+ wdd->timeout = 30;
+
+ watchdog_set_drvdata(wdd, wdt);
+ watchdog_set_nowayout(wdd, nowayout);
+ watchdog_init_timeout(wdd, 0, dev);
+
+ ts4600_wdt_set_timeout(wdd, wdd->timeout);
+
+ /*
+ * The feed register is write-only, so it is not possible to determine
+ * watchdog's state. Disable it to be in a known state.
+ */
+ ts4600_wdt_stop(wdd);
+
+ ret = devm_watchdog_register_device(&pdev->dev, &wdt->wdd);
+ if (ret) {
+ dev_err(dev, "failed to register watchdog device\n");
+ return ret;
+ }
+
+ dev_info(dev, "initialized (timeout = %d sec, nowayout = %d)\n",
+ wdd->timeout, nowayout);
+
+ return 0;
+}
+
+static const struct of_device_id ts4600_wdt_of_match[] = {
+ { .compatible = "technologic,ts4600-wdt", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, ts4600_wdt_of_match);
+
+static struct platform_driver ts4600_wdt_driver = {
+ .probe = ts4600_wdt_probe,
+ .driver = {
+ .name = "ts4600_wdt",
+ .of_match_table = ts4600_wdt_of_match,
+ },
+};
+
+module_platform_driver(ts4600_wdt_driver);
+
+MODULE_AUTHOR("Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:ts4600_wdt");
--
2.13.0
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web