Re: [PATCH v4 6/9] watchdog: st_wdt: Add new driver for ST's LPC Watchdog

2015-03-01 Thread Lee Jones
On Sat, 28 Feb 2015, Paul Bolle wrote:
> On Wed, 2015-02-25 at 13:52 +, Lee Jones wrote:
> > Reviewed-by: Guenter Roeck 
> > Signed-off-by: David Paris 
> > Signed-off-by: Lee Jones 
> > ---
> >  drivers/watchdog/Kconfig  |  13 ++
> >  drivers/watchdog/Makefile |   1 +
> >  drivers/watchdog/st_lpc_wdt.c | 333 
> > ++
> >  3 files changed, 347 insertions(+)
> >  create mode 100644 drivers/watchdog/st_lpc_wdt.c
> 
> A few nits follow.

Thanks Paul, will fix.

[...]

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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 v4 6/9] watchdog: st_wdt: Add new driver for ST's LPC Watchdog

2015-02-28 Thread Paul Bolle
On Wed, 2015-02-25 at 13:52 +, Lee Jones wrote:
> Reviewed-by: Guenter Roeck 
> Signed-off-by: David Paris 
> Signed-off-by: Lee Jones 
> ---
>  drivers/watchdog/Kconfig  |  13 ++
>  drivers/watchdog/Makefile |   1 +
>  drivers/watchdog/st_lpc_wdt.c | 333 
> ++
>  3 files changed, 347 insertions(+)
>  create mode 100644 drivers/watchdog/st_lpc_wdt.c

A few nits follow.

> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 16f2023..023df6d 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -471,6 +471,19 @@ config SIRFSOC_WATCHDOG
> Support for CSR SiRFprimaII and SiRFatlasVI watchdog. When
> the watchdog triggers the system will be reset.
>  
> +config ST_LPC_WATCHDOG
> + tristate "STMicroelectronics LPC Watchdog"
> + depends on ARCH_STI
> + depends on OF
> + select WATCHDOG_CORE
> + select MFD_ST_LPC
> + help
> +   Say Y here to include STMicroelectronics Low Power Controller
> +   (LPC) based Watchdog timer support.
> +
> +   To compile this driver as a module, choose M here: the
> +   module will be called st_wdt.
> +

This calls the module st_wdt. So does the title.

>  config TEGRA_WATCHDOG
>   tristate "Tegra watchdog"
>   depends on (ARCH_TEGRA || COMPILE_TEST) && HAS_IOMEM
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 5c19294..d98768c 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -59,6 +59,7 @@ obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
>  obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o
>  obj-$(CONFIG_MOXART_WDT) += moxart_wdt.o
>  obj-$(CONFIG_SIRFSOC_WATCHDOG) += sirfsoc_wdt.o
> +obj-$(CONFIG_ST_LPC_WATCHDOG) += st_lpc_wdt.o

But this makes it st_lpc_wdt, doesn't it?

>  obj-$(CONFIG_QCOM_WDT) += qcom-wdt.o
>  obj-$(CONFIG_BCM_KONA_WDT) += bcm_kona_wdt.o
>  obj-$(CONFIG_TEGRA_WATCHDOG) += tegra_wdt.o
> diff --git a/drivers/watchdog/st_lpc_wdt.c b/drivers/watchdog/st_lpc_wdt.c
> new file mode 100644
> index 000..91bb631
> --- /dev/null
> +++ b/drivers/watchdog/st_lpc_wdt.c
> @@ -0,0 +1,333 @@
> +/*
> + * st-wdt.c - ST's LPC Watchdog

Mismatch between "st-wdt.c" and the actual filename. Perhaps just remove
"st-wdt.c - "?

> + *
> + * Copyright (C) 2014 STMicroelectronics -- All Rights Reserved
> + *
> + * Author: David Paris  for STMicroelectronics
> + * Lee Jones  for STMicroelectronics
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public Licence
> + * as published by the Free Software Foundation; either version
> + * 2 of the Licence, or (at your option) any later version.
> + */

This states the license is "GPL v2 or later"

[...]

> +MODULE_LICENSE("GPL v2");

So this should probably be
MODULE_LICENSE("GPL");


Paul Bolle

--
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 v4 6/9] watchdog: st_wdt: Add new driver for ST's LPC Watchdog

2015-02-25 Thread Lee Jones
Reviewed-by: Guenter Roeck 
Signed-off-by: David Paris 
Signed-off-by: Lee Jones 
---
 drivers/watchdog/Kconfig  |  13 ++
 drivers/watchdog/Makefile |   1 +
 drivers/watchdog/st_lpc_wdt.c | 333 ++
 3 files changed, 347 insertions(+)
 create mode 100644 drivers/watchdog/st_lpc_wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 16f2023..023df6d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -471,6 +471,19 @@ config SIRFSOC_WATCHDOG
  Support for CSR SiRFprimaII and SiRFatlasVI watchdog. When
  the watchdog triggers the system will be reset.
 
