mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
Input: cyttsp - obtain regulators
The CYTTSP TMA340 chips have two supplies: VCPIN and VDD for analog and digital voltage respectively. Add some minimal code to obtain and enable these regulators if need be. Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20210526230352.1433537-3-linus.walleij@linaro.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
007704c99f
commit
6cf3b3abbf
2 changed files with 37 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <linux/slab.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
|
||||
#include "cyttsp_core.h"
|
||||
|
||||
|
@ -608,6 +609,14 @@ static int cyttsp_parse_properties(struct cyttsp *ts)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void cyttsp_disable_regulators(void *_ts)
|
||||
{
|
||||
struct cyttsp *ts = _ts;
|
||||
|
||||
regulator_bulk_disable(ARRAY_SIZE(ts->regulators),
|
||||
ts->regulators);
|
||||
}
|
||||
|
||||
struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
|
||||
struct device *dev, int irq, size_t xfer_buf_size)
|
||||
{
|
||||
|
@ -628,6 +637,32 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
|
|||
ts->bus_ops = bus_ops;
|
||||
ts->irq = irq;
|
||||
|
||||
/*
|
||||
* VCPIN is the analog voltage supply
|
||||
* VDD is the digital voltage supply
|
||||
*/
|
||||
ts->regulators[0].supply = "vcpin";
|
||||
ts->regulators[1].supply = "vdd";
|
||||
error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->regulators),
|
||||
ts->regulators);
|
||||
if (error) {
|
||||
dev_err(dev, "Failed to get regulators: %d\n", error);
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
error = regulator_bulk_enable(ARRAY_SIZE(ts->regulators),
|
||||
ts->regulators);
|
||||
if (error) {
|
||||
dev_err(dev, "Cannot enable regulators: %d\n", error);
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
error = devm_add_action_or_reset(dev, cyttsp_disable_regulators, ts);
|
||||
if (error) {
|
||||
dev_err(dev, "failed to install chip disable handler\n");
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(ts->reset_gpio)) {
|
||||
error = PTR_ERR(ts->reset_gpio);
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <linux/types.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/input/cyttsp.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
|
||||
#define CY_NUM_RETRY 16 /* max number of retries for read ops */
|
||||
|
||||
|
@ -122,6 +123,7 @@ struct cyttsp {
|
|||
enum cyttsp_state state;
|
||||
bool suspended;
|
||||
|
||||
struct regulator_bulk_data regulators[2];
|
||||
struct gpio_desc *reset_gpio;
|
||||
bool use_hndshk;
|
||||
u8 act_dist;
|
||||
|
|
Loading…
Add table
Reference in a new issue