From patchwork Tue Apr 20 16:52:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 12214777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A502FC433B4 for ; Tue, 20 Apr 2021 17:01:20 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B867613AE for ; Tue, 20 Apr 2021 17:01:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B867613AE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KR1ZnsqPI4kkN4gqZdXL/Yb3EujFsRcx82Vi/6lnbNw=; b=B6KVdsruOou8uPiN+8DF9Slw/ U2Cc4LlH0ce+1OkNmYF218vDLSHd+dCF+DiYW4/CBApOJgUwi0XVGsrsLzdoq3fH+b2GL6i56EFK2 XAcuZWQWQgjfigzs9dbE2MX+ym6sY9P4k4sh82X7eB7Ap5AHKfckLu2R2WT0mM6bu7acDCMiou5k5 rVNS4SudsQ77QW8BbRiPwFAR20TjLhVN1H8k/leA+g/Yf1mKbRjPt2C/qigznk3tbtdVMB6cGzxnx Rec5VTyuN2cpNs/2QWilRkYicMMD3pS99rfoxQqXxRbCHEEQ1vrxC3Lio2gEOCkckaQ+PbDZTqXjz tYru2UBpQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lYtiD-00CeKp-TY; Tue, 20 Apr 2021 16:58:58 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYtbj-00CcFR-PF for linux-arm-kernel@desiato.infradead.org; Tue, 20 Apr 2021 16:52:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=MoLFzcLu/Eh+2OUOytsUKl2eC5AxgOFyE4l9AfiDZdc=; b=ULwyDa0yTvD6Ed5G0PVpO+nH3z ZGpybthow9fmxEC47tRb1+nCHscK8UVr5cqPeEE3vOFEmc3aUVwfckR7HVYYXVX1qKB8N+7lhszBW ZhLQbri9akgm1dQ/7D843ualr9Afx7WtW71WpofX51euu/NCsrXrIMm/nL6quJbzgpnvIzj+Ielsk ad8G8YmRq2TEo/kYMISgK+lmi6Y2Lpgwja3ZhAUenBMW6ZiobmxNtDOyZjbMIfN2WhUsXn/5a9LPX HpkuEUOc/5DN1j3bpmiIbMXgYbaRueAQmiExuqT+XyQ6rZ4u/QWleU3QE4KHFbjXHDVH3WjDAJXbK /vOIuxig==; Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lYtbg-00CHz3-QV for linux-arm-kernel@lists.infradead.org; Tue, 20 Apr 2021 16:52:14 +0000 Received: by mail-ej1-x62b.google.com with SMTP id sd23so50658951ejb.12 for ; Tue, 20 Apr 2021 09:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MoLFzcLu/Eh+2OUOytsUKl2eC5AxgOFyE4l9AfiDZdc=; b=gDVcHehP3Rp6EoYc19cPxcC9eI+nWWw9YTRBLj6nlaqAwIDoe0U41Wn+EqqC8y4fNT Q5pWc0PuktyUhBPE+7Zy9sA01ROlsAHvMplXF4t6eVHSm2PPD2aPsk6e4bUCRn7+60Ru FIXiNy4Rl7NOMpIpIKtP9Bq8ymcaeDzwKryS52wXRtcgYAuOm99+UineN7rw9tewfSPK EiFHe/BYSOsGKomDp8QqbaSpvLsh8TCk+krBAfm34/Nmc76+Yf5oJMZnz2JDZn/F7q+3 hcAvl/MGbaR9HLAU4bD8i2QxmShriUkomg4zZoMwEv9oT+LmTKDRtmL/i2UsQ4sCuFkd 1CsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MoLFzcLu/Eh+2OUOytsUKl2eC5AxgOFyE4l9AfiDZdc=; b=fQOvdFxA8hxYxXsOskTi/7iVAJdXcxptnsYz9wt3IC9SIVssjyHC4sbdkBX/FuB7bM G59dFhFpSBDPpvcmpXzJHohVA7KRVhg95hPB7CbyddmpzZw7MDnecLFED59ctShd2Yfm T4+ZxEsIp8qw/n0ohhShFylun6g4a2tFc4rXJaa8f3B1l1mSmaeDU5JcVS8xEh+HSYPi AqZnQn5Fa21DavTRkoWnmCE3U7DIADh/B841FABHksbcDeeEziHVIkfutVakyAdGsQVt 0/4rsEatIBO8I/B7nRPMtXjUQ+IBwmava/rk8za0N6n+/MEPPSSW7pDOQs31EN80ciTh jUww== X-Gm-Message-State: AOAM532wKXizhlw69LKxkruA8t2LVIZnonsIOX+xHEH1rwSc9pBgc7AS /VgIeRpRXjO5CWmKgyS0s+E= X-Google-Smtp-Source: ABdhPJxXNsXcgMXulFHPKuGVArA35/7KwdEGCPdGH3Edp9O5xw8ieSpoJx2qkYESTjMtLIzDuko10g== X-Received: by 2002:a17:906:dbcd:: with SMTP id yc13mr27198993ejb.99.1618937531625; Tue, 20 Apr 2021 09:52:11 -0700 (PDT) Received: from localhost ([62.96.65.119]) by smtp.gmail.com with ESMTPSA id cf4sm16607156edb.19.2021.04.20.09.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 09:52:10 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Krzysztof Kozlowski Cc: Jon Hunter , Dmitry Osipenko , linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/10] memory: tegra: Unify drivers Date: Tue, 20 Apr 2021 18:52:36 +0200 Message-Id: <20210420165237.3523732-9-thierry.reding@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210420165237.3523732-1-thierry.reding@gmail.com> References: <20210420165237.3523732-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210420_095212_891547_209C03E1 X-CRM114-Status: GOOD ( 27.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thierry Reding The Tegra210 (and earlier) driver now supports all the functionality that the Tegra186 (and later) driver does, so they can be unified. Note that previously the Tegra186 (and later) driver could be unloaded, even if that was perhaps not very useful. Older chips don't support that yet, but once they do this code can be reenabled. Signed-off-by: Thierry Reding --- drivers/memory/tegra/Makefile | 6 +- drivers/memory/tegra/mc.c | 27 +++++++- drivers/memory/tegra/mc.h | 8 +++ drivers/memory/tegra/tegra186.c | 117 +++++++------------------------- include/soc/tegra/mc.h | 1 + 5 files changed, 64 insertions(+), 95 deletions(-) diff --git a/drivers/memory/tegra/Makefile b/drivers/memory/tegra/Makefile index 6c1a2ecc6628..1af0fefacdda 100644 --- a/drivers/memory/tegra/Makefile +++ b/drivers/memory/tegra/Makefile @@ -7,6 +7,8 @@ tegra-mc-$(CONFIG_ARCH_TEGRA_114_SOC) += tegra114.o tegra-mc-$(CONFIG_ARCH_TEGRA_124_SOC) += tegra124.o tegra-mc-$(CONFIG_ARCH_TEGRA_132_SOC) += tegra124.o tegra-mc-$(CONFIG_ARCH_TEGRA_210_SOC) += tegra210.o +tegra-mc-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.o +tegra-mc-$(CONFIG_ARCH_TEGRA_194_SOC) += tegra186.o obj-$(CONFIG_TEGRA_MC) += tegra-mc.o @@ -15,7 +17,7 @@ obj-$(CONFIG_TEGRA30_EMC) += tegra30-emc.o obj-$(CONFIG_TEGRA124_EMC) += tegra124-emc.o obj-$(CONFIG_TEGRA210_EMC_TABLE) += tegra210-emc-table.o obj-$(CONFIG_TEGRA210_EMC) += tegra210-emc.o -obj-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186.o tegra186-emc.o -obj-$(CONFIG_ARCH_TEGRA_194_SOC) += tegra186.o tegra186-emc.o +obj-$(CONFIG_ARCH_TEGRA_186_SOC) += tegra186-emc.o +obj-$(CONFIG_ARCH_TEGRA_194_SOC) += tegra186-emc.o tegra210-emc-y := tegra210-emc-core.o tegra210-emc-cc-r21021.o diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c index 23b7728623cb..c854639cf30c 100644 --- a/drivers/memory/tegra/mc.c +++ b/drivers/memory/tegra/mc.c @@ -39,7 +39,13 @@ static const struct of_device_id tegra_mc_of_match[] = { #ifdef CONFIG_ARCH_TEGRA_210_SOC { .compatible = "nvidia,tegra210-mc", .data = &tegra210_mc_soc }, #endif - { } +#ifdef CONFIG_ARCH_TEGRA_186_SOC + { .compatible = "nvidia,tegra186-mc", .data = &tegra186_mc_soc }, +#endif +#ifdef CONFIG_ARCH_TEGRA_194_SOC + { .compatible = "nvidia,tegra194-mc", .data = &tegra194_mc_soc }, +#endif + { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, tegra_mc_of_match); @@ -800,6 +806,22 @@ static int tegra_mc_probe(struct platform_device *pdev) return 0; } +/* + * XXX The Tegra186 memory controller driver used to be able to do this. Once + * removing the driver is supported on all chips, this can be uncommented. + */ +/* +static int tegra_mc_remove(struct platform_device *pdev) +{ + struct tegra_mc *mc = platform_get_drvdata(pdev); + + if (mc->soc->ops && mc->soc->ops->remove) + mc->soc->ops->remove(mc); + + return 0; +} +*/ + static int __maybe_unused tegra_mc_suspend(struct device *dev) { struct tegra_mc *mc = dev_get_drvdata(dev); @@ -834,6 +856,9 @@ static struct platform_driver tegra_mc_driver = { }, .prevent_deferred_probe = true, .probe = tegra_mc_probe, + /* + .remove = tegra_mc_remove, + */ }; static int tegra_mc_init(void) diff --git a/drivers/memory/tegra/mc.h b/drivers/memory/tegra/mc.h index 5459018541e1..d6c22870517a 100644 --- a/drivers/memory/tegra/mc.h +++ b/drivers/memory/tegra/mc.h @@ -129,6 +129,14 @@ extern const struct tegra_mc_soc tegra132_mc_soc; extern const struct tegra_mc_soc tegra210_mc_soc; #endif +#ifdef CONFIG_ARCH_TEGRA_186_SOC +extern const struct tegra_mc_soc tegra186_mc_soc; +#endif + +#ifdef CONFIG_ARCH_TEGRA_194_SOC +extern const struct tegra_mc_soc tegra194_mc_soc; +#endif + #if defined(CONFIG_ARCH_TEGRA_3x_SOC) || \ defined(CONFIG_ARCH_TEGRA_114_SOC) || \ defined(CONFIG_ARCH_TEGRA_124_SOC) || \ diff --git a/drivers/memory/tegra/tegra186.c b/drivers/memory/tegra/tegra186.c index 9d3fdb609d55..20efbbea587b 100644 --- a/drivers/memory/tegra/tegra186.c +++ b/drivers/memory/tegra/tegra186.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (C) 2017 NVIDIA CORPORATION. All rights reserved. + * Copyright (C) 2017-2021 NVIDIA CORPORATION. All rights reserved. */ #include @@ -45,6 +45,24 @@ static void tegra186_mc_program_sid(struct tegra_mc *mc) } } +static int tegra186_mc_probe(struct tegra_mc *mc) +{ + int err; + + err = of_platform_populate(mc->dev->of_node, NULL, NULL, mc->dev); + if (err < 0) + return err; + + tegra186_mc_program_sid(mc); + + return 0; +} + +static void tegra186_mc_remove(struct tegra_mc *mc) +{ + of_platform_depopulate(mc->dev); +} + static int tegra186_mc_resume(struct tegra_mc *mc) { tegra186_mc_program_sid(mc); @@ -53,6 +71,8 @@ static int tegra186_mc_resume(struct tegra_mc *mc) } static const struct tegra_mc_ops tegra186_mc_ops = { + .probe = tegra186_mc_probe, + .remove = tegra186_mc_remove, .resume = tegra186_mc_resume, }; @@ -709,9 +729,10 @@ static const struct tegra_mc_client tegra186_mc_clients[] = { }, }; -static const struct tegra_mc_soc tegra186_mc_soc = { +const struct tegra_mc_soc tegra186_mc_soc = { .num_clients = ARRAY_SIZE(tegra186_mc_clients), .clients = tegra186_mc_clients, + .num_address_bits = 40, .ops = &tegra186_mc_ops, }; #endif @@ -1918,98 +1939,10 @@ static const struct tegra_mc_client tegra194_mc_clients[] = { }, }; -static const struct tegra_mc_soc tegra194_mc_soc = { +const struct tegra_mc_soc tegra194_mc_soc = { .num_clients = ARRAY_SIZE(tegra194_mc_clients), .clients = tegra194_mc_clients, + .num_address_bits = 40, .ops = &tegra186_mc_ops, }; #endif - -static int tegra186_mc_probe(struct platform_device *pdev) -{ - struct resource *res; - struct tegra_mc *mc; - int err; - - mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL); - if (!mc) - return -ENOMEM; - - mc->soc = of_device_get_match_data(&pdev->dev); - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - mc->regs = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(mc->regs)) - return PTR_ERR(mc->regs); - - mc->dev = &pdev->dev; - - err = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); - if (err < 0) - return err; - - platform_set_drvdata(pdev, mc); - tegra186_mc_program_sid(mc); - - return 0; -} - -static int tegra186_mc_remove(struct platform_device *pdev) -{ - struct tegra_mc *mc = platform_get_drvdata(pdev); - - of_platform_depopulate(mc->dev); - - return 0; -} - -static const struct of_device_id tegra186_mc_of_match[] = { -#if defined(CONFIG_ARCH_TEGRA_186_SOC) - { .compatible = "nvidia,tegra186-mc", .data = &tegra186_mc_soc }, -#endif -#if defined(CONFIG_ARCH_TEGRA_194_SOC) - { .compatible = "nvidia,tegra194-mc", .data = &tegra194_mc_soc }, -#endif - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, tegra186_mc_of_match); - -static int __maybe_unused tegra_mc_suspend(struct device *dev) -{ - struct tegra_mc *mc = dev_get_drvdata(dev); - - if (mc->soc->ops && mc->soc->ops->suspend) - return mc->soc->ops->suspend(mc); - - return 0; -} - -static int __maybe_unused tegra_mc_resume(struct device *dev) -{ - struct tegra_mc *mc = dev_get_drvdata(dev); - - if (mc->soc->ops && mc->soc->ops->resume) - return mc->soc->ops->resume(mc); - - return 0; -} - -static const struct dev_pm_ops tegra186_mc_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(tegra_mc_suspend, tegra_mc_resume) -}; - -static struct platform_driver tegra186_mc_driver = { - .driver = { - .name = "tegra186-mc", - .of_match_table = tegra186_mc_of_match, - .pm = &tegra186_mc_pm_ops, - .suppress_bind_attrs = true, - }, - .probe = tegra186_mc_probe, - .remove = tegra186_mc_remove, -}; -module_platform_driver(tegra186_mc_driver); - -MODULE_AUTHOR("Thierry Reding "); -MODULE_DESCRIPTION("NVIDIA Tegra186 Memory Controller driver"); -MODULE_LICENSE("GPL v2"); diff --git a/include/soc/tegra/mc.h b/include/soc/tegra/mc.h index ce3cdcc7b596..1387747d574b 100644 --- a/include/soc/tegra/mc.h +++ b/include/soc/tegra/mc.h @@ -172,6 +172,7 @@ struct tegra_mc_icc_ops { struct tegra_mc_ops { int (*probe)(struct tegra_mc *mc); + void (*remove)(struct tegra_mc *mc); int (*suspend)(struct tegra_mc *mc); int (*resume)(struct tegra_mc *mc); irqreturn_t (*handle_irq)(int irq, void *data);