Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2326419rwb; Thu, 17 Nov 2022 09:17:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/IzKTikIgkBTj7PhvBSLDcGPVUYkqk51b8ogFTNdFvIdF1paTTLfPjphVIimMxw2bVlEr X-Received: by 2002:a17:906:a198:b0:7aa:8f6c:3347 with SMTP id s24-20020a170906a19800b007aa8f6c3347mr2956666ejy.659.1668705425544; Thu, 17 Nov 2022 09:17:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668705425; cv=none; d=google.com; s=arc-20160816; b=dhxvjaoIq62e1ooNpAtOI0sZJT6ulwoN5c5GUTp2bOOt8V3i1U6M55qZ2qFrJrHP3Z zseNgifNujQ3huBdrHL5FOQMMbu44/1plez9zgwGPkqLy/oU+qsNBLzTvZjXa9feYZ7i IFEp2qPL2UxhHysybHc25dVZoJ+4c8aNXJ1oHcMff0zUQoF9vlXF5sw1zd2HgjmgTI+e iPeQajUbykqhUv74Yyp1uxlI0ptFOiBYWhIqSqGn7BZw93FsKkePfA6vYFBdEbg3h20y Pe6C1aGy52d6BSXrDLCOlbltDRpom3xM0ekjfZ2YF++QhB3BFlZ8s+y5/IuDHBvMsvib 7clA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=ZA1st/D2bOJO8psxoWwnXrvaoM+06eI7cmwLGnc8W7k=; b=mTGJ0FwWiY5e/GzZmo+/pMWFror/Y0MKZuWxqQz9dtPPFJ5sTbZYvtRzCsOUvKFqGD vPbyTbiTMoe8ZhbBeQVdyLmDjtXPZ3wcEoGyXilTm5GhvpEt/adiZDkEP3eP/wzZFV4a /hguYsCwZZvH8/S6s9/Wzq/VtHS+52u6Ewqm+Hm1Si4ho9IX5XWctbiw0yHabIuczNOH Z7AiurLlNvMvVUqkqv7/etlqtjIBAU0BVsDlD9pDShZjgIRlDEpMCIzXPBn9iQzcAtIx pCkOwmLkVeFsGJ5iABxmZ9b9MHeyIu4D/kP6EGJ06empqWGqFgjkxr4SGV3OlAiz+SS7 Hahw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b="Cg/Rlu/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw4-20020a170906478400b007919c624eadsi944516ejc.522.2022.11.17.09.16.42; Thu, 17 Nov 2022 09:17:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@protonmail.com header.s=protonmail3 header.b="Cg/Rlu/2"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=protonmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240188AbiKQQgt (ORCPT + 92 others); Thu, 17 Nov 2022 11:36:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240130AbiKQQg3 (ORCPT ); Thu, 17 Nov 2022 11:36:29 -0500 Received: from mail-4318.protonmail.ch (mail-4318.protonmail.ch [185.70.43.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4205DB99 for ; Thu, 17 Nov 2022 08:35:31 -0800 (PST) Date: Thu, 17 Nov 2022 16:35:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1668702929; x=1668962129; bh=ZA1st/D2bOJO8psxoWwnXrvaoM+06eI7cmwLGnc8W7k=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Cg/Rlu/2jqHXfQSr7sNItLVNNQ8xw1yzzKzYf8K5EMSh151LtJXqRwMonFpaWvGT+ m3VRhU2bAOT/WAu5KJYxYAQCooAAzfWXaISejENCgIP3HHawXBNfehg2onZfMB5avX VD7T8+Ld08rrX9oOYs8Q5viqVR0/fVBUy/oE1tJVkBC7FFv2WAgmn7ZKLJWthjPcqP L1H7wuODL+BlaLInXICffS8CRknC4tXCUouXmJ5vWGYc2NmGLLuWwiwJQ3Fji1zCfq cEMI1UzELsmhHgAQhuZlkWy/P7jSj0d3fDhrJE/Z9q0rJeREuKORvYXuVoD+c954wX tuIsz4dOurcPw== To: linux-kernel@vger.kernel.org From: "Lin, Meng-Bo" Cc: Markuss Broks , Dmitry Torokhov , "open list:INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN)..." Subject: [PATCH 3/3] input/touchscreen: imagis: Add supports for Imagis IST3038 and IST30XXB Message-ID: <20221117163440.23394-4-linmengbo0689@protonmail.com> In-Reply-To: <20221117163440.23394-1-linmengbo0689@protonmail.com> References: <20221117163440.23394-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markuss Broks Imagis IST3038 and IST30XXB are other variants of Imagis IST3038 IC, which have a different register interface from IST3038C (possibly firmware defined). This should also work for IST3044B (though untested), however other variants using this interface/protocol(IST3026, IST3032, IST3026B, IST3032B) have a different format for coordinates, and they'd need additional effort to be supported by this driver. Signed-off-by: Markuss Broks [Use IST3038C_REG_CHIPID_BASE] Signed-off-by: Lin, Meng-Bo --- drivers/input/touchscreen/imagis.c | 71 +++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/drivers/input/touchscreen/imagis.c b/drivers/input/touchscreen= /imagis.c index b667914a44f1..ac07b24496eb 100644 --- a/drivers/input/touchscreen/imagis.c +++ b/drivers/input/touchscreen/imagis.c @@ -13,7 +13,8 @@ =20 #define IST3038C_HIB_ACCESS=09=09(0x800B << 16) #define IST3038C_DIRECT_ACCESS=09=09BIT(31) -#define IST3038C_REG_CHIPID=09=090x40001000 +#define IST3038C_REG_CHIPID_BASE=090x40001000 +#define IST3038C_REG_CHIPID(base)=09(base | IST3038C_DIRECT_ACCESS) #define IST3038C_REG_HIB_BASE=09=090x30000100 #define IST3038C_REG_TOUCH_STATUS=09(IST3038C_REG_HIB_BASE | IST3038C_HIB_= ACCESS) #define IST3038C_REG_TOUCH_COORD=09(IST3038C_REG_HIB_BASE | IST3038C_HIB_A= CCESS | 0x8) @@ -31,8 +32,24 @@ #define IST3038C_FINGER_COUNT_SHIFT=0912 #define IST3038C_FINGER_STATUS_MASK=09GENMASK(9, 0) =20 +#define IST30XX_REG_STATUS=09=090x20 +#define IST30XXB_REG_CHIPID_BASE=090x40000000 +#define IST30XX_WHOAMI=09=09=090x30003000 +#define IST30XXA_WHOAMI=09=09=090x300a300a +#define IST30XXB_WHOAMI=09=09=090x300b300b +#define IST3038_WHOAMI=09=09=090x30383038 + +struct imagis_properties { +=09unsigned int interrupt_msg_cmd; +=09unsigned int touch_coord_cmd; +=09unsigned int chipid_base; +=09unsigned int whoami_val; +=09bool protocol_b; +}; + struct imagis_ts { =09struct i2c_client *client; +=09const struct imagis_properties *tdata; =09struct input_dev *input_dev; =09struct touchscreen_properties prop; =09struct regulator_bulk_data supplies[2]; @@ -84,8 +101,7 @@ static irqreturn_t imagis_interrupt(int irq, void *dev_i= d) =09int i; =09int error; =20 -=09error =3D imagis_i2c_read_reg(ts, IST3038C_REG_INTR_MESSAGE, -=09=09=09=09 &intr_message); +=09error =3D imagis_i2c_read_reg(ts, ts->tdata->interrupt_msg_cmd, &intr_m= essage); =09if (error) { =09=09dev_err(&ts->client->dev, =09=09=09"failed to read the interrupt message: %d\n", error); @@ -104,9 +120,13 @@ static irqreturn_t imagis_interrupt(int irq, void *dev= _id) =09finger_pressed =3D intr_message & IST3038C_FINGER_STATUS_MASK; =20 =09for (i =3D 0; i < finger_count; i++) { -=09=09error =3D imagis_i2c_read_reg(ts, -=09=09=09=09=09 IST3038C_REG_TOUCH_COORD + (i * 4), -=09=09=09=09=09 &finger_status); +=09=09if (ts->tdata->protocol_b) +=09=09=09error =3D imagis_i2c_read_reg(ts, +=09=09=09=09=09=09 ts->tdata->touch_coord_cmd, &finger_status); +=09=09else +=09=09=09error =3D imagis_i2c_read_reg(ts, +=09=09=09=09=09=09 ts->tdata->touch_coord_cmd + (i * 4), +=09=09=09=09=09=09 &finger_status); =09=09if (error) { =09=09=09dev_err(&ts->client->dev, =09=09=09=09"failed to read coordinates for finger %d: %d\n", @@ -261,6 +281,12 @@ static int imagis_probe(struct i2c_client *i2c) =20 =09ts->client =3D i2c; =20 +=09ts->tdata =3D device_get_match_data(dev); +=09if (!ts->tdata) { +=09=09dev_err(dev, "missing chip data\n"); +=09=09return -EINVAL; +=09} + =09error =3D imagis_init_regulators(ts); =09if (error) { =09=09dev_err(dev, "regulator init error: %d\n", error); @@ -279,15 +305,13 @@ static int imagis_probe(struct i2c_client *i2c) =09=09return error; =09} =20 -=09error =3D imagis_i2c_read_reg(ts, -=09=09=09IST3038C_REG_CHIPID | IST3038C_DIRECT_ACCESS, -=09=09=09&chip_id); +=09error =3D imagis_i2c_read_reg(ts, IST3038C_REG_CHIPID(ts->tdata->chipid= _base), &chip_id); =09if (error) { =09=09dev_err(dev, "chip ID read failure: %d\n", error); =09=09return error; =09} =20 -=09if (chip_id !=3D IST3038C_WHOAMI) { +=09if (chip_id !=3D ts->tdata->whoami_val) { =09=09dev_err(dev, "unknown chip ID: 0x%x\n", chip_id); =09=09return -EINVAL; =09} @@ -343,9 +367,34 @@ static int __maybe_unused imagis_resume(struct device = *dev) =20 static SIMPLE_DEV_PM_OPS(imagis_pm_ops, imagis_suspend, imagis_resume); =20 +static const struct imagis_properties imagis_3038_data =3D { +=09.interrupt_msg_cmd =3D IST30XX_REG_STATUS, +=09.touch_coord_cmd =3D IST30XX_REG_STATUS, +=09.chipid_base =3D IST30XXB_REG_CHIPID_BASE, +=09.whoami_val =3D IST3038_WHOAMI, +=09.protocol_b =3D true, +}; + +static const struct imagis_properties imagis_3038c_data =3D { +=09.interrupt_msg_cmd =3D IST3038C_REG_INTR_MESSAGE, +=09.touch_coord_cmd =3D IST3038C_REG_TOUCH_COORD, +=09.chipid_base =3D IST3038C_REG_CHIPID_BASE, +=09.whoami_val =3D IST3038C_WHOAMI, +}; + +static const struct imagis_properties imagis_30xxb_data =3D { +=09.interrupt_msg_cmd =3D IST30XX_REG_STATUS, +=09.touch_coord_cmd =3D IST30XX_REG_STATUS, +=09.chipid_base =3D IST30XXB_REG_CHIPID_BASE, +=09.whoami_val =3D IST30XXB_WHOAMI, +=09.protocol_b =3D true, +}; + #ifdef CONFIG_OF static const struct of_device_id imagis_of_match[] =3D { -=09{ .compatible =3D "imagis,ist3038c", }, +=09{ .compatible =3D "imagis,ist3038", .data =3D &imagis_3038_data }, +=09{ .compatible =3D "imagis,ist3038c", .data =3D &imagis_3038c_data }, +=09{ .compatible =3D "imagis,ist30xxb", .data =3D &imagis_30xxb_data }, =09{ }, }; MODULE_DEVICE_TABLE(of, imagis_of_match); --=20 2.30.2