From patchwork Mon May 11 13:12:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parshuram Raju Thombare X-Patchwork-Id: 11540667 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 196AA81 for ; Mon, 11 May 2020 13:13:00 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id E7EEC20735 for ; Mon, 11 May 2020 13:12:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QASeQXx/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="cTqg7Rsy"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="yEjK079R" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7EEC20735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cadence.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FYe+XD8lPrkaXvSkE2ma/FQdfX7Q6Tv3pGAW0mRfZhw=; b=QASeQXx/TyBqma ScOCeOH8gesZT3lsPJ8QKTe08aLxD2C0tz+8LkK/lVtkftGeWIbizsb+UoALM7py3s4TgdQ7Jfb3K PoZE/jMopg4TzU5/HaA8YygMIyZqRzLyScrXhnK1R/oNOnTHCYOB0gmN7WUUtzibes1EaxqTKhsXm Dw4sbqR+rwMOClntr3Y3mDhHroMa0q9nv9/n/5GXeJtQzlNnyQyjVK2x9Q9SomYr/qj2X59pcmZ3i 9TiPen/lZiG4zj/IF04qdRr6MHI75KCeVu4l1sstkAPffVF7AO45iy4rZLPIEAspK6lQKODLPGrZr AFgh+s6czBmyNtaSmT0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8Er-0006Dw-Nu; Mon, 11 May 2020 13:12:57 +0000 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8Eo-0006DI-U0 for linux-i3c@lists.infradead.org; Mon, 11 May 2020 13:12:56 +0000 Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BD88U4016509; Mon, 11 May 2020 06:12:54 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=sTAplfbdy+B97iC3mdY8J3ROwCeB4Xy2iD0rgKJowE4=; b=cTqg7RsyT0s1YGn4fjfzNDQZRudX0zbbLfwJuoIMRBBn+0eIe/UrxBu+d3+0YliTiUZL 5udH/5CrVohmMvtoHbC0OtikeU7PIhPBPelwrkFwICx4afRrsefXEyYjJfHtDLU28jrU WjGQDExkkoHs0VpBLvm2QLVOa5HOsHrHpcX2u8FRFRFPW7ONn+8f55iE2VI+ESksUcyC IjzaMDTtTEKGHrzhySbJXUz3TVN23ie5m/tUvAAWJ9glwsYJpPfeRywcVqjztcWO9oNO ZGqBndhz2ERhv2Go91raOEc7ys3DeC4hSgv83iEqNWTrSLBdUDGpvx5VApt1hY+q9L0I rg== Received: from nam04-bn3-obe.outbound.protection.outlook.com (mail-bn3nam04lp2050.outbound.protection.outlook.com [104.47.46.50]) by mx0a-0014ca01.pphosted.com with ESMTP id 30ws2xx3sp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 06:12:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FznQ3iqhL63tzJtczx90GQNgHMM1ZYuHmhHYcYnrqOjfQjc+NFQRl5kUgzyfn17k422tXhPI7IruFbg2XeflKtGn90SXTekxt5V0/1CP7zPuvNQdcUYzelPezNUNuarokFJT73UgZ9PKM2fhFg9NILVvABDAoITX9gj8fYKcHAJPrIkJEiKvXgLfVkfdaj5Z0lsx9N52Vg1uCY+EoTSQoVKomFIIOCulT4WQI59+WX38BXgpbGyDBLqykwHPF4BI7VWZPpFNFkez7n6MjWJVg0uOyQo7oV4KBGaVkhSQaFZfrllz8EOCwQzu2fVylan5NN18zBHTi9puBHHVoXyZ2g== 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-SenderADCheck; bh=sTAplfbdy+B97iC3mdY8J3ROwCeB4Xy2iD0rgKJowE4=; b=jhX3eHJFHgnZo4zKbqVkewAP//HxLUiwRDK2RuVC+GJySK5XHqOxb+LLH0aa1shKTek4cVD7eOyTPyg8AezCB+gN9btsiPh5bvyU3tlGtqgbtTzin7gE5aBilPSe6nrk6sgaonZSa6giS7ut3f81Du8ejv8IcIXX5AhTNPm0NhsDldLN8uEbdthefmFjp6RmGUhg/aA4cRz2aVOktd2o0bp1Ij9Y8Ma7O+uKIhCIBaBjBz0T6E5oKCP+70kpw/GPdGhdkvB6c32TrUmY0gwHJTEO710Qt04aTutHnBiT1aeKKJde66ANS5Wl3m7yOqNkzDRF2MuV4e7De6SIVVju0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 158.140.1.147) smtp.rcpttodomain=synopsys.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sTAplfbdy+B97iC3mdY8J3ROwCeB4Xy2iD0rgKJowE4=; b=yEjK079Rt/ifTcx2xdJNHriKR/8UFvoKCkfVxCmmu2TxQgdjVf7ngGFKppnvqIcGMw/r+KsfnO6Zktbc3l2pgMVfRrUpPa7gLrMHVWgHdvSRsQ64RbLmbKGQn+BjdRJtY3Im09nBuLlX00ydW2rLr6KVCpYwMmhWwyIogto0NnY= Received: from BN8PR12CA0033.namprd12.prod.outlook.com (2603:10b6:408:60::46) by BYAPR07MB4229.namprd07.prod.outlook.com (2603:10b6:a02:c7::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.34; Mon, 11 May 2020 13:12:49 +0000 Received: from BN8NAM12FT004.eop-nam12.prod.protection.outlook.com (2603:10b6:408:60:cafe::66) by BN8PR12CA0033.outlook.office365.com (2603:10b6:408:60::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Mon, 11 May 2020 13:12:48 +0000 Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 158.140.1.147 as permitted sender) receiver=protection.outlook.com; client-ip=158.140.1.147; helo=sjmaillnx1.cadence.com; Received: from sjmaillnx1.cadence.com (158.140.1.147) by BN8NAM12FT004.mail.protection.outlook.com (10.13.183.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11 via Frontend Transport; Mon, 11 May 2020 13:12:47 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDCgKx028629 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 11 May 2020 06:12:44 -0700 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 11 May 2020 15:12:42 +0200 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 11 May 2020 15:12:42 +0200 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDCgCT005751; Mon, 11 May 2020 15:12:42 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 04BDCg33005750; Mon, 11 May 2020 15:12:42 +0200 From: Parshuram Thombare To: , Subject: [PATCH v7 1/7] i3c: master: secondary master initialization document Date: Mon, 11 May 2020 15:12:39 +0200 Message-ID: <1589202759-5677-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1589202702-4879-1-git-send-email-pthombar@cadence.com> References: <1589202702-4879-1-git-send-email-pthombar@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:158.140.1.147; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:sjmaillnx1.cadence.com; PTR:unknown.Cadence.COM; CAT:NONE; SFTY:; SFS:(4636009)(136003)(396003)(39860400002)(376002)(346002)(36092001)(46966005)(33430700001)(36906005)(478600001)(316002)(8676002)(33440700001)(356005)(82740400003)(42186006)(110136005)(86362001)(54906003)(70586007)(70206006)(4326008)(2906002)(5660300002)(336012)(7636003)(186003)(2616005)(107886003)(82310400002)(36756003)(26005)(6666004)(426003)(47076004)(8936002); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 349a6e32-d58c-48c4-0dba-08d7f5ad0028 X-MS-TrafficTypeDiagnostic: BYAPR07MB4229: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1728; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U6bKw6wcM+O4rh4wtp+v/IDi3iS1hpBypx/XsBrA4QGlvLi1ikg4RcUh8/0xR0WeZ7gYaQ5uiq+KWm+Aw1hF7y0di7XAC5N3tdPB5+j96oK/SkpBNSKRU4QI0Hj62iEiDk0z+MeN5WqBIRVvVp3QeytRXKnnnfCCQcRwa7yOUOlg3kY4aiXQRhMeliPhgxCQA2yEoMRYVAiG8kVnj2gI/mLZOfv/SwX4j5A6UGmd3n2G6OIeu918GsyWVwrmMh5NMxPk7t/AGM1UcbLji4n+YRWRnQSABIJdLla1FovXBtMV8+riUodzy7UK01MENZSrC7mVw3GtgUa+I29IvosxKZkGoGW6KH8t1rw0ID5hrTkZCDnPwq0vjdxnuzgUhrlcyK9yunoPJvYBiAkC04sjx7qSoMYDqz0CQN9lRwZ+GnUWNZySXT7RGjqPmTBYRpHx8ZO4Hydf2reYD3Tri7vBQ9+HOHjIQCzo0/tiGz2IrmjSQKuvsZ3CbXq4AVYYq1HNIf4yctjCUt1fbqFF8rKLok8gGL8jW0M6ZNxaChVdUJdRODA+eaRziNPTy+kfB9F2PIXAFPfvx3im68F1NRsgmH0GeorQL8ABvCend0XWdZo= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 13:12:47.5627 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 349a6e32-d58c-48c4-0dba-08d7f5ad0028 X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9; Ip=[158.140.1.147]; Helo=[sjmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4229 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_05:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 spamscore=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=2 impostorscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110109 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_061254_984298_7E95D199 X-CRM114-Status: GOOD ( 16.31 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [208.84.65.235 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mparab@cadence.com, Parshuram Thombare , praneeth@ti.com, linux-kernel@vger.kernel.org, pgaj@cadence.com, linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org Document describing secondary master initialization, mastership handover and DEFSLVS handling processes. Signed-off-by: Parshuram Thombare --- Documentation/driver-api/i3c/index.rst | 1 + .../i3c/secondary-master-initialization.rst | 118 ++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 Documentation/driver-api/i3c/secondary-master-initialization.rst diff --git a/Documentation/driver-api/i3c/index.rst b/Documentation/driver-api/i3c/index.rst index 783d6dad054b..af2a0aa68f5b 100644 --- a/Documentation/driver-api/i3c/index.rst +++ b/Documentation/driver-api/i3c/index.rst @@ -9,3 +9,4 @@ I3C subsystem protocol device-driver-api master-driver-api + secondary-master-initialization diff --git a/Documentation/driver-api/i3c/secondary-master-initialization.rst b/Documentation/driver-api/i3c/secondary-master-initialization.rst new file mode 100644 index 000000000000..9d1869550807 --- /dev/null +++ b/Documentation/driver-api/i3c/secondary-master-initialization.rst @@ -0,0 +1,118 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=================================== +I3C Secondary Master Initialization +=================================== + ++-----------------------------------------+-------------------------------------------+ +| **Main master** | **Secondary master** | ++=========================================+===========================================+ +| | | +| | Do I3C master controller specific | | Do I3C master controller specefic | +| initialization. | initialization, except enabling | +| | the DEFSLVS interrupt. | +| | Call i3c_master_register | | Call i3c_secondary_master_register | +| | | +| *i3c_master_register* | *i3c_secondary_master_register* | +| | Initialize I3C master controller | | Initialize I3C master controller | +| object. | object. | +| | Scan I3C and I2C devices from DTS. | | Scan I2C devices from DTS. | +| | Set appropriate bus mode based on | | Set appropriate bus mode based on | +| I2C devices information. | I3C and I2C devices information. | +| | Create a work queue. | | Create a work queue. | +| | Call i3c_master_bus_init | | Call i3c_secondary_master_bus_init | +| | | +| *i3c_master_bus_init* | *i3c_secondary_master_bus_init* | +| | Call bus_init to do controller | | Call bus_init to do controller | +| specific bus initialization and | specific bus initialization and | +| enabling the controller. | enabling the controller. | +| | Create I3C device representing a| | Create I3C device representing a | +| master and add it to the I3C | master and add it to the I3C | +| device list. | device list. | +| | Set current master to the device| | +| created to represent I3C master | | Allocate memory for 'defslvs_data', | +| device. | that will be used to pass I3C | +| | Reset all dynamic address that | device list received in DEFSLVS | +| may have been assigned before. | to I3C core DEFSLVS processing | +| | Disable all slave events before | | Add I3C device representing this | +| starting DAA. | master to the system. | +| | Pre-assign dynamic address and | | Expose our I3C bus as an I2C adapter | +| retrieve device information if | so that I2C devices are exposed | +| needed. | through the I2C subsystem. | +| | Do dynamic address assignment to| | +| all I3C devices currenly present| | Enable DEFSLVS interrupt. | +| on the bus. | | +| | Create I3C devices representing | | +| those found during DAA. +-------------------------------------------+ +| | Send DEFSVLS message | | *DEFSLVS interrupt* | +| containing information about all| | Controller driver can chose how to | +| known I3C and I2C devices. | to handle I2C devices received in | +| | DEFSLVS e.g. Cadence's controller | +| | driver ignore I2C devices from | +| | DEFSLVS and only uses I2C device | +| | information from DTS. | +| | | Read all I3C devices information | +| | from DEFSLVS message in hardware to | +| | defslvs_data in master object. | +| | | Call i3c_master_process_defslvs | +| | | +| | *i3c_master_process_defslvs* | +| | | Acquire I3c bus | +| | | +| | *i3c_master_acquire_bus* | +| | Add I3C device representing this | | If device is already holding the | +| master to the system. | mastership, just broadcast DISEC | +| | Expose our I3C bus as an I2C | MR, HJ message and return. | +| adapter so that I2C devices are | | Check if device has got a address | +| exposed through the I2C subsystem. | by polling with a timeout. | +| | Register all I3C devices. | | +| | | Send MR request: Controller driver| +| | should check if it is already in | +| | master mode, to handle the case | +| | of mastership yielded but due to | +| | poll timeout acquire failed. | +| | | If not a master, wait until MR | +| | ENEC is received if currently it | +| | is disabled. | +| | Broadcast ENEC MR, HJ message. | | Send MR request. | ++-----------------------------------------+ | +| | *MR request interrupt* | | +| | | +| *i3c_master_yield_bus* | | +| | Check if this device is still a | | +| master to handle a case of | | +| multiple MR requests from different| | +| devices at a same time. | | +| | Broadcast DISEC MR, HJ message. | | +| New master should broadcast ENEC | | +| MR, HJ once it's usage of bus is | | +| done. | | +| | Get accept mastership acknowldege | | +| from requesting master. | | +| | Mastership hand over is done. | | Check if device enter master | +| | In case of failure reenable | mode by polling with a timeout. | +| MR requests by broadcasting ENEC | | +| MR, HJ. | Handle I3C device list from DEFSLVS. | +| | | +| | *i3c_master_populate_bus* | +| | | Free up all I3C addresses to handle | +| | address re assignment by main | +| | master. | +| | | Move all devices from I3C list to a | +| | temporary list. | +| | | For every device from defslvs_data | +| | list except the receiving master | +| | device, retrieve pid and compare it | +| | with already known I3C devices from | +| | I3C list. If match is found, | +| | allocate new address and move the | +| | device to the original I3C device | +| | list. If no match is found, it is a | +| | new device. Register and add it to | +| | the original I3C list. | +| | | At the end if temporary list is not | +| | empty, it contains unplugged I3C | +| | device. Deregister and delete them. | +| | | +| | Broadcast ENEC MR, HJ message. | ++-----------------------------------------+-------------------------------------------+ From patchwork Mon May 11 13:13:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parshuram Raju Thombare X-Patchwork-Id: 11540669 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5743481 for ; Mon, 11 May 2020 13:13:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2D0AE20735 for ; Mon, 11 May 2020 13:13:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FTkJYgXT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="XVg+Upd2"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="QimQe5iv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D0AE20735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cadence.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PkLxVlW4vkO4zXCaWIvKXpJT7a/604db5vEbvLQCr3Q=; b=FTkJYgXTE5uJ0h nNMssvTwX34Gn9MY+Wozw0mcriAxBpZHWe3t2nLytfR36YPHnMNzKFxXi6gV0CRopkcW1Ms3Fkg4L DE28CoHZEkBls/ItIEsV9Vvjwb+8/uTmKFskhGVGHPIbGtuVEdJVM8cp22S55xR+Y9S14mYuOWIQA S3a2Hr0ieI9F+PYHogjuMQAn1KgPHOeVEQ/mmicOThZsqajf1kd7Fpk5lbWrVZXPP+ixUW2heY8vX bWj8wWbIvXl+XVuARnwaIilwAut8Bv2hJAIHOqxzdnLCMLhK0kGlfE6wd3GfVBASAKZZRvTWWpNRF X7o6pRMpxvsjBeHJWVEg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8FC-0006Ge-Uq; Mon, 11 May 2020 13:13:18 +0000 Received: from mx0b-0014ca01.pphosted.com ([208.86.201.193] helo=mx0a-0014ca01.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8FA-0006G9-At for linux-i3c@lists.infradead.org; Mon, 11 May 2020 13:13:17 +0000 Received: from pps.filterd (m0042333.ppops.net [127.0.0.1]) by mx0b-0014ca01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BDALTK008908; Mon, 11 May 2020 06:13:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=4FRcNFjZwGmvKQB8przLp4g01TtaSXbGNg+J/Gf1cKU=; b=XVg+Upd2u1Mvqo1VddLDp5V0SXnueFYVLtG1+yvqBsOm9K1ConzRSspFH6UXC31Dp7AR 17GLnOzcZY82jJEN+8bsip2eTanl+hxKp4UOmWkq/dKIUCqz5Npq1V+yLy6sbZyDjqNg M3aJq2evNIuAogbX18Dpg7l7SP6rUsPgeq2T2Df+qZs071/dTKZeG/xfX/ELzqNs64ob MmvQLOsj2B+IRu/ObUno42g35iyz+dHgyhNLsB/OUrMO0gzMIB+FXfSn+qLKOO1RFfDo LSyPc8/L8iGSB5EoqCLVtJ6a3Lpgyh1bw5YLbgTVvUkBUSStAU++QaSYHtpIQ4Uhr24w tA== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by mx0b-0014ca01.pphosted.com with ESMTP id 30wr3xeag9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 06:13:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yar66oRySfYf2ipguupX8rrtnIOPMWtSoui2xUJHrNui6XBWwqiFXHw5CqSjA61zmvGHx9434pU3dGxhU+RJyZa6EjuNu3OeqsbmvtLmSfjRpGawcdZcrrrSYrExEvJ3iejlwumyWfmAMhMmby768PzJCcmQ6w5L/HKFAyTvTiOMplDqlnw/gAYJBn/DW/uhNdUcJ4NYOldzQQRvHzlOTftjJH81datIhhNRCRgIAynkdu6qeWQfQ9Bk0t5UFp/01s/VsWkq+G4oTfcv31h7ZzAEiD0gW+jm+C0ZAhT95bMEwDGfxE1Uga679WQGIupofTPrGfFloYWZDuVBTIBVZA== 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-SenderADCheck; bh=4FRcNFjZwGmvKQB8przLp4g01TtaSXbGNg+J/Gf1cKU=; b=Whzl/cNFJ5nFrt9mbdvfuOW0URVy3n+23glObjvp4jjcANWG+st89KTofNnK+xzDQ4dX94EkdU6nQTvALqsepu/SDmldgjG6H0bGGNE7ZZPGtLUI5VBeHtoykf/jwVxUlZi7XWHkDOW0qvzu1PYEdpQAr9hSrn5Bvpm7yNgdSmN3g0i5HZTavsBhN9XvX1uSdA0CIpQl6UTFqxxLi1N9nSZD1epkHeIeUyS4Lylz4bJbrl0GMTLt8RWoMfAhspBe5OtSpPRWfKEKK4OMuSOA+1lpH+rU/qv3/rs5Z8aKAPQcvIKiMDm0JAIAVp7G79o2NreJSaW6Sj0MKNhYhqWVGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 158.140.1.148) smtp.rcpttodomain=synopsys.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4FRcNFjZwGmvKQB8przLp4g01TtaSXbGNg+J/Gf1cKU=; b=QimQe5ivVFak4Bt5/tPPBq+vCxeM6qK/8Jmq/HuK5w8meztX1C9ZZ3Wd4Q6oFrAGdU+3JmxOycn5XZlsl27jowSYlU6IDMqkdnGLi/DGu30WD1+q0HQ4wm3KqjxGDUqslDRnbACgq0X3snQ40TA7AHZQeMhlo2t89xMCVB11/VM= Received: from BN6PR08CA0078.namprd08.prod.outlook.com (2603:10b6:404:b6::16) by BN8PR07MB6065.namprd07.prod.outlook.com (2603:10b6:408:6c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26; Mon, 11 May 2020 13:13:11 +0000 Received: from BN8NAM12FT032.eop-nam12.prod.protection.outlook.com (2603:10b6:404:b6:cafe::5a) by BN6PR08CA0078.outlook.office365.com (2603:10b6:404:b6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26 via Frontend Transport; Mon, 11 May 2020 13:13:11 +0000 Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 158.140.1.148 as permitted sender) receiver=protection.outlook.com; client-ip=158.140.1.148; helo=sjmaillnx2.cadence.com; Received: from sjmaillnx2.cadence.com (158.140.1.148) by BN8NAM12FT032.mail.protection.outlook.com (10.13.183.127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11 via Frontend Transport; Mon, 11 May 2020 13:13:10 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx2.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDD8ud031288 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 11 May 2020 06:13:09 -0700 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 11 May 2020 15:13:07 +0200 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 11 May 2020 15:13:07 +0200 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDD7uQ006260; Mon, 11 May 2020 15:13:07 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 04BDD7T1006258; Mon, 11 May 2020 15:13:07 +0200 From: Parshuram Thombare To: , Subject: [PATCH v7 2/7] i3c: master: use i3c_master_register only for main master Date: Mon, 11 May 2020 15:13:05 +0200 Message-ID: <1589202785-6174-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1589202702-4879-1-git-send-email-pthombar@cadence.com> References: <1589202702-4879-1-git-send-email-pthombar@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:158.140.1.148; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:sjmaillnx2.cadence.com; PTR:unknown.Cadence.COM; CAT:NONE; SFTY:; SFS:(4636009)(396003)(346002)(39860400002)(136003)(376002)(36092001)(46966005)(33430700001)(54906003)(2616005)(426003)(110136005)(356005)(316002)(42186006)(2906002)(26005)(47076004)(107886003)(86362001)(8936002)(7636003)(82740400003)(8676002)(82310400002)(33440700001)(4326008)(336012)(478600001)(5660300002)(36756003)(70206006)(36906005)(186003)(70586007); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0a380fd1-04d5-4cdb-ae02-08d7f5ad0ddc X-MS-TrafficTypeDiagnostic: BN8PR07MB6065: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ut/MY4dlrjZ8M3I80qUWfMlf9p9gYsaO/rzLC1wtulKkLrO9JAXNRmh7rgTkAoVfX2nvFTCoDz5FCsFoFHUjMP9Yr5wpCg9pC174UOE9Ly7pZYUrKO/h8ZYNL//yxUgNrthadVTT9rymXmdsCpnHZ48qonuNp+QQWbj4rEqIXeCaP1BjIcCAov19lNj+8HZCXoqqeBhUzzGsmkdInA4CY8/ZLDvw9a+49KFS/wSFl42uw/LNaV7Ojo0Sj2cuRYEZ80L4bxx9hkaDsZIpcaGpkwfKAuHdcQU0woTUcjn5fQtwdkE7sXwp92dsgkGL4H84GznkhUeBf2jTGtu3nnQE3g4CBohNlYBE0Sp29x6ju0ZRGguBleBDtaKFSCihsXMw2LkP+DS6g3KxhEmsVQcbiLlxQjt8stbS/yZhVLVX3nesrZsIMXj6yL1sQSPBqaQn+DTcGrgp0basnDqCp1LzMFBkrsqEm+zsInykVlzjNKcbKOMy30orDBGFqdWEyeWf2TU40Thy7X+A1EnpDssgmEsVhe+m23ugt2F9FwRlY3v+HngfPWQMDr4p83LQ5E1bAEU0+79ugJzvdn9AyIHCuXfos+lVTyia6p8IIEgxVbk= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 13:13:10.5568 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a380fd1-04d5-4cdb-ae02-08d7f5ad0ddc X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9; Ip=[158.140.1.148]; Helo=[sjmaillnx2.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR07MB6065 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_05:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 mlxscore=0 phishscore=0 clxscore=1015 suspectscore=2 impostorscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110109 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_061316_494704_FB7744D5 X-CRM114-Status: GOOD ( 16.42 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [208.86.201.193 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mparab@cadence.com, Parshuram Thombare , praneeth@ti.com, linux-kernel@vger.kernel.org, pgaj@cadence.com, linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org Removed last argument 'secondary' and refactored i3c_master_register to move code that can be common to i3c_secondary_master_register to separate function i3c_master_init. Signed-off-by: Parshuram Thombare --- drivers/i3c/master.c | 69 +++++++++++++++++----------- drivers/i3c/master/dw-i3c-master.c | 2 +- drivers/i3c/master/i3c-master-cdns.c | 2 +- include/linux/i3c/master.h | 3 +- 4 files changed, 46 insertions(+), 30 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 5f4bd52121fe..ba07a7d49633 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2391,31 +2391,10 @@ static int i3c_master_check_ops(const struct i3c_master_controller_ops *ops) return 0; } -/** - * i3c_master_register() - register an I3C master - * @master: master used to send frames on the bus - * @parent: the parent device (the one that provides this I3C master - * controller) - * @ops: the master controller operations - * @secondary: true if you are registering a secondary master. Will return - * -ENOTSUPP if set to true since secondary masters are not yet - * supported - * - * This function takes care of everything for you: - * - * - creates and initializes the I3C bus - * - populates the bus with static I2C devs if @parent->of_node is not - * NULL - * - registers all I3C devices added by the controller during bus - * initialization - * - registers the I2C adapter and all I2C devices - * - * Return: 0 in case of success, a negative error code otherwise. - */ -int i3c_master_register(struct i3c_master_controller *master, - struct device *parent, - const struct i3c_master_controller_ops *ops, - bool secondary) +static int i3c_master_init(struct i3c_master_controller *master, + struct device *parent, + const struct i3c_master_controller_ops *ops, + bool secondary) { struct i3c_bus *i3cbus = i3c_master_get_bus(master); enum i3c_bus_mode mode = I3C_BUS_MODE_PURE; @@ -2482,6 +2461,45 @@ int i3c_master_register(struct i3c_master_controller *master, if (ret) goto err_put_dev; + return 0; + +err_put_dev: + put_device(&master->dev); + + return ret; +} + +/** + * i3c_master_register() - register an I3C master + * @master: master used to send frames on the bus + * @parent: the parent device (the one that provides this I3C master + * controller) + * @ops: the master controller operations + * @secondary: true if you are registering a secondary master. Will return + * -ENOTSUPP if set to true since secondary masters are not yet + * supported + * + * This function takes care of everything for you: + * + * - creates and initializes the I3C bus + * - populates the bus with static I2C devs if @parent->of_node is not + * NULL + * - registers all I3C devices added by the controller during bus + * initialization + * - registers the I2C adapter and all I2C devices + * + * Return: 0 in case of success, a negative error code otherwise. + */ +int i3c_master_register(struct i3c_master_controller *master, + struct device *parent, + const struct i3c_master_controller_ops *ops) +{ + int ret; + + ret = i3c_master_init(master, parent, ops, false); + if (ret) + return ret; + ret = device_add(&master->dev); if (ret) goto err_cleanup_bus; @@ -2511,7 +2529,6 @@ int i3c_master_register(struct i3c_master_controller *master, err_cleanup_bus: i3c_master_bus_cleanup(master); -err_put_dev: put_device(&master->dev); return ret; diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c index 1d83c97431c7..5d5a8a90ec06 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -1158,7 +1158,7 @@ static int dw_i3c_probe(struct platform_device *pdev) master->free_pos = GENMASK(master->maxdevs - 1, 0); ret = i3c_master_register(&master->base, &pdev->dev, - &dw_mipi_i3c_ops, false); + &dw_mipi_i3c_ops); if (ret) goto err_assert_rst; diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c index 8889a4fdb454..ed4f43807f9e 100644 --- a/drivers/i3c/master/i3c-master-cdns.c +++ b/drivers/i3c/master/i3c-master-cdns.c @@ -1615,7 +1615,7 @@ static int cdns_i3c_master_probe(struct platform_device *pdev) writel(DEVS_CTRL_DEV_CLR_ALL, master->regs + DEVS_CTRL); ret = i3c_master_register(&master->base, &pdev->dev, - &cdns_i3c_master_ops, false); + &cdns_i3c_master_ops); if (ret) goto err_disable_sysclk; diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index f13fd8b1dd79..f5ba82c390bc 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -533,8 +533,7 @@ int i3c_master_set_info(struct i3c_master_controller *master, int i3c_master_register(struct i3c_master_controller *master, struct device *parent, - const struct i3c_master_controller_ops *ops, - bool secondary); + const struct i3c_master_controller_ops *ops); int i3c_master_unregister(struct i3c_master_controller *master); /** From patchwork Mon May 11 13:13:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parshuram Raju Thombare X-Patchwork-Id: 11540671 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90178913 for ; Mon, 11 May 2020 13:14:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6B57F20735 for ; Mon, 11 May 2020 13:14:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o0+/v6f7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="MJVmX0qF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="ZkzbEj2I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B57F20735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cadence.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i/aNob5plm5dWr/3k4dlhPqP5u+iqe4izpD2XrJy1to=; b=o0+/v6f79wgxBN haavnifL6kssF3fjn5ugZZQdiCEj6pQ8dVoI6ZV/qRFi13rIODS4Yu3BsilhZiilPWzqbQ+r88jsb /6WIqM9+r5fy5blrzdApU6HUNDZ/6d3CuPqnEATTGCVwureVhW+CSSk4pCtYw6ZYL+EJLgi6UYgdg /4SysRIsc8enp+uJw/rEyFpmoAvXE7rAfeR/ZyaeOnGe+5p5wGyF8VYtdMXm47qI2yFEUfUmehULQ UUG6z5U0LH8LSOKcof5phHYemgIqVRuIEpHOFSeDVtQBOEC91UIrtskC8swZ7vSRYOv/Rruis/Pwl KwFPyVg/nuiLad9YhAhQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8G0-0006K5-57; Mon, 11 May 2020 13:14:08 +0000 Received: from mx0b-0014ca01.pphosted.com ([208.86.201.193] helo=mx0a-0014ca01.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8Fx-0006Ja-FQ for linux-i3c@lists.infradead.org; Mon, 11 May 2020 13:14:07 +0000 Received: from pps.filterd (m0042333.ppops.net [127.0.0.1]) by mx0b-0014ca01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BDAKcs008826; Mon, 11 May 2020 06:14:03 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=qum8SK3AEkkepzqllm/N7GlPGng4CYG3oDc+9SHt+3c=; b=MJVmX0qFSpFkUMQKANWE7fmghB8+oi1TP8nYNwrHzv7AhzjG0nRfbTtsdoZygFwqdEOq 5nBoUdw6R7A3t8YTPCIM+kgULe6QsC4M2vdVqMkxldVNFP8FmIPDLGRhFGUaHSHIZ44J osVf72l6cgu/zW9vGS92cqI0EPFw19XQzJ+V61+HlgcCOUWEpyxKAzTPpFDyVG20smBC CwB78Fc3Qx6w+4E1oyrzDOtoMHjTKAvorlf9b7dw00UA0bDcA4K2OJ8ZWg8xDlGjHzdx MHszZBIPwkQPBDZEu087FRHuPnEAe4RjBBth6cYH/sRujw9CeBC68/podJuzSALW8PfB WA== Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2108.outbound.protection.outlook.com [104.47.70.108]) by mx0b-0014ca01.pphosted.com with ESMTP id 30wr3xeajh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 06:14:02 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZkurpUPWsJwaE5T2KgNRNNroaj0z6FCTZ5uth/dEDrny+Bs0f6oEGPN1EEluTZ7AgeUvVYy9KbVyHnXLgdNMjwxntA0JVqPuUBoZqqszF0+EmZY4Yh1Z5kJN33+Uf6ShrL/nZPVSx/04AeihG7nfUuuSvr+3uwYIFqw623uBZ0GIFrxXf87rGt/8mG+ike8cpNBiY8qEOSiet2XjAqH32f7BklJ/gGGtaTrCBhSxiNjH5Nu/YRBGL/Br8pEJ9xLrn4Vs5oZ+CedCKqKNtaWdZJlLfGWHvS1o/6mPT+QMBwwydob34t/TtI8IGByevYpRbUVCb29bEB8Ny3J55vJdbQ== 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-SenderADCheck; bh=qum8SK3AEkkepzqllm/N7GlPGng4CYG3oDc+9SHt+3c=; b=SVIqY7hXWH11RMxj4El2fHtMcchBg5xrT2fpYaR1KVESehuVA+FAF/Zl1Fjal5HAVC0TKS90SQ4RBiNFguWI6JBKpjLceuRkcFLYxfK/onjQ+JBhXpX2XHZWY5yOlzlZQ9CAr3eNSMch33xP3bcFKtFJG48o6pvz1ZkXWU57n8HHRRTH+e+gd7MUbaWqkeysyS7IXJyN0KfFoII/ktIG8WgTioigxapOf6R5DXXD1iOzvfL7+zT62imhllcNuSQR3wqtJTy81ZuxXqp6X8x7CGUBhpcYGANj8bE1F+NJe1QeiUrZfHkvdboe/uCGHOHpMP+X8eGwIueFKVrfRMhQ0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 64.207.220.244) smtp.rcpttodomain=synopsys.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qum8SK3AEkkepzqllm/N7GlPGng4CYG3oDc+9SHt+3c=; b=ZkzbEj2IRPIKPoT+WurCDOrFByR2QD7OiViDTLcYhd+DYqjJ/QiQEeQWQas0SSzC5GNHE3QM8sqoVaUOPYkQkOYaHdI6SYHacZYP18o5gSEl2NYANbzY45UfOCMsG33eNLodiZE0lyMocJD6t3nBvHXMtYlRRF07M0AMWbdgCew= Received: from BN6PR11CA0025.namprd11.prod.outlook.com (2603:10b6:404:4b::11) by SN6PR07MB5311.namprd07.prod.outlook.com (2603:10b6:805:67::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.34; Mon, 11 May 2020 13:13:59 +0000 Received: from BN8NAM12FT062.eop-nam12.prod.protection.outlook.com (2603:10b6:404:4b:cafe::36) by BN6PR11CA0025.outlook.office365.com (2603:10b6:404:4b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26 via Frontend Transport; Mon, 11 May 2020 13:13:59 +0000 Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 64.207.220.244 as permitted sender) receiver=protection.outlook.com; client-ip=64.207.220.244; helo=wcmailrelayl01.cadence.com; Received: from wcmailrelayl01.cadence.com (64.207.220.244) by BN8NAM12FT062.mail.protection.outlook.com (10.13.183.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11 via Frontend Transport; Mon, 11 May 2020 13:13:58 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by wcmailrelayl01.cadence.com (8.14.7/8.14.4) with ESMTP id 04BDDuhF230231 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=OK); Mon, 11 May 2020 06:13:57 -0700 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 11 May 2020 15:13:55 +0200 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 11 May 2020 15:13:55 +0200 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDDtTV006981; Mon, 11 May 2020 15:13:55 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 04BDDtnL006979; Mon, 11 May 2020 15:13:55 +0200 From: Parshuram Thombare To: , Subject: [PATCH v7 3/7] i3c: master: add i3c_secondary_master_register Date: Mon, 11 May 2020 15:13:53 +0200 Message-ID: <1589202833-6908-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1589202702-4879-1-git-send-email-pthombar@cadence.com> References: <1589202702-4879-1-git-send-email-pthombar@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:64.207.220.244; CTRY:CN; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:wcmailrelayl01.cadence.com; PTR:unused.mynethost.com; CAT:NONE; SFTY:; SFS:(4636009)(136003)(346002)(39860400002)(376002)(396003)(36092001)(46966005)(33430700001)(336012)(70206006)(26005)(2906002)(82310400002)(186003)(47076004)(2616005)(81166007)(82740400003)(4326008)(426003)(356005)(107886003)(110136005)(478600001)(54906003)(70586007)(316002)(36906005)(42186006)(5660300002)(8936002)(33440700001)(86362001)(36756003)(8676002); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6468498-7406-4c3c-3e0f-08d7f5ad2a97 X-MS-TrafficTypeDiagnostic: SN6PR07MB5311: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UsF2722Qatd4AlabKxflc3/j7FC925UQgMVBn3aJLcKJ60B16vJ9IAhQphfbnA6DtlxATsCcnj0OA2kTdF6xEEsVdQlt3uZ8oEsjdichjXLymzL3hROaNzo7/XNX0Lza9XpMuxhARazyTqwRWlW7AquGUh3KJrnfY49sxTd1jtqlwbJLZEnk1HzR4kx0nhNHWlC6xSmi3UmvbNcsPSBDWRwiv4XbOOgQy+dYcZsBOlf6Wi8QAkdvnnXv5kBCvkTFvGrugY47NnPVPGb6auJMOFdurOz06MqMcYRZaKEHSVsYW+/k5YsZo27b+EzWr8BTtrQ4tPuDoXQeU4xM/pRMKX6Bu4lVz5zwhjpz9DkK797wKQUt43REZXZtlJdddhcpN/kTWg9KxXT8VmSvg2o2PgOkGUah+Uds25A4d4V7fhjX1CKjNahw+jQ9Y+jjAuRFjtUACJs24eLV1icrOcnMswo8Eaxm01zqSsS4s3uwSIzDlWfUGNWzkdJfDlWXrTQBDaju22D6DlsX7FZZkZv4Wlc+Wc12yZU34B++smuOxHTTsvAgvHOCOlVNBzPArAGVkNiP5JVVtHgUFXCBtjMlfEDzd+wmj52uwdzpJzewSEc= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 13:13:58.7407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6468498-7406-4c3c-3e0f-08d7f5ad2a97 X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9; Ip=[64.207.220.244]; Helo=[wcmailrelayl01.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB5311 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_05:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 mlxscore=0 phishscore=0 clxscore=1015 suspectscore=2 impostorscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110109 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_061405_646315_786F6C75 X-CRM114-Status: GOOD ( 20.03 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [208.86.201.193 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mparab@cadence.com, Parshuram Thombare , praneeth@ti.com, linux-kernel@vger.kernel.org, pgaj@cadence.com, linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org add i3c_secondary_master_register which is used to register secondary masters. Signed-off-by: Parshuram Thombare --- drivers/i3c/master.c | 154 ++++++++++++++++++++++++++++++++++++- include/linux/i3c/master.h | 3 + 2 files changed, 156 insertions(+), 1 deletion(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index ba07a7d49633..669bd7e45810 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1768,6 +1768,90 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) return ret; } +/** + * i3c_secondary_master_bus_init() - initialize an I3C bus for secondary + * master + * @master: secondary master initializing the bus + * + * This function does + * + * 1. Attach I2C devs to the master + * + * 2. Call &i3c_master_controller_ops->bus_init() method to initialize + * the master controller. That's usually where the bus mode is selected + * (pure bus or mixed fast/slow bus) + * + * Once this is done, I2C devices should be usable. + * + * Return: a 0 in case of success, an negative error code otherwise. + */ +static int i3c_secondary_master_bus_init(struct i3c_master_controller *master) +{ + enum i3c_addr_slot_status status; + struct i2c_dev_boardinfo *i2cboardinfo; + struct i2c_dev_desc *i2cdev; + int ret; + + /* + * First attach all devices with static definitions provided by the + * FW. + */ + list_for_each_entry(i2cboardinfo, &master->boardinfo.i2c, node) { + status = i3c_bus_get_addr_slot_status(&master->bus, + i2cboardinfo->base.addr); + if (status != I3C_ADDR_SLOT_FREE) { + ret = -EBUSY; + goto err_detach_devs; + } + + i3c_bus_set_addr_slot_status(&master->bus, + i2cboardinfo->base.addr, + I3C_ADDR_SLOT_I2C_DEV); + + i2cdev = i3c_master_alloc_i2c_dev(master, i2cboardinfo); + if (IS_ERR(i2cdev)) { + ret = PTR_ERR(i2cdev); + goto err_detach_devs; + } + + ret = i3c_master_attach_i2c_dev(master, i2cdev); + if (ret) { + i3c_master_free_i2c_dev(i2cdev); + goto err_detach_devs; + } + } + + /* + * Now execute the controller specific ->bus_init() routine, which + * might configure its internal logic to match the bus limitations. + */ + ret = master->ops->bus_init(master); + if (ret) + goto err_detach_devs; + + /* + * The master device should have been instantiated in ->bus_init(), + * complain if this was not the case. + */ + if (!master->this) { + dev_err(&master->dev, + "master_set_info() was not called in ->bus_init()\n"); + ret = -EINVAL; + goto err_bus_cleanup; + } + + return 0; + +err_bus_cleanup: + if (master->ops->bus_cleanup) + master->ops->bus_cleanup(master); + +err_detach_devs: + i3c_master_detach_free_devs(master); + + return ret; +} + static void i3c_master_bus_cleanup(struct i3c_master_controller *master) { if (master->ops->bus_cleanup) @@ -2457,7 +2541,10 @@ static int i3c_master_init(struct i3c_master_controller *master, goto err_put_dev; } - ret = i3c_master_bus_init(master); + if (secondary) + ret = i3c_secondary_master_bus_init(master); + else + ret = i3c_master_bus_init(master); if (ret) goto err_put_dev; @@ -2535,6 +2622,71 @@ int i3c_master_register(struct i3c_master_controller *master, } EXPORT_SYMBOL_GPL(i3c_master_register); +/** + * i3c_secondary_master_register() - register an I3C secondary master + * @master: master used to send frames on the bus + * @parent: the parent device (the one that provides this I3C master + * controller) + * @ops: the master controller operations + * + * This function does minimal required initialization for secondary + * master, rest functionality like creating and registering I2C + * and I3C devices is done in defslvs processing. + * + * i3c_secondary_master_register() does following things - + * - creates and initializes the I3C bus + * - populates the bus with static I2C devs if @parent->of_node is not + * NULL + * initialization + * - allocate memory for defslvs_data.devs, which is used to receive + * defslvs list + * - create I3C device representing this master + * - registers the I2C adapter and all I2C devices + * + * Return: 0 in case of success, a negative error code otherwise. + */ +int i3c_secondary_master_register(struct i3c_master_controller *master, + struct device *parent, + const struct i3c_master_controller_ops *ops) +{ + int ret; + + ret = i3c_master_init(master, parent, ops, true); + if (ret) + return ret; + + ret = device_add(&master->dev); + if (ret) + goto err_cleanup_bus; + + /* + * Expose our I3C bus as an I2C adapter so that I2C devices are exposed + * through the I2C subsystem. + */ + ret = i3c_master_i2c_adapter_init(master); + if (ret) + goto err_del_dev; + + /* + * We're done initializing the bus and the controller, we can now + * register I3C devices from defslvs list. + */ + master->init_done = true; + + return 0; + +err_del_dev: + device_del(&master->dev); + +err_cleanup_bus: + i3c_master_bus_cleanup(master); + + put_device(&master->dev); + + return ret; +} +EXPORT_SYMBOL_GPL(i3c_secondary_master_register); + /** * i3c_master_unregister() - unregister an I3C master * @master: master used to send frames on the bus diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index f5ba82c390bc..5124ff4831eb 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -534,6 +534,9 @@ int i3c_master_set_info(struct i3c_master_controller *master, int i3c_master_register(struct i3c_master_controller *master, struct device *parent, const struct i3c_master_controller_ops *ops); +int i3c_secondary_master_register(struct i3c_master_controller *master, + struct device *parent, + const struct i3c_master_controller_ops *ops); int i3c_master_unregister(struct i3c_master_controller *master); /** From patchwork Mon May 11 13:14:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parshuram Raju Thombare X-Patchwork-Id: 11540701 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0EFAA913 for ; Mon, 11 May 2020 13:15:09 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DD37C20746 for ; Mon, 11 May 2020 13:15:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="m2cPEAHa"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="YIrtVrdA"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="dM0Ih/io" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD37C20746 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cadence.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=54tbMMwc8y0SxiJhqbEdjME8lhQH9yFE8BBdGYT+yRE=; b=m2cPEAHaoWkK9T LkDAUxYlYBh4zjtuaMgpGPxiKYZwJpnlJaFdKLvu2KY+yjY7R2qOMkZLaOXuUAC39F56ycd4PX5qH FlWs5oQoHvtMK/Qm0qWfD5+lsvU57J67XwyvY2DIItOMTVZGoi6kCGsT9DdzJYvK8E2sScNFzJANu aeRiW4//vw8Us61pbX8VywzT2lKf5WW0GA5Xh4Glazss2ORcnl8aUYrIt6sulJb8k5rJZfUWJCtop cPZby8bEaiQpVwo0wThw1AigUDIHmAJ+8BL1Y6CwtQjFzi04vVuAiu6w2E+p9roWccP9y+SPNOeuB 4dcxwk//RRBRrLkF18rw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8Gu-0007ls-E4; Mon, 11 May 2020 13:15:04 +0000 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8Gr-00078z-3N for linux-i3c@lists.infradead.org; Mon, 11 May 2020 13:15:03 +0000 Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BD8Bx4016654; Mon, 11 May 2020 06:15:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=Ff47UsXqo08jJp96SlPnPp4QA6IrV9yuuGoM9oOVvsM=; b=YIrtVrdAMB26ycd9Oi260N5gijRjbLtKqvCYNkKFUYZQ6jthrCZoXcsYZ7ZCfD3j7LHA c6u1HiBSUdM6Ok4NC7qqk64qmUEaZVSsQ3Yn7dNLYKSsiffsN+iaMKDS3MQZmFsnxK7L SpF8sW5IAJbcqGLRT8IaQjPIwViU1CJYrn1uI6KueIpVnifGBzBrngHYQiJvZo+cTxxS XGGDWBbaFe7t8mK6rqLYcq7COnSrqKmALnnmMsbHrbat6uuDqcPngyU0SwQ+qS3319Gm rDWbmvjNRK1a5T2kV8AbWTkdd9Wss+9dincZTstdv/AtB/Gvcz8h+mnVE2Ri8ALqe6V+ EQ== Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by mx0a-0014ca01.pphosted.com with ESMTP id 30ws2xx3y9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 06:15:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rq4de5OwFNxvGV8khY/Si8ktxGddI9zAwpau93d0wYeUFqGYilr61xlJuA2zVo5XgNIMfP+r5U+62KyQ0nmX1UgV4PvKjxRiPUVAljp79wUN/OV1aPdnbvFzrojR+ybtes3ExKOkv2mPQ2x0R465ucyhnQh4rAKWQ4VjXZKrvmNF4Ewjfs1CejavDwARBrA/wJP5i2HZREwJvR7exXHwWkYNU3eAyl3Y9yeprP5A43yycSSITOmY4NFWfnr15QlqfUb0F356giuw3GntGyk0rAyfNE1cL2oD9bGuBQA49mpqIa5fnieTH90JKLSSYF/bb8xf+XN3wqC+cXv67lJv1Q== 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-SenderADCheck; bh=Ff47UsXqo08jJp96SlPnPp4QA6IrV9yuuGoM9oOVvsM=; b=N/iv5auuDa1lw+Q92s6g4Z/Tc/2IXM9VWOh7199ulGmvt5OYoVUs7Ddv0dFa2w3/gHyFSa8Ypsx2dbhTICSizLtvZT80MOJIK0u/N6lN17nJS9LMs4dYobAYfj0gHbDQTScuLsXGtadgr52czHQ1h9x/HXGTdIqDZm6uIoSmFqnviwV9heMrX7BsS8ZOFakbcWSZ710pZwIlc2iw07dvHdgeWouWr7LVB3mg58DAq22AlqQDuW9iCYSn+xjKzK7FVTH16XF5g3oIDcvdi7xieDeHTIVHAudRIG1EAEz2uS7JAP9srmFeHAYvAdGymoRkr0yg9M41kT//HVR8PAiUtw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 199.43.4.23) smtp.rcpttodomain=synopsys.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ff47UsXqo08jJp96SlPnPp4QA6IrV9yuuGoM9oOVvsM=; b=dM0Ih/ioA3DMTdtrgDgxclqaWZ50HrTfAr7vH4A7DZVzNa1PmRKh1pSaA0Sl5HUWO00Iu/1tJDFT3RN9ldvPScUaLdHoRGDAchzbAohLxl1RzObzvuD7WYo8EA7pvT6ML8RrSp0YMJkc+tEdkLC7ZxTWjOjmApGcc9pA6csbVgk= Received: from BN6PR1101CA0017.namprd11.prod.outlook.com (2603:10b6:405:4a::27) by BL0PR07MB5443.namprd07.prod.outlook.com (2603:10b6:208:27::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.29; Mon, 11 May 2020 13:14:58 +0000 Received: from BN8NAM12FT015.eop-nam12.prod.protection.outlook.com (2603:10b6:405:4a:cafe::12) by BN6PR1101CA0017.outlook.office365.com (2603:10b6:405:4a::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28 via Frontend Transport; Mon, 11 May 2020 13:14:57 +0000 Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 199.43.4.23 as permitted sender) receiver=protection.outlook.com; client-ip=199.43.4.23; helo=rmmaillnx1.cadence.com; Received: from rmmaillnx1.cadence.com (199.43.4.23) by BN8NAM12FT015.mail.protection.outlook.com (10.13.183.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11 via Frontend Transport; Mon, 11 May 2020 13:14:57 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by rmmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDEqt1019853 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 11 May 2020 09:14:53 -0400 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 11 May 2020 15:14:51 +0200 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 11 May 2020 15:14:50 +0200 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDEpe2009276; Mon, 11 May 2020 15:14:51 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 04BDEo8n009271; Mon, 11 May 2020 15:14:50 +0200 From: Parshuram Thombare To: , Subject: [PATCH v7 4/7] i3c: master: add mastership handover support Date: Mon, 11 May 2020 15:14:49 +0200 Message-ID: <1589202889-9186-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1589202702-4879-1-git-send-email-pthombar@cadence.com> References: <1589202702-4879-1-git-send-email-pthombar@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:199.43.4.23; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:rmmaillnx1.cadence.com; PTR:InfoDomainNonexistent; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(396003)(376002)(136003)(346002)(36092001)(46966005)(33430700001)(82740400003)(316002)(36906005)(42186006)(8676002)(8936002)(478600001)(5660300002)(110136005)(70586007)(54906003)(86362001)(82310400002)(107886003)(81166007)(70206006)(47076004)(26005)(186003)(2616005)(336012)(36756003)(33440700001)(356005)(426003)(4326008)(2906002); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d1e4f01-e537-4687-16d1-08d7f5ad4d5c X-MS-TrafficTypeDiagnostic: BL0PR07MB5443: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +NAadNDPwI+++nPilG1p9lzRYXzuIFIDUMqBZI0EWCzqB4jhXuCtySZvTrgJbS+MRwDoGHNB3VPB4WtpsDbto7fU8kTQo/qqgXmicfEI+DaEG5vpJkj0ICqAn1SIOiUS+RerhyndxRKU4NHPpM9VsX/0RrrfQ/IR5hG6JXoxPwn8DB+J3s4QhIemIeIGdXfcglABIvuuE74YDRXTrY9FOq59JLFlf2n9fFq9iCSCeV6N7zD0DHTPfZeFhrutFljlS5efwstGcDlqaDS/Gsi8LKqqeojSlTw+kphe/+3LBbkvQaWAl/ihf+HduSp4cvHfYhHoUce9Om76UgxMv9Mxy3AcWIlXa12uhdBO+V7CwJhGbvJ8xNl0L2Z9UpcDS6YS0sh25Dx7OEuIOpU4oRJGRT2WKGMEUctauCc4Lg/c9SwHm9YIJpcjwFUUOlhMqv9r6I/yQ/BqmHnbD3gf888yVOm/X915i+4iAY/KOQvoxGggtKWWlmrL3jvbQBKAFo7ThlZChugI9nNQcRLUjAeRllJUPvgIohL05Jiwq83/1AioRwM2iQ5AxIxGYLxL1z06sDYqvGmxlllgRU6MjcKbxez5Ba1v7lcDQdca0F0myts= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 13:14:57.1912 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d1e4f01-e537-4687-16d1-08d7f5ad4d5c X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9; Ip=[199.43.4.23]; Helo=[rmmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR07MB5443 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_05:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 spamscore=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=2 impostorscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 mlxlogscore=867 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110109 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_061501_161133_18EC752A X-CRM114-Status: GOOD ( 21.75 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [208.84.65.235 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mparab@cadence.com, Parshuram Thombare , praneeth@ti.com, linux-kernel@vger.kernel.org, pgaj@cadence.com, linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org Added mastership acquire and yield functions. Signed-off-by: Parshuram Thombare --- drivers/i3c/master.c | 187 +++++++++++++++++++++++++++++++++++-- include/linux/i3c/master.h | 23 +++++ 2 files changed, 201 insertions(+), 9 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 669bd7e45810..9c8250a6a2b0 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "internals.h" @@ -467,6 +468,79 @@ static const char * const i3c_bus_mode_strings[] = { [I3C_BUS_MODE_MIXED_SLOW] = "mixed-slow", }; +static int i3c_master_enable_mr_events(struct i3c_master_controller *master) +{ + int ret; + + master->ops->enable_mr_events(master); + i3c_bus_maintenance_lock(&master->bus); + ret = i3c_master_enec_locked(master, I3C_BROADCAST_ADDR, + I3C_CCC_EVENT_MR | I3C_CCC_EVENT_HJ); + i3c_bus_maintenance_unlock(&master->bus); + + return ret; +} + +static int check_event_da_update(struct i3c_master_controller *m) +{ + return m->ops->check_event_set(m, I3C_SLV_DA_UPDATE); +} + +static int check_event_mr_done(struct i3c_master_controller *m) +{ + return m->ops->check_event_set(m, I3C_SLV_MR_DONE); +} + +/** + * i3c_master_acquire_bus() - acquire I3C bus mastership + * @m: I3C master object + * + * This function may sleep. + * It is expected to be called with normaluse_lock. + */ +static int i3c_master_acquire_bus(struct i3c_master_controller *m) +{ + int ret = 0; + u32 val; + + /* + * Request mastership needs maintenance(write) lock. So, to avoid + * deadlock, release normaluse(read) lock, which is expected to be + * held before calling this function. + * normaluse(read) lock is expected to be held before calling + * this function to avoid race with maintenance activities + * like DEFSLVS processing etc + */ + i3c_bus_normaluse_unlock(&m->bus); + i3c_bus_maintenance_lock(&m->bus); + + if (m->this && m->this == m->bus.cur_master) { + i3c_master_disec_locked(m, I3C_BROADCAST_ADDR, + I3C_CCC_EVENT_MR | + I3C_CCC_EVENT_HJ); + goto mr_req_done; + } + + ret = readx_poll_timeout(check_event_da_update, m, val, + val, 100, 1000000); + if (ret) + goto mr_req_done; + + ret = m->ops->request_mastership(m); + if (ret) + goto mr_req_done; + + ret = readx_poll_timeout(check_event_mr_done, m, val, + val, 100, 1000000); + if (!ret) + m->bus.cur_master = m->this; + +mr_req_done: + i3c_bus_maintenance_unlock(&m->bus); + i3c_bus_normaluse_lock(&m->bus); + return ret; +} + static ssize_t mode_show(struct device *dev, struct device_attribute *da, char *buf) @@ -685,6 +759,33 @@ static int i3c_master_send_ccc_cmd_locked(struct i3c_master_controller *master, return 0; } +static int i3c_master_get_accmst_locked(struct i3c_master_controller *master, + u8 addr) +{ + struct i3c_ccc_getaccmst *accmst; + struct i3c_ccc_cmd_dest dest; + struct i3c_ccc_cmd cmd; + int ret; + + accmst = i3c_ccc_cmd_dest_init(&dest, addr, sizeof(*accmst)); + if (!accmst) + return -ENOMEM; + + i3c_ccc_cmd_init(&cmd, true, I3C_CCC_GETACCMST, &dest, 1); + + ret = i3c_master_send_ccc_cmd_locked(master, &cmd); + if (ret) + goto out; + + if (dest.payload.len != sizeof(*accmst)) + ret = -EIO; + +out: + i3c_ccc_cmd_dest_cleanup(&dest); + + return ret; +} + static struct i2c_dev_desc * i3c_master_find_i2c_dev_by_addr(const struct i3c_master_controller *master, u16 addr) @@ -1558,10 +1659,6 @@ int i3c_master_set_info(struct i3c_master_controller *master, if (!i3c_bus_dev_addr_is_avail(&master->bus, info->dyn_addr)) return -EINVAL; - if (I3C_BCR_DEVICE_ROLE(info->bcr) == I3C_BCR_I3C_MASTER && - master->secondary) - return -EINVAL; - if (master->this) return -EINVAL; @@ -1570,7 +1667,9 @@ int i3c_master_set_info(struct i3c_master_controller *master, return PTR_ERR(i3cdev); master->this = i3cdev; - master->bus.cur_master = master->this; + + if (!master->secondary) + master->bus.cur_master = master->this; ret = i3c_master_attach_i3c_dev(master, i3cdev); if (ret) @@ -1612,6 +1711,73 @@ static void i3c_master_detach_free_devs(struct i3c_master_controller *master) } } +/** + * i3c_master_yield_bus() - yield I3C bus mastership + * @m: I3C master object + * @sec_mst_dyn_addr: address of device requesting mastership + * + * This function may sleep. + * It is expected to be called with normaluse_lock. + */ +void +i3c_master_yield_bus(struct i3c_master_controller *m, u8 sec_mst_dyn_addr) +{ + struct i3c_dev_desc *i3cdev; + int ret = 0; + + i3c_bus_maintenance_lock(&m->bus); + if (m->this != m->bus.cur_master) + goto mr_yield_done; + + /* + * Maintenance lock and master check above is used to + * avoid race amongst devices sending MR requests + * at the same time, as soon as ENEC MST is sent by the current + * master. It ensure that only one MR request is processed, + * rest MR requests on losing devices will timeout in wait MR + * DONE state. And next MR requests are blocked due to DISEC MST + * sent by current master in yield operation. + * New master should send ENEC MST once it's work is done. + * maintainanace lock is also needed for i3c_master_get_accmst_locked. + */ + + ret = i3c_master_disec_locked(m, I3C_BROADCAST_ADDR, + I3C_CCC_EVENT_MR | + I3C_CCC_EVENT_HJ); + /* + * Once mastership is given to the new master, it is expected that + * MR is disabled prior to that and new master is responsible to + * enable it by broadcasting ENEC MR when it's work is done. + * If DISEC MR fails and we still go ahead with handover, chances + * are new master will get interrupted by unexpected MR requests. + */ + if (ret) + goto mr_yield_done; + + ret = i3c_master_get_accmst_locked(m, sec_mst_dyn_addr); + if (ret) + goto mr_yield_done; + + i3c_bus_for_each_i3cdev(&m->bus, i3cdev) { + if (sec_mst_dyn_addr == i3cdev->info.dyn_addr) { + m->bus.cur_master = i3cdev; + break; + } + } + + /* Requesting device not found on i3c list. This should never happen. */ + if (m->this == m->bus.cur_master) { + ret = -EAGAIN; + WARN_ON(1); + } + +mr_yield_done: + i3c_bus_maintenance_unlock(&m->bus); + if (ret) + i3c_master_enable_mr_events(m); +} +EXPORT_SYMBOL_GPL(i3c_master_yield_bus); + /** * i3c_master_bus_init() - initialize an I3C bus * @master: main master initializing the bus @@ -2472,6 +2638,10 @@ static int i3c_master_check_ops(const struct i3c_master_controller_ops *ops) !ops->recycle_ibi_slot)) return -EINVAL; + if (ops->request_mastership && + (!ops->enable_mr_events || !ops->check_event_set)) + return -EINVAL; + return 0; } @@ -2485,10 +2655,6 @@ static int i3c_master_init(struct i3c_master_controller *master, struct i2c_dev_boardinfo *i2cbi; int ret; - /* We do not support secondary masters yet. */ - if (secondary) - return -ENOTSUPP; - ret = i3c_master_check_ops(ops); if (ret) return ret; @@ -2608,6 +2774,9 @@ int i3c_master_register(struct i3c_master_controller *master, i3c_master_register_new_i3c_devs(master); i3c_bus_normaluse_unlock(&master->bus); + if (ops->request_mastership) + ret = i3c_master_enable_mr_events(master); + return 0; err_del_dev: diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 5124ff4831eb..dd67497ad8b1 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -259,6 +259,16 @@ enum i3c_bus_mode { I3C_BUS_MODE_MIXED_SLOW, }; +/** + * enum i3c_event - I3C master (currently acting as a slave) controller events + * @I3C_SLV_DA_UPDATE: I3C master has dynamic address + * @I3C_SLV_MR_DONE: I3C mastership request completed successfully + */ +enum i3c_event { + I3C_SLV_DA_UPDATE, + I3C_SLV_MR_DONE, +}; + /** * enum i3c_addr_slot_status - I3C address slot status * @I3C_ADDR_SLOT_FREE: address is free @@ -418,6 +428,12 @@ struct i3c_bus { * for a future IBI * This method is mandatory only if ->request_ibi is not * NULL. + * @request_mastership: send mastership request to the current master + * @enable_mr_events: enable mastership request handling by the controller + * @check_event_set: check events (enum i3c_event) such as device has dynamic + * address, mastership request is completed successfully. + * @sec_mst_dyn_addr: read current dynamic address of the I3C device from + * hardware. */ struct i3c_master_controller_ops { int (*bus_init)(struct i3c_master_controller *master); @@ -445,6 +461,11 @@ 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 (*request_mastership)(struct i3c_master_controller *master); + void (*enable_mr_events)(struct i3c_master_controller *m); + bool (*check_event_set)(struct i3c_master_controller *m, + enum i3c_event); + int (*sec_mst_dyn_addr)(struct i3c_master_controller *m); }; /** @@ -510,6 +531,8 @@ struct i3c_master_controller { #define i3c_bus_for_each_i3cdev(bus, dev) \ list_for_each_entry(dev, &(bus)->devs.i3c, common.node) +void i3c_master_yield_bus(struct i3c_master_controller *m, + u8 sec_mst_dyn_addr); int i3c_master_do_i2c_xfers(struct i3c_master_controller *master, const struct i2c_msg *xfers, int nxfers); From patchwork Mon May 11 13:15:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parshuram Raju Thombare X-Patchwork-Id: 11540703 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 543A4912 for ; Mon, 11 May 2020 13:15:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2F11120735 for ; Mon, 11 May 2020 13:15:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="t6XeAGI/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="YtBmnW2b"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="mEP62Of2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F11120735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cadence.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qKheIp8XKmMixKL97S9pfJBgzugfiJfa39ub9l27/R0=; b=t6XeAGI/NCYgGd ZHQBrfhQhwxTnFULj08QV8CUcUn1dbaTFCq2QLgJ8IQR/cUf95Ic+5ORG4v9kCbW7Oh5Xw4vNvagK x6AqmAZyDWOxtG0AC7g8LPLw61QEvGrjE+lrUbF/5G6bWG7a8G+lKR2yWeLs5BxzK2qjONLcgFfyW EpCkfdydy9XFw+ZwSu7pxXRtZ7Ypez6Mcj5odIjREA9W2RsI2Gj5iQHQvc3lbzNBm+Yv5spZ1fHQw oG1VQPHHL//ISaPk1/F1o8IwUmq/B8n/f4w6uBNX71nvm8w9xPwrPRA3BTxBHTa1+1e1dPvPHhxhD SQBf3a6nmjnGvhoTfx4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8HT-0001Dt-OE; Mon, 11 May 2020 13:15:39 +0000 Received: from mx0a-0014ca01.pphosted.com ([208.84.65.235]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8HR-0001D0-MM for linux-i3c@lists.infradead.org; Mon, 11 May 2020 13:15:39 +0000 Received: from pps.filterd (m0042385.ppops.net [127.0.0.1]) by mx0a-0014ca01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BD8BxC016654; Mon, 11 May 2020 06:15:37 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=MC4fFwRxiOhMm5cfHt7BVPrcLVdhdXxS9WNj0pAT2LY=; b=YtBmnW2b6AwaCo1rbm3GNUBw1xfV1/8kTB8l+fmnhi0zXNSknNBHm1M4EpCsxmJXV8Rc B7q/+OckHOySIQc3q+QaiaPLLNVnLRRb+7D35P5RQ4xUAt8yLHId5umMN8xP1fnPXw8X Q2To7XFkOscp32cYhbrNfuVWgpFh25e8Tw63KoTbbpC9uIti7D77SFaZKPtNZUeAzrnD mcTYeVN+0fpkOpIKf1jo31eWRRUva23Sia8UIyrwbIt7eMyB+nhvUYUZ3BiZ0kv6gHyK YCHsbltscSzn1xiYJDT8L70I8jQge+shLXe/sh29IRakIsv3dD6LcSs0SJmstWo6Armx FQ== Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2105.outbound.protection.outlook.com [104.47.55.105]) by mx0a-0014ca01.pphosted.com with ESMTP id 30ws2xx413-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 06:15:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EHYM8I2CBb83D13rTu3uOrldmPkvOrGsf+g611TD9qZzC3G9ly6y0cuC5lQ4XofKXAAi2L7a6q1VWld/1ZXOi2/tsHwDkoXMwazUXAbuNOtoDNgF2QDL84qWziqReJJb8bdfy5HwfqIDlvB6a6TLRqtbx1w0IwePsq771fYvkaU7fbTmcLFzRhp4yZXGs8OgUfenrdrGJjvrLm42MnJXLEOEK4cO5wBRWU68OdR1jxLUTS00VpZODsfhIBCv5+0BXbDPJ9irRdzJ1/6uZY2MxZHXYXe0KSbaTMijzPCEEpIUTNBQQW7pBZfIu02BRKpbLfX2DCQGpsp3hGVcy9YRPQ== 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-SenderADCheck; bh=MC4fFwRxiOhMm5cfHt7BVPrcLVdhdXxS9WNj0pAT2LY=; b=VnNIuzwvrWzmInSaPcmIEL4qCW1srdk7kvJ8/rilBo7PYsmfNbUPXhNTtYf0JzaiAYmBqbBAeH4bA0FkJYx7bFZpxb/UR5QZO5NySFUmLIKPEa6HtpM81DuR1gdGfzdF37aZ151qACpZRbh4bZFoSTLrzhmztu2wAjbFNeBFTRlUdtilYw7jmUPgLOREPN1xdFRJF9pRWWCZL5TkNZJrjH9njyHoosCuiQJ5J1inEkNq7WkLC1mLcBJGu6WbObzXTYtQ97ZQ214mU/3ybKEkG8HIADATdIb0D9cgI1uOMBcvjT/x5LRbQ9fVlunyrmYxlduhEtvCzFh5SYn5S70UIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 158.140.1.147) smtp.rcpttodomain=synopsys.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MC4fFwRxiOhMm5cfHt7BVPrcLVdhdXxS9WNj0pAT2LY=; b=mEP62Of29MUkQNMX/KoNNfG99EohPajiojs6qx+B7OVSYIC9aL/sE79cMAABOO7kSfF3QugNa7kA0633spgSmaj0ZwnBX4eTEF6kshEKlZzDMerdMH2PEp4JVUB7DPl2g6VNMxgv8Z76lVP/sBi1lXjE88wBeZd4QUFjmg4Jl7Q= Received: from BN4PR13CA0016.namprd13.prod.outlook.com (2603:10b6:403:3::26) by MN2PR07MB7200.namprd07.prod.outlook.com (2603:10b6:208:1d5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.26; Mon, 11 May 2020 13:15:34 +0000 Received: from BN8NAM12FT022.eop-nam12.prod.protection.outlook.com (2603:10b6:403:3:cafe::c8) by BN4PR13CA0016.outlook.office365.com (2603:10b6:403:3::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11 via Frontend Transport; Mon, 11 May 2020 13:15:34 +0000 Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 158.140.1.147 as permitted sender) receiver=protection.outlook.com; client-ip=158.140.1.147; helo=sjmaillnx1.cadence.com; Received: from sjmaillnx1.cadence.com (158.140.1.147) by BN8NAM12FT022.mail.protection.outlook.com (10.13.183.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11 via Frontend Transport; Mon, 11 May 2020 13:15:33 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDFU2Q028905 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 11 May 2020 06:15:31 -0700 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 11 May 2020 15:15:29 +0200 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 11 May 2020 15:15:29 +0200 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDFTIT009970; Mon, 11 May 2020 15:15:29 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 04BDFTFh009969; Mon, 11 May 2020 15:15:29 +0200 From: Parshuram Thombare To: , Subject: [PATCH v7 5/7] i3c: master: add defslvs processing Date: Mon, 11 May 2020 15:15:28 +0200 Message-ID: <1589202928-9912-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1589202702-4879-1-git-send-email-pthombar@cadence.com> References: <1589202702-4879-1-git-send-email-pthombar@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:158.140.1.147; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:sjmaillnx1.cadence.com; PTR:unknown.Cadence.COM; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(396003)(376002)(346002)(136003)(36092001)(46966005)(33430700001)(82740400003)(478600001)(47076004)(4326008)(316002)(186003)(110136005)(42186006)(26005)(107886003)(54906003)(36906005)(86362001)(70586007)(70206006)(2906002)(36756003)(336012)(7636003)(8936002)(356005)(8676002)(82310400002)(33440700001)(5660300002)(2616005)(426003); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8e743f9b-1ff5-4478-c31c-08d7f5ad62fc X-MS-TrafficTypeDiagnostic: MN2PR07MB7200: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8pKDVdmlLvCWGxTP7xQD/WKiKzuRLyr8oebnXE+/uUNLSTjz3SX6XIFVVv4d3K3iBjXUTop0SbUzaV5mtiI9TmTelW0YgT19m0lLNcSu+ykVhfYY+n1Ta+os+Bw99WA3oS2qG+X3si0rZohOQtnnMpxt+OxMkWCdFSc8OSRFnu5WMczWmW1v/I8gzSeAQQNs+0yhovYt9Ja48yit81NxH4Ql9qZe9nHEwL7Q+NbsvcBUFiedhFWe+nrZOBPOs0z0CXTn5NqFGAXbXSEDnj673Lr0cVrrRXmvoV/mpJGkH26++lyFbh8XSJ2VDh9EjlivTL8t2vkYw2H619KaubtA9w/LTxsyB8BZwB4sdZs0c4PMzlX2KWH6CJ8K5jrIkPz1IwzWYXI3MaJOUeswWbQtJqdyt5sDFIXXdrLYCuyxCqF1GKQDBS7kYrBwvaotMTzV8MEv+PlpYSa+3l4B0dFTgsY/o1CYV0vt0PCLBZIWIejw391jS/cKUQj2oFfFFPnI+PF5dvLPFQFtLb7FhqxH4L8Qa/QJKGCIyDL+FYKAcFSpTJ0ogIWQIbfLgLGsVrEyin0tUsbq+Hds5tEkrDYk3KOs3vJVOrV2JZD3BYVMQwM= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 13:15:33.3734 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e743f9b-1ff5-4478-c31c-08d7f5ad62fc X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9; Ip=[158.140.1.147]; Helo=[sjmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR07MB7200 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_05:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 spamscore=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=2 impostorscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110109 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_061537_737068_4E97D1D0 X-CRM114-Status: GOOD ( 19.25 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [208.84.65.235 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mparab@cadence.com, Parshuram Thombare , praneeth@ti.com, linux-kernel@vger.kernel.org, pgaj@cadence.com, linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org Added defslvs processing code to the I3C master subsystem. Signed-off-by: Parshuram Thombare --- drivers/i3c/master.c | 142 ++++++++++++++++++++++++++++++++++++- include/linux/i3c/master.h | 7 ++ 2 files changed, 147 insertions(+), 2 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 9c8250a6a2b0..ea53fadeed99 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -2639,7 +2639,8 @@ static int i3c_master_check_ops(const struct i3c_master_controller_ops *ops) return -EINVAL; if (ops->request_mastership && - (!ops->enable_mr_events || !ops->check_event_set)) + (!ops->enable_mr_events || !ops->check_event_set || + !ops->sec_mst_dyn_addr)) return -EINVAL; return 0; @@ -2818,12 +2819,20 @@ int i3c_secondary_master_register(struct i3c_master_controller *master, struct device *parent, const struct i3c_master_controller_ops *ops) { - int ret; + int ret, sz; ret = i3c_master_init(master, parent, ops, true); if (ret) return ret; + sz = sizeof(struct i3c_ccc_dev_desc) * I3C_BUS_MAX_DEVS; + master->defslvs_data.devs = devm_kzalloc(&master->dev, sz, + GFP_KERNEL); + if (!master->defslvs_data.devs) { + ret = -ENOMEM; + goto err_cleanup_bus; + } + ret = device_add(&master->dev); if (ret) goto err_cleanup_bus; @@ -2856,6 +2865,135 @@ int i3c_secondary_master_register(struct i3c_master_controller *master, } EXPORT_SYMBOL_GPL(i3c_secondary_master_register); +static int i3c_master_populate_bus(struct i3c_master_controller *master) +{ + struct i3c_dev_desc *i3cdev, *olddev, *tmp; + struct i3c_ccc_dev_desc *desc; + struct list_head i3c_old; + struct i3c_bus *i3cbus; + int slot, dyn_addr, ret; + + i3cbus = i3c_master_get_bus(master); + + INIT_LIST_HEAD(&i3c_old); + list_for_each_entry_safe(olddev, tmp, &i3cbus->devs.i3c, common.node) { + i3c_master_put_i3c_addrs(olddev); + list_del(&olddev->common.node); + list_add(&olddev->common.node, &i3c_old); + } + + dyn_addr = master->ops->sec_mst_dyn_addr(master); + master->this->info.dyn_addr = dyn_addr; + i3c_master_get_i3c_addrs(master->this); + list_del(&master->this->common.node); + list_add(&master->this->common.node, &i3cbus->devs.i3c); + + desc = master->defslvs_data.devs; + for (slot = 0; slot < master->defslvs_data.ndevs; slot++, desc++) { + struct i3c_device_info info = { + .dyn_addr = desc->dyn_addr + }; + + if (dyn_addr == info.dyn_addr) + continue; + + i3cdev = i3c_master_alloc_i3c_dev(master, &info); + if (IS_ERR(i3cdev)) { + ret = PTR_ERR(i3cdev); + goto populate_bus_fail; + } + + i3c_master_get_i3c_addrs(i3cdev); + ret = i3c_master_retrieve_dev_info(i3cdev); + i3c_master_put_i3c_addrs(i3cdev); + if (ret) { + i3c_master_free_i3c_dev(i3cdev); + goto populate_bus_fail; + } + + list_for_each_entry_safe(olddev, tmp, &i3c_old, common.node) { + if (olddev->info.pid == i3cdev->info.pid) { + olddev->info.dyn_addr = info.dyn_addr; + i3c_master_get_i3c_addrs(olddev); + list_del(&olddev->common.node); + list_add(&olddev->common.node, + &i3cbus->devs.i3c); + i3c_master_free_i3c_dev(i3cdev); + i3cdev = NULL; + break; + } + } + + if (i3cdev) { + ret = i3c_master_attach_i3c_dev(master, i3cdev); + if (ret) { + i3c_master_free_i3c_dev(i3cdev); + goto populate_bus_fail; + } + } + } + + list_for_each_entry_safe(olddev, tmp, &i3c_old, common.node) { + if (olddev->dev) { + olddev->dev->desc = NULL; + if (device_is_registered(&olddev->dev->dev)) + device_unregister(&olddev->dev->dev); + else + put_device(&olddev->dev->dev); + kfree(olddev->dev); + } + list_del(&olddev->common.node); + i3c_master_free_i3c_dev(olddev); + } + + return 0; + +populate_bus_fail: + /* + * Try to restore i3cbus->devs.i3c list, so far no i3c + * device is deleted, only moved or added to the original + * i3c list. Move rest of the i3c devices from old list, + * to correctly process defslvs in rety. + */ + list_for_each_entry_safe(olddev, tmp, &i3c_old, common.node) { + list_del(&olddev->common.node); + list_add(&olddev->common.node, &i3cbus->devs.i3c); + } + + return ret; +} + +/** + * i3c_master_process_defslvs() - process I3C device list received in + * DEFSLVS for device plug/unplug and address change. + * @m: I3C master object + * + * This function may sleep, so should not be called in the atomic context. + */ +int i3c_master_process_defslvs(struct i3c_master_controller *m) +{ + int ret; + + i3c_bus_normaluse_lock(&m->bus); + ret = i3c_master_acquire_bus(m); + i3c_bus_normaluse_unlock(&m->bus); + if (ret) + return ret; + + i3c_bus_maintenance_lock(&m->bus); + ret = i3c_master_populate_bus(m); + i3c_bus_maintenance_unlock(&m->bus); + if (!ret) { + i3c_bus_normaluse_lock(&m->bus); + i3c_master_register_new_i3c_devs(m); + i3c_bus_normaluse_unlock(&m->bus); + } + i3c_master_enable_mr_events(m); + + return ret; +} +EXPORT_SYMBOL_GPL(i3c_master_process_defslvs); + /** * i3c_master_unregister() - unregister an I3C master * @master: master used to send frames on the bus diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index dd67497ad8b1..688487c4a62a 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -488,6 +488,8 @@ struct i3c_master_controller_ops { * in a thread context. Typical examples are Hot Join processing which * requires taking the bus lock in maintenance, which in turn, can only * be done from a sleep-able context + * @defslvs_data: list used to pass i3c device list received in DEFSLVS message, + * from DEFSLVS controller driver to I3C core * * A &struct i3c_master_controller has to be registered to the I3C subsystem * through i3c_master_register(). None of &struct i3c_master_controller fields @@ -507,6 +509,10 @@ struct i3c_master_controller { } boardinfo; struct i3c_bus bus; struct workqueue_struct *wq; + struct { + u32 ndevs; + struct i3c_ccc_dev_desc *devs; + } defslvs_data; }; /** @@ -533,6 +539,7 @@ struct i3c_master_controller { void i3c_master_yield_bus(struct i3c_master_controller *m, u8 sec_mst_dyn_addr); +int i3c_master_process_defslvs(struct i3c_master_controller *m); int i3c_master_do_i2c_xfers(struct i3c_master_controller *master, const struct i2c_msg *xfers, int nxfers); From patchwork Mon May 11 13:16:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parshuram Raju Thombare X-Patchwork-Id: 11540705 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60800912 for ; Mon, 11 May 2020 13:17:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3C6EC20735 for ; Mon, 11 May 2020 13:17:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="B2VG8UEL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="HWuOSy31"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="c6VCaYU9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C6EC20735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cadence.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xDGFCK0fnrALN0Q/YZbr4jee/vLd2sxaHtZ/zWIlIyE=; b=B2VG8UELs+u3qj S7z8sU64VLCDMMU971EmsbuhEZUhpSTKnKUQ9yrBcPrBQ1E3G5jfXbBTPyoHg3wbPOwW1HSB5qfDd 4PNGPuJGeqf2ymFhhjZ5PRe+yvJGnjMXG5b3JHQ+J4NcSVsp1RKkh9puuarahFEwp2JaPPGq6lHjI GoD8WGnCFg3gPJDH1XOyXXHIooSt9eP3A5z2z9HL/ldMUj5KnJA+G8v6dpX734oOVX+KiOpFPK4f0 nd7OGR3Oy2ZdqsvbWRTwbb3UZZNOaKlAl0T9EhtMHW5lTA+1Y4xCfKKaS3oVhQm/6qzK80fQ8dq6t 8YTwgMyIfJ3iIP62BBfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8Ip-0001LS-0l; Mon, 11 May 2020 13:17:03 +0000 Received: from mx0b-0014ca01.pphosted.com ([208.86.201.193] helo=mx0a-0014ca01.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8Im-0001Kb-FD for linux-i3c@lists.infradead.org; Mon, 11 May 2020 13:17:01 +0000 Received: from pps.filterd (m0042333.ppops.net [127.0.0.1]) by mx0b-0014ca01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BDEOWk013457; Mon, 11 May 2020 06:16:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=D6ASknqDZ+R3RSj4O9hfCPcJF26w7yqdePhBoCzhyqE=; b=HWuOSy31r88rcdr28hwIwnfI2VLpl9uTvp1kRkhIBleIyqkY2LcqEVbBxipZ/iljV9AO PeknOT2vcQVXYA4nnsb549IgawSK7z6CJ6V7hS6zLACKhCXo9/w1bLXg4PiRV1EiWGXi AiodF/O2qVLqgmcNDTDoh6ED8p+kw6Dn0dgWJlgV0PfgjvHhbktdqESkna9Tdd9TQMvr fVA6JItlr66tRzfjaZC1E9WFOAAnCXpV36I9h9WNqmRK4r0m0UyitFONtmlJlurgpxaw ci45JwmgORovaGLXRZnml1vhU7uIzWFu3JSXZhp+mmOlHwcSR4pj6rhsTxp3sVj22Olr Ow== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by mx0b-0014ca01.pphosted.com with ESMTP id 30wr3xeaw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 06:16:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JNtNIh0Il+AON6JtH1CNx3Ox6oXCVTLqQlsIs1guVwN75a6olMNPooIBLWPwPb4aMTon0eu9SYiKVvBFXQX/MPCgfXbgvMgKh+O8Vuh2AHcRlyr3RUtYJIAd23qvwxryGIr6ZnP2jEiCtvCfGF2/0NGA8TLmlvHCk4Mbi3UKfr5zf/MZwtpNUc94vR/1MHG5BAMer5saaETk7G8L4/6QmB9WN0QN26law42qd/JlotFd5ETK8RAkN5GK53HllSWG/1oaNvH5pI1Br/s6+zJKf519SP0HipyJm4vVRgrUmexmPZq/sSUohvgc7HBko0hbQcWyMtG4IbIvHw5AFJjS0g== 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-SenderADCheck; bh=D6ASknqDZ+R3RSj4O9hfCPcJF26w7yqdePhBoCzhyqE=; b=gbVqNA0ClKO9pREhfmwH8joeZf1Nr+8d9Q6orCJFRQ7A323CZRu6BmDgA1/6XFaWSCj3y+o/BQwWcoA7h9fo7yx8089N6p9UOq973jOXGCGvyuPN3rBiw/mVBuU0nRfI1kIh/JqQUfNzCEoU/qXp88vC2CFN2unoPaY31c8z62W5YInPHxlPfOI+h0EHmZm+Soa+HW8UQNSMhEzAiGLwbTqvDQ8mUr+2Y+A3xWYKHwC8vqIocaQNGNmabOmlf/40avWHsP/nViyRCDaGLTPm4Y34wVTLqSY5EOFMvDyGzGQsQbtGqzEahNyFs0F/g2+HD+CsjbxPuppP5u6ppYp8JQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 199.43.4.23) smtp.rcpttodomain=synopsys.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D6ASknqDZ+R3RSj4O9hfCPcJF26w7yqdePhBoCzhyqE=; b=c6VCaYU9zyVSLefKFD2DZrjmz24qsmtGIlhays4VEuB+6mVkNxfyx6/yOMc3qR8omljLl5Xei6IXBiITcSTTdAxfOQmsGbtWIB0s++IxMdsNHefytsaCbNyp+n3iRdbo4UHyGiF7cnhwhgm276mMgorhp0b/trYKVLTZhXYo8pE= Received: from BN6PR1101CA0012.namprd11.prod.outlook.com (2603:10b6:405:4a::22) by DM6PR07MB7161.namprd07.prod.outlook.com (2603:10b6:5:1e1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.34; Mon, 11 May 2020 13:16:57 +0000 Received: from BN8NAM12FT024.eop-nam12.prod.protection.outlook.com (2603:10b6:405:4a:cafe::e0) by BN6PR1101CA0012.outlook.office365.com (2603:10b6:405:4a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28 via Frontend Transport; Mon, 11 May 2020 13:16:57 +0000 Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 199.43.4.23 as permitted sender) receiver=protection.outlook.com; client-ip=199.43.4.23; helo=rmmaillnx1.cadence.com; Received: from rmmaillnx1.cadence.com (199.43.4.23) by BN8NAM12FT024.mail.protection.outlook.com (10.13.183.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11 via Frontend Transport; Mon, 11 May 2020 13:16:56 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by rmmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDGrvI019936 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 11 May 2020 09:16:54 -0400 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 11 May 2020 15:16:51 +0200 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 11 May 2020 15:16:50 +0200 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDGokC010948; Mon, 11 May 2020 15:16:50 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 04BDGnXp010945; Mon, 11 May 2020 15:16:49 +0200 From: Parshuram Thombare To: , Subject: [PATCH v7 6/7] i3c: master: sysfs key for acquire bus Date: Mon, 11 May 2020 15:16:48 +0200 Message-ID: <1589203008-10880-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1589202702-4879-1-git-send-email-pthombar@cadence.com> References: <1589202702-4879-1-git-send-email-pthombar@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:199.43.4.23; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:rmmaillnx1.cadence.com; PTR:InfoDomainNonexistent; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(376002)(396003)(136003)(346002)(36092001)(46966005)(33430700001)(356005)(81166007)(82740400003)(33440700001)(82310400002)(107886003)(4326008)(5660300002)(86362001)(478600001)(2616005)(336012)(47076004)(2906002)(36756003)(426003)(8676002)(316002)(186003)(26005)(36906005)(70586007)(70206006)(42186006)(8936002)(110136005)(54906003); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6fa23c99-58ce-4c1f-536d-08d7f5ad946c X-MS-TrafficTypeDiagnostic: DM6PR07MB7161: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:510; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DYGuCxNzcKhNoAoWs4L0wSCXYm08G8hNwXxrERSuQEbskead0qikLE5GdaE5EYfV6qt8kDzQewE9IXUKhNCtkQ8MzC+/pA7iQpIWh+R3daQPI8VzmmC0ZY3N9dSFQtJPUfq7yj51i44TXu28SrCh47F2e5BuCVuH0cj4+Q3Lsx0WXLdTKohYWjayJJKqVClsoe/KwwHdiYKk4y8exKCAVhTQ8SVz1KkFfnyIrSscNUeg8OsuUQjnxAUgix1MQZh5WpjABt0FakszZO8HgQ8EBcBZnU3HpXrzCpqB5zZwMKknC9RLbo3Kzz2pRCCWqcClySAK3bL1oWCvcmRzrffG52YVXrWE6lMULXBwCFZ8PrejHmgoaxhAY4P116Hi7dsN0UW/o1OoIO+aGA78d/GezQnjg1GodeuCPRj6SkBGm9mraP9x5UB1U9QQaE8AhKeCCnmYF+9GLxK3Hl795xaeZibsoVCBBbjIYsvBwN9jSU+234FyWROdaoEFnk2LBf5OtzzNSXZO+tCjhVEXoSozI925SvBj0VZhXXF7B7FVSi3vK5Y6hrTXw2/qhRjo7W5ccm2U4hh1z/LwX8/0bsSEx1MrN68NXMGcHszNHtGmv0c= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 13:16:56.4239 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fa23c99-58ce-4c1f-536d-08d7f5ad946c X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9; Ip=[199.43.4.23]; Helo=[rmmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR07MB7161 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_05:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 mlxscore=0 phishscore=0 clxscore=1015 suspectscore=0 impostorscore=0 malwarescore=0 mlxlogscore=964 adultscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110110 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_061700_639037_2C667191 X-CRM114-Status: GOOD ( 10.55 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [208.86.201.193 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mparab@cadence.com, Parshuram Thombare , praneeth@ti.com, linux-kernel@vger.kernel.org, pgaj@cadence.com, linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org Added support to acquire I3C bus through sysfs interface. Signed-off-by: Parshuram Thombare --- drivers/i3c/master.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index ea53fadeed99..ec27196e987c 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -607,6 +607,23 @@ static ssize_t i2c_scl_frequency_show(struct device *dev, } static DEVICE_ATTR_RO(i2c_scl_frequency); +static ssize_t i3c_acquire_bus_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct i3c_master_controller *master = dev_to_i3cmaster(dev); + int ret; + + i3c_bus_normaluse_lock(&master->bus); + ret = i3c_master_acquire_bus(master); + i3c_bus_normaluse_unlock(&master->bus); + if (!ret) + i3c_master_enable_mr_events(master); + + return ret ?: count; +} +static DEVICE_ATTR_WO(i3c_acquire_bus); + static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_mode.attr, &dev_attr_current_master.attr, @@ -617,6 +634,7 @@ static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_pid.attr, &dev_attr_dynamic_address.attr, &dev_attr_hdrcap.attr, + &dev_attr_i3c_acquire_bus.attr, NULL, }; ATTRIBUTE_GROUPS(i3c_masterdev); From patchwork Mon May 11 13:17:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parshuram Raju Thombare X-Patchwork-Id: 11540707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98477913 for ; Mon, 11 May 2020 13:17:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 72ADF20735 for ; Mon, 11 May 2020 13:17:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="f2ptj6s0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="Uteur4VJ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="f+aN0uQC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 72ADF20735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cadence.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lQaCAaF/5kAGOUle4/zh08I3McHW8i7RFoNAKDkdZ2U=; b=f2ptj6s0u4DbsF dE2p6MHn36NXAK5YBMm7Dc3KLB/u2xHO7xl2veF6PFYz7R2QnasEuj7OGlfXW6//rvyhnE42rHZgI ZrOO3V5VYmbuIhOrs6rbtPhItG/A7EvDsraX0jjJlQq9+4z/9HmYzhVwhyKCpGYcbIza0ETCQiUyW NonzRfXJTW4ANlfIjjb0+GkpIvRc9lEzjX9fr5BtKSjp3S8i3XY/THCigPHXbnpxZHeWbvc4ztu60 rnI7HqAoTYixM0wemKUdEZ/w9KrbFOQIezEi2Zrv5jSNsNQqxD/Qubxq+SYfyIU0VB/PomMtBHukC O9zP4MbrVPxRxMmDMn0A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8JR-0001Og-62; Mon, 11 May 2020 13:17:41 +0000 Received: from mx0b-0014ca01.pphosted.com ([208.86.201.193] helo=mx0a-0014ca01.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY8JM-0001O2-Lq for linux-i3c@lists.infradead.org; Mon, 11 May 2020 13:17:39 +0000 Received: from pps.filterd (m0042333.ppops.net [127.0.0.1]) by mx0b-0014ca01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04BDEONN013452; Mon, 11 May 2020 06:17:34 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=proofpoint; bh=UtXxKqgtdoRLAx0Ug+UCUsVbZq2xBNWsTKonncytI3g=; b=Uteur4VJxorKIny4l3sTcvuI0iAR5wGp1hQloslFapHOCQgKqmglL98cWoANa85rzA3n T+ZPjBjkW/5u8mgr+it9f5SloW6m3LGGr+sAUwSs4RB1/Hn3OIZJ/SztwkgsQGRiCBTx HTWj2/YiRqTXzAaXOpDWHjSRhm1JEbFh7QVsgEUvJomCq/reuXmSnVgxofornxpzuVM/ RkH/X0yrFXyu2x1Jr5T7R8pWRDDgqjAUqDbGuuuw28qK/BoxOTnwD6zedzPPpVkoxaGH h/EjLtSYTi0lY/90F0JFmOfTxpzsVJRRsWng14cJrWAcaLVslngaRFNLwZLShsTM7IT8 3w== Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2056.outbound.protection.outlook.com [104.47.45.56]) by mx0b-0014ca01.pphosted.com with ESMTP id 30wr3xeay8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 May 2020 06:17:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S0D7CrIIOn7su+kdiXlBPYYx1BYRSXXY2ouSax6wG4Wv47Un9saefUV8k0DKJ340Q6tqfzOzfBAke71cHjy8E2Q6AwGUq0qcemmUVV/jUpyxiUsSrlh3Mq8BemjWP71bl0TckTJCDVRs17AEMYNhD1btI6nZxJKgO92IX+nUwdJj9/elwyAFW7Hkl5Zxswd7Nx7wtbGe3x6awbV/FEoPE7hV3kYDPo9fq24uavoi9Wxwlzb8eVs5EpHmzRswSknYIM2DOy36uxVEDAbvNM0F5gIMs2himHxiw5znx85Lf2ylrE8bXSgq7Q9eCiRikTopLzMnJLhsRoYU6JkkeOvHJQ== 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-SenderADCheck; bh=UtXxKqgtdoRLAx0Ug+UCUsVbZq2xBNWsTKonncytI3g=; b=Gi6S5VVVtlJulj9hszhJqJQ0Qe3TaEn4CnfXcNr/tIAxLE33GFxVqdWMql/XeOC9qzmoI7cVoXanLuYjMs/THLHBL0QDYvNO48CcKdOetFwZo9X+2JDoJSHXz5AlblgDtT1iBEmfK3u/b7r4Otn6WPh55sH3pCnlX05GyOvD+7IJtbOdvnrg+Z2lCigkstROGSQNt4yajoHKPDmLaz4X7ECogqvo35048OOgxi+j6Jqp7GyfhxXqMql1C3jFgqHhMchJWBhB6XHiK53Zh2lVBODCTn6+C0tAIgvl9dmpDiErisX6qLesCb6yBzA08bc4nGnlGXI18/OoQhAoalmggw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 158.140.1.147) smtp.rcpttodomain=synopsys.com smtp.mailfrom=cadence.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=cadence.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cadence.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UtXxKqgtdoRLAx0Ug+UCUsVbZq2xBNWsTKonncytI3g=; b=f+aN0uQCChH2Gej0LEpHX1WcJZxetW6yAOPjgSuL7K+gAZOXiLEg4oGy/d6+trMaGfzIy2EtJs/OSrcaCcw35h5ehDZikD3DxY68B82bjcz+5dLDKFrLNYvE/XqOO4EPDds106h9kfPWIhdFItGZ9n1Td9PBUD5SK4uvJuNBWns= Received: from DM5PR19CA0023.namprd19.prod.outlook.com (2603:10b6:3:151::33) by BYAPR07MB6247.namprd07.prod.outlook.com (2603:10b6:a03:11c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.34; Mon, 11 May 2020 13:17:30 +0000 Received: from DM6NAM12FT055.eop-nam12.prod.protection.outlook.com (2603:10b6:3:151:cafe::d6) by DM5PR19CA0023.outlook.office365.com (2603:10b6:3:151::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Mon, 11 May 2020 13:17:30 +0000 Received-SPF: Pass (protection.outlook.com: domain of cadence.com designates 158.140.1.147 as permitted sender) receiver=protection.outlook.com; client-ip=158.140.1.147; helo=sjmaillnx1.cadence.com; Received: from sjmaillnx1.cadence.com (158.140.1.147) by DM6NAM12FT055.mail.protection.outlook.com (10.13.179.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.11 via Frontend Transport; Mon, 11 May 2020 13:17:29 +0000 Received: from maileu3.global.cadence.com (maileu3.cadence.com [10.160.88.99]) by sjmaillnx1.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDHQxk029055 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 11 May 2020 06:17:27 -0700 X-CrossPremisesHeadersFilteredBySendConnector: maileu3.global.cadence.com Received: from maileu3.global.cadence.com (10.160.88.99) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 11 May 2020 15:17:25 +0200 Received: from vleu-orange.cadence.com (10.160.88.83) by maileu3.global.cadence.com (10.160.88.99) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 11 May 2020 15:17:25 +0200 Received: from vleu-orange.cadence.com (localhost.localdomain [127.0.0.1]) by vleu-orange.cadence.com (8.14.4/8.14.4) with ESMTP id 04BDHPKc011381; Mon, 11 May 2020 15:17:25 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 04BDHPJY011380; Mon, 11 May 2020 15:17:25 +0200 From: Parshuram Thombare To: , Subject: [PATCH v7 7/7] i3c: master: mastership handover, defslvs processing in cdns controller driver Date: Mon, 11 May 2020 15:17:24 +0200 Message-ID: <1589203044-11324-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1589202702-4879-1-git-send-email-pthombar@cadence.com> References: <1589202702-4879-1-git-send-email-pthombar@cadence.com> MIME-Version: 1.0 X-OrganizationHeadersPreserved: maileu3.global.cadence.com X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:158.140.1.147; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:sjmaillnx1.cadence.com; PTR:unknown.Cadence.COM; CAT:NONE; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(346002)(376002)(36092001)(46966005)(33430700001)(5660300002)(54906003)(30864003)(8936002)(2616005)(336012)(426003)(186003)(26005)(8676002)(107886003)(2906002)(4326008)(316002)(82740400003)(42186006)(36756003)(110136005)(36906005)(70586007)(70206006)(33440700001)(82310400002)(356005)(47076004)(7636003)(86362001)(478600001); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 28eedcf4-aa3b-402e-cb35-08d7f5ada855 X-MS-TrafficTypeDiagnostic: BYAPR07MB6247: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:243; X-Forefront-PRVS: 04004D94E2 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ALx1p0IjCEW3RqEkIIiRe6j7UEVmzH2nV0Xt9mC/cq2x3EcfNkqKYh0FZ261kTuxsVcAT+faymq8vBSLjMLDHz4R2J4a5Q9UcSmHETe7GGG/JpUHSriCXJpyQNPHABLKynWknZ6ZQdl392gwH0R/3+jzyzYiDr8xl0NyFJbjoKeXb3XtSUZwVMCXIzWAwDo3WPbtvgKa3Drl5WPNHlwueSqFepI/z/rHDFkbDU+IGumgiq/BghZYt/2ml50UqDiuVj/RgJvQW3AAjONq7JAc7hKerfHTGQYaIA8aw7aBx4u2FG/e6ZZBZULuCaaAo3GmWvwsNrr42L00Ego942KzeIN2UExgU/3AmUD4rEYMrkJtsxJxgL+tMIXdopnEfirSGVN8svI/EctmgN5XRiIbFbp1bXupVQZcBN/dbpPCjQmLhVVYI0hEKX0k7MKSbxWqRRcT9wBHGQZd76As0XzqFhwOKyi2AuWhj3c20hpUmRsUxGJBrxOPbEoBl0itBcTq8gXWpLpX4036s7uughZdDCkeQnCuFLQYEJ6QShzD2bMNjPOZQvjSS1Ei9+LanReFiwOC7rj3BYKWmUFaotXduc0oPbs8apAzzWoxBfA6Od8= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2020 13:17:29.6967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28eedcf4-aa3b-402e-cb35-08d7f5ada855 X-MS-Exchange-CrossTenant-Id: d36035c5-6ce6-4662-a3dc-e762e61ae4c9 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d36035c5-6ce6-4662-a3dc-e762e61ae4c9; Ip=[158.140.1.147]; Helo=[sjmaillnx1.cadence.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB6247 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.676 definitions=2020-05-11_05:2020-05-11, 2020-05-11 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 mlxscore=0 phishscore=0 clxscore=1015 suspectscore=2 impostorscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005110110 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_061736_902914_577710C3 X-CRM114-Status: GOOD ( 16.78 ) X-Spam-Score: -0.9 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at https://www.dnswl.org/, low trust [208.86.201.193 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux I3C List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mparab@cadence.com, Parshuram Thombare , praneeth@ti.com, linux-kernel@vger.kernel.org, pgaj@cadence.com, linux-i3c@lists.infradead.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org Added I3C bus mastership handover and DEFSLVS message handling code to Cadence's I3C master controller driver. Signed-off-by: Parshuram Thombare --- drivers/i3c/master/i3c-master-cdns.c | 377 +++++++++++++++++++++++++-- 1 file changed, 354 insertions(+), 23 deletions(-) diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c index ed4f43807f9e..1155aa327404 100644 --- a/drivers/i3c/master/i3c-master-cdns.c +++ b/drivers/i3c/master/i3c-master-cdns.c @@ -157,6 +157,7 @@ #define SLV_IMR 0x48 #define SLV_ICR 0x4c #define SLV_ISR 0x50 +#define SLV_INT_DEFSLVS BIT(21) #define SLV_INT_TM BIT(20) #define SLV_INT_ERROR BIT(19) #define SLV_INT_EVENT_UP BIT(18) @@ -189,7 +190,7 @@ #define SLV_STATUS1_HJ_DIS BIT(18) #define SLV_STATUS1_MR_DIS BIT(17) #define SLV_STATUS1_PROT_ERR BIT(16) -#define SLV_STATUS1_DA(x) (((s) & GENMASK(15, 9)) >> 9) +#define SLV_STATUS1_DA(s) (((s) & GENMASK(15, 9)) >> 9) #define SLV_STATUS1_HAS_DA BIT(8) #define SLV_STATUS1_DDR_RX_FULL BIT(7) #define SLV_STATUS1_DDR_TX_FULL BIT(6) @@ -390,6 +391,8 @@ struct cdns_i3c_xfer { struct cdns_i3c_master { struct work_struct hj_work; + struct work_struct mr_yield_work; + struct work_struct defslvs_work; struct i3c_master_controller base; u32 free_rr_slots; unsigned int maxdevs; @@ -408,6 +411,7 @@ struct cdns_i3c_master { struct clk *pclk; struct cdns_i3c_master_caps caps; unsigned long i3c_scl_lim; + u8 mr_addr; }; static inline struct cdns_i3c_master * @@ -1187,10 +1191,6 @@ static int cdns_i3c_master_do_daa(struct i3c_master_controller *m) cdns_i3c_master_upd_i3c_scl_lim(master); - /* Unmask Hot-Join and Mastership request interrupts. */ - i3c_master_enec_locked(m, I3C_BROADCAST_ADDR, - I3C_CCC_EVENT_HJ | I3C_CCC_EVENT_MR); - return 0; } @@ -1199,21 +1199,21 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m) struct cdns_i3c_master *master = to_cdns_i3c_master(m); unsigned long pres_step, sysclk_rate, max_i2cfreq; struct i3c_bus *bus = i3c_master_get_bus(m); - u32 ctrl, prescl0, prescl1, pres, low; + u32 ctrl, prescl0, prescl1, pres, low, bus_mode; struct i3c_device_info info = { }; int ret, ncycles; switch (bus->mode) { case I3C_BUS_MODE_PURE: - ctrl = CTRL_PURE_BUS_MODE; + bus_mode = CTRL_PURE_BUS_MODE; break; case I3C_BUS_MODE_MIXED_FAST: - ctrl = CTRL_MIXED_FAST_BUS_MODE; + bus_mode = CTRL_MIXED_FAST_BUS_MODE; break; case I3C_BUS_MODE_MIXED_SLOW: - ctrl = CTRL_MIXED_SLOW_BUS_MODE; + bus_mode = CTRL_MIXED_SLOW_BUS_MODE; break; default: @@ -1244,7 +1244,6 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m) bus->scl_rate.i2c = sysclk_rate / ((pres + 1) * 5); prescl0 |= PRESCL_CTRL0_I2C(pres); - writel(prescl0, master->regs + PRESCL_CTRL0); /* Calculate OD and PP low. */ pres_step = 1000000000 / (bus->scl_rate.i3c * 4); @@ -1252,7 +1251,6 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m) if (ncycles < 0) ncycles = 0; prescl1 = PRESCL_CTRL1_OD_LOW(ncycles); - writel(prescl1, master->regs + PRESCL_CTRL1); /* Get an address for the master. */ ret = i3c_master_get_free_addr(m, 0); @@ -1270,13 +1268,21 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m) if (ret) return ret; + ctrl = readl(master->regs + CTRL); + if (ctrl & CTRL_DEV_EN) + cdns_i3c_master_disable(master); + writel(prescl0, master->regs + PRESCL_CTRL0); + writel(prescl1, master->regs + PRESCL_CTRL1); + ctrl &= ~CTRL_BUS_MODE_MASK; + ctrl |= bus_mode | CTRL_HALT_EN | CTRL_MCS_EN; /* * Enable Hot-Join, and, when a Hot-Join request happens, disable all * events coming from this device. * * We will issue ENTDAA afterwards from the threaded IRQ handler. */ - ctrl |= CTRL_HJ_ACK | CTRL_HJ_DISEC | CTRL_HALT_EN | CTRL_MCS_EN; + if (!m->secondary) + ctrl |= CTRL_HJ_ACK | CTRL_HJ_DISEC; writel(ctrl, master->regs + CTRL); cdns_i3c_master_enable(master); @@ -1340,6 +1346,7 @@ static void cdns_i3c_master_handle_ibi(struct cdns_i3c_master *master, static void cnds_i3c_master_demux_ibis(struct cdns_i3c_master *master) { + struct i3c_dev_desc *dev; u32 status0; writel(MST_INT_IBIR_THR, master->regs + MST_ICR); @@ -1361,6 +1368,14 @@ static void cnds_i3c_master_demux_ibis(struct cdns_i3c_master *master) case IBIR_TYPE_MR: WARN_ON(IBIR_XFER_BYTES(ibir) || (ibir & IBIR_ERROR)); + if (ibir & IBIR_ACKED) { + dev = master->ibi.slots[IBIR_SLVID(ibir)]; + master->mr_addr = dev->info.dyn_addr; + queue_work(master->base.wq, + &master->mr_yield_work); + } + break; + default: break; } @@ -1372,16 +1387,40 @@ static irqreturn_t cdns_i3c_master_interrupt(int irq, void *data) struct cdns_i3c_master *master = data; u32 status; - status = readl(master->regs + MST_ISR); - if (!(status & readl(master->regs + MST_IMR))) - return IRQ_NONE; + if (master->base.this && + master->base.this == master->base.bus.cur_master) { + status = readl(master->regs + MST_ISR); + if (!(status & readl(master->regs + MST_IMR))) + return IRQ_NONE; + + spin_lock(&master->xferqueue.lock); + cdns_i3c_master_end_xfer_locked(master, status); + spin_unlock(&master->xferqueue.lock); + + if (status & MST_INT_IBIR_THR) + cnds_i3c_master_demux_ibis(master); + + if (status & MST_INT_MR_DONE) { + writel(FLUSH_RX_FIFO | FLUSH_TX_FIFO, + master->regs + FLUSH_CTRL); + writel(MST_INT_MR_DONE, master->regs + MST_ICR); + } + } else { + status = (readl(master->regs + SLV_ISR) & + readl(master->regs + SLV_IMR)); + + if (!status) + return IRQ_NONE; + + if (status & SLV_INT_MR_DONE) + writel(FLUSH_RX_FIFO | FLUSH_TX_FIFO, + master->regs + FLUSH_CTRL); - spin_lock(&master->xferqueue.lock); - cdns_i3c_master_end_xfer_locked(master, status); - spin_unlock(&master->xferqueue.lock); + if (status & SLV_INT_DEFSLVS) + queue_work(master->base.wq, &master->defslvs_work); - if (status & MST_INT_IBIR_THR) - cnds_i3c_master_demux_ibis(master); + writel(status, master->regs + SLV_ICR); + } return IRQ_HANDLED; } @@ -1505,6 +1544,138 @@ static void cdns_i3c_master_recycle_ibi_slot(struct i3c_dev_desc *dev, i3c_generic_ibi_recycle_slot(data->ibi_pool, slot); } +static int cdns_i3c_master_find_ibi_slot(struct cdns_i3c_master *master, + struct i3c_dev_desc *dev, + s16 *slot) +{ + unsigned long flags; + unsigned int i; + int ret = -ENOENT; + + spin_lock_irqsave(&master->ibi.lock, flags); + for (i = 0; i < master->ibi.num_slots; i++) { + if (master->ibi.slots[i] == dev) { + *slot = i; + ret = 0; + break; + } + } + + if (ret) { + for (i = 0; i < master->ibi.num_slots; i++) { + if (!master->ibi.slots[i]) { + master->ibi.slots[i] = dev; + *slot = i; + ret = 0; + break; + } + } + } + spin_unlock_irqrestore(&master->ibi.lock, flags); + + return ret; +} + +static int cdns_i3c_request_mastership(struct i3c_master_controller *m) +{ + struct cdns_i3c_master *master = to_cdns_i3c_master(m); + int status; + + status = readl(master->regs + MST_STATUS0); + + if (status & MST_STATUS0_MASTER_MODE) + return 0; + + status = readl(master->regs + SLV_STATUS1); + + if (status & SLV_STATUS1_MR_DIS) + return -EACCES; + + writel(readl(master->regs + CTRL) | CTRL_MST_INIT | CTRL_MST_ACK, + master->regs + CTRL); + + return 0; +} + +static void +cdns_i3c_master_enable_mastership_events(struct i3c_master_controller *m) +{ + struct cdns_i3c_master *master = to_cdns_i3c_master(m); + struct cdns_i3c_i2c_dev_data *data; + struct i3c_dev_desc *i3cdev; + unsigned long flags; + u32 sircfg, sirmap; + int ret; + + i3c_bus_for_each_i3cdev(&m->bus, i3cdev) { + if (I3C_BCR_DEVICE_ROLE(i3cdev->info.bcr) != + I3C_BCR_I3C_MASTER || + m->this == i3cdev) + continue; + + data = i3c_dev_get_master_data(i3cdev); + if (!data) + continue; + + ret = cdns_i3c_master_find_ibi_slot(master, i3cdev, &data->ibi); + if (ret) + continue; + + spin_lock_irqsave(&master->ibi.lock, flags); + sirmap = readl(master->regs + SIR_MAP_DEV_REG(data->ibi)); + sirmap &= ~SIR_MAP_DEV_CONF_MASK(data->ibi); + sircfg = SIR_MAP_DEV_ROLE(i3cdev->info.bcr >> 6) | + SIR_MAP_DEV_DA(i3cdev->info.dyn_addr) | + SIR_MAP_DEV_PL(i3cdev->info.max_ibi_len) | + SIR_MAP_DEV_ACK; + + if (i3cdev->info.bcr & I3C_BCR_MAX_DATA_SPEED_LIM) + sircfg |= SIR_MAP_DEV_SLOW; + + sirmap |= SIR_MAP_DEV_CONF(data->ibi, sircfg); + writel(sirmap, master->regs + SIR_MAP_DEV_REG(data->ibi)); + spin_unlock_irqrestore(&master->ibi.lock, flags); + } +} + +static bool +cdns_i3c_master_check_event_set(struct i3c_master_controller *m, + enum i3c_event event) +{ + struct cdns_i3c_master *master = to_cdns_i3c_master(m); + bool ret = false; + + switch (event) { + case I3C_SLV_DA_UPDATE: + if (readl(master->regs + SLV_STATUS1) & SLV_STATUS1_HAS_DA) + ret = true; + break; + + case I3C_SLV_MR_DONE: + if (readl(master->regs + MST_STATUS0) & MST_STATUS0_MASTER_MODE) + ret = true; + break; + + default: + break; + } + + return ret; +} + +int cdns_i3c_sec_master_dyn_addr(struct i3c_master_controller *m) +{ + struct cdns_i3c_master *master = to_cdns_i3c_master(m); + int dyn_addr = -1; + u32 status; + + status = readl(master->regs + SLV_STATUS1); + if (status & SLV_STATUS1_HAS_DA) + dyn_addr = SLV_STATUS1_DA(status); + + return dyn_addr; +} + static const struct i3c_master_controller_ops cdns_i3c_master_ops = { .bus_init = cdns_i3c_master_bus_init, .bus_cleanup = cdns_i3c_master_bus_cleanup, @@ -1524,6 +1695,10 @@ static const struct i3c_master_controller_ops cdns_i3c_master_ops = { .request_ibi = cdns_i3c_master_request_ibi, .free_ibi = cdns_i3c_master_free_ibi, .recycle_ibi_slot = cdns_i3c_master_recycle_ibi_slot, + .request_mastership = cdns_i3c_request_mastership, + .enable_mr_events = cdns_i3c_master_enable_mastership_events, + .check_event_set = cdns_i3c_master_check_event_set, + .sec_mst_dyn_addr = cdns_i3c_sec_master_dyn_addr, }; static void cdns_i3c_master_hj(struct work_struct *work) @@ -1535,10 +1710,152 @@ static void cdns_i3c_master_hj(struct work_struct *work) i3c_master_do_daa(&master->base); } +static void cdns_i3c_master_yield(struct work_struct *work) +{ + struct cdns_i3c_master *master = container_of(work, + struct cdns_i3c_master, + mr_yield_work); + + i3c_master_yield_bus(&master->base, master->mr_addr); +} + +static void cdns_i3c_sec_master_defslvs(struct work_struct *work) +{ + struct cdns_i3c_master *master = container_of(work, + struct cdns_i3c_master, + defslvs_work); + struct i3c_master_controller *m = &master->base; + struct i3c_ccc_dev_desc *desc; + struct cdns_i3c_i2c_dev_data *data; + struct i2c_dev_desc *i2cdev; + struct i3c_dev_desc *i3cdev; + u32 devs, val, rr, slot; + u32 r0, r1, r2; + u8 saddr; + + devs = readl(master->regs + DEVS_CTRL) & DEVS_CTRL_DEVS_ACTIVE_MASK; + master->free_rr_slots = GENMASK(master->maxdevs, 1) & ~devs; + + /* + * We chose to ignore I2C devices received from + * main master and use I2C device info from boardinfo. + * Since I2C device from boardinfo are already + * registered during bus_init, we just use same slot + * and if any I3C device is received in DEFSLVS in that + * place, just move that I3C device to other free slot. + * If there is no free slot, then such I3C devices + * are ignored. + * Master controller driver can chose how to handle I2C + * devices in DEFSLVS and pass only I3C devices list to + * I3C core DEFSVLS processing to handle hotplug and + * I3C device address changes. + */ + for (slot = 0; slot < master->maxdevs; slot++) { + if (!(devs & BIT(slot))) + continue; + + val = readl(master->regs + DEV_ID_RR0(slot)); + if (!(val & DEV_ID_RR0_IS_I3C)) { + writel(readl(master->regs + DEVS_CTRL) | + DEVS_CTRL_DEV_CLR(slot), + master->regs + DEVS_CTRL); + master->free_rr_slots |= BIT(slot); + } + } + + val = 0; + devs = readl(master->regs + DEVS_CTRL) & DEVS_CTRL_DEVS_ACTIVE_MASK; + i3c_bus_for_each_i2cdev(&m->bus, i2cdev) { + data = i2c_dev_get_master_data(i2cdev); + if (devs & BIT(data->id)) { + rr = readl(master->regs + DEV_ID_RR0(data->id)); + saddr = DEV_ID_RR0_GET_DEV_ADDR(rr); + if (saddr != i2cdev->boardinfo->base.addr) { + r0 = readl(master->regs + DEV_ID_RR0(data->id)); + r1 = readl(master->regs + DEV_ID_RR1(data->id)); + r2 = readl(master->regs + DEV_ID_RR2(data->id)); + slot = ffs(master->free_rr_slots) - 1; + if (slot > 0) { + writel(r0, + master->regs + DEV_ID_RR0(slot)); + writel(r1, + master->regs + DEV_ID_RR1(slot)); + writel(r2, + master->regs + DEV_ID_RR2(slot)); + writel(readl(master->regs + DEVS_CTRL) | + DEVS_CTRL_DEV_ACTIVE(slot), + master->regs + DEVS_CTRL); + master->free_rr_slots &= ~BIT(slot); + } + } else { + continue; + } + } + writel(readl(master->regs + DEVS_CTRL) | + DEVS_CTRL_DEV_CLR(data->id), + master->regs + DEVS_CTRL); + writel(readl(master->regs + DEVS_CTRL) | + DEVS_CTRL_DEV_ACTIVE(data->id), + master->regs + DEVS_CTRL); + writel(prepare_rr0_dev_address(i2cdev->boardinfo->base.addr) | + (i2cdev->boardinfo->base.flags & I2C_CLIENT_TEN ? + DEV_ID_RR0_LVR_EXT_ADDR : 0), + master->regs + DEV_ID_RR0(data->id)); + writel(i2cdev->boardinfo->lvr, + master->regs + DEV_ID_RR2(data->id)); + master->free_rr_slots &= ~BIT(data->id); + } + + master->base.defslvs_data.ndevs = 0; + desc = master->base.defslvs_data.devs; + devs = readl(master->regs + DEVS_CTRL) & DEVS_CTRL_DEVS_ACTIVE_MASK; + + for (slot = 0; slot < master->maxdevs; slot++) { + if (!(devs & BIT(slot))) + continue; + + val = readl(master->regs + DEV_ID_RR0(slot)); + if (val & DEV_ID_RR0_IS_I3C) { + memset(desc, 0, sizeof(struct i3c_ccc_dev_desc)); + rr = readl(master->regs + DEV_ID_RR0(slot)); + desc->dyn_addr = DEV_ID_RR0_GET_DEV_ADDR(rr); + rr = readl(master->regs + DEV_ID_RR2(slot)); + desc->dcr = rr; + desc->bcr = rr >> 8; + master->base.defslvs_data.ndevs++; + desc++; + } + } + + if (i3c_master_process_defslvs(m)) { + queue_work(master->base.wq, work); + return; + } + + /* + * Fix data->id for any changes due to mismatch in number + * of I2C devices on main and secondary master, causing + * I3C devices received in DEFSLVS in a slot which was used + * for I2C device on sec master to be moved to other free + * slot. And then if any I3C device get unplugged + * next DEFSLVS processing would I3C devices in original + * I2C slot to be moved to different slot than it + * was moved at the first DEFSLVS processing. + */ + i3c_bus_for_each_i3cdev(&m->bus, i3cdev) { + data = i3c_dev_get_master_data(i3cdev); + if (!data) + continue; + data->id = cdns_i3c_master_get_rr_slot(master, + i3cdev->info.dyn_addr); + } +} + static int cdns_i3c_master_probe(struct platform_device *pdev) { struct cdns_i3c_master *master; struct resource *res; + bool secondary; int ret, irq; u32 val; @@ -1579,6 +1896,7 @@ static int cdns_i3c_master_probe(struct platform_device *pdev) spin_lock_init(&master->xferqueue.lock); INIT_LIST_HEAD(&master->xferqueue.list); + INIT_WORK(&master->mr_yield_work, cdns_i3c_master_yield); INIT_WORK(&master->hj_work, cdns_i3c_master_hj); writel(0xffffffff, master->regs + MST_IDR); writel(0xffffffff, master->regs + SLV_IDR); @@ -1590,6 +1908,7 @@ static int cdns_i3c_master_probe(struct platform_device *pdev) platform_set_drvdata(pdev, master); val = readl(master->regs + CONF_STATUS0); + secondary = (val & CONF_STATUS0_SEC_MASTER) ? true : false; /* Device ID0 is reserved to describe this master. */ master->maxdevs = CONF_STATUS0_DEVS_NUM(val); @@ -1610,12 +1929,24 @@ static int cdns_i3c_master_probe(struct platform_device *pdev) if (!master->ibi.slots) goto err_disable_sysclk; + if (secondary) + INIT_WORK(&master->defslvs_work, cdns_i3c_sec_master_defslvs); + writel(IBIR_THR(1), master->regs + CMD_IBI_THR_CTRL); - writel(MST_INT_IBIR_THR, master->regs + MST_IER); + writel(MST_INT_IBIR_THR | MST_INT_MR_DONE, master->regs + MST_IER); writel(DEVS_CTRL_DEV_CLR_ALL, master->regs + DEVS_CTRL); - ret = i3c_master_register(&master->base, &pdev->dev, - &cdns_i3c_master_ops); + if (secondary) { + ret = i3c_secondary_master_register(&master->base, &pdev->dev, + &cdns_i3c_master_ops); + if (!ret) + writel(SLV_INT_DEFSLVS | SLV_INT_MR_DONE, + master->regs + SLV_IER); + } else { + ret = i3c_master_register(&master->base, &pdev->dev, + &cdns_i3c_master_ops); + } + if (ret) goto err_disable_sysclk;