All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: S Twiss <stwiss.opensource@diasemi.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	DT <devicetree@vger.kernel.org>,
	David Dajun Chen <david.chen@diasemi.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	INPUT <linux-input@vger.kernel.org>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Pawel Moll <pawel.moll@arm.com>, Rob Herring <robh+dt@kernel.org>,
	Support Opensource <support.opensource@diasemi.com>
Subject: Re: [RESEND PATCH V4 3/3] mfd: da9063: MFD support for OnKey driver
Date: Tue, 26 May 2015 14:57:35 +0100	[thread overview]
Message-ID: <20150526135735.GN11677@x1> (raw)
In-Reply-To: <a508f5d715e94fb18e6ef4ce755c2225a17090ea.1432031565.git.stwiss.opensource@diasemi.com>

On Tue, 19 May 2015, S Twiss wrote:

> From: Steve Twiss <stwiss.opensource@diasemi.com>
> 
> Add MFD support for the DA9063 OnKey driver
> 
> The function da9063_clear_fault_log() is added to mitigate the case of a
> hardware power-cut after a long-long OnKey press. Although there is no
> software intervention in this case (by definition) such a shutdown would
> cause persistent information within the DA9063 FAULT_LOG that would be
> available during the next device restart.
> 
> Clearance of this persistent register must be completed after such a
> hardware power-cut operation has happened so that the FAULT_LOG does not
> continue with previous values. The clearance function has been added here
> in the kernel driver because wiping the fault-log cannot be counted on
> outside the Linux kernel.
> 
> Acked-by: Lee Jones <lee.jones@linaro.org>
> 
> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com>
> 
> ---
> Version History
> 
> Changes in V4
>  - Additional description of MFD patch changes for FAULT_LOG in relation to
>    the requirements of the OnKey driver. Please see a further explanation of
>    the OnKey's operation in this thread: https://lkml.org/lkml/2015/4/29/406
> 
> Changes in V3
>  - The MFD code was originally in [PATCH V2 1/2]. This is now been moved into
>    this patch [PATCH V3 3/3].
>  - Whitespace cleanup
> 
> This patch applies against linux-next and v4.1-rc3 
> 
> 
>  drivers/mfd/da9063-core.c        | 54 ++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/da9063/pdata.h |  1 +
>  2 files changed, 55 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
> index facd361..af841c1 100644
> --- a/drivers/mfd/da9063-core.c
> +++ b/drivers/mfd/da9063-core.c
> @@ -60,6 +60,7 @@ static struct resource da9063_rtc_resources[] = {
>  
>  static struct resource da9063_onkey_resources[] = {
>  	{
> +		.name	= "ONKEY",
>  		.start	= DA9063_IRQ_ONKEY,
>  		.end	= DA9063_IRQ_ONKEY,
>  		.flags	= IORESOURCE_IRQ,
> @@ -97,6 +98,7 @@ static const struct mfd_cell da9063_devs[] = {
>  		.name		= DA9063_DRVNAME_ONKEY,
>  		.num_resources	= ARRAY_SIZE(da9063_onkey_resources),
>  		.resources	= da9063_onkey_resources,
> +		.of_compatible = "dlg,da9063-onkey",
>  	},
>  	{
>  		.name		= DA9063_DRVNAME_RTC,
> @@ -109,12 +111,64 @@ static const struct mfd_cell da9063_devs[] = {
>  	},
>  };
>  
> +static int da9063_clear_fault_log(struct da9063 *da9063)
> +{
> +	int ret = 0;
> +	int fault_log = 0;
> +
> +	ret = regmap_read(da9063->regmap, DA9063_REG_FAULT_LOG, &fault_log);
> +	if (ret < 0) {
> +		dev_err(da9063->dev, "Cannot read FAULT_LOG.\n");
> +		return -EIO;
> +	}
> +
> +	if (fault_log) {
> +		if (fault_log & DA9063_TWD_ERROR)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_TWD_ERROR\n");
> +		if (fault_log & DA9063_POR)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_POR\n");
> +		if (fault_log & DA9063_VDD_FAULT)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_VDD_FAULT\n");
> +		if (fault_log & DA9063_VDD_START)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_VDD_START\n");
> +		if (fault_log & DA9063_TEMP_CRIT)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_TEMP_CRIT\n");
> +		if (fault_log & DA9063_KEY_RESET)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_KEY_RESET\n");
> +		if (fault_log & DA9063_NSHUTDOWN)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_NSHUTDOWN\n");
> +		if (fault_log & DA9063_WAIT_SHUT)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_WAIT_SHUT\n");
> +	}
> +
> +	ret = regmap_write(da9063->regmap,
> +			   DA9063_REG_FAULT_LOG,
> +			   fault_log);
> +	if (ret < 0)
> +		dev_err(da9063->dev,
> +			"Cannot reset FAULT_LOG values %d\n", ret);
> +
> +	return ret;
> +}
> +
>  int da9063_device_init(struct da9063 *da9063, unsigned int irq)
>  {
>  	struct da9063_pdata *pdata = da9063->dev->platform_data;
>  	int model, variant_id, variant_code;
>  	int ret;
>  
> +	ret = da9063_clear_fault_log(da9063);
> +	if (ret < 0)
> +		dev_err(da9063->dev, "Cannot clear fault log\n");
> +
>  	if (pdata) {
>  		da9063->flags = pdata->flags;
>  		da9063->irq_base = pdata->irq_base;
> diff --git a/include/linux/mfd/da9063/pdata.h b/include/linux/mfd/da9063/pdata.h
> index 95c8742..612383b 100644
> --- a/include/linux/mfd/da9063/pdata.h
> +++ b/include/linux/mfd/da9063/pdata.h
> @@ -103,6 +103,7 @@ struct da9063;
>  struct da9063_pdata {
>  	int				(*init)(struct da9063 *da9063);
>  	int				irq_base;
> +	bool				key_power;
>  	unsigned			flags;
>  	struct da9063_regulators_pdata	*regulators_pdata;
>  	struct led_platform_data	*leds_pdata;

-- 
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 linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones@linaro.org>
To: S Twiss <stwiss.opensource@diasemi.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	DT <devicetree@vger.kernel.org>,
	David Dajun Chen <david.chen@diasemi.com>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	INPUT <linux-input@vger.kernel.org>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Pawel Moll <pawel.moll@arm.com>, Rob Herring <robh+dt@kernel.org>,
	Support Opensource <support.opensource@diasemi.com>
Subject: Re: [RESEND PATCH V4 3/3] mfd: da9063: MFD support for OnKey driver
Date: Tue, 26 May 2015 14:57:35 +0100	[thread overview]
Message-ID: <20150526135735.GN11677@x1> (raw)
In-Reply-To: <a508f5d715e94fb18e6ef4ce755c2225a17090ea.1432031565.git.stwiss.opensource@diasemi.com>

On Tue, 19 May 2015, S Twiss wrote:

> From: Steve Twiss <stwiss.opensource@diasemi.com>
> 
> Add MFD support for the DA9063 OnKey driver
> 
> The function da9063_clear_fault_log() is added to mitigate the case of a
> hardware power-cut after a long-long OnKey press. Although there is no
> software intervention in this case (by definition) such a shutdown would
> cause persistent information within the DA9063 FAULT_LOG that would be
> available during the next device restart.
> 
> Clearance of this persistent register must be completed after such a
> hardware power-cut operation has happened so that the FAULT_LOG does not
> continue with previous values. The clearance function has been added here
> in the kernel driver because wiping the fault-log cannot be counted on
> outside the Linux kernel.
> 
> Acked-by: Lee Jones <lee.jones@linaro.org>
> 
> Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com>
> 
> ---
> Version History
> 
> Changes in V4
>  - Additional description of MFD patch changes for FAULT_LOG in relation to
>    the requirements of the OnKey driver. Please see a further explanation of
>    the OnKey's operation in this thread: https://lkml.org/lkml/2015/4/29/406
> 
> Changes in V3
>  - The MFD code was originally in [PATCH V2 1/2]. This is now been moved into
>    this patch [PATCH V3 3/3].
>  - Whitespace cleanup
> 
> This patch applies against linux-next and v4.1-rc3 
> 
> 
>  drivers/mfd/da9063-core.c        | 54 ++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/da9063/pdata.h |  1 +
>  2 files changed, 55 insertions(+)

Applied, thanks.

> diff --git a/drivers/mfd/da9063-core.c b/drivers/mfd/da9063-core.c
> index facd361..af841c1 100644
> --- a/drivers/mfd/da9063-core.c
> +++ b/drivers/mfd/da9063-core.c
> @@ -60,6 +60,7 @@ static struct resource da9063_rtc_resources[] = {
>  
>  static struct resource da9063_onkey_resources[] = {
>  	{
> +		.name	= "ONKEY",
>  		.start	= DA9063_IRQ_ONKEY,
>  		.end	= DA9063_IRQ_ONKEY,
>  		.flags	= IORESOURCE_IRQ,
> @@ -97,6 +98,7 @@ static const struct mfd_cell da9063_devs[] = {
>  		.name		= DA9063_DRVNAME_ONKEY,
>  		.num_resources	= ARRAY_SIZE(da9063_onkey_resources),
>  		.resources	= da9063_onkey_resources,
> +		.of_compatible = "dlg,da9063-onkey",
>  	},
>  	{
>  		.name		= DA9063_DRVNAME_RTC,
> @@ -109,12 +111,64 @@ static const struct mfd_cell da9063_devs[] = {
>  	},
>  };
>  
> +static int da9063_clear_fault_log(struct da9063 *da9063)
> +{
> +	int ret = 0;
> +	int fault_log = 0;
> +
> +	ret = regmap_read(da9063->regmap, DA9063_REG_FAULT_LOG, &fault_log);
> +	if (ret < 0) {
> +		dev_err(da9063->dev, "Cannot read FAULT_LOG.\n");
> +		return -EIO;
> +	}
> +
> +	if (fault_log) {
> +		if (fault_log & DA9063_TWD_ERROR)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_TWD_ERROR\n");
> +		if (fault_log & DA9063_POR)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_POR\n");
> +		if (fault_log & DA9063_VDD_FAULT)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_VDD_FAULT\n");
> +		if (fault_log & DA9063_VDD_START)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_VDD_START\n");
> +		if (fault_log & DA9063_TEMP_CRIT)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_TEMP_CRIT\n");
> +		if (fault_log & DA9063_KEY_RESET)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_KEY_RESET\n");
> +		if (fault_log & DA9063_NSHUTDOWN)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_NSHUTDOWN\n");
> +		if (fault_log & DA9063_WAIT_SHUT)
> +			dev_dbg(da9063->dev,
> +				"Fault log entry detected: DA9063_WAIT_SHUT\n");
> +	}
> +
> +	ret = regmap_write(da9063->regmap,
> +			   DA9063_REG_FAULT_LOG,
> +			   fault_log);
> +	if (ret < 0)
> +		dev_err(da9063->dev,
> +			"Cannot reset FAULT_LOG values %d\n", ret);
> +
> +	return ret;
> +}
> +
>  int da9063_device_init(struct da9063 *da9063, unsigned int irq)
>  {
>  	struct da9063_pdata *pdata = da9063->dev->platform_data;
>  	int model, variant_id, variant_code;
>  	int ret;
>  
> +	ret = da9063_clear_fault_log(da9063);
> +	if (ret < 0)
> +		dev_err(da9063->dev, "Cannot clear fault log\n");
> +
>  	if (pdata) {
>  		da9063->flags = pdata->flags;
>  		da9063->irq_base = pdata->irq_base;
> diff --git a/include/linux/mfd/da9063/pdata.h b/include/linux/mfd/da9063/pdata.h
> index 95c8742..612383b 100644
> --- a/include/linux/mfd/da9063/pdata.h
> +++ b/include/linux/mfd/da9063/pdata.h
> @@ -103,6 +103,7 @@ struct da9063;
>  struct da9063_pdata {
>  	int				(*init)(struct da9063 *da9063);
>  	int				irq_base;
> +	bool				key_power;
>  	unsigned			flags;
>  	struct da9063_regulators_pdata	*regulators_pdata;
>  	struct led_platform_data	*leds_pdata;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2015-05-26 13:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 10:32 [RESEND PATCH V4 0/3] Add OnKey support for DA9063 S Twiss
2015-05-19 10:32 ` [RESEND PATCH V4 2/3] devicetree: Add bindings for DA9063 OnKey S Twiss
     [not found]   ` <72933a3c053b445e7998c818b7a73317fa1e2d8a.1432031565.git.stwiss.opensource-WBD+wuPFNBhBDgjK7y7TUQ@public.gmane.org>
2015-05-20 13:44     ` Rob Herring
2015-05-20 13:44       ` Rob Herring
     [not found]       ` <CAL_JsqJOqs8Y8MYx9mtBZWo+VGb7cTFqSAr1iq=D6jB293kEfg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-20 14:27         ` Opensource [Steve Twiss]
2015-05-20 14:27           ` Opensource [Steve Twiss]
2015-05-26 13:58   ` Lee Jones
2015-05-19 10:32 ` [RESEND PATCH V4 3/3] mfd: da9063: MFD support for OnKey driver S Twiss
2015-05-26 13:57   ` Lee Jones [this message]
2015-05-26 13:57     ` Lee Jones
2015-05-26 14:06     ` Opensource [Steve Twiss]
2015-05-26 14:06       ` Opensource [Steve Twiss]
2015-06-08 23:25   ` Dmitry Torokhov
2015-06-09  6:51     ` Lee Jones
2015-06-09  7:21       ` Opensource [Steve Twiss]
2015-06-09  7:21         ` Opensource [Steve Twiss]
2015-05-19 10:32 ` [RESEND PATCH V4 1/3] input: misc: da9063: " S Twiss
2015-05-27 15:37   ` Opensource [Steve Twiss]
2015-06-01 14:01   ` Opensource [Steve Twiss]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150526135735.GN11677@x1 \
    --to=lee.jones@linaro.org \
    --cc=david.chen@diasemi.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=stwiss.opensource@diasemi.com \
    --cc=support.opensource@diasemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.