From patchwork Tue Jan 23 21:25:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13528155 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 2A13AC47DDB for ; Tue, 23 Jan 2024 21:26:27 +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=WDDhAxErp4f2vYdiQstsc9yThULAkiJnQBD3yAteFkA=; b=Xc0I7L1/xa6+x+ WZ99hrpq8Cu56xVvA/idAV/E9rkAttQ/wf/0z3PjUccKZLyTTVIW3ZFMkJypFUPkB/KredE73YkWm 0zlNpCnWUews5FUIytwRX/2v4HzCzL3w+1hk7h3NN/FbwEXmiMe8JWoi0/vdYDetp2gojtHlQPrOp tKZb2CB29nyfGcGkndcD0gTOkrPaMCKHTp+e0gSTJo2A1XBiSO/SgsB6YqdqS71gSpvixmRqraXNv GIGUuDLQNHpSHokNfkG0FCBZ4oAKDkHtQLhGrDC7WzTrDRlCHpOUBZncWDqRviwC889Yfv0ONPmpz k+t4T259LOuiK+L9Dw8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSOHq-000WVX-0F; Tue, 23 Jan 2024 21:26:26 +0000 Received: from mail-vi1eur04on0600.outbound.protection.outlook.com ([2a01:111:f400:fe0e::600] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSOHn-000WSP-0Y for linux-i3c@lists.infradead.org; Tue, 23 Jan 2024 21:26:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CRZD4goYgpH+Xv25EDrEuv5+aQx3MSgTTlz/lBSsI4sO+8Z8j7ep4V14lNsfTeMnUJymflcuucGC1Z7qlHt5HfB7DobhaEYZZQAngdVcZGZ8ngtrTAw3BkLYO+hTsZrnx96jm6IjjzULVCxuutiiud+sKcZc0y37s56X57OY/iIkXolrGZERHv8pZXFkzG+EZTtu9BNcAsF+BVPyCxGG+zzjGjdXfdXlzztbGDOXitKcHdXImYBZsJSzLhEMtThcT291Pcz7lPE8P+9yzSQQM1DR0DnLtgxRMeJJ76BZfwpSHVixLee9r9KFfjge+rBWCkSoPBiIQLAWlq7xQa7lkA== 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=XMAF6N536AjPAoovcp+vXEnKbjyZDtfqPFMlyEUT7Z8=; b=Mx6kp8UZvfuag8oIGKDShquVKUku4A2bZWbrDGgMj9OmiWmyWm9Rs698LiKnSzynz+bDXxL1ds896gIJ6BwobPkPOtYETYTET+qHBb4NAesRTDToQn/Bbl1gzZ4Sqk4AEwvliupAEh3ppB75Gv6Q7Tewyc5Ruwvdqp+Ml/vu7IzuNPLmsAnYjrrpTWPU1AwoDxAaBdPEgHWmMXHQjRBxcR4fi2lqFQAiGjwbMm2FLiAh9O35fXYt/z89Do0M4mGYMiFJvSpiyGpcMqTlEHMfNll6DSgZwa8KarR+xOfBBBSzQqydVN6+YQsTYb+1fdgYCK/6L3xp34Ki+dJKUxBwug== 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=XMAF6N536AjPAoovcp+vXEnKbjyZDtfqPFMlyEUT7Z8=; b=SxWssYbkW3rtCLtOjSFohmUfogsbQfjKNP3t/pcylQ2GmwWpxvkOXoKEHqU3KpNMAiRCtmIXP7g/Rc2Dga0orv/mR7fVcaDaMkTeoobbfOvTwWx3+vNiNhx0tdlN15B6Z6m0UQhU4FyW6EVQXz1Upt+nAbLGEKfohV24JWw7VOA= 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 AS5PR04MB9873.eurprd04.prod.outlook.com (2603:10a6:20b:672::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.29; Tue, 23 Jan 2024 21:26:07 +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.7202.035; Tue, 23 Jan 2024 21:26:07 +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, 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 v3 0/8] I3C target mode support Date: Tue, 23 Jan 2024 16:25:41 -0500 Message-Id: <20240123212549.3858137-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SJ0PR13CA0081.namprd13.prod.outlook.com (2603:10b6:a03:2c4::26) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AS5PR04MB9873:EE_ X-MS-Office365-Filtering-Correlation-Id: 28f454af-528e-4764-e912-08dc1c59e91a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CYVpKZc//fpWql6Uu8phA/GYL7G91jwpkl0jym/M+G4zU6W1z4Xps2O4CriKr/gXVTwwAf/MKTpX2fwB1g9kuzOy64u47iOz/QM8kYLJk5V8ub13eA+lpnHmb6Q9P11QGl/Bu5Ic6jiR9vGVMhR7MI5YArNbEauNK5F5xdyB2KxAzrDbEM422onj47Q0chGe/rLFIsB7nzn1R46/twhXfBtVMASkQzBvE0PnhwQd8v9SCJdJEIykB3uhxoNW//UJkJogAPeFW5jDqKQaeSDpTWpXjNY9wQ3ZjI+B4UtdAv8Q/czePeIPaZHzxVOdhdb1DnE8TpGgLiScx2y2X3kv1ZlzoujokZ+VYzVCU8VH2j1R6ic0wpOo+rRVemrXzlBc+6yZJBrbbgX8yq0cTFTx/4sheunMOAfyJAPlK8N2ags2TqbPUTnKpdLxom5Dk6wwmpQxmPEhtdqNw4fRBvMPH0ghmYcEQdB9mbZnxGQxaR7Pr6rr5w6iCZrMWCiWuWPyUd970HZe8Tvk8YJkedJiQDRixprCRgoz1miVXeVehGd0bKLvvJ+bNJCY//B2I+s5vdYKsKzfLR9KckoPQB73JWNw7U8BuBEAOrcp3ODO0Qw7xNzhlKnFXJhheuFCyMw7DR4185FmgfzQsbUTMWkbXTu/BL7WINH00m8wE9OD3sA= 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)(366004)(136003)(376002)(396003)(346002)(230173577357003)(230273577357003)(230922051799003)(451199024)(186009)(1800799012)(64100799003)(38350700005)(34206002)(316002)(52116002)(2906002)(6506007)(66556008)(66946007)(37006003)(26005)(5660300002)(6486002)(7416002)(66476007)(4326008)(478600001)(6512007)(6666004)(8936002)(2616005)(1076003)(38100700002)(8676002)(36756003)(41300700001)(83380400001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KBGyHXyDFYximBU0QSDdvK0qMh+EJbP1sI/MQCt1D1JMYl3o6QY1lH5Y04qQJA/HxzUnaN995SJobsYdzZRlcVHBi+eTsuoAUv/Cmx1a279B7V70/vHuo8vItlonRppa0iD0kP8mH+IBJW5rt6Jq+KsR6eRBkrZU46r078WkdMSNs1D1EfateIO9zGJFuGtBGTTy0m75jav/+xpkSynRgDY4LFIWt8JPpv/zsv80C/8q+2s+1lXdOhKC0660x9trQeR2rPWlpSPD6eE3VEYX3wFYKPOgCjZ0O5EOodvOlcY3LsJw6xAoMrYS4ywarcYgg3qe3tyjJXWn6wtfY6IngOWU9EdH/o+1tc6mBcqXI1RFBx1fGerTBFQ/ZSl23mtJM9Rgd3C4n3kO+qqQLUULvcA6GbhanPgf0WcJ3pNJBXhi1DoY4pGElI+yExj+/qYWniPTvq+VW3kgqDU4aD7VG1A3SEEPwoCVX8OkoqeUIKyOAaCuki2knqAK4c58GaiwEZOuGVzcCt3OTK6b/NE3vQFncYidNgQMtTga0aREwP+x+CrTOFbim2DHtgLOSPN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-Id: 28f454af-528e-4764-e912-08dc1c59e91a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 21:26:06.9688 (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: 5gw8eSm+WbDb4/JShbVuMMyPeOOH3aT2hMDCmfM2PaoK0lOXaiKoU+8B0arIuXXq7ZhshvK8iarvOuEBlFJs7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB9873 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240123_132623_214302_545C7F72 X-CRM114-Status: GOOD ( 15.06 ) 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 patch introduces support for I3C target mode, which is referenced with a PCIe Endpoint system. It also establishes a configuration framework (configfs) for the I3C target controller driver and the I3C target function driver Typic usage as The user can configure the i3c-target-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-target-tty Device to target Controller ------------------------------------------------ In order for the target function device to be useful, it has to be bound to a I3C target 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-target/ Host side: cat /dev/ttyI3C0 Taret side: echo abc >/dev/ttyI3C0 Chagne from v2 to v3 - using 'mode' distingiush master and target. - move svc-i3c-target.c to under master, - built together with svc-i3c-master.c Change from v1 to v2 - change "slave" to "target" - include master side tty patch - fixed dtbcheck problem - fixed kerne-doc check warning Some review comment may be lost since it is quite long time since v1. Now master side dependent patches already in linux-next. So sent target side patches with tty support again. No sure why an additional "\r\n" appended. Frank Li (8): i3c: add target mode support dt-bindings: i3c: svc: add proptery mode Documentation: i3c: Add I3C target mode controller and function i3c: svc: Add svc-i3c-main.c and svc-i3c.h i3c: target: add svc target controller support i3c: target: func: add tty driver i3c: add API i3c_dev_gettstatus_format1() to get target device status tty: i3c: add TTY over I3C master support .../bindings/i3c/silvaco,i3c-master.yaml | 11 +- Documentation/driver-api/i3c/index.rst | 1 + .../driver-api/i3c/target/i3c-target-cfs.rst | 109 +++ .../driver-api/i3c/target/i3c-target.rst | 189 +++++ .../driver-api/i3c/target/i3c-tty-howto.rst | 109 +++ Documentation/driver-api/i3c/target/index.rst | 13 + drivers/i3c/Kconfig | 31 +- drivers/i3c/Makefile | 3 + drivers/i3c/device.c | 24 + drivers/i3c/func/Kconfig | 9 + drivers/i3c/func/Makefile | 3 + drivers/i3c/func/tty.c | 475 +++++++++++ drivers/i3c/i3c-cfs.c | 389 +++++++++ drivers/i3c/internals.h | 1 + drivers/i3c/master.c | 26 + drivers/i3c/master/Makefile | 3 +- drivers/i3c/master/svc-i3c-main.c | 79 ++ drivers/i3c/master/svc-i3c-master.c | 34 +- drivers/i3c/master/svc-i3c-target.c | 776 ++++++++++++++++++ drivers/i3c/master/svc-i3c.h | 14 + drivers/i3c/target.c | 453 ++++++++++ drivers/tty/Kconfig | 13 + drivers/tty/Makefile | 1 + drivers/tty/i3c_tty.c | 426 ++++++++++ include/linux/i3c/device.h | 1 + include/linux/i3c/target.h | 527 ++++++++++++ 26 files changed, 3689 insertions(+), 31 deletions(-) create mode 100644 Documentation/driver-api/i3c/target/i3c-target-cfs.rst create mode 100644 Documentation/driver-api/i3c/target/i3c-target.rst create mode 100644 Documentation/driver-api/i3c/target/i3c-tty-howto.rst create mode 100644 Documentation/driver-api/i3c/target/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/master/svc-i3c-main.c create mode 100644 drivers/i3c/master/svc-i3c-target.c create mode 100644 drivers/i3c/master/svc-i3c.h create mode 100644 drivers/i3c/target.c create mode 100644 drivers/tty/i3c_tty.c create mode 100644 include/linux/i3c/target.h