From patchwork Tue Aug 1 09:23:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 109123 Delivered-To: patch@linaro.org Received: by 10.140.101.6 with SMTP id t6csp1267248qge; Tue, 1 Aug 2017 02:29:14 -0700 (PDT) X-Received: by 10.84.137.169 with SMTP id 38mr20047525pln.331.1501579754484; Tue, 01 Aug 2017 02:29:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501579754; cv=none; d=google.com; s=arc-20160816; b=tQVmo0wqwFPjSOaf5YeQtppXOEaT4Q14QsgkFngbNJmBWkORw9NVovdtPpKlW9Y61Q H4i3xPZhYdfDc4rPMwBC4CvgvYOrtiGf8fJnjIPLgLpwaYL8qzpXJybqaU7V4Af1gMP0 9oP/w8fs/SmVWmZ0QVS09f0eeVdMBQtS77ZoF2c1xakk9Oi5tQIifaSQ4UXB4fADNd0x Er2/VtSpOMPErcNgsbe1akr2gKkbPdIssqDHkCPbdkjZe3ySJ50kCuwg/6nspJB8Zqqj fYuaOpiXJYtKCt+0LKBZ5iRQz2PTEqcFJgrRwfFKkmKvff6qn68aiRCHRPMOIxpFBlDD GvHg== 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=Mqqdzezdl5DkbZhvHySyzv7MgeW/7FaWvioq1S2dX80=; b=dos1o4wvpgUHLjQyxVKbkZyrBtRBiXJpg25hERMhhBOWk+N8Wfc7LNPFcmEXv8wubx EZ0Off6eALJBL19aH/Y9UbbIn8r4MrO0KF0cBj7bVkJNG5l/vlDpq/MkcF/NDX5mjIcs qN36U9+wYvo9uNulHGqEnW8cQ7/m4hd/HpU7VqDSrGZzI3s7x5V51FmKZR7NAXa8mW/k /R0k3mQwLa1R8YI+2HXSWMUuXUwicGR/UyQqpL5ZG2WFftxW138Qf3iMzFp1Enwk1Jsg 3i0zRCvYiswM3lhK8uJ7vdO8515tAxlU+gwq2FhDSN0eSxC7e/6PXRuJnYVAp2zP8MW5 WN7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=kDcKwmcZ; 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 m23si17071326plk.953.2017.08.01.02.29.13; Tue, 01 Aug 2017 02:29:14 -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.b=kDcKwmcZ; 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 S1751923AbdHAJ3K (ORCPT + 26 others); Tue, 1 Aug 2017 05:29:10 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:37315 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751804AbdHAJ3D (ORCPT ); Tue, 1 Aug 2017 05:29:03 -0400 Received: by mail-pg0-f49.google.com with SMTP id y129so5688995pgy.4 for ; Tue, 01 Aug 2017 02:29:03 -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=Mqqdzezdl5DkbZhvHySyzv7MgeW/7FaWvioq1S2dX80=; b=kDcKwmcZMyACBTHZ+ebar8USfVgf3XFAGZVBFgxTHPPqGG6t0O4TJbeqf6lTaJozIw X0DcRJxzbos9Nwj632jhIMaLbxq887oHOLw7h6Px8IcMR01eYW/+xU9alB6fZkpW5zRE ouWC0UpB7iSlQeFJrnifonVgJzvoCqhuIlb/4= 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=Mqqdzezdl5DkbZhvHySyzv7MgeW/7FaWvioq1S2dX80=; b=e04TD141CnWrtDiIKIt2XmLNGjVBFj5CoFX4dsH9zvGe/0GdGuGWmU65dSMLMxp0ay J/Frpumcw21E9xzBv2X0n/2sGCnBSfUOSCN12sDxPgxI82XA/lTozg3amAdZG/BrxR68 YBgQm+37sU7jg5iXdh20cu5Tf3RJ2peP5AgOUkpdBbXyNc2Zhi4rrxc7W9LAEYDuTwQG vKZdQ2bs15Zfg8TFnigryL+otszRenFdcFkwXZfKdJJf97MtbC9QxoAct0Rz/yGfWa9a fLw6F2muxYw3owxsp08JWuT0JYvUzXyVyUhbNK6wHXoHHLW4Z1OXmAE77dJuY0AiyV4t HpeQ== X-Gm-Message-State: AIVw1117E39ZzxZ7aW40IahnmPjjlIjRQGWRIfufLVBlLHlEe3tBUFKH 6yHe9kRtvoQcca2B X-Received: by 10.98.40.7 with SMTP id o7mr18261631pfo.124.1501579743419; Tue, 01 Aug 2017 02:29:03 -0700 (PDT) Received: from localhost ([122.172.27.66]) by smtp.gmail.com with ESMTPSA id e198sm13107539pfh.36.2017.08.01.02.29.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Aug 2017 02:29:02 -0700 (PDT) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Mark Brown , Stephen Boyd , Rajendra Nayak , Shiraz Hashim , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com Subject: [PATCH V3 5/8] drivers: boot_constraint: Add support for PM constraints Date: Tue, 1 Aug 2017 14:53:46 +0530 Message-Id: X-Mailer: git-send-email 2.13.0.71.gd7076ec9c9cb 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/base/boot_constraints/Makefile | 2 +- drivers/base/boot_constraints/core.c | 4 ++++ drivers/base/boot_constraints/core.h | 3 +++ drivers/base/boot_constraints/pm.c | 24 ++++++++++++++++++++++++ include/linux/boot_constraint.h | 1 + 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 drivers/base/boot_constraints/pm.c -- 2.13.0.71.gd7076ec9c9cb diff --git a/drivers/base/boot_constraints/Makefile b/drivers/base/boot_constraints/Makefile index 3424379fd1e4..b7ade1a7afb5 100644 --- a/drivers/base/boot_constraints/Makefile +++ b/drivers/base/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/base/boot_constraints/core.c b/drivers/base/boot_constraints/core.c index 88568ed1bfad..06267f0c88d4 100644 --- a/drivers/base/boot_constraints/core.c +++ b/drivers/base/boot_constraints/core.c @@ -109,6 +109,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/base/boot_constraints/core.h b/drivers/base/boot_constraints/core.h index 4f28ac2ef691..a051c3d7c8ab 100644 --- a/drivers/base/boot_constraints/core.h +++ b/drivers/base/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/base/boot_constraints/pm.c b/drivers/base/boot_constraints/pm.c new file mode 100644 index 000000000000..edba5eca5093 --- /dev/null +++ b/drivers/base/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 a2696002e6e1..edc9abe7913a 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, };