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: 10153877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CDC7F602D8 for ; Wed, 10 Jan 2018 03:49:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA9E5274D1 for ; Wed, 10 Jan 2018 03:49:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF38927813; Wed, 10 Jan 2018 03:49:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3AE32274D1 for ; Wed, 10 Jan 2018 03:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=mDpSZJuDYOuZMLFkYi5cARTjvNqT7wO6H1tNnxa+83I=; b=OAgnqVTHJ9O2pi07Tg7X1Cy8k4 s5zn77UVKlpdzn7FxD7sm+pgV0InLOdgV9CGYoRdp83h9dgNuQd2fAOtP5QLmGfq0Jl8aL/p2dwZw +hPPZQ6buMrlqn8aRvxXeqNd4e/H/DlPQRvWauBD25SEYBHyU2LYHYzs+E3jDGtKFSw0D8f3vEOhY pgAfCOhY7J0x8JettSHYjQmxzlF6ie4h8hXw75XQPmCTUf+Fs7jv0PMyzjzVSn0ryKVVYyhJxXbeT imSWcWnYMDIatsL6h7Iq2vv2ZbcBtmna1CUrqic2m03EV+JsHKI14wi5PwvgUHSDQAcmbrwWTQFek f/lLdZHA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZ7OE-0003ZT-Qw; Wed, 10 Jan 2018 03:49:22 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZ7ND-000292-6y for linux-arm-kernel@lists.infradead.org; Wed, 10 Jan 2018 03:48:29 +0000 Received: by mail-pg0-x243.google.com with SMTP id t67so9804251pgc.5 for ; Tue, 09 Jan 2018 19:48:09 -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=t9GKd+1wFRiUHo4q+E9tCpAWhLrPvBNiEu1/PRBsGP7C6vEbQ/aBufPrI6Irf2oj6U lroTU2Go95DNxCfMZAD+LlbE6UVBDiNi/w7rkHjHztyo26ZaqnF9qNUsrMunwlyCApYC iOZ5F+Mc4WbMSF8qpIc29FpEb2UmwQdQHTTxS48bsxGvK0UykRtNCUaLov99K2zIhTNu ojP4I0H5z8iANYu9gGWurDhavO2VQSsTQPzsgaVRmzUQ5ALfOcLBZe22XV4BJRuMqzj+ d2PREj3onszYgztcgySVqNDDGV/Opdb3MTFlI1ruZ61WWg6BMtm0iz5BboZaqF5Al5Ty fnNg== X-Gm-Message-State: AKGB3mJQVVRie/GPUDwYDn62OPSaZmeKrC6Vfs2HzygdTECkOnEJVW6I RHOHruDFHJOGkpP9cyw0zSBAow== X-Google-Smtp-Source: ACJfBotrK3kSGAV2aOSt3hO/aQJLtrredHa6sAf87J1TegOyKCiVG4HPaQA0iT9dfocOpjZDclXG/A== 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 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180109_194819_840443_D311AADF X-CRM114-Status: GOOD ( 17.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nm@ti.com, Rajendra Nayak , Viresh Kumar , s.hauer@pengutronix.de, Stephen Boyd , linux-kernel@vger.kernel.org, xuwei5@hisilicon.com, robdclark@gmail.com, robh+dt@kernel.org, fabio.estevam@nxp.com, Vincent Guittot , shawnguo@kernel.org, linux-arm-kernel@lists.infradead.org, l.stach@pengutronix.de MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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, };