From patchwork Thu Dec 14 15:33:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121982 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6962230qgn; Thu, 14 Dec 2017 07:35:54 -0800 (PST) X-Google-Smtp-Source: ACJfBosagXp98xcLnW+rbKGNtWgaJHBvbPWJJ/ETajd1LgiGfBlz/lUNi0xHN7p44Lx17X5hTwTy X-Received: by 10.99.96.85 with SMTP id u82mr9042345pgb.247.1513265754289; Thu, 14 Dec 2017 07:35:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265754; cv=none; d=google.com; s=arc-20160816; b=hNU8YVsUfa5OdYdMRXzUcjuOPcMYZs2U5L2DFMCGKHQ7LkVRY+K/xGGz+DMga3eEww 1L3wIpcB0l//8GmxJIg1ZfoObXure1ywQh8fbBTgmI4yCnLEMNqFVg7M/bYK8UHx80B+ ojsJb/D07ieIobJ6otn4fx7Ni/ydx6JKCo/4G+hPG6C4q+IevV/qHo2mTu1CcX1Rlz3j WV7nfRvvo69ruS/lxrBRkvUAfcqF2eHOZ/nGWyFya3+MKoNnAZg+8O0Cyffr5SMvAMZX zUmKMaVjYOUxZBGEAwuIw+DBW+3YmHFr1xOVjP4BupTFdSrzuo4TrUPZoz0JTa35qwGF ovrw== 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=tcUcjC5vIfSwTvAkxXMOHN0pj2SMiTHh/pS88zc92oyGJiAsoWUsID2WlolGyETv1I m76PP0Ebgb9GZPR6628Czh77JLc0x066tzy6xqMS/XKPzCM1coWx98S79vumNIUsrmYs AKL3zO+AHTf4Rr7eiLTu0+az5xAzWyX+1Ly4PnXDo7zC70TrTXLAiQ+5x9temksmUB7P fmxi0MGdQh0r1G1xml1N+0vdATLxfAenxBKgrqMdM8Dv8r96c+3luwVVvYqEfj54JyfI lhF/Z1ZMG2n2AukyIc7wi8RByVgN/Eu/jZ9H0ntlR/BsMKtWoeCEwK04+AykXzfu17u8 3RHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S8uTZ7iP; 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 c26si3412776pfh.105.2017.12.14.07.35.54; Thu, 14 Dec 2017 07:35:54 -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=S8uTZ7iP; 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 S1753467AbdLNPeP (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:15 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:40465 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753437AbdLNPeI (ORCPT ); Thu, 14 Dec 2017 10:34:08 -0500 Received: by mail-pf0-f193.google.com with SMTP id v26so3852471pfl.7 for ; Thu, 14 Dec 2017 07:34: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=S8uTZ7iPSAo3vmcNpq1/tT4T8Y7OwMUnPhMSrvD8BFxYgj0SSW72/6bceQh0Yikm/W jR1JCuhYJmiCpzPCkIro4htv6ssQXWpjplGoYbQ71yRCA2p4afqCE6Fgrif0uLxH2Pru LKHQ0tAJRUXWwP9HQdqTcYF6oA5gt5TzL1tUU= 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=O2xQGlezgvbehkrh0pvuUf3skdTSitLfVu+ltUY1YeFFiqAJOE4AwLOPgEhgXIV70t M+K3P5M/cTZFwbnTzZOwgJTCcZG5D7veMZtif2Rj48AA7R86JmD6RKgKyKlyYSYktIIj KBCs5o44DW4IHTZJkFp5N6MkUeuAvHwwYgk5jodzytwnqvqfbk1jxkgajtw96l5qhvdz kzZzDVUF4spcgVYsaiTCdq5WgDhE80Uhip6jaAb+IqG8I1G8eJ4nwS9/2shbvND4c3lx 60jPT50b23/nJYUg/cQg4Jy/bjOhT2A+IcayCUzFH8dXWD6lYODp26uo0xa6MtJVBzqE 0pQg== X-Gm-Message-State: AKGB3mJZ5oDlGA42wv3N+i2Js9BzMqY/i5x5ijlwV71DgNFqnAcqGhj+ YWIlKY/sAR4Ul7SdQt1EQwtCsQ== X-Received: by 10.99.177.8 with SMTP id r8mr8905604pgf.365.1513265648045; Thu, 14 Dec 2017 07:34:08 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id 9sm7687092pge.74.2017.12.14.07.34.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:07 -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 V5 06/13] boot_constraint: Add support for PM constraints Date: Thu, 14 Dec 2017 21:03:13 +0530 Message-Id: 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, };