From patchwork Thu Nov 30 22:44:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13475139 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB121C10F04 for ; Thu, 30 Nov 2023 22:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=emnljd2WCBniSALuy+PBECWnc595D+bLtYnpVNM0sts=; b=09kUB30QFETezt K7+03jABJ5rhd2Albgdnw6my4jqFbgqaSX3d4INY/Xs7md90fFhkIyHmv7mvgoSuzYSVB63LiAcBC 2R8C6jGVLIGUWwFqMyyWwdHAQToDSduZ8pdEgxUswKS+lfIGOC01+B7MLJQeTvtVZ9lpGrENwthL6 u+ssqqqVLZvfNVX1vc+gpDK82UeH7CeubTM9Ae84fEf0NJa4KrFFssN4Q7s+FCG+rPYKZmlt6rL1G OzofQFSpeYcPlWh2qOAmOyLdn3+1wgYA4Ql6aFAvCQj8Ki5jowc2q5zDp49JrN0/BBLVxH4wQhLEk ENNl975ZK+Bq93cCBtGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8pm9-00C5jc-1l; Thu, 30 Nov 2023 22:44:53 +0000 Received: from mail-dbaeur03on20613.outbound.protection.outlook.com ([2a01:111:f400:fe1a::613] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8pm7-00C5hS-1Q for linux-i3c@lists.infradead.org; Thu, 30 Nov 2023 22:44:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZMb7Px7DzGm9QuNHUBEX9n5hDyt7AyC9pO8rqyo2k/VHKkkrXS8dwUK/i1hY0x9/+quHRbAaBpkGra/EEAXC5N3s/spB7+oTrCbx+KXAZESlcDgbFCQqOTvOQ3EAmsjs/7+SUcGbBQxieWQ2DnP3LYoGlmW0/avoXtj1vTnERLY5C3vk2fkSxAKLWM4vq2ZqBFlNzv+JBbofT1ylJ8d0pmOTB0CHUN49mKolEG91prDUB23cdgs8JfT3argSRET8USlWFU3ivl1V+yMx9LS6HdCR8Wc6xgrUV0ewQ2ZHMu8cMXr8eGrKLkrMD9P5pbyI3mg9S20o+hewTWJN9yyuOQ== 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=b176R2RF531nL60YMogkuUjnlG8fVTLufS2yB0DChwk=; b=Uphf+0W7V52tqyJ0jV0X8M/q4FGFXshKfnLW/cNi8nqbT0xwFpshgMinKVN+Cm7k87+XXO01M1fWMfte/0kANzTkoTr16iqTlmwICj5DgYzzB/X+hlzZF+uIcnOhYyJfMvSXytFr+3I347KoR3xwu9OuhEUIgZ/hjr16uIYWMIz/6RM0O7ly+FNRiG0p/visk+5m5NOW8kl4LUoXspL/exkKdD3LoYPZN3/4G4FKmMvu2Evet09sGa6vP8oEo8M9mKxtLF87UtJqzD0dp3fFawGdQrGBWp8SDhaH4pQjHXUJcq9hB+utTTVsB95xtMVChqiGnRDgDZGmjpMVzOEcwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=b176R2RF531nL60YMogkuUjnlG8fVTLufS2yB0DChwk=; b=Zyoc8FVc8k4zF+Ke7WIqdZdcAZp68aLNeBh715zw15uvobKRzeaV+6rrT5n/Gf4NLWZ4GhcaZZjKtp9a9j9FxrW0CNXGWT2nPddZg5iH/OxRJuKiumOpPHO+ovb5BRRvg+qCp4B35P6b2Jiaa9oHWo3KmnxV+21Fj3ASMgLNlsU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by AS8PR04MB8851.eurprd04.prod.outlook.com (2603:10a6:20b:42e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.13; Thu, 30 Nov 2023 22:44:47 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40%6]) with mapi id 15.20.7046.015; Thu, 30 Nov 2023 22:44:47 +0000 From: Frank Li To: miquel.raynal@bootlin.com Cc: Frank.li@nxp.com, alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, zbigniew.lukwinski@linux.intel.com, gregkh@linuxfoundation.org, jirislaby@kernel.org, linux-serial@vger.kernel.org Subject: [PATCH v5 6/7] i3c: add API i3c_dev_gettstatus_format1() to get target device status Date: Thu, 30 Nov 2023 17:44:07 -0500 Message-Id: <20231130224408.3591288-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130224408.3591288-1-Frank.Li@nxp.com> References: <20231130224408.3591288-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR03CA0212.namprd03.prod.outlook.com (2603:10b6:a03:39f::7) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS8PR04MB8851:EE_ X-MS-Office365-Filtering-Correlation-Id: 665ac62f-6107-44b7-33e8-08dbf1f5f441 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EipFGbCe+nmVQaqLJq7GJQF1vUugZxSxnMKsAsCein/8HxgN6GuT9DYyoiuvrCRuBHp6Ls0WHdgKNYbx8XR4aCCT8rWRt1k3Q/oxfzq/3aLtbms8uFmTk508gBLQTdT0ehWWHmfD2iXKCuBiyqAW1t3ekfOMDnzJYQEwrshs1rNZmYf/JqdSQDQx0Rcq2gY4tUcjBo3p5i52DAcrXuUYqulRJ3e9pVwtKmpJglMmSApeCQzeH6XR6VTJA+4bxBCdv4Qbcato0qhh506WE37OJQN4jIbcgrPiT2x3rLRRggsDiHA8/KJFFGcpRkx2n8lA2BThqEPRaiq6XG8zrHaRen8FwuNA8rgZQIaKLHHQkGF/RX/K3gtgIpS6qZJcJptYaEclrmBXgiWe4S3iUsaS0zn6Uigjn81qP8mCnknmA5qFX/vNaFFUjCY4V/02ZUraDuYKAZSBo/f5kiJTHy2+KxfjvKMolNfdeEfw7g/TdUCQ8PMslKrRKH14pwf4KUJJhHri7RFGj7Oak1Zj7BTgZgXHSoM7CIi3IK86ZuyDMCmWyVl0+G1uNKcGBq31qt+qtYjeSN0WSos4fOB0ogC4Lht4XzjIMwhW0u8jnxugZDUtf77azBJMXRvyAzPYC46JSitGHNTu4HnTh7ERtjVne6bqkPmMld3tN/Q2bsNEpb8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39860400002)(396003)(136003)(366004)(376002)(230922051799003)(451199024)(1800799012)(186009)(64100799003)(86362001)(6512007)(5660300002)(36756003)(41300700001)(6506007)(38350700005)(8676002)(52116002)(478600001)(2906002)(6486002)(6666004)(26005)(83380400001)(7416002)(2616005)(1076003)(4326008)(8936002)(66946007)(6916009)(66476007)(66556008)(38100700002)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xsIVPO4ryE1EDW+4eDeYpj+Rgy6oxzxfNz5a+kI7N+peOTR5xKZHQmhcc/axrL1oReMFwc4sl3oecU3tuJW4DNN0sBlVbPl5RplCiJY3zKuoKoN4y8tpzUF2yQcNi1Q0TZcOzsAD7fqi+NoeOxevljjb1VaaSsz8xUiZw5tauVgCS9s8LXGVlwD8pmxO0F+Am/W/7kc2EyLHd6FltMZESmHcVx085JHwE/0fPs6NJKBUcXbC2QJP4DwhBZONcJO81lWsRpuJUCE4x0B2FrCWQSY/C4PJ5fNUAEckGSYr78oU3ezkgiJ/tbmTokfZGxgLTQbE0Ih07h03QocrdmAFdAkvkmyFRbIIKO9jyqomXWOXFRiCD83/mcVo//CtDdznqckHVp6zMr0bgMPxrsWDqlBNixI36QLJt9bLBn1Lui1BGvur8ZgvTMR2uTHzadVizcvZnxbEeiHExJHCZHrWLOP294zy+j/X379N6xuo5p9R/U39mEVZT/MoRbbHN7BFWuY/wZClX3Wx4Jz/o1eWPT9HyiN9FqIAv/OLMMwy5bjvyT9mV4p5pjjeO+W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-33e8-08dbf1f5f441 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2023 22:44:47.1601 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kolQr8cS0D6vUzch39fsfxOl4FR2bFMRJnMpwtoWgbEAqcOM6Gi5wXDz6AZmVDToo5F5FNitSX0XegRUpfBkpQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8851 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231130_144451_682365_B033E981 X-CRM114-Status: GOOD ( 13.05 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org I3C standard 5.1.9.3.15 Get Device Status (GETSTATUS): Get request for one I3C Target Device to return its current status. Add API to fetch it with format1. Signed-off-by: Frank Li --- Notes: Change from v4 to v5 - none drivers/i3c/device.c | 24 ++++++++++++++++++++++++ drivers/i3c/internals.h | 1 + drivers/i3c/master.c | 26 ++++++++++++++++++++++++++ include/linux/i3c/device.h | 1 + 4 files changed, 52 insertions(+) diff --git a/drivers/i3c/device.c b/drivers/i3c/device.c index 1a6a8703dbc3a..aa26cf50ab9c6 100644 --- a/drivers/i3c/device.c +++ b/drivers/i3c/device.c @@ -196,6 +196,30 @@ void i3c_device_free_ibi(struct i3c_device *dev) } EXPORT_SYMBOL_GPL(i3c_device_free_ibi); +/** + * i3c_device_getstatus_format1() - Get device status with format 1. + * @dev: device for which you want to get status. + * @status: I3C status format 1 + * + * Return: 0 in case of success, a negative error core otherwise. + */ +int i3c_device_getstatus_format1(struct i3c_device *dev, u16 *status) +{ + int ret = -EINVAL; + + if (!status) + return -EINVAL; + + i3c_bus_normaluse_lock(dev->bus); + if (dev->desc) + ret = i3c_dev_getstatus_format1_locked(dev->desc, status); + + i3c_bus_normaluse_unlock(dev->bus); + + return ret; +} +EXPORT_SYMBOL_GPL(i3c_device_getstatus_format1); + /** * i3cdev_to_dev() - Returns the device embedded in @i3cdev * @i3cdev: I3C device diff --git a/drivers/i3c/internals.h b/drivers/i3c/internals.h index 908a807badaf9..976ad26ca79c2 100644 --- a/drivers/i3c/internals.h +++ b/drivers/i3c/internals.h @@ -24,4 +24,5 @@ int i3c_dev_enable_ibi_locked(struct i3c_dev_desc *dev); int i3c_dev_request_ibi_locked(struct i3c_dev_desc *dev, const struct i3c_ibi_setup *req); void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev); +int i3c_dev_getstatus_format1_locked(struct i3c_dev_desc *dev, u16 *status); #endif /* I3C_INTERNAL_H */ diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index d3b56c9f601e2..81611a3e3585a 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2923,6 +2923,32 @@ void i3c_dev_free_ibi_locked(struct i3c_dev_desc *dev) dev->ibi = NULL; } +int i3c_dev_getstatus_format1_locked(struct i3c_dev_desc *dev, u16 *status) +{ + struct i3c_master_controller *master = i3c_dev_get_master(dev); + struct i3c_ccc_getstatus *format1; + struct i3c_ccc_cmd_dest dest; + struct i3c_ccc_cmd cmd; + int ret; + + format1 = i3c_ccc_cmd_dest_init(&dest, dev->info.dyn_addr, sizeof(*format1)); + if (!format1) + return -ENOMEM; + + i3c_ccc_cmd_init(&cmd, true, I3C_CCC_GETSTATUS, &dest, 1); + + ret = i3c_master_send_ccc_cmd_locked(master, &cmd); + if (ret) + goto out; + + *status = be16_to_cpu(format1->status); + +out: + i3c_ccc_cmd_dest_cleanup(&dest); + + return ret; +} + static int __init i3c_init(void) { int res; diff --git a/include/linux/i3c/device.h b/include/linux/i3c/device.h index ef6217da8253b..5f511bd400f11 100644 --- a/include/linux/i3c/device.h +++ b/include/linux/i3c/device.h @@ -345,4 +345,5 @@ void i3c_device_free_ibi(struct i3c_device *dev); int i3c_device_enable_ibi(struct i3c_device *dev); int i3c_device_disable_ibi(struct i3c_device *dev); +int i3c_device_getstatus_format1(struct i3c_device *dev, u16 *status); #endif /* I3C_DEV_H */