From patchwork Fri Apr 17 16:20:52 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: 11495539 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 5E0AF186E for ; Fri, 17 Apr 2020 16:21:45 +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 36DA02087E for ; Fri, 17 Apr 2020 16:21:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HjURr+uS"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=cadence.com header.i=@cadence.com header.b="clBeF4Ei"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=cadence.com header.i=@cadence.com header.b="M/1ubVVy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36DA02087E 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=ZqZkZmlW2rnu62k0WEEn052xrRnXnFnmIG1tlwa5oCs=; b=HjURr+uSk1fMpn QVU4nfD7zKkw8jwZSGtdTpIO7bsHbIyDmHEerBi5OES/iIY984idmyEKdlPFzH4sDQNTXkePuXilZ v6p7vAmd3stZ4J9VYo0/ZowAeZxZ8apDmoe9H2He54q4eh7cfnv3bMN420XPUX8CrfNzerB+HuVZx 4LwSFLMO/s2OQc9g9VPSwJIqM18SkXWz02EsxeHy6UBWIbaqKMkiYlVeWXGMrsOu6O/ygpoHYZKNg kJ96u1eHdJNuHwx/uiuDh6XqZJ6R/676vPU/LRRH8zDcP3f2q1m4INJdT+Ur5QsWsuvdG4wGsZj2b vrlnZLOE9yrHOsB/O4Zg==; 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 1jPTkL-0006Cr-Tf; Fri, 17 Apr 2020 16:21: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 1jPTjj-0005cw-No for linux-i3c@lists.infradead.org; Fri, 17 Apr 2020 16:21: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 03HGAFUQ019664; Fri, 17 Apr 2020 09:21:01 -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=v/Jq0f/Q3Cf7y0O11BM3lByHfl3SGsLzushnQMtfEB4=; b=clBeF4EiaXAfjKqycV0WP3sibbm84WgMYgrfsHa+PNpo7xqWqXnDN+bC1+XFPdFXQFCt PmV3FWMuIJe54bHXK91MkkdQp3yCIMhysGJCEYotsN0VohtceUK8Xtx/UjW+92Beu+2i g2QQOwCr+BrdFYYVrCpc22c1HwDmylmEFGiyuxggL1zcVJyu+YQvbJ82X8tZtMiZpjQ4 3VV2PcHJW4r+kTU6q26gyUMkhU/D8zoifc7h57GlhpQfQ+OO5Dj3dTtZLtHWDwH0egS4 AJEIPpZ0rFk1yh573vM2/SpbnkDj6xTwXMyBYv+w+j8jCgsT22+yXPM7ham5V3/4o38J kg== Received: from nam04-co1-obe.outbound.protection.outlook.com (mail-co1nam04lp2053.outbound.protection.outlook.com [104.47.45.53]) by mx0b-0014ca01.pphosted.com with ESMTP id 30dn7954w1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 Apr 2020 09:21:01 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cmyqTf5JX2iPYYrhTw2HyWDbhPzxB/Rz2/CLbzNIy12h9bQsdvBkTVS3r+nZvrW82HwwyRzSSB7/RIbIqNgSS5nkDTUX239+Z81MxInbhB89qkujM85KG6PE7fCOXtTCmK+Fk27X3oNnpA98TsKFB9t/VhrAvXMRScZu+aOa3bN9/P30y+cP8VS8QwjdZXoLQK5Uh98cUi8qmtxRrvarRj2dTepXbwpIWhjJnPg43fIgg7z/OHtBj1FVY/Tmf7bMAu+zybiWxOBm78G66NHRlHIAw2oer7hIqV6cA10fIv5j1+KB5IpkNwgrNbaXUf8kXeoEIVeQnuXSwPg6gx9ahA== 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=v/Jq0f/Q3Cf7y0O11BM3lByHfl3SGsLzushnQMtfEB4=; b=fbVO6N3zy5f0n0ivaVv+UjcTZ04BK9C4rcQBBXnwJzIz6z3bybN0XzXVgLJ3fN8lyI1C1srl0qzah3G85aMSuY3LuyiuYnuGgnPnepEy7P4W9Dw5S7VGbJ3FeJ6AwoUt7FSYvL280EjaxtlQZok0Qb85YqSkh3HDrjAQ9JD+Jz+nYkAEYoEQRUdfu6s/q8vYORWl+qRSIGM6DN68DqpnSg+YG/RWZ6kqZxrzraURYeXsLO4KVtaIQAHUN/A40wHsBd/V9xWdZ2nxKpA+XfaV8Tui36M7sqqq3mAJZoT4ih4LPRPsOo3zZhY+6ndfvtqe+TLZXGFAgk9LYrKrsejihA== 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=v/Jq0f/Q3Cf7y0O11BM3lByHfl3SGsLzushnQMtfEB4=; b=M/1ubVVyGbYn8Uy/ZHOWF9hpx3wwTKzBkqnlHFqLK5lFIsV9g+3Pl7nBcSCTKDkPhO0HEFzPAAy71hcaO7tD+N598vp3zU5w0s3+LCyYjq6RdcWUKWLn6mJRaDbS0avxIy2ubSb4tblG180EYN3IfQElNa8GliTfkELprvla7/g= Received: from CO1PR15CA0082.namprd15.prod.outlook.com (2603:10b6:101:20::26) by DM5PR07MB2825.namprd07.prod.outlook.com (2603:10b6:3:14::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.27; Fri, 17 Apr 2020 16:20:58 +0000 Received: from MW2NAM12FT022.eop-nam12.prod.protection.outlook.com (2603:10b6:101:20:cafe::15) by CO1PR15CA0082.outlook.office365.com (2603:10b6:101:20::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.25 via Frontend Transport; Fri, 17 Apr 2020 16:20:58 +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 MW2NAM12FT022.mail.protection.outlook.com (10.13.180.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.12 via Frontend Transport; Fri, 17 Apr 2020 16:20:57 +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 03HGKtUh024409 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=OK); Fri, 17 Apr 2020 09:20:56 -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; Fri, 17 Apr 2020 18:20:54 +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; Fri, 17 Apr 2020 18:20:54 +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 03HGKsBp030139; Fri, 17 Apr 2020 18:20:54 +0200 Received: (from pthombar@localhost) by vleu-orange.cadence.com (8.14.4/8.14.4/Submit) id 03HGKsAD030138; Fri, 17 Apr 2020 18:20:54 +0200 From: Parshuram Thombare To: , Subject: [PATCH v6 2/8] i3c: master: split bus_init callback into bus_init and master_set_info Date: Fri, 17 Apr 2020 18:20:52 +0200 Message-ID: <1587140452-30071-1-git-send-email-pthombar@cadence.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1587140398-29473-1-git-send-email-pthombar@cadence.com> References: <1587140398-29473-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:(10009020)(4636009)(396003)(376002)(346002)(39860400002)(136003)(36092001)(46966005)(5660300002)(47076004)(186003)(36756003)(246002)(7636003)(336012)(4326008)(42186006)(478600001)(2906002)(107886003)(86362001)(316002)(70206006)(36906005)(26005)(70586007)(8936002)(356005)(110136005)(54906003)(426003)(2616005)(82740400003)(8676002); DIR:OUT; SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76e81e24-a3b4-46a2-f6d6-08d7e2eb4fc6 X-MS-TrafficTypeDiagnostic: DM5PR07MB2825: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-Forefront-PRVS: 0376ECF4DD X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P/JbW6vLG7gwrDghoobcJx8rEeWNnhwf9EtaUqrX3n4yf9SW+8OgYPpOqiCOAdQLHVptY04cHD+CaD52rOdXq+gie70qQByDKl35BLx4fjZzYXuwVlyFY1oDV/klL7mUr3nLfiboTTfJsXRRKdkvge9y3KXWsrNbLuAUGOybZTkkAS9gwOBL04o4+uMz6FXKGl9IOaowhpWsIFDbIgba43LKyBOWpyr/N7lADd1tBq+zMRajSW5j52yx/To2uO3QDnFTv0bxvQit7z8zi6Vgf2MGSuvdfksvD82KbydVBct8Q9oSkWLhfzoCgWmuATh9tBWIiLblhRdaFRJROJjK4dsXPPdHuf0LJ0Y2e7/HVFlyKPT9NVGb0lZwPbrxKieMIYFhr+FZ4CLnUyMKHO+SzVm7BHCto22OYAp1A9vIxHVyV/0L9vIECMOzvZUBxpZwm1rwk+dMA1Toddb3PNnPLlRuPq3FsPe/Gq9ALgahoY/h+T7qreuTW0KS3W5cuG/KILrymzwRDDIv9ibKixRhUY9qxgI7fgtEUvsqeXtyFCI= X-OriginatorOrg: cadence.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Apr 2020 16:20:57.6877 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76e81e24-a3b4-46a2-f6d6-08d7e2eb4fc6 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: DM5PR07MB2825 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-17_07:2020-04-17, 2020-04-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_check_notspam policy=outbound_check score=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 mlxscore=0 spamscore=0 adultscore=0 mlxlogscore=999 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004170129 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200417_092103_979749_C6397DAA X-CRM114-Status: GOOD ( 18.10 ) 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_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -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 To support mastership handover procedure, this patch splits the bus_init callback into bus_init and master_set_info callbacks Signed-off-by: Parshuram Thombare --- drivers/i3c/master.c | 10 +++-- drivers/i3c/master/dw-i3c-master.c | 29 ++++++++----- drivers/i3c/master/i3c-master-cdns.c | 63 ++++++++++++++++++---------- include/linux/i3c/master.h | 7 +++- 4 files changed, 71 insertions(+), 38 deletions(-) diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c index 5f4bd52121fe..0ec332e45737 100644 --- a/drivers/i3c/master.c +++ b/drivers/i3c/master.c @@ -1716,6 +1716,10 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) if (ret) goto err_detach_devs; + ret = master->ops->master_set_info(master); + if (ret) + goto err_detach_devs; + /* * The master device should have been instantiated in ->bus_init(), * complain if this was not the case. @@ -2378,9 +2382,9 @@ EXPORT_SYMBOL_GPL(i3c_generic_ibi_recycle_slot); static int i3c_master_check_ops(const struct i3c_master_controller_ops *ops) { - if (!ops || !ops->bus_init || !ops->priv_xfers || - !ops->send_ccc_cmd || !ops->do_daa || !ops->i2c_xfers || - !ops->i2c_funcs) + if (!ops || !ops->bus_init || !ops->master_set_info || + !ops->priv_xfers || !ops->send_ccc_cmd || !ops->do_daa || + !ops->i2c_xfers || !ops->i2c_funcs) return -EINVAL; if (ops->request_ibi && diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c index 1d83c97431c7..5c9a72d68fb8 100644 --- a/drivers/i3c/master/dw-i3c-master.c +++ b/drivers/i3c/master/dw-i3c-master.c @@ -593,7 +593,6 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m) { struct dw_i3c_master *master = to_dw_i3c_master(m); struct i3c_bus *bus = i3c_master_get_bus(m); - struct i3c_device_info info = { }; u32 thld_ctrl; int ret; @@ -624,6 +623,24 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m) writel(INTR_MASTER_MASK, master->regs + INTR_STATUS_EN); writel(INTR_MASTER_MASK, master->regs + INTR_SIGNAL_EN); + writel(IBI_REQ_REJECT_ALL, master->regs + IBI_SIR_REQ_REJECT); + writel(IBI_REQ_REJECT_ALL, master->regs + IBI_MR_REQ_REJECT); + + /* For now don't support Hot-Join */ + writel(readl(master->regs + DEVICE_CTRL) | DEV_CTRL_HOT_JOIN_NACK, + master->regs + DEVICE_CTRL); + + dw_i3c_master_enable(master); + + return 0; +} + +static int dw_i3c_master_set_info(struct i3c_master_controller *m) +{ + struct dw_i3c_master *master = to_dw_i3c_master(m); + struct i3c_device_info info = { }; + int ret; + ret = i3c_master_get_free_addr(m, 0); if (ret < 0) return ret; @@ -638,15 +655,6 @@ static int dw_i3c_master_bus_init(struct i3c_master_controller *m) if (ret) return ret; - writel(IBI_REQ_REJECT_ALL, master->regs + IBI_SIR_REQ_REJECT); - writel(IBI_REQ_REJECT_ALL, master->regs + IBI_MR_REQ_REJECT); - - /* For now don't support Hot-Join */ - writel(readl(master->regs + DEVICE_CTRL) | DEV_CTRL_HOT_JOIN_NACK, - master->regs + DEVICE_CTRL); - - dw_i3c_master_enable(master); - return 0; } @@ -1088,6 +1096,7 @@ static irqreturn_t dw_i3c_master_irq_handler(int irq, void *dev_id) static const struct i3c_master_controller_ops dw_mipi_i3c_ops = { .bus_init = dw_i3c_master_bus_init, + .master_set_info = dw_i3c_master_set_info, .bus_cleanup = dw_i3c_master_bus_cleanup, .attach_i3c_dev = dw_i3c_master_attach_i3c_dev, .reattach_i3c_dev = dw_i3c_master_reattach_i3c_dev, diff --git a/drivers/i3c/master/i3c-master-cdns.c b/drivers/i3c/master/i3c-master-cdns.c index 8889a4fdb454..c2d1631a9e38 100644 --- a/drivers/i3c/master/i3c-master-cdns.c +++ b/drivers/i3c/master/i3c-master-cdns.c @@ -1199,21 +1199,20 @@ 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; - struct i3c_device_info info = { }; - int ret, ncycles; + u32 ctrl, prescl0, prescl1, pres, low, bus_mode; + int 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 +1243,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,15 +1250,43 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m) if (ncycles < 0) ncycles = 0; prescl1 = PRESCL_CTRL1_OD_LOW(ncycles); + + 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. + */ + if (!m->secondary) + ctrl |= CTRL_HJ_ACK | CTRL_HJ_DISEC; + writel(ctrl, master->regs + CTRL); + cdns_i3c_master_enable(master); - /* Get an address for the master. */ - ret = i3c_master_get_free_addr(m, 0); - if (ret < 0) - return ret; + return 0; +} - writel(prepare_rr0_dev_address(ret) | DEV_ID_RR0_IS_I3C, - master->regs + DEV_ID_RR0(0)); +static int cdns_i3c_master_set_info(struct i3c_master_controller *m) +{ + struct cdns_i3c_master *master = to_cdns_i3c_master(m); + struct i3c_device_info info = { }; + int ret; + + if (!m->secondary) { + /* Get an address for the master. */ + ret = i3c_master_get_free_addr(m, 0); + if (ret < 0) + return ret; + + writel(prepare_rr0_dev_address(ret) | DEV_ID_RR0_IS_I3C, + master->regs + DEV_ID_RR0(0)); + } cdns_i3c_master_dev_rr_to_info(master, 0, &info); if (info.bcr & I3C_BCR_HDR_CAP) @@ -1270,16 +1296,6 @@ static int cdns_i3c_master_bus_init(struct i3c_master_controller *m) if (ret) return ret; - /* - * 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; - writel(ctrl, master->regs + CTRL); - - cdns_i3c_master_enable(master); return 0; } @@ -1507,6 +1523,7 @@ static void cdns_i3c_master_recycle_ibi_slot(struct i3c_dev_desc *dev, 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, .bus_cleanup = cdns_i3c_master_bus_cleanup, .do_daa = cdns_i3c_master_do_daa, .attach_i3c_dev = cdns_i3c_master_attach_i3c_dev, diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h index f13fd8b1dd79..3dc7eafe811a 100644 --- a/include/linux/i3c/master.h +++ b/include/linux/i3c/master.h @@ -337,10 +337,12 @@ struct i3c_bus { /** * struct i3c_master_controller_ops - I3C master methods - * @bus_init: hook responsible for the I3C bus initialization. You should at - * least call master_set_info() from there and set the bus mode. + * @bus_init: hook responsible for the I3C bus initialization. * You can also put controller specific initialization in there. * This method is mandatory. + * @master_set_info: hook responsible for assigning address to main master. + * You should call i3c_master_set_info from here. + * This method is mandatory. * @bus_cleanup: cleanup everything done in * &i3c_master_controller_ops->bus_init(). * This method is optional. @@ -421,6 +423,7 @@ struct i3c_bus { */ struct i3c_master_controller_ops { int (*bus_init)(struct i3c_master_controller *master); + int (*master_set_info)(struct i3c_master_controller *m); void (*bus_cleanup)(struct i3c_master_controller *master); int (*attach_i3c_dev)(struct i3c_dev_desc *dev); int (*reattach_i3c_dev)(struct i3c_dev_desc *dev, u8 old_dyn_addr);