Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1023917pxb; Tue, 14 Sep 2021 14:23:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp00UUP7fCe17S6+R5lPPPsBStW+Cpx9mkRHaxKnMHvn4UPePErKhnpz7aSKEaO5L487jD X-Received: by 2002:a05:6512:3886:: with SMTP id n6mr15053898lft.279.1631654621126; Tue, 14 Sep 2021 14:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631654621; cv=none; d=google.com; s=arc-20160816; b=KPAMSBzKRf6AyTwxZkC4hay4h1sxg+SfViDTVytdkj3YfWJVG0f8Ff96zSUML4ZXgF chGlr8Ngo0nF0HeqKBlfInNNCRob7i4nhKUbiPugwsRXdcKkSsPCSh+lTVHr7lOcXdvM 3g0+zPQBc0WOD0Swu5CCDxku1sPF8P2bmbMXYUyvy/TL2Jrv6lqNQX1RY9EumrFocxys lnbEjtMXFPEiCPOHsSp8MgtjmRvKXEb8H4+RIVEbsUWo/PgbVHALNhusZsTpm0vsU2/j zXsq5LhyYCxhqGq7tYWiFY5a3AqOdoz+1o3t+S5v7sV3hIL9ae0TS+AkWq6sHov7ai+F qbFw== 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:to:from :dkim-signature; bh=cOehKLdr21JWg0458JhnAiOM+tCkh7a5QPtIpRgyjos=; b=peB+aHp1o2a+OoAU9O+PMRxphIj04DuSUDymDA7tm0ih620AXGbzUZhAt4izphKXgr fHRogC80Xw1rCN53J6rCZg6cG6vsgLZjtp8LAS2sW6cU/M5Y7FDLns0Pl6nRtkBXJIbQ AADVa56tOUxI3hHDEYVbvR6T1EuffuQWtUii/4GXXTvNpEnDxojO6j3s3PJ1r8/v/qzt ZltfRjcqk4j2ZgsMorxUsY0usLOk9ZrvNw27PECwGYmCOHyXe23NZhxEXLw0/yJVrIN4 Wje2s1J/TQqRTIFGAivIL+eaHOnZmeyMISJrTPRoF3k0GwZk5vWSOsALrZ7dWFz+b/st oN7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=rUiAoVVE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a10si20045172lfh.307.2021.09.14.14.23.13; Tue, 14 Sep 2021 14:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@wp.pl header.s=1024a header.b=rUiAoVVE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wp.pl Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231472AbhINVWg (ORCPT + 99 others); Tue, 14 Sep 2021 17:22:36 -0400 Received: from mx4.wp.pl ([212.77.101.11]:35532 "EHLO mx4.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234245AbhINVWd (ORCPT ); Tue, 14 Sep 2021 17:22:33 -0400 Received: (wp-smtpd smtp.wp.pl 7702 invoked from network); 14 Sep 2021 23:21:11 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1631654471; bh=cOehKLdr21JWg0458JhnAiOM+tCkh7a5QPtIpRgyjos=; h=From:To:Subject; b=rUiAoVVESuKS8ujsMQWFrDCX24U7oLsDJyGjwnKWrY9G/vfPUi7933fsYApm2Au/Y JxdtZhdZHGjnxLRzNRiPUIqYkyZeDAsr98g8vNJvTTaUTaiC7gTMcxSC0C+QpGFGTV pqesPPE19RtKcs7xrQ1mj2QMdlJVKYCTeXIDJJvw= Received: from 46.204.52.243.nat.umts.dynamic.t-mobile.pl (HELO LAPTOP-OLEK.Free) (olek2@wp.pl@[46.204.52.243]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 14 Sep 2021 23:21:11 +0200 From: Aleksander Jan Bajkowski To: john@phrozen.org, tsbogend@alpha.franken.de, olek2@wp.pl, maz@kernel.org, ralf@linux-mips.org, ralph.hempel@lantiq.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, hauke@hauke-m.de, dev@kresin.me, arnd@arndb.de, jgg@ziepe.ca, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/8] MIPS: lantiq: dma: reset correct number of channel Date: Tue, 14 Sep 2021 23:20:59 +0200 Message-Id: <20210914212105.76186-2-olek2@wp.pl> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210914212105.76186-1-olek2@wp.pl> References: <20210914212105.76186-1-olek2@wp.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-WP-MailID: da6b6b20d853f9e8e7420051a3627358 X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000000 [8UOk] Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Different SoCs have a different number of channels, e.g .: * amazon-se has 10 channels, * danube+ar9 have 20 channels, * vr9 has 28 channels, * ar10 has 24 channels. We can read the ID register and, depending on the reported number of channels, reset the appropriate number of channels. Signed-off-by: Aleksander Jan Bajkowski --- arch/mips/lantiq/xway/dma.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/mips/lantiq/xway/dma.c b/arch/mips/lantiq/xway/dma.c index 2784715933d1..364ab39eb8a4 100644 --- a/arch/mips/lantiq/xway/dma.c +++ b/arch/mips/lantiq/xway/dma.c @@ -31,6 +31,7 @@ #define LTQ_DMA_PCTRL 0x44 #define LTQ_DMA_IRNEN 0xf4 +#define DMA_ID_CHNR GENMASK(26, 20) /* channel number */ #define DMA_DESCPT BIT(3) /* descriptor complete irq */ #define DMA_TX BIT(8) /* TX channel direction */ #define DMA_CHAN_ON BIT(0) /* channel on / off bit */ @@ -41,7 +42,6 @@ #define DMA_POLL BIT(31) /* turn on channel polling */ #define DMA_CLK_DIV4 BIT(6) /* polling clock divider */ #define DMA_2W_BURST BIT(1) /* 2 word burst length */ -#define DMA_MAX_CHANNEL 20 /* the soc has 20 channels */ #define DMA_ETOP_ENDIANNESS (0xf << 8) /* endianness swap etop channels */ #define DMA_WEIGHT (BIT(17) | BIT(16)) /* default channel wheight */ @@ -207,7 +207,7 @@ ltq_dma_init(struct platform_device *pdev) { struct clk *clk; struct resource *res; - unsigned id; + unsigned int id, nchannels; int i; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -229,17 +229,18 @@ ltq_dma_init(struct platform_device *pdev) ltq_dma_w32(0, LTQ_DMA_IRNEN); /* reset/configure each channel */ - for (i = 0; i < DMA_MAX_CHANNEL; i++) { + id = ltq_dma_r32(LTQ_DMA_ID); + nchannels = ((id & DMA_ID_CHNR) >> 20); + for (i = 0; i < nchannels; i++) { ltq_dma_w32(i, LTQ_DMA_CS); ltq_dma_w32(DMA_CHAN_RST, LTQ_DMA_CCTRL); ltq_dma_w32(DMA_POLL | DMA_CLK_DIV4, LTQ_DMA_CPOLL); ltq_dma_w32_mask(DMA_CHAN_ON, 0, LTQ_DMA_CCTRL); } - id = ltq_dma_r32(LTQ_DMA_ID); dev_info(&pdev->dev, "Init done - hw rev: %X, ports: %d, channels: %d\n", - id & 0x1f, (id >> 16) & 0xf, id >> 20); + id & 0x1f, (id >> 16) & 0xf, nchannels); return 0; } -- 2.30.2