From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 References: <1542821264-9200-1-git-send-email-loic.poulain@linaro.org> <20181122155915.GB27764@roeck-us.net> In-Reply-To: <20181122155915.GB27764@roeck-us.net> From: Loic Poulain Date: Thu, 22 Nov 2018 17:07:30 +0100 Message-ID: Subject: Re: [PATCH v2 1/3] watchdog: Add pm8916 watchdog driver Content-Type: multipart/alternative; boundary="0000000000008b5c58057b4312d5" To: Guenter Roeck Cc: wim@linux-watchdog.org, Rob Herring , linux-arm-msm , linux-watchdog@vger.kernel.org, devicetree , Andy Gross List-ID: --0000000000008b5c58057b4312d5 Content-Type: text/plain; charset="UTF-8" Hi Guenter, On Thu, 22 Nov 2018 at 16:59, Guenter Roeck wrote: > On Wed, Nov 21, 2018 at 06:27:42PM +0100, Loic Poulain wrote: > > The PM816 module is a versatile PMIC with many diverse functions > > integrated, including, a watchdog. > > This watchdog is subcomponent of the PON (Power On) peripheral, > > in the same way as pwrkey/resin buttons. > > It works with two timers (2-stages), the first one generates an > > IRQ to the main SoC (APQ8016/MSM8916), the second one performs > > the reset. > > > > This driver expects the following device hierarchy: > > [pm8916]->[pm8916-pon]->[pm8916-wdt] > > > > It uses the pm8916 regmap to access PM8916 registers. > > > > Signed-off-by: Loic Poulain > > --- > > v2: SPDX license > > headers ordering > > coding styles / tabs / multi-line comments > > pretimeout / bark interrupt > > WDIOF_MAGICCLOSE flag > > timeout init via fdt > > devm usage > > > > drivers/watchdog/Kconfig | 8 ++ > > drivers/watchdog/Makefile | 1 + > > drivers/watchdog/pm8916_wdt.c | 214 > ++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 223 insertions(+) > > create mode 100644 drivers/watchdog/pm8916_wdt.c > > > > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig > > index 2d64333..ef2c2b5 100644 > > --- a/drivers/watchdog/Kconfig > > +++ b/drivers/watchdog/Kconfig > > @@ -847,6 +847,14 @@ config SPRD_WATCHDOG > > Say Y here to include watchdog timer supported > > by Spreadtrum system. > > > > +config PM8916_WATCHDOG > > + tristate "QCOM PM8916 pmic watchdog" > > + depends on OF && MFD_SPMI_PMIC > > + select WATCHDOG_CORE > > + help > > + Say Y here to include support watchdog timer embedded into the > > + pm8916 module. > > + > > # X86 (i386 + ia64 + x86_64) Architecture > > > > config ACQUIRE_WDT > > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile > > index f69cdff..cc90e72 100644 > > --- a/drivers/watchdog/Makefile > > +++ b/drivers/watchdog/Makefile > > @@ -92,6 +92,7 @@ obj-$(CONFIG_STM32_WATCHDOG) += stm32_iwdg.o > > obj-$(CONFIG_UNIPHIER_WATCHDOG) += uniphier_wdt.o > > obj-$(CONFIG_RTD119X_WATCHDOG) += rtd119x_wdt.o > > obj-$(CONFIG_SPRD_WATCHDOG) += sprd_wdt.o > > +obj-$(CONFIG_PM8916_WATCHDOG) += pm8916_wdt.o > > > > # X86 (i386 + ia64 + x86_64) Architecture > > obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o > > diff --git a/drivers/watchdog/pm8916_wdt.c > b/drivers/watchdog/pm8916_wdt.c > > new file mode 100644 > > index 0000000..25d1110 > > --- /dev/null > > +++ b/drivers/watchdog/pm8916_wdt.c > > @@ -0,0 +1,214 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define PON_INT_RT_STS 0x10 > > +#define PMIC_WD_BARK_STS_BIT BIT(6) > > + > > +#define PON_PMIC_WD_RESET_S1_TIMER 0x54 > > +#define PON_PMIC_WD_RESET_S2_TIMER 0x55 > > + > > +#define PON_PMIC_WD_RESET_S2_CTL 0x56 > > +#define RESET_TYPE_WARM 0x01 > > +#define RESET_TYPE_SHUTDOWN 0x04 > > +#define RESET_TYPE_HARD 0x07 > > + > > +#define PON_PMIC_WD_RESET_S2_CTL2 0x57 > > +#define S2_RESET_EN_BIT BIT(7) > > + > > +#define PON_PMIC_WD_RESET_PET 0x58 > > +#define WATCHDOG_PET_BIT BIT(0) > > + > > +#define PM8916_WDT_DEFAULT_TIMEOUT 32 > > +#define PM8916_WDT_MIN_TIMEOUT 1 > > +#define PM8916_WDT_MAX_TIMEOUT 127 > > + > > +struct pm8916_wdt { > > + struct device *dev; > > Not used anywhere. > > > + struct regmap *regmap; > > + struct watchdog_device wdev; > > + u32 baseaddr; > > + int irq; > > Not used anywhere except for the probe function, and there it can be > kept internal. > > Thanks for the sharp-eyed review, I'll send a v3. Guenter > --0000000000008b5c58057b4312d5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Guenter,

