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: 10112539 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 BB1D76019C for ; Thu, 14 Dec 2017 15:37:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC29729172 for ; Thu, 14 Dec 2017 15:37:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0FF02935F; Thu, 14 Dec 2017 15:37:02 +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=unavailable 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 9AB6C29172 for ; Thu, 14 Dec 2017 15:37:01 +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=GqkbuTG+ACdmRGpBpBP6M/J5R4 RGSiUPmviUNTjbyq8Bm8QED+31n4eS6n2nsMU1AzGO4X4LGsO/1uP7WDn/RuW0bamA80dtHoFUTFa plSY/N6a5BRAK0RC7+ZIYDnSBsEgLzCxEpvTrCnVu7/2hu+gzxrxzy7tnewYzGMdx1/WF+K8cFa7n k88pqYOCXWIpkKcquNIFbU1SwPhvnRopLRBoqHsg1nR2NxunebZDw/rHkZ21S4oXOE7VJZ+HQPUln LYMTz0etIZqFRYIggRqDJBD06DXr4Zsa+djthxQUh1ydWmZsrpx/xrGthfw5AYI7v1L4oR7rJq7Yd AnO8T6Mw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ePVZE-0007Kx-VL; Thu, 14 Dec 2017 15:37:01 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ePVWm-0003iC-RJ for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2017 15:34:36 +0000 Received: by mail-pf0-x242.google.com with SMTP id j124so3858182pfc.2 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=o6w4EO0SrmC2FJruV2VV9xIFREEutYs39Vg9Iowu9S2O9eqjljhKamqKsH41+fnDDo ZVlQrmGFxGZ/DoGdHL/HC7XKXoC6+KaqES4ZC1P67TXcFF6LwsMmrYo2WvHfx9lWLfvn /6uWrVDMIM/6pw/XFeLK9LU4GekveKLbHZON8xumIOGgGjDlkg9ZasDqXfi+43cnakhS wVi1j/hW9/Fl+7hSqU0pysB57M5YbNKGd6Df8pPEMf/cpZgBTkhMmM08luPZtIELkaGg TuOhSAKXUZrgr3YmE0Q/xrMGwnqFV4GdNkrTODa4TkKimYJhL7NT01Ev+pS8nTIhciPu U1Tg== X-Gm-Message-State: AKGB3mIS7fSoB+7dV6J+5wMEy3lGDNo2oYt9IX52yAve2DcDlzWf7pyY r70BRgxEmCky3GQSDF91JzmZ/w== X-Google-Smtp-Source: ACJfBouDvKJiyQk4UvGNw7mnQ0d//fc7L5yGx474GOlmrNZK/2HM2TqVZ/V6qVWyMpT1aMaDTmBNsw== 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 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171214_073429_626919_D246C895 X-CRM114-Status: GOOD ( 16.81 ) 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, };