From patchwork Wed Jan 10 03:47:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 124004 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4789406qgn; Tue, 9 Jan 2018 19:49:33 -0800 (PST) X-Google-Smtp-Source: ACJfBosjHZFGzVlSq4rfeb/Ff0LQpFM3JUs31mG7LSmVannSNNXa69b8ZV9ImDjQNmYowwAVoO7h X-Received: by 10.159.245.150 with SMTP id a22mr8687015pls.60.1515556173795; Tue, 09 Jan 2018 19:49:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515556173; cv=none; d=google.com; s=arc-20160816; b=xrh4x1uJMbYbtnrpsVoFoyy7dyRpktULQLjCP01GW+drNv6rxB5+ciI3pjQ9duqa4B 7PsoK6b2gYV2GLtEnexDRSWQYsv60nOHgIE/i+yzjjrxZVInO0YMq6RVPBF3bnuzFtP3 u/RS9iY4Gw+k3NsQVWt0Z407eDPaVNfoi6SmnRSWBbFSG02ruJ8Ij27LeGRE1omyoL1U ruJ7LWBS+hpbgeZnj0tVK/isJmLjOmr2Ngz4OGA5FDavN2rjIEr8bgxWpam7gibiyIzz KQvJT4NbGFnixfcrIRf5mOhoYvsPnuz9OWui+0VEO2LpYJKD/+jZIDmxn4U/m42f+zPF WUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=yOVDowshOOB3m6GCsZb+K+vIW7RioybFuH6xJnqS0Kg=; b=iREJIzybr3SqgnXcBMiZCj16l5ihRKW4LqMEYkt7zt+uTxUf+es0XtJkFwo6T/zBzP QRi2qffu0dX0cl1rxp89JqZWrHVMvlT+uLsq7bgo6OyzPkAXB3eQj98LKyrlGwlSzUiM 95U1EJzMS4z8vQe03nLcAU0z9BuyMx+B2kqIFs62AluQtEoHnZDDO2yQBnTKWCRBaGSz h0/GR57oaQyA0lXEplP5bW/s5hUBzufjS374qKRZhlo8GLXyUA+YI4UDIfJtbhjbIRaD Uhw9ANOfFPqxetzQN4jEH5u7EoPSY1bxd2+cngQ82xILBo6gfQYd56UVMc2yNNJT+8ag nCHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qsfgcj+c; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si11653225pln.700.2018.01.09.19.49.33; Tue, 09 Jan 2018 19:49:33 -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=@linaro.org header.s=google header.b=Qsfgcj+c; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965217AbeAJDsS (ORCPT + 28 others); Tue, 9 Jan 2018 22:48:18 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35076 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965196AbeAJDsJ (ORCPT ); Tue, 9 Jan 2018 22:48:09 -0500 Received: by mail-pg0-f67.google.com with SMTP id d6so8750710pgv.2 for ; Tue, 09 Jan 2018 19:48:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=yOVDowshOOB3m6GCsZb+K+vIW7RioybFuH6xJnqS0Kg=; b=Qsfgcj+c9tH9G7ml7XFBEvCd83NwFnzFswhmCeR1aoFmpG6kAXRXFCGYfSsJekvoXR a4zU4YWoN/yCavK5Vn/hRo+qQnOCbWDkJnee2JX4/MLmc0xMBNJgSTZHMD+BHw9BV33m 2B091pFFwZsBs+XQpOoHGTMcv/HxmkWcZ/6XQ= 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:in-reply-to:references; bh=yOVDowshOOB3m6GCsZb+K+vIW7RioybFuH6xJnqS0Kg=; b=WLhc6n4SryvaTCSi4v7RK6+A24pjZum9LXBHGONPpHWBhaXjNn8C73Wd+JncIwtwVx yeCJ3OcHvvt/dxvd3LF2JsZ96zpxwQiv2+54mdWjnjr7pc7rsCdr9257EHokGP5FMB1e Tiv497yuKkC6tdvhUDs6o0M9ldpAYhKDA3yvXGYKVOZZx52RrGUUjQHlzqd9ZWp77cV9 PFYUUevsoDlwREisdGBWnOERYM/SLNy5HcTi6FtkjQdUUZtx+z6yzCqYoubSaII5nLac bKFD6d20k2qkg5RHF1DVEUVhM0PnBzJny9h3mF4bCw/tksOeQef+XAyd9cbrEXTm1Oby kx5A== X-Gm-Message-State: AKGB3mKbBeuCK/Hp+ZBGTZHEalz+hwFMGnxHX2o4StoyLiurp6874p0p HZAqdf3wpP+CDTEshm/XD5DzAw== X-Received: by 10.98.80.70 with SMTP id e67mr15396375pfb.93.1515556088588; Tue, 09 Jan 2018 19:48:08 -0800 (PST) Received: from localhost ([122.172.19.39]) by smtp.gmail.com with ESMTPSA id e8sm27182530pgs.44.2018.01.09.19.48.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 19:48:08 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org Subject: [PATCH V6 06/13] boot_constraint: Add support for PM constraints Date: Wed, 10 Jan 2018 09:17:35 +0530 Message-Id: <231bb37457dd0d420116afeabd0b13683410fc09.1515554879.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the PM constraint type. The constraint is set by attaching the power domain for the device, which will also enable the power domain. This guarantees that the power domain doesn't get shut down while being used. We don't need to detach the power domain to remove the constraint as the domain is attached only once, from here or before driver probe. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/boot_constraint/Makefile | 2 +- drivers/boot_constraint/core.c | 4 ++++ drivers/boot_constraint/core.h | 3 +++ drivers/boot_constraint/pm.c | 21 +++++++++++++++++++++ include/linux/boot_constraint.h | 2 ++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 drivers/boot_constraint/pm.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/boot_constraint/Makefile b/drivers/boot_constraint/Makefile index 3424379fd1e4..b7ade1a7afb5 100644 --- a/drivers/boot_constraint/Makefile +++ b/drivers/boot_constraint/Makefile @@ -1,3 +1,3 @@ # Makefile for device boot constraints -obj-y := clk.o core.o supply.o +obj-y := clk.o core.o pm.o supply.o diff --git a/drivers/boot_constraint/core.c b/drivers/boot_constraint/core.c index df9e0bddbfbe..b36c02aa50c5 100644 --- a/drivers/boot_constraint/core.c +++ b/drivers/boot_constraint/core.c @@ -95,6 +95,10 @@ static struct constraint *constraint_allocate(struct constraint_dev *cdev, add = constraint_clk_add; remove = constraint_clk_remove; break; + case DEV_BOOT_CONSTRAINT_PM: + add = constraint_pm_add; + remove = constraint_pm_remove; + break; case DEV_BOOT_CONSTRAINT_SUPPLY: add = constraint_supply_add; remove = constraint_supply_remove; diff --git a/drivers/boot_constraint/core.h b/drivers/boot_constraint/core.h index 720bda0a0f44..c5b27617b4ae 100644 --- a/drivers/boot_constraint/core.h +++ b/drivers/boot_constraint/core.h @@ -32,6 +32,9 @@ struct constraint { int constraint_clk_add(struct constraint *constraint, void *data); void constraint_clk_remove(struct constraint *constraint); +int constraint_pm_add(struct constraint *constraint, void *data); +void constraint_pm_remove(struct constraint *constraint); + int constraint_supply_add(struct constraint *constraint, void *data); void constraint_supply_remove(struct constraint *constraint); diff --git a/drivers/boot_constraint/pm.c b/drivers/boot_constraint/pm.c new file mode 100644 index 000000000000..4950ec6b248b --- /dev/null +++ b/drivers/boot_constraint/pm.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ + +#include + +#include "core.h" + +int constraint_pm_add(struct constraint *constraint, void *data) +{ + struct device *dev = constraint->cdev->dev; + + return dev_pm_domain_attach(dev, true); +} + +void constraint_pm_remove(struct constraint *constraint) +{ + /* Nothing to do for now */ +} diff --git a/include/linux/boot_constraint.h b/include/linux/boot_constraint.h index d798355fd93f..12fac0d565b0 100644 --- a/include/linux/boot_constraint.h +++ b/include/linux/boot_constraint.h @@ -17,10 +17,12 @@ struct device; * enum dev_boot_constraint_type - This defines different boot constraint types. * * @DEV_BOOT_CONSTRAINT_CLK: This represents a clock boot constraint. + * @DEV_BOOT_CONSTRAINT_PM: This represents a power domain boot constraint. * @DEV_BOOT_CONSTRAINT_SUPPLY: This represents a power supply boot constraint. */ enum dev_boot_constraint_type { DEV_BOOT_CONSTRAINT_CLK, + DEV_BOOT_CONSTRAINT_PM, DEV_BOOT_CONSTRAINT_SUPPLY, };