On Thu, 22 Nov 2018 at 16:59, Guenter Roeck <linux@roeck-us.net> wrote:
On Wed, Nov 21, 2018 at 06:27:42PM +0100, Loic Poulain = wrote:
> The PM816 module is a versatile PMIC with many diverse functions
> integrated, including, a watchdog.
> This watchdog is subcomponent of the PON (Power On) peripheral,
> in the same way as pwrkey/resin buttons.
> It works with two timers (2-stages), the first one generates an
> IRQ to the main SoC (APQ8016/MSM8916), the second one performs
> the reset.
>
> This driver expects the following device hierarchy:
> [pm8916]->[pm8916-pon]->[pm8916-wdt]
>
> It uses the pm8916 regmap to access PM8916 registers.
>
> Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
> ---
>=C2=A0 v2: SPDX license
>=C2=A0 =C2=A0 =C2=A0 headers ordering
>=C2=A0 =C2=A0 =C2=A0 coding styles / tabs / multi-line comments
>=C2=A0 =C2=A0 =C2=A0 pretimeout / bark interrupt
>=C2=A0 =C2=A0 =C2=A0 WDIOF_MAGICCLOSE flag
>=C2=A0 =C2=A0 =C2=A0 timeout init via fdt
>=C2=A0 =C2=A0 =C2=A0 devm usage
>
>=C2=A0 drivers/watchdog/Kconfig=C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A08 ++<= br> >=C2=A0 drivers/watchdog/Makefile=C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A01 + >=C2=A0 drivers/watchdog/pm8916_wdt.c | 214 ++++++++++++++++++++++++++++= ++++++++++++++
>=C2=A0 3 files changed, 223 insertions(+)
>=C2=A0 create mode 100644 drivers/watchdog/pm8916_wdt.c
>
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 2d64333..ef2c2b5 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -847,6 +847,14 @@ config SPRD_WATCHDOG
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Say Y here to include watchdog timer = supported
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0by Spreadtrum system.
>=C2=A0
> +config PM8916_WATCHDOG
> +=C2=A0 =C2=A0 =C2=A0tristate "QCOM PM8916 pmic watchdog" > +=C2=A0 =C2=A0 =C2=A0depends on OF && MFD_SPMI_PMIC
> +=C2=A0 =C2=A0 =C2=A0select WATCHDOG_CORE
> +=C2=A0 =C2=A0 =C2=A0help
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0Say Y here to include support watchdog tim= er embedded into the
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0pm8916 module.
> +
>=C2=A0 # X86 (i386 + ia64 + x86_64) Architecture
>=C2=A0
>=C2=A0 config ACQUIRE_WDT
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index f69cdff..cc90e72 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -92,6 +92,7 @@ obj-$(CONFIG_STM32_WATCHDOG) +=3D stm32_iwdg.o
>=C2=A0 obj-$(CONFIG_UNIPHIER_WATCHDOG) +=3D uniphier_wdt.o
>=C2=A0 obj-$(CONFIG_RTD119X_WATCHDOG) +=3D rtd119x_wdt.o
>=C2=A0 obj-$(CONFIG_SPRD_WATCHDOG) +=3D sprd_wdt.o
> +obj-$(CONFIG_PM8916_WATCHDOG) +=3D pm8916_wdt.o
>=C2=A0
>=C2=A0 # X86 (i386 + ia64 + x86_64) Architecture
>=C2=A0 obj-$(CONFIG_ACQUIRE_WDT) +=3D acquirewdt.o
> diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_w= dt.c
> new file mode 100644
> index 0000000..25d1110
> --- /dev/null
> +++ b/drivers/watchdog/pm8916_wdt.c
> @@ -0,0 +1,214 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <linux/bitops.h>
> +#include <linux/interrupt.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/property.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/watchdog.h>
> +
> +#define PON_INT_RT_STS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A00x10
> +#define PMIC_WD_BARK_STS_BIT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0BIT(6)<= br> > +
> +#define PON_PMIC_WD_RESET_S1_TIMER=C2=A0 =C2=A00x54
> +#define PON_PMIC_WD_RESET_S2_TIMER=C2=A0 =C2=A00x55
> +
> +#define PON_PMIC_WD_RESET_S2_CTL=C2=A0 =C2=A0 =C2=A00x56
> +#define RESET_TYPE_WARM=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0x01
> +#define RESET_TYPE_SHUTDOWN=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0x04 > +#define RESET_TYPE_HARD=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0x07
> +
> +#define PON_PMIC_WD_RESET_S2_CTL2=C2=A0 =C2=A0 0x57
> +#define S2_RESET_EN_BIT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 BIT(7)
> +
> +#define PON_PMIC_WD_RESET_PET=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 0x58
> +#define WATCHDOG_PET_BIT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0BIT(0)
> +
> +#define PM8916_WDT_DEFAULT_TIMEOUT=C2=A0 =C2=A032
> +#define PM8916_WDT_MIN_TIMEOUT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A01
> +#define PM8916_WDT_MAX_TIMEOUT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0127
> +
> +struct pm8916_wdt {
> +=C2=A0 =C2=A0 =C2=A0struct device *dev;

Not used anywhere.

> +=C2=A0 =C2=A0 =C2=A0struct regmap *regmap;
> +=C2=A0 =C2=A0 =C2=A0struct watchdog_device wdev;
> +=C2=A0 =C2=A0 =C2=A0u32 baseaddr;
> +=C2=A0 =C2=A0 =C2=A0int irq;

Not used anywhere except for the probe function, and there it can be
kept internal.


Thanks for the sharp-eyed review, I'll send a v3.

Guenter
--0000000000008b5c58057b4312d5--