devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Add board support for TS-4800
@ 2015-10-27 20:33 Damien Riegel
       [not found] ` <1445978021-13961-1-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Damien Riegel @ 2015-10-27 20:33 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA
  Cc: shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/, Damien Riegel

This patch serie adds support for TS-4800 board. This board,
manufactured by Technologic Systems, is based on an IMX515.

The first stage bootloader, called TS-BOOTROM, enables the watchdog,
so a watchdog driver is required to prevent board from rebooting.

The current device tree is minimal but it allows to get a shell on the
board.

Damien Riegel (4):
  of: add vendor prefix for Technologic Systems
  watchdog: ts4800: add new driver for TS-4800 watchdog
  ARM: imx_v6_v7_defconfig: add TS-4800 watchdog
  ARM: dts: TS-4800: add basic device tree

 Documentation/devicetree/bindings/arm/ts.txt       |   6 +
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 .../devicetree/bindings/watchdog/ts4800-wdt.txt    |  12 ++
 arch/arm/boot/dts/Makefile                         |   3 +-
 arch/arm/boot/dts/imx51-ts4800.dts                 | 186 ++++++++++++++++++
 arch/arm/configs/imx_v6_v7_defconfig               |   1 +
 drivers/watchdog/Kconfig                           |   9 +
 drivers/watchdog/Makefile                          |   1 +
 drivers/watchdog/ts4800_wdt.c                      | 212 +++++++++++++++++++++
 9 files changed, 430 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/arm/ts.txt
 create mode 100644 Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
 create mode 100644 arch/arm/boot/dts/imx51-ts4800.dts
 create mode 100644 drivers/watchdog/ts4800_wdt.c

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/4] of: add vendor prefix for Technologic Systems
       [not found] ` <1445978021-13961-1-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
