From patchwork Mon Dec 27 07:45:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 12699583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA7F7C4332F for ; Mon, 27 Dec 2021 07:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BCyN5IiZY97uEmaejCo59VO3uq7AFd+h7DFVQx3fz7o=; b=nIBJ3gCTCqVENm DVfMtjmUeobJ4HWFKk2Ak4mDaNyuhWqBMridOS/PwWDbW6e4Sw4pVxDt3tUsX+mjp2OGYdZdWS9sT Aw427BOQ8YOgX2drDG9qTvTUSTnh+q7teSjlDxEn0tQnMlEAMKF+Zh5x9N2NmNtw9rMKsADSMbZoP MbFKdwxXEcDL8+4HC2EPV7qU79tQoWxk1pwpojX7nKGO86X2YTwXrQJi+6RDErj7jEvagjVKe401j xnESBjbQUOl8GXQyPYeEiuox7RQkpgE3x40t6us+qRj3zl3daXr0BGTnKIHISLDaGVf+gvlbezVw9 CG2ySrTFp9LyNnasP0Fg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1kl8-00GJqD-4J; Mon, 27 Dec 2021 07:49:30 +0000 Received: from mail-vi1eur05on2081.outbound.protection.outlook.com ([40.107.21.81] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1kl5-00GJmw-VQ for linux-i3c@lists.infradead.org; Mon, 27 Dec 2021 07:49:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uq0zS6cLwpi4/xMGu3LDEZOSjSLsl0N+QVLvbmVtKnKrd1tJYO+6NVMyX+M9T6aeZqiwBevVaM8LjexK9gbaNOT6c1gBjwgjMkHeQC+BmBspIyQZmMg7lpqqnYRUpr9cKOXbMhq428tDBavrDf/TBHMLOMeB1HhWemtkrDB5QeKHtl9klph9DwOngRDQRPk0zj1YRL+OB0DtAe6/RXbmq+AjPZ2HyXP28vCdrzqwnt6x+grpRIlIH3pw5LX99IH51NCLJ4FfjVwPTDScvAYdgMZXX/S4DRtPmyB3eCw66Sqgez1CGkxf6wwP5+0wR5wdUGJteqCuQQXCt+mgjz69lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QUfVU8ZlO1kArJwBMnFVhJEZ/Nog01cUdi63xgM03LM=; b=cJLIumQPiMZKWyoH6wmywf+VsynxiQ6VAI1vdO6wka/y3OTygsVE9dM7cghwZ8GtRvihWi0nQYwZyTbjgN++NJjp5CK2UOotpoGQdgKvFVKrNzVPYkF5dSy1oMwH4++hwRic1P5bfCpUUF4JcYpE3Q85Ku+bwavWq1b624FOrnvGLGzBWA+by/hziQHweXHQplU/vTHIf+J5WBsYoKGFbbRpAO2NB1r81n2GuRDwze4XKR8rpGadNdr/r7qN1VfsxEFIaYiNCT1EyuGqszBCjuk7iw9UwcNJVjTssayryRQEAIB5cRbVNBfBgqzGLGfpwER8TsJND68fIafna/JyyA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QUfVU8ZlO1kArJwBMnFVhJEZ/Nog01cUdi63xgM03LM=; b=dOioepdAZYOyKXixHaUjPrpEgjC0dFnCTLdqi7cYuyVIUSun1iLHp0Sz86sVstv27dqA9JYW9IhgDOwevcoZ9BCStRFwf11jAXHoMdcG3MYdyoyNF3OIsoFj2Yve4kWR/Z9fOStQ6Dejp2SdYkygeJsWZfWJd6psBRZHaUUadwA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5631.eurprd04.prod.outlook.com (2603:10a6:803:dd::27) by VI1PR04MB5629.eurprd04.prod.outlook.com (2603:10a6:803:de::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.18; Mon, 27 Dec 2021 07:49:23 +0000 Received: from VI1PR04MB5631.eurprd04.prod.outlook.com ([fe80::90fe:b60a:94b5:c748]) by VI1PR04MB5631.eurprd04.prod.outlook.com ([fe80::90fe:b60a:94b5:c748%5]) with mapi id 15.20.4823.022; Mon, 27 Dec 2021 07:49:23 +0000 From: Clark Wang To: miquel.raynal@bootlin.com Cc: conor.culhane@silvaco.com, alexandre.belloni@bootlin.com, linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH V5 3/8] i3c: master: svc: separate err, fifo and disable interrupt of reset function Date: Mon, 27 Dec 2021 15:45:24 +0800 Message-Id: <20211227074529.1660398-4-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211227074529.1660398-1-xiaoning.wang@nxp.com> References: <20211227074529.1660398-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SG2PR01CA0132.apcprd01.prod.exchangelabs.com (2603:1096:4:40::36) To VI1PR04MB5631.eurprd04.prod.outlook.com (2603:10a6:803:dd::27) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f0fad1f3-5cac-4420-fc1f-08d9c90d6632 X-MS-TrafficTypeDiagnostic: VI1PR04MB5629:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1265; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bWhFOpj7Ho0j/VkGoXxJf18/P9F1WERRFY3qY3ShXvLV3DVFptNkOitzdXc2MkvAb9YTIPYQxeCgRchdUw/NMQAtYM3cvRiGxn8bhgHQS0qUZ1LjzYqB2mxV2Qq8/6bNfoy9HcL7hEu/MtPTCxdmZVsh19hK7vY3pXHJ2YmabXtYqyhaURNCJrhG0f5JCkMmzQhhFNPrL7NeA/5n7PfRoNvSWhaNxo9Q74nCQleOkfDxsvwPGsepNaQXdsgm6nNpMOXdi+5aUyFDVwU8eEH7VHXk9dEYFkO91AxWD8RYy7R4UF+8tACgULIymmKcuTCD0gfp2dkXep8KnBnzFxIf9rycBADM65Z8VruQ+WDYh1UzYcR9F8Pi2HhzL8dKs4TAE6r1xKAER6egnChWJbnpDQb6nOOKlQnURPEt+8oYY4Ijp5RPZCUWw2SdgGMBdxRAvgAbakd00HjD6FNKDR3ylJZdtmhUBXdX+ZxpYf7oaOPz68re4G+dmQJ+DmW2Qy8ICzOb/SDG7Wm6DrnrU6QHXJ0uPbe25YqchYPVfQ5otccvG2hWFKafUtZpONH8vR828QNyRy6OQF+wN0Vekj/4odHteCrwA0o4YsEBIp1q2RYPwkj9hK+FQicYQ6tSge+WmyHYRTVAzZOSwwbSXAXSOQlVWAALjBVcTeVKA0s8nBXRFJZAf1Xo2dR+KLDlD+ZxCyJWte0/uFIdlyhHRjT1Pg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5631.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6506007)(26005)(2906002)(6916009)(83380400001)(86362001)(36756003)(66556008)(6486002)(66476007)(66946007)(8936002)(52116002)(4326008)(38350700002)(38100700002)(2616005)(186003)(508600001)(8676002)(6512007)(1076003)(5660300002)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BHqXBnXz9cEHZLDpohxSedwFWHP7cwZFm+6ETDeEnQPSFxjT94nhAc31b4eUGFcju7919M8RS63+u2bHthXR9IZVkQQm58JbzpE8ZbDFilaTN43As3/Jo2Wkn+XlyhkVR3odATOhTDoDHCMpspwUd2lIsmyFqiNnienRKhBSmcVj0Cyz4T3NXv/F5+y7EOLpVoP+0MEA8g/nhj+Jhou9XweXT6GmnOp3dRJqvKCsZCgIb5hL6KBmkdyNuyZxrnNk2HImlmt/gyEUZp9wXdMANAUkvuEWhVUg+U9IvaACnZSZ4Nn+EyniRoF7bpDGeXy8TZSaD1wsH16Z1NqebpEQFv5vQLiMGfdDdxWUgWKZXlpg9CsUW+jaIl3gQ1BlPdOq+LI0xR/rWrk1zuPlB8yAYVPtakvo0l39aJo+NDXdJYq4jrv51RIoqIr0Vhi2L6U+Sdo357oI8sJE4IlsVrd5PSA6HbcAdR28LeQbHtg965APPMuTL4dDVZ95s49YTrsbKzhMainMwHMj77yCSxBpwKFdfNclVTj+QQ1DFf6T9z8uuzFjM8n/kjxeCQN+UAmt2aeIoOV/Cg24YFhnP1B8uQyXPW346x3bGQKMv30B/70UR4iwmIiZ/YFDAqVOSSK9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9c90d6632 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5631.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2021 07:49:23.7630 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: X5s0oqZXuM1DJA9NOCowG5JyHBz7Z4/j6QjdFjW2GsW+lMNz+yPEuhveHSBtL+ex4g2j6ARXus/VqFlig/XMQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB5629 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211226_234928_038419_C00F4B6C X-CRM114-Status: GOOD ( 11.93 ) X-BeenThere: linux-i3c@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-i3c" Errors-To: linux-i3c-bounces+linux-i3c=archiver.kernel.org@lists.infradead.org Sometimes only need to reset err and fifo regs, so split the origin reset function to three functions. Put them at the top of the file, to let more functions can call them. Signed-off-by: Clark Wang Reviewed-by: Miquel Raynal Reviewed-by: Jun Li --- V5: - add Miquel's reviewed tag --- drivers/i3c/master/svc-i3c-master.c | 59 +++++++++++++++++------------ 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index 47c02a60cf62..4e69c691253d 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -236,6 +236,40 @@ static void svc_i3c_master_disable_interrupts(struct svc_i3c_master *master) writel(mask, master->regs + SVC_I3C_MINTCLR); } +static void svc_i3c_master_clear_merrwarn(struct svc_i3c_master *master) +{ + /* Clear pending warnings */ + writel(readl(master->regs + SVC_I3C_MERRWARN), + master->regs + SVC_I3C_MERRWARN); +} + +static void svc_i3c_master_flush_fifo(struct svc_i3c_master *master) +{ + /* Flush FIFOs */ + writel(SVC_I3C_MDATACTRL_FLUSHTB | SVC_I3C_MDATACTRL_FLUSHRB, + master->regs + SVC_I3C_MDATACTRL); +} + +static void svc_i3c_master_reset_fifo_trigger(struct svc_i3c_master *master) +{ + u32 reg; + + /* Set RX and TX tigger levels, flush FIFOs */ + reg = SVC_I3C_MDATACTRL_FLUSHTB | + SVC_I3C_MDATACTRL_FLUSHRB | + SVC_I3C_MDATACTRL_UNLOCK_TRIG | + SVC_I3C_MDATACTRL_TXTRIG_FIFO_NOT_FULL | + SVC_I3C_MDATACTRL_RXTRIG_FIFO_NOT_EMPTY; + writel(reg, master->regs + SVC_I3C_MDATACTRL); +} + +static void svc_i3c_master_reset(struct svc_i3c_master *master) +{ + svc_i3c_master_clear_merrwarn(master); + svc_i3c_master_reset_fifo_trigger(master); + svc_i3c_master_disable_interrupts(master); +} + static inline struct svc_i3c_master * to_svc_i3c_master(struct i3c_master_controller *master) { @@ -279,12 +313,6 @@ static void svc_i3c_master_emit_stop(struct svc_i3c_master *master) udelay(1); } -static void svc_i3c_master_clear_merrwarn(struct svc_i3c_master *master) -{ - writel(readl(master->regs + SVC_I3C_MERRWARN), - master->regs + SVC_I3C_MERRWARN); -} - static int svc_i3c_master_handle_ibi(struct svc_i3c_master *master, struct i3c_dev_desc *dev) { @@ -1334,25 +1362,6 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = { .disable_ibi = svc_i3c_master_disable_ibi, }; -static void svc_i3c_master_reset(struct svc_i3c_master *master) -{ - u32 reg; - - /* Clear pending warnings */ - writel(readl(master->regs + SVC_I3C_MERRWARN), - master->regs + SVC_I3C_MERRWARN); - - /* Set RX and TX tigger levels, flush FIFOs */ - reg = SVC_I3C_MDATACTRL_FLUSHTB | - SVC_I3C_MDATACTRL_FLUSHRB | - SVC_I3C_MDATACTRL_UNLOCK_TRIG | - SVC_I3C_MDATACTRL_TXTRIG_FIFO_NOT_FULL | - SVC_I3C_MDATACTRL_RXTRIG_FIFO_NOT_EMPTY; - writel(reg, master->regs + SVC_I3C_MDATACTRL); - - svc_i3c_master_disable_interrupts(master); -} - static int svc_i3c_master_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev;