Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp214410ybv; Thu, 6 Feb 2020 21:29:05 -0800 (PST) X-Google-Smtp-Source: APXvYqxDg/LFkuWWVFj+c2eIOQkx6rIfbcV3T4aXKV4YS8kb2WUAL6SJKy+73V2jCuc0UOpqxSjU X-Received: by 2002:a05:6830:1185:: with SMTP id u5mr1257450otq.147.1581053345473; Thu, 06 Feb 2020 21:29:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581053345; cv=none; d=google.com; s=arc-20160816; b=Ullqtk4nGCwF3hhsp3FGertzb5oo+jCTMISZwrdolwa7kZNykAUXdhGz24wCDnDL5q SFvOwpvf6z2q5FxW7I5Q3cJJhp/jwJSzA7x16he41+VYNf8ogo8np74r+YdXNj4aBiDA u/9FJWPcTTSuJrKndoFYRlJBcqee9R0E47bRh6RcngXWt4Zhs6E4dYl2o4QyQZZuYMe1 M7EFd4JAToaOit4mFNBMPS3vQ0HE+eWRcNmy8thnYg6xmUEohkLlV9f8gedb/Y+xr8qU vkydMfY5WPJWyG8GRBQHbmKQ87b7APOyMuvBx073zp+zQstgV2XAmzpCfbWwpa7wwUPz iq9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6xiAuePiYUDaMhCwdUVnLN02q98KdUMo0qYM9SWCYvk=; b=TWHlGMtOxFojlc7AhsxdMTKXlLoDP1eIiP+IwnATmAcsZFgR4a9E1IZ2GAS2uGW123 ymCF1etsFLOOwT/8uK05Xv36+qWTPp/Lxw4x4uugypXGYm7aJO86oim2HIcemFyulcY3 jIaVDxfqpoaiQdycsYKynZhG8x0LZzwPKhgKUpXKaQgmSkGWH6zC8UOmgjdG9i5BLm+y Vv5bU1B81fmLZVRtvQ3FLbUPRf8hpAARXzKg/+RpXVOYpEaZkCFgIpaJtsU9Pq8AJsML E4kN3P+CSroH+TGK1/u5kIIpLLkEcorLYj7MmMBByMRlr7qiNigzLLJn5TSYIPAVwP8W DMXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mP91Qror; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a143si3405116oii.179.2020.02.06.21.28.49; Thu, 06 Feb 2020 21:29:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mP91Qror; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727130AbgBGF1P (ORCPT + 99 others); Fri, 7 Feb 2020 00:27:15 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40045 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727114AbgBGF1N (ORCPT ); Fri, 7 Feb 2020 00:27:13 -0500 Received: by mail-pf1-f195.google.com with SMTP id q8so669156pfh.7 for ; Thu, 06 Feb 2020 21:27:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6xiAuePiYUDaMhCwdUVnLN02q98KdUMo0qYM9SWCYvk=; b=mP91QrorHLWCX9Rh9X47DtclzQQKLoeO9iO3IvXmxidLSUWEYCmZG3ZEgKr0pSJKnb TWUxVRkDGv77ATkUUhec/xYpUXI0QkVwwC+ITTb2N+nslPjJNvFbiuP+FOKJww+18Phh gk+CCiFxNbG3t97x3izZOi0kxZeRlTzW3NCIg= 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=6xiAuePiYUDaMhCwdUVnLN02q98KdUMo0qYM9SWCYvk=; b=eQAtcU+qJ2nXwK2g9mrT3dDdpLV2w8DMnVjCMQa05U2WAKKMzXLRmzsWxykomXzK6b XqHLH8GEkoHezH4HyYviNVeEKrhBn/cO4g7l5gqF+PMgW0uQMlF56wFqUurOC9zYHGIM 1zZGEp0iVmILui7Rt3YgkL4hwRLX03XV5guPd/o+GUQy/6UU07RR2TI3OtqRfl8J7ifD BkrXGz+95bVAnT8INsnluL6dkH/+bcSc5mjDp/wKmD4IjUe58nK71OC1Ib3DlnV9c+XW 00xNJy6/kgVTDO0zklV9hy688diese15RT+x8Sofn8nVh+9kczrt+rlf3kUH2t9lUjvU DlBw== X-Gm-Message-State: APjAAAVYbTtx8urxD8VTvRlyULTQc86SpquEtgpVe9RGS5wKelPQ+pvV H94V/0lTaMUahKXuY4yPXvry7g== X-Received: by 2002:a63:2266:: with SMTP id t38mr7950990pgm.145.1581053232225; Thu, 06 Feb 2020 21:27:12 -0800 (PST) Received: from drinkcat2.tpe.corp.google.com ([2401:fa00:1:b:d8b7:33af:adcb:b648]) by smtp.gmail.com with ESMTPSA id i66sm1174485pfg.85.2020.02.06.21.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2020 21:27:11 -0800 (PST) From: Nicolas Boichat To: Rob Herring Cc: David Airlie , Daniel Vetter , Mark Rutland , Matthias Brugger , Tomeu Vizoso , Steven Price , Alyssa Rosenzweig , Liam Girdwood , Mark Brown , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, hsinyi@chromium.org, ulf.hansson@linaro.org Subject: [PATCH v4 7/7] RFC: drm/panfrost: devfreq: Add support for 2 regulators Date: Fri, 7 Feb 2020 13:26:27 +0800 Message-Id: <20200207052627.130118-8-drinkcat@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200207052627.130118-1-drinkcat@chromium.org> References: <20200207052627.130118-1-drinkcat@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Bifrost GPU on MT8183 uses 2 regulators (core and SRAM) for devfreq, and provides OPP table with 2 sets of voltages. TODO: This is incomplete as we'll need add support for setting a pair of voltages as well. Signed-off-by: Nicolas Boichat --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 17 +++++++++++++++++ drivers/gpu/drm/panfrost/panfrost_device.h | 1 + 2 files changed, 18 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 413987038fbfccb..9c0987a3d71c597 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -79,6 +79,21 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) struct devfreq *devfreq; struct thermal_cooling_device *cooling; + /* If we have 2 regulator, we need an OPP table with 2 voltages. */ + if (pfdev->comp->num_supplies > 1) { + pfdev->devfreq.dev_opp_table = + dev_pm_opp_set_regulators(dev, + pfdev->comp->supply_names, + pfdev->comp->num_supplies); + if (IS_ERR(pfdev->devfreq.dev_opp_table)) { + ret = PTR_ERR(pfdev->devfreq.dev_opp_table); + pfdev->devfreq.dev_opp_table = NULL; + dev_err(dev, + "Failed to init devfreq opp table: %d\n", ret); + return ret; + } + } + ret = dev_pm_opp_of_add_table(dev); if (ret == -ENODEV) /* Optional, continue without devfreq */ return 0; @@ -119,6 +134,8 @@ void panfrost_devfreq_fini(struct panfrost_device *pfdev) if (pfdev->devfreq.cooling) devfreq_cooling_unregister(pfdev->devfreq.cooling); dev_pm_opp_of_remove_table(&pfdev->pdev->dev); + if (pfdev->devfreq.dev_opp_table) + dev_pm_opp_put_regulators(pfdev->devfreq.dev_opp_table); } void panfrost_devfreq_resume(struct panfrost_device *pfdev) diff --git a/drivers/gpu/drm/panfrost/panfrost_device.h b/drivers/gpu/drm/panfrost/panfrost_device.h index c30c719a805940a..5009a8b7c853ea1 100644 --- a/drivers/gpu/drm/panfrost/panfrost_device.h +++ b/drivers/gpu/drm/panfrost/panfrost_device.h @@ -110,6 +110,7 @@ struct panfrost_device { struct { struct devfreq *devfreq; struct thermal_cooling_device *cooling; + struct opp_table *dev_opp_table; ktime_t busy_time; ktime_t idle_time; ktime_t time_last_update; -- 2.25.0.341.g760bfbb309-goog