From patchwork Wed Nov 29 22:12:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13473582 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 44FADC07CB1 for ; Wed, 29 Nov 2023 22:12:55 +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=szeLe5NUEg6R1SGNN/H1a+UCrHF4GiFGr5ccTYUz96c=; b=2DO9PCSJLnp5fh GirDm4h5l5l+Ajo2Mdj6+8WhggApTtL9j0Yf+pnQsvVQzmaHKxXVWu2/3rRCm7fBNMiayitNrC0TS dhHzRer+uDJhV57U+OiQ9FkagBZuv5lfSWRcmp9f4IEgzohy6WaYftJSu1IC9YXruIXuov5SLQQnq 0l3TF2kDQ+4v5qQZBLHuDTn2HMrUseNNo4PmCUqMIU00bbzHi43yICC/VSwKp3EwOn8gHH3Y277Ib SSJISfsLBcjlaZOmRaPhgCPDdPrjl4X8RN2G01Vhn5bfPzIrwGDowvB7waSuVOEu2dt/NGxVt87iz mlghphSqVeZ38/B7kY7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snf-009PZU-01; Wed, 29 Nov 2023 22:12:55 +0000 Received: from mail-am0eur02on20621.outbound.protection.outlook.com ([2a01:111:f400:fe13::621] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r8Snc-009PYC-1I for linux-i3c@lists.infradead.org; Wed, 29 Nov 2023 22:12:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E6AuFl7HL60izem5MOw0aNv4ZIYzrepqbcoDusqE65B2rUxrJGOFFQlO8bU1Vw7qqEyan3RG+hxe0MShWjSDR97QsqRD3+UOuTZ9wwcMyvNKm6ipODs6iP5H4JUIua5xKFNXGgqxY7RTEkGXP4NVI0J6V/Imx3nmXrRkZWJJeNfCDRKHCPHgC/INmV82sNxlHBseZCRykrSUq2wuRkHhcYQJggIJt4rUq2REiCsggt21bz5GQtk8qSN1llEesGR8Y/jLPFnSpZGckxBUANh6yDIomGH1EwL2IbhnqrgFr/dj9t1QaX3wAUeDuZQx1kEsdXipZcokGiBsTO81qRdFqw== 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=sDlf4xSFouG1bOinSyyY0+9HL8i98T9MXvpDH0ZtEyI=; b=NhvNVmfRClD2Th/UrKVNq4aesI6+SRik/7BeduKRjE5Bc8l04FAbpTx7Nr2l2fE8DcsnBBBsevCapYTAJ0yiKxQ1mAmnUkOqSSvxA3teyPyq+F4IE976/5mbF9nxYEiQuD6XEWGb+8RV1m3KU5pYICisWiRqcOXQKbUWq2MNmUZX83rT71EwWm5YkhmRvQVZOfB9FxaIXUlMUnAcBEAWbX1g4/ybWM2ho1yXFVqKDS7T2WfJnNxHgwd4uPigiO2/wDE39cnBgR5fMAOU9Cb+31W6EsyO52+XcqhYqdSAlNxuQMKpOrAX1x9j6nT+jgEB82+w9C2IYOiNDLKRIQikfg== 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=sDlf4xSFouG1bOinSyyY0+9HL8i98T9MXvpDH0ZtEyI=; b=pXgpmX5Ss+DIwAcDeTt2lXV7dzR0kRBsBeBVza52enzdrESUD4pIzzfdvW0YUgL5XVDoQxPLj8dRqKnTPuFhXx4VrpPI2JT3iIvbycdigXf16vh8TK1ji4azu2fzn6YZciBnVmmTx+c+QM5D1grsHEJPF7V80Hr4WfQs0f6tJmI= 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 DB9PR04MB9578.eurprd04.prod.outlook.com (2603:10a6:10:305::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.21; Wed, 29 Nov 2023 22:12: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; Wed, 29 Nov 2023 22:12:47 +0000 From: Frank Li To: alexandre.belloni@bootlin.com Cc: Frank.li@nxp.com, conor.culhane@silvaco.com, imx@lists.linux.dev, joe@perches.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org, miquel.raynal@bootlin.com, zbigniew.lukwinski@linux.intel.com Subject: [PATCH v4 1/6] i3c: master: add enable(disable) hot join in sys entry Date: Wed, 29 Nov 2023 17:12:20 -0500 Message-Id: <20231129221225.387952-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129221225.387952-1-Frank.Li@nxp.com> References: <20231129221225.387952-1-Frank.Li@nxp.com> X-ClientProxiedBy: BYAPR04CA0003.namprd04.prod.outlook.com (2603:10b6:a03:40::16) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DB9PR04MB9578:EE_ X-MS-Office365-Filtering-Correlation-Id: c56aadeb-5476-4a4b-b5ec-08dbf1285164 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8T6UvqL72rIyTUg8dN18HgG6jDUJ66471hzNfWi4rBAHBtNeLEKaY8n5ysIqoWKvFyobVzmWIUrQda1xeS8ocov9vEInA7GRhL4+gpQQ3ESgMfSoRxP+N63iGKxtyArluV/7aDb9qQBPT02SmvBC7v3sDQhwdzFo6jeeXUiQR0uwmhNdGfveagwGTOYIeRIhfGpyU67YxF7Rt/uFbgwH2u2NZg+BkhrYr0nKJhaDn0062/IA8fjLZMYQoQx21OaMltLyxX7Z54e4XU+5ehLr9nE5tt5HXyVmlFZqNeKYPUPvl/03d6k1n6M+aF/Fv8rMnvWFdJiJOX6zZn6ZvLxfT7QRhUUPrpvxQuOvdp8/ivler5JknE5G8MuTNic2GjIWfns6H+3RRFBoNC6XYWhdN/QvqRzcWFyOutWPMXczMZ4QCDDKEopKdWbKe3PepGeP7npQPkh0RkLxssy6sGd0WvH4cu+1UzRUHMNVUhwq/8UZYVhuY8ec9Dl9nAgAAyMLC5KRjDetiKaKA51FmwTKZ6uCuDGlzz5fM0sLMgRTAbKJK0SJxAZEFPl2K7nRN0MSa5Qb4dIoSZu/aTsDdwofoNQox/HOHfByTUq80ywDDdfL6wt40q+PdUgiysL1SQL+yWnRaAkMeGeAt0aAUyukS8XTqzl3qHXXchMGKgFp4uVKezoYhERa8mPpDKBMzCFm 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)(366004)(39860400002)(136003)(346002)(376002)(396003)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(202311291699003)(38350700005)(36756003)(2906002)(41300700001)(5660300002)(86362001)(6666004)(6512007)(52116002)(83380400001)(2616005)(1076003)(38100700002)(6506007)(26005)(316002)(66476007)(478600001)(6486002)(8936002)(66946007)(8676002)(66556008)(4326008)(6916009)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KFsGWnNOwltynlexzi5u2ESBFmm4iqjE1fDffTCeku7zK4UrrwfCnqGemHSdXw1rDaQk1lm+zk2LiAd8xro07rPGryobO051Tz6i71AO8/JuATTbvc9VPjwyx+1S+Aqfm2jmf7y3grf7yWOEr2HYHDoJMIn9CD2izXqENzae1bi+GdXEdGBPYgdT+OkqCUVQiR5xm7KY5C4cWr+ikVXfO9a+g7V9iYt6SrRnfSeCjluJaruffc+5lhbqkn88Lu67jNfjWNtvlJkjT+KaoABfnuV1/WLAr9oYPuZ4cIZnuoZoyUdOcxmxqXQZ7Q1cQ01lXe+Ct8MjrpJgXSrk7v8daSuzwxFj8L9jy6UCQqhNxdSEbs3oa3QRapJVO3Ateskb2hPvtUYy5oscULCtj1K2jHrgVX3L4ocbOeKroLlkho9r8+FOgOaXRT6RRTTnVzdjIIlsQTTnaSED+vwQdPh9t/yRi4mjG6zwB9hPYdd+KCGCMuLg6l/u8INj+q1UV1RWR2zDzXsxP8IoPbp2Mgh2tnfJ0H90WmKoFOI4zSoferkl7U6s59bIgcM+HBhrsjuFrOyuqcswszFw5UWwOqW8Tfahhjk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-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 22:12:47.1334 (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: /g/ITY229ayTGX/TLiZUaYMzBUSjufNblxgFEyJ/f8Qwh6gN2WQjjkTbOxy/eikPE7640u0sATSk7r7wOZEhyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231129_141252_441058_3542640E X-CRM114-Status: GOOD ( 12.45 ) 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 Add hotjoin entry in sys file system allow user enable/disable hotjoin feature. Add (*enable(disable)_hotjoin)() to i3c_master_controller_ops. Add api i3c_master_enable(disable)_hotjoin(); Signed-off-by: Frank Li --- drivers/i3c/master.c | 84 ++++++++++++++++++++++++++++++++++++++ include/linux/i3c/master.h | 5 +++ 2 files changed, 89 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 08aeb69a78003..ed5e27cd20811 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -526,6 +526,89 @@ static ssize_t i2c_scl_frequency_show(struct device *dev, } static DEVICE_ATTR_RO(i2c_scl_frequency); +static int i3c_set_hotjoin(struct i3c_master_controller *master, bool enable) +{ + int ret; + + if (!master || + !master->ops || + !master->ops->enable_hotjoin || + !master->ops->disable_hotjoin + ) + return -EINVAL; + + i3c_bus_normaluse_lock(&master->bus); + + if (enable) + ret = master->ops->enable_hotjoin(master); + else + ret = master->ops->disable_hotjoin(master); + + master->hotjoin = enable; + + i3c_bus_normaluse_unlock(&master->bus); + + return ret; +} + +static ssize_t hotjoin_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i3c_bus *i3cbus = dev_to_i3cbus(dev); + int ret; + long res; + + if (!i3cbus->cur_master) + return -EINVAL; + + if (kstrtol(buf, 10, &res)) + return -EINVAL; + + ret = i3c_set_hotjoin(i3cbus->cur_master->common.master, !!res); + if (ret) + return ret; + + return count; +} + +/* + * i3c_master_enable_hotjoin - Enable hotjoin + * @master: I3C master object + * + * Return: a 0 in case of success, an negative error code otherwise. + */ +int i3c_master_enable_hotjoin(struct i3c_master_controller *master) +{ + return i3c_set_hotjoin(master, true); +} +EXPORT_SYMBOL_GPL(i3c_master_enable_hotjoin); + +/* + * i3c_master_disable_hotjoin - Disable hotjoin + * @master: I3C master object + * + * Return: a 0 in case of success, an negative error code otherwise. + */ +int i3c_master_disable_hotjoin(struct i3c_master_controller *master) +{ + return i3c_set_hotjoin(master, false); +} +EXPORT_SYMBOL_GPL(i3c_master_disable_hotjoin); + +static ssize_t hotjoin_show(struct device *dev, struct device_attribute *da, char *buf) +{ + struct i3c_bus *i3cbus = dev_to_i3cbus(dev); + ssize_t ret; + + i3c_bus_normaluse_lock(i3cbus); + ret = sysfs_emit(buf, "%d\n", i3cbus->cur_master->common.master->hotjoin); + i3c_bus_normaluse_unlock(i3cbus); + + return ret; +} + +static DEVICE_ATTR_RW(hotjoin); + static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_mode.attr, &dev_attr_current_master.attr, @@ -536,6 +619,7 @@ static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_pid.attr, &dev_attr_dynamic_address.attr, &dev_attr_hdrcap.attr, + &dev_attr_hotjoin.attr, NULL, }; ATTRIBUTE_GROUPS(i3c_masterdev); diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 0b52da4f23467..65b8965968af2 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -452,6 +452,8 @@ struct i3c_master_controller_ops { int (*disable_ibi)(struct i3c_dev_desc *dev); void (*recycle_ibi_slot)(struct i3c_dev_desc *dev, struct i3c_ibi_slot *slot); + int (*enable_hotjoin)(struct i3c_master_controller *master); + int (*disable_hotjoin)(struct i3c_master_controller *master); }; /** @@ -487,6 +489,7 @@ struct i3c_master_controller { const struct i3c_master_controller_ops *ops; unsigned int secondary : 1; unsigned int init_done : 1; + unsigned int hotjoin: 1; struct { struct list_head i3c; struct list_head i2c; @@ -543,6 +546,8 @@ int i3c_master_register(struct i3c_master_controller *master, const struct i3c_master_controller_ops *ops, bool secondary); void i3c_master_unregister(struct i3c_master_controller *master); +int i3c_master_enable_hotjoin(struct i3c_master_controller *master); +int i3c_master_disable_hotjoin(struct i3c_master_controller *master); /** * i3c_dev_get_master_data() - get master private data attached to an I3C