@ 2015-10-27 20:33   ` Damien Riegel
       [not found]     ` <1445978021-13961-2-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  2015-10-27 20:33   ` [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog Damien Riegel
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 15+ messages in thread
From: Damien Riegel @ 2015-10-27 20:33 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA
  Cc: shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/, Damien Riegel

Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index d444757..68aad78a 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -211,6 +211,7 @@ toshiba	Toshiba Corporation
 toumaz	Toumaz
 tplink	TP-LINK Technologies Co., Ltd.
 truly	Truly Semiconductors Limited
+ts	Technologic Systems
 usi	Universal Scientific Industrial Co., Ltd.
 v3	V3 Semiconductor
 variscite	Variscite Ltd.
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog
       [not found] ` <1445978021-13961-1-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  2015-10-27 20:33   ` [PATCH 1/4] of: add vendor prefix for Technologic Systems Damien Riegel
@ 2015-10-27 20:33   ` Damien Riegel
       [not found]     ` <1445978021-13961-3-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  2015-10-27 20:33   ` [PATCH 3/4] ARM: imx_v6_v7_defconfig: add " Damien Riegel
  2015-10-27 20:33   ` [PATCH 4/4] ARM: dts: TS-4800: add basic device tree Damien Riegel
  3 siblings, 1 reply; 15+ messages in thread
From: Damien Riegel @ 2015-10-27 20:33 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA
  Cc: shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/, Damien Riegel

Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
---
 .../devicetree/bindings/watchdog/ts4800-wdt.txt    |  12 ++
 drivers/watchdog/Kconfig                           |   9 +
 drivers/watchdog/Makefile                          |   1 +
 drivers/watchdog/ts4800_wdt.c                      | 212 +++++++++++++++++++++
 4 files changed, 234 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
 create mode 100644 drivers/watchdog/ts4800_wdt.c

diff --git a/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
new file mode 100644
index 0000000..06bdb5f
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
@@ -0,0 +1,12 @@
+Technologic Systems Watchdog
+
+Required properties:
+- compatible : must be "ts,ts4800-wdt"
+- reg : physical base address and length of memory mapped region
+
+Example:
+
+wdt1: wdt@b0010000 {
+	compatible = "ts,ts4800-wdt";
+	reg = <0xb0010000 0x1000>;
+};
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 241fafd..cf30f3b 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -417,6 +417,15 @@ config NUC900_WATCHDOG
 	  To compile this driver as a module, choose M here: the
 	  module will be called nuc900_wdt.
 
+config TS4800_WATCHDOG
+	tristate "TS-4800 Watchdog"
+	depends on SOC_IMX51
+	select WATCHDOG_CORE
+	help
+	  Technologic Systems TS-4800 has watchdog timer implemented in
+	  an external FPGA. Say Y here if you want to support for the
+	  watchdog timer on TS-4800 board.
+
 config TS72XX_WATCHDOG
 	tristate "TS-72XX SBC Watchdog"
 	depends on MACH_TS72XX
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 59ea9a1..435fc93 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -52,6 +52,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_TS4800_WATCHDOG) += ts4800_wdt.o
 obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
 obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
 obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o
diff --git a/drivers/watchdog/ts4800_wdt.c b/drivers/watchdog/ts4800_wdt.c
new file mode 100644
index 0000000..bf3badf
--- /dev/null
+++ b/drivers/watchdog/ts4800_wdt.c
@@ -0,0 +1,212 @@
+/*
+ * ts4800_wdt.c - Watchdog driver for TS-4800 based boards
+ *
+ * Copyright (c) 2015 - Savoir-faire Linux
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/watchdog.h>
+#include <linux/platform_device.h>
+#include <linux/io.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) ")");
+
+
+/* feed register is at base + 0xE */
+#define TS4800_WTD_FEED		0xE
+
+/* possible feed values */
+#define TS4800_WTD_FEED_2S	0x1
+#define TS4800_WTD_FEED_10S	0x2
+#define TS4800_WTD_DISABLE	0x3
+
+
+struct ts4800_wdt {
+	struct watchdog_device  wdd;
+	void __iomem            *base;
+	u16                     feed_val;
+};
+
+/* TS-4800 supports the following timeout values:
+ *
+ *   value desc
+ *   ---------------------
+ *     0    feed for 338ms
+ *     1    feed for 2.706s
+ *     2    feed for 10.824s
+ *     3    disable watchd
+ *
+ * Keep the regmap/timeout map ordered by timeout
+ */
+static const struct {
+	const int timeout;
+	const int regval;
+} ts4800_wdt_map[] = {
+	{ 2, 1 },
+	{ 10, 2 },
+};
+
+static int timeout_to_regval(struct watchdog_device *wdd, int new_timeout)
+{
+	int i;
+
+	new_timeout = clamp_val(new_timeout,
+				wdd->min_timeout, wdd->max_timeout);
+
+	for (i = 0; i < ARRAY_SIZE(ts4800_wdt_map); i++) {
+		if (ts4800_wdt_map[i].timeout >= new_timeout)
+			return ts4800_wdt_map[i].timeout;
+	}
+
+	return -EINVAL;
+}
+
+static void ts4800_write_feed(struct ts4800_wdt *wdt, u16 val)
+{
+	__raw_writew(val, wdt->base + TS4800_WTD_FEED);
+}
+
+static int ts4800_wdt_ping(struct watchdog_device *wdd)
+{
+	struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
+
+	ts4800_write_feed(wdt, wdt->feed_val);
+	return 0;
+}
+
+static int ts4800_wdt_stop(struct watchdog_device *wdd)
+{
+	struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
+
+	ts4800_write_feed(wdt, TS4800_WTD_DISABLE);
+	return 0;
+}
+
+static int ts4800_wdt_set_timeout(struct watchdog_device *wdd,
+				  unsigned int new_timeout)
+{
+	struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
+	int val = timeout_to_regval(wdd, new_timeout);
+
+	if (val < 0)
+		return val;
+
+	wdt->feed_val = (u16) val;
+
+	return 0;
+}
+
+static const struct watchdog_ops ts4800_wdt_ops = {
+	.owner = THIS_MODULE,
+	/*
+	 * pinging the watchdog enables it, so use same function
+	 * for pinging and starting the watchdog
+	 */
+	.start = ts4800_wdt_ping,
+	.stop = ts4800_wdt_stop,
+	.ping = ts4800_wdt_ping,
+	.set_timeout = ts4800_wdt_set_timeout,
+};
+
+static const struct watchdog_info ts4800_wdt_info = {
+	.options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
+	.identity = "TS-4800 Watchdog",
+};
+
+static int ts4800_wdt_probe(struct platform_device *pdev)
+{
+	int max_timeout_index = ARRAY_SIZE(ts4800_wdt_map) - 1;
+	struct watchdog_device *wdd;
+	struct ts4800_wdt *wdt;
+	struct resource *res;
+	void __iomem *regs;
+	int ret;
+
+	/* get watchdog base addr */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
+
+	/* allocate memory for watchdog struct */
+	wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);
+	if (!wdt)
+		return -ENOMEM;
+
+	/* set watchdog base addr */
+	wdt->base = regs;
+
+	/* Initialize struct watchdog_device */
+	wdd = &wdt->wdd;
+	wdd->info = &ts4800_wdt_info;
+	wdd->ops = &ts4800_wdt_ops;
+	wdd->min_timeout = ts4800_wdt_map[0].timeout;
+	wdd->max_timeout = ts4800_wdt_map[max_timeout_index].timeout;
+	wdd->timeout = wdd->max_timeout;
+	wdt->feed_val = ts4800_wdt_map[max_timeout_index].regval;
+
+	watchdog_set_drvdata(wdd, wdt);
+	watchdog_set_nowayout(wdd, nowayout);
+
+	/*
+	 * Must be called after watchdog_set_drvdata to dereference a valid
+	 * pointer. The feed register is write-only, so it is not possible to
+	 * determine if watchdog is already started or not. Disable it to be in
+	 * a known state.
+	 */
+	ts4800_wdt_stop(wdd);
+
+	ret = watchdog_register_device(wdd);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"failed to register watchdog device\n");
+		return ret;
+	}
+
+	platform_set_drvdata(pdev, wdt);
+
+	dev_info(&pdev->dev,
+		 "initialized (timeout = %d sec, nowayout = %d)\n",
+		 wdd->timeout, nowayout);
+
+	return 0;
+}
+
+static int ts4800_wdt_remove(struct platform_device *pdev)
+{
+	struct ts4800_wdt *wdt = platform_get_drvdata(pdev);
+
+	watchdog_unregister_device(&wdt->wdd);
+
+	return 0;
+}
+
+static const struct of_device_id ts4800_wdt_of_match[] = {
+	{ .compatible = "ts,ts4800-wdt", },
+	{ },
+};
+MODULE_DEVICE_TABLE(of, ts4800_wdt_of_match);
+
+static struct platform_driver ts4800_wdt_driver = {
+	.probe		= ts4800_wdt_probe,
+	.remove		= ts4800_wdt_remove,
+	.driver		= {
+		.name	= "ts4800_wdt",
+		.of_match_table = ts4800_wdt_of_match,
+	},
+};
+
+module_platform_driver(ts4800_wdt_driver);
+
+MODULE_AUTHOR("Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:ts4800_wdt");
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/4] ARM: imx_v6_v7_defconfig: add TS-4800 watchdog
       [not found] ` <1445978021-13961-1-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  2015-10-27 20:33   ` [PATCH 1/4] of: add vendor prefix for Technologic Systems Damien Riegel
  2015-10-27 20:33   ` [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog Damien Riegel
@ 2015-10-27 20:33   ` Damien Riegel
  2015-10-27 20:33   ` [PATCH 4/4] ARM: dts: TS-4800: add basic device tree Damien Riegel
  3 siblings, 0 replies; 15+ messages in thread
From: Damien Riegel @ 2015-10-27 20:33 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA
  Cc: shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/, Damien Riegel

Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
---
 arch/arm/configs/imx_v6_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index b47863d..6bb3a50 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -190,6 +190,7 @@ CONFIG_THERMAL=y
 CONFIG_CPU_THERMAL=y
 CONFIG_IMX_THERMAL=y
 CONFIG_WATCHDOG=y
+CONFIG_TS4800_WATCHDOG=y
 CONFIG_IMX2_WDT=y
 CONFIG_MFD_DA9052_I2C=y
 CONFIG_MFD_MC13XXX_SPI=y
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/4] ARM: dts: TS-4800: add basic device tree
       [not found] ` <1445978021-13961-1-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
                     ` (2 preceding siblings ...)
  2015-10-27 20:33   ` [PATCH 3/4] ARM: imx_v6_v7_defconfig: add " Damien Riegel
@ 2015-10-27 20:33   ` Damien Riegel
       [not found]     ` <1445978021-13961-5-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  3 siblings, 1 reply; 15+ messages in thread
From: Damien Riegel @ 2015-10-27 20:33 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA
  Cc: shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/, Damien Riegel

This device tree adds support for TS-4800 by Technologic Systems. This
board is based on MX51-babbage, but there are some subtle differences in
the pins used, and there is an additional FPGA that is memory-mapped.

More details here:
  http://wiki.embeddedarm.com/wiki/TS-4800

Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
---
 Documentation/devicetree/bindings/arm/ts.txt |   6 +
 arch/arm/boot/dts/Makefile                   |   3 +-
 arch/arm/boot/dts/imx51-ts4800.dts           | 186 +++++++++++++++++++++++++++
 3 files changed, 194 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/arm/ts.txt
 create mode 100644 arch/arm/boot/dts/imx51-ts4800.dts

diff --git a/Documentation/devicetree/bindings/arm/ts.txt b/Documentation/devicetree/bindings/arm/ts.txt
new file mode 100644
index 0000000..1b01651
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/ts.txt
@@ -0,0 +1,6 @@
+Technologic Systems Platforms Device Tree Bindings
+--------------------------------------------------
+
+TS-4800 board
+Required root node properties:
+	- compatible = "ts,imx51-ts4800", "fsl,imx51";
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 246473a..541829a 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -254,7 +254,8 @@ dtb-$(CONFIG_SOC_IMX51) += \
 	imx51-apf51dev.dtb \
 	imx51-babbage.dtb \
 	imx51-digi-connectcore-jsk.dtb \
-	imx51-eukrea-mbimxsd51-baseboard.dtb
+	imx51-eukrea-mbimxsd51-baseboard.dtb \
+	imx51-ts4800.dtb
 dtb-$(CONFIG_SOC_IMX53) += \
 	imx53-ard.dtb \
 	imx53-m53evk.dtb \
diff --git a/arch/arm/boot/dts/imx51-ts4800.dts b/arch/arm/boot/dts/imx51-ts4800.dts
new file mode 100644
index 0000000..d8c88aa
--- /dev/null
+++ b/arch/arm/boot/dts/imx51-ts4800.dts
@@ -0,0 +1,186 @@
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ * Copyright 2011 Linaro Ltd.
+ * Copyright 2015 Savoir-faire Linux
+ *
+ * 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:
+ *
+ * This device tree is based on imx51-babbage.dts
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include "imx51.dtsi"
+
+/ {
+	model = "Technologic Systems TS4800";
+	compatible = "ts,imx51-ts4800", "fsl,imx51";
+
+	chosen {
+		stdout-path = &uart1;
+	};
+
+	memory {
+		reg = <0x90000000 0x10000000>;
+	};
+
+	soc {
+		fpga {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "simple-bus";
+			reg = <0xb0000000 0x1d000>;
+			ranges;
+
+			wdt1: wdt@b0010000 {
+				compatible = "ts,ts4800-wdt";
+				reg = <0xb0010000 0x1000>;
+			};
+		};
+	};
+
+	clocks {
+		ckih1 {
+			clock-frequency = <22579200>;
+		};
+
+		ckih2 {
+			clock-frequency = <24576000>;
+		};
+	};
+};
+
+&esdhc1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_esdhc1>;
+	cd-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
+	wp-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
+	status = "okay";
+};
+
+&fec {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_fec>;
+	phy-mode = "mii";
+	phy-reset-gpios = <&gpio2 14 GPIO_ACTIVE_LOW>;
+	phy-reset-duration = <1>;
+	status = "okay";
+};
+
+&uart1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_uart1>;
+	status = "okay";
+};
+
+&uart2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_uart2>;
+	status = "okay";
+};
+
+&uart3 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_uart3>;
+	status = "okay";
+};
+
+&i2c2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_i2c2>;
+	status = "okay";
+
+	rtc: m41t00@68 {
+		compatible = "stm,m41t00";
+		reg = <0x68>;
+	};
+};
+
+
+&iomuxc {
+	imx51-ts4800 {
+
+		pinctrl_ecspi1: ecspi1grp {
+			fsl,pins = <
+				MX51_PAD_CSPI1_MISO__ECSPI1_MISO	0x185
+				MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI	0x185
+				MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK	0x185
+				MX51_PAD_CSPI1_SS0__GPIO4_24		0x85 /* CS0 */
+			>;
+		};
+
+		pinctrl_esdhc1: esdhc1grp {
+			fsl,pins = <
+				MX51_PAD_SD1_CMD__SD1_CMD		0x400020d5
+				MX51_PAD_SD1_CLK__SD1_CLK		0x20d5
+				MX51_PAD_SD1_DATA0__SD1_DATA0		0x20d5
+				MX51_PAD_SD1_DATA1__SD1_DATA1		0x20d5
+				MX51_PAD_SD1_DATA2__SD1_DATA2		0x20d5
+				MX51_PAD_SD1_DATA3__SD1_DATA3		0x20d5
+				MX51_PAD_GPIO1_0__GPIO1_0		0x100
+				MX51_PAD_GPIO1_1__GPIO1_1		0x100
+			>;
+		};
+
+		pinctrl_fec: fecgrp {
+			fsl,pins = <
+				MX51_PAD_EIM_EB2__FEC_MDIO		0x000001f5
+				MX51_PAD_EIM_EB3__FEC_RDATA1		0x00000085
+				MX51_PAD_EIM_CS2__FEC_RDATA2		0x00000085
+				MX51_PAD_EIM_CS3__FEC_RDATA3		0x00000085
+				MX51_PAD_EIM_CS4__FEC_RX_ER		0x00000180
+				MX51_PAD_EIM_CS5__FEC_CRS		0x00000180
+				MX51_PAD_DISP2_DAT10__FEC_COL		0x00000180
+				MX51_PAD_DISP2_DAT11__FEC_RX_CLK		0x00000180
+				MX51_PAD_DISP2_DAT14__FEC_RDATA0		0x00002180
+				MX51_PAD_DISP2_DAT15__FEC_TDATA0		0x00002004
+				MX51_PAD_NANDF_CS2__FEC_TX_ER		0x00002004
+				MX51_PAD_DI2_PIN2__FEC_MDC		0x00002004
+				MX51_PAD_DISP2_DAT6__FEC_TDATA1		0x00002004
+				MX51_PAD_DISP2_DAT7__FEC_TDATA2		0x00002004
+				MX51_PAD_DISP2_DAT8__FEC_TDATA3		0x00002004
+				MX51_PAD_DISP2_DAT9__FEC_TX_EN		0x00002004
+				MX51_PAD_DISP2_DAT13__FEC_TX_CLK	0x00002180
+				MX51_PAD_DISP2_DAT12__FEC_RX_DV		0x000020a4
+				MX51_PAD_EIM_A20__GPIO2_14		0x00000085 /* Phy Reset */
+			>;
+		};
+
+		pinctrl_i2c2: i2c2grp {
+			fsl,pins = <
+				MX51_PAD_KEY_COL4__I2C2_SCL		0x400001ed
+				MX51_PAD_KEY_COL5__I2C2_SDA		0x400001ed
+			>;
+		};
+
+		pinctrl_uart1: uart1grp {
+			fsl,pins = <
+				MX51_PAD_UART1_RXD__UART1_RXD		0x1c5
+				MX51_PAD_UART1_TXD__UART1_TXD		0x1c5
+				MX51_PAD_UART1_RTS__UART1_RTS		0x1c5
+				MX51_PAD_UART1_CTS__UART1_CTS		0x1c5
+			>;
+		};
+
+		pinctrl_uart2: uart2grp {
+			fsl,pins = <
+				MX51_PAD_UART2_RXD__UART2_RXD		0x1c5
+				MX51_PAD_UART2_TXD__UART2_TXD		0x1c5
+			>;
+		};
+
+		pinctrl_uart3: uart3grp {
+			fsl,pins = <
+				MX51_PAD_EIM_D25__UART3_RXD		0x1c5
+				MX51_PAD_EIM_D26__UART3_TXD		0x1c5
+				MX51_PAD_EIM_D27__UART3_RTS		0x1c5
+				MX51_PAD_EIM_D24__UART3_CTS		0x1c5
+			>;
+		};
+
+	};
+};
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog
       [not found]     ` <1445978021-13961-3-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
