From patchwork Mon Apr 6 22:21:43 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: 11479725 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 DD0C91893 for ; Wed, 8 Apr 2020 10:01:55 +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 B6F3920771 for ; Wed, 8 Apr 2020 10:01:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sr0NBG5c"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="ByDtxukF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="GxY2LbNP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6F3920771 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=XERIlqvdjp/BlwBUL5Eid5sNsTB0NYWSbWyZzEgu5eU=; b=sr0NBG5cjF3Bps P4x9FUfCRUZflfOIHaOHStSXpAx4iDqhUTpa6tgYzNkp+eHmI/DOTZETHjFQhc0Un02rNH9BdIiQc n83ZwknSynhM5QK0hSi3/oMvUckvaA7EfAb+rNsGhuMX2mohqK2lV66lE+CxcOW0cFvy7ZnUr3f5p b3YdogOh5y93Xhvd91lV63hIIhcOYieiVVi8d48R5YoOLO+AsyKQbyLOq56h8JfsGJmlaFxk1BYVk 6BGx+kmhZ6VvUwqj3xtY1ghKmPWurbwTEvlBDV7TB6xnLvh7jtK+3vsR5qoGDtc0ooF7hzvdv1FLm JWGE4gKs40PlqGkSK1KA==; 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 1jM7Wp-0004rp-CH; Wed, 08 Apr 2020 10:01:51 +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 1jLa7t-0005rN-Fi for linux-i3c@lists.infradead.org; Mon, 06 Apr 2020 22:21:55 +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 036MGvhx003807; Mon, 6 Apr 2020 15:21:52 -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=w9lCPLv2HC7RRhOjj8aCZiyTVq/tBNMk+rrYBZGIfRQ=; b=ByDtxukFI8cQ3kKNM/J46zWVLiCjM/y/yHFVVx8yD6NJaOfPgGY/+ojM1fXLGPr/MG8z c5KO+bEzrvpGMJ2gOpawCtPiKaSIIslsZengLbUGqSrYHR9vbETy+48wt7zhSqwlkqtK HCBNlAtA1d7jozxxmUXmISE0EFn4iS3IYIw72r4+OVJux6HMlm5uZWhhRMM7j9sPEzEm /gTPHowo79Bp3G2Nn4I74CwDM2V5qKsWbwzQrWOpVUFtmRCTU5/98HYwczvssRvzEYE/ wkNAhSfqBOOhVAI8Y7rQyAg5KMWJgIQly670J6gCNiEurKopF2jMb2fnw8qoUtQUUPfi lQ== Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by mx0a-0014ca01.pphosted.com with ESMTP id 306psw07gq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Apr 2020 15:21:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LBNbMjnbf++cDoc5ZGvF8CmHcUo175fH9ES0XHj7VetCeo9G3/fgO8vJFzqckg0kHusByLummt2/c80+zbr9vjP1QS51g1uI6ZTLUuyHKoenYaZIim9Z4cq6Mt1UWYg0tpmecU40e6NrFbyUx8DuqGN5a5b54jE/5p9qU+M4L1iM6tVR7KxK7oSuq2seciO17jKZzsZwR4kA5mcgGdZd8KFlzVHeny0Hui+aiNcDJicK7mOgnHAOUPJUvjLjDn29jrySmIPlGn38qNlrptjcccoNEV+jUJ4gp5Fbjx9DBHQgqq8xLgLsD9CR5upjkbDyxRp6t5hxr/icv9nt8SMhYw== 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=w9lCPLv2HC7RRhOjj8aCZiyTVq/tBNMk+rrYBZGIfRQ=; b=OQUNi+4RRKNi1roUrIU7yzOaVWBnIqEwtxcMLKpYilPo5rS/5Uh0bA7JqyzhDCfGTgN+VB81tXJjhQ+r/8seBvuOJFArSMdH2L7pS2cZ/NBkNJyl1YK9pYdDJ6c0HCXtOYsn1c5viL19IyQicYRfycz3YE2WbnamiC3igQv8WYjNphtgV5uuNLJHWzf1+j8C+D0w8LVbx8jI+4kapSVX0KbMnEWDahLJCeGuvJACe+q0JgrweW7zvlwkOT4KzC1/30/gdQiZPcUZGtxpbNVbsrfUaSECh45HocJk8cvGs5TyyybH0Ba7zGIzJ41ufxQfcXBKnxo0uCpNDOV4Kf92jw== 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=w9lCPLv2HC7RRhOjj8aCZiyTVq/tBNMk+rrYBZGIfRQ=; b=GxY2LbNP9BhEFEcrANSM2aNMvKDgoQrmb4mG5zIiwm4fHLV9J1Ji+U9K2zfTqpVkQfI9nnT8yyOFwyPTc2fySe1OETqHVRCTG24N+lvWxzrX8zL+138Eu5wZqz2ZKpxEWg1C+BGr1uYF+vyg3wfnSRE3oUzUpi4Ax5nWH6S8kL4= Received: from MN2PR02CA0017.namprd02.prod.outlook.com (2603:10b6:208:fc::30) by BL0PR07MB3874.namprd07.prod.outlook.com (2603:10b6:207:4b::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.20; Mon, 6 Apr 2020 22:21:50 +0000 Received: from BN8NAM12FT010.eop-nam12.prod.protection.outlook.com (2603:10b6:208:fc:cafe::cd) by MN2PR02CA0017.outlook.office365.com (2603:10b6:208:fc::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.15 via Frontend Transport; Mon, 6 Apr 2020 22:21:50 +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 BN8NAM12FT010.mail.protection.outlook.com (10.13.182.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.9 via Frontend Transport; Mon, 6 Apr 2020 22:21:49 +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 036MLju5009940 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Mon, 6 Apr 2020 15:21:48 -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; Tue, 7 Apr 2020 00:21:45 +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; Tue, 7 Apr 2020 00:21:45 +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 036MLjRn008923; Tue, 7 Apr 2020 00:21:45 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 036MLj0r008922; Tue, 7 Apr 2020 00:21:45 +0200 From: Parshuram Thombare To: , Subject: [PATCH v1 2/3] i3c: add mastership handover support to i3c master subsystem Date: Tue, 7 Apr 2020 00:21:43 +0200 Message-ID: <1586211703-8862-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1586211645-8065-1-git-send-email-pthombar@cadence.com> References: <1586211645-8065-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:(10009020)(4636009)(396003)(136003)(39850400004)(376002)(346002)(36092001)(46966005)(47076004)(30864003)(356004)(2616005)(36906005)(36756003)(186003)(336012)(8676002)(42186006)(107886003)(26826003)(478600001)(86362001)(54906003)(4326008)(316002)(2906002)(110136005)(426003)(82740400003)(5660300002)(8936002)(7636002)(70206006)(26005)(246002)(70586007)(42413003); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82515725-c5c8-4e11-c1f1-08d7da78e6af X-MS-TrafficTypeDiagnostic: BL0PR07MB3874: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:372; X-Forefront-PRVS: 0365C0E14B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OOAbMYhvFFOmzAtz8Ia1T4VNki9KmSRvfGS+pVrtFUqa0wlzFLPsuwwStwpC+B/UzUF4lGni+IVuJ+uaAzfNI/kZwoOidHoTAE58sWc5laB46Q/ohD0hUI0nZEgo2shulPRFjLJma3Y/e337oQsjgNQ9r/vrhrdiVgM/EIpHEuaS+9Tdxk1BQcCKrxDwN4VZpF+YzsEhvMnIrDluu1zeXTFvGzxE9VKLtoFPMBbqEsGKJvMgmcNgT2JNNCyprYntsmEJE07on06RYS7NRl8/suuOsSMhq5N0CpWzXn9kBaQ+y81p03DC78djST718lgi/dWk6P3xzJrDnRd3vk/X0SXh4o23IJYQCYBmD5GnH8EGp1CSZbMdu0GHThPAsNdXh5xepcsXfEYo66XpEBUke/c548ZHmwQZns7P4SCghZ0AWIOcXrhvRDf8FmBTqGNB2lUZ7OHPcVQMDHX0gFR8cj3YUwrvtiya5T0k4UwQHxwrtMF1nLPkJo984ermBSexiEwyyrvxNhcTfgSBEc531NhVRkoLSuk2UClpp4Ay+W52Kjc8DsTLXATyqGEejqkY X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2020 22:21:49.5424 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82515725-c5c8-4e11-c1f1-08d7da78e6af 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: BL0PR07MB3874 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-06_10:2020-04-06, 2020-04-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 bulkscore=0 spamscore=0 clxscore=1015 adultscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=999 mlxscore=0 suspectscore=2 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060169 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200406_152153_542544_8D3E692A X-CRM114-Status: GOOD ( 18.41 ) 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Mailman-Approved-At: Wed, 08 Apr 2020 03:01:49 -0700 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, pgaj@cadence.com, Parshuram Thombare , linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org This patch adds mastership handover support to I3C master subsystem as per MIPI I3C v1.0 specification. Signed-off-by: Parshuram Thombare --- drivers/i3c/master.c | 486 ++++++++++++++++++++++++++++++++++--- include/linux/i3c/master.h | 40 +++ 2 files changed, 487 insertions(+), 39 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 0ec332e45737..42b6385fc3c8 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -963,6 +963,33 @@ int i3c_master_defslvs_locked(struct i3c_master_controller *master) } EXPORT_SYMBOL_GPL(i3c_master_defslvs_locked); +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 int i3c_master_setda_locked(struct i3c_master_controller *master, u8 oldaddr, u8 newaddr, bool setdasa) { @@ -1525,6 +1552,185 @@ int i3c_master_do_daa(struct i3c_master_controller *master) } EXPORT_SYMBOL_GPL(i3c_master_do_daa); +static int i3c_master_getaccmst(struct i3c_master_controller *master) +{ + int ret; + + i3c_bus_maintenance_lock(&master->bus); + ret = i3c_master_get_accmst_locked(master, master->mr_addr); + i3c_bus_maintenance_unlock(&master->bus); + + return ret; +} + +static int i3c_master_request_mastership(struct i3c_master_controller *master) +{ + int ret; + + /* request_mastership callback should handle EN/DIS EC MR.*/ + i3c_bus_maintenance_lock(&master->bus); + ret = master->ops->request_mastership(master); + i3c_bus_maintenance_unlock(&master->bus); + + return ret; +} + +static void i3c_mst_yield_bus(struct work_struct *work) +{ + struct i3c_master_controller *m; + struct i3c_dev_desc *i3cdev; + int ret; + + m = container_of(work, struct i3c_master_controller, mst_work); + switch (m->mr_state) { + case I3C_MR_DISEC_MR: + /* + * Disable MR on all but the secondary master first + * reaching here. + */ + i3c_bus_for_each_i3cdev(&m->bus, i3cdev) { + if (I3C_BCR_DEVICE_ROLE(i3cdev->info.bcr) != + I3C_BCR_I3C_MASTER || + i3cdev->info.dyn_addr == m->mr_addr || + m->this == i3cdev) + continue; + i3c_bus_maintenance_lock(&m->bus); + i3c_master_disec_locked(m, i3cdev->info.dyn_addr, + I3C_CCC_EVENT_MR); + i3c_bus_maintenance_unlock(&m->bus); + } + m->mr_state = I3C_MR_GETACCMST; + queue_work(m->wq, &m->mst_work); + break; + + case I3C_MR_GETACCMST: + ret = i3c_master_getaccmst(m); + if (!ret) + m->mr_state = I3C_MR_DONE; + else + m->mr_state = I3C_MR_FAILED; + queue_work(m->wq, &m->mst_work); + break; + + case I3C_MR_DONE: + i3c_bus_for_each_i3cdev(&m->bus, i3cdev) { + if (m->mr_addr == i3cdev->info.dyn_addr) { + m->bus.cur_master = i3cdev; + break; + } + } + m->mr_state = I3C_MR_IDLE; + break; + + case I3C_MR_FAILED: + m->ops->enable_mr_events(m); + i3c_bus_maintenance_lock(&m->bus); + i3c_master_enec_locked(m, I3C_BROADCAST_ADDR, + I3C_CCC_EVENT_MR); + i3c_bus_maintenance_unlock(&m->bus); + m->mr_state = I3C_MR_IDLE; + break; + + default: + break; + } +} + +void +i3c_master_yield_bus(struct i3c_master_controller *master, u8 sec_mst_dyn_addr) +{ + master->ops->disable_mr_events(master); + master->mr_addr = sec_mst_dyn_addr; + master->mr_state = I3C_MR_DISEC_MR; + queue_work(master->wq, &master->mst_work); +} +EXPORT_SYMBOL_GPL(i3c_master_yield_bus); + +static void i3c_sec_mst_acquire_bus(struct work_struct *work) +{ + struct i3c_master_controller *m; + struct i3c_bus *i3cbus; + int ret; + + m = container_of(work, struct i3c_master_controller, sec_mst_work); + i3cbus = i3c_master_get_bus(m); + switch (m->mr_state) { + case I3C_MR_WAIT_DA: + /* Wait until this master have dynamic address */ + if (m->ops->check_event_set(m, I3C_SLV_DA_UPDATE)) + m->mr_state = I3C_MR_REQUEST; + queue_work(m->wq, &m->sec_mst_work); + break; + + case I3C_MR_REQUEST: + /* Wait until we can send MR */ + ret = i3c_master_request_mastership(m); + if (!ret) + m->mr_state = I3C_MR_WAIT_DEFSLVS; + queue_work(m->wq, &m->sec_mst_work); + break; + + case I3C_MR_WAIT_DEFSLVS: + /* + * Wait for DEFSLVS, this event check should make sure + * that DEFSLVS list is read into m->defslvs_data + */ + if (m->ops->check_event_set(m, I3C_SLV_DEFSLVS_CCC)) + m->mr_state = I3C_MR_WAIT_MR_DONE; + queue_work(m->wq, &m->sec_mst_work); + break; + + case I3C_MR_WAIT_MR_DONE: + if (m->ops->check_event_set(m, I3C_SLV_MR_DONE)) { + m->mr_state = I3C_MR_DONE; + complete(&m->mr_comp); + } else { + queue_work(m->wq, &m->sec_mst_work); + } + break; + + default: + m->mr_state = I3C_MR_FAILED; + complete(&m->mr_comp); + break; + } +} + +void i3c_sec_mst_mr_dis_event(struct i3c_master_controller *m) +{ + if (m->mr_state != I3C_MR_IDLE) + m->mr_state = I3C_MR_WAIT_DA; +} +EXPORT_SYMBOL_GPL(i3c_sec_mst_mr_dis_event); + +static int i3c_master_acquire_bus(struct i3c_master_controller *master) +{ + int ret = 0; + + if (!master->this || master->this != master->bus.cur_master) { + i3c_bus_normaluse_lock(&master->bus); + if (master->mr_state == I3C_MR_IDLE) { + master->mr_state = I3C_MR_WAIT_DA; + i3c_bus_normaluse_unlock(&master->bus); + init_completion(&master->mr_comp); + queue_work(master->wq, &master->sec_mst_work); + wait_for_completion(&master->mr_comp); + if (master->mr_state != I3C_MR_DONE) + ret = -EAGAIN; + master->mr_state = I3C_MR_IDLE; + } else { + /* + * MR request is already in process for + * this master + */ + ret = -EAGAIN; + i3c_bus_normaluse_unlock(&master->bus); + } + } + + return ret; +} + /** * i3c_master_set_info() - set master device information * @master: master used to send frames on the bus @@ -1558,10 +1764,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; @@ -1622,9 +1824,10 @@ static void i3c_master_detach_free_devs(struct i3c_master_controller *master) * 1. Attach I2C and statically defined I3C devs to the master so that the * master can fill its internal device table appropriately * - * 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) + * 2. Should have called &i3c_master_controller_ops->bus_init() + * method with pure bus mode to initialize the master controller. + * That's usually where the bus mode is selected (pure bus or + * mixed fast/slow bus) * * 3. Instruct all devices on the bus to drop their dynamic address. This is * particularly important when the bus was previously configured by someone @@ -1708,14 +1911,6 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) } } - /* - * 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; - ret = master->ops->master_set_info(master); if (ret) goto err_detach_devs; @@ -1728,7 +1923,7 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) dev_err(&master->dev, "master_set_info() was not called in ->bus_init()\n"); ret = -EINVAL; - goto err_bus_cleanup; + goto err_detach_devs; } /* @@ -1737,14 +1932,14 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) */ ret = i3c_master_rstdaa_locked(master, I3C_BROADCAST_ADDR); if (ret && ret != I3C_ERROR_M2) - goto err_bus_cleanup; + goto err_detach_devs; /* Disable all slave events before starting DAA. */ ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR, I3C_CCC_EVENT_SIR | I3C_CCC_EVENT_MR | I3C_CCC_EVENT_HJ); if (ret && ret != I3C_ERROR_M2) - goto err_bus_cleanup; + goto err_detach_devs; /* * Pre-assign dynamic address and retrieve device information if @@ -1762,10 +1957,6 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) err_rstdaa: i3c_master_rstdaa_locked(master, I3C_BROADCAST_ADDR); -err_bus_cleanup: - if (master->ops->bus_cleanup) - master->ops->bus_cleanup(master); - err_detach_devs: i3c_master_detach_free_devs(master); @@ -2249,6 +2440,9 @@ void i3c_generic_ibi_free_pool(struct i3c_generic_ibi_pool *pool) struct i3c_generic_ibi_slot *slot; unsigned int nslots = 0; + if (!pool) + return; + while (!list_empty(&pool->free_slots)) { slot = list_first_entry(&pool->free_slots, struct i3c_generic_ibi_slot, node); @@ -2392,9 +2586,179 @@ 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->disable_mr_events || + !ops->check_event_set)) + return -EINVAL; + return 0; } +static struct i2c_dev_boardinfo * +i3c_master_alloc_i2c_boardinfo(struct i3c_master_controller *master, + u16 addr, u8 lvr) +{ + struct i2c_dev_boardinfo *i2cboardinfo; + + i2cboardinfo = kzalloc(sizeof(*i2cboardinfo), GFP_KERNEL); + if (!i2cboardinfo) + return ERR_PTR(-ENOMEM); + + i2cboardinfo->base.addr = addr; + i2cboardinfo->lvr = lvr; + + return i2cboardinfo; +} + +static int i3c_secondary_master_bus_init(struct i3c_master_controller *master) +{ + struct i3c_ccc_dev_desc *desc; + struct i3c_dev_desc *i3cdev; + struct i2c_dev_desc *i2cdev; + struct i2c_dev_boardinfo *info; + int ret, slot; + + desc = master->defslvs_data.devs; + for (slot = 1; slot <= master->defslvs_data.ndevs; slot++, desc++) { + if (desc->static_addr) { + i3c_bus_set_addr_slot_status(&master->bus, + desc->static_addr, + I3C_ADDR_SLOT_I2C_DEV); + info = i3c_master_alloc_i2c_boardinfo(master, + desc->static_addr, + desc->lvr); + if (IS_ERR(info)) { + ret = PTR_ERR(info); + goto err_detach_devs; + } + + i2cdev = i3c_master_alloc_i2c_dev(master, info); + 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; + } + } else { + struct i3c_device_info info = { + .dyn_addr = desc->dyn_addr, + }; + + i3cdev = i3c_master_alloc_i3c_dev(master, &info); + if (IS_ERR(i3cdev)) { + ret = PTR_ERR(i3cdev); + goto err_detach_devs; + } + + ret = i3c_master_attach_i3c_dev(master, i3cdev); + if (ret) { + i3c_master_free_i3c_dev(i3cdev); + goto err_detach_devs; + } + } + } + + ret = master->ops->master_set_info(master); + if (ret) + goto err_bus_cleanup; + + i3c_bus_for_each_i3cdev(&master->bus, i3cdev) { + if (master->this != i3cdev) { + ret = i3c_master_retrieve_dev_info(i3cdev); + if (ret) + goto err_bus_cleanup; + } + } + + 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_secondary_master_register(struct work_struct *work) +{ + struct i3c_master_controller *master; + struct i3c_bus *i3cbus; + int ret; + + master = container_of(work, struct i3c_master_controller, + sec_mst_register_work); + i3cbus = i3c_master_get_bus(master); + + ret = i3c_master_acquire_bus(master); + if (ret) + goto err_cleanup_bus; + + /* Again bus_init to bus_mode, based on data received in DEFSLVS */ + ret = i3c_bus_set_mode(i3cbus, master->defslvs_data.bus_mode); + if (ret) + goto err_cleanup_bus; + + ret = master->ops->bus_init(master); + if (ret) + goto err_cleanup_bus; + + ret = i3c_secondary_master_bus_init(master); + if (ret) + goto err_cleanup_bus; + + 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; + i3c_bus_normaluse_lock(&master->bus); + i3c_master_register_new_i3c_devs(master); + i3c_bus_normaluse_unlock(&master->bus); + + 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_bus_maintenance_unlock(&master->bus); + + return; + +err_del_dev: + device_del(&master->dev); + +err_cleanup_bus: + if (master->ops->bus_cleanup) + master->ops->bus_cleanup(master); + + put_device(&master->dev); +} + /** * i3c_master_register() - register an I3C master * @master: master used to send frames on the bus @@ -2424,10 +2788,10 @@ int i3c_master_register(struct i3c_master_controller *master, struct i3c_bus *i3cbus = i3c_master_get_bus(master); enum i3c_bus_mode mode = I3C_BUS_MODE_PURE; struct i2c_dev_boardinfo *i2cbi; - int ret; + int ret, sz; - /* We do not support secondary masters yet. */ - if (secondary) + /*Check if controller driver supports secondary masters. */ + if (secondary && !ops->request_mastership) return -ENOTSUPP; ret = i3c_master_check_ops(ops); @@ -2451,10 +2815,45 @@ int i3c_master_register(struct i3c_master_controller *master, device_initialize(&master->dev); dev_set_name(&master->dev, "i3c-%d", i3cbus->id); - ret = of_populate_i3c_bus(master); + master->wq = alloc_workqueue("%s", 0, 0, dev_name(parent)); + if (!master->wq) { + ret = -ENOMEM; + goto err_put_dev; + } + + master->mr_state = I3C_MR_IDLE; + INIT_WORK(&master->sec_mst_work, i3c_sec_mst_acquire_bus); + INIT_WORK(&master->mst_work, i3c_mst_yield_bus); + + ret = i3c_bus_set_mode(i3cbus, mode); + if (ret) + goto err_put_dev; + + /* + * 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_put_dev; + if (secondary) { + 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) + goto err_put_dev; + + INIT_WORK(&master->sec_mst_register_work, + i3c_secondary_master_register); + queue_work(master->wq, &master->sec_mst_register_work); + return 0; + } + + ret = of_populate_i3c_bus(master); + if (ret) + goto err_cleanup_bus; + list_for_each_entry(i2cbi, &master->boardinfo.i2c, node) { switch (i2cbi->lvr & I3C_LVR_I2C_INDEX_MASK) { case I3C_LVR_I2C_INDEX(0): @@ -2468,23 +2867,13 @@ int i3c_master_register(struct i3c_master_controller *master, break; default: ret = -EINVAL; - goto err_put_dev; + goto err_cleanup_bus; } } - ret = i3c_bus_set_mode(i3cbus, mode); - if (ret) - goto err_put_dev; - - master->wq = alloc_workqueue("%s", 0, 0, dev_name(parent)); - if (!master->wq) { - ret = -ENOMEM; - goto err_put_dev; - } - ret = i3c_master_bus_init(master); if (ret) - goto err_put_dev; + goto err_cleanup_bus; ret = device_add(&master->dev); if (ret) @@ -2507,6 +2896,22 @@ 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) { + master->ops->enable_mr_events(master); + i3c_bus_maintenance_lock(&master->bus); + i3c_master_enec_locked(master, I3C_BROADCAST_ADDR, + I3C_CCC_EVENT_MR); + i3c_bus_maintenance_unlock(&master->bus); + } + + ret = i3c_bus_set_mode(i3cbus, mode); + if (ret) + goto err_del_dev; + + ret = master->ops->bus_init(master); + if (ret) + goto err_del_dev; + return 0; err_del_dev: @@ -2557,7 +2962,10 @@ int i3c_dev_do_priv_xfers_locked(struct i3c_dev_desc *dev, if (!master->ops->priv_xfers) return -ENOTSUPP; - return master->ops->priv_xfers(dev, xfers, nxfers); + if (!i3c_master_acquire_bus(master)) + return master->ops->priv_xfers(dev, xfers, nxfers); + else + return -EAGAIN; } int i3c_dev_disable_ibi_locked(struct i3c_dev_desc *dev) diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index 3dc7eafe811a..c6427c62ed83 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -259,6 +259,27 @@ enum i3c_bus_mode { I3C_BUS_MODE_MIXED_SLOW, }; +enum i3c_mr_state { + I3C_MR_IDLE, + I3C_MR_DISEC_MR, + I3C_MR_SEND_DEFSLVS, + I3C_MR_GETACCMST, + I3C_MR_WAIT_DA, + I3C_MR_CHECK_STATE, + I3C_MR_REQUEST, + I3C_MR_WAIT_DEFSLVS, + I3C_MR_WAIT_MR_DONE, + I3C_MR_DONE, + I3C_MR_FAILED, +}; + +enum i3c_event { + I3C_SLV_DA_UPDATE, + I3C_SLV_DEFSLVS_CCC, + I3C_SLV_MR_DIS, + I3C_SLV_MR_DONE, +}; + /** * enum i3c_addr_slot_status - I3C address slot status * @I3C_ADDR_SLOT_FREE: address is free @@ -448,6 +469,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); + void (*disable_mr_events)(struct i3c_master_controller *m); + bool (*check_event_set)(struct i3c_master_controller *m, + enum i3c_event); }; /** @@ -489,6 +515,17 @@ struct i3c_master_controller { } boardinfo; struct i3c_bus bus; struct workqueue_struct *wq; + struct work_struct sec_mst_register_work; + struct work_struct mst_work; + struct work_struct sec_mst_work; + struct completion mr_comp; + enum i3c_mr_state mr_state; + u8 mr_addr; + struct { + u32 ndevs; + enum i3c_bus_mode bus_mode; + struct i3c_ccc_dev_desc *devs; + } defslvs_data; }; /** @@ -513,6 +550,9 @@ 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 *master, + u8 slv_dyn_addr); +void i3c_sec_mst_mr_dis_event(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 Apr 6 22:21:56 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: 11479719 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 73C2714B4 for ; Wed, 8 Apr 2020 10:01:55 +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 4BCE520787 for ; Wed, 8 Apr 2020 10:01:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nUUmPDNm"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="TkyHeETx"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="nqslRqMl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BCE520787 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=osqEJTAy8EKh7UTAOaMKO06ngr7RJLtbVf/w3s5KJXc=; b=nUUmPDNmcSY/TR a+kyf9OX8a3MPUPvpUHxcRdhdZIqJ/KUkCXXJlExoR+tCiggZ5P72UeEcTHs8/rmheGcY7URTzP3v D6Bc3ka8fwabxepMpW6JBWK6GGbmLmlhyewfMH7duGQJkKNTROXubvutvn/CgTEpLmV5a+lwl9M5c 5A4+ztR41cL5uVbNMBXoOghN6UK88RBm3YIaEd5rl3MWrFCR4MAOpkpAGydi/FHj+SdXj0qSSijQ0 oH92Hb26o3WTZ7qPI3MkpWVs/2AQq7eMbAJU4CEeBXqkkm6itRwvgugu9WCV+jV3ymwV98c2Glyo7 E0e4iqvoXX5n+DyxUrpg==; 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 1jM7Wp-0004s0-H5; Wed, 08 Apr 2020 10:01:51 +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 1jLa9C-0005vt-U8 for linux-i3c@lists.infradead.org; Mon, 06 Apr 2020 22:23:16 +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 036MNCBG009717; Mon, 6 Apr 2020 15:23:14 -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=7wHSv0am9OQoZebiR9rHF++s0NpUbmG1qgVWelzGGLc=; b=TkyHeETxF4yI3XSlSaKeMTrs+pSIkYxjTYFEZOaJWXQJ1m5pIGeS40ImnfNVV+kYifxG 7I14IYnIdQHeg9Fr6tYMEqbLmNrUsPyR78YycWoBTc2JY6p5g05n0XcM8C09SW+SGhxS fWYB4j4yu5tJB+pzmRx30guM5luguSn/4e7aE/5ggwIbJGMTiI+tP+Lg5NNJMqjXs9Fo ooeFWECI0pW4EDTnmEOAXiQC/qcYmjWtlY2GjrmStKDoAIRn5fmDJF+HZzp/LY/ma4CK RHnWbkkdHqFKZFjWK6fUHav7GSwa5aGOs0zIzNM8YIGCIR0y0pX/krsb+CepizqShFii bA== Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by mx0a-0014ca01.pphosted.com with ESMTP id 306psw07m2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Apr 2020 15:23:12 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O+XhHmMj4DM6j5RIgKGUVtBqBPcgDRiKt020bP02MFAMxoWsZkCOqKMrbzmaBf1Edh+ofpXPHjfysrg08Q3jiQkPErS3MqcuWLgPYhkIFFEhlY76X4eUfOWlFg9DPuH+WZEpdIynJd/w+L5EblKd7nKCTvwbnM76tF3nZ7wSdLmT9M2/s/Zao/bYjyMneR0k1lC1JGZPmPkIi4e+96JHblgLod6Y7oQlhCEP8oyyJK8ZTI9+CxTlOqGqgeYmkKk9PHYEn2bOKRXsg+5wsKQs/Rj9FQuPnBlBAwtb0Qv2X1Ru/RXtQX7i9ijoRUov7jbHDoGU8ff5z86UFpQ3B0ZJYA== 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=7wHSv0am9OQoZebiR9rHF++s0NpUbmG1qgVWelzGGLc=; b=MMe9Kk23HLVz96K2OKZ7Smh6mla4sNLJPk1mV+FqBpbpE9XM7kTm3htMmhXfAXa2LnZt/oB4c9EekOs5mpSbsrB+J+6/hp/UQR86C3I3ynSJ+5N4Deo41ZC0VFspdxpYJVX0nVcfkXZ/YL84SGisxj4rdA69jHhQtpvlc4swERQK+sNE+CRGPjFvoaMoozPwVpz4azjhPcWVur7PaVyvdny65dylejvTPorEPg3h/MJF7QkTGseg3+kvLcg32KxsXwxjpDxwli469+bwQAFM0vDUWvmqc9xv+iUzVlOSMd7zzENKFd1kiE0zBlLTZ7kd0o5XT2sxUqbrJXwSYMBXVg== 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=7wHSv0am9OQoZebiR9rHF++s0NpUbmG1qgVWelzGGLc=; b=nqslRqMl9YguW50ZFwVnpSOSMwWf8AZLe/QjnQN70OjfDyHvP4jbscNADWEmRKgLYKMA9NJ7wcMqSDZfrmD/5q4TkUYLCwt38X5fmK1SVqlmm0vsaX9v95IH/OKXgejFzDSPJ6KwyHJ6SZzfSZQpzngf30fcY5m7ugH5o193cjg= Received: from MWHPR1201CA0007.namprd12.prod.outlook.com (2603:10b6:301:4a::17) by BYAPR07MB5431.namprd07.prod.outlook.com (2603:10b6:a03:10::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.16; Mon, 6 Apr 2020 22:22:50 +0000 Received: from MW2NAM12FT006.eop-nam12.prod.protection.outlook.com (2603:10b6:301:4a:cafe::b7) by MWHPR1201CA0007.outlook.office365.com (2603:10b6:301:4a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.16 via Frontend Transport; Mon, 6 Apr 2020 22:22:50 +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 MW2NAM12FT006.mail.protection.outlook.com (10.13.180.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.9 via Frontend Transport; Mon, 6 Apr 2020 22:22:50 +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 036MMl4c057715 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=OK); Mon, 6 Apr 2020 15:22:49 -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; Tue, 7 Apr 2020 00:22:47 +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; Tue, 7 Apr 2020 00:22:47 +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 036MMlX4009569; Tue, 7 Apr 2020 00:22:47 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 036MMlHG009566; Tue, 7 Apr 2020 00:22:47 +0200 From: Parshuram Thombare To: , Subject: [PATCH v1 3/3] i3c: master: add mastership handover support to cdns i3c master driver Date: Tue, 7 Apr 2020 00:21:56 +0200 Message-ID: <1586211716-9023-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1586211645-8065-1-git-send-email-pthombar@cadence.com> References: <1586211645-8065-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:(10009020)(4636009)(376002)(346002)(136003)(396003)(39850400004)(36092001)(46966005)(36756003)(47076004)(30864003)(70206006)(8676002)(2616005)(81156014)(70586007)(8936002)(86362001)(81166006)(336012)(426003)(107886003)(26826003)(316002)(82740400003)(36906005)(5660300002)(2906002)(4326008)(6666004)(478600001)(26005)(356004)(54906003)(186003)(110136005)(42186006)(42413003); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 476b0dd5-0aa0-4193-eb46-08d7da790aab X-MS-TrafficTypeDiagnostic: BYAPR07MB5431: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:142; X-Forefront-PRVS: 0365C0E14B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wFOPhKLX40IxHrXDsVdk/TTfggzk/0nWexqAoS8T9dOa3+vasLAZgK3B8WpJxmNwjcmqAIFCaWdylpzg7E3rKseprZ2cWocML8wHhGvIF8N6iTvEulPBWAMrzOqZNPEFBWcLbqYuhm2AeiOknzl107f1owtypFALaSlUF34PhjEuHDpEHEj0Aa19Lg9tp8dza2SRGfItvSF9v/P3qD9+tTZhwfkWNehgzcz7zFkrIm8uQj5oSP8V/jnSnS1wMdbHWEAUgVXneaw7GVilJOux2bOz5pIS+BBG/Jh1svwD8hKdsFjm6mgq+PIEMpDkVYsLAk9eQkZazLZ55BZFTRCjsIKwDU+3KPhMzSvv2m8veW/uesX4Z17Hq27tMdo0hDMn+zzu4rySADF6GRjiSxYhohjGFk+iQ1TcMnztxxm8L6mDNURq3sLA+bh6lvOuBETO558iYZAP8JxoXkGtGrVt/wPwUf+mF/bP0Cm29oEst5wgwbLAa+I36/RGTOgYukfn5rqcyx28ncPpGUuXO9Y/nAYVDCHRaXZGdu0bKKEz7QVm+Ei7BbphxF+/M8em9muK X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2020 22:22:50.0581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 476b0dd5-0aa0-4193-eb46-08d7da790aab 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: BYAPR07MB5431 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-06_10:2020-04-06, 2020-04-06 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 bulkscore=0 spamscore=0 clxscore=1015 adultscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 mlxlogscore=834 mlxscore=0 suspectscore=2 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060170 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200406_152314_994902_5756A899 X-CRM114-Status: GOOD ( 15.94 ) 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_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-Mailman-Approved-At: Wed, 08 Apr 2020 03:01:49 -0700 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, pgaj@cadence.com, Parshuram Thombare , linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=patchwork.kernel.org@lists.infradead.org This patch adds mastership handover support to the Cadence I3C controller driver. Signed-off-by: Parshuram Thombare --- drivers/i3c/master/i3c-master-cdns.c | 322 +++++++++++++++++++++++++-- 1 file changed, 299 insertions(+), 23 deletions(-) diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c index c2d1631a9e38..672391d845bb 100644 --- a/drivers/i3c/master/i3c-master-cdns.c +++ b/drivers/i3c/master/i3c-master-cdns.c @@ -391,6 +391,10 @@ struct cdns_i3c_xfer { struct cdns_i3c_master { struct work_struct hj_work; struct i3c_master_controller base; + struct { + struct work_struct work; + u32 ibir; + } events; u32 free_rr_slots; unsigned int maxdevs; struct { @@ -936,6 +940,27 @@ static int cdns_i3c_master_get_rr_slot(struct cdns_i3c_master *master, return -EINVAL; } +static int cdns_i3c_master_find_rr_slot(struct cdns_i3c_master *master, + u8 addr) +{ + u32 activedevs, rr; + int i; + + activedevs = readl(master->regs + DEVS_CTRL) & + DEVS_CTRL_DEVS_ACTIVE_MASK; + + for (i = 1; i <= master->maxdevs; i++) { + if (!(BIT(i) & activedevs)) + continue; + + rr = readl(master->regs + DEV_ID_RR0(i)); + if (DEV_ID_RR0_GET_DEV_ADDR(rr) == addr) + return i; + } + + return -EINVAL; +} + static int cdns_i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev, u8 old_dyn_addr) { @@ -955,7 +980,11 @@ static int cdns_i3c_master_attach_i3c_dev(struct i3c_dev_desc *dev) if (!data) return -ENOMEM; - slot = cdns_i3c_master_get_rr_slot(master, dev->info.dyn_addr); + if (m->secondary) + slot = cdns_i3c_master_find_rr_slot(master, dev->info.dyn_addr); + else + slot = cdns_i3c_master_get_rr_slot(master, dev->info.dyn_addr); + if (slot < 0) { kfree(data); return slot; @@ -998,7 +1027,12 @@ static int cdns_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev) struct cdns_i3c_i2c_dev_data *data; int slot; - slot = cdns_i3c_master_get_rr_slot(master, 0); + if (m->secondary) + slot = cdns_i3c_master_find_rr_slot(master, + dev->boardinfo->base.addr); + else + slot = cdns_i3c_master_get_rr_slot(master, 0); + if (slot < 0) return slot; @@ -1010,14 +1044,17 @@ static int cdns_i3c_master_attach_i2c_dev(struct i2c_dev_desc *dev) master->free_rr_slots &= ~BIT(slot); i2c_dev_set_master_data(dev, data); - writel(prepare_rr0_dev_address(dev->boardinfo->base.addr) | - (dev->boardinfo->base.flags & I2C_CLIENT_TEN ? - DEV_ID_RR0_LVR_EXT_ADDR : 0), - master->regs + DEV_ID_RR0(data->id)); - writel(dev->boardinfo->lvr, master->regs + DEV_ID_RR2(data->id)); - writel(readl(master->regs + DEVS_CTRL) | - DEVS_CTRL_DEV_ACTIVE(data->id), - master->regs + DEVS_CTRL); + if (!m->secondary) { + writel(prepare_rr0_dev_address(dev->boardinfo->base.addr) | + (dev->boardinfo->base.flags & I2C_CLIENT_TEN ? + DEV_ID_RR0_LVR_EXT_ADDR : 0), + master->regs + DEV_ID_RR0(data->id)); + writel(dev->boardinfo->lvr, + master->regs + DEV_ID_RR2(data->id)); + writel(readl(master->regs + DEVS_CTRL) | + DEVS_CTRL_DEV_ACTIVE(data->id), + master->regs + DEVS_CTRL); + } return 0; } @@ -1187,10 +1224,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; } @@ -1356,6 +1389,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); @@ -1377,27 +1411,102 @@ 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)]; + i3c_master_yield_bus(&master->base, + dev->info.dyn_addr); + } + break; + default: break; } } } +static void cdns_i3c_process_defslvs(struct cdns_i3c_master *master) +{ + enum i3c_bus_mode mode = I3C_BUS_MODE_PURE; + struct i3c_ccc_dev_desc *desc; + u32 devs, ndevs, val, rr, slot; + + desc = master->base.defslvs_data.devs; + ndevs = readl(master->regs + CONF_STATUS0); + ndevs = CONF_STATUS0_DEVS_NUM(ndevs); + master->base.defslvs_data.ndevs = ndevs; + devs = readl(master->regs + DEVS_CTRL) & DEVS_CTRL_DEVS_ACTIVE_MASK; + for (slot = 1; slot < I3C_BUS_MAX_DEVS; slot++) { + if (!(devs & BIT(slot))) + continue; + + memset(desc, 0, sizeof(struct i3c_ccc_dev_desc)); + val = readl(master->regs + DEV_ID_RR0(slot)); + if (val & DEV_ID_RR0_IS_I3C) { + 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; + } else { + rr = readl(master->regs + DEV_ID_RR0(slot)); + desc->static_addr = DEV_ID_RR0_GET_DEV_ADDR(rr); + rr = readl(master->regs + DEV_ID_RR2(slot)); + desc->lvr = rr; + switch (desc->lvr & I3C_LVR_I2C_INDEX_MASK) { + case I3C_LVR_I2C_INDEX(0): + if (mode < I3C_BUS_MODE_MIXED_FAST) + mode = I3C_BUS_MODE_MIXED_FAST; + break; + case I3C_LVR_I2C_INDEX(1): + case I3C_LVR_I2C_INDEX(2): + if (mode < I3C_BUS_MODE_MIXED_SLOW) + mode = I3C_BUS_MODE_MIXED_SLOW; + break; + default: + break; + } + } + desc++; + } + master->base.defslvs_data.bus_mode = mode; +} + +void cdns_i3c_handle_slv_events(struct cdns_i3c_master *master, u32 events) +{ + u32 status1; + + status1 = readl(master->regs + SLV_STATUS1); + + if (events & SLV_INT_EVENT_UP && status1 & SLV_STATUS1_MR_DIS) + i3c_sec_mst_mr_dis_event(&master->base); +} + 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 + SLV_ISR) & + readl(master->regs + SLV_IMR)); + if (!status) + return IRQ_NONE; + cdns_i3c_handle_slv_events(master, status); + + writel(status, master->regs + SLV_ICR); + } else { + 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); + 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_IBIR_THR) + cnds_i3c_master_demux_ibis(master); + } return IRQ_HANDLED; } @@ -1521,6 +1630,166 @@ 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 + 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_disable_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 sirmap; + + 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 (i3cdev->ibi && i3cdev->ibi->handler) + 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); + sirmap |= SIR_MAP_DEV_CONF(data->ibi, + SIR_MAP_DEV_DA(I3C_BROADCAST_ADDR)); + writel(sirmap, master->regs + SIR_MAP_DEV_REG(data->ibi)); + spin_unlock_irqrestore(&master->ibi.lock, flags); + + cdns_i3c_master_free_ibi(i3cdev); + } +} + +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; + u32 status; + + switch (event) { + case I3C_SLV_DA_UPDATE: + if (readl(master->regs + SLV_STATUS1) & SLV_STATUS1_HAS_DA) + ret = true; + break; + + case I3C_SLV_DEFSLVS_CCC: + status = readl(master->regs + CONF_STATUS0); + if (CONF_STATUS0_DEVS_NUM(status) > 1) { + cdns_i3c_process_defslvs(master); + ret = true; + } + break; + + case I3C_SLV_MR_DIS: + if (readl(master->regs + SLV_STATUS1) & SLV_STATUS1_MR_DIS) + 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; +} + static const struct i3c_master_controller_ops cdns_i3c_master_ops = { .bus_init = cdns_i3c_master_bus_init, .master_set_info = cdns_i3c_master_set_info, @@ -1541,6 +1810,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, + .disable_mr_events = cdns_i3c_master_disable_mastership_events, + .check_event_set = cdns_i3c_master_check_event_set, }; static void cdns_i3c_master_hj(struct work_struct *work) @@ -1556,6 +1829,7 @@ 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; @@ -1607,6 +1881,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); @@ -1627,12 +1902,13 @@ static int cdns_i3c_master_probe(struct platform_device *pdev) if (!master->ibi.slots) goto err_disable_sysclk; + writel(SLV_INT_EVENT_UP, master->regs + SLV_IER); writel(IBIR_THR(1), master->regs + CMD_IBI_THR_CTRL); writel(MST_INT_IBIR_THR, 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, false); + &cdns_i3c_master_ops, secondary); if (ret) goto err_disable_sysclk;