From patchwork Sun May 10 16:55:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= X-Patchwork-Id: 11539819 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C77C5912 for ; Mon, 11 May 2020 07:18:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 A5988207FF for ; Mon, 11 May 2020 07:18:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wwq94eZf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5988207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC84C6E22E; Mon, 11 May 2020 07:17:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DDDA89FCC for ; Sun, 10 May 2020 16:55:54 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id l11so2040568wru.0 for ; Sun, 10 May 2020 09:55:54 -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=UBcArp9z+dOkkmJwdzsA1OSuQPmhGv0QOxoFlPBuJwQ=; b=Wwq94eZf1awZPhOOpjkFV8onGcsTP4j6JSoLaP1hv/NsRtIKa3v2QYtSzINIdVMh9F 9gj5aW/rjEbnu43zvkMt5q0Mi3qX3UYW/KTPlRdVCuAMXoJWervwJp2DQza7Vrl8mGd/ yGgPBiUtYNpHlRsyfgBLkOBi3yTsXsxDj+rECDUwN1aLqQbY+yiyQsu4FR8tauyMS+O6 P/AEJuLJSWL8WD+wjnBkYhT1IyqpHwIFnDOReKeuw8XRW2RCLvPp7NF7YZYGniIoBH6q KyX4poSnD139MRUGIyGlGwn/AZ3xO+vsghXfTPKnL0tOL/BBksP8ee0sxeW/RNec/rpj 95bQ== 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=UBcArp9z+dOkkmJwdzsA1OSuQPmhGv0QOxoFlPBuJwQ=; b=qUU1Bcr0dNzvg98XNIGb8bvmcDf2snsSoetNjFExX8I+z/Ivap5R0hBtFE2A4ymiVr mM7f+1g9y+xk4kkv1kPZ+j5zUgnQlPYtXP5fwmq93rmA33gVgHkKbYu/5jHQu0ly+wf5 R6OFYt847iEPHroivJhwX1PcJj45IZYvU9swEUPjI5VaLZemiAaRdMk6Fit+JZBneNcK 8sdcyAuJHn40YyLP99rw9g5ZRWO1VYOu+EUZSQt6a51WPwgB7n7UKcK44yVy7bg8B1wt Du7Aiv5vmE7O81SoZ61E+EQtKVDMi2cKeUPfJ0m1HS0j0AyzlY2IEW4zRBJsNOe0TrUM ob0g== X-Gm-Message-State: AGi0PubErSatcgEuvJfHWpm83hqkCTGQvD1aEBT8MYo8gCVjucux0YhZ 7f2KPDucQsL2W0jI0ItJyEI= X-Google-Smtp-Source: APiQypKYWnQjWfAFe8Sh1wPAmn7ij3fKLm9ouithCNi1zPtZuofz2+9xQFanf+kmHfZ+CzFF3krFgQ== X-Received: by 2002:a5d:460d:: with SMTP id t13mr14831054wrq.280.1589129752787; Sun, 10 May 2020 09:55:52 -0700 (PDT) Received: from localhost.localdomain ([2a01:e0a:1f1:d0f0:1cc8:b1f1:a2b8:a1ee]) by smtp.gmail.com with ESMTPSA id g15sm13637670wrp.96.2020.05.10.09.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 09:55:52 -0700 (PDT) From: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= To: Rob Herring , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , Viresh Kumar , Nishanth Menon , Stephen Boyd , Maxime Ripard , Chen-Yu Tsai Subject: [PATCH 10/15] drm/panfrost: add regulators to devfreq Date: Sun, 10 May 2020 18:55:33 +0200 Message-Id: <20200510165538.19720-11-peron.clem@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200510165538.19720-1-peron.clem@gmail.com> References: <20200510165538.19720-1-peron.clem@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 11 May 2020 07:17:27 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Some OPP tables specify voltage for each frequency. Devfreq can handle these regulators but they should be get only 1 time to avoid issue and know who is in charge. If OPP table is probe don't init regulator. Signed-off-by: Clément Péron Reviewed-by: Steven Price --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 19 +++++++++++++++++++ drivers/gpu/drm/panfrost/panfrost_devfreq.h | 2 ++ drivers/gpu/drm/panfrost/panfrost_device.c | 11 +++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index fce21c682414..9ffea0d4a087 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -93,6 +93,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) unsigned long cur_freq; struct device *dev = &pfdev->pdev->dev; struct devfreq *devfreq; + struct opp_table *opp_table; struct thermal_cooling_device *cooling; struct panfrost_devfreq *pfdevfreq = &pfdev->pfdevfreq; @@ -102,6 +103,19 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) spin_lock_init(&pfdevfreq->lock); + opp_table = dev_pm_opp_set_regulators(dev, pfdev->comp->supply_names, + pfdev->comp->num_supplies); + if (IS_ERR(opp_table)) { + ret = PTR_ERR(opp_table); + /* Continue if the optional regulator is missing */ + if (ret != -ENODEV) { + DRM_DEV_ERROR(dev, "Couldn't set OPP regulators\n"); + goto err_fini; + } + } else { + pfdevfreq->regulators_opp_table = opp_table; + } + ret = dev_pm_opp_of_add_table(dev); if (ret) { DRM_DEV_ERROR(dev, "Couldn't add OPP table\n"); @@ -157,6 +171,11 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) dev_pm_opp_of_remove_table(&pfdev->pdev->dev); pfdevfreq->opp_of_table_added = false; } + + if (pfdevfreq->regulators_opp_table) { + dev_pm_opp_put_regulators(pfdevfreq->regulators_opp_table); + pfdevfreq->regulators_opp_table = NULL; + } } void panfrost_devfreq_resume(struct panfrost_device *pfdev) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.h b/drivers/gpu/drm/panfrost/panfrost_devfreq.h index add203cb00c2..347cde4786cf 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.h +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.h @@ -8,12 +8,14 @@ #include struct devfreq; +struct opp_table; struct thermal_cooling_device; struct panfrost_device; struct panfrost_devfreq { struct devfreq *devfreq; + struct opp_table *regulators_opp_table; struct thermal_cooling_device *cooling; bool opp_of_table_added; diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c index 67eedf64e82d..8b17fb2e3369 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.c +++ b/drivers/gpu/drm/panfrost/panfrost_device.c @@ -222,10 +222,13 @@ int panfrost_device_init(struct panfrost_device *pfdev) goto err_out0; } - err = panfrost_regulator_init(pfdev); - if (err) { - dev_err(pfdev->dev, "regulator init failed %d\n", err); - goto err_out1; + /* OPP will handle regulators */ + if (!pfdev->pfdevfreq.opp_of_table_added) { + err = panfrost_regulator_init(pfdev); + if (err) { + dev_err(pfdev->dev, "regulator init failed %d\n", err); + goto err_out1; + } } err = panfrost_reset_init(pfdev);