@ 2015-10-27 21:20       ` Dinh Nguyen
       [not found]         ` <CADhT+wdWcYMQ_ZPhcGOye3oP=6N+Yos+sbqV20E5x5Hmfm8ycw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2015-10-30 12:53       ` Arnd Bergmann
  2015-11-11 23:28       ` Rob Herring
  2 siblings, 1 reply; 15+ messages in thread
From: Dinh Nguyen @ 2015-10-27 21:20 UTC (permalink / raw)
  To: Damien Riegel
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, Sascha Hauer, Wim Van Sebroeck,
	Rob Herring, kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Tue, Oct 27, 2015 at 3:33 PM, Damien Riegel
<damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org> wrote:
> Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
> ---
>  .../devicetree/bindings/watchdog/ts4800-wdt.txt    |  12 ++
>  drivers/watchdog/Kconfig                           |   9 +
>  drivers/watchdog/Makefile                          |   1 +
>  drivers/watchdog/ts4800_wdt.c                      | 212 +++++++++++++++++++++
>  4 files changed, 234 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
>  create mode 100644 drivers/watchdog/ts4800_wdt.c
>
> diff --git a/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> new file mode 100644
> index 0000000..06bdb5f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> @@ -0,0 +1,12 @@
> +Technologic Systems Watchdog
> +
> +Required properties:
> +- compatible : must be "ts,ts4800-wdt"
> +- reg : physical base address and length of memory mapped region
> +
> +Example:
> +
> +wdt1: wdt@b0010000 {
> +       compatible = "ts,ts4800-wdt";
> +       reg = <0xb0010000 0x1000>;
> +};
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 241fafd..cf30f3b 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -417,6 +417,15 @@ config NUC900_WATCHDOG
>           To compile this driver as a module, choose M here: the
>           module will be called nuc900_wdt.
>
> +config TS4800_WATCHDOG
> +       tristate "TS-4800 Watchdog"
> +       depends on SOC_IMX51

