From patchwork Fri May 24 18:26:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673474 Received: from mail-wm1-f98.google.com (mail-wm1-f98.google.com [209.85.128.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 297CB55E5B for ; Fri, 24 May 2024 18:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; cv=none; b=cInLvOLn3rNuR/uW3MvkHFM1d5GkYUifYD5+c/UNdH18axXibPwjMcMBct4lZHpGzO5iAUZFTMaStJgZ+G+GLA+L4FUSY+BcAmozj6S1wr1l9C1hcll8LioC34ieScGdUscNlm3N0nYpRWzlmcfioIbe/bcn7LYRuXCDMY/zcFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; c=relaxed/simple; bh=N3Kfi5rjJxhjSAGsgu3nLGQYoSBKamIirsVfmPZi9nY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Lic9NV5BzRDud9j6diJvyee6+TyFaQQ3zkJ/NSFBHhkRWFdEP6/+TZPDBRsx1RSSiahRDo0/kyYp2Pb5ghcPG72WnU1cfkw5hi0GYhK7JL9sCP3po4Pc0NIlz370ZTzoetbrQqch7qhCZFs4mwrf1+AsSQu6T+2poaMlJQZeBu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=H8SvFKa9; arc=none smtp.client-ip=209.85.128.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="H8SvFKa9" Received: by mail-wm1-f98.google.com with SMTP id 5b1f17b1804b1-420180b58c3so70303175e9.2 for ; Fri, 24 May 2024 11:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575280; x=1717180080; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FGCf1ir0ewKxnfYL+8Y6zr0drR+R4O1jhqT1oluTBL8=; b=H8SvFKa9kcI0I/S+GtybgKj6wteHMsd/mvWsk40hg9y3B5a7budMlqyQzjhI2tTyuc KS1R7UFxf0NRtU3gcoSd1Xk7xdRHs4khoOx4koY4eZU9PutbV04+vkjrh8hStrVcaHlg t7Y7FGGkUC6+hy4TOVMMMSVriHxTRMzyUfZJWiuWS95xvP6CCA5KvqTmZHtwc1K83yZ4 IVObWlnssFfrwYMea+b1gDqGMw9dmc7pXVMGzhz14ec3Jkwo4QG1OMl2sPf24xh9+KGG xWRJRUSfo8lhlUDrMtl6++T6y9gppJYBvtcN9D3913uLH4Ho+c2t1cRjYmcJfoFmrmcS EhtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575280; x=1717180080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FGCf1ir0ewKxnfYL+8Y6zr0drR+R4O1jhqT1oluTBL8=; b=Bo+VN0s1+Lsn7PyNT77MQp6GS4rriN45nASXTkeYPh4lqF2shYq5UcjJQSMQv0IL4k rJd/BwpFx2ix9oJafaXGc7qhXPE0vqA4WUcf3nrMd0Rj45106aT7N2C1lBITq+HqtFoI dfxQQJBC6gf1kOFF+xvC0nBkZU9VLtZ0IAMKSBkxX1FmDgYYiYc9SqB3tAjYltdnPB1C ANDzcld6QUA7VbDPVV1HHW4tdJ+pua8Cuwx9fxUDW9Vc+YvThb+ohHVU73U6yk/6usLb USabEzz6K0xtHjl/TMmf5dnsr71WRyQDDBgMFbCMZQIIuQUt6hKaOIJ4KYeDOccBrCRm k+6g== X-Forwarded-Encrypted: i=1; AJvYcCU8DNz3IJmPYZQKB8IXBtTH5Uf0eCyVhqrfwq4l6pY01mkYMuUioJiOD8q95uCoVmtFDgBHHSFxewpvtp7AyGM3bqOLby7djS58 X-Gm-Message-State: AOJu0YzyTjfEkI0FsB9HPFsLe4Ngfw4LMoMySqJYG2++rQhcSmHHJcYq QYywm0n3OQjY66tHxevA3B9dDWXczhC276c4ymLjBjNnBbB7NC/ImZGPp6f93YTNIZtxeuE3HoS kK+N/S3gzbQMSiFmudKt6PrD706A5rxS4 X-Google-Smtp-Source: AGHT+IHAQFzXjWnTl+TwMEnEF3wypw9s7LeiM71e7MxN0zWKYR44rUnrOPV4U43jDFBiNTbbJuux8HJQ65dC X-Received: by 2002:a05:600c:1381:b0:41f:b0e7:f299 with SMTP id 5b1f17b1804b1-42108a59292mr20514315e9.9.1716575280074; Fri, 24 May 2024 11:28:00 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42100fa9eb7sm5393305e9.34.2024.05.24.11.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:28:00 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 15/18] spi: bcm2835: Use phys addresses for slave DMA config Date: Fri, 24 May 2024 19:26:59 +0100 Message-Id: <20240524182702.1317935-16-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> Precedence: bulk X-Mailing-List: dmaengine@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Phil Elwell Contrary to what struct snd_dmaengine_dai_dma_data suggests, the configuration of addresses of DMA slave interfaces should be done in CPU physical addresses. Signed-off-by: Phil Elwell Signed-off-by: Dave Stevenson --- drivers/spi/spi-bcm2835.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index e1b9b1235787..e8242e0c4246 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -119,6 +119,7 @@ MODULE_PARM_DESC(polling_limit_us, */ struct bcm2835_spi { void __iomem *regs; + phys_addr_t phys_addr; struct clk *clk; struct gpio_desc *cs_gpio; unsigned long clk_hz; @@ -891,19 +892,8 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, struct bcm2835_spi *bs) { struct dma_slave_config slave_config; - const __be32 *addr; - dma_addr_t dma_reg_base; int ret; - /* base address in dma-space */ - addr = of_get_address(ctlr->dev.of_node, 0, NULL, NULL); - if (!addr) { - dev_err(dev, "could not get DMA-register address - not using dma mode\n"); - /* Fall back to interrupt mode */ - return 0; - } - dma_reg_base = be32_to_cpup(addr); - /* get tx/rx dma */ ctlr->dma_tx = dma_request_chan(dev, "tx"); if (IS_ERR(ctlr->dma_tx)) { @@ -925,7 +915,7 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, * or, in case of an RX-only transfer, cyclically copies from the zero * page to the FIFO using a preallocated, reusable descriptor. */ - slave_config.dst_addr = (u32)(dma_reg_base + BCM2835_SPI_FIFO); + slave_config.dst_addr = bs->phys_addr + BCM2835_SPI_FIFO; slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ret = dmaengine_slave_config(ctlr->dma_tx, &slave_config); @@ -964,9 +954,9 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, * RX FIFO or, in case of a TX-only transfer, cyclically writes a * precalculated value to the CS register to clear the RX FIFO. */ - slave_config.src_addr = (u32)(dma_reg_base + BCM2835_SPI_FIFO); + slave_config.src_addr = bs->phys_addr + BCM2835_SPI_FIFO; slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - slave_config.dst_addr = (u32)(dma_reg_base + BCM2835_SPI_CS); + slave_config.dst_addr = bs->phys_addr + BCM2835_SPI_CS; slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ret = dmaengine_slave_config(ctlr->dma_rx, &slave_config); @@ -1336,6 +1326,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev) { struct spi_controller *ctlr; struct bcm2835_spi *bs; + struct resource *iomem; int err; ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*bs)); @@ -1359,10 +1350,12 @@ static int bcm2835_spi_probe(struct platform_device *pdev) bs = spi_controller_get_devdata(ctlr); bs->ctlr = ctlr; - bs->regs = devm_platform_ioremap_resource(pdev, 0); + bs->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &iomem); if (IS_ERR(bs->regs)) return PTR_ERR(bs->regs); + bs->phys_addr = iomem->start; + bs->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(bs->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(bs->clk),