From patchwork Fri Nov 23 12:06:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10695711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E1111750 for ; Fri, 23 Nov 2018 12:06:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1EC32AB8C for ; Fri, 23 Nov 2018 12:06:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E63B22B681; Fri, 23 Nov 2018 12:06:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A1FB62AB8C for ; Fri, 23 Nov 2018 12:06:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB67C6E08E; Fri, 23 Nov 2018 12:06:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6BE9B6E082 for ; Fri, 23 Nov 2018 12:06:42 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id y56so10057073edd.11 for ; Fri, 23 Nov 2018 04:06:42 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=4BOTl7jux4pQasSyxKIZHtohs1Rc7WDNsfhWL1lC7Ac=; b=N9fQ5ZfVGyhfyYig5872i678KRjxiE2QQLBM42syp7tz5NO80LiBxZWxkooU720YTc +ARAw1PgVNP5l9pZ8OFNT5XWHgrVjlbVO5yeNPBhlPObrnRzArUcVyrEZdzDXUha+b/M 1diL5OVoVcaD1zejjOZrilaLNDegx/uBrrC5lexe4if1Qt6AIsei3y260NMDXPCWdCbU fYO4ppmgvR6bBNR2xU/HLfunVhJL/1PXV4YQEVbatZqDKEu6K4TDtzcJrEyxVKv6ukVy 0MmQf5cqcTiBA/V20lyM0Zi31Sw1fWAslsThISrVm3+W20tG2z7UQgRlji42IZRtrYh/ PqWQ== X-Gm-Message-State: AA+aEWZd7PYrsHElS65sjZzNGiewmVT1AmA19bXTubL7yTIhWqbX8Rvv MKx73st6mrZGfp8NgdAPizU= X-Google-Smtp-Source: AFSGD/WlXGV59U5AHaA1bLfarEzaJ6oQziDbIrPEHwpH8hjwGErkY6G841n4tEbrk0+2gA3Sc/yLkg== X-Received: by 2002:a50:a5b8:: with SMTP id a53mr13367817edc.199.1542974801042; Fri, 23 Nov 2018 04:06:41 -0800 (PST) Received: from localhost (pD9E51040.dip0.t-ipconnect.de. [217.229.16.64]) by smtp.gmail.com with ESMTPSA id f19-v6sm4571896eje.28.2018.11.23.04.06.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Nov 2018 04:06:40 -0800 (PST) From: Thierry Reding To: Thierry Reding Subject: [PATCH 1/3] drm/tegra: vic: Implement explicit reset support Date: Fri, 23 Nov 2018 13:06:37 +0100 Message-Id: <20181123120639.16706-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Mikko Perttunen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding Tegra supports generic PM domains on 64-bit ARM, and if that is enabled, the power domain code will make sure that resets are asserted and deasserted at appropriate points in time. If generic PM domains are not implemented, such as on 32-bit Tegra, the resets need to be asserted and deasserted explicitly by the driver. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/vic.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index 9fa77405db01..23f530db45ad 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -38,6 +38,7 @@ struct vic { struct iommu_domain *domain; struct device *dev; struct clk *clk; + struct reset_control *rst; /* Platform configuration */ const struct vic_config *config; @@ -56,13 +57,37 @@ static void vic_writel(struct vic *vic, u32 value, unsigned int offset) static int vic_runtime_resume(struct device *dev) { struct vic *vic = dev_get_drvdata(dev); + int err; + + err = clk_prepare_enable(vic->clk); + if (err < 0) + return err; + + usleep_range(2000, 4000); + + err = reset_control_deassert(vic->rst); + if (err < 0) + goto disable; + + usleep_range(2000, 4000); + + return 0; - return clk_prepare_enable(vic->clk); +disable: + clk_disable_unprepare(vic->clk); + return err; } static int vic_runtime_suspend(struct device *dev) { struct vic *vic = dev_get_drvdata(dev); + int err; + + err = reset_control_assert(vic->rst); + if (err < 0) + return err; + + usleep_range(2000, 4000); clk_disable_unprepare(vic->clk); @@ -324,6 +349,14 @@ static int vic_probe(struct platform_device *pdev) return PTR_ERR(vic->clk); } + if (!dev->pm_domain) { + vic->rst = devm_reset_control_get(dev, "vic"); + if (IS_ERR(vic->rst)) { + dev_err(&pdev->dev, "failed to get reset\n"); + return PTR_ERR(vic->rst); + } + } + vic->falcon.dev = dev; vic->falcon.regs = vic->regs; vic->falcon.ops = &vic_falcon_ops;