>From the DTS, I saw that this watchdog is on an FPGA, is it limited to only
the i.MX51?

Dinh
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog
       [not found]         ` <CADhT+wdWcYMQ_ZPhcGOye3oP=6N+Yos+sbqV20E5x5Hmfm8ycw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-10-27 21:51           ` Damien Riegel
  2015-10-28  2:05             ` Guenter Roeck
  0 siblings, 1 reply; 15+ messages in thread
From: Damien Riegel @ 2015-10-27 21:51 UTC (permalink / raw)
  To: Dinh Nguyen
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, Sascha Hauer, Wim Van Sebroeck,
	Rob Herring, kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Tue, Oct 27, 2015 at 04:20:52PM -0500, Dinh Nguyen wrote:
> On Tue, Oct 27, 2015 at 3:33 PM, Damien Riegel
> <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org> wrote:
> > Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
> > ---
> >  .../devicetree/bindings/watchdog/ts4800-wdt.txt    |  12 ++
> >  drivers/watchdog/Kconfig                           |   9 +
> >  drivers/watchdog/Makefile                          |   1 +
> >  drivers/watchdog/ts4800_wdt.c                      | 212 +++++++++++++++++++++
> >  4 files changed, 234 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> >  create mode 100644 drivers/watchdog/ts4800_wdt.c
> >
> > diff --git a/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> > new file mode 100644
> > index 0000000..06bdb5f
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> > @@ -0,0 +1,12 @@
> > +Technologic Systems Watchdog
> > +
> > +Required properties:
> > +- compatible : must be "ts,ts4800-wdt"
> > +- reg : physical base address and length of memory mapped region
> > +
> > +Example:
> > +
> > +wdt1: wdt@b0010000 {
> > +       compatible = "ts,ts4800-wdt";
> > +       reg = <0xb0010000 0x1000>;
> > +};
> > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> > index 241fafd..cf30f3b 100644
> > --- a/drivers/watchdog/Kconfig
> > +++ b/drivers/watchdog/Kconfig
> > @@ -417,6 +417,15 @@ config NUC900_WATCHDOG
> >           To compile this driver as a module, choose M here: the
> >           module will be called nuc900_wdt.
> >
> > +config TS4800_WATCHDOG
> > +       tristate "TS-4800 Watchdog"
> > +       depends on SOC_IMX51
> 
> From the DTS, I saw that this watchdog is on an FPGA, is it limited to only
> the i.MX51?

Actually, no. I took a quick look at other TS's boards and it is used on
other boards: TS-4740, TS-4712, TS-4710, and TS-4700 (Marvell
PXA166/PXA168); TS-4600 (iMX283).

But as far as I know, these boards are not supported by Linux. So,
should I add more "depends on" even if we don't support them yet; or
should I let it as is and add other dependances when adding support for
other boards ?
I could also drop that line completely.

Anyway, I will rename the driver to have a more generic name. Is
ts_wdt.c fine for you ?
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog
  2015-10-27 21:51           ` Damien Riegel
@ 2015-10-28  2:05             ` Guenter Roeck
       [not found]               ` <20151028020501.GA1548-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Guenter Roeck @ 2015-10-28  2:05 UTC (permalink / raw)
  To: Damien Riegel
  Cc: Dinh Nguyen, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, Sascha Hauer, Wim Van Sebroeck,
	Rob Herring, kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Tue, Oct 27, 2015 at 05:51:35PM -0400, Damien Riegel wrote:
