From patchwork Thu Apr 27 12:09:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 88227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp219721vqo; Thu, 27 Apr 2023 05:11:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tY1hMxc6MkH4kvYcooPoL57c1U25LGzH5cvJzfLm6RUVuOwzUNy+wLW97fm+/5l0JiZrP X-Received: by 2002:a05:6a00:c88:b0:63b:8a00:4580 with SMTP id a8-20020a056a000c8800b0063b8a004580mr2252692pfv.0.1682597487366; Thu, 27 Apr 2023 05:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682597487; cv=none; d=google.com; s=arc-20160816; b=qOsCS2nELr3X8xfjqmfuNK7WYFfp1i/wc9isFl7eHa0OCkG3j7LCq184HT6regN2+H icW2vu3L4xyOaR0Slz6CJy9U7ryW9u5DzaIqu7h4MEdB+ZhDV9rAyJN+5hO66alCRflJ V0IRNsqpvnIHl4WFpRIJRH1jK48O59RfhYHODcHnYQfa/euTuxNlKFvFneAsjVfmP5+Z CiezC3SnXhWmxg794csqqYC1LbN7ueq7eXHeP/ebxDKTiyZRUXEqfG9plrYktieEuyrb VnBcU+KEt+rA0+f5sRc6XgQtTjKCkQEesAR4dSNnRbs7JwYKCecBya+z6+WXfZqzx1t8 mikg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=aWTuvneH8OCx2P81Wc3vASVRb7SduL7aaPSfgRD/SAs=; b=y3g+ktyu8LZ7P26EQteEofUm0hr0ljCGCsgV4f7O9KYn3l1/ZbEqUdvjXEFrP8cnD4 O8reJfwfsgI65LN0Q5PmSHVB77Bl4yjiPtKvhQmfGqYoJVwLTwflyPbNa1JUHNEq1uYN IVtOPitUiZV7vbd73ZvVnw3KLx/74uaZoNd2AsB27jptdjDcIg3vKUce6zw5jvgfy5eL INJSb1r8KV2bturjSYGNvZ5KSyqjA0mO1ZZPLbB0CUbIpS1YOplGS/kD4bz9nhJDS68y TPQAXST39qDtgVJoZ90cUz+ksV8gnLZ9EASqvAVvI6iVUN8YHKR9sJBaof/bO5ZMaAeT 0bWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=om4ZJrub; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k28-20020aa7973c000000b0063d37ae9543si18982441pfg.28.2023.04.27.05.11.12; Thu, 27 Apr 2023 05:11:27 -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=@linaro.org header.s=google header.b=om4ZJrub; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243743AbjD0MKL (ORCPT + 99 others); Thu, 27 Apr 2023 08:10:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243638AbjD0MKE (ORCPT ); Thu, 27 Apr 2023 08:10:04 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A66F49DC for ; Thu, 27 Apr 2023 05:10:02 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-4ec816c9d03so9317432e87.2 for ; Thu, 27 Apr 2023 05:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682597401; x=1685189401; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aWTuvneH8OCx2P81Wc3vASVRb7SduL7aaPSfgRD/SAs=; b=om4ZJrubqvm9fw2ZalUk1RT0azz39OuLOId41AYD0LfTb5dlZ9LX3jCwDrBZKOO++e uA1mRFlnjWE2DTzo+ZEKqXtcuZhYON83NYKG5peLU1pizGZ1Gwa7SJipGmrVJEUf4upi yp9LH5iTxIqy8l15MjffFKXm4jfGcp+XPj97cRTp1hrQUnEb4HAFaYn+P1uhVDxlxWo/ WD1ZR1HVW5/REtdxhNkQnjbS02c9El/JOTgMDHdVZpQ+wH3rYf50S403y6n1slz289eO mNT+SaaGh+DDOzJ0okF99kSR/kGGc5YehVHI8N8wPHUz6/1ivOHPM+jRdU4uS+zRsBOq AvmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682597401; x=1685189401; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aWTuvneH8OCx2P81Wc3vASVRb7SduL7aaPSfgRD/SAs=; b=itVlUeI6EA9Q8h2MakiHOyEm+E6tK5MS/Mq/9jV9lSbQgECqOubX6YbYnTEZZCZMX9 8EgvAZkaqA7+7YROIYFA0YN8EreoUG3iar+1zLDeq14fud2ezoBYiVVMgm7vFgug5iZY OCv4iAagQjT9SMZodeGNsR/ljIDxAvCAxieiOU/DRGXihR+0XA1DsILhGM173/9qdmeY kk7r2WmtNNVjVKEL3HhHkx8sgLVu9Q7hWTG+osBpjCglwkd6u8DmqEf7UutH0YS5cZI2 guCY33BoW1lMiD1i/72Ftdf96jau/InjAS5MdVXjqwiEYGnf7E+/FvPWu56EzGV5HTAN Lpxg== X-Gm-Message-State: AC+VfDzq+7S/lo6eSyhLD97KeLpfcyWGaqO10Z2ovHfjB6vrl+5Z/Q9e gUgJLgnrLSHXuCslEX2mIgQBXw== X-Received: by 2002:a05:6512:3cc:b0:4ed:cc6d:1da1 with SMTP id w12-20020a05651203cc00b004edcc6d1da1mr433433lfp.36.1682597400855; Thu, 27 Apr 2023 05:10:00 -0700 (PDT) Received: from [192.168.1.2] (c-05d8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.216.5]) by smtp.gmail.com with ESMTPSA id e7-20020ac25467000000b004d4d7fb0e07sm2892044lfn.216.2023.04.27.05.09.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 05:10:00 -0700 (PDT) From: Linus Walleij Date: Thu, 27 Apr 2023 14:09:57 +0200 Subject: [PATCH v2 2/8] dmaengine: ste_dma40: Get LCPA SRAM from SRAM node MIME-Version: 1.0 Message-Id: <20230417-ux500-dma40-cleanup-v2-2-cdaa68a4b863@linaro.org> References: <20230417-ux500-dma40-cleanup-v2-0-cdaa68a4b863@linaro.org> In-Reply-To: <20230417-ux500-dma40-cleanup-v2-0-cdaa68a4b863@linaro.org> To: Vinod Koul , Rob Herring , Krzysztof Kozlowski Cc: dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764331343163637082?= X-GMAIL-MSGID: =?utf-8?q?1764331343163637082?= Instead of passing the reserved SRAM as a "reg" field look for a phandle to the LCPA SRAM memory so we can use the proper SRAM device tree bindings for the SRAM. Signed-off-by: Linus Walleij --- drivers/dma/Kconfig | 1 + drivers/dma/ste_dma40.c | 47 ++++++++++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig index fb7073fc034f..37db3dc9a92a 100644 --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -553,6 +553,7 @@ config STE_DMA40 bool "ST-Ericsson DMA40 support" depends on ARCH_U8500 select DMA_ENGINE + select SRAM help Support for ST-Ericsson DMA40 controller diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index f093e08c23b1..236269d35a53 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -3506,9 +3507,11 @@ static int __init d40_probe(struct platform_device *pdev) { struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev); struct device_node *np = pdev->dev.of_node; + struct device_node *np_lcpa; int ret = -ENOENT; struct d40_base *base; struct resource *res; + struct resource res_lcpa; int num_reserved_chans; u32 val; @@ -3535,37 +3538,37 @@ static int __init d40_probe(struct platform_device *pdev) spin_lock_init(&base->interrupt_lock); spin_lock_init(&base->execmd_lock); - /* Get IO for logical channel parameter address */ - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lcpa"); - if (!res) { - ret = -ENOENT; - d40_err(&pdev->dev, "No \"lcpa\" memory resource\n"); - goto destroy_cache; + /* Get IO for logical channel parameter address (LCPA) */ + np_lcpa = of_parse_phandle(np, "sram", 0); + if (!np_lcpa) { + dev_err(&pdev->dev, "no LCPA SRAM node\n"); + goto report_failure; } - base->lcpa_size = resource_size(res); - base->phy_lcpa = res->start; - - if (request_mem_region(res->start, resource_size(res), - D40_NAME " I/O lcpa") == NULL) { - ret = -EBUSY; - d40_err(&pdev->dev, "Failed to request LCPA region %pR\n", res); - goto destroy_cache; + /* This is no device so read the address directly from the node */ + ret = of_address_to_resource(np_lcpa, 0, &res_lcpa); + if (ret) { + dev_err(&pdev->dev, "no LCPA SRAM resource\n"); + goto report_failure; } + base->lcpa_size = resource_size(&res_lcpa); + base->phy_lcpa = res_lcpa.start; + dev_info(&pdev->dev, "found LCPA SRAM at 0x%08x, size 0x%08x\n", + base->phy_lcpa, base->lcpa_size); /* We make use of ESRAM memory for this. */ val = readl(base->virtbase + D40_DREG_LCPA); - if (res->start != val && val != 0) { + if (base->phy_lcpa != val && val != 0) { dev_warn(&pdev->dev, - "[%s] Mismatch LCPA dma 0x%x, def %pa\n", - __func__, val, &res->start); + "[%s] Mismatch LCPA dma 0x%x, def %08x\n", + __func__, val, base->phy_lcpa); } else - writel(res->start, base->virtbase + D40_DREG_LCPA); + writel(base->phy_lcpa, base->virtbase + D40_DREG_LCPA); - base->lcpa_base = ioremap(res->start, resource_size(res)); + base->lcpa_base = ioremap(base->phy_lcpa, base->lcpa_size); if (!base->lcpa_base) { ret = -ENOMEM; d40_err(&pdev->dev, "Failed to ioremap LCPA region\n"); - goto destroy_cache; + goto release_base; } /* If lcla has to be located in ESRAM we don't need to allocate */ if (base->plat_data->use_esram_lcla) { @@ -3678,9 +3681,7 @@ static int __init d40_probe(struct platform_device *pdev) if (base->lcpa_base) iounmap(base->lcpa_base); - if (base->phy_lcpa) - release_mem_region(base->phy_lcpa, - base->lcpa_size); +release_base: if (base->phy_start) release_mem_region(base->phy_start, base->phy_size);