From patchwork Fri Feb 23 10:23:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10237357 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 28687602DC for ; Fri, 23 Feb 2018 10:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E5392947F for ; Fri, 23 Feb 2018 10:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 003EC29503; Fri, 23 Feb 2018 10:34:37 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 19E4F2947F for ; Fri, 23 Feb 2018 10:34:37 +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=p0NRnbcTnqHEb6IPsMvLYhQRcM4nArtHyu8iXFYhp7U=; b=np9hDTZ8nUX/tRZDb+hJluyYH4 7d5zQLexifZCBv5xH1hn3Q1O9a1YgqbjmL4CozafyLzvdX88j1sUik7v+1Ko/SAxGFZ7AQsVmQRMt YnNzsQwEerCpbkh8J8HE4VRLMfGFAK9YBc0novANqFdNFdeBn4/KGElufjgp3udOCSPugantfQS/Q 9xHwYz9jpOxgdLdSV3tj1CYVVN5hxMPMPAL6ign5G0oZMF/rTGSdIVEtrkZD415Gfiamb2idfzpFK QVxgqr8GPEzhvXlRl6qPnP88C4GgbmWTCJZSivn8Ecg/i8rtQcaL3pWSZj+1oPla4KAK1Geyq8zIZ kV/MOZnQ==; 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 1epAgN-0005Gt-CH; Fri, 23 Feb 2018 10:34:27 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1epAd6-0003JE-RO for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Feb 2018 10:31:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=yo/HwvWl5x7NgUYRRWuyvg7loN2thKGDdEcTTRAFKr0=; b=oXfqtjYBnJqjUdLdwQqgVN3t8 9a8ZH0iHcQKn0axXfWu0pEicmEEvy/v1e4fV/kddGfcInhx+qrIsQYLk26Tl8pcNrvmsfQWQHikV5 wGlNv98y2vCbYzoICV36SkLEMcMPmvM3Z2jFq32wdEo5iUIutI1JP2qKTenCsVu1z5rub4voZcESb jaL3qij8kOQNs+Aa11hCSgK9Z6vucrYkfDlHKmiw9kShboJ4991teqWz6LEmTjcmTnxjHynC3mEWE 0MZFH1rI8SzXHBYVXCzQJ1i7ERybgx99liXc5ADpEpF8sj6kAPBi3VeHqAG2FqEQqhGzGVuPcx/DH 5AFIfOBPA==; Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1epAWm-00060T-El for linux-arm-kernel@lists.infradead.org; Fri, 23 Feb 2018 10:24:34 +0000 Received: by mail-pl0-x244.google.com with SMTP id d4so4664687pll.5 for ; Fri, 23 Feb 2018 02:24:22 -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=yo/HwvWl5x7NgUYRRWuyvg7loN2thKGDdEcTTRAFKr0=; b=aFz0SBqc+gRhrVGUBICm8ttFtuifquZfT2oDiYL4TtVjfojhQIjv4Uo2gJ4HHlMqPJ 3AqWJtl90uxhQnxWEDH+LQNMkldqylR1crVKYBVehl6tZq3F99CIi0Mks22Gqb/dfkSm AiVc8uh1LaFfhAPsYXlEIM5EzqAybLKOIE7Ew= 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=yo/HwvWl5x7NgUYRRWuyvg7loN2thKGDdEcTTRAFKr0=; b=j7Ftw3SvbkTc/fzbnkPzBBnt5BqjHWiDxhdVAgmrlDoU7NSSJX+I/kZ/5JzcU4xu8s sJhzLr0PXm2qJpSQ1xUu+6wWBYI+rC7PvJEM1OX0uE6hJ6tW2ozz3jHccjSCXfrlBwiH mRuXBK0sTaGJxo2O/iceiyjltOYEJ6ZguIBnig8vrz12NaigJXqvnFm2zgKisvvOtt1c wwl5CxQj1WnT8nohJLZbEw9/3XRG+RnzKGpNkLnPhRuvrAxo7TR2weQ7FHMz3fEt3stL UrOOBazyhBdM+xCCRVTask0O62YXqTIpGmLvUQjssgn0P54XwdD9Dh6X3CDLmVnnByBG 2biA== X-Gm-Message-State: APf1xPBxkGikf+dBhVNQQo0D/kp4xWiTEHnKYsQ5K1TVvx0V9RMIZUp2 K4Bu8Ab/XcV48yQQ4woI9tcRrQ== X-Google-Smtp-Source: AH8x226JR6zIuaelvROOpm054lv614QMp7U0d5/fpKEDl29W6iCDHrGySS3cqWJQwTsiAvt4yCynUg== X-Received: by 2002:a17:902:2823:: with SMTP id e32-v6mr1285128plb.44.1519381460853; Fri, 23 Feb 2018 02:24:20 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id r29sm4449111pfj.99.2018.02.23.02.24.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:20 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Subject: [PATCH V7 06/13] boot_constraint: Add support for PM constraints Date: Fri, 23 Feb 2018 15:53:45 +0530 Message-Id: <9802d5501b0f22cc14e2043797ab995f7640b3c0.1519380923.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-20180223_102432_480873_E456063E X-CRM114-Status: GOOD ( 22.78 ) 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 , Stephen Boyd , Viresh Kumar , s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, xuwei5@hisilicon.com, olof@lixom.net, 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/bootconstraint/Makefile | 2 +- drivers/bootconstraint/core.c | 4 ++++ drivers/bootconstraint/core.h | 3 +++ drivers/bootconstraint/pm.c | 21 +++++++++++++++++++++ include/linux/boot_constraint.h | 2 ++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 drivers/bootconstraint/pm.c diff --git a/drivers/bootconstraint/Makefile b/drivers/bootconstraint/Makefile index 3424379fd1e4..b7ade1a7afb5 100644 --- a/drivers/bootconstraint/Makefile +++ b/drivers/bootconstraint/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/bootconstraint/core.c b/drivers/bootconstraint/core.c index a73744c5d599..a6148b625b48 100644 --- a/drivers/bootconstraint/core.c +++ b/drivers/bootconstraint/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/bootconstraint/core.h b/drivers/bootconstraint/core.h index 09a6176541d7..35ea984d74f0 100644 --- a/drivers/bootconstraint/core.h +++ b/drivers/bootconstraint/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/bootconstraint/pm.c b/drivers/bootconstraint/pm.c new file mode 100644 index 000000000000..f52bff240dd5 --- /dev/null +++ b/drivers/bootconstraint/pm.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 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 4685ff55fff8..fbccb62f423d 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, };