> On Tue, Oct 27, 2015 at 04:20:52PM -0500, Dinh Nguyen wrote:
> > On Tue, Oct 27, 2015 at 3:33 PM, Damien Riegel
> > <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org> wrote:
> > > Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
> > > ---
> > >  .../devicetree/bindings/watchdog/ts4800-wdt.txt    |  12 ++
> > >  drivers/watchdog/Kconfig                           |   9 +
> > >  drivers/watchdog/Makefile                          |   1 +
> > >  drivers/watchdog/ts4800_wdt.c                      | 212 +++++++++++++++++++++
> > >  4 files changed, 234 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> > >  create mode 100644 drivers/watchdog/ts4800_wdt.c
> > >
> > > diff --git a/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> > > new file mode 100644
> > > index 0000000..06bdb5f
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> > > @@ -0,0 +1,12 @@
> > > +Technologic Systems Watchdog
> > > +
> > > +Required properties:
> > > +- compatible : must be "ts,ts4800-wdt"
> > > +- reg : physical base address and length of memory mapped region
> > > +
> > > +Example:
> > > +
> > > +wdt1: wdt@b0010000 {
> > > +       compatible = "ts,ts4800-wdt";
> > > +       reg = <0xb0010000 0x1000>;
> > > +};
> > > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> > > index 241fafd..cf30f3b 100644
> > > --- a/drivers/watchdog/Kconfig
> > > +++ b/drivers/watchdog/Kconfig
> > > @@ -417,6 +417,15 @@ config NUC900_WATCHDOG
> > >           To compile this driver as a module, choose M here: the
> > >           module will be called nuc900_wdt.
> > >
> > > +config TS4800_WATCHDOG
> > > +       tristate "TS-4800 Watchdog"
> > > +       depends on SOC_IMX51
> > 
> > From the DTS, I saw that this watchdog is on an FPGA, is it limited to only
> > the i.MX51?
> 
> Actually, no. I took a quick look at other TS's boards and it is used on
> other boards: TS-4740, TS-4712, TS-4710, and TS-4700 (Marvell
> PXA166/PXA168); TS-4600 (iMX283).
> 
> But as far as I know, these boards are not supported by Linux. So,
> should I add more "depends on" even if we don't support them yet; or
> should I let it as is and add other dependances when adding support for
> other boards ?
> I could also drop that line completely.
> 
> Anyway, I will rename the driver to have a more generic name. Is
> ts_wdt.c fine for you ?

Can you at least spell that out ? "ts" is a bit _too_ generic.

In general, naming a driver for the first chip it supports is not
problematic. Making it too generic is, on the other side, problematic.
What are you going to do if ts4900 (or ts4801) implements a different
watchdog ?

Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog
       [not found]               ` <20151028020501.GA1548-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
@ 2015-10-28 16:52                 ` Damien Riegel
  0 siblings, 0 replies; 15+ messages in thread
From: Damien Riegel @ 2015-10-28 16:52 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Dinh Nguyen, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, Sascha Hauer, Wim Van Sebroeck,
	Rob Herring, kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Tue, Oct 27, 2015 at 07:05:01PM -0700, Guenter Roeck wrote:
> In general, naming a driver for the first chip it supports is not
> problematic. Making it too generic is, on the other side, problematic.
> What are you going to do if ts4900 (or ts4801) implements a different
> watchdog ?

Okay, I will keep the current name.

I noticed that other boards might have their feed register at different
offsets from syscon base. For instance, feed register is at offset 0x6
on TS-4720 and offset 0xE on TS-4800 (syscon registers are 16-bit wide).
So I need to address that as well (it is related to the next point).

Currently, the driver maps all syscon registers even if it uses only one
of them. I was thinking about adding a "syscon" node and define the
watchdog as a child of it, but the syscon driver set
syscon_regmap_config.val_bits to 32. Do I have to create a new driver if
I want to use val_bits = 16, or is there another way ?

Damien
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/4] of: add vendor prefix for Technologic Systems
       [not found]     ` <1445978021-13961-2-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
@ 2015-10-30 12:50       ` Arnd Bergmann
  2015-10-30 14:17         ` Damien Riegel
  0 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2015-10-30 12:50 UTC (permalink / raw)
  To: Damien Riegel
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Tuesday 27 October 2015 16:33:38 Damien Riegel wrote:
>  truly  Truly Semiconductors Limited
> +ts     Technologic Systems
>  usi    Universal Scientific Industrial Co., Ltd.
> 

The stock ticker symbol 'ts' is https://en.wikipedia.org/wiki/Tenaris,
which is unlikely to conflict here, but it's still better to avoid using
very short names when that is not also the stock ticker symbol for the
same company. How about using 'technologic'?

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog
       [not found]     ` <1445978021-13961-3-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  2015-10-27 21:20       ` Dinh Nguyen
@ 2015-10-30 12:53       ` Arnd Bergmann
  2015-10-30 14:27         ` Damien Riegel
  2015-11-11 23:28       ` Rob Herring
  2 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2015-10-30 12:53 UTC (permalink / raw)
  To: Damien Riegel
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Tuesday 27 October 2015 16:33:39 Damien Riegel wrote:
> +static void ts4800_write_feed(struct ts4800_wdt *wdt, u16 val)
> +{
> +       __raw_writew(val, wdt->base + TS4800_WTD_FEED);
> +}
> +
> 

Using __raw_writew() is broken when you run a big-endian kernel. Better always
use the normal writew() in device drivers.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/4] of: add vendor prefix for Technologic Systems
  2015-10-30 12:50       ` Arnd Bergmann
@ 2015-10-30 14:17         ` Damien Riegel
  0 siblings, 0 replies; 15+ messages in thread
From: Damien Riegel @ 2015-10-30 14:17 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Fri, Oct 30, 2015 at 01:50:37PM +0100, Arnd Bergmann wrote:
> On Tuesday 27 October 2015 16:33:38 Damien Riegel wrote:
> >  truly  Truly Semiconductors Limited
> > +ts     Technologic Systems
> >  usi    Universal Scientific Industrial Co., Ltd.
> > 
> 
> The stock ticker symbol 'ts' is https://en.wikipedia.org/wiki/Tenaris,
> which is unlikely to conflict here, but it's still better to avoid using
> very short names when that is not also the stock ticker symbol for the
> same company. How about using 'technologic'?

Okay. I will change the vendor prefix to 'technologic' and resubmit once
I get feedback on the v2 of this patch serie.

Damien
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog
  2015-10-30 12:53       ` Arnd Bergmann
@ 2015-10-30 14:27         ` Damien Riegel
  0 siblings, 0 replies; 15+ messages in thread
From: Damien Riegel @ 2015-10-30 14:27 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Fri, Oct 30, 2015 at 01:53:00PM +0100, Arnd Bergmann wrote:
> On Tuesday 27 October 2015 16:33:39 Damien Riegel wrote:
> > +static void ts4800_write_feed(struct ts4800_wdt *wdt, u16 val)
> > +{
> > +       __raw_writew(val, wdt->base + TS4800_WTD_FEED);
> > +}
> > +
> > 
> 
> Using __raw_writew() is broken when you run a big-endian kernel. Better always
> use the normal writew() in device drivers.

Noted for future work. Anyway, this has changed in v2 and the driver now
uses regmap_write instead of __raw_writew, so the endianess issue should
already be taken care of.

