Received: by 10.223.185.116 with SMTP id b49csp518468wrg; Fri, 23 Feb 2018 02:28:10 -0800 (PST) X-Google-Smtp-Source: AH8x227T8fiD+g5gnBxUqqseOBeRtDx2SJDPnbOc6Qebv0H2IburCkdvlNre2VLMm8jpkj5m52W8 X-Received: by 10.99.103.195 with SMTP id b186mr1068187pgc.446.1519381690876; Fri, 23 Feb 2018 02:28:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381690; cv=none; d=google.com; s=arc-20160816; b=MEEFSDA+YGjzBNZi0JaMzTfROX42d/HYKDUgPCUU3tEHbozW5D4+lqdpkm3+omtwsw 2NJF11IZ3JyO3dN2n4N6kh8Ish/WJCQopIAR02hJoX0NREKmMIE9APmYhVE2xiRSDU6q Mx4HxaCvxJDJp2616n2xUb/ZK/MpZypIbsFhSZzNXwydHog2YiONn7YiWR3uA/QuEag0 lrkZP4+k8MYKhkMIiEO/nUZLC0bSQKND8EsKyf/+YPhudBPjB1eDzCgqJKCncQEmM27i xZvgyGdhiN80ojq+IDM7aEMMjcSe8oqtQQKlsdEn1YQKC/bt1pDCm3RvKJiUQRjKfHKq RXzg== 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=yo/HwvWl5x7NgUYRRWuyvg7loN2thKGDdEcTTRAFKr0=; b=pRywea09/mo/3+sqET5EfaGAxaaY6EL6jDQOi0iUyX7EW+3HqNwjjoXlF6dQK+jbPv md47Y7TgPkKUUIUdDRRizYreGs3yFrSZ+/FvJXZFCu4zg9wrmFrExHtI6DdMqK7gFJyW wZKeyfZTUzn1TwW51zE1qlmKhpvNxXYqMSNwS4/KuKx7WCiS+EexqKK58e/XfVRsK5nP zh+u3KxroOT9z/WAkAIH5SjU66rY6KsvyKeeUsn6+AgDdkpjUGlhQHqT+r0yh9HTRnll z7b0BVKXZ/n+QYf74wtr/65Ui1C0TxHnFZiFzaU9BJSsv3uryKRvV46+RUlK4pviGyIv d3Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aFz0SBqc; 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 p9-v6si1598091plr.622.2018.02.23.02.27.53; Fri, 23 Feb 2018 02:28:10 -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=aFz0SBqc; 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 S1751611AbeBWKYX (ORCPT + 99 others); Fri, 23 Feb 2018 05:24:23 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:42162 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbeBWKYV (ORCPT ); Fri, 23 Feb 2018 05:24:21 -0500 Received: by mail-pl0-f66.google.com with SMTP id 31so4654000ple.9 for ; Fri, 23 Feb 2018 02:24:21 -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=tdciQARMc0db7QsmykueN/YHXRQPnqtLDtVpk1ztaq0Q7ELiuOiD/CeAT3G6YD8cpq /2sveKCQhTrQMvyRUgQqqO63VPT0DH3ex6X3ecG8h8uG6iHetPc5xW5gUjEe0vQcZD5a jDIUDbYaY4xe8f5bR8ZMLe3a8aCJFA5cB16GTVfkUUb5ab5hQRjP6AIc64zevUyT16JO iE2eoI0ulY5CDCeBR6SXCLzly9j8XmCvGa+YahZ9vaAnMVS8hOA38zICrBGf5mnDsSYl a1s9Ge6UUaYIpR1a04VpIBNrNVWQTV2dsDQSSNTtVM8ff4T6r1P0Sf66N0cXnNVqrgdT vczQ== X-Gm-Message-State: APf1xPCGWTV19EYVRDHDx1xE/VH92qCKasRSMMJneStAkFch+ZSdjhLd mBD2M8yvk/mk0eXakZZT0+B0IA== 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 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, olof@lixom.net 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: 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/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, }; -- 2.15.0.194.g9af6a3dea062