Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp3445271pxb; Sun, 26 Sep 2021 15:46:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpIu8YWHv9u3gXitI8AoMK7zFl8QApnxlegYh34s0Znuhfwl+nWBBlaK+2EWSzaBbyACDT X-Received: by 2002:a17:90a:6286:: with SMTP id d6mr16045407pjj.199.1632696391788; Sun, 26 Sep 2021 15:46:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632696391; cv=none; d=google.com; s=arc-20160816; b=xsb8A3t2ot2gfn3/2Ko3PmCV1HJ8CHrgV28bOT57eERyD8/YgneVKT9GleY2X0DCZq Cng2HBXCE0VMhuMXFAk6gOVpykTG0h7b9QAhF51tExx51g8EUsbLEVId2IbUVXZIylms r9VcqzLJF9ESYHNzNQOVF9Su78MzmfSLsIKllUgmBSXgL6bcskWXDdRKj1tnDsvFU3ea HLaS/O9cYeeJuRYweMJ3PSBEaS0ussOP9ujj6/40cfJ0LlojJTxw+aK0v9Dmumu8NxNj Lqa4s5SA6HwkxSXWN7TlWhPhDLPbmOpnT9tbremIRvjhvSazryqnfS9u2E0fDMItReqO SoMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OIcT7jD3PqmkaPXwCgv6FGE++Qsz6I3+CRXDdvNGkZc=; b=chAZ62RHaZ/FaGsETHFTm7VZ2ND9eG6IuxnGH7d1fdlxSvTKG0c7vaIthXcTGxZKbY Cb7s0Zx69nX6XRXfS+4Ttvac0E93l5qqbYeb3OYan48vvJUf4gDqnl7MpmT7Z/R/qr0u nR0TxsnBi33V4iELLRItsezJWQ9Lgv/MERQRVaKeCXv3Qmu6f09UV7ASEdR4dulX9JJm 2wWppZ7eEy01CmnvqNop/CzHCQ1Q+B/IvLjqhfwyoL9lPaNbCAG02YDWdYY64NZxFeXg Tq0ob2A/iVcVphYBvtjTeELpkZnssWrJIlMvoRY8a0vI6BilLOCqM4VTCF8KLuPSDvcC xHjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GQr5zOfq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z4si20488191pgs.218.2021.09.26.15.46.19; Sun, 26 Sep 2021 15:46:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GQr5zOfq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232392AbhIZWpt (ORCPT + 99 others); Sun, 26 Sep 2021 18:45:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231962AbhIZWoX (ORCPT ); Sun, 26 Sep 2021 18:44:23 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67657C061769; Sun, 26 Sep 2021 15:42:46 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id b15so67584113lfe.7; Sun, 26 Sep 2021 15:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OIcT7jD3PqmkaPXwCgv6FGE++Qsz6I3+CRXDdvNGkZc=; b=GQr5zOfq1k+YD5tRGG59H9eHekGNDorwM1nNZne6Kpi2fJlwmk0Dea4jWM6r4ie4px NNreWO0Mb2InlEUV2l8PnwYcTbOTgP93BUL8JiiCKmTEFaqcD8QXlrwu4kn3AN2jxIv+ ALJ5L8EVgfu5QxJeCvhI1pzCcYMfYNJA0mBARUJOGw5je9hVPlorRBEL6CZH1nBoGaJo Hipk6QrJIBA1QKSJuV4ZKKbFUW+pvg2g+M0S6xfbzm3wbQ8m8U7OvkDT5Ji/eS3FX16w Nzn48ZTC1DXy/M7bQk5DXw8DinobPj485QTO9Myk+oMrmcTAOugWlQ1pyqHEOlu05dc2 s9yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OIcT7jD3PqmkaPXwCgv6FGE++Qsz6I3+CRXDdvNGkZc=; b=fSW5EKBO2kjVXzFRBw1bN5Il6AiMZHPeVRo7g/9cwAbTmxupeeX3ZnB5HieoRwS7O1 tH8zedDBBowr265dz1ACvuftfN7o11T1FateSk9b6aD38mSlyRDB/Je0uI7RQycT0OJ9 vxW+iHB50QT0pWl/3nCjiwJQGja78IN06Zrb4gi+UlcGcYJy6D+wMBmJT4niFutBwmv4 CCvn+blCQzKQAaCYyW7Vfi9g4peqmY6xksZGvlnQPVXIh12OySiDwqEOpR7IedkZ8KUY cCXnJZIo4IiavO9NNmxa+Qh/k635fUVrZS14GHkwCO/UUKMcEWTq6Mn69+xZ/L6oGH1a aX3A== X-Gm-Message-State: AOAM531llljc/xdPaQAzCOwXx8dYpH2Y1Vb2s9pzLiEaMjFtSozvqCdy 5s871SHwM2Gv/3gEOorcP/w= X-Received: by 2002:a2e:9ed9:: with SMTP id h25mr24886446ljk.40.1632696164806; Sun, 26 Sep 2021 15:42:44 -0700 (PDT) Received: from localhost.localdomain (46-138-80-108.dynamic.spd-mgts.ru. [46.138.80.108]) by smtp.gmail.com with ESMTPSA id m10sm1408899lfr.272.2021.09.26.15.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Sep 2021 15:42:44 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Ulf Hansson , Viresh Kumar , Stephen Boyd , Peter De Schrijver , Mikko Perttunen , Peter Chen , Lee Jones , =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Nishanth Menon , Adrian Hunter , Michael Turquette Cc: linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-staging@lists.linux.dev, linux-pwm@vger.kernel.org, linux-mmc@vger.kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-clk@vger.kernel.org, Mark Brown , Vignesh Raghavendra , Richard Weinberger , Miquel Raynal , Lucas Stach , Stefan Agner , Mauro Carvalho Chehab , David Heidelberg Subject: [PATCH v13 16/35] usb: chipidea: tegra: Add runtime PM and OPP support Date: Mon, 27 Sep 2021 01:40:39 +0300 Message-Id: <20210926224058.1252-17-digetx@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210926224058.1252-1-digetx@gmail.com> References: <20210926224058.1252-1-digetx@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Tegra USB controller belongs to the core power domain and we're going to enable GENPD support for the core domain. Now USB controller must be resumed using runtime PM API in order to initialize the USB power state. We already support runtime PM for the CI device, but CI's PM is separated from the RPM managed by tegra-usb driver. Add runtime PM and OPP support to the driver. Signed-off-by: Dmitry Osipenko --- drivers/usb/chipidea/ci_hdrc_tegra.c | 53 ++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c index 60361141ac04..3142ef7ebe42 100644 --- a/drivers/usb/chipidea/ci_hdrc_tegra.c +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -15,6 +16,8 @@ #include #include +#include + #include "../host/ehci.h" #include "ci.h" @@ -278,6 +281,8 @@ static int tegra_usb_probe(struct platform_device *pdev) if (!usb) return -ENOMEM; + platform_set_drvdata(pdev, usb); + soc = of_device_get_match_data(&pdev->dev); if (!soc) { dev_err(&pdev->dev, "failed to match OF data\n"); @@ -296,11 +301,17 @@ static int tegra_usb_probe(struct platform_device *pdev) return err; } - err = clk_prepare_enable(usb->clk); - if (err < 0) { - dev_err(&pdev->dev, "failed to enable clock: %d\n", err); + err = devm_pm_runtime_enable(&pdev->dev); + if (err) + return err; + + err = devm_tegra_core_dev_init_opp_table_common(&pdev->dev); + if (err) + return err; + + err = pm_runtime_resume_and_get(&pdev->dev); + if (err) return err; - } if (device_property_present(&pdev->dev, "nvidia,needs-double-reset")) usb->needs_double_reset = true; @@ -320,8 +331,6 @@ static int tegra_usb_probe(struct platform_device *pdev) if (err) goto fail_power_off; - platform_set_drvdata(pdev, usb); - /* setup and register ChipIdea HDRC device */ usb->soc = soc; usb->data.name = "tegra-usb"; @@ -350,7 +359,8 @@ static int tegra_usb_probe(struct platform_device *pdev) phy_shutdown: usb_phy_shutdown(usb->phy); fail_power_off: - clk_disable_unprepare(usb->clk); + pm_runtime_put(&pdev->dev); + return err; } @@ -360,15 +370,44 @@ static int tegra_usb_remove(struct platform_device *pdev) ci_hdrc_remove_device(usb->dev); usb_phy_shutdown(usb->phy); + pm_runtime_put(&pdev->dev); + + return 0; +} + +static int __maybe_unused tegra_usb_runtime_resume(struct device *dev) +{ + struct tegra_usb *usb = dev_get_drvdata(dev); + int err; + + err = clk_prepare_enable(usb->clk); + if (err < 0) { + dev_err(dev, "failed to enable clock: %d\n", err); + return err; + } + + return 0; +} + +static int __maybe_unused tegra_usb_runtime_suspend(struct device *dev) +{ + struct tegra_usb *usb = dev_get_drvdata(dev); + clk_disable_unprepare(usb->clk); return 0; } +static const struct dev_pm_ops tegra_usb_pm = { + SET_RUNTIME_PM_OPS(tegra_usb_runtime_suspend, tegra_usb_runtime_resume, + NULL) +}; + static struct platform_driver tegra_usb_driver = { .driver = { .name = "tegra-usb", .of_match_table = tegra_usb_of_match, + .pm = &tegra_usb_pm, }, .probe = tegra_usb_probe, .remove = tegra_usb_remove, -- 2.32.0