From patchwork Tue Sep 5 21:38:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13375082 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 5DB20CA100D for ; Tue, 5 Sep 2023 21:39:14 +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: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:In-Reply-To:References: List-Owner; bh=s1F19S6giGXAPH2BJKXqt+QVwKF9WRw/0GCwbRoOQ8M=; b=QTcilRlWDxiBJv UugGFgg6/SWivN5FzH7DQExpXLs1uZNnawG+VXF0f3oEvvhY88D9WflSWOq0sZ4QBJeVkA8YCFZ/S IjRIzqrrMeQO7xSitKaQxVt8n/84eDeXx+Dn4s5ittIJg5yrns7SJiHt/syT1hlivtDGNlI8KnQsq u1zxfvil9aMFNWillDqPMfpmY+TvRP0CfCkcpRytfD9mI80tVkP739P0c/iI0S6FHHtCkxcSFMr0q 4ZhPyQ5Jbvrp3JQD8K5BTTMclWstS4mXTgyWqz365UjoRvatTOvRkWk6FZVijosfjIe/joPGKLQkm 58VUWNw0oLfQTYujh8pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qddlR-006lgz-1o; Tue, 05 Sep 2023 21:39:13 +0000 Received: from mail-db3eur04on061b.outbound.protection.outlook.com ([2a01:111:f400:fe0c::61b] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qddlO-006lfI-2x for linux-i3c@lists.infradead.org; Tue, 05 Sep 2023 21:39:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Va2E0GQIybVUzIv5aOb0MMIE1FefYdSOgZXWfhv1njQRAJ/nZb9FRnJ5wwhDeBO5MKAdO+Tm31NYqvfOZcS4z0RG1TMvSOBYxfp37ToRunTtcRO/d0p0zjJsxGEmyBuDQuQvdcQu1y7iZ+irOUmOSStLb+hyGFac5sSDxrntgUewVpIqu/eBMqL/QkMMJLWww63i6hgX+05qg5jkNsTtQtoDLPmvq2PtYHtcf80QxiRLnmFNsaqwtr6tfE5PtESze76mlQ+j0eIdmmiUtGxHWeHz/UE7bLkVVPfayAHhUhWdWTdBNnpa2+BU1HpAtFtta9KspLixSRFr8NmvHo4H3w== 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=X/Y4ExIQBpO0Ngmmd9S2zE/fnFMalwtsaWy3Pad3xwQ=; b=GvhfzJblTCp9YDi0+j7jA08pOdioFaf33O2rwkn/cVhYaMadQtAjjSJnszRDr2CRW38fl38RospMWl89A24jzs0WIrjrSFmOZP0Ra0vvhmUE4Y3PoxFZSa75j8c60+H/r6Go9HLuigIdQzozL+avCCD6uKS4rmDNZH4r4NuHU5VuBK4LFlVCxgAmEZFS8GDy05XLa5s//PYyavMTRW6fG+RQPb6v9KDF55o8yU8jJ1osgSLaTSnxXPNUAfLi0bxV5xaHTpoILMDfH7IVoB7odRg9lMkVo3P6eNVEhrwb7sxy0h7wyQ/RlJQ781aAJ/AGwt+er6MOeOZcmvlsBVu/YQ== 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=X/Y4ExIQBpO0Ngmmd9S2zE/fnFMalwtsaWy3Pad3xwQ=; b=qL+JTt806DORPgGc2wObwnoURf9fnhMS+2w156PGABWv17xLCNTc7Etc1q0q1dpft54g40aZQKFcoEV7azfpMBgCnXuacDTy3i9A0oxDM7EGU/H6V7jqJ3z3NOCJHoqGWO+2tMA0X7LcYG5dWIRmGa5h6CpwSRIraUZtunblB7E= 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 PAXPR04MB9256.eurprd04.prod.outlook.com (2603:10a6:102:2ba::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Tue, 5 Sep 2023 21:39:01 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::aa90:117d:c1d0:346a]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::aa90:117d:c1d0:346a%3]) with mapi id 15.20.6745.030; Tue, 5 Sep 2023 21:39:01 +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, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 0/9] I3C Slave Mode support Date: Tue, 5 Sep 2023 17:38:33 -0400 Message-Id: <20230905213842.3035779-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR03CA0215.namprd03.prod.outlook.com (2603:10b6:a03:39f::10) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|PAXPR04MB9256:EE_ X-MS-Office365-Filtering-Correlation-Id: ccac1e4b-b698-4e30-526b-08dbae588492 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pzLMgTQXxFTE/kxDN5PRUN/RlVKSPsorJZTsj5PXXV7mTKTXDj6V3odvRwBKPRIpHG3pJkAO2BzjohA41aVPQ3w0ZADjG1IEDFPl0ft6eXTsuNi38g36UqOm2qFyuiFCG2F4Bg1/tEMUGApxDFr8oyM3Qf0DhS6cPZ5/Jh4vtPGgLUU5y0J+jYdDMfbqBmkHnzBFtVo+kyt4A+JVijAhtkG+D06kyYzCI/lWXftpo1hK00ppEfMVaVEoLrWFzhK9ar9HbifOzq4ZvzqfFhab9ryG4hacyPfTafF+03eAuyi9YDV4RtHQzb4Go37NU9EsjSFH7PnnzbF4fPD9kGJ2SvhWPcBOLSK22/Z0QRJbM7eYK1JiSyX99nh28KYYULIIRYZAXS9itqKMkuS3ne9ELdpLo6TXkilwR4Tt7GjZpJplSKhMshbQ7bB+EhcvpqQ/sVCG+6erm8+xi65NJ3UpBmAtSZVadl1xFsABvNNI+v7LuoMtnKkv6vrZeEG9HebiMZ32LtDscaECgqz6yzsRW2dpkhXZ7SPoWxB1DyyDC1WEObvoWZxjQZO/lEZJmvdfVwoUfo7YuHpWjeVQq1dTRXqAlWk/mbdLWdV7vi+/MGcBp+0TEVkYGzsVLvWavViU 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)(396003)(376002)(39860400002)(366004)(346002)(136003)(186009)(1800799009)(451199024)(2906002)(83380400001)(6486002)(52116002)(6506007)(6916009)(316002)(66946007)(66556008)(66476007)(478600001)(26005)(6666004)(5660300002)(1076003)(41300700001)(8676002)(8936002)(6512007)(2616005)(4326008)(36756003)(38100700002)(38350700002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Oq/xZ9OKIG9g1YtSNyBvmzdUfBJ5?= =?utf-8?q?2AfQbn1efoNqFnoiVN+lg7DxBgYRfru1Yt2ImHkDOrSdHV301CQim++3lvIvZESha?= =?utf-8?q?074vWJLYTbC1JYM4UcCXbJ2MEw+6ZkhVQT3+wXxJX2peYiC0O60mMN9DQX4WB3RbM?= =?utf-8?q?TdWcDHonNTTmfW0M7ZrzeDoOJOTLKS7xA6O+u4GTXfiOlVh2nQExy6hNfCW7fJM7P?= =?utf-8?q?SkxB8v3V/kC9wPopo8g2JM/GzKIuAMftITmFLbpB9MOnEX5Rp6DVB7f07fZGjFliQ?= =?utf-8?q?mtJHFZ1rsrVrivtZyRSG7bhAVuM4tfpS+9RhPshH1wIFMeBpM4mdDs0pnxiply2ST?= =?utf-8?q?ACQRumguW519naErxSMGqUsR1toBfrhd9ygkEhd4yLQXqBClmO9WtzOINRe4h2eFB?= =?utf-8?q?L5csAyTE7jd6NPwAybx+7BHsS9qpnvHlSFd08c9uAl7+nL58HLFBh8n+b934gZjEx?= =?utf-8?q?2LOfY0ZRNpQsHRoakk5xWqdB68lhN1eyT8NRydvGIDIZeCNwc9sZhptNBMuU6CxfL?= =?utf-8?q?72W3V9N1bvlsPk7zZfpjLYd7U8xeQo1IKvFjdo6mA5JybXeqLNmgDQP1IFp+GTYoS?= =?utf-8?q?Yjm65GSefxUnL6+QOoqKMdRcgY1tCSfk8HHH/ILx3lB7QRX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kKxhyRRxmrpaVouZGiF?= =?utf-8?q?ZJ9ZMvMdjmSz?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccac1e4b-b698-4e30-526b-08dbae588492 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2023 21:39:00.9123 (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: yPSXPbexU+FUb6qENTpSKTP/FXK10jvJcCmPmdPKhqfPEh3xO2xK9CjqQKW14WNjM4JpvvzpK1k9wtQoYcPn7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9256 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230905_143910_978456_0120C3B3 X-CRM114-Status: GOOD ( 13.62 ) 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 This RFC patch introduces support for I3C slave mode, which is referenced with a PCIe Endpoint system. It also establishes a configuration framework (configfs) for the I3C slave controller driver and the I3C slave function driver Typic usage as The user can configure the i3c-slave-tty device using configfs entry. In order to change the vendorid, the following commands can be used # echo 0x011b > functions/tty/func1/vendor_id # echo 0x1000 > functions/tty/func1/part_id # echo 0x6 > functions/tty/t/bcr Binding i3c-slave-tty Device to slave Controller ------------------------------------------------ In order for the slave function device to be useful, it has to be bound to a I3C slave controller driver. Use the configfs to bind the function device to one of the controller driver present in the system:: # ln -s functions/pci_epf_test/func1 controllers/44330000.i3c-slave/ Host side: cat /dev/ttyI3C0 Slave side: echo abc >/dev/ttyI3C0 These patches have not full implemented, especially at tty driver side. But it does not impact to review i3c slave part, especially data transfer and configfs. Frank Li (9): i3c: add actual in i3c_priv_xfer i3c: svc: rename read_len as actual_len i3c: master: svc return actual transfer data len dt-bindings: i3c: svc: add compatible string i3c: silvaco,i3c-slave-v1 i3c: add slave mode support i3c: slave: add svc slave controller support i3c: slave: func: add tty driver tty: serial: add tty over I3C master side driver Documentation: i3c: Add I3C slave mode controller and function .../bindings/i3c/silvaco,i3c-master.yaml | 7 +- Documentation/driver-api/i3c/index.rst | 1 + .../driver-api/i3c/slave/i3c-slave-cfs.rst | 109 ++++ .../driver-api/i3c/slave/i3c-slave.rst | 189 ++++++ .../driver-api/i3c/slave/i3c-tty-function.rst | 103 +++ .../driver-api/i3c/slave/i3c-tty-howto.rst | 109 ++++ Documentation/driver-api/i3c/slave/index.rst | 13 + drivers/i3c/Kconfig | 30 + drivers/i3c/Makefile | 4 + drivers/i3c/func/Kconfig | 9 + drivers/i3c/func/Makefile | 3 + drivers/i3c/func/tty.c | 345 ++++++++++ drivers/i3c/i3c-cfs.c | 361 +++++++++++ drivers/i3c/master/svc-i3c-master.c | 52 +- drivers/i3c/slave.c | 441 +++++++++++++ drivers/i3c/slave/Kconfig | 9 + drivers/i3c/slave/Makefile | 4 + drivers/i3c/slave/svc-i3c-slave.c | 600 ++++++++++++++++++ drivers/tty/serial/Kconfig | 6 + drivers/tty/serial/Makefile | 1 + drivers/tty/serial/ttyi3c.c | 276 ++++++++ include/linux/i3c/device.h | 1 + include/linux/i3c/slave.h | 458 +++++++++++++ 23 files changed, 3109 insertions(+), 22 deletions(-) create mode 100644 Documentation/driver-api/i3c/slave/i3c-slave-cfs.rst create mode 100644 Documentation/driver-api/i3c/slave/i3c-slave.rst create mode 100644 Documentation/driver-api/i3c/slave/i3c-tty-function.rst create mode 100644 Documentation/driver-api/i3c/slave/i3c-tty-howto.rst create mode 100644 Documentation/driver-api/i3c/slave/index.rst create mode 100644 drivers/i3c/func/Kconfig create mode 100644 drivers/i3c/func/Makefile create mode 100644 drivers/i3c/func/tty.c create mode 100644 drivers/i3c/i3c-cfs.c create mode 100644 drivers/i3c/slave.c create mode 100644 drivers/i3c/slave/Kconfig create mode 100644 drivers/i3c/slave/Makefile create mode 100644 drivers/i3c/slave/svc-i3c-slave.c create mode 100644 drivers/tty/serial/ttyi3c.c create mode 100644 include/linux/i3c/slave.h