From patchwork Sun Oct 29 13:48:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 117408 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1527459qgn; Sun, 29 Oct 2017 06:49:39 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Tp/7rHsoE/Iur22KcOHH3PmQE11qG1eO2Mlwtarhsb4H+VIg6h++M9Z3n4a/wi7ZUSrWTx X-Received: by 10.101.82.129 with SMTP id y1mr5273029pgp.137.1509284979088; Sun, 29 Oct 2017 06:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509284979; cv=none; d=google.com; s=arc-20160816; b=pPlHXRBHUJC56Pp/tGBT1s5t4UHIzngNskMKB5ngHwPxKeMuRyHHUxTsTZVmCtsc5W +hN8dN+EpgJkYTyW8muApw/QfilUdJg0oDl+FzyoTjJlvlJX5lcqMv6yblkpdI80VFDt MX0PB9sFYbr9qXuuF0dPd/6tz6tcPH1LjGzIyCQCAwSJvZaPzx3GjOEC6k2dS4snQ022 GIH9xDIE5ckL0obdbGrB3ff4kl44ihR0YK2bVSoLbM+/nntpk1B47vJT1JgnRst9yA0s OgeEmoFlM691hZFwNWrlfnkPGv/kFL6S++zu9chiZ+1LVqUVic4GKMte5hIIedDe6cqd nbPw== 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=D0ETMoWJcqfm/lXQtf6mkIrcvhuj3IBvyUBKm+r1MeE=; b=QOF8d9fgBgaOhCte4pR+ufejYE6FG+xtHyThgZ2VhALv6CXJD4Ox/OKvXm5fVsGy+a eCxrVqSJS3SQ8x9M+25dFrLi2q0k7A1WQvqP8BeHzyuPfc7XnJKdNYfmr9BNmKdSGDZT ZTMy5jZgz4e6319IA8w5i56ugPLV9bt3unVXncyKV5dflWhVaVx0foWuW6RReYL5QnRH uGCMeqKKX8jl9+pIar/OkuoXwKFaSb7HTArLnMhqmFzee1m6ZKpBYlapcH8TWPI5IA3G 6u56Mq7H5T917qLJ3Qp/c6A7Uj2nAMNX31DsXqFsatfEsHjP7XnSFpUn1qZXHGoMbWos KaFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=axZEWr3l; 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 j6si8653501pfh.329.2017.10.29.06.49.38; Sun, 29 Oct 2017 06:49:39 -0700 (PDT) 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=axZEWr3l; 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 S1751802AbdJ2Nta (ORCPT + 27 others); Sun, 29 Oct 2017 09:49:30 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:55600 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751676AbdJ2Nt1 (ORCPT ); Sun, 29 Oct 2017 09:49:27 -0400 Received: by mail-pf0-f193.google.com with SMTP id 17so8652237pfn.12 for ; Sun, 29 Oct 2017 06:49:26 -0700 (PDT) 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=D0ETMoWJcqfm/lXQtf6mkIrcvhuj3IBvyUBKm+r1MeE=; b=axZEWr3lB7/Qzy8OjJu69vP4Lrgmf0hZrHbzSX3FLMw2Fy2EVxHvLnK0zag3sc5uJy Jof4hxsoSShH1koIzH5TejLar++mfxCRitVvI1SRUAfMsxgohNvFfdqQjXUYWfAp+C9b +5BRwMaBT98d/a8vLeHRkRpSg2JdZv2kAYwMs= 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=D0ETMoWJcqfm/lXQtf6mkIrcvhuj3IBvyUBKm+r1MeE=; b=BqACeWa69vaIQ9oLAJX+v9v9CFP6ITn3W8as4cu9fVRPfyuRxp3RluV7qvxKhoZEw8 qmThWvF1vr3G9OfNY74fXJ+1gJVC9z7mfIMsgjn2DEhbo+i+vjzG8WgsE7AM60zcNNnM JF78I3b94X3gX0eblrsIrgWthkhoN6x9prgWgfDdVaZdQaiWZOSrmVFOMJvsoQYVpaqp rB73VKKsdHyfgw8Hd9I+b7veMDsVh9d+7Ny1WV10NXshFFqaFCo/rSBrPHSfEtDb9lOe KYGdhUMLfpagj3SzKhQvPMdKTjEcDH94UvlFLNalIpLRjzjjiNS7LkZRvfzlrbQUYRf2 9dUw== X-Gm-Message-State: AMCzsaXrn9+v6jKrEfkCRRaAc5F3kIygmxozyycczFz5TQDNF9W3aMLX iz+Ko11T2A1UCcSbOwM4gbgEyQ== X-Received: by 10.98.189.23 with SMTP id a23mr5949965pff.124.1509284966442; Sun, 29 Oct 2017 06:49:26 -0700 (PDT) Received: from localhost ([122.167.161.211]) by smtp.gmail.com with ESMTPSA id w5sm23161628pfw.51.2017.10.29.06.49.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 29 Oct 2017 06:49:25 -0700 (PDT) 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 V4 06/12] boot_constraint: Add support for PM constraints Date: Sun, 29 Oct 2017 19:18:54 +0530 Message-Id: <000268f9c5b06354333a18dbe26fc8b052231ed8.1509284255.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.rc1.236.g92ea95045093 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_constraints/Makefile | 2 +- drivers/boot_constraints/core.c | 4 ++++ drivers/boot_constraints/core.h | 3 +++ drivers/boot_constraints/pm.c | 24 ++++++++++++++++++++++++ include/linux/boot_constraint.h | 1 + 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 drivers/boot_constraints/pm.c -- 2.15.0.rc1.236.g92ea95045093 diff --git a/drivers/boot_constraints/Makefile b/drivers/boot_constraints/Makefile index 3424379fd1e4..b7ade1a7afb5 100644 --- a/drivers/boot_constraints/Makefile +++ b/drivers/boot_constraints/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_constraints/core.c b/drivers/boot_constraints/core.c index 9213e56e8078..f4d3520ddb04 100644 --- a/drivers/boot_constraints/core.c +++ b/drivers/boot_constraints/core.c @@ -98,6 +98,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_constraints/core.h b/drivers/boot_constraints/core.h index 4f28ac2ef691..a051c3d7c8ab 100644 --- a/drivers/boot_constraints/core.h +++ b/drivers/boot_constraints/core.h @@ -33,6 +33,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_constraints/pm.c b/drivers/boot_constraints/pm.c new file mode 100644 index 000000000000..edba5eca5093 --- /dev/null +++ b/drivers/boot_constraints/pm.c @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2017 Linaro. + * Viresh Kumar + * + * This file is released under the GPLv2. + */ + +#define pr_fmt(fmt) "PM Boot Constraints: " fmt + +#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 a74b261a4ee4..637fe9d65536 100644 --- a/include/linux/boot_constraint.h +++ b/include/linux/boot_constraint.h @@ -16,6 +16,7 @@ struct device; enum dev_boot_constraint_type { DEV_BOOT_CONSTRAINT_CLK, + DEV_BOOT_CONSTRAINT_PM, DEV_BOOT_CONSTRAINT_SUPPLY, };