Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp740682lqb; Fri, 24 May 2024 11:38:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNmY1k8ImCcpRSntnr2RFPYYLtKZjnxmoSledB+FI5J4xirwr5OBAUsRfe+Q6EuQfoANnKhGwSNeFV7WeLgGcWj+0FsvAqGuj0FOnUOQ== X-Google-Smtp-Source: AGHT+IFCObVtapI1aIYTq75jb8aS/Kk37BKRS729p4vZj/giRYwC13ku90O4O98392ISMistWQnL X-Received: by 2002:a17:906:fe06:b0:a5c:d67a:e8ef with SMTP id a640c23a62f3a-a62642d49bdmr264284166b.31.1716575891923; Fri, 24 May 2024 11:38:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716575891; cv=pass; d=google.com; s=arc-20160816; b=ALVsEf/OGFBwtP7AospJ7BoiFKxvI3bccewFMCmG6Ugq/HXU8Y9A8pXeEXXegmqHqH 9NegEGvWhT4I0XwJlC4EwKa5mT1phpVuL28+bE5JA2Wjnu451cq7ZbdQRf9F6huWFJ4z Ssa0qNimt9lqvdV/HA73SO3HeQC2wh3gRdcJfdH8+VX5PP8e9I048qIYG5/W20Wb8hXb XB5q1efLr6JfQCzZfvV7syOMdDOi5KN+1IeHdfb07qlGyHHKWwy6lFss2Bj9SEd0Akfr YF9PqDDjpTD9qYejv5aC53V6TlMGJzdigUjmlt6lsVbJc8pSKiJ72exrMD2VP8vhgZOw 81CA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FGCf1ir0ewKxnfYL+8Y6zr0drR+R4O1jhqT1oluTBL8=; fh=8aoUHhQQLq4EHQ5bjAF7aVZctNf2vSK3wfjk2HBxVW8=; b=0jHJKRYTL0keeTIf73SBY2ZNUxI6RwilOK1FO38LWtNuI4kMcMhKqYDDtgi0n25B31 /nVjOKCKmhJDth8Pm39LSS6A9IIX/cQjyzOIkBcqnKNj2Zkzzv4caB/IweoZf6uep+UA Lca5vU7082COWO0mwDBVddojU+b48Z09TM6SvE4BdlzNIeq582DjJ7a7UoGF8Bi2/TJc PhWS0gcvP639emFKjSxzFiCi5JdpFnN/q82eZQ4EoYJKNeF63+4iXbvf0tCnufLxrFN5 nUhioALIaGkjcON09sYI+z5PD0ObZTgwIrO60RYqgt7issIVCrF+jHrsKi/i8PKsVJlg sWEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=H8SvFKa9; arc=pass (i=1 spf=pass spfdomain=raspberrypi.com dkim=pass dkdomain=raspberrypi.com dmarc=pass fromdomain=raspberrypi.com); spf=pass (google.com: domain of linux-kernel+bounces-189007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cc3c578si99643766b.338.2024.05.24.11.38.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:38:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=H8SvFKa9; arc=pass (i=1 spf=pass spfdomain=raspberrypi.com dkim=pass dkdomain=raspberrypi.com dmarc=pass fromdomain=raspberrypi.com); spf=pass (google.com: domain of linux-kernel+bounces-189007-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189007-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1CFC41F23801 for ; Fri, 24 May 2024 18:31:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1105E12FF94; Fri, 24 May 2024 18:28:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="H8SvFKa9" Received: from mail-wm1-f97.google.com (mail-wm1-f97.google.com [209.85.128.97]) (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 685E255C1A for ; Fri, 24 May 2024 18:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.97 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575287; cv=none; b=TBHl2rPtzFoblp+7vsF/TOOCJWGUuirrao5jkiMh292LA9k3OgDKcrVrS+llEvEG0LeLUU7ZfFmUolP96n2beOM1EAFF+YJpoqkt/t/06gcXB22gnty3gR4ZHQF+LZ1lGwdvkXbPv47I/W5f+Czt+Y1iJhkVlU776qdBUOdiKXg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575287; c=relaxed/simple; bh=N3Kfi5rjJxhjSAGsgu3nLGQYoSBKamIirsVfmPZi9nY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RB+wVlx98Xkz9dSjNMZe4oOfEp6FQo/Gy51WU4rop8+QnUhsg9HriVthKSbqES/w+dT7w1NIRll+QAeOGlIHzTQ4vALVavtYBNxPrL03iH6DO/GQt2VXivM+W7sFHc6mw/2Eu7Gq09nl1HVCZLaeAxBC5HBNeFizpe4jXsR7oaE= 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.97 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 Received: by mail-wm1-f97.google.com with SMTP id 5b1f17b1804b1-4210aa012e5so6627775e9.0 for ; Fri, 24 May 2024 11:28:01 -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=OrIlDKdjCVKAMaMiSG1yh6bbXS9Zag3MQGJFIDUmtMcq4tibFzNIqyINwZhjtLIS7j trgV8UmhLQBWlMW/pL8K7W+4fp+sD/mHsFUm0wA8qgngl7tDZM8hFxtHv/6xo5/Pv3jO vQQoLAxO9xGQFwp9adMtU/Nlx6swZ/XUnORcjDfINZeqZk0bG/TE7OzAMsNNwFvj9ILA 9QS+yu2GniTumizOeahbJT57DznLXEMd4WUUXpZ83XhyPM9DmkbtCa+iMFSVZck0fG8s Cq1OJo49TOVlr7Fx3EILsoWIXD/8g4m+dRL+SuHjZT3wgq9SgStiCsFW6+6aITTGInZc aW7g== X-Forwarded-Encrypted: i=1; AJvYcCXZIeKrXTdzZxf9d3RHuPgwG4o2lZvs8OwFm6C0oQcPkBi/HFPy56SQRSkZf5iPHXG+6+znL8DFC0cbH+AQYEElHs+flsxd3vajW1Mi X-Gm-Message-State: AOJu0YykN+WjhmTJYAC/s3Y9JEYuLY8MF2XuybDDa4g67s8yxX7lKu3R 8wDMCuhzH6dcN3rljdmEG1fr1t8vUc9pVt9rxh+9gQ96jK62TBEb+fBXPaV8NL9OPD9DHJOmyFy PX+182D6/XTUV4TXG4F6IRl96LblYeM7L 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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), -- 2.34.1