From patchwork Wed Oct 18 20:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 155176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6359:8089:b0:164:83eb:24d7 with SMTP id re9csp5082291rwb; Wed, 18 Oct 2023 14:12:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWcZeTqGL60jZjDtWJvZAfLhiX16fgBybvQBwrS4UG1uJ5chs8qVxvxecaDJmAxFnqUzyd X-Received: by 2002:a05:6870:b426:b0:1e9:b4b6:55d4 with SMTP id x38-20020a056870b42600b001e9b4b655d4mr675491oap.8.1697663573875; Wed, 18 Oct 2023 14:12:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697663573; cv=pass; d=google.com; s=arc-20160816; b=xQjo3myl5UJ/+yplDIspxRL7LY5NzFjIgQbLKpyBr+3tumG6FF+wCdKkVzNaUqcatV dDUkvQ1FSwtdzQOet3GboCaxGGQpGP4jjyWplnIRO8X1Gt29IYCJY3z1ZGgHZtEzSGpx LVnGyw26CU3rYVAIvmoeMEo9SLNTTOcBV7NW88UsxA95B2SCl5WOTVfvn6Ofi2H7CD+4 6LzLtmzkQmr3F4HbFSaWlVVi5fVUeira8fVlsYG1bhDW3YwzF47c3o/30yuPWdlDwy6g /7NLgvIKk1eh08EKhwr86LDHSX8JlTTa0z2SXrmDPIDB07w/wY0ayoALZeHZKP45di8w 3vsg== 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=pPWQn2l7iuQDprEGwbhMq6laPM8yM/hxK/Z8Bbastmc=; fh=sDe3TG6/b46JEOvF2xh0f1K4oYWCH8cpxTVfh1/w/G8=; b=OThuRNzOLURwk8pwJzlPwXurEhIOGnAKLqlpz1k/mIut7s9drbIJJp7ahMONnaBZo1 1h+ZeMMKKMxFtPL4FLz3o0H4ikAjTApZZL5n8z2jWmVWf6YUZlFAmcN15g9TBBklen8Q ZSIzj4EQeouWmhpvK3sEQiSyUXgezspEoMxBK81q+mKUtJFGVJp0OGzDntBGpXa55nDq neMtIwnJikMunGCQSNQb806Z8Wd8TvQmy7riCgTHYnvnY07zdbU/W9Nqvg17OgYBpI00 nAWlAfkaF2O+SvVvfWZBJNeU64LpXOoZUUnOkw7+W0HGWyqL6qkBXUJWieoDRmMFMXGh Fvtw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=D5WJ5I4p; 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 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id i191-20020a6387c8000000b005859b2d8d7asi2932555pge.4.2023.10.18.14.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 14:12:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=D5WJ5I4p; 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 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 023FF8208F08; Wed, 18 Oct 2023 14:12:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231894AbjJRVMc (ORCPT + 24 others); Wed, 18 Oct 2023 17:12:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235147AbjJRVMR (ORCPT ); Wed, 18 Oct 2023 17:12:17 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2050.outbound.protection.outlook.com [40.107.8.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4C1B1FFF for ; Wed, 18 Oct 2023 14:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z6Co+EHdWCanZ952ieyV9ceK7OTEHKBS/XL2zdqc/KQejQHz3YyFBIKDmGlvNkqXtw2/wTdJR0G0Nwdl9/ZRPVFg72CV/AkxnTQP+D1YC/w4mg9riJWIVvNv0ZizthOvD36uvv0/V6XzhnCikp4roA+bWENfZjGeHafjvHAab1fThmEGE5shHk5gY2s1iYVz4cOF2AXV4YYojOC2htkZriR1mKEMZlqRGO8iBiRHZwt0ZNcsh0cVdhFfXu+6/yrilO3/4c+xBhICO1YI/8EFQuD9CRAiZjXZ9SJQEzibGQ/BWQtFU9pH41Y/EOaXSH2dmdPHKxhK2tF6PhyqukhOTg== 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=pPWQn2l7iuQDprEGwbhMq6laPM8yM/hxK/Z8Bbastmc=; b=DLL20XYv/p6YV8lfZDC6isrRNpr5/rikRcHb+yG059cJpfiDLkvS/GlRJ0EBTHKAVEzu9ulW2ZW4/5A1mZUVUSt1M23YlT+TUZzirpmY38kPTcPKuRUpXaAqS3NaR2JEA7Z0RKrsCHqaV7GSMgJiFLaAoXuIp2stRNqnrkarilonBXHnqwC+JImaT0uzr/gmduCodWTcBHM5ZS4cm1cDFcmmMe6G1hdh8nXh3mdQPpyJ92+rm2G/LGH8ScWQ0KXZywEIHRbTk+yWVuwfVtpGK7GRfkE6+lgqrsr4Etr7AhfwnJd3mUia3Oxnm07t1nMmCENZfYrWjYo6+PLKbUXC2A== 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=pPWQn2l7iuQDprEGwbhMq6laPM8yM/hxK/Z8Bbastmc=; b=D5WJ5I4poDP9tr8NmTLdruEItVz1b/SI2Bz2I0+I3yIdge48PuBA7jAtkUdsQDVRLWTrzNcfl6FuK1H5arrG4y4B9iyLw/tn5NPLDZh4frYd+IlS8tBCnqNraR5/4YN3eKAFkzfXxSLgYekOX0HTeDsXH3UFZFVpH2IMV4EFoTw= 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 PAXPR04MB8653.eurprd04.prod.outlook.com (2603:10a6:102:21c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 21:00:00 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::1774:e25f:f99:aca2%4]) with mapi id 15.20.6907.022; Wed, 18 Oct 2023 21:00:00 +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 Subject: [PATCH v2 6/6] i3c: add API i3c_dev_gettstatus_format1() to get target device status Date: Wed, 18 Oct 2023 16:59:29 -0400 Message-Id: <20231018205929.3435110-7-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231018205929.3435110-1-Frank.Li@nxp.com> References: <20231018205929.3435110-1-Frank.Li@nxp.com> X-ClientProxiedBy: BY3PR10CA0027.namprd10.prod.outlook.com (2603:10b6:a03:255::32) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PAXPR04MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c3db509-38f8-4d00-57d2-08dbd01d3122 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eXmQsfiEaRccNqVQh1deWn23RsXQyikL6+sim2T8w9bQhFls8NLAJDglbF5WfbtTFcVZn40Wp+cVpzAtc4+p7EY5io/41gmgHCW0x08z8dS1usmUc3NfbAI4bj/3OiZXCXsygcyz/BhwsLJCdI7i0syqRf/IL72CxftF8mmY24wj2tq+0mv4XzD85zI0KlLtQGMRakGTgKZt2wTKs3+jjREYImMTINMROSX78pZ86eDQ2eF4hmKTJ4JtWnCV4StR6r7AhQOCjf9V0WhzNc/fAatau6uRuHlGDy8m/mM8I9U78Mr/wnKtqwz2fU5CCn89Ez94Yem1LPijVTRVuUOqsPwUi+CTBt5zOAGmUvIwXfA75WdtDJ3kTZq38Y2BZTgqL9eZDL0ovp3Qjfyd9aWouzbtu0aRfnD5Y287ft5P1pcaIvMbY79Vy+Q2zji0eiOPx7B0MckgwNYfisHpKY12t6qb+HrLqK3KdyHV9l4ViazRFo/jG88525G/EGiL9ZAi8WL9O+BuItxqfxSdxw8KVucbfPb8SxIJqCn8wESc3SOnqKT8YgsDWN0wOtDkJKo4UslyKZOZfGgIylZzjeRkX7u6WPgOtGMzzGRNC/hS2M58TwkuPdi4dZ6K86yXRoxq 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)(136003)(346002)(366004)(376002)(396003)(39860400002)(230922051799003)(1800799009)(186009)(451199024)(64100799003)(6512007)(6666004)(6506007)(52116002)(2906002)(4326008)(41300700001)(478600001)(38350700005)(6486002)(1076003)(26005)(83380400001)(2616005)(36756003)(66476007)(66946007)(6916009)(316002)(66556008)(86362001)(8936002)(8676002)(38100700002)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pyA8avBN0jzIr9wrq6Ug5HsLAEyQFXanSeryQFBVRncnx3YNWfatVkZnZsrw/yDYkYKgtSNXp/PaHf2h313s1DK9Ul4HFioxA6ph7baqxQeZOG858aF2ayGMtoslXIwf+BvA8bBJr52x5++zdyJfiQ+vvkCaouUwI/wOyYKLlBgTA0AKDxWZs1eO2xtZZszonTKDwU8AvYjamn6Dq9NpB73wUsDbI+xq8Q5kgepmn3KRLIWPGnbHldcynAxGpvcFVlM+r6BaVMlLvJwVqfwiyHW1PWft7kqz4JXBcA69vwaCwk5RHphyWSrU3qw+Nwb3JKMfFfMaXzZqP7QngG5T25lGBLmOXv2KQFgUWhJxfc9C76y9OxELDkzs8+uaz4ph2uAqtt8D7GLViQhRwPrhwkdA18O3YdvsIkt8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heCYF/u56cmG/y8saeWnPho6SxocmJ1stlaAhyDe6yAy9jl5TcDBAOhCvJdl88+E33f18XCAbth0NawMBmXNl8hCys9ghp42acDIOjf9iGphf8C X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c3db509-38f8-4d00-57d2-08dbd01d3122 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 21:00:00.1560 (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: 5I2nE/qVE0L5o6XYqNPnaTP8GIM483Fefzids26mpLkQK+4GD7Md7f+4MC2B1TU602AECzpXJpjbBpvYKs1qrA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8653 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 14:12:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780129279476762754 X-GMAIL-MSGID: 1780129279476762754 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 ed5e27cd20811..6a16ebdd180b5 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2924,6 +2924,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 */