From patchwork Mon Feb 5 23:33:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13546433 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 DD18BC4828D for ; Mon, 5 Feb 2024 23:34:19 +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=tUdBuPBo+nhI1Jtr6ojtSVPTP652e2lm7MhCTe9+Mj8=; b=S3Tl4crNYIS1iY tp10c5nOKgH1kgPsAawYs6pzpRw6NDIG4EjCdz0f7QzEJjCzeEYS95SsIbtvWfcpoPITX6D1xA6qU tAZJr9Dnr9U2lAp3UpUE9Ez4ijbIgIMLnlvHzElSWY56MlmFHEpEtuPmw0/fGE4Dv6e1Hn11cqxcC XbebjOvKM9YNXQYeiRFXLkBaq/RbEzz2OfJTfZ4Vozd4Le5YEJreCbkmzcYBxM4rEquWCN7s+UOKj OVpOeu5mLZE8X/1PE1Evl5PIKVl5q1Xa+Ux1hmSzwXBERN4ETuQOmcOYbxhquZkZSa4SdaDybZyz1 OUfu8+AOQ+gs6sYxOdWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX8Tj-00000005ZA8-2NHo; Mon, 05 Feb 2024 23:34:19 +0000 Received: from mail-he1eur04on20601.outbound.protection.outlook.com ([2a01:111:f403:260f::601] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX8Tf-00000005Z4q-3l7t for linux-i3c@lists.infradead.org; Mon, 05 Feb 2024 23:34:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CuFN4GCyNXhcfOzsSG4dpv4IK+WftmZJTnba5orX8Z/ZSaf85emO1laYo5bXNoQ9e8WzJtHyP2VMDCy75FoQkKC1CI5IdTfGmEhChZXU+fXZpt677OfNW5jKV2dHOanUz0VLtgOQ08Xs8fGMed0G43c42SkGXcx9AtHjyDKbRFxyg1TVknmvc0QiGuZfFGwPx2cu/aMYR5kZ4s2o09lV47WsL1VFGvEV+HJRUZxfjKr6gV6PuENUvz+cfax4yzlRY+RgfEOVJan6744KESfrHXlE+J6WhtPxV5MscdKV4XLpez2ANYdS4dLCGM2u56NQotGmT7rlqW51atEtaY8V8Q== 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=m6ARtUV31Aw0WkrJm4RAXeC+QYXs6+F2YjWwVs9OYOM=; b=Dp+Vx+zmiIwuhH63to4Aj7jHLYAxLIbpna/ZHxQBVngUNUFAMUinTRBWf7HWT/kPsVUWUNHqdh2AJq9D0byE+m745JkyrS5AjZJ+V+tm0wR9HhpliQjquUf+NLvObqyNE/3w1iLsvKuw3ZqXVnURrL6X5iWDgLJQwLQEwJZv3sEBDf7QTA2HyNEiE8VsKgyt0QaiTBEMpI0NCacXuoj9GQPQb9oWchuqrmnSsx4+Ub6RnY2BBbu5sfxkDVzJQBzyw3mGkK/aRAIUD7WG7h2vSLXFywxi6h0mwwR5ydF4VEMIw/AD52RyEJG3x5C5fAJu8JdVsZBbArsKyCjkektTfw== 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=m6ARtUV31Aw0WkrJm4RAXeC+QYXs6+F2YjWwVs9OYOM=; b=pk1pQImRT4Lsj32rDUI3o5KyEJYqubChH/XzaPHnCQhmEMnvvfacxUf2g9OC0LUWKImefCajXsjc9qYTjHwiF/rfhwaczXTi9fpLXbHvNqDy8uBt8l1KMbwhTfNx0h18cx6FyFeXwW/WRTIxzbkj+S340gTeeUYJSoXV2yLhupA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AS8PR04MB9205.eurprd04.prod.outlook.com (2603:10a6:20b:44c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.34; Mon, 5 Feb 2024 23:34:12 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7249.032; Mon, 5 Feb 2024 23:34:12 +0000 From: Frank Li To: frank.li@nxp.com Cc: alexandre.belloni@bootlin.com, conor.culhane@silvaco.com, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, ilpo.jarvinen@linux.intel.com, imx@lists.linux.dev, jirislaby@kernel.org, joe@perches.com, krzysztof.kozlowski+dt@linaro.org, krzysztof.kozlowski@linaro.org, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, miquel.raynal@bootlin.com, robh@kernel.org, zbigniew.lukwinski@linux.intel.com Subject: [PATCH v7 7/8] i3c: add API i3c_dev_gettstatus_format1() to get target device status Date: Mon, 5 Feb 2024 18:33:25 -0500 Message-Id: <20240205233326.552576-8-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240205233326.552576-1-Frank.Li@nxp.com> References: <20240205233326.552576-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR02CA0005.namprd02.prod.outlook.com (2603:10b6:a02:ee::18) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS8PR04MB9205:EE_ X-MS-Office365-Filtering-Correlation-Id: 67880ca9-1b3f-4f63-cccf-08dc26a2f538 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E+qIA56m5lvApYF+o1o7GBfoj5UmdHfUteXKzQRE+xbjNIHyNj3ZqFeRDh/Ds3kS7FJ/DGEFuB7BiZGvKGm7MHnhcsmds75+VDzIWFjG+uKwPMAq++RJWfp/uPXuO7NIYGcASny3FAeaSpHfdSkGm4KdEvb46JYJQdFNWJNoBmS+xsQhd4Sa02xfPTyVyVX6oyD3T/WstcEav+jZDkbZhXI9OCAVk0uSmsr2FNwS0ttCOPmAL1FCZEHDb/8FJiP9Q0IGJT+3RcQldSBPuCWCrsfbin0vWY8FxyMOZ926/GcC/xoGT75fzWgB27u2ohAiBW91OfScPASlE0K/XsiYcynLdeCeTtAgB57jdKEHuewlCjX9R3+wJnABaUE1XVw7+yhc4ZQFkU5N9cyS9gzHD44e7mLypIxAhsjzFNVebkCh7Y25ahp4NGFM4wALyYV7Vd1U7POo4p2+S2/h2ZHm6h4LSIIGGpGpc4XavlwIcsUPT9hOmFB9mU6gm9kzGes9x+3aJg+JI2v4B1aGocVsHpZhpXzsdfKvXHizH+K4pgIzsPxfTiBySEH6kIhP2E00glChrf9MNNU//2FebOTYEnkTCtil8+EtFUOHlc46HA/1GbUjuVT18XNbjmcBPR4h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(346002)(396003)(376002)(366004)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(1076003)(2616005)(26005)(86362001)(41300700001)(7416002)(6486002)(5660300002)(2906002)(38350700005)(316002)(37006003)(66476007)(66556008)(66946007)(478600001)(8676002)(34206002)(4326008)(8936002)(36756003)(6512007)(6506007)(52116002)(6666004)(38100700002)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rFCbeAkN54O3jnosWw7KLYVF0OFEC9DV7zX7xw/bvZ/0jL+Jmu4Ak7iC30sRKzjX+loBuo9XQt04UgKK4kqYXkl04ttaRUgXboHjLYlbeTmOIT6GcuYhJbrpzDIrF2/C7tMrSIEuf3F55sF2wgG4R7H5UNXiUuvRdMIYO0xTTup4NV5g4UJkLk3vk1b0oxqNNIHACgAb8j4sqQn/p9Wkhh2LKAxvnU0UW0V1BfHSb1fxlXlgRg3AdI+nKjjIHi74R/i0PN5hZzygSdPVM4UH24tgXuONOD6jwENFYuGDeOrDl+tppC5Emp3voNP2X9G2MtAlIF4SyqEKHzbpptqXwbInQ59bAyKmClPsIFYb/FJvVX8QYx0uh7pzsGZEooAK32Mbf+TfM0rlbPghwvrPfSx9uUfE4uOFCplI+ykXZatMmQXassfnHqxR53Q+LghljuaPB8r6+q5YgJodGiK/rkIPZhLulN0sSUyAeQWbSBzNkWDEIGBk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8PnUAuKooct7/Tbij4entc X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67880ca9-1b3f-4f63-cccf-08dc26a2f538 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2024 23:34:12.1734 (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: VT0CkpdGr+d8b2i+GWI792D7AUxxnR719i7RE5dcEKGiPJo+eJUNRvHcgXoRixFRolvXeOptv4SWF5Vu7mp4wA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9205 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_153416_001187_F9A43D55 X-CRM114-Status: GOOD ( 11.66 ) 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 --- 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 3afa530c5e322..ff61a218bcc6d 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2988,6 +2988,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 e119f11948efe..66920045ff042 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 */