Damien
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] ARM: dts: TS-4800: add basic device tree
       [not found]     ` <1445978021-13961-5-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
@ 2015-11-11 23:25       ` Rob Herring
  0 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2015-11-11 23:25 UTC (permalink / raw)
  To: Damien Riegel
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Tue, Oct 27, 2015 at 04:33:41PM -0400, Damien Riegel wrote:
> This device tree adds support for TS-4800 by Technologic Systems. This
> board is based on MX51-babbage, but there are some subtle differences in
> the pins used, and there is an additional FPGA that is memory-mapped.
> 
> More details here:
>   http://wiki.embeddedarm.com/wiki/TS-4800
> 
> Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

> ---
>  Documentation/devicetree/bindings/arm/ts.txt |   6 +
>  arch/arm/boot/dts/Makefile                   |   3 +-
>  arch/arm/boot/dts/imx51-ts4800.dts           | 186 +++++++++++++++++++++++++++
>  3 files changed, 194 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/arm/ts.txt
>  create mode 100644 arch/arm/boot/dts/imx51-ts4800.dts
> 
> diff --git a/Documentation/devicetree/bindings/arm/ts.txt b/Documentation/devicetree/bindings/arm/ts.txt
> new file mode 100644
> index 0000000..1b01651
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/ts.txt
> @@ -0,0 +1,6 @@
> +Technologic Systems Platforms Device Tree Bindings
> +--------------------------------------------------
> +
> +TS-4800 board
> +Required root node properties:
> +	- compatible = "ts,imx51-ts4800", "fsl,imx51";
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index 246473a..541829a 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -254,7 +254,8 @@ dtb-$(CONFIG_SOC_IMX51) += \
>  	imx51-apf51dev.dtb \
>  	imx51-babbage.dtb \
>  	imx51-digi-connectcore-jsk.dtb \
> -	imx51-eukrea-mbimxsd51-baseboard.dtb
> +	imx51-eukrea-mbimxsd51-baseboard.dtb \
> +	imx51-ts4800.dtb
>  dtb-$(CONFIG_SOC_IMX53) += \
>  	imx53-ard.dtb \
>  	imx53-m53evk.dtb \
> diff --git a/arch/arm/boot/dts/imx51-ts4800.dts b/arch/arm/boot/dts/imx51-ts4800.dts
> new file mode 100644
> index 0000000..d8c88aa
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx51-ts4800.dts
> @@ -0,0 +1,186 @@
> +/*
> + * Copyright 2011 Freescale Semiconductor, Inc.
> + * Copyright 2011 Linaro Ltd.
> + * Copyright 2015 Savoir-faire Linux
> + *
> + * 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:
> + *
> + * This device tree is based on imx51-babbage.dts
> + *
> + * http://www.opensource.org/licenses/gpl-license.html
> + * http://www.gnu.org/copyleft/gpl.html
> + */
> +
> +/dts-v1/;
> +#include "imx51.dtsi"
> +
> +/ {
> +	model = "Technologic Systems TS4800";
> +	compatible = "ts,imx51-ts4800", "fsl,imx51";
> +
> +	chosen {
> +		stdout-path = &uart1;
> +	};
> +
> +	memory {
> +		reg = <0x90000000 0x10000000>;
> +	};
> +
> +	soc {
> +		fpga {
> +			#address-cells = <1>;
> +			#size-cells = <1>;
> +			compatible = "simple-bus";
> +			reg = <0xb0000000 0x1d000>;
> +			ranges;
> +
> +			wdt1: wdt@b0010000 {
> +				compatible = "ts,ts4800-wdt";
> +				reg = <0xb0010000 0x1000>;
> +			};
> +		};
> +	};
> +
> +	clocks {
> +		ckih1 {
> +			clock-frequency = <22579200>;
> +		};
> +
> +		ckih2 {
> +			clock-frequency = <24576000>;
> +		};
> +	};
> +};
> +
> +&esdhc1 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_esdhc1>;
> +	cd-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
> +	wp-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
> +	status = "okay";
> +};
> +
> +&fec {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_fec>;
> +	phy-mode = "mii";
> +	phy-reset-gpios = <&gpio2 14 GPIO_ACTIVE_LOW>;
> +	phy-reset-duration = <1>;
> +	status = "okay";
> +};
> +
> +&uart1 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_uart1>;
> +	status = "okay";
> +};
> +
> +&uart2 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_uart2>;
> +	status = "okay";
> +};
> +
> +&uart3 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_uart3>;
> +	status = "okay";
> +};
> +
> +&i2c2 {
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_i2c2>;
> +	status = "okay";
> +
> +	rtc: m41t00@68 {
> +		compatible = "stm,m41t00";
> +		reg = <0x68>;
> +	};
> +};
> +
> +
> +&iomuxc {
> +	imx51-ts4800 {
> +
> +		pinctrl_ecspi1: ecspi1grp {
> +			fsl,pins = <
> +				MX51_PAD_CSPI1_MISO__ECSPI1_MISO	0x185
> +				MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI	0x185
> +				MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK	0x185
> +				MX51_PAD_CSPI1_SS0__GPIO4_24		0x85 /* CS0 */
> +			>;
> +		};
> +
> +		pinctrl_esdhc1: esdhc1grp {
> +			fsl,pins = <
> +				MX51_PAD_SD1_CMD__SD1_CMD		0x400020d5
> +				MX51_PAD_SD1_CLK__SD1_CLK		0x20d5
> +				MX51_PAD_SD1_DATA0__SD1_DATA0		0x20d5
> +				MX51_PAD_SD1_DATA1__SD1_DATA1		0x20d5
> +				MX51_PAD_SD1_DATA2__SD1_DATA2		0x20d5
> +				MX51_PAD_SD1_DATA3__SD1_DATA3		0x20d5
> +				MX51_PAD_GPIO1_0__GPIO1_0		0x100
> +				MX51_PAD_GPIO1_1__GPIO1_1		0x100
> +			>;
> +		};
> +
> +		pinctrl_fec: fecgrp {
> +			fsl,pins = <
> +				MX51_PAD_EIM_EB2__FEC_MDIO		0x000001f5
> +				MX51_PAD_EIM_EB3__FEC_RDATA1		0x00000085
> +				MX51_PAD_EIM_CS2__FEC_RDATA2		0x00000085
> +				MX51_PAD_EIM_CS3__FEC_RDATA3		0x00000085
> +				MX51_PAD_EIM_CS4__FEC_RX_ER		0x00000180
> +				MX51_PAD_EIM_CS5__FEC_CRS		0x00000180
> +				MX51_PAD_DISP2_DAT10__FEC_COL		0x00000180
> +				MX51_PAD_DISP2_DAT11__FEC_RX_CLK		0x00000180
> +				MX51_PAD_DISP2_DAT14__FEC_RDATA0		0x00002180
> +				MX51_PAD_DISP2_DAT15__FEC_TDATA0		0x00002004
> +				MX51_PAD_NANDF_CS2__FEC_TX_ER		0x00002004
> +				MX51_PAD_DI2_PIN2__FEC_MDC		0x00002004
> +				MX51_PAD_DISP2_DAT6__FEC_TDATA1		0x00002004
> +				MX51_PAD_DISP2_DAT7__FEC_TDATA2		0x00002004
> +				MX51_PAD_DISP2_DAT8__FEC_TDATA3		0x00002004
> +				MX51_PAD_DISP2_DAT9__FEC_TX_EN		0x00002004
> +				MX51_PAD_DISP2_DAT13__FEC_TX_CLK	0x00002180
> +				MX51_PAD_DISP2_DAT12__FEC_RX_DV		0x000020a4
> +				MX51_PAD_EIM_A20__GPIO2_14		0x00000085 /* Phy Reset */
> +			>;
> +		};
> +
> +		pinctrl_i2c2: i2c2grp {
> +			fsl,pins = <
> +				MX51_PAD_KEY_COL4__I2C2_SCL		0x400001ed
> +				MX51_PAD_KEY_COL5__I2C2_SDA		0x400001ed
> +			>;
> +		};
> +
> +		pinctrl_uart1: uart1grp {
> +			fsl,pins = <
> +				MX51_PAD_UART1_RXD__UART1_RXD		0x1c5
> +				MX51_PAD_UART1_TXD__UART1_TXD		0x1c5
> +				MX51_PAD_UART1_RTS__UART1_RTS		0x1c5
> +				MX51_PAD_UART1_CTS__UART1_CTS		0x1c5
> +			>;
> +		};
> +
> +		pinctrl_uart2: uart2grp {
> +			fsl,pins = <
> +				MX51_PAD_UART2_RXD__UART2_RXD		0x1c5
> +				MX51_PAD_UART2_TXD__UART2_TXD		0x1c5
> +			>;
> +		};
> +
> +		pinctrl_uart3: uart3grp {
> +			fsl,pins = <
> +				MX51_PAD_EIM_D25__UART3_RXD		0x1c5
> +				MX51_PAD_EIM_D26__UART3_TXD		0x1c5
> +				MX51_PAD_EIM_D27__UART3_RTS		0x1c5
> +				MX51_PAD_EIM_D24__UART3_CTS		0x1c5
> +			>;
> +		};
> +
> +	};
> +};
> -- 
> 2.5.0
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog
       [not found]     ` <1445978021-13961-3-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
  2015-10-27 21:20       ` Dinh Nguyen
  2015-10-30 12:53       ` Arnd Bergmann
@ 2015-11-11 23:28       ` Rob Herring
  2 siblings, 0 replies; 15+ messages in thread