+config ST_LPC_WATCHDOG
+   tristate "STMicroelectronics LPC Watchdog"
+   depends on ARCH_STI
+   depends on OF
+   select WATCHDOG_CORE
+   select MFD_ST_LPC
+   help
+ Say Y here to include STMicroelectronics Low Power Controller
+ (LPC) based Watchdog timer support.
+
+ To compile this driver as a module, choose M here: the
+ module will be called st_wdt.
+
 config TEGRA_WATCHDOG
tristate "Tegra watchdog"
depends on (ARCH_TEGRA || COMPILE_TEST) && HAS_IOMEM
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 5c19294..d98768c 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o
 obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o
 obj-$(CONFIG_MOXART_WDT) += moxart_wdt.o
 obj-$(CONFIG_SIRFSOC_WATCHDOG) += sirfsoc_wdt.o
+obj-$(CONFIG_ST_LPC_WATCHDOG) += st_lpc_wdt.o
 obj-$(CONFIG_QCOM_WDT) += qcom-wdt.o
 obj-$(CONFIG_BCM_KONA_WDT) += bcm_kona_wdt.o
 obj-$(CONFIG_TEGRA_WATCHDOG) += tegra_wdt.o
diff --git a/drivers/watchdog/st_lpc_wdt.c b/drivers/watchdog/st_lpc_wdt.c
new file mode 100644
index 000..91bb631
--- /dev/null
+++ b/drivers/watchdog/st_lpc_wdt.c
@@ -0,0 +1,333 @@
+/*
+ * st-wdt.c - ST's LPC Watchdog
+ *
+ * Copyright (C) 2014 STMicroelectronics -- All Rights Reserved
+ *
+ * Author: David Paris  for STMicroelectronics
+ * Lee Jones  for STMicroelectronics
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public Licence
+ * as published by the Free Software Foundation; either version
+ * 2 of the Licence, or (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/* Low Power Alarm */
+#define LPC_LPA_LSB_OFF0x410
+#define LPC_LPA_START_OFF  0x418
+
+/* LPC as WDT */
+#define LPC_WDT_OFF0x510
+
+static struct watchdog_device st_wdog_dev;
+
+struct st_wdog_syscfg {
+   unsigned int reset_type_reg;
+   unsigned int reset_type_mask;
+   unsigned int enable_reg;
+   unsigned int enable_mask;
+};
+
+struct st_wdog {
+   void __iomem *base;
+   struct device *dev;
+   struct regmap *regmap;
+   struct st_wdog_syscfg *syscfg;
+   struct clk *clk;
+   unsigned long clkrate;
+   bool warm_reset;
+};
+
+static struct st_wdog_syscfg stid127_syscfg = {
+   .reset_type_reg = 0x004,
+   .reset_type_mask= BIT(2),
+   .enable_reg = 0x000,
+   .enable_mask= BIT(2),
+};
+
+static struct st_wdog_syscfg stih415_syscfg = {
+   .reset_type_reg = 0x0B8,
+   .reset_type_mask= BIT(6),
+   .enable_reg = 0x0B4,
+   .enable_mask= BIT(7),
+};
+
+static struct st_wdog_syscfg stih416_syscfg = {
+   .reset_type_reg = 0x88C,
+   .reset_type_mask= BIT(6),
+   .enable_reg = 0x888,
+   .enable_mask= BIT(7),
+};
+
+static struct st_wdog_syscfg stih407_syscfg = {
+   .enable_reg = 0x204,
+   .enable_mask= BIT(19),
+};
+
+static const struct of_device_id st_wdog_match[] = {
+   {
+   .compatible = "st,stih407-lpc",
+   .data = &stih407_syscfg,
+   },
+   {
+   .compatible = "st,stih416-lpc",
+   .data = &stih416_syscfg,
+   },
+   {
+   .compatible = "st,stih415-lpc",
+   .data = &stih415_syscfg,
+   },
+   {
+   .compatible = "st,stid127-lpc",
+   .data = &stid127_syscfg,
+   },
+   {},
+};
+MODULE_DEVICE_TABLE(of, st_wdog_match);
+
+static void st_wdog_setup(struct st_wdog *st_wdog, bool enable)
+{
+   /* Type of watchdog reset - 0: Cold 1: Warm */
+   if (st_wdog->syscfg->reset_type_reg)
+   regmap_update_bits(st_wdog->regmap,
+  st_wdog->syscfg->reset_type_reg,
+  st_wdog->syscfg->reset_type_mask,
+  st_wdog->warm_reset);
+
+   /* Mask/unmask watchdog reset */
+   regmap_upda