From patchwork Fri Mar 8 16:25:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13587053 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2057.outbound.protection.outlook.com [40.107.8.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59B8F5DF32 for ; Fri, 8 Mar 2024 16:26:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709915194; cv=fail; b=Hw2ZkkAU1Pae607JqDqOT3JitcMUHf5rg2u/7EjYVHkAFnqRKFJPWhaqAXowmxw1yvxUZSdqfqYeNCFxi56Sq0CGtl6Lb2ujD4oz8KVjEpTW8qx+QD9ILyvAZBVg3QzCdwQPfIrAaBu8HTlLaspzBxNHQRbFHqndDVECSHHLlm4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709915194; c=relaxed/simple; bh=qW3xZSPxV69HhCqaxH4lMTpKrUoMPbR7IONE/5QS6Vk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=PB5uuQi+EmJyFbNcII8FWUyrS5XpQ3aqQ87e2VmyNaeNATCDxnlwnJxP2oGkgKf2AIsLpWexrYbf1SpYxqQznuGRlMDegLaCRB9KcwwnIIsrcNJy+Oj5MgeMGjAfgwxY2TOGytX/ikW+ShLg3fvU4ALQ9Uh1SiLpLT204HpGFxk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=Pt33OXLp; arc=fail smtp.client-ip=40.107.8.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Pt33OXLp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b6refx98ULpLKSENe7K3w5V9KqhSyGQOLqDVTVqhXWlFmLMdBtG6EWmdKw4rjVRy4fMJn54KFrfcM1hfyEzN1SCTuTQs7lq0tBsZBPVTNtkmDlRHWi2Qm81A7nwWHG+c/XmdyyLgDtRNLjYGtf1IEMUMw1PpGvutO6f2yFNmjMW5i6oztq0CCbCEWkKRJZ3HxPKi8omM4Gs5QFx2roAxcVXNaYEGUD+aTmFn9+smVxxHOckIU8AP7ejeeM/Q1P9k5TIQStRFlK2VtvuaG9Bpon/Z8sXhqjQbv2y4Luw8YqEX+mcJy/hMZFE0qmRiMYB5XFOwozYs4ob2uVGnNzU8hw== 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=ZQsS+edj743bhozBXozfWNp9Q0DVTgEOxS7wIdnGQUfl7+kgrzp72mAAAT20p5DrOxVqqLwKZPA7iFGNvXdg4mLyhPrqkCTpChWjdAHTzUwpA62cCYMR86VlREzCv2Es0Uq3PcLGtpdzrkoTQL+sN+56R/QR/4BL0AD6f96yqVKWkQHCqjRKiQGL7QM3jcCB1dCZCfcCPBcBdnw9cPRqbl136IwTKQdBpzOloy49cYBypuCI97qy1Oljs+FxyvHL4P+61C3zr1SXGSXAgZEha5DZtlOebkg/RREJ20v6zFxkuNMqvnS3dtWK/Wp5w886fuiEVOWXBadMFxsf3tNjuA== 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=Pt33OXLp3Mz3/8ah66pPJ3gIkjHevRPMmpg9+edG3zg0WxEn3M6quHlPrVMefD6TsHQv1zK1e7i/+LMT8gb8ZCJvqVQOXmUpOyddpWCVxPgso4+Igy8++d1ZEpJWWwfErgMstLGKAqhogsnyBnwJ/+MYuP5l24h8TeTmOTH1i5Y= 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 PAWPR04MB9864.eurprd04.prod.outlook.com (2603:10a6:102:390::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.26; Fri, 8 Mar 2024 16:26:28 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6%3]) with mapi id 15.20.7362.024; Fri, 8 Mar 2024 16:26:28 +0000 From: Frank Li To: frank.li@nxp.com, alexandre.belloni@bootlin.com Cc: 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 v9 7/8] i3c: add API i3c_dev_gettstatus_format1() to get target device status Date: Fri, 8 Mar 2024 11:25:17 -0500 Message-Id: <20240308162518.1615468-8-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240308162518.1615468-1-Frank.Li@nxp.com> References: <20240308162518.1615468-1-Frank.Li@nxp.com> X-ClientProxiedBy: SJ0PR13CA0137.namprd13.prod.outlook.com (2603:10b6:a03:2c6::22) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|PAWPR04MB9864:EE_ X-MS-Office365-Filtering-Correlation-Id: 636bfc23-f5ce-438b-b7ce-08dc3f8c81b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vy4ESECLqL2+dM+73PBXpKR0MDMYG7M2nCDKZ8TthRNqSK+hZ4jdWCOK6yMB+ax85xN4SOW3pvUaeO1q9b5PguJpoUK6oREvhlUmSZfioge27f4Isas+SSQ9Pa072t0foElaDwEtIRqtujSAttt/OM7v+A5bNrkt/pfQYt0dB107OdBZo3YZb1zofnmVAZuPtPue58N5A0WN2S2InCHouQEOuslNKUtxrDYaOZKEQJWLbfHvsPRdSZRE5iQU0TSU8FBE5TazoxuV9N9LvRFTBL6vi2T3Ik2pzm75n36AQoSyKX8sOLhbSCsEuf0gsM8r7YS9WgqEPfe4A81wme47hP+HEWm3IKLXVapuQERhhbu4aoTOaQk3kc5XQDa1F3xerzY4GmasrE6gUYDLoplcLQDClhVls4nt5+WDub7KPQgb2vH/ceI/2UydyFurLgg/38MXAUMeEZe6l3cNgzVFPDISK7k15jXBeritCNxBEp+143Sb7wQdcn1a9/ZvatGdQHtpBIMFsTghxSp8tAi+iKX1byCYFmx+VRlBi4vdxI6zkR8sRaUqUxv5kCcbOoyZ8DkIvR5Q/tXWuohSdgvAyQZbF5mrPTFAJJaMcCyNbDR0FI0l0FF00l4D+CYJTtDI32QbkRrJJqanlTG3CQJzXXb91F3N62p+l1EL+pJpW6dZATYi9C8Pdp8JPMaTAvtD2FgCCimJLZJuZD4egxiDe1f7HoWEbkljgA392wpfK4A= 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)(1800799015)(376005)(52116005)(7416005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jn+vRoSDruetO9Ssm3oYyjw8w7/xERYQ026u6bICfIylPDPBACr/hDEBHaS8ia35OGlFVJZ1W6znQ2qQbCpLviRa4i6hNnuPN9DMwOLwvBxUOHHJcue2bEDkb32xhljC1T1ftvb2ivIOYcszNU2r9F7kgMlKYjfbhBGzzWHz1hEPwPlSW48RH/deDl8GgvuCxISbCHG187xtBzo8B0Z+AEaWDeJo+5XfCqie+dzcUGAXV/OKhwANVkDy+AzlRSY/lQoyl4EPj1NIP99KtWJ381cCVlJq6ALQnbKZC5FJxj58GmmqDCWiz8ZolerUi1MT2s3pJVKOuZLBgVPJPdPq2KxkT8/m4Fd48JZmHDBEHopvffdVHU83v3HmmOrOzGvaFGVDOQaSH5RZHu0H8y4Rc2bUTM/dh2uASRxJO/5NcB8FOIoQXw/IlG8sisnimWhv3YAt4+Ny/9WfOZAs/1K4cCkTrl/Ssrq0I5pyuBujuwjWR1QnLjBmYzK81saRCcbXKpDNuM5ly9UmcBIbsn5JBAC6eSgQPVQo6J4P89RxVsAedc4SJy6VUdBiPkib+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5ce-438b-b7ce-08dc3f8c81b3 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 16:26:28.5846 (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: iiTBssdwM0rQdYIUeTB7qMT86WaYZoqOlQX2pIyVuBP19mcsGgKMK2plcCNm27MJhEAyYYSV+u4R/p0lX44p1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9864 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 */