From patchwork Thu Sep 24 09:46:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Huang X-Patchwork-Id: 293931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AC54C4363D for ; Thu, 24 Sep 2020 09:48:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 29EC12396E for ; Thu, 24 Sep 2020 09:48:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Synaptics.onmicrosoft.com header.i=@Synaptics.onmicrosoft.com header.b="TcvEQFMt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727338AbgIXJsT (ORCPT ); Thu, 24 Sep 2020 05:48:19 -0400 Received: from mail-eopbgr680065.outbound.protection.outlook.com ([40.107.68.65]:33540 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726315AbgIXJsP (ORCPT ); Thu, 24 Sep 2020 05:48:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y1sGyvrnZczHDCuSz/RvKDXWw1phRgpiFQwayLvHQGPY8YVcdC/o09ka6bEDVeKIo6Nrogz6fYO3OV/jetjTK3ewuS5b/SXKYDSoHDOCS6J7MBWJZc+ebY/0fGUN1o5RDAo0FRMHKajXb/ar4acBxpX90rpXB1PRszLMu3Uk48D52+BiZ/73FwYouDF6uvzoGYKhbIsE8mnfaGqTV+Dkodfw0XmXQ0UmGk51QfT0vXb2hbcO89aKyUZcQc1SNyrBTfedYKK+ybrCKs9/+cL5KSnfNycmtU4Q6wsTgOH3AlyinD8crW4bqnzu8UPRNJ6DZku2JQOH4m38wHHPuU4j+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QIYWG2skThI0rJljXg9vSZYlxWt3Yu+wuuihKvudKl8=; b=LdMLTc8i9VPkxFwhUO0A+VUL4T7HYNRunkgcJXrl+nGq5o1h/OlO+LaG2LhkzOuPrajkU0xORr3dmZzvcG+4tx0BsaC+8NHj3UfYLcJT3kwM4Qj4buNiW3b3OHFA5Rp3OeHKNnznHJNZZDX9EeH6OD6BpEeELzMjRdFDnvq3sE0UNgB8KqFIKTYs6opmrbRLff6p5W5/qBwRWcREdeWgy79QUITx0BrwnifPWVkwlTs/JG8ZrEU+UKZudODgzrGeaMMytTwSlcZ89m8DOKhKZ1dghIssMevq7L5Rw8jFGXza/ZdoCQvd2CDGl5xtHsGir900CGrX6uT5J4J3PIDc0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=tw.synaptics.com; dmarc=pass action=none header.from=tw.synaptics.com; dkim=pass header.d=tw.synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QIYWG2skThI0rJljXg9vSZYlxWt3Yu+wuuihKvudKl8=; b=TcvEQFMtTR8BK+GzTvlQNqs4WR/o7qekqZOKH98KnoWm3lK3ltMknx9MVhWu37Z5zNBWBUohi1whzeEqJ9JhOrwUJlWOELtK/Gd99VSETFqlsLlpbyWYlYK1n0KDPZKcR9YiE3g5bkCm76xNVx+CgKLGsEjNIRoYi9LZc2UicLk= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=tw.synaptics.com; Received: from SN6PR03MB3952.namprd03.prod.outlook.com (2603:10b6:805:75::26) by SN6PR03MB4496.namprd03.prod.outlook.com (2603:10b6:805:103::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 24 Sep 2020 09:48:13 +0000 Received: from SN6PR03MB3952.namprd03.prod.outlook.com ([fe80::3c54:f5cf:3148:407e]) by SN6PR03MB3952.namprd03.prod.outlook.com ([fe80::3c54:f5cf:3148:407e%7]) with mapi id 15.20.3391.027; Thu, 24 Sep 2020 09:48:13 +0000 From: Vincent Huang To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vincent Huang , Dmitry Torokhov , Jiri Kosina , Andrew Duggan , Hans de Goede , Benjamin Tissoires , Lyude Paul , Chris Heiny Subject: [PATCH 1/3] Input: synaptics-rmi4 - rename f30_data to gpio_data Date: Thu, 24 Sep 2020 17:46:26 +0800 Message-Id: <20200924094628.1085000-2-vincent.huang@tw.synaptics.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200924094628.1085000-1-vincent.huang@tw.synaptics.com> References: <20200924094628.1085000-1-vincent.huang@tw.synaptics.com> X-ClientProxiedBy: HK2PR02CA0181.apcprd02.prod.outlook.com (2603:1096:201:21::17) To SN6PR03MB3952.namprd03.prod.outlook.com (2603:10b6:805:75::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from test-ThinkPad.synaptics-inc.local (60.250.40.146) by HK2PR02CA0181.apcprd02.prod.outlook.com (2603:1096:201:21::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22 via Frontend Transport; Thu, 24 Sep 2020 09:48:10 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [60.250.40.146] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 752889c2-ceba-411e-171a-08d8606ef3f6 X-MS-TrafficTypeDiagnostic: SN6PR03MB4496: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1kQU1324TrhUNcyV2lZwxuXpWolhgUDjzukqvjQzDXvYTe251PM3KBTJ6C2/7IEVfWRlRJuzC5FN+7x7kF7mEl5qqqTUG2+AnLksfIgh3Hq0xSXcsfOTNvyPBeGCWXBCXmqNNVH1CHPg8eLRo9OoBz8DKbowtqrikNuNggTWnDir98+EfxY4GqNx0wMmifQ+jUkfq1uTmFzJVhHRGnyxBt/jGY8oflAd57H94hYF48hj+L9a0VYqtknNQymvGIKr8X8PHZUrQTHTy1yTlvdZsuqMmROOTFraetVgJ0tZZErsklJ+Ve+esGeGjoYd2zwu3sEwAyw42SNTcdK73l0aj+Av6V19Srf0lYcdZBWOs40Q5MnHyemLnpSMpKF81vDBTipo9l8iJv7Wv4Fm+DsvnH8LTmpKBrsRFSFbizMoUng= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3952.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(366004)(346002)(136003)(376002)(2616005)(956004)(66556008)(44832011)(26005)(6512007)(83380400001)(16526019)(186003)(8676002)(8936002)(6506007)(52116002)(1076003)(478600001)(66476007)(54906003)(86362001)(5660300002)(66946007)(2906002)(6486002)(316002)(107886003)(6666004)(4326008)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: PRHo93gtSdzSb2iPY96H37PNTyQ/+5C6n5Cl/k3Wa2iTaN4vfXHNy4PLxd8BXSL5Iit6jbbP2yVRVY20MWdWkjIAhCY6HOrCCJTGq8d+RZMCpXfnpDqoRVxfP7ph2DA9zLeSe1bhibF42sAT/meD7zo/OHxdNGX15xu8t8RccRgGKCu4cjrgjnfmes/8tFEJx6vChZgNnokQ46Po9mFjP7+s91tztWtTA9LDbV26jINzbwLNQdFJhr08OoMO1iTPkAwDEarStqOT8JoCrlFhU68TddSoJUVJY7hGtzFdjET3EaNOteyY12vGjECgiSYbVqKvOkPg0SHCCjRIofhQk5r+eukH2HzdLBe2EpiCXk4kVbL5kV/wTuNkU/WdsO5NK0loBZal3BkQ/exy3VCs8gzpEflTRWyudtD7gldPUIlS8w1HqylomCJiFvX8AJdQbfRDsZewzjvTFdKwRtW5j3ngX3on9njUHdFwzV8y9Kr87qR95JR+D2pSoBSut6/SLT8504i4puOnMDyqBZhCd1Xl6ZL3IyYbWp/8frrRJR030HsJHjoaxIsS5dV1uDp/FUSWdGEppz2DX5KYcY/aek0KeIC128LLN2TlngcWUeLl5hABDscTZJ4YFi1g8uGaDlI9fcHCaSQ39d1BILz9hA== X-OriginatorOrg: tw.synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 752889c2-ceba-411e-171a-08d8606ef3f6 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3952.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 09:48:13.0132 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: G2XKmGvwo5CCafqElpDrh5dSLSO+FD94K2zbaRqieOm3JI2xDF/VME0VXN9DKLL/VQ2mO2NPThEaBxzdglpRxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4496 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org f30_data in rmi_device_platform_data could be also referenced by RMI function 3A, so rename it and the structure name to avoid confusion. Signed-off-by: Vincent Huang --- drivers/input/mouse/synaptics.c | 2 +- drivers/input/rmi4/rmi_f30.c | 14 +++++++------- include/linux/rmi.h | 11 ++++++----- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index 4b81b2d0fe06..8a54efd6eb95 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c @@ -1752,7 +1752,7 @@ static int synaptics_create_intertouch(struct psmouse *psmouse, .kernel_tracking = false, .topbuttonpad = topbuttonpad, }, - .f30_data = { + .gpio_data = { .buttonpad = SYN_CAP_CLICKPAD(info->ext_cap_0c), .trackstick_buttons = !!SYN_CAP_EXT_BUTTONS_STICK(info->ext_cap_10), diff --git a/drivers/input/rmi4/rmi_f30.c b/drivers/input/rmi4/rmi_f30.c index a90dad1d9ac7..35045f161dc2 100644 --- a/drivers/input/rmi4/rmi_f30.c +++ b/drivers/input/rmi4/rmi_f30.c @@ -168,17 +168,17 @@ static int rmi_f30_config(struct rmi_function *fn) rmi_get_platform_data(fn->rmi_dev); int error; - /* can happen if f30_data.disable is set */ + /* can happen if gpio_data.disable is set */ if (!f30) return 0; - if (pdata->f30_data.trackstick_buttons) { + if (pdata->gpio_data.trackstick_buttons) { /* Try [re-]establish link to F03. */ f30->f03 = rmi_find_function(fn->rmi_dev, 0x03); f30->trackstick_buttons = f30->f03 != NULL; } - if (pdata->f30_data.disable) { + if (pdata->gpio_data.disable) { drv->clear_irq_bits(fn->rmi_dev, fn->irq_mask); } else { /* Write Control Register values back to device */ @@ -245,10 +245,10 @@ static int rmi_f30_map_gpios(struct rmi_function *fn, if (!rmi_f30_is_valid_button(i, f30->ctrl)) continue; - if (pdata->f30_data.trackstick_buttons && + if (pdata->gpio_data.trackstick_buttons && i >= TRACKSTICK_RANGE_START && i < TRACKSTICK_RANGE_END) { f30->gpioled_key_map[i] = trackstick_button++; - } else if (!pdata->f30_data.buttonpad || !button_mapped) { + } else if (!pdata->gpio_data.buttonpad || !button_mapped) { f30->gpioled_key_map[i] = button; input_set_capability(input, EV_KEY, button++); button_mapped = true; @@ -264,7 +264,7 @@ static int rmi_f30_map_gpios(struct rmi_function *fn, * but I am not sure, so use only the pdata info and the number of * mapped buttons. */ - if (pdata->f30_data.buttonpad || (button - BTN_LEFT == 1)) + if (pdata->gpio_data.buttonpad || (button - BTN_LEFT == 1)) __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); return 0; @@ -372,7 +372,7 @@ static int rmi_f30_probe(struct rmi_function *fn) struct f30_data *f30; int error; - if (pdata->f30_data.disable) + if (pdata->gpio_data.disable) return 0; if (!drv_data->input) { diff --git a/include/linux/rmi.h b/include/linux/rmi.h index 7b22366d0065..00dda5381bf8 100644 --- a/include/linux/rmi.h +++ b/include/linux/rmi.h @@ -102,15 +102,16 @@ struct rmi_2d_sensor_platform_data { }; /** - * struct rmi_f30_data - overrides defaults for a single F30 GPIOs/LED chip. + * struct rmi_gpio_data - overrides defaults for a single F30/F3A GPIOs/LED + * chip. * @buttonpad - the touchpad is a buttonpad, so enable only the first actual * button that is found. - * @trackstick_buttons - Set when the function 30 is handling the physical + * @trackstick_buttons - Set when the function 30 or 3a is handling the physical * buttons of the trackstick (as a PS/2 passthrough device). - * @disable - the touchpad incorrectly reports F30 and it should be ignored. + * @disable - the touchpad incorrectly reports F30/F3A and it should be ignored. * This is a special case which is due to misconfigured firmware. */ -struct rmi_f30_data { +struct rmi_gpio_data { bool buttonpad; bool trackstick_buttons; bool disable; @@ -218,7 +219,7 @@ struct rmi_device_platform_data { /* function handler pdata */ struct rmi_2d_sensor_platform_data sensor_pdata; struct rmi_f01_power_management power_management; - struct rmi_f30_data f30_data; + struct rmi_gpio_data gpio_data; }; /** From patchwork Thu Sep 24 09:46:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Huang X-Patchwork-Id: 254959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0495C4363D for ; Thu, 24 Sep 2020 09:48:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A10A82396E for ; Thu, 24 Sep 2020 09:48:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Synaptics.onmicrosoft.com header.i=@Synaptics.onmicrosoft.com header.b="L5xqJn/5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727391AbgIXJsc (ORCPT ); Thu, 24 Sep 2020 05:48:32 -0400 Received: from mail-eopbgr750057.outbound.protection.outlook.com ([40.107.75.57]:4929 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727367AbgIXJs0 (ORCPT ); Thu, 24 Sep 2020 05:48:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g2n8jQ9Q/QsEDMZicZPlCNWT71RG9sfjxx14qqbYcX1zBNd6IAhy6gfZ8Lh31uYGVdJ8CYzuQGe+SemcXSe8fDda46AUgDhnWqC7KjMWNu6ux6ShI9VERftT1fizxq73Ym8IJmRLNoBA3FivwjXAjQkRPlkh/UoinkdQ/Nwgl+a/m9M6sjxyRljmv+CUbNy/qD0SF9bWG9QPi6FvERlP+/HzinWVrfoNkrTwb7IGDt0KxVYuXp+7CC0e+sQ23I/TlOL3mk4nei+d3YaQRXfL15XnrKkG4ttzy7IhINqAYxJzRTD96WdVzvEhjdeNuSV53gaffBPVJXaqZd4IJCk0xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vy7zmDyTs2oyvhI9zsOvF7rVN8oWYwurWACSeTjTrl0=; b=mH83NADa4Q/+I8/vo76yBwXxVQbLO0AGS/E1wvTIlS+I0Qvis6NMoKmYrS43IpmLjxGNSqTKEwi+ffOx+vwT+ImLOOMqyPgabOfiMbUzEXprphV7YanNks0sKsG1XXxJhN9cERVKeu4aMMR3d3p6V2bHUSqiFx+cjihOXHNAs6sOveHfGizK+9B5vLvjEEcm6r8z7LG+pAFiZE7az5mh0OMgtZyv+oNSTK/k4kFWGlFhs7S3e90MMTn0uNWLDA+c6jnT8tA2kYaLTsTQhYJ2C/5bqFJdpYa3CopQ2bXGoPoPGmW+8mtFZia4/KXWe69W6adnhtS5IhAWF/MiRdSd7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=tw.synaptics.com; dmarc=pass action=none header.from=tw.synaptics.com; dkim=pass header.d=tw.synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vy7zmDyTs2oyvhI9zsOvF7rVN8oWYwurWACSeTjTrl0=; b=L5xqJn/5b31D6g2H6o9oFcox62rl4ktUMfE6+E/pXG223cY6bCiB9sARGMOTb9tc8uGyudKEbh0LcZqDGQ5ZfYoObo6Dw8556E6wNIhYtv894hSBD3CByUTjbDYuhrqHEVePRtfQKvkgShLwvNWtum/a8ff1srAxmTeMpjHezFo= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=tw.synaptics.com; Received: from SN6PR03MB3952.namprd03.prod.outlook.com (2603:10b6:805:75::26) by SN6PR03MB4496.namprd03.prod.outlook.com (2603:10b6:805:103::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 24 Sep 2020 09:48:23 +0000 Received: from SN6PR03MB3952.namprd03.prod.outlook.com ([fe80::3c54:f5cf:3148:407e]) by SN6PR03MB3952.namprd03.prod.outlook.com ([fe80::3c54:f5cf:3148:407e%7]) with mapi id 15.20.3391.027; Thu, 24 Sep 2020 09:48:23 +0000 From: Vincent Huang To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vincent Huang , Dmitry Torokhov , Jiri Kosina , Andrew Duggan , Hans de Goede , Benjamin Tissoires , Lyude Paul , Chris Heiny Subject: [PATCH 2/3] HID: rmi - rename f30_data to gpio_data Date: Thu, 24 Sep 2020 17:46:27 +0800 Message-Id: <20200924094628.1085000-3-vincent.huang@tw.synaptics.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200924094628.1085000-1-vincent.huang@tw.synaptics.com> References: <20200924094628.1085000-1-vincent.huang@tw.synaptics.com> X-ClientProxiedBy: HK2PR02CA0181.apcprd02.prod.outlook.com (2603:1096:201:21::17) To SN6PR03MB3952.namprd03.prod.outlook.com (2603:10b6:805:75::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from test-ThinkPad.synaptics-inc.local (60.250.40.146) by HK2PR02CA0181.apcprd02.prod.outlook.com (2603:1096:201:21::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22 via Frontend Transport; Thu, 24 Sep 2020 09:48:20 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [60.250.40.146] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a55f5bc-fe28-4d2f-930a-08d8606efa10 X-MS-TrafficTypeDiagnostic: SN6PR03MB4496: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7KA6St6Ia0/WCn4Gq1Y6+/bXg+nHXJRi/IC8LL7L7SCvWXOSKegC0emrEPz68w5oP0sKRJDK1TwXYJC3HiHW3Yr9zBALipVb5g3Ex+5zhNFIoISjfUFkZJw158v+qcVC6GqDuUidhrxuG29sDA5hhVb1w6L4JAN90rMQVAOcfrrgWE5OkG+VeAYyuHqX+utVSykbQl6n4mwnithrILnFD1VFcwe6VbawjZqvg9fpRKe5zUeTuklOQhvOjhLHfeHmpFIeUfDrft0tJDfd49s5wtLt3CwVcA7kheA4aRDOmjpD8UNYyXFSyuaD3rIpsXCygSHfRha1806GRumXOt57di5IM2sEQ75DQhUu/pFadgTBfxgcd9Si9bXaz6gAeRM7 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3952.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(366004)(346002)(136003)(376002)(2616005)(956004)(66556008)(44832011)(26005)(6512007)(83380400001)(16526019)(186003)(8676002)(8936002)(6506007)(52116002)(1076003)(478600001)(66476007)(54906003)(86362001)(5660300002)(66946007)(2906002)(6486002)(316002)(107886003)(4744005)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: eEst2ww4Q/LUkVtvfs9/FSTkvH/sxkIyPmlKP/NzSWsjyw1kn/esV8eH6wfyEns55r7ozq6Pc/H44TPOTzcz50v+w6krIio1GbtW6mnbeWuJJnrVaQtq5VKesALVzxThynNcO4+RIJyv/Goq9sRGbjS3mQqPuAeRvlFSx77iLtF4mcKQFL6v9QR74GHlpfR4ml1XoR40aiNdnexl4kSU1II2ylSJMygrS5/W5As9Q2sgC9yN53NeR7+QBUvhHUIg2cpRu57lcKCXeCEF1YeVRT+SRY6Yo2Tuf2rHIfu7r39EZOfD+5UjwZmN7S+yo5DWYMSiFMiqUnj8wioJpwH2KcOh8gUbgU/u59+2//H1YhrkAdy5P4kZBdtEU+ZDhQmN4hW0HM9MXcvJ/6rte08SogA3DoMdukvsbxfAk1ZEaGwW39fxeP2lw5N2scluTAWueDxZF+Qej+CmV4ZrqeqgwHFsRknvTrBZQxl7JhPOdXqaUtXMq9qsoF/uCZYb/j2hmEQPJFb2L+7RqsNKrFS9EQ8M9+83CfVAJabHWYRfQTm/Rx6mrhH3VatOfP+ZjWdFA/43abdeqUjgsiA1YYNEzTL4MAmuPbec5NNr1BCbBhAcN1PQITp5iwIQzav2LoITLrvS9sWxiuUpGhMtIJbT9Q== X-OriginatorOrg: tw.synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a55f5bc-fe28-4d2f-930a-08d8606efa10 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3952.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 09:48:23.4577 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PfV++j8eEQOQxCAMcyZWCZuH7aX4lCfZwvmwsnooaev1yS6/Ag93swnIvLoq3bWoYVw3o/tut7pw6PKvpg4Vsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4496 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org f30_data in rmi_device_platform_data could be also referenced by RMI function 3A, so rename it and the structure name to avoid confusion. Signed-off-by: Vincent Huang --- drivers/hid/hid-rmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index 9ce22acdfaca..62315e31d520 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c @@ -722,7 +722,7 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) } if (data->device_flags & RMI_DEVICE_HAS_PHYS_BUTTONS) - rmi_hid_pdata.f30_data.disable = true; + rmi_hid_pdata.gpio_data.disable = true; data->xport.dev = hdev->dev.parent; data->xport.pdata = rmi_hid_pdata; From patchwork Thu Sep 24 09:46:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Huang X-Patchwork-Id: 293930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC5FCC4363D for ; Thu, 24 Sep 2020 09:48:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C5E5239A1 for ; Thu, 24 Sep 2020 09:48:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=Synaptics.onmicrosoft.com header.i=@Synaptics.onmicrosoft.com header.b="CPIeZztq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727367AbgIXJsg (ORCPT ); Thu, 24 Sep 2020 05:48:36 -0400 Received: from mail-eopbgr680074.outbound.protection.outlook.com ([40.107.68.74]:15172 "EHLO NAM04-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726631AbgIXJse (ORCPT ); Thu, 24 Sep 2020 05:48:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FUr5+4xU+AL/urcaHPaygKqmyM65kIJ5HO/l2JxjFPgOvW60yeVJClsvZB/KNPAtw5c+whq2/7qnHeds2peMgbIuu3HbEUmq5e3qF0IN2+PFJL7arDb+mvclXd/m51xtFAYhloVCYfCICbFJ0YhQqf9tlqADJJ0MDlNomULtAdF3RrozCRKR2vq3oc0T2ttb+Oq9NuD7xM3pY5BDQODauEXGaLt5n/O9Ig2e2ORb9IAsEG94obKcpTbKmdNPK0lTZzjHe7CqB3pj1TkXd7XIhnfpT7aYn+lNCLFkgKBjDFwGteT4U6E/aWxZN4SPk6xzmwuzhWIOYR2v9HQJPWH0TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MpZOIGLtPerLal07TwFocRTguGLK0rwSVV8FrmOyeaU=; b=eh4kkEsYVBrYjiOlO7k+HEYqp+RRKyr/T3bqes1AmuuyOQTaXynIWwJNGxMnzHpZ+XqH0pv4aQW01Z3/rwiKHLoMdALOX4V+154wiBbSEJdfE9ZUOUWAQ9h55sKewgoYeoW9UactRRln87FM8WJ4jdRhHv01IXcP9gDCt/qGb0jDmaxKou4XtT6bGATq1ZwJ+kQk0sWCiG6U/H9Q8uJ2vJg7OPsdY+ybfp53De9MnM5BF2hS8TDdnKLIG6BDua4d6UwdCOtUEbkUEjbTxTKTmuUdYU09m4/WJHwxBhPSSFEDqcZx7liDkGKMvCegBQDYvwmQJNiS87caMroUYDhAZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=tw.synaptics.com; dmarc=pass action=none header.from=tw.synaptics.com; dkim=pass header.d=tw.synaptics.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector2-Synaptics-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MpZOIGLtPerLal07TwFocRTguGLK0rwSVV8FrmOyeaU=; b=CPIeZztqVQ2zz8fG1ZYZ6yAXB5wLi0cBpLVsTad57AODUkTk2vykfm/aoeezpyWbzFa6kENpAcoZSxz6XmoAr48lKqSO7jnuAMJeaciULmKlYhGap9Ms6iIZVtmoQLpqUMdnMyIhiTp0yVuh+elGAOZ2FhgMaecK3Q7oLOwfY38= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=tw.synaptics.com; Received: from SN6PR03MB3952.namprd03.prod.outlook.com (2603:10b6:805:75::26) by SN6PR03MB4496.namprd03.prod.outlook.com (2603:10b6:805:103::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11; Thu, 24 Sep 2020 09:48:30 +0000 Received: from SN6PR03MB3952.namprd03.prod.outlook.com ([fe80::3c54:f5cf:3148:407e]) by SN6PR03MB3952.namprd03.prod.outlook.com ([fe80::3c54:f5cf:3148:407e%7]) with mapi id 15.20.3391.027; Thu, 24 Sep 2020 09:48:30 +0000 From: Vincent Huang To: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vincent Huang , Dmitry Torokhov , Jiri Kosina , Andrew Duggan , Hans de Goede , Benjamin Tissoires , Lyude Paul , Chris Heiny Subject: [PATCH 3/3] Input: synaptics-rmi4 - add support for F3A Date: Thu, 24 Sep 2020 17:46:28 +0800 Message-Id: <20200924094628.1085000-4-vincent.huang@tw.synaptics.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200924094628.1085000-1-vincent.huang@tw.synaptics.com> References: <20200924094628.1085000-1-vincent.huang@tw.synaptics.com> X-ClientProxiedBy: HK2PR02CA0181.apcprd02.prod.outlook.com (2603:1096:201:21::17) To SN6PR03MB3952.namprd03.prod.outlook.com (2603:10b6:805:75::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from test-ThinkPad.synaptics-inc.local (60.250.40.146) by HK2PR02CA0181.apcprd02.prod.outlook.com (2603:1096:201:21::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.22 via Frontend Transport; Thu, 24 Sep 2020 09:48:27 +0000 X-Mailer: git-send-email 2.25.1 X-Originating-IP: [60.250.40.146] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72766cee-0783-441e-51c9-08d8606efe86 X-MS-TrafficTypeDiagnostic: SN6PR03MB4496: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:26; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d7brrD8X/mFBZCgfvMvSXM8bzjhn1Qh/GV4vb+NMiw/A4OYq18Z3YmBZH24/2a5w0EJkK9oYSx1PEZM3AXtXshVXYW48O2xxyZE5ClRI9L+Qm/u/atqdizVtMSZYjMlZsNz2IkSpWDfAoqdqjX/2TDZiogNrsoutu3iaBVWJM3PxJLBPxzgisXKppwZb1NfKz+GR8NEJApetar1YeTD8MLRr1rurSr/xmYTL1q3zJKMkAGcjtedOH5KH+SohnJhg6bkixZg27nYN7WfiTxO3Pcs0CMUPkUafaVmRFkzbsczRcQ1gfSZW5PDYoBAas+qJRWUi2fg9aPUkBmM8YUafzqriW3FvsvMl56Oxgc4vc1Bs+XkxGinAHMWJb9FM5aOl X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SN6PR03MB3952.namprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(366004)(346002)(136003)(376002)(2616005)(956004)(66556008)(44832011)(26005)(6512007)(83380400001)(16526019)(186003)(8676002)(8936002)(6506007)(52116002)(1076003)(478600001)(66476007)(54906003)(86362001)(5660300002)(66946007)(2906002)(6486002)(316002)(107886003)(4326008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 2Ff1GoJ2Efqiqdpp7cPAdJlNzt0qBfcMUHD5FRg9DvaheS/1PMlY7pPo/pf+UH8ikqlQcdAZyGJEZ/ccN8X7RYEsMtKk/BPxgPAKc4xfQ1A6Yq6O/bmAf+0E9mARxg41Z75Iq/ReiZmC4a0oF5Cy0f75CJxd/uMke6jBxvv5m/US1pFEh1QtMlMjPGvWjDmjWYki5pAqPGZGrWcXIB+TnGgvjeTjyFsoLPINBcljWJ2fNk2TEJ/ZcXuzQ2FHU/mTy5aBKYAgPwdWeFmqYmGfT2V2iND7oLy1H0istF/qdFvvF42fKdDtZZ0KsmITcajNAHPKmGZ3gKwp00L9bG2/27wf1FdbcxZAORsBOAB8LxcvAiSpeOOGLH6Be6f0JkrQQnsDwHVwvVlLbIt0YOTSLJsDJc97WPo14pKYIEXOSEoc+BYAXgUJP0rOgQB9XMDGXnOzheMWuiMqqOnC2tdT/V9NNwe0W9U1fSzgnp5+QnFtOQa8605qr9ZAs8wO8QyDJHxfdtn+2ULW792NqspmqQMLpvKTRwXloz7PSV6XGbq5EL/bDytohfvsgAIMbrv6Jla2gA0nsLNYNybTYnBcSvbZaJ0ZnBT0t3V3IctH9t+AQnx5CAZKwVxm3anHyDyXcucaTYlFYmgsCyVp4+DdIw== X-OriginatorOrg: tw.synaptics.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72766cee-0783-441e-51c9-08d8606efe86 X-MS-Exchange-CrossTenant-AuthSource: SN6PR03MB3952.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2020 09:48:30.7885 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kc8oZIQCI0vk2thDE7dU65SQqkh8OhY/qlkofDU5ATL89OXSMgEnvd30i3KLDEWoY89u+ym/b6hHpTDCE8tgDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR03MB4496 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org RMI4 F3A supports the touchpad GPIO function, it's designed to support more GPIOs and used on newer touchpads. This patch adds support of the touchpad buttons. Signed-off-by: Vincent Huang --- drivers/input/rmi4/Kconfig | 8 ++ drivers/input/rmi4/Makefile | 1 + drivers/input/rmi4/rmi_bus.c | 3 + drivers/input/rmi4/rmi_driver.h | 1 + drivers/input/rmi4/rmi_f3a.c | 241 ++++++++++++++++++++++++++++++++ 5 files changed, 254 insertions(+) create mode 100644 drivers/input/rmi4/rmi_f3a.c diff --git a/drivers/input/rmi4/Kconfig b/drivers/input/rmi4/Kconfig index a212ff706f74..16119f760d11 100644 --- a/drivers/input/rmi4/Kconfig +++ b/drivers/input/rmi4/Kconfig @@ -100,6 +100,14 @@ config RMI4_F34 device via the firmware loader interface. This is triggered using a sysfs attribute. +config RMI4_F3A + bool "RMI4 Function 3A (GPIO)" + help + Say Y here if you want to add support for RMI4 function 3A. + + Function 3A provides GPIO support for RMI4 devices. This includes + support for buttons on TouchPads and ClickPads. + config RMI4_F54 bool "RMI4 Function 54 (Analog diagnostics)" depends on VIDEO_V4L2=y || (RMI4_CORE=m && VIDEO_V4L2=m) diff --git a/drivers/input/rmi4/Makefile b/drivers/input/rmi4/Makefile index f17631656987..02f14c846861 100644 --- a/drivers/input/rmi4/Makefile +++ b/drivers/input/rmi4/Makefile @@ -10,6 +10,7 @@ rmi_core-$(CONFIG_RMI4_F11) += rmi_f11.o rmi_core-$(CONFIG_RMI4_F12) += rmi_f12.o rmi_core-$(CONFIG_RMI4_F30) += rmi_f30.o rmi_core-$(CONFIG_RMI4_F34) += rmi_f34.o rmi_f34v7.o +rmi_core-$(CONFIG_RMI4_F3A) += rmi_f3a.o rmi_core-$(CONFIG_RMI4_F54) += rmi_f54.o rmi_core-$(CONFIG_RMI4_F55) += rmi_f55.o diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c index af706a583656..47d1b97ed6cf 100644 --- a/drivers/input/rmi4/rmi_bus.c +++ b/drivers/input/rmi4/rmi_bus.c @@ -365,6 +365,9 @@ static struct rmi_function_handler *fn_handlers[] = { #ifdef CONFIG_RMI4_F34 &rmi_f34_handler, #endif +#ifdef CONFIG_RMI4_F3A + &rmi_f3a_handler, +#endif #ifdef CONFIG_RMI4_F54 &rmi_f54_handler, #endif diff --git a/drivers/input/rmi4/rmi_driver.h b/drivers/input/rmi4/rmi_driver.h index 65bfaa95e193..1c6c6086c0e5 100644 --- a/drivers/input/rmi4/rmi_driver.h +++ b/drivers/input/rmi4/rmi_driver.h @@ -135,6 +135,7 @@ extern struct rmi_function_handler rmi_f11_handler; extern struct rmi_function_handler rmi_f12_handler; extern struct rmi_function_handler rmi_f30_handler; extern struct rmi_function_handler rmi_f34_handler; +extern struct rmi_function_handler rmi_f3a_handler; extern struct rmi_function_handler rmi_f54_handler; extern struct rmi_function_handler rmi_f55_handler; #endif diff --git a/drivers/input/rmi4/rmi_f3a.c b/drivers/input/rmi4/rmi_f3a.c new file mode 100644 index 000000000000..be3c1ecc1181 --- /dev/null +++ b/drivers/input/rmi4/rmi_f3a.c @@ -0,0 +1,241 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2012-2020 Synaptics Incorporated + */ + +#include +#include +#include +#include +#include "rmi_driver.h" + +#define RMI_F3A_MAX_GPIO_COUNT 128 +#define RMI_F3A_MAX_REG_SIZE DIV_ROUND_UP(RMI_F3A_MAX_GPIO_COUNT, 8) + +/* Defs for Query 0 */ +#define RMI_F3A_GPIO_COUNT 0x7F + +#define RMI_F3A_DATA_REGS_MAX_SIZE RMI_F3A_MAX_REG_SIZE + +#define TRACKSTICK_RANGE_START 3 +#define TRACKSTICK_RANGE_END 6 + +struct f3a_data { + /* Query Data */ + u8 gpio_count; + + u8 register_count; + + u8 data_regs[RMI_F3A_DATA_REGS_MAX_SIZE]; + u16 *gpio_key_map; + + struct input_dev *input; + + struct rmi_function *f03; + bool trackstick_buttons; +}; + +static void rmi_f3a_report_button(struct rmi_function *fn, + struct f3a_data *f3a, unsigned int button) +{ + u16 key_code = f3a->gpio_key_map[button]; + bool key_down = !(f3a->data_regs[0] & BIT(button)); + + if (f3a->trackstick_buttons && + button >= TRACKSTICK_RANGE_START && + button <= TRACKSTICK_RANGE_END) { + rmi_f03_overwrite_button(f3a->f03, key_code, key_down); + } else { + rmi_dbg(RMI_DEBUG_FN, &fn->dev, + "%s: call input report key (0x%04x) value (0x%02x)", + __func__, key_code, key_down); + input_report_key(f3a->input, key_code, key_down); + } +} + +static irqreturn_t rmi_f3a_attention(int irq, void *ctx) +{ + struct rmi_function *fn = ctx; + struct f3a_data *f3a = dev_get_drvdata(&fn->dev); + struct rmi_driver_data *drvdata = dev_get_drvdata(&fn->rmi_dev->dev); + int error; + int i; + + if (drvdata->attn_data.data) { + if (drvdata->attn_data.size < f3a->register_count) { + dev_warn(&fn->dev, + "F3A interrupted, but data is missing\n"); + return IRQ_HANDLED; + } + memcpy(f3a->data_regs, drvdata->attn_data.data, + f3a->register_count); + drvdata->attn_data.data += f3a->register_count; + drvdata->attn_data.size -= f3a->register_count; + } else { + error = rmi_read_block(fn->rmi_dev, fn->fd.data_base_addr, + f3a->data_regs, f3a->register_count); + if (error) { + dev_err(&fn->dev, + "%s: Failed to read F3a data registers: %d\n", + __func__, error); + return IRQ_RETVAL(error); + } + } + + + for (i = 0; i < f3a->gpio_count; i++) + if (f3a->gpio_key_map[i] != KEY_RESERVED) + rmi_f3a_report_button(fn, f3a, i); + if (f3a->trackstick_buttons) + rmi_f03_commit_buttons(f3a->f03); + + return IRQ_HANDLED; +} + +static int rmi_f3a_config(struct rmi_function *fn) +{ + struct f3a_data *f3a = dev_get_drvdata(&fn->dev); + struct rmi_driver *drv = fn->rmi_dev->driver; + const struct rmi_device_platform_data *pdata = + rmi_get_platform_data(fn->rmi_dev); + + if (!f3a) + return 0; + + if (pdata->gpio_data.trackstick_buttons) { + /* Try [re-]establish link to F03. */ + f3a->f03 = rmi_find_function(fn->rmi_dev, 0x03); + f3a->trackstick_buttons = f3a->f03 != NULL; + } + + drv->set_irq_bits(fn->rmi_dev, fn->irq_mask); + + return 0; +} + +static bool rmi_f3a_is_valid_button(int button, struct f3a_data *f3a, + u8 *query1_regs, u8 *ctrl1_regs) +{ + /* gpio exist && direction input */ + return (query1_regs[0] & BIT(button)) && !(ctrl1_regs[0] & BIT(button)); +} + +static int rmi_f3a_map_gpios(struct rmi_function *fn, struct f3a_data *f3a, + u8 *query1_regs, u8 *ctrl1_regs) +{ + const struct rmi_device_platform_data *pdata = + rmi_get_platform_data(fn->rmi_dev); + struct input_dev *input = f3a->input; + unsigned int button = BTN_LEFT; + unsigned int trackstick_button = BTN_LEFT; + bool button_mapped = false; + int i; + int button_count = min_t(u8, f3a->gpio_count, TRACKSTICK_RANGE_END); + + f3a->gpio_key_map = devm_kcalloc(&fn->dev, + button_count, + sizeof(f3a->gpio_key_map[0]), + GFP_KERNEL); + if (!f3a->gpio_key_map) { + dev_err(&fn->dev, "Failed to allocate gpio map memory.\n"); + return -ENOMEM; + } + + for (i = 0; i < button_count; i++) { + + if (!rmi_f3a_is_valid_button(i, f3a, query1_regs, ctrl1_regs)) + continue; + + if (pdata->gpio_data.trackstick_buttons && + i >= TRACKSTICK_RANGE_START && i < TRACKSTICK_RANGE_END) { + f3a->gpio_key_map[i] = trackstick_button++; + } else if (!pdata->gpio_data.buttonpad || !button_mapped) { + f3a->gpio_key_map[i] = button; + input_set_capability(input, EV_KEY, button++); + button_mapped = true; + } + } + input->keycode = f3a->gpio_key_map; + input->keycodesize = sizeof(f3a->gpio_key_map[0]); + input->keycodemax = f3a->gpio_count; + + if (pdata->gpio_data.buttonpad || (button - BTN_LEFT == 1)) + __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); + + return 0; +} + +static int rmi_f3a_initialize(struct rmi_function *fn, struct f3a_data *f3a) +{ + u8 query1[RMI_F3A_MAX_REG_SIZE]; + u8 ctrl1[RMI_F3A_MAX_REG_SIZE]; + u8 buf; + int error; + + error = rmi_read(fn->rmi_dev, fn->fd.query_base_addr, &buf); + if (error < 0) { + dev_err(&fn->dev, "Failed to read general info register: %d\n", + error); + return -ENODEV; + } + + f3a->gpio_count = buf & RMI_F3A_GPIO_COUNT; + f3a->register_count = DIV_ROUND_UP(f3a->gpio_count, 8); + + /* Query1 -> gpio exist */ + error = rmi_read_block(fn->rmi_dev, fn->fd.query_base_addr + 1, + query1, f3a->register_count); + if (error) { + dev_err(&fn->dev, "Failed to read query1 register\n"); + return error; + } + + /* Ctrl1 -> gpio direction */ + error = rmi_read_block(fn->rmi_dev, fn->fd.control_base_addr + 1, + ctrl1, f3a->register_count); + if (error) { + dev_err(&fn->dev, "Failed to read control1 register\n"); + return error; + } + + error = rmi_f3a_map_gpios(fn, f3a, query1, ctrl1); + if (error) + return error; + return 0; +} + +static int rmi_f3a_probe(struct rmi_function *fn) +{ + struct rmi_device *rmi_dev = fn->rmi_dev; + struct rmi_driver_data *drv_data = dev_get_drvdata(&rmi_dev->dev); + struct f3a_data *f3a; + int error; + + if (!drv_data->input) { + dev_info(&fn->dev, "F3A: no input device found, ignoring\n"); + return -ENXIO; + } + + f3a = devm_kzalloc(&fn->dev, sizeof(*f3a), GFP_KERNEL); + if (!f3a) + return -ENOMEM; + + f3a->input = drv_data->input; + + error = rmi_f3a_initialize(fn, f3a); + if (error) + return error; + + dev_set_drvdata(&fn->dev, f3a); + return 0; +} + +struct rmi_function_handler rmi_f3a_handler = { + .driver = { + .name = "rmi4_f3a", + }, + .func = 0x3a, + .probe = rmi_f3a_probe, + .config = rmi_f3a_config, + .attention = rmi_f3a_attention, +};