Input: cyttsp5 - add handling for vddio regulator
authorLin, Meng-Bo <linmengbo0689@protonmail.com>
Fri, 27 Oct 2023 22:56:33 +0000 (15:56 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 27 Oct 2023 23:20:38 +0000 (16:20 -0700)
The Cypress touchscreen controllers are often used with external pull-up
for the interrupt line and the I2C lines, so we might need to enable
a regulator to bring the lines into usable state. Otherwise, this might
cause spurious interrupts and reading from I2C will fail.

Implement support for a "vddio-supply" that is enabled by the cyttsp5
driver so that the regulator gets enabled when needed.

Signed-off-by: Lin, Meng-Bo <linmengbo0689@protonmail.com>
Acked-by: Alistair Francis <alistair@alistair23.me>
Link: https://lore.kernel.org/r/20221117190507.87535-3-linmengbo0689@protonmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/touchscreen/cyttsp5.c

index db5a885ecd728573edc566eb2d57f10d26e7e33a..68527ede5c0eae1393fdec5ce76150fb92ac7675 100644 (file)
@@ -207,7 +207,7 @@ struct cyttsp5 {
        int num_prv_rec;
        struct regmap *regmap;
        struct touchscreen_properties prop;
-       struct regulator *vdd;
+       struct regulator_bulk_data supplies[2];
 };
 
 /*
@@ -817,7 +817,7 @@ static void cyttsp5_cleanup(void *data)
 {
        struct cyttsp5 *ts = data;
 
-       regulator_disable(ts->vdd);
+       regulator_bulk_disable(ARRAY_SIZE(ts->supplies), ts->supplies);
 }
 
 static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
@@ -840,9 +840,12 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
        init_completion(&ts->cmd_done);
 
        /* Power up the device */
-       ts->vdd = devm_regulator_get(dev, "vdd");
-       if (IS_ERR(ts->vdd)) {
-               error = PTR_ERR(ts->vdd);
+       ts->supplies[0].supply = "vdd";
+       ts->supplies[1].supply = "vddio";
+       error = devm_regulator_bulk_get(dev, ARRAY_SIZE(ts->supplies),
+                                       ts->supplies);
+       if (error) {
+               dev_err(ts->dev, "Failed to get regulators, error %d\n", error);
                return error;
        }
 
@@ -850,9 +853,11 @@ static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
        if (error)
                return error;
 
-       error = regulator_enable(ts->vdd);
-       if (error)
+       error = regulator_bulk_enable(ARRAY_SIZE(ts->supplies), ts->supplies);
+       if (error) {
+               dev_err(ts->dev, "Failed to enable regulators, error %d\n", error);
                return error;
+       }
 
        ts->input = devm_input_allocate_device(dev);
        if (!ts->input) {