From patchwork Tue Jul 12 18:18:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915385 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 200D1C433EF for ; Tue, 12 Jul 2022 18:19:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232790AbiGLSTT (ORCPT ); Tue, 12 Jul 2022 14:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233368AbiGLSTR (ORCPT ); Tue, 12 Jul 2022 14:19:17 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ED6EA2E79 for ; Tue, 12 Jul 2022 11:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ABgZ93drVOhzhVzwMQt8Jw7oELbjIvyPCxGn2Xm7f79HuAvqwDK6p2ivC89BkZ6Ffqo9nPxsz8ryYJP/ybfLamg7DluK1ybopt7QUDaI3UC3Zn06tM8PS3EY+YMgaLzPt4GmmUANHraiL9b8z5Rkm3BKEZMQ1ea7TkAQ26pTc9D4kIPV98AIVIg9Ga+IQdsmtGeZZ4DNSf7nEXE7un6cAuMgAdEwUUTJHhdOU6YVGBIax/jooUEBY5qzi70tMRAjdIt8Xkke1u7b+8N1WFDKstCSmfE9zKjXhT7rPp3gOK1WZ3HixE4c1VQwxVIjxJcOWrmdAHpxU8ZevgzkYJYrBg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hj4iwjIhpnyPGk2wFKhYxIl/5/iCSGC5XWvMqPpx3TA=; b=ZCD1sm0q3qObcWMY14cvhmc8SMKQiJP/P0gX+s763yBD94FYAuepyvsZxpwlgl9siQJlYTaqodlZ/KR9ROU9BLVrHWP9aXv41Zct0nza+cCh218c7WOS2R5H2uithrkGWzo4G9x3Aunc6ppmoaZzT26oCk177IST0FIvoDHamcnrJoaalnCPxZAetFD6AS9AIvvY2HhV59VhS8z210CcubrRpaYEQCwwY3O0rPiffBpff/RcZilNeNLek/mwroo7/yOD0/rjWSKft1ia0Z1tkQ5DKUvAnPUtaBD8i1tfzMS478glo7vZb6NllSasfgrDjc/BGu5TbTfRp5zxJOa5EQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hj4iwjIhpnyPGk2wFKhYxIl/5/iCSGC5XWvMqPpx3TA=; b=rrfICNeC0xSJG5RYlNwBKhQGaGY6uFGq1IfT15DoEcesVQT3wSLw0Yzxvyp561RUzbIEBbsSBfP1GxdfjMnkW1Aqv2yngKHW5cWwf1NkCBUGLQZwmgX9d6E9kGa5Qgh3xPC/RuNvKLGUVJsQANMLnubb4LKnbtScUP8ISnGQt9M= Received: from DM6PR02CA0051.namprd02.prod.outlook.com (2603:10b6:5:177::28) by PH7PR12MB5903.namprd12.prod.outlook.com (2603:10b6:510:1d7::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.26; Tue, 12 Jul 2022 18:19:13 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:5:177:cafe::53) by DM6PR02CA0051.outlook.office365.com (2603:10b6:5:177::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.25 via Frontend Transport; Tue, 12 Jul 2022 18:19:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:12 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:10 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 01/11] HID: amd_sfh: Add NULL check for hid device Date: Tue, 12 Jul 2022 23:48:26 +0530 Message-ID: <20220712181836.3488343-2-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 51af9925-50bf-4ae1-12b1-08da643305b6 X-MS-TrafficTypeDiagnostic: PH7PR12MB5903:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hlSjhll8eCWV7X77daatOHNZzOoNEEo7xO8u8eNy3ok3ePVJ1XxFnILIcYoF25dr0NC9Sy+DYsag6fQXumab9JmSazb6vknZtLy4EFDtbvsx8l9erStAXrbKHvGXeIjK3DiT7vZFyqNUJd5j+McvtJrNNbdTSFByes01+Se0dHpGEHyK6A8P4vW4mzweDjragHMpVekSvhRiazXem85Dz6HxlE0wxT4MVQtddGYoK88P66CNVu17nBPirWLPHqBb/7hz9bOT0gt7td36l6O0ch59X1j09O/qsKHUQa1LeJjMQH50uBx5LR+ilsJSb3lG8DyW5j3qZhNRFdLD/uB1dwnAg6hBTR4SGCicqpXR2oor2zXyrQpZMtLTGyIn6Ymxnl7QHeXfkh9AA1hv6N9uBvxASMbqNNHRf5eXGfUfSYqAtMJPpGCGLvdfAQrlJdhREfUZ5hGbT3ciLBidDKxfO6V2wz3oIDT3tUNfqGbNXSAl7Xxdh1oMyQU7UePj7x9kCAzcQKyJ2upxHP0awaj9/d+jRRZx6LKU62jdEqxu4iGrJ84CGDkw7wqQ2WlNz+Q1kzDcKYHPFveq0X+Im/KC7cOKI0aQO7a4fiVmj5ChyakfzB+2+q5LPK5XfRBXAcpN+ZWaACCKSwuxrls8/4HVrPR8agJzyckQF+EwrqzRpirAEIv0CnIknAACWymWPh906E3Kdjlu3RbJzv0L348x2yp0JPSuPl9qbSWTeHqWgGtc7NGY6Ly94XsauaRUni93kmK5/+Is8MGWGMMhjjWsO98GTreRUJspRGN0/pd3g/MOirlm/YIWInzw+pMB3o2ClP67pE/EAH9Xru4rvZ9mznlni1e/Y2UIufeSnYm65Z0= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(396003)(39860400002)(346002)(136003)(376002)(46966006)(36840700001)(40470700004)(40480700001)(83380400001)(426003)(1076003)(336012)(47076005)(70586007)(4326008)(186003)(2616005)(8676002)(86362001)(82740400003)(70206006)(16526019)(8936002)(36860700001)(26005)(82310400005)(7696005)(5660300002)(40460700003)(356005)(81166007)(2906002)(110136005)(41300700001)(478600001)(6666004)(36756003)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:12.7180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 51af9925-50bf-4ae1-12b1-08da643305b6 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5903 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On removal of hid device during SFH set report may cause NULL pointer exception. Hence add NULL check for hid device before accessing. Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)") Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_hid.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c index 1089134030b0..1b18291fc5af 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.c @@ -101,11 +101,15 @@ static int amdtp_wait_for_response(struct hid_device *hid) void amdtp_hid_wakeup(struct hid_device *hid) { - struct amdtp_hid_data *hid_data = hid->driver_data; - struct amdtp_cl_data *cli_data = hid_data->cli_data; + struct amdtp_hid_data *hid_data; + struct amdtp_cl_data *cli_data; - cli_data->request_done[cli_data->cur_hid_dev] = true; - wake_up_interruptible(&hid_data->hid_wait); + if (hid) { + hid_data = hid->driver_data; + cli_data = hid_data->cli_data; + cli_data->request_done[cli_data->cur_hid_dev] = true; + wake_up_interruptible(&hid_data->hid_wait); + } } static struct hid_ll_driver amdtp_hid_ll_driver = { From patchwork Tue Jul 12 18:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915386 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0ADC7C43334 for ; Tue, 12 Jul 2022 18:19:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232632AbiGLSTV (ORCPT ); Tue, 12 Jul 2022 14:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233396AbiGLSTS (ORCPT ); Tue, 12 Jul 2022 14:19:18 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2082.outbound.protection.outlook.com [40.107.101.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53E3CBB7F7 for ; Tue, 12 Jul 2022 11:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YTtlhi8X8gVfca9Z145022e9ZmXuCjvVRhezgwaoqRQ8aB+ye2PEmNztPENOiaTBMXJW6Bjg2iGOsrkL9PJoztmuDFPuflZQPYGWOL24Kbqehl11QP6t+Kj4kA1jQaEIch1XSvvbfpAWo6P+k4x/nrkVBSzKK8kwR/ZAdp30b4mqLXsEjIDHgNQmZUDgBrOAWsceWLb+RFcLWvS6ysvCNUe1yvcqglraH3C04bS94R1vEu/aB6Os1lXSxhZF3M9RvL8oMu/TfBgkzuK8232tdMPvHuFEWU7kFEWDotVwHpI1LniaEYXcY5t+TgcAnhz/Y8ou70FhSBbK24IKOj5qyw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=odoEKLTVIhkGa0bg3WhTeqbOJILLHOAjfNu8pWc6Ta8=; b=FF3DD3McLDbI/tcgZi1pYs+guDNV+yXE3tmZxqD7uobqhceWEvVcpQVlFBJPk2t89JzIUNEQPxk+iEwTVOpKWhsrdYPMM0cE5FAB0WhsvWTF5nzniQCnes3DZoL4NVPKKdz6gUydmPueCrPhz7j54lnr2LGSBu/XFD0SHzv/AUci4hQ7TteQ3Wd1wQdm9FsRy1A+UpeOxSAGzPtgPL/S5Ul8lW0MvW1pZlkzDRYHW3XFqaCB25oh4g4jQoVvS0sDv+bvo1Lv8bwcvZyxi4YoxgcEleYB4nRxopyphLUJbe7WSZvZSpxTV7SQbIKcDU7mrHuwxowhJ1tUk/T97bwOAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=odoEKLTVIhkGa0bg3WhTeqbOJILLHOAjfNu8pWc6Ta8=; b=ajjFwBeVmO2cR0dQc65TeBD2MIEVAMcMiu34wvDuzHETD9MRcmFgYmvrwe224B1fuqwc91p9Egb8F+aYUmWlv18oqIfSovWF2HMqJoXHwRgHPxAaUuu3Soy2JcK8rvhskE5y1D4oxpv+frLROXZqyO0Z1+e7Ri2NOV834/c8gwM= Received: from DS7PR05CA0014.namprd05.prod.outlook.com (2603:10b6:5:3b9::19) by LV2PR12MB5752.namprd12.prod.outlook.com (2603:10b6:408:14d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.26; Tue, 12 Jul 2022 18:19:14 +0000 Received: from DM6NAM11FT033.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b9:cafe::24) by DS7PR05CA0014.outlook.office365.com (2603:10b6:5:3b9::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5438.11 via Frontend Transport; Tue, 12 Jul 2022 18:19:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT033.mail.protection.outlook.com (10.13.172.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:14 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:12 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 02/11] HID: amd_sfh: Move common macros and structures Date: Tue, 12 Jul 2022 23:48:27 +0530 Message-ID: <20220712181836.3488343-3-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4009555f-abbc-45d7-cb41-08da643306be X-MS-TrafficTypeDiagnostic: LV2PR12MB5752:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qWcR1osceqGLAJG+fshcFMX+SkuiJYlKFIKeevr1KgI2r6sUBHmFuBVWNHP8JhcmrPUJUSX2oaY+j0BeQrkZEN2BjK6wFT+rtA6PqlnXrVy0NVnZ2Zerr7I2/3eRYRQlgfdpRFyoN+JGHsjKwVVIDZE2qrHei3WyN+0hzsA0mgBJ/9yGFWnlGYjUXtTMWUvkCzOtqF+KaVVMd5R4Xl6YOwraUdeh/6aHhMWp5U1y3x5xEABIa2PmWsDR2SKSnFTSkGANNKD0RABA2Xs4j6xoZlwaMQB542YQ1PKhggiDQZPguM9sokVNijfy5jgNUTfpQjcRROwpzwNSa7QYqg5opyQ7sDUqg1Lr6NaAlQZAI6gFRSDhbMZmCI+8oby8xi/foJ/G9EIZZjD84o18kqTrvpIFcUx/bE3XBWBGNEyUdHYaUOY13q6ErlFd1eYeDX5HCGDWLyzA8u3k3NSASE0TGJbGc70yKVBoxVb1kBVoDG7C4jvYmfGpj02nTBxq9YaVMQsY0r7bS7By5YyOMq/xasCSV77cXWIad2GEX22YnRizMuVv9iXxUgLcm7mDSJJPfI5BVoEG6lbPWHoTrrVccf9Xp9p1TZa51RO2Er7KUieWrIH7DlDoDDmrwmKCZLhoB9v+bbknYtYNU/1qaqGgOcvqvVLNSf9sJbWdNVwdGBi+fTMNY5cXSUPupgFlmVDmpV05m47QK5J/slIKcDrqlRacIr1YP9fHlw34LGcOEwcCwsUADtcS/SF7x+Wekfhz6wpb5u1UfAk/6pTbyFKys2BDKwrQZSNa/KBLCvSA6q7TSSE/eUnQ49xa6WMVcVhcd2UZgnv54wd93yZskZutNYYxCVUpzIEuwtHYQker0Fs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(346002)(136003)(39860400002)(46966006)(36840700001)(40470700004)(81166007)(2616005)(356005)(426003)(8676002)(36860700001)(16526019)(4326008)(82740400003)(40460700003)(83380400001)(336012)(5660300002)(70586007)(47076005)(186003)(8936002)(70206006)(82310400005)(1076003)(41300700001)(40480700001)(6666004)(110136005)(36756003)(26005)(478600001)(316002)(86362001)(2906002)(7696005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:14.4529 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4009555f-abbc-45d7-cb41-08da643306be X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT033.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5752 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Introduce common macros and structures to support multiple generations of AMD SOCs, move them to amd_sfh_common.h. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 59 ++++++++++++++++++++++++ drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 42 +---------------- 2 files changed, 60 insertions(+), 41 deletions(-) create mode 100644 drivers/hid/amd-sfh-hid/amd_sfh_common.h diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h new file mode 100644 index 000000000000..40da53d5efd0 --- /dev/null +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * AMD MP2 common macros and structures + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Basavaraj Natikar + */ +#ifndef AMD_SFH_COMMON_H +#define AMD_SFH_COMMON_H + +#include +#include "amd_sfh_hid.h" + +#define PCI_DEVICE_ID_AMD_MP2 0x15E4 + +#define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4)) +#define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4)) + +#define SENSOR_ENABLED 4 +#define SENSOR_DISABLED 5 + +#define AMD_SFH_IDLE_LOOP 200 + +enum cmd_id { + NO_OP, + ENABLE_SENSOR, + DISABLE_SENSOR, + STOP_ALL_SENSORS = 8, +}; + +struct amd_mp2_sensor_info { + u8 sensor_idx; + u32 period; + dma_addr_t dma_address; +}; + +struct amd_mp2_dev { + struct pci_dev *pdev; + struct amdtp_cl_data *cl_data; + void __iomem *mmio; + const struct amd_mp2_ops *mp2_ops; + struct amd_input_data in_data; + /* mp2 active control status */ + u32 mp2_acs; +}; + +struct amd_mp2_ops { + void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info); + void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx); + void (*stop_all)(struct amd_mp2_dev *privdata); + int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); + void (*clear_intr)(struct amd_mp2_dev *privdata); + int (*init_intr)(struct amd_mp2_dev *privdata); + int (*discovery_status)(struct amd_mp2_dev *privdata); +}; + +#endif diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 8c760526132a..2feac14f5d3c 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -10,35 +10,20 @@ #ifndef PCIE_MP2_AMD_H #define PCIE_MP2_AMD_H -#include -#include "amd_sfh_hid.h" - -#define PCI_DEVICE_ID_AMD_MP2 0x15E4 - -#define ENABLE_SENSOR 1 -#define DISABLE_SENSOR 2 -#define STOP_ALL_SENSORS 8 +#include "amd_sfh_common.h" /* MP2 C2P Message Registers */ #define AMD_C2P_MSG0 0x10500 #define AMD_C2P_MSG1 0x10504 #define AMD_C2P_MSG2 0x10508 -#define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4)) -#define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4)) - /* MP2 P2C Message Registers */ #define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */ #define V2_STATUS 0x2 -#define SENSOR_ENABLED 4 -#define SENSOR_DISABLED 5 - #define HPD_IDX 16 -#define AMD_SFH_IDLE_LOOP 200 - #define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3) #define SENSOR_DISCOVERY_STATUS_SHIFT 3 @@ -96,22 +81,6 @@ enum sensor_idx { als_idx = 19 }; -struct amd_mp2_dev { - struct pci_dev *pdev; - struct amdtp_cl_data *cl_data; - void __iomem *mmio; - const struct amd_mp2_ops *mp2_ops; - struct amd_input_data in_data; - /* mp2 active control status */ - u32 mp2_acs; -}; - -struct amd_mp2_sensor_info { - u8 sensor_idx; - u32 period; - dma_addr_t dma_address; -}; - enum mem_use_type { USE_DRAM, USE_C2P_REG, @@ -140,13 +109,4 @@ void amd_mp2_suspend(struct amd_mp2_dev *mp2); void amd_mp2_resume(struct amd_mp2_dev *mp2); const char *get_sensor_name(int idx); -struct amd_mp2_ops { - void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info); - void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx); - void (*stop_all)(struct amd_mp2_dev *privdata); - int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); - void (*clear_intr)(struct amd_mp2_dev *privdata); - int (*init_intr)(struct amd_mp2_dev *privdata); - int (*discovery_status)(struct amd_mp2_dev *privdata); -}; #endif From patchwork Tue Jul 12 18:18:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915387 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D965AC43334 for ; Tue, 12 Jul 2022 18:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229652AbiGLSTX (ORCPT ); Tue, 12 Jul 2022 14:19:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233200AbiGLSTT (ORCPT ); Tue, 12 Jul 2022 14:19:19 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2047.outbound.protection.outlook.com [40.107.220.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EA27A0273 for ; Tue, 12 Jul 2022 11:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FGm40E7JpBFrl69htLRygh+9V14dt1RfxLI/Bn7PSIHWXvRpP3hkcN6HRzrVdPDLP08RtOJclnKdlmoyfZF3ZyhzkNCEJoMp3vj6MR+mqllTy3KB1EDtC8njSYkFf/DtEf6oty6YKRKJpaTzHlcdL4x+/yNA2APBBtvGCfnjRKJkbV+A0wC3SQtjBS87AYW62pw6ge1VL+YMhLFtq4fM2pD+p0qxk7Sp4/S7eFk/WNMt494bN6ETIivmz93aXqW8KABiZf7/TWeRywlpYTwylPRFt0l4icY1n7/SdYkoZmteeBCdSrRyoqYJ4sdqfMww5mwkg+qiic7wMDEAiWa7Fg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=j+4OPzPgIzLnp2MClkySHx9S4VsOU1KlfZcTVNSSnvg=; b=cCyAZf97Ib/fSgtRG6Pw7ZWybKE/hcrwqRm96ARdtA+chb6o9+A1qdh3j+oYAeDpIo45DVSuMwNOh+uktB6p1uqKVq8tu9JAZGPj3QROJHfoc/SmelkeCz2UbYzgKP7OivxRZ+P/1FJXlWjgDoez7w5hNGhwgx0WX35T39X/EeteplTTHWR7LCLriLbeg4ETgzmevug/bdYec7F9WFP3ZmAM2jfkFmJy52wNFc6Nu6nRhPSoC8x+45QWrFro/jPQSVzeOurFJs3xhEmurdqkozuphiNql9MOEXZ+SGxLtU4owImJLkeU7PO6cJFqRGcZoLHohR7nzcjtQTJgBAodrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=j+4OPzPgIzLnp2MClkySHx9S4VsOU1KlfZcTVNSSnvg=; b=QAJLIcpL7o5gR/oH4ecNCYm29tO0Gx85SrqB/XOKgxbTVL/yMJrSkgbhYjUdl3JloQaa4rVUdiyuYaspr4irjepeEjmlQ20P2FCkx+oijqTaan8xex5vVrRT/VpMNnJluRlR61xx1KjtIdiMZrEJf8ftnrVD+4wAa2yy4+xkKTk= Received: from DS7PR03CA0115.namprd03.prod.outlook.com (2603:10b6:5:3b7::30) by BY5PR12MB4179.namprd12.prod.outlook.com (2603:10b6:a03:211::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16; Tue, 12 Jul 2022 18:19:16 +0000 Received: from DM6NAM11FT025.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::1d) by DS7PR03CA0115.outlook.office365.com (2603:10b6:5:3b7::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.21 via Frontend Transport; Tue, 12 Jul 2022 18:19:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT025.mail.protection.outlook.com (10.13.172.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5438.12 via Frontend Transport; Tue, 12 Jul 2022 18:19:16 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:14 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 03/11] HID: amd_sfh: Move request_list struct to header file Date: Tue, 12 Jul 2022 23:48:28 +0530 Message-ID: <20220712181836.3488343-4-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05c5cc8e-e178-4798-7284-08da643307b8 X-MS-TrafficTypeDiagnostic: BY5PR12MB4179:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jzYJ2Kq8q94eP8u0ekObrqoYb2U9L5aAXOFTDxLOMZm1Ld8qUSOa6OMlc4q1UbAgMqqfwBFUcw3lpv/FoDkXskJgw9web9OaeHNJLqVAs6HK1e1xF8Y9St/iKAJd6rnpBFv37PZp4/MfYY140rJ0KSQ6RjX+6kn9otT9Ebpfh3equN4J3g7XQaFrkhTdr2iD72VcoqaqnIy/U9iB4mUqXbE9GPOxidH2ViQ9Fv5RwR4J34YfHMRvvT2kr5pToIHSYn0+/gQOP8pZq2F5UagQFRCjpMAS75KVIALM2DgtHtY+j14r2LAEcLDTOulo6s/OVLmnp5EbNcI0vRfvF7XqWXm3SwBmZyOTovtKuagA4afI1cq99IY9z4kh28Ko3zsM59pXDpAktNdN0U7UJIBfxrR/+BKo6rL3lEdhKokzCnIR3OhOSRdPC0oHZb1UM1L88CT6tBDI5Tl4njFSHxoLRtavGTOJ9t1PB3Q9RE2i7S7a2rQ/KfTkgfacENuLO7WZN5CPHaSbwG4YShhBkwoXoRiliP8KM8ZCp+edB5gr0I5D4ioc9I9Wxho/zyppRE4NuXWT+YQ4pgIaBV3ISTKKsDM4eW21Qy4LUN9Uq9cC2xcHbnQC1DRk0LX30N/KXp5rpoA+XpAd7XlT/pzyTSEDn+P3n2Sco4tIcjv2Y06liNNxAMxYavC8QHGeT0/CG+MyRNv92KHSwPh+tZ+CZaNFZ1hiyEh2EfxpCFZaHlMoyxrlRadY3+miQQca6lMxJ2cmzM1FDFaEJT3afqpRkEy8Z/ThIIzR3bPSIdY6b+cCo0pkzyR1ZOiToncj5Lg9O2P5QWjYiZyIKwH/xPPnOA9wTgj4aeFqohAASxbO43o6PSo= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(396003)(39860400002)(136003)(376002)(346002)(46966006)(36840700001)(40470700004)(81166007)(336012)(426003)(82740400003)(83380400001)(70206006)(40460700003)(186003)(36860700001)(16526019)(356005)(2616005)(8936002)(1076003)(47076005)(4326008)(70586007)(5660300002)(8676002)(40480700001)(2906002)(41300700001)(82310400005)(7696005)(478600001)(26005)(316002)(110136005)(36756003)(86362001)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:16.1047 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05c5cc8e-e178-4798-7284-08da643307b8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT025.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4179 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org request_list structure can be used in multiple files to support all AMD SOCs. Hence move request_list structure to header file. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 10 ---------- drivers/hid/amd-sfh-hid/amd_sfh_hid.h | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index 0f770a2b47ff..fac9e8a66120 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -18,16 +18,6 @@ #include "amd_sfh_pcie.h" #include "amd_sfh_hid.h" - -struct request_list { - struct hid_device *hid; - struct list_head list; - u8 report_id; - u8 sensor_idx; - u8 report_type; - u8 current_index; -}; - static struct request_list req_list; void amd_sfh_set_report(struct hid_device *hid, int report_id, diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h index ad264db63180..e2e4cc5fc946 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h @@ -15,6 +15,15 @@ #define AMD_SFH_HID_VENDOR 0x1022 #define AMD_SFH_HID_PRODUCT 0x0001 +struct request_list { + struct hid_device *hid; + struct list_head list; + u8 report_id; + u8 sensor_idx; + u8 report_type; + u8 current_index; +}; + struct amd_input_data { u32 *sensor_virt_addr[MAX_HID_DEVICES]; u8 *input_report[MAX_HID_DEVICES]; From patchwork Tue Jul 12 18:18:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915388 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E27A2CCA483 for ; Tue, 12 Jul 2022 18:19:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233220AbiGLSTW (ORCPT ); Tue, 12 Jul 2022 14:19:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbiGLSTV (ORCPT ); Tue, 12 Jul 2022 14:19:21 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2063.outbound.protection.outlook.com [40.107.244.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F4DDA2E79 for ; Tue, 12 Jul 2022 11:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DDPt3VW1USXjwlO+A0RrMhW5/VjhXvCRKZdpuJcOmV9t08kZbMoYV57079qPEThOei9em/AaIWIzBusXKDV5ty2uC9exNqY3rC7TTkc5JQz8zdyK2dVQu5dQamdhvUhL6o+gDCPLXBCyGKiDy9XYaIhhT3zXbpbfysn3cJiYCkBNg0jpSKeGqK6Tg3DqXht5fEm82NGCNMum/hVmRrgCKcsgWRRMmZ+ZTJgdOWIZD9DU0ob5z8vLzQzXaeg7zgYZJSVpn8OOMq1G8phkN2NLIUrl5QZSCs09d9ahu/8/WNYE5FwC04Ajz0XpvebqUSyY41+jiXk1kL+2O+TM/nrNuA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l4GFrud1kQtralifIha/Qxe0E5KaSBi1R0h9zKu5Jmg=; b=U0CIeIV7Lmqd0Zx5nkh61DPc8ZucxxFoH6B/OVrYIHA5IAZjpStV+uYjQnmD5jBJeGpOvjFA/psN841p0T9f97UtKyp/Vks/F2PKhXUdj+oY8wR6Vrdn/GTf3GluRkDJ8G0KrWk/P1SMYoFfgLcPAIWLoyNSgVjYd0GRgdOwB9xr2T+255IPpUbn7IexbP9Y7x8OhrbosEfDNw3Zjs08MWYgkE6+q3HrvUzw7OJSCbu+j/w7EGMhy/Gxwh0FTPCpgOgnTghRUUar+6eqGOCJ8q+C21NUVqJSMpdcFCiOmChn1BB0vFdQLhaA8F5r+RwCSmEbiO61rcP6VGqdZi38AA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=l4GFrud1kQtralifIha/Qxe0E5KaSBi1R0h9zKu5Jmg=; b=te14XCYGpoV9so0+ziblKqAU2nl7bHfuVmlULfTn4no6kNDdT484dN4WkxSlQXeko3jL+n0X+4Z0mIKA58y76AAKf9NfM9jO24Z3q2FHQqXJXoTxbrGui5ykobR4hSc9sljmRTnkX33LYt+PAHoYcO0vFHWZwGjJq0qgb5I34Rw= Received: from DM5PR08CA0028.namprd08.prod.outlook.com (2603:10b6:4:60::17) by MN2PR12MB3869.namprd12.prod.outlook.com (2603:10b6:208:16f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.25; Tue, 12 Jul 2022 18:19:18 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:4:60:cafe::b) by DM5PR08CA0028.outlook.office365.com (2603:10b6:4:60::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16 via Frontend Transport; Tue, 12 Jul 2022 18:19:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:17 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:15 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 04/11] HID: amd_sfh: Move request_list variable to client data Date: Tue, 12 Jul 2022 23:48:29 +0530 Message-ID: <20220712181836.3488343-5-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bbee227-7cab-4c78-acb0-08da643308c7 X-MS-TrafficTypeDiagnostic: MN2PR12MB3869:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kN24pBrnZkAeydq1Ma7kZDYfZ0+st+hMdaTyPe59pkNQtPhkJaDef3x21AqHulBnCPdTWvcta4CQwjRsz7D7IN18NGRfX8XDsO+D+1pFOlJ+wToTA1KXE51TzF0p6vuR4Bc7kKePRE2ybSg7znJfVNAXimje6VtMhxXAjcazbbN8zFOwjyW3lDJCW947Ai42iEFYDMT+mrZw4zA5/6nZ1rfh91mLJCzk5CD9uyisvQ5mNllce755YD6u3wt5LjH/CWk2MBnhLUIlonkwrbUMmUesMOaDpZeC4Ps2RAjcq2CiILiUhd+KLM95/gQZQ6fOffJl70u9aEcViHvWowsddzLWYCOwGXo93n8OGWHSYaXa9cZXztyYttKpispKUttgYotKlXJZlErarTdW4rxPFR0C6cmtdb0yNZKWwDuCIDYw9u1E4LL9R1YhaDzQ87DHGpql7JxjHAh09YMoXJfhfxUU8fQOOlMzhqi2E1GR/E4hh//klPSZS6MBDX8EdV/0La0MRVx9oola/zizMfgaW9H11gJEpymOAzl8FRg7yCMZphfJvPZ7jDpbN/BXLdc3Z0b13tGCiu8DRFouI1pF4l34gjTGAeJsp6pSCD3FepevCz0merIUNhhg/tlpvQfjVFWKC40vfYcmWEUZ7yrlqK5AsGUrlHxMTbFWgmXLm38VUl9Jd4JyyBUJQEnJkPbV6HTc6sMsZ9kZyVX8tCKNRYRieeuJsqsKWv1/3f93AJpJrTvnEqXk33inHjrJU4fqrnAxrtaNxvZZHNuQfotxHGtPEmEQwk+VR3iMaVPkqf8J0A2SVyhma/lKjhrE0wTqplgQcWD2OtTzuWrZ/XTp3qa+aaEntKo1rBJwU7Nz9CM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(136003)(376002)(396003)(346002)(46966006)(36840700001)(40470700004)(426003)(81166007)(41300700001)(82740400003)(47076005)(6666004)(2906002)(336012)(356005)(4326008)(16526019)(7696005)(2616005)(82310400005)(26005)(186003)(1076003)(70586007)(86362001)(70206006)(40460700003)(36860700001)(8676002)(8936002)(316002)(83380400001)(40480700001)(5660300002)(36756003)(478600001)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:17.8666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bbee227-7cab-4c78-acb0-08da643308c7 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB3869 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org request_list variable can be used in multiple files to support all AMD SOCs. Hence move request_list variable to client data. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 12 +++++++----- drivers/hid/amd-sfh-hid/amd_sfh_hid.h | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index fac9e8a66120..e3b3db514c91 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -18,8 +18,6 @@ #include "amd_sfh_pcie.h" #include "amd_sfh_hid.h" -static struct request_list req_list; - void amd_sfh_set_report(struct hid_device *hid, int report_id, int report_type) { @@ -40,6 +38,7 @@ int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type) { struct amdtp_hid_data *hid_data = hid->driver_data; struct amdtp_cl_data *cli_data = hid_data->cli_data; + struct request_list *req_list = &cli_data->req_list; int i; for (i = 0; i < cli_data->num_hid_devices; i++) { @@ -56,7 +55,7 @@ int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type) new->report_id = report_id; cli_data->report_id[i] = report_id; cli_data->request_done[i] = false; - list_add(&new->list, &req_list.list); + list_add(&new->list, &req_list->list); break; } } @@ -67,13 +66,14 @@ int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type) static void amd_sfh_work(struct work_struct *work) { struct amdtp_cl_data *cli_data = container_of(work, struct amdtp_cl_data, work.work); + struct request_list *req_list = &cli_data->req_list; struct amd_input_data *in_data = cli_data->in_data; struct request_list *req_node; u8 current_index, sensor_index; u8 report_id, node_type; u8 report_size = 0; - req_node = list_last_entry(&req_list.list, struct request_list, list); + req_node = list_last_entry(&req_list->list, struct request_list, list); list_del(&req_node->list); current_index = req_node->current_index; sensor_index = req_node->sensor_idx; @@ -154,19 +154,21 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) struct amd_input_data *in_data = &privdata->in_data; struct amdtp_cl_data *cl_data = privdata->cl_data; struct amd_mp2_sensor_info info; + struct request_list *req_list; struct device *dev; u32 feature_report_size; u32 input_report_size; int rc, i, status; u8 cl_idx; + req_list = &cl_data->req_list; dev = &privdata->pdev->dev; cl_data->num_hid_devices = amd_mp2_get_sensor_num(privdata, &cl_data->sensor_idx[0]); INIT_DELAYED_WORK(&cl_data->work, amd_sfh_work); INIT_DELAYED_WORK(&cl_data->work_buffer, amd_sfh_work_buffer); - INIT_LIST_HEAD(&req_list.list); + INIT_LIST_HEAD(&req_list->list); cl_data->in_data = in_data; for (i = 0; i < cl_data->num_hid_devices; i++) { diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h index e2e4cc5fc946..ecdd2f48cfb8 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h @@ -52,6 +52,7 @@ struct amdtp_cl_data { struct amd_input_data *in_data; struct delayed_work work; struct delayed_work work_buffer; + struct request_list req_list; }; /** From patchwork Tue Jul 12 18:18:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915391 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58F12C43334 for ; Tue, 12 Jul 2022 18:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233032AbiGLSTh (ORCPT ); Tue, 12 Jul 2022 14:19:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233396AbiGLST2 (ORCPT ); Tue, 12 Jul 2022 14:19:28 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5A55D0862 for ; Tue, 12 Jul 2022 11:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SxOJMadSEjIoI2Hh49woUE5qqY7umZJXHzBtrGx5Xv5+HRLfE8xXaf2uNjWwNnWd2EWPcmOJZmK0GbkP3rPl+ejwdXoa4AJjagu9/mWjmZwhyKQF4Fhh/8VBsm6iLTYG+FCyt0uh+vf/DmMLMBev/w0QtabMeN+ocTr/IOP6n79Va3TPfHZbJZ41CV+g+VaJhlaB+hbFQyGR/a7OpnaYT7Y1wZWA57Z/gnNict0JLwcDKzliiszd2mLPSdGjH6DDpNuBe0SCtJxnh2IM4wykhp6QRp1EPyoVjJswnt9h8NJx0b5Dj9nHNVqqzQC2pJ59f38SERrHx96RFfqMvLKAqw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aZqHH/DAyaE5dTgo8HjiC0gUD2NSCesj0yf+rc3U+Fw=; b=gAzpVTbTgz2x0CvFngLiS5xbuHdj4fwOqCBbvMVu60I+g220gGF9BGYDRKygrgiblM3C6Qc4/9C3zGVEoAKhRLHlBgrmIeY16qaZa5/uP/ot0+NTd0BERES832n9hXZNa0VmoCboJdJduwto1iBFzgyH8YYkCoP147xe46pvY/LcSuamLw81rqDXuc7l3AGFKf4S/YERmO4f1/pw9v2/1toVY/qElY4pIw8YgrJNZsE2JVf7mR/y/U/y4oVyF2bNJ/jcDfiOjTwL2qCc2k0ElECpY2MdoJDiPO5ZIv0QK7caMVhikFp5BFt0hDQX/9O87Kze92qz6XsU6rLF7XGiuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aZqHH/DAyaE5dTgo8HjiC0gUD2NSCesj0yf+rc3U+Fw=; b=WBzM7AB418kys3Vr4lSyo7lKQ8NYYm5Jh2opENWywR6G92WJ4Z1Gy1Hx1GGd5CXwzuPGoRwpFfChr3UzAIr/u6WnO2jtpgy5YNnHid59+3Fc9RvyfwWRKAlHwLC4MBxboRB+nimzDuwlAbeFCBCcByqr7RxI0NXUKZ0wxHUTIpc= Received: from DM5PR08CA0059.namprd08.prod.outlook.com (2603:10b6:4:60::48) by DM6PR12MB2860.namprd12.prod.outlook.com (2603:10b6:5:186::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Tue, 12 Jul 2022 18:19:19 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:4:60:cafe::cb) by DM5PR08CA0059.outlook.office365.com (2603:10b6:4:60::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.17 via Frontend Transport; Tue, 12 Jul 2022 18:19:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:19 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:17 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 05/11] HID: amd_sfh: Add descriptor operations in amd_mp2_ops Date: Tue, 12 Jul 2022 23:48:30 +0530 Message-ID: <20220712181836.3488343-6-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c8e29678-6340-47c4-ad43-08da643309f1 X-MS-TrafficTypeDiagnostic: DM6PR12MB2860:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PSjwBWxA/7pW0s7MURRaEo3ZDMp9cEWrBnMKV98XrRg0zBElr3iCED6sUzciVVoPgEgRWwYU84v+RWeJaJRvg3zmI3jxR3LZk6neqb6UKCwHkME8FFBTNzJAes8wn7cCybCmi7aLBxidmZJcwrIiBStkgVbyUhk53uZ2m9MnQKz3HvbsshJYpDKscozcnwOFM6rVkt0Nk9+hov9ABTOCDgE7f0PPmW0IdNcUAwGdKhJDMDEHU81AJtvxeylpUky/cXCSE/RmcCJRkd/RrCOM7jgHK/EnDdGNLk337kYlzy9rcldhuEVZn8xP/AZunEskL8yn88lhT6CeTI/DtntTDDCZqiS7SouKnmhoideXPfk++PBmX4oe8Q6BvKX/PtkSwuA3WHpSnkSqHlD+YAAJr0wA0bDRF82k6hDnQLbslcLCpEUSYvajSn4wfobYMwPLGqFv5/h3NrCTMcgCHgZHX8feHfHwDgF0O7kgIStESjinJCjb7zzPk07CLgbTDwMXCfA+DY6AkU/BDeSQHJDKjUTDZ0Qk9C/UkNVdbBpdVtHt08V4c9cQge5Llpv/BdX9oTGF2CJiLZ4xvRFFlqYN9e5ejfSPco1v4xa9jB0JenpfVBjzCvGA7I1cjjSqXRtGct7o7y55SOmPGN8g5m1cPVcXcMDk+iuyFjMsebNrJh82gST8glc7nl9deailKfzndOqPot0VcLw8xF3lPd5+fqwSs/XWmtgSLtBNnXDiSGFNT+8XP6SLBY2R6EDb6Vhss0XRbugtGJ4lQxeaB0rNiTCQYOqtYuBjyGNjgBoOHd3VG6DnGDa+/es5PZozILTr5yue9bupI/LTCBGeZTC8JHGV7c8FHqdaINeS10qWDgM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(376002)(346002)(396003)(136003)(39860400002)(36840700001)(40470700004)(46966006)(6666004)(110136005)(82310400005)(26005)(1076003)(7696005)(41300700001)(2616005)(316002)(2906002)(36860700001)(8936002)(47076005)(81166007)(36756003)(16526019)(356005)(40480700001)(426003)(478600001)(86362001)(5660300002)(336012)(83380400001)(82740400003)(186003)(40460700003)(8676002)(4326008)(70206006)(70586007)(30864003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:19.8196 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8e29678-6340-47c4-ad43-08da643309f1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2860 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add dynamic descriptor operations as part of amd_mp2_ops structure to support all AMD SOCs and use wherever applicable. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 33 +++++++++++-------- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 7 +++- drivers/hid/amd-sfh-hid/amd_sfh_hid.h | 2 -- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 +-- drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 1 + .../hid_descriptor/amd_sfh_hid_desc.c | 17 +++++++--- .../hid_descriptor/amd_sfh_hid_desc.h | 3 -- 7 files changed, 42 insertions(+), 25 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index e3b3db514c91..e9ccdad66d12 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -70,6 +70,8 @@ static void amd_sfh_work(struct work_struct *work) struct amd_input_data *in_data = cli_data->in_data; struct request_list *req_node; u8 current_index, sensor_index; + struct amd_mp2_ops *mp2_ops; + struct amd_mp2_dev *mp2; u8 report_id, node_type; u8 report_size = 0; @@ -81,9 +83,11 @@ static void amd_sfh_work(struct work_struct *work) node_type = req_node->report_type; kfree(req_node); + mp2 = container_of(in_data, struct amd_mp2_dev, in_data); + mp2_ops = mp2->mp2_ops; if (node_type == HID_FEATURE_REPORT) { - report_size = get_feature_report(sensor_index, report_id, - cli_data->feature_report[current_index]); + report_size = mp2_ops->get_feat_rep(sensor_index, report_id, + cli_data->feature_report[current_index]); if (report_size) hid_input_report(cli_data->hid_sensor_hubs[current_index], cli_data->report_type[current_index], @@ -92,7 +96,7 @@ static void amd_sfh_work(struct work_struct *work) pr_err("AMDSFH: Invalid report size\n"); } else if (node_type == HID_INPUT_REPORT) { - report_size = get_input_report(current_index, sensor_index, report_id, in_data); + report_size = mp2_ops->get_in_rep(current_index, sensor_index, report_id, in_data); if (report_size) hid_input_report(cli_data->hid_sensor_hubs[current_index], cli_data->report_type[current_index], @@ -109,13 +113,15 @@ static void amd_sfh_work_buffer(struct work_struct *work) { struct amdtp_cl_data *cli_data = container_of(work, struct amdtp_cl_data, work_buffer.work); struct amd_input_data *in_data = cli_data->in_data; + struct amd_mp2_dev *mp2; u8 report_size; int i; for (i = 0; i < cli_data->num_hid_devices; i++) { if (cli_data->sensor_sts[i] == SENSOR_ENABLED) { - report_size = get_input_report - (i, cli_data->sensor_idx[i], cli_data->report_id[i], in_data); + mp2 = container_of(in_data, struct amd_mp2_dev, in_data); + report_size = mp2->mp2_ops->get_in_rep(i, cli_data->sensor_idx[i], + cli_data->report_id[i], in_data); hid_input_report(cli_data->hid_sensor_hubs[i], HID_INPUT_REPORT, in_data->input_report[i], report_size, 0); } @@ -153,6 +159,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) { struct amd_input_data *in_data = &privdata->in_data; struct amdtp_cl_data *cl_data = privdata->cl_data; + struct amd_mp2_ops *mp2_ops = privdata->mp2_ops; struct amd_mp2_sensor_info info; struct request_list *req_list; struct device *dev; @@ -163,6 +170,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) req_list = &cl_data->req_list; dev = &privdata->pdev->dev; + amd_sfh_set_desc_ops(mp2_ops); cl_data->num_hid_devices = amd_mp2_get_sensor_num(privdata, &cl_data->sensor_idx[0]); @@ -179,17 +187,17 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) cl_data->sensor_requested_cnt[i] = 0; cl_data->cur_hid_dev = i; cl_idx = cl_data->sensor_idx[i]; - cl_data->report_descr_sz[i] = get_descr_sz(cl_idx, descr_size); + cl_data->report_descr_sz[i] = mp2_ops->get_desc_sz(cl_idx, descr_size); if (!cl_data->report_descr_sz[i]) { rc = -EINVAL; goto cleanup; } - feature_report_size = get_descr_sz(cl_idx, feature_size); + feature_report_size = mp2_ops->get_desc_sz(cl_idx, feature_size); if (!feature_report_size) { rc = -EINVAL; goto cleanup; } - input_report_size = get_descr_sz(cl_idx, input_size); + input_report_size = mp2_ops->get_desc_sz(cl_idx, input_size); if (!input_report_size) { rc = -EINVAL; goto cleanup; @@ -214,17 +222,17 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) rc = -ENOMEM; goto cleanup; } - rc = get_report_descriptor(cl_idx, cl_data->report_descr[i]); + rc = mp2_ops->get_rep_desc(cl_idx, cl_data->report_descr[i]); if (rc) return rc; - privdata->mp2_ops->start(privdata, info); + mp2_ops->start(privdata, info); status = amd_sfh_wait_for_response (privdata, cl_data->sensor_idx[i], SENSOR_ENABLED); if (status == SENSOR_ENABLED) { cl_data->sensor_sts[i] = SENSOR_ENABLED; rc = amdtp_hid_probe(cl_data->cur_hid_dev, cl_data); if (rc) { - privdata->mp2_ops->stop(privdata, cl_data->sensor_idx[i]); + mp2_ops->stop(privdata, cl_data->sensor_idx[i]); status = amd_sfh_wait_for_response (privdata, cl_data->sensor_idx[i], SENSOR_DISABLED); if (status != SENSOR_ENABLED) @@ -240,8 +248,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), cl_data->sensor_sts[i]); } - if (privdata->mp2_ops->discovery_status && - privdata->mp2_ops->discovery_status(privdata) == 0) { + if (mp2_ops->discovery_status && mp2_ops->discovery_status(privdata) == 0) { amd_sfh_hid_client_deinit(privdata); for (i = 0; i < cl_data->num_hid_devices; i++) { devm_kfree(dev, cl_data->feature_report[i]); diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h index 40da53d5efd0..d2a72ab64ebf 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -40,7 +40,7 @@ struct amd_mp2_dev { struct pci_dev *pdev; struct amdtp_cl_data *cl_data; void __iomem *mmio; - const struct amd_mp2_ops *mp2_ops; + struct amd_mp2_ops *mp2_ops; struct amd_input_data in_data; /* mp2 active control status */ u32 mp2_acs; @@ -54,6 +54,11 @@ struct amd_mp2_ops { void (*clear_intr)(struct amd_mp2_dev *privdata); int (*init_intr)(struct amd_mp2_dev *privdata); int (*discovery_status)(struct amd_mp2_dev *privdata); + int (*get_rep_desc)(int sensor_idx, u8 rep_desc[]); + u32 (*get_desc_sz)(int sensor_idx, int descriptor_name); + u8 (*get_feat_rep)(int sensor_idx, int report_id, u8 *feature_report); + u8 (*get_in_rep)(u8 current_index, int sensor_idx, int report_id, + struct amd_input_data *in_data); }; #endif diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h index ecdd2f48cfb8..3754fb423e3a 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_hid.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_hid.h @@ -79,6 +79,4 @@ void amdtp_hid_remove(struct amdtp_cl_data *cli_data); int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type); void amd_sfh_set_report(struct hid_device *hid, int report_id, int report_type); void amdtp_hid_wakeup(struct hid_device *hid); -u8 get_input_report(u8 current_index, int sensor_idx, int report_id, - struct amd_input_data *in_data); #endif diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index dadc491bbf6b..f169b4413abb 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -244,7 +244,7 @@ static void amd_mp2_pci_remove(void *privdata) amd_sfh_clear_intr(mp2); } -static const struct amd_mp2_ops amd_sfh_ops_v2 = { +static struct amd_mp2_ops amd_sfh_ops_v2 = { .start = amd_start_sensor_v2, .stop = amd_stop_sensor_v2, .stop_all = amd_stop_all_sensor_v2, @@ -254,7 +254,7 @@ static const struct amd_mp2_ops amd_sfh_ops_v2 = { .discovery_status = amd_sfh_dis_sts_v2, }; -static const struct amd_mp2_ops amd_sfh_ops = { +static struct amd_mp2_ops amd_sfh_ops = { .start = amd_start_sensor, .stop = amd_stop_sensor, .stop_all = amd_stop_all_sensors, diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 2feac14f5d3c..71c114acdd2b 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -108,5 +108,6 @@ u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); void amd_mp2_suspend(struct amd_mp2_dev *mp2); void amd_mp2_resume(struct amd_mp2_dev *mp2); const char *get_sensor_name(int idx); +void amd_sfh_set_desc_ops(struct amd_mp2_ops *mp2_ops); #endif diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c index 76095bd53c65..f9a8c02d5a7b 100644 --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.c @@ -29,7 +29,7 @@ #define HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM 0x04 #define ILLUMINANCE_MASK GENMASK(14, 0) -int get_report_descriptor(int sensor_idx, u8 *rep_desc) +static int get_report_descriptor(int sensor_idx, u8 *rep_desc) { switch (sensor_idx) { case accel_idx: /* accel */ @@ -63,7 +63,7 @@ int get_report_descriptor(int sensor_idx, u8 *rep_desc) return 0; } -u32 get_descr_sz(int sensor_idx, int descriptor_name) +static u32 get_descr_sz(int sensor_idx, int descriptor_name) { switch (sensor_idx) { case accel_idx: @@ -133,7 +133,7 @@ static void get_common_features(struct common_feature_property *common, int repo common->report_interval = HID_DEFAULT_REPORT_INTERVAL; } -u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report) +static u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report) { struct accel3_feature_report acc_feature; struct gyro_feature_report gyro_feature; @@ -200,7 +200,8 @@ static void get_common_inputs(struct common_input_property *common, int report_i common->event_type = HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM; } -u8 get_input_report(u8 current_index, int sensor_idx, int report_id, struct amd_input_data *in_data) +static u8 get_input_report(u8 current_index, int sensor_idx, int report_id, + struct amd_input_data *in_data) { struct amd_mp2_dev *privdata = container_of(in_data, struct amd_mp2_dev, in_data); u32 *sensor_virt_addr = in_data->sensor_virt_addr[current_index]; @@ -267,3 +268,11 @@ u8 get_input_report(u8 current_index, int sensor_idx, int report_id, struct amd_ } return report_size; } + +void amd_sfh_set_desc_ops(struct amd_mp2_ops *mp2_ops) +{ + mp2_ops->get_rep_desc = get_report_descriptor; + mp2_ops->get_feat_rep = get_feature_report; + mp2_ops->get_in_rep = get_input_report; + mp2_ops->get_desc_sz = get_descr_sz; +} diff --git a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h index 70b1b7abe2c6..ebd55675eb62 100644 --- a/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h +++ b/drivers/hid/amd-sfh-hid/hid_descriptor/amd_sfh_hid_desc.h @@ -111,7 +111,4 @@ struct hpd_input_report { u8 human_presence; } __packed; -int get_report_descriptor(int sensor_idx, u8 rep_desc[]); -u32 get_descr_sz(int sensor_idx, int descriptor_name); -u8 get_feature_report(int sensor_idx, int report_id, u8 *feature_report); #endif From patchwork Tue Jul 12 18:18:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915389 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54C12C43334 for ; Tue, 12 Jul 2022 18:19:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233392AbiGLST0 (ORCPT ); Tue, 12 Jul 2022 14:19:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbiGLSTZ (ORCPT ); Tue, 12 Jul 2022 14:19:25 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1166EBDB89 for ; Tue, 12 Jul 2022 11:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BwqppxllO3UtE3ukMLcqoFVxQcHv4IsqZ+bj+F3n/vlVU1NsdCznNbdooGen61ZNl6YJBZoGjydF5HCMYo8NjWEx8cvc88kf1OfHQNkqkuGOP0B5jz8k+ddTlAf4DAfUJbVeXvviFHlrxMOBNl8JT/RveHeQa84nmdQhmOg248NyrBK+Lx7PNZ7vZCSsje7EL1mjbwNSDoxgU6LoICK8NfruqCDiB29Iacf6UG5eIzz4BIxsqJ4dQAl+vgQa/NQEPiI68Vp+zEkqwotM87Eq437onRZgDejFU/ETJy/0NSkXMbBaWKt1kTh7QzPbPNX3Q/MGvdT9fT/opCbS0pOqSA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F0F8LXmleuf44u0t1eaIzBurBy/MO4WhpRP6d7s4cyo=; b=AukT8EtH85SyeuBZ2i0lUw/Z51Cs+QdzQWrHgCMJXxyM52rILc1h0rcvkwaukL2mRs06tOjpNt9NtXne1TMW9ZfIfb5Hyl502mQ8aiOgA8kMZdOkpniRwl+yG5ccGEHqtTdmmoDg/KVQk4o99d9OqiYDOKT81P3t1ozNo8HOI+moH4JiO+qKe+yWpDBsGybzEaBP3Ltiylj0jSKtyvSvlGyo85C9S+7gXGh7/F/8r5S53xpOGPFpgYMJG7uVAe1aySfOinbXff/n1RliGtnQkHRcGSsYfL1flfPHp2NvuzQ2ea5m0WqMgYig6nA/z4LbHQNq+TSxDqyaGN7Aje+lRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F0F8LXmleuf44u0t1eaIzBurBy/MO4WhpRP6d7s4cyo=; b=YF+9+QjC1ozCtgdR8SGvKq8mKiSpnYsGgslMT54G6TFML9biR7cx7x5pNCywHX33jwTQZqLfXwrNIHEQ2pgAtIfRbGp8eb21EFoyOCeHZC7K/6VMgFErFkusJX5tjUl6icsMizt7Bk7WCjur3lIoHtzI5tgVrx8KCFvm0EEpRBE= Received: from DM5PR08CA0054.namprd08.prod.outlook.com (2603:10b6:4:60::43) by CH2PR12MB4890.namprd12.prod.outlook.com (2603:10b6:610:63::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.20; Tue, 12 Jul 2022 18:19:22 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:4:60:cafe::b4) by DM5PR08CA0054.outlook.office365.com (2603:10b6:4:60::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.16 via Frontend Transport; Tue, 12 Jul 2022 18:19:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:21 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:19 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 06/11] HID: amd_sfh: Add PM operations in amd_mp2_ops Date: Tue, 12 Jul 2022 23:48:31 +0530 Message-ID: <20220712181836.3488343-7-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef00869f-b802-4727-7283-08da64330b20 X-MS-TrafficTypeDiagnostic: CH2PR12MB4890:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h3BJJAAVMeeY7kUuH3Nsvue1oGS6NQ0688Q2++77rcN2mV+QcetN9WB3MSXXfFjnXYiO0ASM7d9bhOPEvDiVWwHXS4UsrTcRKRzJKYEVNruDsqqbOptCafzEZOz18nKcT27z9sHPzuf59pJ9gB3MdDDLSK+9KMBzWUSuqxQZ+btvEtLVF8UdgeCY5zxfQAhAibiDoelSwCZM+S0Js2eFIvRImU7HY8Synzp6i7/X4AA4HIvpWAtqylpdyVEWsMSSSac4iiNfNNM1VmZ5kVHIU6sD//1I8gjECrOMH7Xx2ACkKzZGry1OwjfutHnD4MKm1X3SmVPLj9KZjcR0Pik0A3nbmRzArRm/tidxz9M7QAmeikkHjp6/1qs0xaU2BSSI455/8VO2RQ6ImfNFxzFYM13gmx4PCeZvaM+/bCXUBENzqgKY8LA+OTx7BMi9YHHRW4V0sAiH+sZwJHhwBdg6ZBMxNiPhVQS36vj0zXPCn77nMQOgMAmT8sssOo4FDRlyva7Y+7AbG0VTbb+NPQkMKPruOS7htC0TCAajMrB09UISUcFbXcnYTrOeTkM8PHMRV4mrZsN4xVkeJT/KjTivjOzuTef2r9hSVygR6MidDDKz2x6bPDetNvrP/hJhPJw+Nv+LE35XwHNEI7ttwI5Wft6d/NDD5+cXBuNqn07c7LQrD+lxxpjQpfWr7CE2dOFlzlRHapjx4w1l2+IvaZiEYQDRrCxlndnZajxN+YJdIRl8KgTRCvhSGVaN0Gf75c3Ec9cON3mFbCIaUq0sSGKVB2EJ0aTn2E4Eg7FXmPfBLgkWXZyymPX72Fq+dzFTiy1F/aosaRMzzJNFHSj3mwTKmLtub4/1fEBqBL7SGMPyvNs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(376002)(39860400002)(346002)(396003)(136003)(40470700004)(46966006)(36840700001)(36756003)(40460700003)(1076003)(82740400003)(478600001)(2906002)(8936002)(6666004)(426003)(356005)(36860700001)(40480700001)(4326008)(70206006)(41300700001)(8676002)(26005)(47076005)(70586007)(316002)(83380400001)(81166007)(7696005)(110136005)(86362001)(2616005)(186003)(16526019)(5660300002)(336012)(82310400005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:21.8038 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef00869f-b802-4727-7283-08da64330b20 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4890 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add PM operations as part of amd_mp2_ops structure to support all AMD SOCs and use wherever applicable. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 54 ++++++++++++++++++++++++ drivers/hid/amd-sfh-hid/amd_sfh_common.h | 2 + drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 41 +----------------- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index e9ccdad66d12..b198b564db7d 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -155,6 +155,57 @@ const char *get_sensor_name(int idx) } } +static void amd_sfh_resume(struct amd_mp2_dev *mp2) +{ + struct amdtp_cl_data *cl_data = mp2->cl_data; + struct amd_mp2_sensor_info info; + int i, status; + + for (i = 0; i < cl_data->num_hid_devices; i++) { + if (cl_data->sensor_sts[i] == SENSOR_DISABLED) { + info.period = AMD_SFH_IDLE_LOOP; + info.sensor_idx = cl_data->sensor_idx[i]; + info.dma_address = cl_data->sensor_dma_addr[i]; + mp2->mp2_ops->start(mp2, info); + status = amd_sfh_wait_for_response + (mp2, cl_data->sensor_idx[i], SENSOR_ENABLED); + if (status == SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_ENABLED; + dev_dbg(&mp2->pdev->dev, "resume sid 0x%x (%s) status 0x%x\n", + cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), + cl_data->sensor_sts[i]); + } + } + + schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); + if (mp2->mp2_ops->clear_intr) + mp2->mp2_ops->clear_intr(mp2); +} + +static void amd_sfh_suspend(struct amd_mp2_dev *mp2) +{ + struct amdtp_cl_data *cl_data = mp2->cl_data; + int i, status; + + for (i = 0; i < cl_data->num_hid_devices; i++) { + if (cl_data->sensor_idx[i] != HPD_IDX && + cl_data->sensor_sts[i] == SENSOR_ENABLED) { + mp2->mp2_ops->stop(mp2, cl_data->sensor_idx[i]); + status = amd_sfh_wait_for_response + (mp2, cl_data->sensor_idx[i], SENSOR_DISABLED); + if (status != SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_DISABLED; + dev_dbg(&mp2->pdev->dev, "suspend sid 0x%x (%s) status 0x%x\n", + cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), + cl_data->sensor_sts[i]); + } + } + + cancel_delayed_work_sync(&cl_data->work_buffer); + if (mp2->mp2_ops->clear_intr) + mp2->mp2_ops->clear_intr(mp2); +} + int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) { struct amd_input_data *in_data = &privdata->in_data; @@ -172,6 +223,9 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) dev = &privdata->pdev->dev; amd_sfh_set_desc_ops(mp2_ops); + mp2_ops->suspend = amd_sfh_suspend; + mp2_ops->resume = amd_sfh_resume; + cl_data->num_hid_devices = amd_mp2_get_sensor_num(privdata, &cl_data->sensor_idx[0]); INIT_DELAYED_WORK(&cl_data->work, amd_sfh_work); diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h index d2a72ab64ebf..2b45d507ead7 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -54,6 +54,8 @@ struct amd_mp2_ops { void (*clear_intr)(struct amd_mp2_dev *privdata); int (*init_intr)(struct amd_mp2_dev *privdata); int (*discovery_status)(struct amd_mp2_dev *privdata); + void (*suspend)(struct amd_mp2_dev *mp2); + void (*resume)(struct amd_mp2_dev *mp2); int (*get_rep_desc)(int sensor_idx, u8 rep_desc[]); u32 (*get_desc_sz)(int sensor_idx, int descriptor_name); u8 (*get_feat_rep)(int sensor_idx, int report_id, u8 *feature_report); diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index f169b4413abb..be9ac3778f37 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -339,28 +339,8 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i static int __maybe_unused amd_mp2_pci_resume(struct device *dev) { struct amd_mp2_dev *mp2 = dev_get_drvdata(dev); - struct amdtp_cl_data *cl_data = mp2->cl_data; - struct amd_mp2_sensor_info info; - int i, status; - - for (i = 0; i < cl_data->num_hid_devices; i++) { - if (cl_data->sensor_sts[i] == SENSOR_DISABLED) { - info.period = AMD_SFH_IDLE_LOOP; - info.sensor_idx = cl_data->sensor_idx[i]; - info.dma_address = cl_data->sensor_dma_addr[i]; - mp2->mp2_ops->start(mp2, info); - status = amd_sfh_wait_for_response - (mp2, cl_data->sensor_idx[i], SENSOR_ENABLED); - if (status == SENSOR_ENABLED) - cl_data->sensor_sts[i] = SENSOR_ENABLED; - dev_dbg(dev, "suspend sid 0x%x (%s) status 0x%x\n", - cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), - cl_data->sensor_sts[i]); - } - } - schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); - amd_sfh_clear_intr(mp2); + mp2->mp2_ops->resume(mp2); return 0; } @@ -368,25 +348,8 @@ static int __maybe_unused amd_mp2_pci_resume(struct device *dev) static int __maybe_unused amd_mp2_pci_suspend(struct device *dev) { struct amd_mp2_dev *mp2 = dev_get_drvdata(dev); - struct amdtp_cl_data *cl_data = mp2->cl_data; - int i, status; - - for (i = 0; i < cl_data->num_hid_devices; i++) { - if (cl_data->sensor_idx[i] != HPD_IDX && - cl_data->sensor_sts[i] == SENSOR_ENABLED) { - mp2->mp2_ops->stop(mp2, cl_data->sensor_idx[i]); - status = amd_sfh_wait_for_response - (mp2, cl_data->sensor_idx[i], SENSOR_DISABLED); - if (status != SENSOR_ENABLED) - cl_data->sensor_sts[i] = SENSOR_DISABLED; - dev_dbg(dev, "suspend sid 0x%x (%s) status 0x%x\n", - cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), - cl_data->sensor_sts[i]); - } - } - cancel_delayed_work_sync(&cl_data->work_buffer); - amd_sfh_clear_intr(mp2); + mp2->mp2_ops->suspend(mp2); return 0; } From patchwork Tue Jul 12 18:18:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915390 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 356CEC433EF for ; Tue, 12 Jul 2022 18:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233557AbiGLSTf (ORCPT ); Tue, 12 Jul 2022 14:19:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232821AbiGLST2 (ORCPT ); Tue, 12 Jul 2022 14:19:28 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2066.outbound.protection.outlook.com [40.107.223.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EEFCC1FD0 for ; Tue, 12 Jul 2022 11:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VNyu3ZhRacv2FbU+Ln470IDPuIwyo9DvmgUVkrcqKI5nXH7xCykhKB1xTLeLh5+vBS4lEJTIMoiXTOQSj3pIdRysdWmITSMceLsuCywm48oF2o41cNDb5c5yITRwue6IAs7AOoGdkqV8KppoUUXFiqQQip51Prw63iPnSH9iLC5iWQUGNQOnnHAGiePBeLeHkg7W/gdfRP7OBQXof/oCrYtzQEuBNZA8A8f9uRW9BxoHQsbUOHa7Dt6J9ucqnlTs2x33aouq3H0We6KE2qcGXStr52avBJSdajwvkLbFPfBbY0LbYW7+oYJPWvy5TvXaw7XBBG2t735w78Oqxa6/wA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c1BKsqPXgH7EUslIdOD5uoM9con7G28rkj25TINMDgU=; b=nV4OneF3vGrMrNkEZTTeNM3u7sjCYPxdlhF3O7YWzAgylJyGUp0zyIwDRSX+nDSC34mqOv37Y5QakkV08Qb9s1R0Zy4Uaexkc9z4RCUzS9sxrgmuG0GSXgF3OH6LJzldAx8p9Ku2BBXpYw/KnHPq2LVHOIB8R+i8nKt3p1rDw551mGcFp8SZTaHbBx7R/6epGcPbSw5FLUIOqmNRAfDSlfyDri8D2GkP9h3y8manNYJh1JsQ9ECrCXbnL2XElmKLeqqzwG9ncgyvU2OyzgzHkxenG9kHdqRvbEHViTw2ayXeB24jx3wYhE6t54fcMY8JokdYBxFuhvd8EOcdED2QcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c1BKsqPXgH7EUslIdOD5uoM9con7G28rkj25TINMDgU=; b=5Lp5OuuUD3W66114OB1CCh3KbGJP6+P2QuMgGpLYbZxcVhY4nBXvyjsb1Fp2TwFNfTkJbbA8VGl2ThCklD2JURCBn9cneon+91I6vQgZK0t5KvfG1cyT0tddHMWJmAZ+AakAN6f5FXJmP6eB3xYkRbUzXkW6FhjKXb0lVwo08o4= Received: from DM5PR08CA0060.namprd08.prod.outlook.com (2603:10b6:4:60::49) by DM6PR12MB4355.namprd12.prod.outlook.com (2603:10b6:5:2a3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.20; Tue, 12 Jul 2022 18:19:23 +0000 Received: from DM6NAM11FT021.eop-nam11.prod.protection.outlook.com (2603:10b6:4:60:cafe::cb) by DM5PR08CA0060.outlook.office365.com (2603:10b6:4:60::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT021.mail.protection.outlook.com (10.13.173.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:23 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:21 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 07/11] HID: amd_sfh: Add remove operation in amd_mp2_ops Date: Tue, 12 Jul 2022 23:48:32 +0530 Message-ID: <20220712181836.3488343-8-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72cbd521-0b77-4a59-790a-08da64330bed X-MS-TrafficTypeDiagnostic: DM6PR12MB4355:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tVBCoyAV5LW7ZYSmeaP5cxPnVyCCw92oPv0avA57vjMUBkMbthAKlHfucEaaPjK7sj992+Q1pVMFJsj4u1gh1BUcmYj4BACtMQgeJqFv+XqSLiHYI/6NN+bgSs1Bq6rmpzJxY2515IVoVkvzEUgBCqRCrOUR672dW0+R/MQBzkVKiHUzn8gVw59vKTDtuEFDF+LKnJYiustVuu+ybbaGAeSkY0hm4kqj2WgLH/jC5WjREUbQNG6elbSKUXCFRfQt7WMFnVdqMuVyWrRMC47b+X25uU+pllx29lna6zJ557DbKcE9cVRnXDmkbwReAIOiDLmvKGSefAlBmIlXclRChs9/GKSDnU2lduQlYLgfEK4mXKqImbtMEE+iCgHRqo2fiNhri/OjBVFPOnpUky2k+IQwZj4UrhheF96cJVvT/hYWk6UtHsmqisE6VAvMtqOPHwFSITc+M3beauLnFPMP6tdUPDOaMD8xR0FwX8Vvx7+q44PIFPxKr7v43HWyuW1b3U4Eq3MOE48C103wQUPEsXSlvWR9C4j2MA1nWn9dSSd5ocBkJiVefmbLdbNHSamAQJtix7wvHWK8W31sFcTokkLLYf3Pa1cMzpRZQ6SMu52L34Db3gkOSmf8WTwYzb7fn/l64jeIwiWLPRx8P/R5fAdccT+6Z5v+7cgmuzwOFt/4Vbdve8jbgbnPQoDDRtwtXbTKH1a7IztTgPtj7VeNFI3swzIPUV8NWGbXs8zjTq9DDTdvh9vEqBy9FR+Il/9oLxCE64UoywXrouxbX2mFaO2eQNUZcza1dJki9bPBkLNYt1G3RxALNYYHvRRpM2xsB2hs3+MlJQ017BiiD4+cc/eu3uOYXXfr8ujFKGqPULw= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(376002)(396003)(39860400002)(36840700001)(46966006)(40470700004)(36860700001)(82310400005)(86362001)(40460700003)(2906002)(8936002)(82740400003)(356005)(478600001)(316002)(81166007)(41300700001)(5660300002)(70206006)(70586007)(110136005)(26005)(4326008)(426003)(8676002)(336012)(186003)(16526019)(47076005)(40480700001)(1076003)(83380400001)(7696005)(6666004)(36756003)(2616005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:23.1474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72cbd521-0b77-4a59-790a-08da64330bed X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT021.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4355 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add remove operation as part of amd_mp2_ops structure to support all AMD SOCs and use wherever applicable. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 1 + drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h index 2b45d507ead7..afecf7d2bebe 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -56,6 +56,7 @@ struct amd_mp2_ops { int (*discovery_status)(struct amd_mp2_dev *privdata); void (*suspend)(struct amd_mp2_dev *mp2); void (*resume)(struct amd_mp2_dev *mp2); + void (*remove)(void *privdata); int (*get_rep_desc)(int sensor_idx, u8 rep_desc[]); u32 (*get_desc_sz)(int sensor_idx, int descriptor_name); u8 (*get_feat_rep)(int sensor_idx, int report_id, u8 *feature_report); diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index be9ac3778f37..62e6757f889d 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -252,12 +252,14 @@ static struct amd_mp2_ops amd_sfh_ops_v2 = { .clear_intr = amd_sfh_clear_intr_v2, .init_intr = amd_sfh_irq_init_v2, .discovery_status = amd_sfh_dis_sts_v2, + .remove = amd_mp2_pci_remove, }; static struct amd_mp2_ops amd_sfh_ops = { .start = amd_start_sensor, .stop = amd_stop_sensor, .stop_all = amd_stop_all_sensors, + .remove = amd_mp2_pci_remove, }; static void mp2_select_ops(struct amd_mp2_dev *privdata) @@ -333,7 +335,7 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i amd_sfh_clear_intr(privdata); - return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata); + return devm_add_action_or_reset(&pdev->dev, privdata->mp2_ops->remove, privdata); } static int __maybe_unused amd_mp2_pci_resume(struct device *dev) From patchwork Tue Jul 12 18:18:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915392 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 354F3C43334 for ; Tue, 12 Jul 2022 18:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233368AbiGLSTm (ORCPT ); Tue, 12 Jul 2022 14:19:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233461AbiGLSTc (ORCPT ); Tue, 12 Jul 2022 14:19:32 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D9FD1389 for ; Tue, 12 Jul 2022 11:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QY9UzHUsI2BVMipL9vVJTbIcTKn70JMK9v0cQliCll2ube+XNBCgMCKJQGsUvdn7VGpyYmoNdcDLwnVDokU4760vhW0GoXxipRfSwkPbKbkMHLw7QB5yo5AtuBuBGxFTAYL1CIBhDBHN1TsCJKIoYtuqOkclot4aEgqZAYWDJseUm2P6tZAG6MmxmJlMujX2g6pfnoJZ8YXxA1sgaxtAdewbFyQu/sDcHwAsIa1Iap6tmcoyimTpyKFESe3XK4gPdIg9hgJkM7WUpC9h9mkhdwn1rrlRg91ZDoHVk6Bj1cHk1GZblrhvw+U7m0XuBN00gV1kpFQX3rJdG2VutVm9SQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tye7fFHH/+vQFO6+oWMbuUK1ELPOi5Z/IcbrXunKnBw=; b=Fu80x12h3GVRlQEmz8c+N6BXORZK6QvOIPPjJ3zrsgSNyEO39eEy0Ns50lFyeJLDVFYYbQU8c0PAEK0kqeKU4ia2nKHryb2pxeIq9BQCc5xJ0CDp3b6Nc/wKbad7G8rdaEVrxotA1+UFijmhkxn89WPwaJMvoAj+35jV2B7nOIs2ftKSslvP+oSVfNmxSKRNHw0BkFQ6YkM138qz6pimS32DHHiIcrLI4eDxFIoyAtufREP8FAOZmuzjxu4gcu6QwpM+sR9Z0urdpM5EVLDAN8dbaaQy6o1mMdhpo7u06nQ2SPp2NBlc6GwhwhH99q5H0gYyYrUjIROMX5r4MwmMYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tye7fFHH/+vQFO6+oWMbuUK1ELPOi5Z/IcbrXunKnBw=; b=2zwuDwvZ5VeebxvHz6VP2AvIV5AGovNEYhhX1EnDSPJrKSaQmvp6KTJTlT6DGmyoTx7i0X6gz0SaG07z/k+0YrS23cGNdG1wFJjAl7yaRse0OQ8Ss0oFc/RucLEgNIXzk5/+3HiQpqUqR1cHadeMNmpc1j2sSuf4QutCywdGgyI= Received: from DM6PR07CA0039.namprd07.prod.outlook.com (2603:10b6:5:74::16) by CY4PR1201MB0229.namprd12.prod.outlook.com (2603:10b6:910:1d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.25; Tue, 12 Jul 2022 18:19:25 +0000 Received: from DM6NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::64) by DM6PR07CA0039.outlook.office365.com (2603:10b6:5:74::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.20 via Frontend Transport; Tue, 12 Jul 2022 18:19:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT059.mail.protection.outlook.com (10.13.172.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5438.12 via Frontend Transport; Tue, 12 Jul 2022 18:19:24 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:22 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 08/11] HID: amd_sfh: Move global functions to static Date: Tue, 12 Jul 2022 23:48:33 +0530 Message-ID: <20220712181836.3488343-9-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 89bc0075-166e-4d70-ee36-08da64330cef X-MS-TrafficTypeDiagnostic: CY4PR1201MB0229:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1Aemic4TmcCLfmoTxlvMy9XxYdTJd6Uud37DWj72YZiB1K6d/9/bui83vht3NpAgAkdByuvs9KTl0qvEA1TOJRPBQRrLrm/46ScyMk4MlbOPsvlQgvrIw+ZydBP6eGTVJMQuOlPV2TPhT+Xu+lgRQYbneS8mREfsQMbreR8wz6NvgO+5D1qdt+BQWSkWeVSwkM0b7VDWNnYWeVlSEcydSZLGzcQgHpz0Bp+fNtuo3hOZZnxyrwifKbsd9oZ35N4b3RARbxyf6fodQhGtPOqICdBc17mTScFRSZHzr+QbowY0v/E2+B+fHIluZZSa6I2uW9o9VPIIce4E66VYYv2JcwA0jU6CpUbfC4mf9ttntJbBPJisJSiG/kLz6CwRP+x1FCvFgD1kPEyiMInNucMwyZ8HLvig9TXynqKOl1GAHeaaTLhT6R+NVvcl87IiGv5fHwZVwa77ymY8LGsow1ARnH42BdbAUtn8hgmejLtrKBogtKjBPq6m/2nzm8QsRJZ4SIgkT6l3xix1x1rjsZ2HDELgaM45Uq6ggcVBpxXsYLmkTlf/rg3snt6raw8gTZk7sXoYlbGcfjTo0S0xVFPdHB9ouT6/1tMCChLWHYhovonQfWjue1kj2BWYb2zAPbgGvQXVL0IntU/YBn8rgtV02d38Pkxbv43988aeJOBG460DHFci06/ga6d3BTr6RPskmrlVBGbLfpD5gzEdWSUL2PEo8gw2He2tgz5Qp7GQfK6jZgLltk+IqF+Xq0U0loMi1q1p0jTYT4uTcxz9Ex0WaRuIdmBmJEhd5oHYkifN2psRgdGcz9necIVHwmSu+yupShwD8FuJsVBzI9AdyLcTa2r+Be5jROQz13Dui5BlLos= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(136003)(376002)(39860400002)(396003)(40470700004)(36840700001)(46966006)(110136005)(70586007)(8936002)(4326008)(5660300002)(2906002)(82310400005)(36756003)(40460700003)(316002)(40480700001)(86362001)(70206006)(7696005)(81166007)(6666004)(83380400001)(478600001)(16526019)(8676002)(186003)(47076005)(336012)(41300700001)(2616005)(26005)(36860700001)(356005)(82740400003)(426003)(1076003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:24.8569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 89bc0075-166e-4d70-ee36-08da64330cef X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0229 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Move global functions declared from header files and make them as static functions wherever applicable. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 4 ++-- drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 6 +++--- drivers/hid/amd-sfh-hid/amd_sfh_pcie.h | 7 ------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index b198b564db7d..1f59fabded85 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -129,7 +129,7 @@ static void amd_sfh_work_buffer(struct work_struct *work) schedule_delayed_work(&cli_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); } -u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts) +static u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts) { if (mp2->mp2_ops->response) sensor_sts = mp2->mp2_ops->response(mp2, sid, sensor_sts); @@ -137,7 +137,7 @@ u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts) return sensor_sts; } -const char *get_sensor_name(int idx) +static const char *get_sensor_name(int idx) { switch (idx) { case accel_idx: diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 62e6757f889d..c9a9ac11f124 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -136,7 +136,7 @@ static int amd_sfh_dis_sts_v2(struct amd_mp2_dev *privdata) SENSOR_DISCOVERY_STATUS_MASK) >> SENSOR_DISCOVERY_STATUS_SHIFT; } -void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info) +static void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info) { union sfh_cmd_param cmd_param; union sfh_cmd_base cmd_base; @@ -157,7 +157,7 @@ void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info i writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG0); } -void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx) +static void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx) { union sfh_cmd_base cmd_base; @@ -171,7 +171,7 @@ void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx) writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG0); } -void amd_stop_all_sensors(struct amd_mp2_dev *privdata) +static void amd_stop_all_sensors(struct amd_mp2_dev *privdata) { union sfh_cmd_base cmd_base; diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h index 71c114acdd2b..dfb7cabd82ef 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.h @@ -98,16 +98,9 @@ struct hpd_status { }; }; -void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info); -void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx); -void amd_stop_all_sensors(struct amd_mp2_dev *privdata); int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id); int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata); int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata); -u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts); -void amd_mp2_suspend(struct amd_mp2_dev *mp2); -void amd_mp2_resume(struct amd_mp2_dev *mp2); -const char *get_sensor_name(int idx); void amd_sfh_set_desc_ops(struct amd_mp2_ops *mp2_ops); #endif From patchwork Tue Jul 12 18:18:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915393 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA4C6CCA47F for ; Tue, 12 Jul 2022 18:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229564AbiGLSTn (ORCPT ); Tue, 12 Jul 2022 14:19:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233541AbiGLSTe (ORCPT ); Tue, 12 Jul 2022 14:19:34 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9361D138F for ; Tue, 12 Jul 2022 11:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gZ4s4VPFmn0e7Ltph5deiSW2KcwJ0E2sv5X2dvFy6YpddbWd9tPbgFX0K4lKtKTqPNxJJEzIEb6bfYH9qPk2G7F+ikpBpOPtLs2eoR5l/7vMgS1C5ceFGEljrnJ+JCUcewMpAVLpETdimZj0dBsvwHIg3g7LIVL1Ni+DyZogtm7PzxL5xq0Mjo2MAnSojQ3p83xmm1NkcxqVdoMrN9h2mpFO4dYcqj8xYkHv9IZzvYb5xgRfIXjmvccUg2YcioiSKURM6xdG9GOw7FBHnIrYvRDAcbGbYT5yq/6+IS5HMTgf/l0yvrGKUuEHlYW8We7wfTUsO7zah6jPlWdNHWt26Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EO0ABWkvcQSx0PlIa1C5O1DPZvmrdpNMetJ5nCaxMJs=; b=HltYv6VrzDpgxQ7B0OK0AQzAjcOnyJFPsbvJMxQbKycZwnZ4CdQYt6sTKBhphIO7CEHO30kD0nOlc40tQDmkUX6CNsPq+SXCaInru//CVARqmVUZZVfXy/m+eyuzYA2ya3F28r7B4o0SQSw9PFndewWPx0Pu8mXG4OwW35bfy3Zc0YqH1urRs52iSOVyovO1dGIKuK7IPr772C/2zJJ2kYrOBeu+88reHqhey0skTBlKtpCi5ynfWlsM0N27VGdJ9cLbgN0sXOhMGMCloBTFNxalbCuxQKtd/Qdy9TM7AqbjQcRVfXV+a4pMyJLCHl76LLvxcw06dmNtRh6ggxJItQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EO0ABWkvcQSx0PlIa1C5O1DPZvmrdpNMetJ5nCaxMJs=; b=QaE9Y7C7PeWN46vdi5oTytau9N2NlXX3AOTvYs9DMVdfMdnsFcvLeqyqar8gg8Jky6Nmy2TpFLFSoChMFOgQjG6uTE5NX2RuAXFfHGyon9d8Zkz1tXii09rK+cwIYufnqO9ct8vy/IEMjNLNCWWZdgL9fRCehakddyZrKyRBf/E= Received: from DM6PR03CA0050.namprd03.prod.outlook.com (2603:10b6:5:100::27) by MN2PR12MB4272.namprd12.prod.outlook.com (2603:10b6:208:1de::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.15; Tue, 12 Jul 2022 18:19:26 +0000 Received: from DM6NAM11FT038.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::fb) by DM6PR03CA0050.outlook.office365.com (2603:10b6:5:100::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.26 via Frontend Transport; Tue, 12 Jul 2022 18:19:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT038.mail.protection.outlook.com (10.13.173.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:26 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:24 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 09/11] HID: amd_sfh: Move amd_sfh_work to common interface Date: Tue, 12 Jul 2022 23:48:34 +0530 Message-ID: <20220712181836.3488343-10-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 166f649d-45d9-40f2-0425-08da64330df5 X-MS-TrafficTypeDiagnostic: MN2PR12MB4272:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ftsqWjrPw8UIJbido188IsiNZ4cxmi+96Ytu3/oX8/EUjXeIvddeDCsCLGDMj32vzozwH2ME2Fa34L2DII6m0ZApCwBvZtg3y/Udon2TXwv0alL/MTmCWjkw9d9T41dt3ZcPGumIpbZbyS+0a3Kq78nBccvOelY9HbX74NWtjlIOMVbctBqqHJmycxRiINqOIxPVu8Y2oKymWm4T460dBPetIpIAFLKzAI3cXZ9wIL4S+lzbV9QiojcDqg94dFhp72yf2DIGmWMEITSE4dCNuEXtTEx/XGLWvYEcYzuq+rwIyo7M8S+GsFDOxRhZPVwKJB+e2TuoW0LTktQwlwYMpMxWCClMB3S+9DFLXHrLDgg4CIf6JZjyt60QI3CuD3sLYwdWhsJJ+Yb8wow7ifkrvA+esD7Oy5McJ2lnGOEDk/TKqMNh9+Dfcnp3LpJ1TvnI0TWIGbG1eAFxmSP2+QW8tz1H2wGp6Lk7XaPeiYVp84c8KzGT/sMAbIL4/XAJEe7zl8km17cO4u6PDMX42eqSL7ZnFP14awn0R4AlOx8TnWAG7VMc5HlVswHT0C1l+8L9H9cEO/eL0es+ACzyD5h9v4E1fLWWgbu8dfMuMQi5AY5yAXyRV4uFvyDYuPrpm3nmws8xa+t6JYJDtiCbnpTkoCufTxgaey8PHHmhTxV5/otjMxAJEOypvD4unI24pHNME9eiNW5SbqESPpvAZAeW1j2JgrAHFCxNlg/HfzNStY+85tLwQwptdDf72e8H/irQrcD/kaLd4XeTYZgXP/P3s5k4m8U38v3UN0I2Bxi98o6IU7sOyYk7WodAS1FarW5sPh+Pqa8k6tfC5o7ZMbcokFv4zCZsqqtR4nIP0RP2xak= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(376002)(39860400002)(136003)(396003)(36840700001)(40470700004)(46966006)(478600001)(40460700003)(36860700001)(82310400005)(81166007)(36756003)(70206006)(6666004)(316002)(41300700001)(110136005)(8676002)(5660300002)(83380400001)(8936002)(4326008)(2906002)(82740400003)(1076003)(336012)(426003)(16526019)(47076005)(7696005)(86362001)(40480700001)(186003)(70586007)(2616005)(26005)(356005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:26.5679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 166f649d-45d9-40f2-0425-08da64330df5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT038.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4272 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org amd_sfh_work can be used in multiple files to support all AMD SOCs. Hence move amd_sfh_work to common interface. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 4 ++-- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index 1f59fabded85..8e686081c8fc 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -63,7 +63,7 @@ int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type) return 0; } -static void amd_sfh_work(struct work_struct *work) +void amd_sfh_work(struct work_struct *work) { struct amdtp_cl_data *cli_data = container_of(work, struct amdtp_cl_data, work.work); struct request_list *req_list = &cli_data->req_list; @@ -109,7 +109,7 @@ static void amd_sfh_work(struct work_struct *work) amdtp_hid_wakeup(cli_data->hid_sensor_hubs[current_index]); } -static void amd_sfh_work_buffer(struct work_struct *work) +void amd_sfh_work_buffer(struct work_struct *work) { struct amdtp_cl_data *cli_data = container_of(work, struct amdtp_cl_data, work_buffer.work); struct amd_input_data *in_data = cli_data->in_data; diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h index afecf7d2bebe..b3dd758ecca4 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -64,4 +64,6 @@ struct amd_mp2_ops { struct amd_input_data *in_data); }; +void amd_sfh_work(struct work_struct *work); +void amd_sfh_work_buffer(struct work_struct *work); #endif From patchwork Tue Jul 12 18:18:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915394 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D365C433EF for ; Tue, 12 Jul 2022 18:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbiGLSTo (ORCPT ); Tue, 12 Jul 2022 14:19:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233263AbiGLSTk (ORCPT ); Tue, 12 Jul 2022 14:19:40 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2082.outbound.protection.outlook.com [40.107.220.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6024D13AC for ; Tue, 12 Jul 2022 11:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cAYdeteetMZFC1ko49VGScC5io/Up8c8xDeB4nV7hWHtPeQ+F/7MXjxoOt0VN5Uu2vG+RMVeRSR0IW3iCwl43gdjRBVoIAESfWestiICxC/GmxIKQ7BjIMvPl92GE2mKuI0htIAdqCd8fxAfr8owcfVQVCn/ol1mQOEYHma8Z6SSdSD9nzy2Z4uLhhzlAOKMZA6KMLoMBXvE5inNY4wl0Uu/T8mVBP9BX1yAkmkHK2SXeJkJY6UfFLrdHRStEzIJ0CL8gZsiQLnJAfrXJrTbGGWNMrMW70nE/3UOQrTv+Oj86Cpt8AXAy8+f9U0R/kokElW+agQ5/PMxPu1sbK9jZQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lT4kFTHCsuYhmbYyh0OQqbpKIfHuvERv73xtnr1oKtc=; b=JEuAdK/wjQFhas/ka5EDcePiFh3qKx5fqLnSPYevsQfb/7yg468WUK3RzxuQYyTiEa0RbULClkQND4VClFLoGR0+Kr9PkkNLQQ4Or7go9poXckkH3mxuN7qUuhk1ErGqlFBTbNF7b5fyDebUUNqpKtJeroEJ247ifIrqKKWyE/pydfTFB9xeaE9XmBklmG+frZXXnmHk8mVUDMh7JQXZjUBhKKRRiEZGumLCTyHibNXCgMeZ4Uljv0n4G07EYyKRVhGlTfqLuXJMy7L9UExhGKaig8CGcm+znnM3/7Nt0cXRb6Igo/KA7WNVCOFpEldp5N+f4sN7G1XZQS2WcuKYFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lT4kFTHCsuYhmbYyh0OQqbpKIfHuvERv73xtnr1oKtc=; b=oVETonN/i9fXcGK4MH+FBufe5mkJvLLnsUcmpGzSSwqDCnmDOse8S/wlR9HfqVI9BETuD2eCxeRYgryl/cx8Qt/V43hII4Jk45c0IrfM1zi4uGQU89d2gq6APfp4gZYl5l+XD3U5wv8HwD/AUmGypXW6v13thXUgwiqDyySV3aY= Received: from DS7PR03CA0220.namprd03.prod.outlook.com (2603:10b6:5:3ba::15) by MN0PR12MB5835.namprd12.prod.outlook.com (2603:10b6:208:37a::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.26; Tue, 12 Jul 2022 18:19:28 +0000 Received: from DM6NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ba:cafe::25) by DS7PR03CA0220.outlook.office365.com (2603:10b6:5:3ba::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.20 via Frontend Transport; Tue, 12 Jul 2022 18:19:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT050.mail.protection.outlook.com (10.13.173.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Tue, 12 Jul 2022 18:19:28 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:26 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 10/11] HID: amd_sfh: Move interrupt handling to common interface Date: Tue, 12 Jul 2022 23:48:35 +0530 Message-ID: <20220712181836.3488343-11-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f7e9804-9d4c-4f18-db9b-08da64330f01 X-MS-TrafficTypeDiagnostic: MN0PR12MB5835:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LPe/Bg2LavDdZkl34HzzRb6E17vLLIGbTiKBWdXpjiFi6klE+xQZb/n+KfJaoxoB8yOAOihRy6aWhiyFFKvFbkNviLvkkGD3EN9tAM2Ic2eMg38eGpay/28lfROOmyl5kORYg4NDgWqnkUQr/W3DdzWs4ILO5XJcy9WVzPtfZvu7ZV0b8F0UUpvVc+IYuz5Rri+wPvjidxBo9RqnH7aIYynSgb4EGIjt8CUOUL0yp26wSiAaxTd7SyM+0syuvRj263lu0BviPTiq6N+OfVIUjNvj+M8ZPSj3MILhws1nmdlO0ko5tu+V157CxDSuEFNz4I0cma0uIMjmI+pW3enl7bd8Lq38jT+Kbmyq9N8K8pX9oHIWaU4cbQOgbnxZOVqS8QmJ5K63tPL3EFiyWiRyEeQHhyB6ViHo0vbmn+FS9E8zOi0p8XeksIcZxMzICVs5s+aP3TBwRoeApHj2nk5ImqOQutVvgpgnyKu0jztzO+jhkffqEML1PsJr7lpen5GczICQtc0o6W2+TKy8E7y7zpcmQ3tKGkQMno3PGwXFH2XwB6V8wZQt1n/Cc8sxx1YeF/AP9BvQkJteNM8ZHwziz39wltSogyj6cyFP3LtaNf/Ltvyl+hgytiRmubrSdoXACS8kxUEmcWDv2KRMT6ugGqVMbZJXCmzVYNeb2UMc+zfmQGz8RqlufW3wY90Nc68JDNpBT3SNjlXNrs/rJDUyhnFEJ/8YCTNCeaiNmbnpBjNH7SfKssSTAzfBGoA4PfkzJkul8Td/g1vQP+Y+TLFMj1voplszr1OeZ73q/4sv2NTGhwHnGrpIN4zlLFjzCpTR/IwO+DlbsAW79Ko/s8o+s5dLO+NMnmZdQGgkpiirk2I= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(39860400002)(396003)(376002)(136003)(40470700004)(46966006)(36840700001)(2906002)(478600001)(40460700003)(8936002)(41300700001)(26005)(2616005)(7696005)(86362001)(1076003)(6666004)(82740400003)(186003)(81166007)(82310400005)(36756003)(316002)(5660300002)(16526019)(47076005)(40480700001)(36860700001)(4326008)(336012)(356005)(83380400001)(8676002)(110136005)(70586007)(70206006)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:28.3298 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f7e9804-9d4c-4f18-db9b-08da64330f01 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5835 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Interrupt handling can be used in multiple files to support all AMD SOCs. Hence move interrupt handling to common interface. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/amd_sfh_client.c | 6 ++---- drivers/hid/amd-sfh-hid/amd_sfh_common.h | 4 ++++ drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c index 8e686081c8fc..f95e623040f3 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c @@ -178,8 +178,7 @@ static void amd_sfh_resume(struct amd_mp2_dev *mp2) } schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); - if (mp2->mp2_ops->clear_intr) - mp2->mp2_ops->clear_intr(mp2); + amd_sfh_clear_intr(mp2); } static void amd_sfh_suspend(struct amd_mp2_dev *mp2) @@ -202,8 +201,7 @@ static void amd_sfh_suspend(struct amd_mp2_dev *mp2) } cancel_delayed_work_sync(&cl_data->work_buffer); - if (mp2->mp2_ops->clear_intr) - mp2->mp2_ops->clear_intr(mp2); + amd_sfh_clear_intr(mp2); } int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata) diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h index b3dd758ecca4..1efb72ec116f 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -66,4 +66,8 @@ struct amd_mp2_ops { void amd_sfh_work(struct work_struct *work); void amd_sfh_work_buffer(struct work_struct *work); +void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata); +int amd_sfh_irq_init_v2(struct amd_mp2_dev *privdata); +void amd_sfh_clear_intr(struct amd_mp2_dev *privdata); +int amd_sfh_irq_init(struct amd_mp2_dev *privdata); #endif diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index c9a9ac11f124..1425b57f3580 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -92,7 +92,7 @@ static void amd_stop_all_sensor_v2(struct amd_mp2_dev *privdata) writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG0); } -static void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata) +void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata) { if (readl(privdata->mmio + AMD_P2C_MSG(4))) { writel(0, privdata->mmio + AMD_P2C_MSG(4)); @@ -100,7 +100,7 @@ static void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata) } } -static void amd_sfh_clear_intr(struct amd_mp2_dev *privdata) +void amd_sfh_clear_intr(struct amd_mp2_dev *privdata) { if (privdata->mp2_ops->clear_intr) privdata->mp2_ops->clear_intr(privdata); @@ -113,7 +113,7 @@ static irqreturn_t amd_sfh_irq_handler(int irq, void *data) return IRQ_HANDLED; } -static int amd_sfh_irq_init_v2(struct amd_mp2_dev *privdata) +int amd_sfh_irq_init_v2(struct amd_mp2_dev *privdata) { int rc; @@ -279,7 +279,7 @@ static void mp2_select_ops(struct amd_mp2_dev *privdata) } } -static int amd_sfh_irq_init(struct amd_mp2_dev *privdata) +int amd_sfh_irq_init(struct amd_mp2_dev *privdata) { if (privdata->mp2_ops->init_intr) return privdata->mp2_ops->init_intr(privdata); From patchwork Tue Jul 12 18:18:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Basavaraj Natikar X-Patchwork-Id: 12915395 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBAB5C43334 for ; Tue, 12 Jul 2022 18:19:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbiGLSTp (ORCPT ); Tue, 12 Jul 2022 14:19:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233615AbiGLSTl (ORCPT ); Tue, 12 Jul 2022 14:19:41 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDBCFC3ACE for ; Tue, 12 Jul 2022 11:19:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fpcqpyvJZUo8GDQouyumQpnx7En1s3RDsVhGhKWBw3AY912U7vowAU2Ppi8Y8ppvf7t6DYKmbFnTlIciNPelbUXbJHAr+K2ZsImi7eZRyU1BHNAB1C9/8OMDqa3YiVuKA+yQl9NU6FaXwL+ixH/oqT1rMXHd++cKRkTjAxhEmRB98S6EoR3Y+MQtmxMJFKkFLUBtiHiKUG1h+/7kMgjZNSFN6EeVTaW+dHUKaMnCJuK/sUdz7b/IaAoKuy6uKvruM3hHYT8bnPEp0Xdo5UmXMjf50QmZf/h5d7g8ix3b0qIiXF3r+IZSfM7ikxMagi1vZQIe/BZnqZlnBjedrLHCsQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EE9xo+5kNV9B87Io+PM211r3e4yXa1rkja3nBbF99mk=; b=H2D4mFKCCpOq4SQXWZ2h4EdES67QPIczyzOF5FQXYZAzSK/h7kFPMLgt7st4k5XYwTdmUPCwj7g1VKIjg+KwY8kodis9kpWk3czqM0cIag+zwdv4d7tpz3O48aoG9mTx8yOTK5qOzbTghUeCYFeJBOkFmG87FPjSkTEZvEiSJMtdYi9RppfN7rt56yg3+qghnE6EtMBECcjfFtp7+JwJVDXpvy68/3qcoACTNBj+9g09Mi4dwLkXjtXncI5CfdweyAjXb1wLhZRZ5kAT6qynHp1kyhZs1laZnaF3O6Q90ojMiiuILwi0nwX7cTe0wWTM8uvN/S5VVkjQGT2+Vb7DTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EE9xo+5kNV9B87Io+PM211r3e4yXa1rkja3nBbF99mk=; b=G4b151jegMRPC4kKyiESQnM+kgUgdQgT4crY6OUST3aKoJrLDIeorHBSWDzmdATXGS3aQ+7cvCZ6jPfPuaBrrPHmgexQPK5eUvjx1eXLfm9pvUNdiHfFhPpmc8XtA4lz6r90dQCj2iA3zedbTX3aYrE2+IgccUIKB1N7EDqHc6Y= Received: from DM6PR03CA0045.namprd03.prod.outlook.com (2603:10b6:5:100::22) by MW3PR12MB4410.namprd12.prod.outlook.com (2603:10b6:303:5b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.21; Tue, 12 Jul 2022 18:19:31 +0000 Received: from DM6NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::7b) by DM6PR03CA0045.outlook.office365.com (2603:10b6:5:100::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.26 via Frontend Transport; Tue, 12 Jul 2022 18:19:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT024.mail.protection.outlook.com (10.13.172.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5438.12 via Frontend Transport; Tue, 12 Jul 2022 18:19:30 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 12 Jul 2022 13:19:28 -0500 From: Basavaraj Natikar To: , , CC: Basavaraj Natikar Subject: [PATCH 11/11] HID: amd_sfh: Implement SFH1.1 functionality Date: Tue, 12 Jul 2022 23:48:36 +0530 Message-ID: <20220712181836.3488343-12-Basavaraj.Natikar@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> References: <20220712181836.3488343-1-Basavaraj.Natikar@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3d299e9e-701a-4ee0-41a0-08da6433104e X-MS-TrafficTypeDiagnostic: MW3PR12MB4410:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: C8Fsj0/NyKedOBRC5dc6m6JHt9nRqnfIVC0IAHxVq2CofLiqWdhFyx8DnB5tVCcDgIxL//bXkC+jBOg36rduBP5wTitX0KhrS231JjUkKPQLSXxDboCYo2EBd2jnfESjgi0YgXUrr0VxoAvxGQo2ZofepzPx7gbhCxK/kL1R+VC5AHkHjEnH/4LONw8Gqsh1XautEI9YsBB83rb8f8ozZgWO34LADdDpZDEtlmdxJeF4M6hE95fZe79SWSlCFxzhdvdur6wX52sfxRq2bmqC1qXHAz4cxtwUCQK66JbP6mi7yz4T6uUJ5xqQ9GVjV2NDZjl9X5X8Sm4FwFJ+OKdMxz1S4ijFngu7YIX+vZIr0cbzTO9zYeFwTA6JRp32e1sRCEKBkt4Gp6j7jOo9AICq0K3i7kOZUYESilTol3h2GusaYvFNut1Km2Yev7wCXt6GfDRBzgk9IB8ojxIDMvHy0KfyWlLebWJJczVipl0SsLfncwnueDOvJsIbdzIZ1ys+qYkXNKky0vE+lrPNOEAMatdQtrhaovuEGu+pZMXZNC8+Q7HRZS6g9n4xFhYITlZKKqrj3Ux/xjzYAWEtl+mdO0trelhywohW16r11JQu3V126aC6B8jvwtNvjg8IMHj6wiSudkAxLq0OXeZVVKmHkzQeX5HyFCqhrNpKmrSQ9z2R9pSpt/eJCcFBrBrcsWqTD5wTKPMaQ8ssm0Smge0KUHWT+xE/Yh9ugKR2d38C33zW/BnQipLTBmahJKn4W/WDNO2+4x3vVWPiZSsBdMzCjdDclr9YG6vW70oMKcV3OmYTKD6Hdrren5z5+ngIOlgeHaS8SFbI71jdUcZVKlBHtXBpSLb5Gqyy6VCmK8jykuY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(136003)(39860400002)(396003)(376002)(46966006)(36840700001)(40470700004)(47076005)(426003)(40480700001)(81166007)(336012)(83380400001)(8676002)(16526019)(36756003)(82740400003)(4326008)(70206006)(186003)(36860700001)(70586007)(316002)(356005)(110136005)(40460700003)(6666004)(82310400005)(7696005)(86362001)(1076003)(41300700001)(2906002)(478600001)(26005)(8936002)(5660300002)(2616005)(30864003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 18:19:30.5082 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d299e9e-701a-4ee0-41a0-08da6433104e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4410 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Newer AMD SOCs use SFH1.1 memory access with new PCI-id. Hence add new sfh1_1 sub directory to implement SFH1.1 functionality by defining new PCI id, interface functions, descriptor functions and handlers which invokes sfh1.1. Signed-off-by: Basavaraj Natikar --- drivers/hid/amd-sfh-hid/Makefile | 3 + drivers/hid/amd-sfh-hid/amd_sfh_common.h | 3 + drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 12 + drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c | 300 ++++++++++++++++ drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c | 324 ++++++++++++++++++ drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.h | 26 ++ .../amd-sfh-hid/sfh1_1/amd_sfh_interface.c | 73 ++++ .../amd-sfh-hid/sfh1_1/amd_sfh_interface.h | 154 +++++++++ 8 files changed, 895 insertions(+) create mode 100644 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c create mode 100644 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c create mode 100644 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.h create mode 100644 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c create mode 100644 drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h diff --git a/drivers/hid/amd-sfh-hid/Makefile b/drivers/hid/amd-sfh-hid/Makefile index 35e704da5612..0222170ab7ad 100644 --- a/drivers/hid/amd-sfh-hid/Makefile +++ b/drivers/hid/amd-sfh-hid/Makefile @@ -9,5 +9,8 @@ amd_sfh-objs := amd_sfh_hid.o amd_sfh-objs += amd_sfh_client.o amd_sfh-objs += amd_sfh_pcie.o amd_sfh-objs += hid_descriptor/amd_sfh_hid_desc.o +amd_sfh-objs += sfh1_1/amd_sfh_init.o +amd_sfh-objs += sfh1_1/amd_sfh_interface.o +amd_sfh-objs += sfh1_1/amd_sfh_desc.o ccflags-y += -I $(srctree)/$(src)/ diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_common.h b/drivers/hid/amd-sfh-hid/amd_sfh_common.h index 1efb72ec116f..2643bb14fee2 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_common.h +++ b/drivers/hid/amd-sfh-hid/amd_sfh_common.h @@ -14,6 +14,7 @@ #include "amd_sfh_hid.h" #define PCI_DEVICE_ID_AMD_MP2 0x15E4 +#define PCI_DEVICE_ID_AMD_MP2_1_1 0x164A #define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4)) #define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4)) @@ -40,6 +41,8 @@ struct amd_mp2_dev { struct pci_dev *pdev; struct amdtp_cl_data *cl_data; void __iomem *mmio; + void __iomem *vsbase; + const struct amd_sfh1_1_ops *sfh1_1_ops; struct amd_mp2_ops *mp2_ops; struct amd_input_data in_data; /* mp2 active control status */ diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c index 1425b57f3580..c9fb844e3360 100644 --- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c +++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c @@ -19,6 +19,7 @@ #include #include "amd_sfh_pcie.h" +#include "sfh1_1/amd_sfh_init.h" #define DRIVER_NAME "pcie_mp2_amd" #define DRIVER_DESC "AMD(R) PCIe MP2 Communication Driver" @@ -318,6 +319,14 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i if (!privdata->cl_data) return -ENOMEM; + privdata->sfh1_1_ops = (const struct amd_sfh1_1_ops *)id->driver_data; + if (privdata->sfh1_1_ops) { + rc = privdata->sfh1_1_ops->init(privdata); + if (rc) + return rc; + goto init_done; + } + mp2_select_ops(privdata); rc = amd_sfh_irq_init(privdata); @@ -333,6 +342,7 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i return rc; } +init_done: amd_sfh_clear_intr(privdata); return devm_add_action_or_reset(&pdev->dev, privdata->mp2_ops->remove, privdata); @@ -361,6 +371,8 @@ static SIMPLE_DEV_PM_OPS(amd_mp2_pm_ops, amd_mp2_pci_suspend, static const struct pci_device_id amd_mp2_pci_tbl[] = { { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2) }, + { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_MP2_1_1), + .driver_data = (kernel_ulong_t)&sfh1_1_ops }, { } }; MODULE_DEVICE_TABLE(pci, amd_mp2_pci_tbl); diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c new file mode 100644 index 000000000000..0609fea581c9 --- /dev/null +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_desc.c @@ -0,0 +1,300 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * AMD MP2 1.1 descriptor interfaces + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Basavaraj Natikar + */ + +#include + +#include "amd_sfh_interface.h" +#include "../hid_descriptor/amd_sfh_hid_desc.h" +#include "../hid_descriptor/amd_sfh_hid_report_desc.h" + +#define SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM 0x41 +#define SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM 0x51 +#define HID_DEFAULT_REPORT_INTERVAL 0x50 +#define HID_DEFAULT_MIN_VALUE 0X7F +#define HID_DEFAULT_MAX_VALUE 0x80 +#define HID_DEFAULT_SENSITIVITY 0x7F +#define HID_USAGE_SENSOR_PROPERTY_CONNECTION_TYPE_PC_INTEGRATED_ENUM 0x01 +/* state enums */ +#define HID_USAGE_SENSOR_STATE_READY_ENUM 0x02 +#define HID_USAGE_SENSOR_STATE_INITIALIZING_ENUM 0x05 +#define HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM 0x04 + +static int get_report_desc(int sensor_idx, u8 *rep_desc) +{ + switch (sensor_idx) { + case ACCEL_IDX: /* accelerometer */ + memset(rep_desc, 0, sizeof(accel3_report_descriptor)); + memcpy(rep_desc, accel3_report_descriptor, + sizeof(accel3_report_descriptor)); + break; + case GYRO_IDX: /* gyroscope */ + memset(rep_desc, 0, sizeof(gyro3_report_descriptor)); + memcpy(rep_desc, gyro3_report_descriptor, + sizeof(gyro3_report_descriptor)); + break; + case MAG_IDX: /* magnetometer */ + memset(rep_desc, 0, sizeof(comp3_report_descriptor)); + memcpy(rep_desc, comp3_report_descriptor, + sizeof(comp3_report_descriptor)); + break; + case ALS_IDX: /* ambient light sensor */ + memset(rep_desc, 0, sizeof(als_report_descriptor)); + memcpy(rep_desc, als_report_descriptor, + sizeof(als_report_descriptor)); + break; + case HPD_IDX: /* HPD sensor */ + memset(rep_desc, 0, sizeof(hpd_report_descriptor)); + memcpy(rep_desc, hpd_report_descriptor, + sizeof(hpd_report_descriptor)); + break; + } + return 0; +} + +static void get_common_features(struct common_feature_property *common, int report_id) +{ + common->report_id = report_id; + common->connection_type = HID_USAGE_SENSOR_PROPERTY_CONNECTION_TYPE_PC_INTEGRATED_ENUM; + common->report_state = SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM; + common->power_state = SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM; + common->sensor_state = HID_USAGE_SENSOR_STATE_INITIALIZING_ENUM; + common->report_interval = HID_DEFAULT_REPORT_INTERVAL; +} + +static u8 get_feature_rep(int sensor_idx, int report_id, u8 *feature_report) +{ + struct magno_feature_report magno_feature; + struct accel3_feature_report acc_feature; + struct gyro_feature_report gyro_feature; + struct hpd_feature_report hpd_feature; + struct als_feature_report als_feature; + u8 report_size = 0; + + if (!feature_report) + return report_size; + + switch (sensor_idx) { + case ACCEL_IDX: /* accelerometer */ + get_common_features(&acc_feature.common_property, report_id); + acc_feature.accel_change_sesnitivity = HID_DEFAULT_SENSITIVITY; + acc_feature.accel_sensitivity_min = HID_DEFAULT_MIN_VALUE; + acc_feature.accel_sensitivity_max = HID_DEFAULT_MAX_VALUE; + memcpy(feature_report, &acc_feature, sizeof(acc_feature)); + report_size = sizeof(acc_feature); + break; + case GYRO_IDX: /* gyroscope */ + get_common_features(&gyro_feature.common_property, report_id); + gyro_feature.gyro_change_sesnitivity = HID_DEFAULT_SENSITIVITY; + gyro_feature.gyro_sensitivity_min = HID_DEFAULT_MIN_VALUE; + gyro_feature.gyro_sensitivity_max = HID_DEFAULT_MAX_VALUE; + memcpy(feature_report, &gyro_feature, sizeof(gyro_feature)); + report_size = sizeof(gyro_feature); + break; + case MAG_IDX: /* magnetometer */ + get_common_features(&magno_feature.common_property, report_id); + magno_feature.magno_headingchange_sensitivity = HID_DEFAULT_SENSITIVITY; + magno_feature.heading_min = HID_DEFAULT_MIN_VALUE; + magno_feature.heading_max = HID_DEFAULT_MAX_VALUE; + magno_feature.flux_change_sensitivity = HID_DEFAULT_MIN_VALUE; + magno_feature.flux_min = HID_DEFAULT_MIN_VALUE; + magno_feature.flux_max = HID_DEFAULT_MAX_VALUE; + memcpy(feature_report, &magno_feature, sizeof(magno_feature)); + report_size = sizeof(magno_feature); + break; + case ALS_IDX: /* ambient light sensor */ + get_common_features(&als_feature.common_property, report_id); + als_feature.als_change_sesnitivity = HID_DEFAULT_SENSITIVITY; + als_feature.als_sensitivity_min = HID_DEFAULT_MIN_VALUE; + als_feature.als_sensitivity_max = HID_DEFAULT_MAX_VALUE; + memcpy(feature_report, &als_feature, sizeof(als_feature)); + report_size = sizeof(als_feature); + break; + case HPD_IDX: /* human presence detection sensor */ + get_common_features(&hpd_feature.common_property, report_id); + memcpy(feature_report, &hpd_feature, sizeof(hpd_feature)); + report_size = sizeof(hpd_feature); + break; + } + return report_size; +} + +static void get_common_inputs(struct common_input_property *common, int report_id) +{ + common->report_id = report_id; + common->sensor_state = HID_USAGE_SENSOR_STATE_READY_ENUM; + common->event_type = HID_USAGE_SENSOR_EVENT_DATA_UPDATED_ENUM; +} + +static int float_to_int(u32 float32) +{ + int fraction, shift, mantissa, sign, exp, zeropre; + + mantissa = float32 & GENMASK(22, 0); + sign = (float32 & BIT(31)) ? -1 : 1; + exp = (float32 & ~BIT(31)) >> 23; + + if (!exp && !mantissa) + return 0; + + exp -= 127; + if (exp < 0) { + exp = -exp; + zeropre = (((BIT(23) + mantissa) * 100) >> 23) >> exp; + return zeropre >= 50 ? sign : 0; + } + + shift = 23 - exp; + float32 = BIT(exp) + (mantissa >> shift); + fraction = mantissa & GENMASK(shift - 1, 0); + + return (((fraction * 100) >> shift) >= 50) ? sign * (float32 + 1) : sign * float32; +} + +static u8 get_input_rep(u8 current_index, int sensor_idx, int report_id, + struct amd_input_data *in_data) +{ + struct amd_mp2_dev *mp2 = container_of(in_data, struct amd_mp2_dev, in_data); + u8 *input_report = in_data->input_report[current_index]; + struct magno_input_report magno_input; + struct accel3_input_report acc_input; + struct gyro_input_report gyro_input; + struct als_input_report als_input; + struct hpd_input_report hpd_input; + struct sfh_accel_data accel_data; + struct sfh_gyro_data gyro_data; + struct sfh_mag_data mag_data; + struct sfh_als_data als_data; + struct hpd_status hpdstatus; + void __iomem *sensoraddr; + u8 report_size = 0; + + if (!input_report) + return report_size; + + switch (sensor_idx) { + case ACCEL_IDX: /* accelerometer */ + sensoraddr = mp2->vsbase + (ACCEL_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) + + OFFSET_SENSOR_DATA_DEFAULT; + memcpy_fromio(&accel_data, sensoraddr, sizeof(struct sfh_accel_data)); + get_common_inputs(&acc_input.common_property, report_id); + acc_input.in_accel_x_value = float_to_int(accel_data.acceldata.x) / 100; + acc_input.in_accel_y_value = float_to_int(accel_data.acceldata.y) / 100; + acc_input.in_accel_z_value = float_to_int(accel_data.acceldata.z) / 100; + memcpy(input_report, &acc_input, sizeof(acc_input)); + report_size = sizeof(acc_input); + break; + case GYRO_IDX: /* gyroscope */ + sensoraddr = mp2->vsbase + (GYRO_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) + + OFFSET_SENSOR_DATA_DEFAULT; + memcpy_fromio(&gyro_data, sensoraddr, sizeof(struct sfh_gyro_data)); + get_common_inputs(&gyro_input.common_property, report_id); + gyro_input.in_angel_x_value = float_to_int(gyro_data.gyrodata.x) / 1000; + gyro_input.in_angel_y_value = float_to_int(gyro_data.gyrodata.y) / 1000; + gyro_input.in_angel_z_value = float_to_int(gyro_data.gyrodata.z) / 1000; + memcpy(input_report, &gyro_input, sizeof(gyro_input)); + report_size = sizeof(gyro_input); + break; + case MAG_IDX: /* magnetometer */ + sensoraddr = mp2->vsbase + (MAG_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) + + OFFSET_SENSOR_DATA_DEFAULT; + memcpy_fromio(&mag_data, sensoraddr, sizeof(struct sfh_mag_data)); + get_common_inputs(&magno_input.common_property, report_id); + magno_input.in_magno_x = float_to_int(mag_data.magdata.x) / 100; + magno_input.in_magno_y = float_to_int(mag_data.magdata.y) / 100; + magno_input.in_magno_z = float_to_int(mag_data.magdata.z) / 100; + magno_input.in_magno_accuracy = mag_data.accuracy / 100; + memcpy(input_report, &magno_input, sizeof(magno_input)); + report_size = sizeof(magno_input); + break; + case ALS_IDX: + sensoraddr = mp2->vsbase + (ALS_IDX * SENSOR_DATA_MEM_SIZE_DEFAULT) + + OFFSET_SENSOR_DATA_DEFAULT; + memcpy_fromio(&als_data, sensoraddr, sizeof(struct sfh_als_data)); + get_common_inputs(&als_input.common_property, report_id); + als_input.illuminance_value = als_data.lux; + report_size = sizeof(als_input); + memcpy(input_report, &als_input, sizeof(als_input)); + break; + case HPD_IDX: + get_common_inputs(&hpd_input.common_property, report_id); + hpdstatus.val = readl(mp2->mmio + AMD_C2P_MSG(4)); + hpd_input.human_presence = hpdstatus.shpd.presence; + report_size = sizeof(hpd_input); + memcpy(input_report, &hpd_input, sizeof(hpd_input)); + break; + } + return report_size; +} + +static u32 get_desc_size(int sensor_idx, int descriptor_name) +{ + switch (sensor_idx) { + case ACCEL_IDX: + switch (descriptor_name) { + case descr_size: + return sizeof(accel3_report_descriptor); + case input_size: + return sizeof(struct accel3_input_report); + case feature_size: + return sizeof(struct accel3_feature_report); + } + break; + case GYRO_IDX: + switch (descriptor_name) { + case descr_size: + return sizeof(gyro3_report_descriptor); + case input_size: + return sizeof(struct gyro_input_report); + case feature_size: + return sizeof(struct gyro_feature_report); + } + break; + case MAG_IDX: + switch (descriptor_name) { + case descr_size: + return sizeof(comp3_report_descriptor); + case input_size: + return sizeof(struct magno_input_report); + case feature_size: + return sizeof(struct magno_feature_report); + } + break; + case ALS_IDX: + switch (descriptor_name) { + case descr_size: + return sizeof(als_report_descriptor); + case input_size: + return sizeof(struct als_input_report); + case feature_size: + return sizeof(struct als_feature_report); + } + break; + case HPD_IDX: + switch (descriptor_name) { + case descr_size: + return sizeof(hpd_report_descriptor); + case input_size: + return sizeof(struct hpd_input_report); + case feature_size: + return sizeof(struct hpd_feature_report); + } + break; + } + + return 0; +} + +void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops) +{ + mp2_ops->get_rep_desc = get_report_desc; + mp2_ops->get_feat_rep = get_feature_rep; + mp2_ops->get_desc_sz = get_desc_size; + mp2_ops->get_in_rep = get_input_rep; +} diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c new file mode 100644 index 000000000000..70436f9fad2f --- /dev/null +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.c @@ -0,0 +1,324 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * AMD MP2 1.1 communication driver + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Basavaraj Natikar + */ + +#include +#include + +#include "amd_sfh_init.h" +#include "amd_sfh_interface.h" +#include "../hid_descriptor/amd_sfh_hid_desc.h" + +static int amd_sfh_get_sensor_num(struct amd_mp2_dev *mp2, u8 *sensor_id) +{ + struct sfh_sensor_list *slist; + struct sfh_base_info binfo; + int num_of_sensors = 0; + int i; + + memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info)); + slist = &binfo.sbase.s_list; + + for (i = 0; i < MAX_IDX; i++) { + switch (i) { + case ACCEL_IDX: + case GYRO_IDX: + case MAG_IDX: + case ALS_IDX: + case HPD_IDX: + if (BIT(i) & slist->sl.sensors) + sensor_id[num_of_sensors++] = i; + break; + } + } + + return num_of_sensors; +} + +static u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id) +{ + if (mp2->mp2_ops->response) + return mp2->mp2_ops->response(mp2, sid, cmd_id); + + return 0; +} + +static const char *get_sensor_name(int idx) +{ + switch (idx) { + case ACCEL_IDX: + return "accelerometer"; + case GYRO_IDX: + return "gyroscope"; + case MAG_IDX: + return "magnetometer"; + case ALS_IDX: + return "ALS"; + case HPD_IDX: + return "HPD"; + default: + return "unknown sensor type"; + } +} + +static int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata) +{ + struct amdtp_cl_data *cl_data = privdata->cl_data; + int i, status; + + for (i = 0; i < cl_data->num_hid_devices; i++) { + if (cl_data->sensor_sts[i] == SENSOR_ENABLED) { + privdata->mp2_ops->stop(privdata, cl_data->sensor_idx[i]); + status = amd_sfh_wait_for_response + (privdata, cl_data->sensor_idx[i], DISABLE_SENSOR); + if (status == 0) + cl_data->sensor_sts[i] = SENSOR_DISABLED; + dev_dbg(&privdata->pdev->dev, "stopping sid 0x%x (%s) status 0x%x\n", + cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), + cl_data->sensor_sts[i]); + } + } + + cancel_delayed_work_sync(&cl_data->work); + cancel_delayed_work_sync(&cl_data->work_buffer); + amdtp_hid_remove(cl_data); + + return 0; +} + +static int amd_sfh1_1_hid_client_init(struct amd_mp2_dev *privdata) +{ + struct amd_input_data *in_data = &privdata->in_data; + struct amdtp_cl_data *cl_data = privdata->cl_data; + struct amd_mp2_ops *mp2_ops = privdata->mp2_ops; + struct amd_mp2_sensor_info info; + struct request_list *req_list; + u32 feature_report_size; + u32 input_report_size; + struct device *dev; + int rc, i, status; + u8 cl_idx; + + req_list = &cl_data->req_list; + dev = &privdata->pdev->dev; + amd_sfh1_1_set_desc_ops(mp2_ops); + + cl_data->num_hid_devices = amd_sfh_get_sensor_num(privdata, &cl_data->sensor_idx[0]); + + INIT_DELAYED_WORK(&cl_data->work, amd_sfh_work); + INIT_DELAYED_WORK(&cl_data->work_buffer, amd_sfh_work_buffer); + INIT_LIST_HEAD(&req_list->list); + cl_data->in_data = in_data; + + for (i = 0; i < cl_data->num_hid_devices; i++) { + cl_data->sensor_sts[i] = SENSOR_DISABLED; + cl_data->sensor_requested_cnt[i] = 0; + cl_data->cur_hid_dev = i; + cl_idx = cl_data->sensor_idx[i]; + + cl_data->report_descr_sz[i] = mp2_ops->get_desc_sz(cl_idx, descr_size); + if (!cl_data->report_descr_sz[i]) { + rc = -EINVAL; + goto cleanup; + } + feature_report_size = mp2_ops->get_desc_sz(cl_idx, feature_size); + if (!feature_report_size) { + rc = -EINVAL; + goto cleanup; + } + input_report_size = mp2_ops->get_desc_sz(cl_idx, input_size); + if (!input_report_size) { + rc = -EINVAL; + goto cleanup; + } + cl_data->feature_report[i] = devm_kzalloc(dev, feature_report_size, GFP_KERNEL); + if (!cl_data->feature_report[i]) { + rc = -ENOMEM; + goto cleanup; + } + in_data->input_report[i] = devm_kzalloc(dev, input_report_size, GFP_KERNEL); + if (!in_data->input_report[i]) { + rc = -ENOMEM; + goto cleanup; + } + + info.sensor_idx = cl_idx; + + cl_data->report_descr[i] = + devm_kzalloc(dev, cl_data->report_descr_sz[i], GFP_KERNEL); + if (!cl_data->report_descr[i]) { + rc = -ENOMEM; + goto cleanup; + } + rc = mp2_ops->get_rep_desc(cl_idx, cl_data->report_descr[i]); + if (rc) + return rc; + + writel(0, privdata->mmio + AMD_P2C_MSG(0)); + mp2_ops->start(privdata, info); + status = amd_sfh_wait_for_response + (privdata, cl_data->sensor_idx[i], ENABLE_SENSOR); + + status = (status == 0) ? SENSOR_ENABLED : SENSOR_DISABLED; + + if (status == SENSOR_ENABLED) { + cl_data->sensor_sts[i] = SENSOR_ENABLED; + rc = amdtp_hid_probe(i, cl_data); + if (rc) { + mp2_ops->stop(privdata, cl_data->sensor_idx[i]); + status = amd_sfh_wait_for_response + (privdata, cl_data->sensor_idx[i], DISABLE_SENSOR); + if (status == 0) + status = SENSOR_DISABLED; + if (status != SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_DISABLED; + dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n", + cl_data->sensor_idx[i], + get_sensor_name(cl_data->sensor_idx[i]), + cl_data->sensor_sts[i]); + goto cleanup; + } + } + dev_dbg(dev, "sid 0x%x (%s) status 0x%x\n", + cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), + cl_data->sensor_sts[i]); + } + + schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); + return 0; + +cleanup: + amd_sfh_hid_client_deinit(privdata); + for (i = 0; i < cl_data->num_hid_devices; i++) { + devm_kfree(dev, cl_data->feature_report[i]); + devm_kfree(dev, in_data->input_report[i]); + devm_kfree(dev, cl_data->report_descr[i]); + } + return rc; +} + +static void amd_sfh_resume(struct amd_mp2_dev *mp2) +{ + struct amdtp_cl_data *cl_data = mp2->cl_data; + struct amd_mp2_sensor_info info; + int i, status; + + for (i = 0; i < cl_data->num_hid_devices; i++) { + if (cl_data->sensor_sts[i] == SENSOR_DISABLED) { + info.sensor_idx = cl_data->sensor_idx[i]; + mp2->mp2_ops->start(mp2, info); + status = amd_sfh_wait_for_response + (mp2, cl_data->sensor_idx[i], ENABLE_SENSOR); + if (status == 0) + status = SENSOR_ENABLED; + if (status == SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_ENABLED; + dev_dbg(&mp2->pdev->dev, "resume sid 0x%x (%s) status 0x%x\n", + cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), + cl_data->sensor_sts[i]); + } + } + + schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP)); + amd_sfh_clear_intr(mp2); +} + +static void amd_sfh_suspend(struct amd_mp2_dev *mp2) +{ + struct amdtp_cl_data *cl_data = mp2->cl_data; + int i, status; + + for (i = 0; i < cl_data->num_hid_devices; i++) { + if (cl_data->sensor_idx[i] != HPD_IDX && + cl_data->sensor_sts[i] == SENSOR_ENABLED) { + mp2->mp2_ops->stop(mp2, cl_data->sensor_idx[i]); + status = amd_sfh_wait_for_response + (mp2, cl_data->sensor_idx[i], DISABLE_SENSOR); + if (status == 0) + status = SENSOR_DISABLED; + if (status != SENSOR_ENABLED) + cl_data->sensor_sts[i] = SENSOR_DISABLED; + dev_dbg(&mp2->pdev->dev, "suspend sid 0x%x (%s) status 0x%x\n", + cl_data->sensor_idx[i], get_sensor_name(cl_data->sensor_idx[i]), + cl_data->sensor_sts[i]); + } + } + + cancel_delayed_work_sync(&cl_data->work_buffer); + amd_sfh_clear_intr(mp2); +} + +static void amd_mp2_pci_remove(void *privdata) +{ + struct amd_mp2_dev *mp2 = privdata; + + amd_sfh_hid_client_deinit(privdata); + mp2->mp2_ops->stop_all(mp2); + pci_intx(mp2->pdev, false); + amd_sfh_clear_intr(mp2); +} + +static void amd_sfh_set_ops(struct amd_mp2_dev *mp2) +{ + struct amd_mp2_ops *mp2_ops; + + sfh_interface_init(mp2); + mp2_ops = mp2->mp2_ops; + mp2_ops->clear_intr = amd_sfh_clear_intr_v2, + mp2_ops->init_intr = amd_sfh_irq_init_v2, + mp2_ops->suspend = amd_sfh_suspend; + mp2_ops->resume = amd_sfh_resume; + mp2_ops->remove = amd_mp2_pci_remove; +} + +int amd_sfh1_1_init(struct amd_mp2_dev *mp2) +{ + u32 phy_base = readl(mp2->mmio + AMD_C2P_MSG(22)); + struct device *dev = &mp2->pdev->dev; + struct sfh_base_info binfo; + int rc; + + phy_base <<= 21; + if (!devm_request_mem_region(dev, phy_base, 128 * 1024, "amd_sfh")) { + dev_err(dev, "can't reserve mmio registers\n"); + return -ENOMEM; + } + + mp2->vsbase = devm_ioremap(dev, phy_base, 128 * 1024); + if (!mp2->vsbase) { + dev_err(dev, "failed to remap vsbase\n"); + return -ENOMEM; + } + + /* Before accessing give time for SFH firmware for processing configuration */ + msleep(5000); + + memcpy_fromio(&binfo, mp2->vsbase, sizeof(struct sfh_base_info)); + if (binfo.sbase.fw_info.fw_ver == 0 || binfo.sbase.s_list.sl.sensors == 0) { + dev_err(dev, "failed to get sensors\n"); + return -EOPNOTSUPP; + } + dev_dbg(dev, "firmware version 0x%x\n", binfo.sbase.fw_info.fw_ver); + + amd_sfh_set_ops(mp2); + + rc = amd_sfh_irq_init(mp2); + if (rc) { + dev_err(dev, "amd_sfh_irq_init failed\n"); + return rc; + } + + rc = amd_sfh1_1_hid_client_init(mp2); + if (rc) { + dev_err(dev, "amd_sfh1_1_hid_client_init failed\n"); + return rc; + } + + return rc; +} diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.h new file mode 100644 index 000000000000..21c44990bbeb --- /dev/null +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_init.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * AMD MP2 1.1 initialization structures + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Basavaraj Natikar + */ + +#ifndef AMD_SFH_INIT_H +#define AMD_SFH_INIT_H + +#include "../amd_sfh_common.h" + +struct amd_sfh1_1_ops { + int (*init)(struct amd_mp2_dev *mp2); +}; + +int amd_sfh1_1_init(struct amd_mp2_dev *mp2); + +static const struct amd_sfh1_1_ops __maybe_unused sfh1_1_ops = { + .init = amd_sfh1_1_init, +}; + +#endif diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c new file mode 100644 index 000000000000..14a1578055b6 --- /dev/null +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * AMD MP2 1.1 communication interfaces + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Basavaraj Natikar + */ +#include +#include "amd_sfh_interface.h" + +static int amd_sfh_wait_response(struct amd_mp2_dev *mp2, u8 sid, u32 cmd_id) +{ + struct sfh_cmd_response cmd_resp; + + /* Get response with status within a max of 1600 ms timeout */ + if (!readl_poll_timeout(mp2->mmio + AMD_P2C_MSG(0), cmd_resp.resp, + (cmd_resp.response.response == 0 && + cmd_resp.response.cmd_id == cmd_id && (sid == 0xff || + cmd_resp.response.sensor_id == sid)), 500, 1600000)) + return cmd_resp.response.response; + + return -1; +} + +static void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info) +{ + struct sfh_cmd_base cmd_base; + + cmd_base.ul = 0; + cmd_base.cmd.cmd_id = ENABLE_SENSOR; + cmd_base.cmd.intr_disable = 0; + cmd_base.cmd.sensor_id = info.sensor_idx; + + writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG(0)); +} + +static void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx) +{ + struct sfh_cmd_base cmd_base; + + cmd_base.ul = 0; + cmd_base.cmd.cmd_id = DISABLE_SENSOR; + cmd_base.cmd.intr_disable = 0; + cmd_base.cmd.sensor_id = sensor_idx; + + writeq(0x0, privdata->mmio + AMD_C2P_MSG(1)); + writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG(0)); +} + +static void amd_stop_all_sensor(struct amd_mp2_dev *privdata) +{ + struct sfh_cmd_base cmd_base; + + cmd_base.ul = 0; + cmd_base.cmd.cmd_id = STOP_ALL_SENSORS; + cmd_base.cmd.intr_disable = 0; + + writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG(0)); +} + +static struct amd_mp2_ops amd_sfh_ops = { + .start = amd_start_sensor, + .stop = amd_stop_sensor, + .stop_all = amd_stop_all_sensor, + .response = amd_sfh_wait_response, +}; + +void sfh_interface_init(struct amd_mp2_dev *mp2) +{ + mp2->mp2_ops = &amd_sfh_ops; +} diff --git a/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h new file mode 100644 index 000000000000..ae47a369dc05 --- /dev/null +++ b/drivers/hid/amd-sfh-hid/sfh1_1/amd_sfh_interface.h @@ -0,0 +1,154 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * AMD MP2 1.1 communication interfaces + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Basavaraj Natikar + */ + +#ifndef AMD_SFH_INTERFACE_H +#define AMD_SFH_INTERFACE_H + +#include "../amd_sfh_common.h" + +#define SENSOR_DATA_MEM_SIZE_DEFAULT 256 +#define TOTAL_STATIC_MEM_DEFAULT 1024 +#define OFFSET_SFH_INFO_BASE_DEFAULT 0 +#define OFFSET_SENSOR_DATA_DEFAULT (OFFSET_SFH_INFO_BASE_DEFAULT + \ + TOTAL_STATIC_MEM_DEFAULT) +enum sensor_index { + ACCEL_IDX, + GYRO_IDX, + MAG_IDX, + ALS_IDX = 4, + HPD_IDX = 5, + MAX_IDX = 15, +}; + +struct sfh_cmd_base { + union { + u32 ul; + struct { + u32 sensor_id : 4; + u32 cmd_id : 4; + u32 sub_cmd_id : 6; + u32 length : 12; + u32 rsvd : 5; + u32 intr_disable : 1; + } cmd; + }; +}; + +struct sfh_cmd_response { + union { + u32 resp; + struct { + u32 response : 8; + u32 sensor_id : 4; + u32 cmd_id : 4; + u32 sub_cmd : 6; + u32 rsvd2 : 10; + } response; + }; +}; + +struct sfh_platform_info { + union { + u32 pi; + struct { + u32 cust_id : 16; + u32 plat_id : 6; + u32 interface_id : 4; + u32 rsvd : 6; + } pinfo; + }; +}; + +struct sfh_firmware_info { + union { + u32 fw_ver; + struct { + u32 minor_rev : 8; + u32 major_rev : 8; + u32 minor_ver : 8; + u32 major_ver : 8; + } fver; + }; +}; + +struct sfh_sensor_list { + union { + u32 slist; + struct { + u32 sensors : 16; + u32 rsvd : 16; + } sl; + }; +}; + +struct sfh_base_info { + union { + u32 sfh_base[24]; + struct { + struct sfh_platform_info plat_info; + struct sfh_firmware_info fw_info; + struct sfh_sensor_list s_list; + } sbase; + }; +}; + +struct sfh_common_data { + u64 timestamp; + u32 intr_cnt; + u32 featvalid : 16; + u32 rsvd : 13; + u32 sensor_state : 3; +}; + +struct sfh_float32 { + u32 x; + u32 y; + u32 z; +}; + +struct sfh_accel_data { + struct sfh_common_data commondata; + struct sfh_float32 acceldata; + u32 accelstatus; +}; + +struct sfh_gyro_data { + struct sfh_common_data commondata; + struct sfh_float32 gyrodata; + u32 result; +}; + +struct sfh_mag_data { + struct sfh_common_data commondata; + struct sfh_float32 magdata; + u32 accuracy; +}; + +struct sfh_als_data { + struct sfh_common_data commondata; + u16 lux; +}; + +struct hpd_status { + union { + struct { + u32 distance : 16; + u32 probablity : 8; + u32 presence : 2; + u32 rsvd : 5; + u32 state : 1; + } shpd; + u32 val; + }; +}; + +void sfh_interface_init(struct amd_mp2_dev *mp2); +void amd_sfh1_1_set_desc_ops(struct amd_mp2_ops *mp2_ops); +#endif