Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp652368rdb; Thu, 30 Nov 2023 14:45:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuN+1DNWsxs3BGuBjN47fSxqsKf5MsFICvmT42s5WVrTTT3U6mNYf2J2RSnPXRoTE7IuYn X-Received: by 2002:a05:6358:2911:b0:16d:f743:4107 with SMTP id y17-20020a056358291100b0016df7434107mr26640365rwb.3.1701384320016; Thu, 30 Nov 2023 14:45:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701384319; cv=pass; d=google.com; s=arc-20160816; b=rh3HP5g7fzODWogErnskRKFNQKuiBOJMmEzuQi6McQ9tFxeJHNJTVcu1LoAF9lFWpL EJZ3pSiS1oP/bl4aUNgSn/c4lW8i1GE3/YVltUyUeoPz8jUot7RC3Hp8jNGBzaOz5Ub6 wMKDSPfQ3gcycjQS20h2TCp/KN08V20rRJtDQAZg+wy4vJWrLv+W86T3lZTe+7tc/n83 RDOiLABcgxoyIpxCOWkz53JaFV6Q0Wv0RPfqi5KwNJ3FenDYt8K40i8XC9c4IWEdMo7l Id0ctAGUKzntaOOJ3ylTa9B0uPcfOaGNDi4BWckzJcQ8OEKSWurl9IOWP5hJfZBl+E2Y I4Bg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b176R2RF531nL60YMogkuUjnlG8fVTLufS2yB0DChwk=; fh=QvVwebdT3bZrKTDGKDPwLZCEAMRt3rGnWnj1XEkRwgM=; b=AuwlI+elSbXABWseakdzYWB1cDmEMMdLUwBJEqFJJsHm1q8nt2BtS33X2lMGlzb/AU db4QOHVJ/3WSg3RC+Se1/XdDOmQ6ZYinpu4Qz8luRdfxZ70ecvNEcg7o/Sr9nBDA7U1U BlaQ8XgGX3pVdB0EgP3dyqhVQglKML4D7dYrXuCfe1DrfZO/9pOM/lbj28ITWDIOp+0x ngG5VgAqBt3AwTU/3qaxX5gmoJHxiDg9z3HrAhl0FUgbgzR3e/LH1tSE2pouWn3LP7OA pb+yUExCqaFWhqIlPKwTJNvTDF1ng5jBOs2uCX49sAATk6N/nYMRabJzwwQSB11uafNX Tehw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Zyoc8FVc; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id s26-20020a63525a000000b00578fe1bdfcasi2249904pgl.860.2023.11.30.14.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 14:45:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Zyoc8FVc; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DA6F6808D4BE; Thu, 30 Nov 2023 14:45:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377212AbjK3Wos (ORCPT + 99 others); Thu, 30 Nov 2023 17:44:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377228AbjK3Woo (ORCPT ); Thu, 30 Nov 2023 17:44:44 -0500 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2063.outbound.protection.outlook.com [40.107.104.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E8161731; Thu, 30 Nov 2023 14:44:49 -0800 (PST) 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> Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: =?us-ascii?Q?xsIVPO4ryE1EDW+4eDeYpj+Rgy6oxzxfNz5a+kI7N+peOTR5xKZHQmhcc/ax?= =?us-ascii?Q?rL1oReMFwc4sl3oecU3tuJW4DNN0sBlVbPl5RplCiJY3zKuoKoN4y8tpzUF2?= =?us-ascii?Q?yQcNi1Q0TZcOzsAD7fqi+NoeOxevljjb1VaaSsz8xUiZw5tauVgCS9s8LXGV?= =?us-ascii?Q?lwD8pmxO0F+Am/W/7kc2EyLHd6FltMZESmHcVx085JHwE/0fPs6NJKBUcXbC?= =?us-ascii?Q?2QJP4DwhBZONcJO81lWsRpuJUCE4x0B2FrCWQSY/C4PJ5fNUAEckGSYr78oU?= =?us-ascii?Q?3ezkgiJ/tbmTokfZGxgLTQbE0Ih07h03Qocrd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qiUNsYNPFeJ97InDXMNTtBu0/5NtEtqK1qUfxRCAtgzssE+zAziOhr?= =?us-ascii?Q?xSPdklo845QxWVMwlQ9vENiROPBcc8EZ8t4C317rRrBawq3WYD9z7aMJj5tM?= =?us-ascii?Q?6o7b0SVDZZBZTU88ngXOLgOekjj2gxxzNSf6zaO/kToCaDcy3cICRpREN54M?= =?us-ascii?Q?GYWdQjkTREme91Fmc4e/jfmBx719ijnproyS1MhO4h8rKM7bg/sU9fh9hhBH?= =?us-ascii?Q?c/+D+vnr5lUNjuErDQv2ZMhNE2BKmsupcbdQfKGxkJkdJNE7EJVpSPuc1yXM?= =?us-ascii?Q?EsZB273ZKXRwDDZPOQgq8y0qnaDYOOPl6eXcba8UN0kNcwL34woTAmg47neK?= =?us-ascii?Q?KHYbMQ0uQfr8VU7oO5kLIB3wyev65VQiebBRAuNB?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 665ac62f-6107-44b7-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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 30 Nov 2023 14:45:10 -0800 (PST) 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 */ -- 2.34.1