From: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Bjorn Andersson
<bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Pawel Moll <pawel.moll-5wv7dgnIgG8@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Ian Campbell
<ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org>,
Andrew Duggan <aduggan-Gq53QDLGkWKakBO8gow8eQ@public.gmane.org>,
Christopher Heiny
<cheiny-Gq53QDLGkWKakBO8gow8eQ@public.gmane.org>,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Bjorn Andersson
<bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
Subject: Re: [PATCH] Input: synaptics-rmi4: Support regulator supplies
Date: Thu, 31 Mar 2016 11:19:05 -0700 [thread overview]
Message-ID: <20160331181905.GJ39098@dtor-ws> (raw)
In-Reply-To: <1459357049-5608-1-git-send-email-bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Hi Bjorn,
On Wed, Mar 30, 2016 at 09:57:29AM -0700, Bjorn Andersson wrote:
> From: Bjorn Andersson <bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
>
> Support the two supplies - vdd and vio - to make it possible to control
> power to the Synaptics chip.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> .../devicetree/bindings/input/rmi4/rmi_i2c.txt | 7 ++++
> drivers/input/rmi4/rmi_i2c.c | 45 ++++++++++++++++++++++
Would not we need pretty much the same changes for SPI devices? Can this
be done in core?
Thanks.
> 2 files changed, 52 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt b/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt
> index 95fa715c6046..a8c31f40f816 100644
> --- a/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt
> +++ b/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt
> @@ -22,6 +22,13 @@ See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
> - syna,reset-delay-ms: The number of milliseconds to wait after resetting the
> device.
>
> +- vdd-supply: VDD power supply.
> +See Documentation/devicetree/bindings/regulator/regulator.txt
> +
> +- vio-supply: VIO power supply
> +See Documentation/devicetree/bindings/regulator/regulator.txt
> +
> +
> Function Parameters:
> Parameters specific to RMI functions are contained in child nodes of the rmi device
> node. Documentation for the parameters of each function can be found in:
> diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c
> index a96a326b53bd..a8c794daba04 100644
> --- a/drivers/input/rmi4/rmi_i2c.c
> +++ b/drivers/input/rmi4/rmi_i2c.c
> @@ -11,6 +11,8 @@
> #include <linux/rmi.h>
> #include <linux/irq.h>
> #include <linux/of.h>
> +#include <linux/delay.h>
> +#include <linux/regulator/consumer.h>
> #include "rmi_driver.h"
>
> #define BUFFER_SIZE_INCREMENT 32
> @@ -37,6 +39,8 @@ struct rmi_i2c_xport {
>
> u8 *tx_buf;
> size_t tx_buf_size;
> +
> + struct regulator_bulk_data supplies[2];
> };
>
> #define RMI_PAGE_SELECT_REGISTER 0xff
> @@ -246,6 +250,22 @@ static int rmi_i2c_probe(struct i2c_client *client,
> return -ENODEV;
> }
>
> + rmi_i2c->supplies[0].supply = "vdd";
> + rmi_i2c->supplies[1].supply = "vio";
> + retval = devm_regulator_bulk_get(&client->dev,
> + ARRAY_SIZE(rmi_i2c->supplies),
> + rmi_i2c->supplies);
> + if (retval < 0)
> + return retval;
> +
> + retval = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies),
> + rmi_i2c->supplies);
> + if (retval < 0)
> + return retval;
> +
> + /* Allow the firmware to get ready */
> + msleep(10);
> +
> rmi_i2c->client = client;
> mutex_init(&rmi_i2c->page_mutex);
>
> @@ -286,6 +306,8 @@ static int rmi_i2c_remove(struct i2c_client *client)
> struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client);
>
> rmi_unregister_transport_device(&rmi_i2c->xport);
> + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies),
> + rmi_i2c->supplies);
>
> return 0;
> }
> @@ -308,6 +330,10 @@ static int rmi_i2c_suspend(struct device *dev)
> dev_warn(dev, "Failed to enable irq for wake: %d\n",
> ret);
> }
> +
> + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies),
> + rmi_i2c->supplies);
> +
> return ret;
> }
>
> @@ -317,6 +343,14 @@ static int rmi_i2c_resume(struct device *dev)
> struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client);
> int ret;
>
> + ret = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies),
> + rmi_i2c->supplies);
> + if (ret)
> + return ret;
> +
> + /* Allow the firmware to get ready */
> + msleep(10);
> +
> enable_irq(rmi_i2c->irq);
> if (device_may_wakeup(&client->dev)) {
> ret = disable_irq_wake(rmi_i2c->irq);
> @@ -346,6 +380,9 @@ static int rmi_i2c_runtime_suspend(struct device *dev)
>
> disable_irq(rmi_i2c->irq);
>
> + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies),
> + rmi_i2c->supplies);
> +
> return 0;
> }
>
> @@ -355,6 +392,14 @@ static int rmi_i2c_runtime_resume(struct device *dev)
> struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client);
> int ret;
>
> + ret = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies),
> + rmi_i2c->supplies);
> + if (ret)
> + return ret;
> +
> + /* Allow the firmware to get ready */
> + msleep(10);
> +
> enable_irq(rmi_i2c->irq);
>
> ret = rmi_driver_resume(rmi_i2c->xport.rmi_dev);
> --
> 2.5.0
>
--
Dmitry
--
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
next prev parent reply other threads:[~2016-03-31 18:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 16:57 [PATCH] Input: synaptics-rmi4: Support regulator supplies Bjorn Andersson
[not found] ` <1459357049-5608-1-git-send-email-bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-03-31 18:19 ` Dmitry Torokhov [this message]
2016-03-31 19:14 ` Bjorn Andersson
2016-04-01 1:47 ` Andrew Duggan
2016-04-21 22:37 ` Bjorn Andersson
2016-05-05 20:55 ` Andrew Duggan
[not found] ` <572BB344.6030100-Gq53QDLGkWKakBO8gow8eQ@public.gmane.org>
2016-05-06 0:58 ` Bjorn Andersson
2016-05-07 4:40 ` [PATCH v2 0/3] input: rmi4: Regulator supply support Bjorn Andersson
2016-05-07 4:40 ` [PATCH v2 1/3] input: rmi4: Move IRQ handling to rmi_driver Bjorn Andersson
2016-05-07 4:40 ` [PATCH v2 2/3] input: rmi4: Acquire and enable VDD and VIO supplies Bjorn Andersson
2016-05-09 19:58 ` Rob Herring
2016-05-07 4:40 ` [PATCH v2 3/3] input: rmi4: Remove set_page() call before core is initialized Bjorn Andersson
2016-05-10 0:36 ` [PATCH v2 0/3] input: rmi4: Regulator supply support Andrew Duggan
[not found] ` <57312CFB.2040304-Gq53QDLGkWKakBO8gow8eQ@public.gmane.org>
2016-05-10 15:49 ` Bjorn Andersson
2016-05-11 23:30 ` Andrew Duggan
2016-05-12 3:05 ` Bjorn Andersson
2016-05-13 0:52 ` Andrew Duggan
2016-05-13 22:29 ` Bjorn Andersson
2016-05-16 23:55 ` Andrew Duggan
-- strict thread matches above, loose matches on Subject: below --
2016-03-30 16:57 [PATCH] Input: synaptics-rmi4: Support regulator supplies Bjorn Andersson
2016-03-30 17:02 ` Bjorn Andersson
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=20160331181905.GJ39098@dtor-ws \
--to=dmitry.torokhov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=aduggan-Gq53QDLGkWKakBO8gow8eQ@public.gmane.org \
--cc=bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org \
--cc=bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=cheiny-Gq53QDLGkWKakBO8gow8eQ@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox