Re: [PATCH v2 1/4] Input: Add driver for Cypress Generation 5 touchscreen

Andreas Kemnade
2021-11-05T15:01:59Z

On Wed, 3 Nov 2021 21:48:27 +1000
Alistair Francis <alistair@alistair23.me> wrote:

[...]
> +static int cyttsp5_probe(struct device *dev, struct regmap *regmap, int irq,
> + const char *name)
> +{
> + struct cyttsp5 *ts;
> + struct cyttsp5_sysinfo *si;
> + int rc = 0, i;
> +
> + ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
> + if (!ts)
> + return -ENOMEM;
> +
> + /* Initialize device info */
> + ts->regmap = regmap;
> + ts->dev = dev;
> + si = &ts->sysinfo;
> + dev_set_drvdata(dev, ts);
> +
> + /* Initialize mutexes and spinlocks */
> + mutex_init(&ts->system_lock);
> +
> + /* Initialize wait queue */
> + init_waitqueue_head(&ts->wait_q);
> +
> + /* Power up the device */
> + ts->vdd = regulator_get(dev, "vdd");
> + if (IS_ERR(ts->vdd)) {
> + rc = PTR_ERR(ts->vdd);
> + dev_set_drvdata(dev, NULL);
> + kfree(ts);
> + return rc;
> + }
> +
> + rc = regulator_enable(ts->vdd);
> + if (rc) {
> + regulator_put(ts->vdd);
> + dev_set_drvdata(dev, NULL);
> + kfree(ts);
> + return rc;
> + }
> +
> + /* Reset the gpio to be in a reset state */
> + ts->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);

so we deassert reset for

> + if (IS_ERR(ts->reset_gpio)) {
> + rc = PTR_ERR(ts->reset_gpio);
> + dev_err(dev, "Failed to request reset gpio, error %d\n", rc);
> + return rc;
> + }

almost no time
> + gpiod_set_value(ts->reset_gpio, 1);

and then assert it, keeping the chip in reset
> +
> + /* Need a delay to have device up */
> + msleep(20);
> +
and why it should wake up?

I reversed the logic here to test. I have

reset-gpios = <&gpio5 13 GPIO_ACTIVE_LOW>;

in my tests.

> + rc = devm_request_threaded_irq(dev, irq, NULL, cyttsp5_handle_irq,
> + IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> + name, ts);
falling or level low (according to the example in the
dt schema)?

Regards,
Andreas