From patchwork Wed Jul 26 15:02:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herve Codina X-Patchwork-Id: 126438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp473997vqo; Wed, 26 Jul 2023 08:18:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlGOoitbgr9JFvxvmthRitH0uleT2AguU6GYBwt99GGIx+joGzc2iiUUvEqD1GSYBDIx/c7j X-Received: by 2002:a17:902:c205:b0:1b8:3786:3344 with SMTP id 5-20020a170902c20500b001b837863344mr1635265pll.49.1690384689784; Wed, 26 Jul 2023 08:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690384689; cv=none; d=google.com; s=arc-20160816; b=zKj3N3dX1mfab9K5l7X48I4VGRwpmnBotUOCfU6j5CRp++EgJJGy/0PV1yoHXR+U/n 0Y2VWb/VzqQlQoQU7NwDs5N2gHcDfAu4CGxdNYGD9ziD1hkNQzxPJTDVkzvNfsd0ETwc Pz6tbpX4+PzYoZlrnjoBbFuA+gK9EGzQN+YQCP/lJM20J++TffQjZNNZsys9eLlUU+y4 eNghHil0EpiaFHeUzwcPh8U9+SCFIJwm0DDCUZuAUPKIFfzZ1B9vMdMxF5MY/YgZhwL6 nAbHcYn161jc1vM4LDeLgwb3IgPvVv8DB40QXtoboAYSCQOreKVOI5EvGIe2BaWNF47L 0KGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QsB/MROgXq9pXsqS+5J4PMhc0csFongYTf9/sr1bSFQ=; fh=OtJVFpZ5Y8/ND7g8QcUIbRSFhG4LznwcYYtG4zWKevM=; b=nTQ2rJtshNOUfiotfjY0DAT0F/vOF5YGWtpLoTqj13A9edHjw4KWdMxW1x/7ZJ3Gp/ OkKhxEMD1GeokI4wN7NeHLEzuoPhZdOvrM6TsRSXjYPp3NvI7nNhUWiPz9RwUtunOVAW 2L9ZWPtsES4G/AiCKojlH8Vb2IN0E8YmIF+GTBSv7ydmWe4eLNV0p6IpdiRU3KZceIGP TW6J0onoBVsnA56YWDuOGs+v88I0qp6/8Obfg1FTJnLvdYGqgoe/rej/YRTgruW9QZUF tXUSsQq3N4tIM/oz7/dfBfGI+QbanKPTgCGbbCpPUE4GTnZpnR5egQpTjqmGi3kW+w+T w7cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=blolVYOz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x10-20020a170902ec8a00b001b8e443b6ffsi14023274plg.7.2023.07.26.08.17.55; Wed, 26 Jul 2023 08:18:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=blolVYOz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234784AbjGZPEZ (ORCPT + 99 others); Wed, 26 Jul 2023 11:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234655AbjGZPEA (ORCPT ); Wed, 26 Jul 2023 11:04:00 -0400 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4831B2D64; Wed, 26 Jul 2023 08:03:31 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPA id BE18E1C0005; Wed, 26 Jul 2023 15:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690383810; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QsB/MROgXq9pXsqS+5J4PMhc0csFongYTf9/sr1bSFQ=; b=blolVYOzvpDtX/SRGAahoKWOHeQ7cDal8c4Kh93qJGwn87oAhUw2yFLndycJv7bNUKO4Ot m2vgZqqlspsf3p/Ydw9JQ7jXOif3Ms/ZbgcCOuL89twKPIvDnzUvq3jryfRtQcSbVrwhJ+ aMAVG+r1XSlnztsqpTa8kAFPBmpolHdvdkfveYtvO9EzMks+NWqoGeCFnD61ICxQMHty8V HqTj4N2iJZc6vwEBrYFiaCh1Q8pnpKGTsuzs4IJZF36+741tz6PSfaHC77973RA30Q2Hn9 qG2zWRVY/5aOqf4Iu9hvCpWZZ48yxZF9UbZ44jof6AWxPRssZVBcHT0/ivKGEQ== From: Herve Codina To: Herve Codina , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Lee Jones , Linus Walleij , Qiang Zhao , Li Yang , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Shengjiu Wang , Xiubo Li , Fabio Estevam , Nicolin Chen , Christophe Leroy , Randy Dunlap Cc: netdev@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, Thomas Petazzoni Subject: [PATCH v2 14/28] soc: fsl: cpm1: qmc: Split Tx and Rx TSA entries setup Date: Wed, 26 Jul 2023 17:02:10 +0200 Message-ID: <20230726150225.483464-15-herve.codina@bootlin.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726150225.483464-1-herve.codina@bootlin.com> References: <20230726150225.483464-1-herve.codina@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: herve.codina@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772496816737805147 X-GMAIL-MSGID: 1772496816737805147 The Tx and Rx entries for a given channel are set in one function. In order to modify Rx entries and Tx entries independently of one other, split this function in one for the Rx part and one for the Tx part. Signed-off-by: Herve Codina Reviewed-by: Christophe Leroy --- drivers/soc/fsl/qe/qmc.c | 49 ++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/drivers/soc/fsl/qe/qmc.c b/drivers/soc/fsl/qe/qmc.c index 146eebc12737..c8ddd2a54bee 100644 --- a/drivers/soc/fsl/qe/qmc.c +++ b/drivers/soc/fsl/qe/qmc.c @@ -610,14 +610,14 @@ static int qmc_chan_setup_tsa_64rxtx(struct qmc_chan *chan, const struct tsa_ser return 0; } -static int qmc_chan_setup_tsa_32rx_32tx(struct qmc_chan *chan, const struct tsa_serial_info *info, - bool enable) +static int qmc_chan_setup_tsa_32rx(struct qmc_chan *chan, const struct tsa_serial_info *info, + bool enable) { unsigned int i; u16 curr; u16 val; - /* Use a Tx 32 entries table and a Rx 32 entries table */ + /* Use a Rx 32 entries table */ val = QMC_TSA_VALID | QMC_TSA_MASK | QMC_TSA_CHANNEL(chan->id); @@ -633,6 +633,30 @@ static int qmc_chan_setup_tsa_32rx_32tx(struct qmc_chan *chan, const struct tsa_ return -EBUSY; } } + + /* Set entries based on Rx stuff */ + for (i = 0; i < info->nb_rx_ts; i++) { + if (!(chan->rx_ts_mask & (((u64)1) << i))) + continue; + + qmc_clrsetbits16(chan->qmc->scc_pram + QMC_GBL_TSATRX + (i * 2), + ~QMC_TSA_WRAP, enable ? val : 0x0000); + } + + return 0; +} + +static int qmc_chan_setup_tsa_32tx(struct qmc_chan *chan, const struct tsa_serial_info *info, + bool enable) +{ + unsigned int i; + u16 curr; + u16 val; + + /* Use a Tx 32 entries table */ + + val = QMC_TSA_VALID | QMC_TSA_MASK | QMC_TSA_CHANNEL(chan->id); + /* Check entries based on Tx stuff */ for (i = 0; i < info->nb_tx_ts; i++) { if (!(chan->tx_ts_mask & (((u64)1) << i))) @@ -646,14 +670,6 @@ static int qmc_chan_setup_tsa_32rx_32tx(struct qmc_chan *chan, const struct tsa_ } } - /* Set entries based on Rx stuff */ - for (i = 0; i < info->nb_rx_ts; i++) { - if (!(chan->rx_ts_mask & (((u64)1) << i))) - continue; - - qmc_clrsetbits16(chan->qmc->scc_pram + QMC_GBL_TSATRX + (i * 2), - ~QMC_TSA_WRAP, enable ? val : 0x0000); - } /* Set entries based on Tx stuff */ for (i = 0; i < info->nb_tx_ts; i++) { if (!(chan->tx_ts_mask & (((u64)1) << i))) @@ -680,9 +696,14 @@ static int qmc_chan_setup_tsa(struct qmc_chan *chan, bool enable) * Setup one common 64 entries table or two 32 entries (one for Tx * and one for Tx) according to assigned TS numbers. */ - return ((info.nb_tx_ts > 32) || (info.nb_rx_ts > 32)) ? - qmc_chan_setup_tsa_64rxtx(chan, &info, enable) : - qmc_chan_setup_tsa_32rx_32tx(chan, &info, enable); + if (info.nb_tx_ts > 32 || info.nb_rx_ts > 32) + return qmc_chan_setup_tsa_64rxtx(chan, &info, enable); + + ret = qmc_chan_setup_tsa_32rx(chan, &info, enable); + if (ret) + return ret; + + return qmc_chan_setup_tsa_32tx(chan, &info, enable); } static int qmc_chan_command(struct qmc_chan *chan, u8 qmc_opcode)