From: Rob Herring @ 2015-11-11 23:28 UTC (permalink / raw)
  To: Damien Riegel
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-watchdog-u79uwXL29TY76Z2rM5mHXA,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	wim-IQzOog9fTRqzQB+pC5nmwQ,
	kernel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/

On Tue, Oct 27, 2015 at 04:33:39PM -0400, Damien Riegel wrote:
> Signed-off-by: Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
> ---
>  .../devicetree/bindings/watchdog/ts4800-wdt.txt    |  12 ++

For the binding:

Acked-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>


>  drivers/watchdog/Kconfig                           |   9 +
>  drivers/watchdog/Makefile                          |   1 +
>  drivers/watchdog/ts4800_wdt.c                      | 212 +++++++++++++++++++++
>  4 files changed, 234 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
>  create mode 100644 drivers/watchdog/ts4800_wdt.c
> 
> diff --git a/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> new file mode 100644
> index 0000000..06bdb5f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/watchdog/ts4800-wdt.txt
> @@ -0,0 +1,12 @@
> +Technologic Systems Watchdog
> +
> +Required properties:
> +- compatible : must be "ts,ts4800-wdt"
> +- reg : physical base address and length of memory mapped region
> +
> +Example:
> +
> +wdt1: wdt@b0010000 {
> +	compatible = "ts,ts4800-wdt";
> +	reg = <0xb0010000 0x1000>;
> +};
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 241fafd..cf30f3b 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -417,6 +417,15 @@ config NUC900_WATCHDOG
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called nuc900_wdt.
>  
> +config TS4800_WATCHDOG
> +	tristate "TS-4800 Watchdog"
> +	depends on SOC_IMX51
> +	select WATCHDOG_CORE
> +	help
> +	  Technologic Systems TS-4800 has watchdog timer implemented in
> +	  an external FPGA. Say Y here if you want to support for the
> +	  watchdog timer on TS-4800 board.
> +
>  config TS72XX_WATCHDOG
>  	tristate "TS-72XX SBC Watchdog"
>  	depends on MACH_TS72XX
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 59ea9a1..435fc93 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -52,6 +52,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_TS4800_WATCHDOG) += ts4800_wdt.o
>  obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o
>  obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o
>  obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o
> diff --git a/drivers/watchdog/ts4800_wdt.c b/drivers/watchdog/ts4800_wdt.c
> new file mode 100644
> index 0000000..bf3badf
> --- /dev/null
> +++ b/drivers/watchdog/ts4800_wdt.c
> @@ -0,0 +1,212 @@
> +/*
> + * ts4800_wdt.c - Watchdog driver for TS-4800 based boards
> + *
> + * Copyright (c) 2015 - Savoir-faire Linux
> + *
> + * 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.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/kernel.h>
> +#include <linux/watchdog.h>
> +#include <linux/platform_device.h>
> +#include <linux/io.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) ")");
> +
> +
> +/* feed register is at base + 0xE */
> +#define TS4800_WTD_FEED		0xE
> +
> +/* possible feed values */
> +#define TS4800_WTD_FEED_2S	0x1
> +#define TS4800_WTD_FEED_10S	0x2
> +#define TS4800_WTD_DISABLE	0x3
> +
> +
> +struct ts4800_wdt {
> +	struct watchdog_device  wdd;
> +	void __iomem            *base;
> +	u16                     feed_val;
> +};
> +
> +/* TS-4800 supports the following timeout values:
> + *
> + *   value desc
> + *   ---------------------
> + *     0    feed for 338ms
> + *     1    feed for 2.706s
> + *     2    feed for 10.824s
> + *     3    disable watchd
> + *
> + * Keep the regmap/timeout map ordered by timeout
> + */
> +static const struct {
> +	const int timeout;
> +	const int regval;
> +} ts4800_wdt_map[] = {
> +	{ 2, 1 },
> +	{ 10, 2 },
> +};
> +
> +static int timeout_to_regval(struct watchdog_device *wdd, int new_timeout)
> +{
> +	int i;
> +
> +	new_timeout = clamp_val(new_timeout,
> +				wdd->min_timeout, wdd->max_timeout);
> +
> +	for (i = 0; i < ARRAY_SIZE(ts4800_wdt_map); i++) {
> +		if (ts4800_wdt_map[i].timeout >= new_timeout)
> +			return ts4800_wdt_map[i].timeout;
> +	}
> +
> +	return -EINVAL;
> +}
> +
> +static void ts4800_write_feed(struct ts4800_wdt *wdt, u16 val)
> +{
> +	__raw_writew(val, wdt->base + TS4800_WTD_FEED);
> +}
> +
> +static int ts4800_wdt_ping(struct watchdog_device *wdd)
> +{
> +	struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
> +
> +	ts4800_write_feed(wdt, wdt->feed_val);
> +	return 0;
> +}
> +
> +static int ts4800_wdt_stop(struct watchdog_device *wdd)
> +{
> +	struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
> +
> +	ts4800_write_feed(wdt, TS4800_WTD_DISABLE);
> +	return 0;
> +}
> +
> +static int ts4800_wdt_set_timeout(struct watchdog_device *wdd,
> +				  unsigned int new_timeout)
> +{
> +	struct ts4800_wdt *wdt = watchdog_get_drvdata(wdd);
> +	int val = timeout_to_regval(wdd, new_timeout);
> +
> +	if (val < 0)
> +		return val;
> +
> +	wdt->feed_val = (u16) val;
> +
> +	return 0;
> +}
> +
> +static const struct watchdog_ops ts4800_wdt_ops = {
> +	.owner = THIS_MODULE,
> +	/*
> +	 * pinging the watchdog enables it, so use same function
> +	 * for pinging and starting the watchdog
> +	 */
> +	.start = ts4800_wdt_ping,
> +	.stop = ts4800_wdt_stop,
> +	.ping = ts4800_wdt_ping,
> +	.set_timeout = ts4800_wdt_set_timeout,
> +};
> +
> +static const struct watchdog_info ts4800_wdt_info = {
> +	.options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
> +	.identity = "TS-4800 Watchdog",
> +};
> +
> +static int ts4800_wdt_probe(struct platform_device *pdev)
> +{
> +	int max_timeout_index = ARRAY_SIZE(ts4800_wdt_map) - 1;
> +	struct watchdog_device *wdd;
> +	struct ts4800_wdt *wdt;
> +	struct resource *res;
> +	void __iomem *regs;
> +	int ret;
> +
> +	/* get watchdog base addr */
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	regs = devm_ioremap_resource(&pdev->dev, res);
> +	if (IS_ERR(regs))
> +		return PTR_ERR(regs);
> +
> +	/* allocate memory for watchdog struct */
> +	wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);
> +	if (!wdt)
> +		return -ENOMEM;
> +
> +	/* set watchdog base addr */
> +	wdt->base = regs;
> +
> +	/* Initialize struct watchdog_device */
> +	wdd = &wdt->wdd;
> +	wdd->info = &ts4800_wdt_info;
> +	wdd->ops = &ts4800_wdt_ops;
> +	wdd->min_timeout = ts4800_wdt_map[0].timeout;
> +	wdd->max_timeout = ts4800_wdt_map[max_timeout_index].timeout;
> +	wdd->timeout = wdd->max_timeout;
> +	wdt->feed_val = ts4800_wdt_map[max_timeout_index].regval;
> +
> +	watchdog_set_drvdata(wdd, wdt);
> +	watchdog_set_nowayout(wdd, nowayout);
> +
> +	/*
> +	 * Must be called after watchdog_set_drvdata to dereference a valid
> +	 * pointer. The feed register is write-only, so it is not possible to
> +	 * determine if watchdog is already started or not. Disable it to be in
> +	 * a known state.
> +	 */
> +	ts4800_wdt_stop(wdd);
> +
> +	ret = watchdog_register_device(wdd);
> +	if (ret) {
> +		dev_err(&pdev->dev,
> +			"failed to register watchdog device\n");
> +		return ret;
> +	}
> +
> +	platform_set_drvdata(pdev, wdt);
> +
> +	dev_info(&pdev->dev,
> +		 "initialized (timeout = %d sec, nowayout = %d)\n",
> +		 wdd->timeout, nowayout);
> +
> +	return 0;
> +}
> +
> +static int ts4800_wdt_remove(struct platform_device *pdev)
> +{
> +	struct ts4800_wdt *wdt = platform_get_drvdata(pdev);
> +
> +	watchdog_unregister_device(&wdt->wdd);
> +
> +	return 0;
> +}
> +
> +static const struct of_device_id ts4800_wdt_of_match[] = {
> +	{ .compatible = "ts,ts4800-wdt", },
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, ts4800_wdt_of_match);
> +
> +static struct platform_driver ts4800_wdt_driver = {
> +	.probe		= ts4800_wdt_probe,
> +	.remove		= ts4800_wdt_remove,
> +	.driver		= {
> +		.name	= "ts4800_wdt",
> +		.of_match_table = ts4800_wdt_of_match,
> +	},
> +};
> +
> +module_platform_driver(ts4800_wdt_driver);
> +
> +MODULE_AUTHOR("Damien Riegel <damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:ts4800_wdt");
> -- 
> 2.5.0
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-11-11 23:28 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-27 20:33 [PATCH 0/4] Add board support for TS-4800 Damien Riegel
     [not found] ` <1445978021-13961-1-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
2015-10-27 20:33   ` [PATCH 1/4] of: add vendor prefix for Technologic Systems Damien Riegel
     [not found]     ` <1445978021-13961-2-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
2015-10-30 12:50       ` Arnd Bergmann
2015-10-30 14:17         ` Damien Riegel
2015-10-27 20:33   ` [PATCH 2/4] watchdog: ts4800: add new driver for TS-4800 watchdog Damien Riegel
     [not found]     ` <1445978021-13961-3-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
2015-10-27 21:20       ` Dinh Nguyen
     [not found]         ` <CADhT+wdWcYMQ_ZPhcGOye3oP=6N+Yos+sbqV20E5x5Hmfm8ycw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-27 21:51           ` Damien Riegel
2015-10-28  2:05             ` Guenter Roeck
     [not found]               ` <20151028020501.GA1548-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2015-10-28 16:52                 ` Damien Riegel
2015-10-30 12:53       ` Arnd Bergmann
2015-10-30 14:27         ` Damien Riegel
2015-11-11 23:28       ` Rob Herring
2015-10-27 20:33   ` [PATCH 3/4] ARM: imx_v6_v7_defconfig: add " Damien Riegel
2015-10-27 20:33   ` [PATCH 4/4] ARM: dts: TS-4800: add basic device tree Damien Riegel
     [not found]     ` <1445978021-13961-5-git-send-email-damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/@public.gmane.org>
2015-11-11 23:25       ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).