From patchwork Thu Dec 14 15:33:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121973 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6960010qgn; Thu, 14 Dec 2017 07:34:04 -0800 (PST) X-Google-Smtp-Source: ACJfBotJ3hFxRZhzEJk+qeeig4ZvnfArhaaRIIXNIIg+FYpxt396eCCPiCESuySdKNVsb4BZ/86+ X-Received: by 10.98.163.73 with SMTP id s70mr9875391pfe.64.1513265644740; Thu, 14 Dec 2017 07:34:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265644; cv=none; d=google.com; s=arc-20160816; b=w813ZhDXdfc373h+CFCqFQSDe6+rv7sLmX+5AC360Ce3aQTKwKCPffHeBvWRzgimp/ H7YzwTebxsRcMGhsodAJDljeWsLO9czBqj1j6/AMk4ZRw3F4fcxc1YmTT+xomXAqVJsX 5zqYqghsNwb9IDI18XN0Ep6TtqVnM03uOAzp4jrNHRwsKWQq4ipKUkFvwI6u38DcfFwO 5PZeDIQlhHG16x29/ooZnqqp4zPX/xa7xQR/FwrEaPfEogF3NVTo6wFdk1dXWcqflL96 dKUxh9cNVByqvUgZkvCs+LpWweDHlWx9M/KiZ2KcSztGBk/WFhSWgluhA007DO5Z6mgi j3mg== 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=JvF1dk+O7f0i+Fy6jVvZS+EaoWZtI51KnXjLkfkaMqQ=; b=L2jvAGAsv9XxhKmrq+BC5liNBLzdIHYfWNO3NCY5kpzgjhU9Vr5v2nxuG9G7j2SAAU ePoZRo9qhVXHxuEqZYAjmudGaekRQCINifnjIZCY4bCxTtUQc7f3e2ua3qCHkhJRSA0h ZbThydonzI3wKCJtKOat/9KzC46Fqd2zIw66ygWz6Od5w8aU5o/ANjMS8hjN0MZmKAFt k+OPuv1SL0/9YyzTQPQrauG0OQoN9gRL7BQNeGom1rNVxY0ZPtvPdo5bvq7RAaYVWt/o 7X2bQ8RFZvGoHvTPpjAf8elslzK/3+lX6Sqo5s644TZqk25LUtzNSrq76lLANH/jb2+B BWkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cYdJ9iaR; 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 q12si3358439pls.475.2017.12.14.07.34.04; Thu, 14 Dec 2017 07:34:04 -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=cYdJ9iaR; 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 S1753325AbdLNPd6 (ORCPT + 19 others); Thu, 14 Dec 2017 10:33:58 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:45069 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbdLNPdy (ORCPT ); Thu, 14 Dec 2017 10:33:54 -0500 Received: by mail-pg0-f66.google.com with SMTP id m25so3615147pgv.12 for ; Thu, 14 Dec 2017 07:33:53 -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=JvF1dk+O7f0i+Fy6jVvZS+EaoWZtI51KnXjLkfkaMqQ=; b=cYdJ9iaR7RB/2eh2ysuLTqt6mI8pRef5ilpcS+/OGV7qaWUZIw/NSF4z3dxvnp7prh vFEVJHAApLYR20XT886s98bX+wjgNTnvlVakyfhkSqVsCWvg9VMDVxVa09N59A+YxPIS D0jbvh+SZsa6NKLPA4uJ0Al/mbZwaJuBdkh3Q= 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=JvF1dk+O7f0i+Fy6jVvZS+EaoWZtI51KnXjLkfkaMqQ=; b=DIbcMXSjLgnOcpwZM1JLAQyBhOnHFpvCudZg6kqWKr/jxjoGykiiq6RwOrmDoA+vUd SGevh0V1DgtvbkqSPS+XPCNZ9fTcREiE5UVtlQ37hVV5mYNOiUzvueo4P02rbfMVK3SG 6OeBP2duv2PsDCeMmVqxGYcatCQWlh8Ulql6D5FazGlE56EgqmSFMBPZDUThb/HPoe6B KomSvbOO0t8LZ7XCOVLprN/qHufHYj7+lBc0TKeX71J1VTgDFoyVblxTabZEOjwgw6Yd Jdh8ZLTH/R0Jd3wTidsluscGnvDFu5mCxHeAEAoyMHB4u0emkLz0RE179PPv3Qb+Z4ab C8aQ== X-Gm-Message-State: AKGB3mLGTdxErtZuqcVW/rI0hCptQBn/eE/6z/MIMw7LfqEK0sJmXl/s RG8mITkC6fQD8exAg17ICA2kfg== X-Received: by 10.99.109.5 with SMTP id i5mr8631028pgc.359.1513265633370; Thu, 14 Dec 2017 07:33:53 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id r90sm8676848pfj.148.2017.12.14.07.33.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:33:52 -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 Subject: [PATCH V5 01/13] of: platform: Add of_find_any_device_by_node() Date: Thu, 14 Dec 2017 21:03:08 +0530 Message-Id: <6dbdbc0e5fa8ca4722e9d3b1a92a6f9e008066e2.1513264961.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 creates a new helper that returns the struct device corresponding to a struct device_node. This currently works only for amba and platform devices, but can be easily extended to include other bus types. This also creates an internal of_find_amba_device_by_node() helper, which isn't exported as of now. Signed-off-by: Viresh Kumar --- drivers/of/platform.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_platform.h | 5 +++++ 2 files changed, 60 insertions(+) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b7cf84b29737..61a4a81bea9f 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -60,6 +60,61 @@ struct platform_device *of_find_device_by_node(struct device_node *np) } EXPORT_SYMBOL(of_find_device_by_node); +#ifdef CONFIG_ARM_AMBA +/** + * of_find_amba_device_by_node - Find the amba_device associated with a node + * @np: Pointer to device tree node + * + * Takes a reference to the embedded struct device which needs to be dropped + * after use. + * + * Returns amba_device pointer, or NULL if not found + */ +static struct amba_device *of_find_amba_device_by_node(struct device_node *np) +{ + struct device *dev; + + dev = bus_find_device(&amba_bustype, NULL, np, of_dev_node_match); + return dev ? to_amba_device(dev) : NULL; +} +#else +static inline struct amba_device *of_find_amba_device_by_node(struct device_node *np) +{ + return NULL; +} +#endif + +/** + * of_find_any_device_by_node - Find the struct device associated with a node + * @np: Pointer to device tree node + * + * Takes a reference to the embedded struct device which needs to be dropped + * after use. + * + * This currently supports only AMBA and platform devices. + * + * Returns struct device pointer, or NULL if not found + */ +struct device *of_find_any_device_by_node(struct device_node *np) +{ + struct device *dev = NULL; + + if (of_device_is_compatible(np, "arm,primecell")) { + struct amba_device *adev = of_find_amba_device_by_node(np); + + if (adev) + dev = &adev->dev; + } else { + struct platform_device *pdev = of_find_device_by_node(np); + + if (pdev) + dev = &pdev->dev; + } + + return dev; +} +EXPORT_SYMBOL(of_find_any_device_by_node); + #ifdef CONFIG_OF_ADDRESS /* * The following routines scan a subtree and registers a device for diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index fb908e598348..4909d1aa47ec 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -59,11 +59,16 @@ extern struct platform_device *of_device_alloc(struct device_node *np, struct device *parent); #ifdef CONFIG_OF extern struct platform_device *of_find_device_by_node(struct device_node *np); +extern struct device *of_find_any_device_by_node(struct device_node *np); #else static inline struct platform_device *of_find_device_by_node(struct device_node *np) { return NULL; } +static inline struct device *of_find_any_device_by_node(struct device_node *np) +{ + return NULL; +} #endif /* Platform devices and busses creation */ From patchwork Thu Dec 14 15:33:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121985 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6964292qgn; Thu, 14 Dec 2017 07:37:28 -0800 (PST) X-Google-Smtp-Source: ACJfBotojkgXWYgCbXuiLVd6k54i7bFyweUmwzZ2/Ry5NMLU6B0LpNJKrBMLKEnxbkSVWxSymjnm X-Received: by 10.101.101.12 with SMTP id x12mr8927401pgv.420.1513265848757; Thu, 14 Dec 2017 07:37:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265848; cv=none; d=google.com; s=arc-20160816; b=gLxMPSdunL46jn9DwjuOQKAVBVw93u6LAVzR1AR/GCiUIQy48vCEiPvrPCqRuuedxH ksRRnwPJg0ahlsC8mJbxHYx1Z5SJO2QYTP4mQnqRvAVdaPKw7dLtNE77Nk4XueVQOS+y 68JMzI7LW01QXXDtD8Y6DdCG4n8z65zYYqmz2dl9fZlu7tzlc+uSES/DaFqCGH79Z7BL dj8q7X98XOthJ73Rx6UDUv3xF83BTRzg4UZ4WD35jd/oMbPQ11B2O/CakHYyGD7GL8Vi OzzgbSxxG6mHe2B+2Nz/xMk+IWKiuhIl70aFmAojHA/4o/faNXksj6Fb2vIrYjlMnGOm 6X9w== 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=zH/FzqdJj80clYWMIBvDY0RhHgfpv/mcx5mR70beTL4=; b=Y1EaDJIMYTJZiU7k+u4qKoMYnbDpIqqTb4HxMzp+5VfQrUOkYhETgLedbp4TwL7g5q Qx4AVW4xlBAn+2eekowdVkf2/Lx+vYDigMzlm0TKS75S03jIxW6JD7n8ILU8ZFUxoQ78 FN9uTEMdyXKII7c/rTHKj0/TBMsO38hK0EWTpcrN/9sDy0CoCjeS2oSwDmigXizj4wCo llnqNaPN664Z1Kgn3JHFeSNfM2gnab47mPHi7rU1tH6p8r507cMEKfLXmFZH2fabYdD6 AOI0dL2J0FrSFa20n7cs3dMZINaaVEdPFeOCHXHXfy63cS/Jtx7NGmtiep09pF5AtFZc JupQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PXQ3BPZ5; 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 s13si3263990plp.665.2017.12.14.07.37.28; Thu, 14 Dec 2017 07:37:28 -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=PXQ3BPZ5; 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 S1753666AbdLNPhY (ORCPT + 19 others); Thu, 14 Dec 2017 10:37:24 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:46480 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753298AbdLNPd4 (ORCPT ); Thu, 14 Dec 2017 10:33:56 -0500 Received: by mail-pf0-f195.google.com with SMTP id c204so3833885pfc.13 for ; Thu, 14 Dec 2017 07:33:56 -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=zH/FzqdJj80clYWMIBvDY0RhHgfpv/mcx5mR70beTL4=; b=PXQ3BPZ5F47jUP/fzv/x99+H5dl2mZ/Tt5DvDXwiNZXjA9pKl0EXFSdwENFol1CnjU OrCsgFezGGqasijYRlfIhtzd4+iJtkf58fjIxx/3j+M1UxjnreWTcpmBbfgFRAFbV03N Tkr/XG/McjvlqOlMvlRkKjlKUxxlTIxDJOTx0= 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=zH/FzqdJj80clYWMIBvDY0RhHgfpv/mcx5mR70beTL4=; b=lO03Dqf93SzEf0oUJdxzRTs++pNY+MDvq5RFQCuPuPUrE7WkW8KKj9FONWfosPHoaW KFHAW0fZ2CcZrg0JY5AUl7C7PvOB/84952SUKTl65wtwHITk/uGg2pnPCIBX9r9HhOLq bmKeN2OuaE8xL1WEysj8a9+Z+jc6TyCr0/XQgU9drtS9HNmKj3zlqadlZ+rNYAomopUC q5ghtxdQfIscXxmoIG/PYgLxqsX8rsbaLW3i11GMtkxilwavAcPLRLdMUVYpDn+8bUsQ V5+ZAp7PFTecLYgK/lGFfj92tVGCNvt2hfqcroRsqCno3/lsyQUYvTdNtaGY+oUcw8rM 0WWQ== X-Gm-Message-State: AKGB3mKymZ3WCiTc7AlZ1P01oUXGUtR86cSD4ZDM1gHUjDlHN84F1DnY iTrqu2FXjBqnxbnLNZWE4lF2TA== X-Received: by 10.98.8.67 with SMTP id c64mr10080613pfd.50.1513265636313; Thu, 14 Dec 2017 07:33:56 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id y3sm8772051pff.122.2017.12.14.07.33.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:33:55 -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 Subject: [PATCH V5 02/13] of: platform: Make of_platform_bus_create() global Date: Thu, 14 Dec 2017 21:03:09 +0530 Message-Id: <3875af7e7e77745f02ad429f09a1ad168a55e248.1513264961.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 The boot constraints core needs to create platform or AMBA devices corresponding to a compatible string and not for rest of the nodes in DT. of_platform_bus_create() fits in the best to achieve that. Allow it to be used outside of platform.c. Signed-off-by: Viresh Kumar --- drivers/of/platform.c | 8 ++++---- include/linux/of_platform.h | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 61a4a81bea9f..6f707bfb348f 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -397,10 +397,10 @@ static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *l * Creates a platform_device for the provided device_node, and optionally * recursively create devices for all the child nodes. */ -static int of_platform_bus_create(struct device_node *bus, - const struct of_device_id *matches, - const struct of_dev_auxdata *lookup, - struct device *parent, bool strict) +int of_platform_bus_create(struct device_node *bus, + const struct of_device_id *matches, + const struct of_dev_auxdata *lookup, + struct device *parent, bool strict) { const struct of_dev_auxdata *auxdata; struct device_node *child; diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 4909d1aa47ec..511a59fb8e15 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -77,6 +77,10 @@ extern struct platform_device *of_platform_device_create(struct device_node *np, struct device *parent); extern int of_platform_device_destroy(struct device *dev, void *data); +extern int of_platform_bus_create(struct device_node *bus, + const struct of_device_id *matches, + const struct of_dev_auxdata *lookup, + struct device *parent, bool strict); extern int of_platform_bus_probe(struct device_node *root, const struct of_device_id *matches, struct device *parent); @@ -94,6 +98,13 @@ extern int devm_of_platform_populate(struct device *dev); extern void devm_of_platform_depopulate(struct device *dev); #else +static inline int of_platform_bus_create(struct device_node *bus, + const struct of_device_id *matches, + const struct of_dev_auxdata *lookup, + struct device *parent, bool strict) +{ + return -ENODEV; +} static inline int of_platform_populate(struct device_node *root, const struct of_device_id *matches, const struct of_dev_auxdata *lookup, From patchwork Thu Dec 14 15:33:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121974 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6960088qgn; Thu, 14 Dec 2017 07:34:09 -0800 (PST) X-Google-Smtp-Source: ACJfBovtcAMes6RrdTNVVcz2DsvDCjSYSHgeP7qL6pFgm6cBPqCvp+jHqwzpP+CT2m56m2ZuBKdK X-Received: by 10.99.60.83 with SMTP id i19mr5393589pgn.26.1513265649352; Thu, 14 Dec 2017 07:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265649; cv=none; d=google.com; s=arc-20160816; b=ocWT23C9kOeU/oJEkB3gXXIHMCw/1NQw8F80WrN1Z4eEZKcqIppwHP/9V/DUCHVoqV /Y2MY8GrT46rgkd9WunKJvSCUH4NsORaI81i/wTYjODR41qkOuooRhprS4DD58kDJiRb m1IPK5DAsBookcaKU0RBqwZObOqTutGvaGgvud+QF3U8I6qWUtZIHIzWqpqpSBEg4LYi cFsM8QVj/Fkn5ZTBU9VdybDLxYju/lu+gUOWXRKk67lhGKz6C2wvWQzOLYck4gNRf+x+ S31HwP57BYkGPS5jLW2qVhFlVzGBtwCKgdRz3ahaavsHaD6a5e2PfwOkNYU5hHpqnBvR RadA== 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=Q48q+6TjNvbTmyxVHj136e/nZ3VZyJzcyJOXTAoJhx4=; b=rCPMUy4YH5w/3McXliXLzC6hUvfGi2jDbwkxf3P+953N25MrHiP+zSn6ozS8o7aE0W y709sqsbL5XJeOPZRIoVylAjvEAephBHNRAYRO6ovhIp2bIabAnHhY8umfzqhgw/oR1a A0PHSBhFqTqZCRC2h4nvuY1l/VB7XKVJzoaU5MpkgFUOUM3ePmuU4iv8PmEWSeH4/cNo VkgCIpcgO4BgmC00p180IQ5d60NWgxEB+pjylCPI6TDkBdzAJ9Zj9VGYpI2sG2cXN59/ 9hb5wL+s1xa58dKR4ZFYLp/eK305sUlT9MiIOkyXnoZFvGMrJQLDw/Krr6RHYjoRYdG2 QVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ESfY6KB+; 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 q12si3358439pls.475.2017.12.14.07.34.09; Thu, 14 Dec 2017 07:34:09 -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=ESfY6KB+; 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 S1753416AbdLNPeD (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:03 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37438 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbdLNPeA (ORCPT ); Thu, 14 Dec 2017 10:34:00 -0500 Received: by mail-pf0-f196.google.com with SMTP id n6so3851451pfa.4 for ; Thu, 14 Dec 2017 07:34:00 -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=Q48q+6TjNvbTmyxVHj136e/nZ3VZyJzcyJOXTAoJhx4=; b=ESfY6KB+6RPImGzzp1O3Jaum29FtT3uakojdtdfVxU28uTYlaJigF/N3cWBOO1VyBt K+U+Vnglw5c5klZ8S18AfAFBcU1NaUz/15salp+ltVHCfBVYYCpqa0CP426RvejqirHp SCCc7EvsIHAIfGr3fJAVmRWfLaaY7+k+o9h0Q= 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=Q48q+6TjNvbTmyxVHj136e/nZ3VZyJzcyJOXTAoJhx4=; b=UXNvztvugE17132xYVIzfi9z66YXbNwymk6X4pscglyVdkUytOUz6NsUUr6nQBAJKS 0BG+pDpVW+UlCSL3dZ1hunUyoDYH3DglgsppPG3mkWuZfSe+6M9I5QgrG316EjgIoJoh kfNpf2JTwrW3gSdY4t8M5LVF10Ys0WvAgNSoJ0qNUks4SJgt1SbYI0fhmwNrpCvxEwzA 4k84z9h/1co4BoU3joTNe8ZSDMZKbv7zJ7SBDyVqjykE1qz2MFr6Yiky1daSaMLBCn7R vUnhKoz46yIvI9+JqjuoCLp3C6zgLY95JRuuo5cZlZKk48yzEKbyJX7P8RJ0VkHGPshY n15g== X-Gm-Message-State: AKGB3mJLeGj6PehtoKYhfUjl9sRN3zd+QyDKItFlOuqs8R592bzFeotP ptkvWtljRREZd+PpatK/B+ZnQA== X-Received: by 10.98.11.71 with SMTP id t68mr9867381pfi.79.1513265639366; Thu, 14 Dec 2017 07:33:59 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id t66sm8913566pfa.153.2017.12.14.07.33.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:33:58 -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 Subject: [PATCH V5 03/13] drivers: Add boot constraints core Date: Thu, 14 Dec 2017 21:03:10 +0530 Message-Id: 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 Some devices are powered ON by the bootloader before the bootloader handovers control to Linux. It maybe important for those devices to keep working until the time a Linux device driver probes the device and reconfigure its resources. A typical example of that can be the LCD controller, which is used by the bootloaders to show image(s) while the platform is booting into Linux. The LCD controller can be using some resources, like clk, regulators, PM domain, etc, that are shared between several devices. These shared resources should be configured to satisfy need of all the users. If another device's (X) driver gets probed before the LCD controller driver in this case, then it may end up reconfiguring these resources to ranges satisfying the current users (only device X) and that can make the LCD screen unstable. This patch introduces the concept of boot-constraints, which will be set by the bootloaders and the kernel will satisfy them until the time driver for such a device is probed (successfully or unsuccessfully). The list of boot constraint types is empty for now, and will be incrementally updated by later patches. Only two routines are exposed by the boot constraints core for now: - dev_boot_constraint_add(): This shall be called by parts of the kernel (before the device is probed) to set the constraints. - dev_boot_constraints_remove(): This is called only by the driver core after a device is probed successfully or unsuccessfully. Special handling is done here for deferred probing. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/base/dd.c | 20 ++-- drivers/boot_constraint/Kconfig | 9 ++ drivers/boot_constraint/Makefile | 3 + drivers/boot_constraint/core.c | 219 +++++++++++++++++++++++++++++++++++++++ drivers/boot_constraint/core.h | 30 ++++++ include/linux/boot_constraint.h | 66 ++++++++++++ 8 files changed, 343 insertions(+), 7 deletions(-) create mode 100644 drivers/boot_constraint/Kconfig create mode 100644 drivers/boot_constraint/Makefile create mode 100644 drivers/boot_constraint/core.c create mode 100644 drivers/boot_constraint/core.h create mode 100644 include/linux/boot_constraint.h -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/Kconfig b/drivers/Kconfig index ef5fb8395d76..87ec868c74c5 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -5,6 +5,8 @@ source "drivers/amba/Kconfig" source "drivers/base/Kconfig" +source "drivers/boot_constraint/Kconfig" + source "drivers/bus/Kconfig" source "drivers/connector/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 7a2330077e47..7fd71b658aa7 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -73,6 +73,7 @@ obj-$(CONFIG_FB_INTEL) += video/fbdev/intelfb/ obj-$(CONFIG_PARPORT) += parport/ obj-$(CONFIG_NVM) += lightnvm/ obj-y += base/ block/ misc/ mfd/ nfc/ +obj-$(CONFIG_DEV_BOOT_CONSTRAINT) += boot_constraint/ obj-$(CONFIG_LIBNVDIMM) += nvdimm/ obj-$(CONFIG_DAX) += dax/ obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/ diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 533c82f55cea..dc89f98a2487 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -16,6 +16,7 @@ * Copyright (c) 2007-2009 Novell Inc. */ +#include #include #include #include @@ -419,15 +420,20 @@ static int really_probe(struct device *dev, struct device_driver *drv) */ devices_kset_move_last(dev); - if (dev->bus->probe) { + if (dev->bus->probe) ret = dev->bus->probe(dev); - if (ret) - goto probe_failed; - } else if (drv->probe) { + else if (drv->probe) ret = drv->probe(dev); - if (ret) - goto probe_failed; - } + + /* + * Remove boot constraints for both successful and unsuccessful probe(), + * except for the case where EPROBE_DEFER is returned by probe(). + */ + if (ret != -EPROBE_DEFER) + dev_boot_constraints_remove(dev); + + if (ret) + goto probe_failed; if (test_remove) { test_remove = false; diff --git a/drivers/boot_constraint/Kconfig b/drivers/boot_constraint/Kconfig new file mode 100644 index 000000000000..9195f9a39fe2 --- /dev/null +++ b/drivers/boot_constraint/Kconfig @@ -0,0 +1,9 @@ +config DEV_BOOT_CONSTRAINT + bool "Boot constraints for devices" + help + This enables boot constraints detection for devices. These constraints + are (normally) set by the Bootloader and must be satisfied by the + kernel until the relevant device driver is probed. Once the driver is + probed, the constraint is dropped. + + If unsure, say N. diff --git a/drivers/boot_constraint/Makefile b/drivers/boot_constraint/Makefile new file mode 100644 index 000000000000..0f2680177974 --- /dev/null +++ b/drivers/boot_constraint/Makefile @@ -0,0 +1,3 @@ +# Makefile for device boot constraints + +obj-y := core.o diff --git a/drivers/boot_constraint/core.c b/drivers/boot_constraint/core.c new file mode 100644 index 000000000000..45a0fbed1b11 --- /dev/null +++ b/drivers/boot_constraint/core.c @@ -0,0 +1,219 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * This takes care of boot time device constraints, normally set by the + * Bootloader. + * + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ + +#include +#include +#include +#include + +#include "core.h" + +#define for_each_constraint(_constraint, _temp, _cdev) \ + list_for_each_entry_safe(_constraint, _temp, &_cdev->constraints, node) + +/* Global list of all constraint devices currently registered */ +static LIST_HEAD(constraint_devices); +static DEFINE_MUTEX(constraint_devices_mutex); + +/* Boot constraints core */ + +static struct constraint_dev *constraint_device_find(struct device *dev) +{ + struct constraint_dev *cdev; + + list_for_each_entry(cdev, &constraint_devices, node) { + if (cdev->dev == dev) + return cdev; + } + + return NULL; +} + +static struct constraint_dev *constraint_device_allocate(struct device *dev) +{ + struct constraint_dev *cdev; + + cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); + if (!cdev) + return ERR_PTR(-ENOMEM); + + cdev->dev = dev; + INIT_LIST_HEAD(&cdev->node); + INIT_LIST_HEAD(&cdev->constraints); + + list_add(&cdev->node, &constraint_devices); + + return cdev; +} + +static void constraint_device_free(struct constraint_dev *cdev) +{ + list_del(&cdev->node); + kfree(cdev); +} + +static struct constraint_dev *constraint_device_get(struct device *dev) +{ + struct constraint_dev *cdev; + + cdev = constraint_device_find(dev); + if (cdev) + return cdev; + + cdev = constraint_device_allocate(dev); + if (IS_ERR(cdev)) { + dev_err(dev, "Failed to add constraint dev (%ld)\n", + PTR_ERR(cdev)); + } + + return cdev; +} + +static void constraint_device_put(struct constraint_dev *cdev) +{ + if (!list_empty(&cdev->constraints)) + return; + + constraint_device_free(cdev); +} + +static struct constraint *constraint_allocate(struct constraint_dev *cdev, + enum dev_boot_constraint_type type) +{ + struct constraint *constraint; + int (*add)(struct constraint *constraint, void *data); + void (*remove)(struct constraint *constraint); + + switch (type) { + default: + return ERR_PTR(-EINVAL); + } + + constraint = kzalloc(sizeof(*constraint), GFP_KERNEL); + if (!constraint) + return ERR_PTR(-ENOMEM); + + constraint->cdev = cdev; + constraint->type = type; + constraint->add = add; + constraint->remove = remove; + INIT_LIST_HEAD(&constraint->node); + + list_add(&constraint->node, &cdev->constraints); + + return constraint; +} + +static void constraint_free(struct constraint *constraint) +{ + list_del(&constraint->node); + kfree(constraint); +} + +/** + * dev_boot_constraint_add: Adds a boot constraint. + * + * @dev: Device for which the boot constraint is getting added. + * @info: Structure representing the boot constraint. + * + * This routine adds a single boot constraint for the device. This must be + * called before the device is probed by its driver, otherwise the boot + * constraint will never get removed and may result in unwanted behavior of the + * hardware. The boot constraint is removed by the driver core automatically + * after the device is probed (successfully or unsuccessfully). + * + * Return: 0 on success, and a negative error otherwise. + */ +int dev_boot_constraint_add(struct device *dev, + struct dev_boot_constraint_info *info) +{ + struct constraint_dev *cdev; + struct constraint *constraint; + int ret; + + mutex_lock(&constraint_devices_mutex); + + /* Find or add the cdev type first */ + cdev = constraint_device_get(dev); + if (IS_ERR(cdev)) { + ret = PTR_ERR(cdev); + goto unlock; + } + + constraint = constraint_allocate(cdev, info->constraint.type); + if (IS_ERR(constraint)) { + dev_err(dev, "Failed to add constraint type: %d (%ld)\n", + info->constraint.type, PTR_ERR(constraint)); + ret = PTR_ERR(constraint); + goto put_cdev; + } + + constraint->free_resources = info->free_resources; + constraint->free_resources_data = info->free_resources_data; + + /* Set constraint */ + ret = constraint->add(constraint, info->constraint.data); + if (ret) + goto free_constraint; + + dev_dbg(dev, "Added boot constraint-type (%d)\n", + info->constraint.type); + + mutex_unlock(&constraint_devices_mutex); + + return 0; + +free_constraint: + constraint_free(constraint); +put_cdev: + constraint_device_put(cdev); +unlock: + mutex_unlock(&constraint_devices_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(dev_boot_constraint_add); + +static void constraint_remove(struct constraint *constraint) +{ + constraint->remove(constraint); + + if (constraint->free_resources) + constraint->free_resources(constraint->free_resources_data); + + constraint_free(constraint); +} + +/** + * dev_boot_constraints_remove: Removes all boot constraints of a device. + * + * @dev: Device for which the boot constraints are getting removed. + * + * This routine removes all the boot constraints that were previously added for + * the device. This is called directly by the driver core and should not be + * called by platform specific code. + */ +void dev_boot_constraints_remove(struct device *dev) +{ + struct constraint_dev *cdev; + struct constraint *constraint, *temp; + + mutex_lock(&constraint_devices_mutex); + + cdev = constraint_device_find(dev); + if (!cdev) + goto unlock; + + for_each_constraint(constraint, temp, cdev) + constraint_remove(constraint); + + constraint_device_put(cdev); +unlock: + mutex_unlock(&constraint_devices_mutex); +} diff --git a/drivers/boot_constraint/core.h b/drivers/boot_constraint/core.h new file mode 100644 index 000000000000..1e87125de531 --- /dev/null +++ b/drivers/boot_constraint/core.h @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ +#ifndef _CORE_H +#define _CORE_H + +#include +#include +#include + +struct constraint_dev { + struct device *dev; + struct list_head node; + struct list_head constraints; +}; + +struct constraint { + struct constraint_dev *cdev; + struct list_head node; + enum dev_boot_constraint_type type; + void (*free_resources)(void *data); + void *free_resources_data; + + int (*add)(struct constraint *constraint, void *data); + void (*remove)(struct constraint *constraint); + void *private; +}; +#endif /* _CORE_H */ diff --git a/include/linux/boot_constraint.h b/include/linux/boot_constraint.h new file mode 100644 index 000000000000..2ce62b7b3cc6 --- /dev/null +++ b/include/linux/boot_constraint.h @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Boot constraints header. + * + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ +#ifndef _LINUX_BOOT_CONSTRAINT_H +#define _LINUX_BOOT_CONSTRAINT_H + +#include +#include + +struct device; + +/** + * enum dev_boot_constraint_type - This defines different boot constraint types. + * + */ +enum dev_boot_constraint_type { + DEV_BOOT_CONSTRAINT_NONE, +}; + +/** + * struct dev_boot_constraint - This represents a single boot constraint. + * + * @type: This is boot constraint type (like: clk, supply, etc.). + * @data: This points to constraint type specific data (like: + * dev_boot_constraint_clk_info). + */ +struct dev_boot_constraint { + enum dev_boot_constraint_type type; + void *data; +}; + +/** + * struct dev_boot_constraint_info - This is used to add a single boot + * constraint. + * + * @constraint: This represents a single boot constraint. + * @free_resources: This callback is called by the boot constraint core after + * the constraint is removed. This is an optional field. + * @free_resources_data: This is data to be passed to free_resources() callback. + * This is an optional field. + */ +struct dev_boot_constraint_info { + struct dev_boot_constraint constraint; + + /* This will be called just before the constraint is removed */ + void (*free_resources)(void *data); + void *free_resources_data; +}; + +#ifdef CONFIG_DEV_BOOT_CONSTRAINT +int dev_boot_constraint_add(struct device *dev, + struct dev_boot_constraint_info *info); +void dev_boot_constraints_remove(struct device *dev); +#else +static inline +int dev_boot_constraint_add(struct device *dev, + struct dev_boot_constraint_info *info) +{ return 0; } +static inline void dev_boot_constraints_remove(struct device *dev) {} +#endif /* CONFIG_DEV_BOOT_CONSTRAINT */ + +#endif /* _LINUX_BOOT_CONSTRAINT_H */ From patchwork Thu Dec 14 15:33:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121984 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6963561qgn; Thu, 14 Dec 2017 07:36:54 -0800 (PST) X-Google-Smtp-Source: ACJfBoub/A5iNVIZQpysRhp8NPPIVUykK0Bv3XsXIQ6idagdZflCw9+5NIlMjn126v3GrPWMheI7 X-Received: by 10.98.113.196 with SMTP id m187mr9966211pfc.136.1513265813939; Thu, 14 Dec 2017 07:36:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265813; cv=none; d=google.com; s=arc-20160816; b=P4JANunogUoY43Q0ashkLmzpjAnDFEBfaRJGejPC1CMMBz2zn8U2TY7i1lXEFliviP J9QsYAWye5bGWiWDT8CwYTD+cAivKs0tSg6V+NwM/kxtVcO+G0hM8qOxsEarEkWCMbHd kfBxe6N/vZY8v14u9U5uM3D9nwn/0chX4r5hRdMw/bzSmQ9zHxMYNYyNCWu+eRDFd7Q2 jJrnuqYiWFrADryQGzNqUEJ0WQqLoYJG7MHb8KrCsW0oZeux81FKnkLQsTFGIrU5FFUR HbsfL7nkGYAtRxgtG5QFUO6FPV4rrMc+Iao5F68G033IpkEQGS1la/YowbBCjrAh6f66 wAnw== 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=icrIZ+0hNJgAa851BNV/t+RWElv/Pouel/nrtZERfj0=; b=YSB1yWl91uE6FYFFwxjEYykF6BtSuMhFEPlKLFSy91+CW9B9dtAU2z8Z03A58AUhTM P6TJDBisORCrPbY5eBlYVQMCDq70s3BduXLE3JUvJmXfWBAmksLDaTAVsWubI2Rvwg9C mmJgHNzM44TLZ56Aq7UGIQQypDBegVUKvEck7XpvOpoNe7YRQM5GNYpZlGeEZz9XvjO1 C1i6OZTBBPS6dLUvmcIPPTN9loRLVkqZZZFrjMLei0npdAnfklj9lY4N3fnbAwh/ojvi LbHElVnPjw7y3cXAloNQVZjTaFgnmSxRnj9zrWFOdqaLcbHJL5ERC9piFD0F74CtxksY xvKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UyXFvnvn; 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 v4si3295862plb.791.2017.12.14.07.36.53; Thu, 14 Dec 2017 07:36:53 -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=UyXFvnvn; 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 S1753554AbdLNPgt (ORCPT + 19 others); Thu, 14 Dec 2017 10:36:49 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35230 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753330AbdLNPeC (ORCPT ); Thu, 14 Dec 2017 10:34:02 -0500 Received: by mail-pg0-f66.google.com with SMTP id q20so3635459pgv.2 for ; Thu, 14 Dec 2017 07:34:02 -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=icrIZ+0hNJgAa851BNV/t+RWElv/Pouel/nrtZERfj0=; b=UyXFvnvngSXhJGWyn/WU2SKyx4pDr/isdHpx7gjw3taHi72pIyZTJoDX6anhBDfGno 7GG1R5d5yIXhtOo1ZOqIbnpas4SpnlmLmttLM0SBjZ9l4WGEGvl6O8ZtLFN9yFB6OuTj IBPck5dmTGgnu0cUbSeIrO0IRQY4h3HJR102g= 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=icrIZ+0hNJgAa851BNV/t+RWElv/Pouel/nrtZERfj0=; b=RvQfqg9qVG7po8hnwwSRMVi6z4ilPXqxHjj/HB5hLnSXQc98EqgOOrmAg5goRF+K1V ObH12/GINCu6HmUW+r7sE36ZTqbowtblNx336ZsTsdL+nrSSRpmlRJtL9MDFLpMohUu8 IHQmQRwZ4o2tCBhmkCNKyJ4MvKiAhGwuitOqKQHveXe3xNhJKnACJOXvNSH10ylUEzTS qbxOnvLM6QQRjz6w7AXtvelZW9ylWNImgC6w7lPwp0tRjQ9vcXueTU0M7mo1bqocwq9M mYwt520PccPufIvppO1etCi0tHl9vR3K3IfRtRhN/TY3+Vi/2CtpDGNiU8S38mMImpQU Vh9Q== X-Gm-Message-State: AKGB3mJ7rHFslIcGQd0jpFB+StFLpoOTBompSXbxZe8bAwS0FrATtNbe 0Td8r0k0aTwwUzLnYTGykE/i5g== X-Received: by 10.84.252.146 with SMTP id y18mr9882365pll.70.1513265642229; Thu, 14 Dec 2017 07:34:02 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id q72sm9560151pfi.42.2017.12.14.07.34.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:01 -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 Subject: [PATCH V5 04/13] boot_constraint: Add support for supply constraints Date: Thu, 14 Dec 2017 21:03:11 +0530 Message-Id: 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 first constraint type: power-supply. The constraint is set by enabling the regulator and setting a voltage range (if required) for the respective regulator device, which will be honored by the regulator core even if more users turn up. Once the device is probed, the regulator is released and the constraint is removed. 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 | 5 +++ drivers/boot_constraint/supply.c | 95 ++++++++++++++++++++++++++++++++++++++++ include/linux/boot_constraint.h | 17 ++++++- 5 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 drivers/boot_constraint/supply.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/boot_constraint/Makefile b/drivers/boot_constraint/Makefile index 0f2680177974..a45616f0c3b0 100644 --- a/drivers/boot_constraint/Makefile +++ b/drivers/boot_constraint/Makefile @@ -1,3 +1,3 @@ # Makefile for device boot constraints -obj-y := core.o +obj-y := core.o supply.o diff --git a/drivers/boot_constraint/core.c b/drivers/boot_constraint/core.c index 45a0fbed1b11..63a4b1a2fa2c 100644 --- a/drivers/boot_constraint/core.c +++ b/drivers/boot_constraint/core.c @@ -91,6 +91,10 @@ static struct constraint *constraint_allocate(struct constraint_dev *cdev, void (*remove)(struct constraint *constraint); switch (type) { + case DEV_BOOT_CONSTRAINT_SUPPLY: + add = constraint_supply_add; + remove = constraint_supply_remove; + break; default: return ERR_PTR(-EINVAL); } diff --git a/drivers/boot_constraint/core.h b/drivers/boot_constraint/core.h index 1e87125de531..d0d3e7bf7d57 100644 --- a/drivers/boot_constraint/core.h +++ b/drivers/boot_constraint/core.h @@ -27,4 +27,9 @@ struct constraint { void (*remove)(struct constraint *constraint); void *private; }; + +/* Forward declarations of constraint specific callbacks */ +int constraint_supply_add(struct constraint *constraint, void *data); +void constraint_supply_remove(struct constraint *constraint); + #endif /* _CORE_H */ diff --git a/drivers/boot_constraint/supply.c b/drivers/boot_constraint/supply.c new file mode 100644 index 000000000000..916e5d6848d5 --- /dev/null +++ b/drivers/boot_constraint/supply.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ + +#include +#include +#include + +#include "core.h" + +struct constraint_supply { + struct dev_boot_constraint_supply_info supply; + struct regulator *reg; +}; + +int constraint_supply_add(struct constraint *constraint, void *data) +{ + struct dev_boot_constraint_supply_info *supply = data; + struct constraint_supply *csupply; + struct device *dev = constraint->cdev->dev; + int ret; + + csupply = kzalloc(sizeof(*csupply), GFP_KERNEL); + if (!csupply) + return -ENOMEM; + + csupply->reg = regulator_get(dev, supply->name); + if (IS_ERR(csupply->reg)) { + ret = PTR_ERR(csupply->reg); + if (ret != -EPROBE_DEFER) { + dev_err(dev, "regulator_get() failed for %s (%d)\n", + supply->name, ret); + } + goto free; + } + + if (supply->u_volt_min != 0 && supply->u_volt_max != 0) { + ret = regulator_set_voltage(csupply->reg, supply->u_volt_min, + supply->u_volt_max); + if (ret) { + dev_err(dev, "regulator_set_voltage %s failed (%d)\n", + supply->name, ret); + goto free_regulator; + } + } + + ret = regulator_enable(csupply->reg); + if (ret) { + dev_err(dev, "regulator_enable %s failed (%d)\n", + supply->name, ret); + goto remove_voltage; + } + + memcpy(&csupply->supply, supply, sizeof(*supply)); + csupply->supply.name = kstrdup_const(supply->name, GFP_KERNEL); + constraint->private = csupply; + + return 0; + +remove_voltage: + if (supply->u_volt_min != 0 && supply->u_volt_max != 0) + regulator_set_voltage(csupply->reg, 0, INT_MAX); +free_regulator: + regulator_put(csupply->reg); +free: + kfree(csupply); + + return ret; +} + +void constraint_supply_remove(struct constraint *constraint) +{ + struct constraint_supply *csupply = constraint->private; + struct dev_boot_constraint_supply_info *supply = &csupply->supply; + struct device *dev = constraint->cdev->dev; + int ret; + + kfree_const(supply->name); + + ret = regulator_disable(csupply->reg); + if (ret) + dev_err(dev, "regulator_disable failed (%d)\n", ret); + + if (supply->u_volt_min != 0 && supply->u_volt_max != 0) { + ret = regulator_set_voltage(csupply->reg, 0, INT_MAX); + if (ret) + dev_err(dev, "regulator_set_voltage failed (%d)\n", + ret); + } + + regulator_put(csupply->reg); + kfree(csupply); +} diff --git a/include/linux/boot_constraint.h b/include/linux/boot_constraint.h index 2ce62b7b3cc6..1db24d53b622 100644 --- a/include/linux/boot_constraint.h +++ b/include/linux/boot_constraint.h @@ -16,9 +16,24 @@ struct device; /** * enum dev_boot_constraint_type - This defines different boot constraint types. * + * @DEV_BOOT_CONSTRAINT_SUPPLY: This represents a power supply boot constraint. */ enum dev_boot_constraint_type { - DEV_BOOT_CONSTRAINT_NONE, + DEV_BOOT_CONSTRAINT_SUPPLY, +}; + +/** + * struct dev_boot_constraint_supply_info - Power supply boot constraint + * information. + * + * @name: This must match the power supply name for the device. + * @u_volt_min: This is the minimum microvolts value supported by the device. + * @u_volt_max: This is the maximum microvolts value supported by the device. + */ +struct dev_boot_constraint_supply_info { + const char *name; + unsigned int u_volt_min; + unsigned int u_volt_max; }; /** From patchwork Thu Dec 14 15:33:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121975 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6960139qgn; Thu, 14 Dec 2017 07:34:11 -0800 (PST) X-Google-Smtp-Source: ACJfBotIw+rq+ONf2CDFs15VvNPX3dkzrwYUDOP1btnjIT2laiYC7HZoLRNncprVfV2ojIzhYn5u X-Received: by 10.99.127.70 with SMTP id p6mr8754839pgn.418.1513265651638; Thu, 14 Dec 2017 07:34:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265651; cv=none; d=google.com; s=arc-20160816; b=JqwUGYd1x68DqQwDpTBjLidRQhPRZNsS/pus7toE0/WlpnxUzUPsWEPOAaLV/QQyB1 nUnAqzjV1+ZXcErMY6yD9sVjYe7dPIMi/wu3QCwlZGhBNW8LCLdUPXiltQv0OMpMuivY uEo+HbqGFB3Tj5jRd5ZJ/4jY5HTgahY6e8HhCGxjmYRcEY05EgNumqcEM0ESwNuyO5qj moQJzO9kFsSx4Yp67P+dSEx4d64V9BSLVxCfrVP1Y643KWbM8/uE2PiU+pt9P7Jpuzu8 eCIl2rfMtQmOodYoN5bxF0hUzyD6ciCutPk9A9ln3UkP1aGgGmPQ7qcUgdW8qmEvDvkk 793A== 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=96/PenY+L4PT6MZMyfgg3j5Cpr3agCdGKBAcQne3S8E=; b=hF4OCIyQJ27HFHR56CAuEVtn0/JX3oHi5DU/JY1Bz8oTxlzCKGq7uvwrI9qpCXZWlG zvrd3VEqKk+PoO9cdVo6RXz2gIRgeEL2oMcXOPmyMbiPBeAVysXVr1NRVEY3cDono9LA Mk7QkX3mKxU1Sbe3LhTKNL/fX9jQEmKaqVLjVr3ACLqkO1xPnL8tzWrP3+oyDBGM8LJY vqYuPzXPzcrHXEEL/FhSxGdM0bAXImWCtBPT1cw8TU3zR7CqfRa1vPthNxbOQnb0Dhup DxBrS9B9TpCIUN7Ie8b2z0vI6oX/XHXwvjkqKeV2wAAJ0rQUaURbNjfAuMIFxptJnvmZ Cyng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RMX6yglh; 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 q12si3358439pls.475.2017.12.14.07.34.11; Thu, 14 Dec 2017 07:34:11 -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=RMX6yglh; 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 S1753444AbdLNPeJ (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:09 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33100 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbdLNPeF (ORCPT ); Thu, 14 Dec 2017 10:34:05 -0500 Received: by mail-pf0-f196.google.com with SMTP id y89so3861684pfk.0 for ; Thu, 14 Dec 2017 07:34:05 -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=96/PenY+L4PT6MZMyfgg3j5Cpr3agCdGKBAcQne3S8E=; b=RMX6yglhKo0Od2dfIeF3KvGc8xecnI7SWYZ/zm/BMTCGA6jTijPWO2/vOrt/OueX3X 1lJHLnUUYXZZhTe2H3ms4kDRv/SFDfdrDTm7tfPyWFJbOrchYPI3N+dkdik3EESuUykh cTXcdbge6e21vXuSbjoru9q7seeuJ/babuNOw= 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=96/PenY+L4PT6MZMyfgg3j5Cpr3agCdGKBAcQne3S8E=; b=l5476x3x31ymRJ6ed6Y5TPySdo/nzhcB/COY99v2xcg4TDBzOoSb0QM4staL7Af59E LBiXgE6rrAMZtaya20J1V92EaLs5hrdqRtbb2PaZMJLr9CZzf5VKAFUhQRLgYTdYSQZY IrBH8Fy7WjrE3X+GgZmeuAuRaH+BLM4Nr7s5r0qA+eMFogrVFk5C42l90JEm5JKJ071v DGSfY28WlReowQg0/YtgBLmKmvrvcZKsj8q0MbRKV5GEhQSOI/zgPOU2hSuIEnPG4Xo3 zFJel3qiJvRBl6YJn0UpS4RcRRYA2O7ddP2m58CuXukZ83d11Rn+/UmF0nGnVel9Yhb4 dMaw== X-Gm-Message-State: AKGB3mIOW1bFrGp+Fb8oP0BvLfjeKF80Mviy/C4DuAjTgM1jqBIu3SZD y94dnQtcz3gRM4+8RTkWEPSs0g== X-Received: by 10.159.242.132 with SMTP id u4mr9985674plr.296.1513265645077; Thu, 14 Dec 2017 07:34:05 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id b10sm8503649pfj.20.2017.12.14.07.34.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:04 -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 Subject: [PATCH V5 05/13] boot_constraint: Add support for clk constraints Date: Thu, 14 Dec 2017 21:03:12 +0530 Message-Id: <1384510a9ca95d307e6a23b32cb467a2e23b22b6.1513264961.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 clk constraint type. The constraint is set by enabling the clk for the device. Once the device is probed, the clk is disabled and the constraint is removed. We may want to do clk_set_rate() from here, but lets wait for some real users that really want it. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/boot_constraint/Makefile | 2 +- drivers/boot_constraint/clk.c | 67 ++++++++++++++++++++++++++++++++++++++++ drivers/boot_constraint/core.c | 4 +++ drivers/boot_constraint/core.h | 3 ++ include/linux/boot_constraint.h | 11 +++++++ 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 drivers/boot_constraint/clk.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/boot_constraint/Makefile b/drivers/boot_constraint/Makefile index a45616f0c3b0..3424379fd1e4 100644 --- a/drivers/boot_constraint/Makefile +++ b/drivers/boot_constraint/Makefile @@ -1,3 +1,3 @@ # Makefile for device boot constraints -obj-y := core.o supply.o +obj-y := clk.o core.o supply.o diff --git a/drivers/boot_constraint/clk.c b/drivers/boot_constraint/clk.c new file mode 100644 index 000000000000..db22acff43e6 --- /dev/null +++ b/drivers/boot_constraint/clk.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ + +#include +#include +#include + +#include "core.h" + +struct constraint_clk { + struct dev_boot_constraint_clk_info clk_info; + struct clk *clk; +}; + +int constraint_clk_add(struct constraint *constraint, void *data) +{ + struct dev_boot_constraint_clk_info *clk_info = data; + struct constraint_clk *cclk; + struct device *dev = constraint->cdev->dev; + int ret; + + cclk = kzalloc(sizeof(*cclk), GFP_KERNEL); + if (!cclk) + return -ENOMEM; + + cclk->clk = clk_get(dev, clk_info->name); + if (IS_ERR(cclk->clk)) { + ret = PTR_ERR(cclk->clk); + if (ret != -EPROBE_DEFER) { + dev_err(dev, "clk_get() failed for %s (%d)\n", + clk_info->name, ret); + } + goto free; + } + + ret = clk_prepare_enable(cclk->clk); + if (ret) { + dev_err(dev, "clk_prepare_enable() %s failed (%d)\n", + clk_info->name, ret); + goto put_clk; + } + + cclk->clk_info.name = kstrdup_const(clk_info->name, GFP_KERNEL); + constraint->private = cclk; + + return 0; + +put_clk: + clk_put(cclk->clk); +free: + kfree(cclk); + + return ret; +} + +void constraint_clk_remove(struct constraint *constraint) +{ + struct constraint_clk *cclk = constraint->private; + + kfree_const(cclk->clk_info.name); + clk_disable_unprepare(cclk->clk); + clk_put(cclk->clk); + kfree(cclk); +} diff --git a/drivers/boot_constraint/core.c b/drivers/boot_constraint/core.c index 63a4b1a2fa2c..df9e0bddbfbe 100644 --- a/drivers/boot_constraint/core.c +++ b/drivers/boot_constraint/core.c @@ -91,6 +91,10 @@ static struct constraint *constraint_allocate(struct constraint_dev *cdev, void (*remove)(struct constraint *constraint); switch (type) { + case DEV_BOOT_CONSTRAINT_CLK: + add = constraint_clk_add; + remove = constraint_clk_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 d0d3e7bf7d57..720bda0a0f44 100644 --- a/drivers/boot_constraint/core.h +++ b/drivers/boot_constraint/core.h @@ -29,6 +29,9 @@ struct constraint { }; /* Forward declarations of constraint specific callbacks */ +int constraint_clk_add(struct constraint *constraint, void *data); +void constraint_clk_remove(struct constraint *constraint); + int constraint_supply_add(struct constraint *constraint, void *data); void constraint_supply_remove(struct constraint *constraint); diff --git a/include/linux/boot_constraint.h b/include/linux/boot_constraint.h index 1db24d53b622..d798355fd93f 100644 --- a/include/linux/boot_constraint.h +++ b/include/linux/boot_constraint.h @@ -16,12 +16,23 @@ 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_SUPPLY: This represents a power supply boot constraint. */ enum dev_boot_constraint_type { + DEV_BOOT_CONSTRAINT_CLK, DEV_BOOT_CONSTRAINT_SUPPLY, }; +/** + * struct dev_boot_constraint_clk_info - Clock boot constraint information. + * + * @name: This must match the connection-id of the clock for the device. + */ +struct dev_boot_constraint_clk_info { + const char *name; +}; + /** * struct dev_boot_constraint_supply_info - Power supply boot constraint * information. 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: 121982 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6962230qgn; Thu, 14 Dec 2017 07:35:54 -0800 (PST) X-Google-Smtp-Source: ACJfBosagXp98xcLnW+rbKGNtWgaJHBvbPWJJ/ETajd1LgiGfBlz/lUNi0xHN7p44Lx17X5hTwTy X-Received: by 10.99.96.85 with SMTP id u82mr9042345pgb.247.1513265754289; Thu, 14 Dec 2017 07:35:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265754; cv=none; d=google.com; s=arc-20160816; b=hNU8YVsUfa5OdYdMRXzUcjuOPcMYZs2U5L2DFMCGKHQ7LkVRY+K/xGGz+DMga3eEww 1L3wIpcB0l//8GmxJIg1ZfoObXure1ywQh8fbBTgmI4yCnLEMNqFVg7M/bYK8UHx80B+ ojsJb/D07ieIobJ6otn4fx7Ni/ydx6JKCo/4G+hPG6C4q+IevV/qHo2mTu1CcX1Rlz3j WV7nfRvvo69ruS/lxrBRkvUAfcqF2eHOZ/nGWyFya3+MKoNnAZg+8O0Cyffr5SMvAMZX zUmKMaVjYOUxZBGEAwuIw+DBW+3YmHFr1xOVjP4BupTFdSrzuo4TrUPZoz0JTa35qwGF ovrw== 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=yOVDowshOOB3m6GCsZb+K+vIW7RioybFuH6xJnqS0Kg=; b=tcUcjC5vIfSwTvAkxXMOHN0pj2SMiTHh/pS88zc92oyGJiAsoWUsID2WlolGyETv1I m76PP0Ebgb9GZPR6628Czh77JLc0x066tzy6xqMS/XKPzCM1coWx98S79vumNIUsrmYs AKL3zO+AHTf4Rr7eiLTu0+az5xAzWyX+1Ly4PnXDo7zC70TrTXLAiQ+5x9temksmUB7P fmxi0MGdQh0r1G1xml1N+0vdATLxfAenxBKgrqMdM8Dv8r96c+3luwVVvYqEfj54JyfI lhF/Z1ZMG2n2AukyIc7wi8RByVgN/Eu/jZ9H0ntlR/BsMKtWoeCEwK04+AykXzfu17u8 3RHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S8uTZ7iP; 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 c26si3412776pfh.105.2017.12.14.07.35.54; Thu, 14 Dec 2017 07:35:54 -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=S8uTZ7iP; 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 S1753467AbdLNPeP (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:15 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:40465 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753437AbdLNPeI (ORCPT ); Thu, 14 Dec 2017 10:34:08 -0500 Received: by mail-pf0-f193.google.com with SMTP id v26so3852471pfl.7 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=O2xQGlezgvbehkrh0pvuUf3skdTSitLfVu+ltUY1YeFFiqAJOE4AwLOPgEhgXIV70t M+K3P5M/cTZFwbnTzZOwgJTCcZG5D7veMZtif2Rj48AA7R86JmD6RKgKyKlyYSYktIIj KBCs5o44DW4IHTZJkFp5N6MkUeuAvHwwYgk5jodzytwnqvqfbk1jxkgajtw96l5qhvdz kzZzDVUF4spcgVYsaiTCdq5WgDhE80Uhip6jaAb+IqG8I1G8eJ4nwS9/2shbvND4c3lx 60jPT50b23/nJYUg/cQg4Jy/bjOhT2A+IcayCUzFH8dXWD6lYODp26uo0xa6MtJVBzqE 0pQg== X-Gm-Message-State: AKGB3mJZ5oDlGA42wv3N+i2Js9BzMqY/i5x5ijlwV71DgNFqnAcqGhj+ YWIlKY/sAR4Ul7SdQt1EQwtCsQ== 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 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 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: 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/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 -- 2.15.0.194.g9af6a3dea062 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, }; From patchwork Thu Dec 14 15:33:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121976 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6960320qgn; Thu, 14 Dec 2017 07:34:20 -0800 (PST) X-Google-Smtp-Source: ACJfBotaWP/GurTV8CyP0O7jRULlGdlNJfHv+lHxFsY/zGdfIrN0poT8DCi8AOJDymIqTjXS2MFf X-Received: by 10.101.68.129 with SMTP id l1mr8805654pgq.53.1513265660497; Thu, 14 Dec 2017 07:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265660; cv=none; d=google.com; s=arc-20160816; b=crgsKUm3SeLkNipvAZVFd3tL6hXhQryr5FzE6WYyrDZoec9CiWDwgCTk/gPIilJmDz 3zRN4q4EwchS+7F9ltYvWH9gFJLU31mpXeMCj1NqiqRok/vSJLMYyOXOX/U4NcCGQqdr rBxoi/NhdYnYYA24MZd1OBw5znSl83nz2SkF6CIx3JBFvCsUZF388WpEawjIv9HbUMi7 74kAbe27/E++CVBnFh5qD4/RaUEi8V/L3L0jEYF37GjWGhTxBTxcSLUwbbphOqxmM86R IoWbsk4c4ZvBvV+sqrVUO+D1LqnLOHP9hd/KRkQpexaGl+cSOipFQQz1QDVmhlL3ZjuA QViw== 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=Y9LAhMI7yhCkqOWCqeEdKg7pECc3enz78Dn0k4Sy7n4=; b=D3stH0odsHHGC18YRy+WeMh26gxuvy5BlUr0vFPQrUuQZtIlG5PjHz+caI4BXNF4fO FNPBe1gxa2CAZZ+T+xpIp/8oTc/PlYm3653jTZXVCV6orBZrv0v0hLSkxsCQMUxOsVaR s8s3xgXeaSAiepcrCVOrmhStXRfBTv1lIp1PVFk8dH6jsPNBdBw9UpZdT1kda40C22T9 ixgHBzlaMTCgyofPb/0ESevjMpaPaXhkyfiVprVM/2jOtiRKDpXZSw6VI/eugA/RdHAU Uf6IJ1IBQkvC2YJg8vIPkNnj0riyw/3v4YX8/4/72GmCzB3IPYouUwq+a5iXcsj4o+UQ +SCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ONj6Qgwc; 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 m5si3312916pli.463.2017.12.14.07.34.20; Thu, 14 Dec 2017 07:34:20 -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=ONj6Qgwc; 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 S1753484AbdLNPeQ (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:16 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37900 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbdLNPeL (ORCPT ); Thu, 14 Dec 2017 10:34:11 -0500 Received: by mail-pf0-f196.google.com with SMTP id u25so3849279pfg.5 for ; Thu, 14 Dec 2017 07:34:11 -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=Y9LAhMI7yhCkqOWCqeEdKg7pECc3enz78Dn0k4Sy7n4=; b=ONj6QgwcwfOdoMBspKIyMoxw08QoDury4saq2+lCujRDwLtt+dq+R/6/zxMIeZHWUr rqp84geIiSaljK2AFHIOxCUHRwVaexv9e4Jgd9tLJGcwN+qizlR+MGk2CXsd/YKn/H7u IM9Bf8Vlt8vT/ADd43ijaOrYPqJxsjM4bb+qI= 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=Y9LAhMI7yhCkqOWCqeEdKg7pECc3enz78Dn0k4Sy7n4=; b=EFtn3NUlyx9U5TANUY82hh137EiyGuD++RfkqDgkhjGANulGRzZgnOwXqr9p8YXj2q x0qlZp5dl9NPemoqZfrVdranXe0NNigVt2xsVqF7AEnG/mZ6BsefPpPVPnHwiwCg4ryx zlq/yyusIrj67rtTYCl0VSDFJqOtSPApmp4aB0W7jsCGUk8sbtAswe51XIHqcHhRx5VB bXCOO8MwQimU54baMWRVNqhqElTH6dh5H4csLz73npE7DEkE/wcrLMVe4bpfsXFTymPs kMvOrBcV7afHyKOyrrAhLq8zu2TCQlfIqxg20VnVPjed5MOye8ktkPelMICwHFdwpxcM 4H9w== X-Gm-Message-State: AKGB3mLPQlQhA3erBoIQSkch+YEvAXyfAc1c0HRpibGMPq45J/t5ybVT N2XdDnnSIJHJhBBnLiSqsZp02w== X-Received: by 10.98.159.135 with SMTP id v7mr9929784pfk.162.1513265650931; Thu, 14 Dec 2017 07:34:10 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id r5sm7615942pgq.25.2017.12.14.07.34.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:10 -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 Subject: [PATCH V5 07/13] boot_constraint: Add debugfs support Date: Thu, 14 Dec 2017 21:03:14 +0530 Message-Id: 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 debugfs support for boot constraints. This is how it looks for a "vmmc-supply" constraint for the MMC device. $ ls -R /sys/kernel/debug/boot_constraints/ /sys/kernel/debug/boot_constraints/: f723d000.dwmmc0 /sys/kernel/debug/boot_constraints/f723d000.dwmmc0: clk-ciu pm-domain supply-vmmc supply-vmmcaux /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/clk-ciu: /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/pm-domain: /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/supply-vmmc: u_volt_max u_volt_min /sys/kernel/debug/boot_constraints/f723d000.dwmmc0/supply-vmmcaux: u_volt_max u_volt_min Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/boot_constraint/clk.c | 3 ++ drivers/boot_constraint/core.c | 59 ++++++++++++++++++++++++++++++++++++++++ drivers/boot_constraint/core.h | 6 ++++ drivers/boot_constraint/pm.c | 11 ++++++-- drivers/boot_constraint/supply.c | 9 ++++++ 5 files changed, 86 insertions(+), 2 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/boot_constraint/clk.c b/drivers/boot_constraint/clk.c index db22acff43e6..ebc871c29a83 100644 --- a/drivers/boot_constraint/clk.c +++ b/drivers/boot_constraint/clk.c @@ -46,6 +46,8 @@ int constraint_clk_add(struct constraint *constraint, void *data) cclk->clk_info.name = kstrdup_const(clk_info->name, GFP_KERNEL); constraint->private = cclk; + constraint_add_debugfs(constraint, clk_info->name); + return 0; put_clk: @@ -60,6 +62,7 @@ void constraint_clk_remove(struct constraint *constraint) { struct constraint_clk *cclk = constraint->private; + constraint_remove_debugfs(constraint); kfree_const(cclk->clk_info.name); clk_disable_unprepare(cclk->clk); clk_put(cclk->clk); diff --git a/drivers/boot_constraint/core.c b/drivers/boot_constraint/core.c index b36c02aa50c5..0350c5057ee5 100644 --- a/drivers/boot_constraint/core.c +++ b/drivers/boot_constraint/core.c @@ -21,6 +21,63 @@ static LIST_HEAD(constraint_devices); static DEFINE_MUTEX(constraint_devices_mutex); +/* Debugfs */ + +static struct dentry *rootdir; + +static void constraint_device_add_debugfs(struct constraint_dev *cdev) +{ + struct device *dev = cdev->dev; + + cdev->dentry = debugfs_create_dir(dev_name(dev), rootdir); +} + +static void constraint_device_remove_debugfs(struct constraint_dev *cdev) +{ + debugfs_remove_recursive(cdev->dentry); +} + +void constraint_add_debugfs(struct constraint *constraint, const char *suffix) +{ + struct device *dev = constraint->cdev->dev; + const char *prefix; + char name[NAME_MAX]; + + switch (constraint->type) { + case DEV_BOOT_CONSTRAINT_CLK: + prefix = "clk"; + break; + case DEV_BOOT_CONSTRAINT_PM: + prefix = "pm"; + break; + case DEV_BOOT_CONSTRAINT_SUPPLY: + prefix = "supply"; + break; + default: + dev_err(dev, "%s: Constraint type (%d) not supported\n", + __func__, constraint->type); + return; + } + + snprintf(name, NAME_MAX, "%s-%s", prefix, suffix); + + constraint->dentry = debugfs_create_dir(name, constraint->cdev->dentry); +} + +void constraint_remove_debugfs(struct constraint *constraint) +{ + debugfs_remove_recursive(constraint->dentry); +} + +static int __init constraint_debugfs_init(void) +{ + rootdir = debugfs_create_dir("boot_constraints", NULL); + + return 0; +} +core_initcall(constraint_debugfs_init); + + /* Boot constraints core */ static struct constraint_dev *constraint_device_find(struct device *dev) @@ -48,12 +105,14 @@ static struct constraint_dev *constraint_device_allocate(struct device *dev) INIT_LIST_HEAD(&cdev->constraints); list_add(&cdev->node, &constraint_devices); + constraint_device_add_debugfs(cdev); return cdev; } static void constraint_device_free(struct constraint_dev *cdev) { + constraint_device_remove_debugfs(cdev); list_del(&cdev->node); kfree(cdev); } diff --git a/drivers/boot_constraint/core.h b/drivers/boot_constraint/core.h index c5b27617b4ae..9dd481d38b99 100644 --- a/drivers/boot_constraint/core.h +++ b/drivers/boot_constraint/core.h @@ -7,6 +7,7 @@ #define _CORE_H #include +#include #include #include @@ -14,6 +15,7 @@ struct constraint_dev { struct device *dev; struct list_head node; struct list_head constraints; + struct dentry *dentry; }; struct constraint { @@ -22,12 +24,16 @@ struct constraint { enum dev_boot_constraint_type type; void (*free_resources)(void *data); void *free_resources_data; + struct dentry *dentry; int (*add)(struct constraint *constraint, void *data); void (*remove)(struct constraint *constraint); void *private; }; +void constraint_add_debugfs(struct constraint *constraint, const char *suffix); +void constraint_remove_debugfs(struct constraint *constraint); + /* Forward declarations of constraint specific callbacks */ int constraint_clk_add(struct constraint *constraint, void *data); void constraint_clk_remove(struct constraint *constraint); diff --git a/drivers/boot_constraint/pm.c b/drivers/boot_constraint/pm.c index 4950ec6b248b..584d3d46ef65 100644 --- a/drivers/boot_constraint/pm.c +++ b/drivers/boot_constraint/pm.c @@ -11,11 +11,18 @@ int constraint_pm_add(struct constraint *constraint, void *data) { struct device *dev = constraint->cdev->dev; + int ret; - return dev_pm_domain_attach(dev, true); + ret = dev_pm_domain_attach(dev, true); + if (ret) + return ret; + + constraint_add_debugfs(constraint, "domain"); + + return 0; } void constraint_pm_remove(struct constraint *constraint) { - /* Nothing to do for now */ + constraint_remove_debugfs(constraint); } diff --git a/drivers/boot_constraint/supply.c b/drivers/boot_constraint/supply.c index 916e5d6848d5..28fda60a0711 100644 --- a/drivers/boot_constraint/supply.c +++ b/drivers/boot_constraint/supply.c @@ -57,6 +57,14 @@ int constraint_supply_add(struct constraint *constraint, void *data) csupply->supply.name = kstrdup_const(supply->name, GFP_KERNEL); constraint->private = csupply; + constraint_add_debugfs(constraint, supply->name); + + debugfs_create_u32("u_volt_min", 0444, constraint->dentry, + &csupply->supply.u_volt_min); + + debugfs_create_u32("u_volt_max", 0444, constraint->dentry, + &csupply->supply.u_volt_max); + return 0; remove_voltage: @@ -77,6 +85,7 @@ void constraint_supply_remove(struct constraint *constraint) struct device *dev = constraint->cdev->dev; int ret; + constraint_remove_debugfs(constraint); kfree_const(supply->name); ret = regulator_disable(csupply->reg); From patchwork Thu Dec 14 15:33:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121983 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6962300qgn; Thu, 14 Dec 2017 07:35:58 -0800 (PST) X-Google-Smtp-Source: ACJfBotfKCKSh3cvs4KfYAxb0DfCMRTCZu5f5DOyFI90YEWiRyT/pOkZEhs6Ux8hf65EE96iK0g0 X-Received: by 10.99.126.11 with SMTP id z11mr8979010pgc.281.1513265758452; Thu, 14 Dec 2017 07:35:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265758; cv=none; d=google.com; s=arc-20160816; b=KGovKdZ15wmaZfOMC5fXxJRH8/KJESOVz5xubsuOhSTYBdjBvhN/GEiKpqowX+1Gi2 FwtiTRl5vUGngXPCDxzJVUUj9PN1ghsRqyL7nmOAklpZygU1eCNIrMc6ZOET8HRLSDR4 SEaqUaNLrsrvQtfbe5rmE1nhcBhFMEpLwjaxMmFseKzbwykkwUKTkWhcQ/Jk9U+I4ekY Fu4Gv2mBIOVRjY1NjyXCEq23Ifefw1wWlIxXKjC7/Fq+3y5Uupe5w1Lb8tB7TLu3N48k s5LDcvW6zYO3ZIy2dLrO3Khe2nE0IBZtnNFVHvruegSvCwCdT0dSZn+pMGNoxJL66AaQ W9nw== 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=AxixgptxoF1a5YSD7fnnHinY77lgikb7+X/JHXaO7Cs=; b=mMMXjyJ7Boqcp69mHKhbL6Tj/qvEOzop0VF4Gi+tmxJaKs/x9KYsHA1gs9ssvIfmSO TttUCVU29mWPhwlLbJoRQnloWOUu2eI3kMKrr4k4ir+D6Fo7MaHOv/vCcAlQ3IF1eJor X4CMyz6n2Mw7zBg7zg80Ns9sUWyoS3NfSlQ1IZB4uiCAgHMIISyG+g2qjtv54vtevijX dQ0o1rhCbGje8Op1B8MgTA3XoFgz1PIJ4OIUsgm65OHXRtYKTXk/s88iA6iekDzQvAIK iUoLluoTtkxC6IcYEozN1VQ5tFxRlW2NmaGB5Uewe91eAf1mgPYMPvivLFk0vMihINNu SA+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S4sj7M0A; 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 v4si3295862plb.791.2017.12.14.07.35.58; Thu, 14 Dec 2017 07:35:58 -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=S4sj7M0A; 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 S1753608AbdLNPfz (ORCPT + 19 others); Thu, 14 Dec 2017 10:35:55 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40479 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753403AbdLNPeO (ORCPT ); Thu, 14 Dec 2017 10:34:14 -0500 Received: by mail-pf0-f196.google.com with SMTP id v26so3852672pfl.7 for ; Thu, 14 Dec 2017 07:34:14 -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=AxixgptxoF1a5YSD7fnnHinY77lgikb7+X/JHXaO7Cs=; b=S4sj7M0AvFOIoGZR3ZoSyPX5Srj1WAf+twvh6GYCyOjbP5nhJYlxw7YCV9uQwJaZAz si+7/RU62mNgAfJcUerq8l9euiJi4b1PWw/9DLYcN9i2FVYWfmwCS0jMB3HUTfpfa0ya +JLaVk4wd1b8Q3LbEl8NTJoxPjOwdVXMSt8ic= 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=AxixgptxoF1a5YSD7fnnHinY77lgikb7+X/JHXaO7Cs=; b=JieauVsa3LM6O2vfjFJGZ4m6jOht15h72YeSBN60bnd5p6fwLi9FSZYn8cuu8HTVsh OC/hXn8/3L4eVlN+fpP22pMqIU/OoHJfOiCjXiCSaAGtAx4q3uRPEI99zU/QPsLvnwpu m4czy3jeQKwqNXN1gsR/K1oUUen3ooy3clz9+b3FnVuZHFXAmOF0GgipTK/o7YoivKCJ 7LeRlxI6JjLt93lq7Hqo+jTroSjLs707mViXHD6/yDOChg4nugt15aZc03wluKEVyUZd djAFC9FrEW6De+GbF3aNOfdiGYsprLjVPwlF0XzYIBx0o9OZV4Cm92jmGgx1mcSMLmi0 bgOA== X-Gm-Message-State: AKGB3mIgNpAlRFdWs4sLnLiWiDLraMdAh99pzNradJ3FH6KLVx8PYObo DlOO/Yk/cVbTXgXjaDQN0sESXA== X-Received: by 10.98.70.132 with SMTP id o4mr10205571pfi.102.1513265653867; Thu, 14 Dec 2017 07:34:13 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id r1sm8840463pfg.98.2017.12.14.07.34.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:13 -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 Subject: [PATCH V5 08/13] boot_constraint: Manage deferrable constraints Date: Thu, 14 Dec 2017 21:03:15 +0530 Message-Id: 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 It is possible that some of the resources aren't available at the time constraints are getting set and the boot constraints core will return -EPROBE_DEFER for them. In order to retry adding the constraints at a later point of time (after the resource is added and before any of its users come up), this patch proposes two things: - Each constraint is represented by a virtual platform device, so that it is re-probed again until the time all the dependencies aren't met. The platform device is removed along with the constraint, with help of the free_resources() callback. - Enable early defer probing support by calling driver_enable_deferred_probe(), so that the core retries probing deferred devices every time any device is bound to a driver. This makes sure that the constraint is set before any of the users of the resources come up. This is tested on ARM64 Hikey board where probe was deferred for a device. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/base/dd.c | 12 ++ drivers/boot_constraint/Makefile | 2 +- drivers/boot_constraint/deferrable_dev.c | 241 +++++++++++++++++++++++++++++++ include/linux/boot_constraint.h | 27 ++++ 4 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 drivers/boot_constraint/deferrable_dev.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/base/dd.c b/drivers/base/dd.c index dc89f98a2487..48a9945ff206 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -227,6 +227,18 @@ void device_unblock_probing(void) driver_deferred_probe_trigger(); } +/** + * driver_enable_deferred_probe() - Enable probing of deferred devices + * + * We don't want to get in the way when the bulk of drivers are getting probed + * and so deferred probe is disabled in the beginning. Enable it now because we + * need it. + */ +void driver_enable_deferred_probe(void) +{ + driver_deferred_probe_enable = true; +} + /** * deferred_probe_initcall() - Enable probing of deferred devices * diff --git a/drivers/boot_constraint/Makefile b/drivers/boot_constraint/Makefile index b7ade1a7afb5..a765094623a3 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 pm.o supply.o +obj-y := clk.o deferrable_dev.o core.o pm.o supply.o diff --git a/drivers/boot_constraint/deferrable_dev.c b/drivers/boot_constraint/deferrable_dev.c new file mode 100644 index 000000000000..158c04d41e09 --- /dev/null +++ b/drivers/boot_constraint/deferrable_dev.c @@ -0,0 +1,241 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ + +#include +#include +#include +#include +#include +#include + +#include "core.h" + +static DEFINE_IDA(pdev_index); + +void driver_enable_deferred_probe(void); + +struct boot_constraint_pdata { + struct device *dev; + struct dev_boot_constraint constraint; + int probe_failed; + int index; +}; + +static void boot_constraint_remove(void *data) +{ + struct platform_device *pdev = data; + struct boot_constraint_pdata *pdata = dev_get_platdata(&pdev->dev); + + ida_simple_remove(&pdev_index, pdata->index); + kfree(pdata->constraint.data); + platform_device_unregister(pdev); +} + +/* + * A platform device is added for each and every constraint, to handle + * -EPROBE_DEFER properly. + */ +static int boot_constraint_probe(struct platform_device *pdev) +{ + struct boot_constraint_pdata *pdata = dev_get_platdata(&pdev->dev); + struct dev_boot_constraint_info info; + int ret; + + if (WARN_ON(!pdata)) + return -EINVAL; + + info.constraint = pdata->constraint; + info.free_resources = boot_constraint_remove; + info.free_resources_data = pdev; + + ret = dev_boot_constraint_add(pdata->dev, &info); + if (ret) { + if (ret == -EPROBE_DEFER) + driver_enable_deferred_probe(); + else + pdata->probe_failed = ret; + } + + return ret; +} + +static struct platform_driver boot_constraint_driver = { + .driver = { + .name = "boot-constraints-dev", + }, + .probe = boot_constraint_probe, +}; + +static int __init boot_constraint_init(void) +{ + return platform_driver_register(&boot_constraint_driver); +} +core_initcall(boot_constraint_init); + +static int boot_constraint_add_dev(struct device *dev, + struct dev_boot_constraint *constraint) +{ + struct boot_constraint_pdata pdata = { + .dev = dev, + .constraint.type = constraint->type, + }; + struct platform_device *pdev; + struct boot_constraint_pdata *pdev_pdata; + int size, ret; + + switch (constraint->type) { + case DEV_BOOT_CONSTRAINT_CLK: + size = sizeof(struct dev_boot_constraint_clk_info); + break; + case DEV_BOOT_CONSTRAINT_PM: + size = 0; + break; + case DEV_BOOT_CONSTRAINT_SUPPLY: + size = sizeof(struct dev_boot_constraint_supply_info); + break; + default: + dev_err(dev, "%s: Constraint type (%d) not supported\n", + __func__, constraint->type); + return -EINVAL; + } + + /* Will be freed from boot_constraint_remove() */ + pdata.constraint.data = kmemdup(constraint->data, size, GFP_KERNEL); + if (!pdata.constraint.data) + return -ENOMEM; + + ret = ida_simple_get(&pdev_index, 0, 256, GFP_KERNEL); + if (ret < 0) { + dev_err(dev, "failed to allocate index (%d)\n", ret); + goto free; + } + + pdata.index = ret; + + pdev = platform_device_register_data(NULL, "boot-constraints-dev", ret, + &pdata, sizeof(pdata)); + if (IS_ERR(pdev)) { + dev_err(dev, "%s: Failed to create pdev (%ld)\n", __func__, + PTR_ERR(pdev)); + ret = PTR_ERR(pdev); + goto ida_remove; + } + + /* Release resources if probe has failed */ + pdev_pdata = dev_get_platdata(&pdev->dev); + if (pdev_pdata->probe_failed) { + ret = pdev_pdata->probe_failed; + goto remove_pdev; + } + + return 0; + +remove_pdev: + platform_device_unregister(pdev); +ida_remove: + ida_simple_remove(&pdev_index, pdata.index); +free: + kfree(pdata.constraint.data); + + return ret; +} + +static int dev_boot_constraint_add_deferrable(struct device *dev, + struct dev_boot_constraint *constraints, int count) +{ + int ret, i; + + for (i = 0; i < count; i++) { + ret = boot_constraint_add_dev(dev, &constraints[i]); + if (ret) + return ret; + } + + return 0; +} + +/* This only creates platform devices for now */ +static void add_deferrable_of_single(struct device_node *np, + struct dev_boot_constraint *constraints, + int count) +{ + struct device *dev; + int ret; + + if (!of_device_is_available(np)) + return; + + ret = of_platform_bus_create(np, NULL, NULL, NULL, false); + if (ret) + return; + + dev = of_find_any_device_by_node(np); + if (!dev) { + pr_err("Boot Constraints: Failed to find dev: %pOF\n", np); + return; + } + + ret = dev_boot_constraint_add_deferrable(dev, constraints, count); + if (ret) + dev_err(dev, "Failed to add boot constraint (%d)\n", ret); +} + +/* Not all compatible device nodes may have boot constraints */ +static bool node_has_boot_constraints(struct device_node *np, + struct dev_boot_constraint_of *oconst) +{ + int i; + + if (!oconst->dev_names) + return true; + + for (i = 0; i < oconst->dev_names_count; i++) { + if (!strcmp(oconst->dev_names[i], kbasename(np->full_name))) + return true; + } + + return false; +} + +/** + * dev_boot_constraint_add_deferrable_of: Adds all constraints for a platform. + * + * @oconst: This is an array of 'struct dev_boot_constraint_of', where each + * entry of the array is used to add one or more boot constraints across one or + * more devices having the same compatibility in the device tree. + * @count: Size of the 'oconst' array. + * + * This helper routine provides an easy way to add all boot constraints for a + * machine or platform. Just like dev_boot_constraint_add(), this must be called + * before the devices (to which we want to add constraints) are probed by their + * drivers, otherwise the boot constraint will never get removed for those + * devices and may result in unwanted behavior of the hardware. The boot + * constraints are removed by the driver core automatically after the devices + * are probed (successfully or unsuccessfully). + * + * This adds the boot constraints in a deferrable way and the caller need not + * worry about the availability of the resources required by the constraint. + * This routine will return successfully and the constraint will be added by the + * boot constraint core as soon as the resource is available at a later point in + * time. + */ +void dev_boot_constraint_add_deferrable_of(struct dev_boot_constraint_of *oconst, + int count) +{ + struct device_node *np; + int i; + + for (i = 0; i < count; i++) { + for_each_compatible_node(np, NULL, oconst[i].compat) { + if (!node_has_boot_constraints(np, &oconst[i])) + continue; + + add_deferrable_of_single(np, oconst[i].constraints, + oconst[i].count); + } + } +} +EXPORT_SYMBOL_GPL(dev_boot_constraint_add_deferrable_of); diff --git a/include/linux/boot_constraint.h b/include/linux/boot_constraint.h index 12fac0d565b0..ab752e19bfd0 100644 --- a/include/linux/boot_constraint.h +++ b/include/linux/boot_constraint.h @@ -79,16 +79,43 @@ struct dev_boot_constraint_info { void *free_resources_data; }; +/** + * struct dev_boot_constraint_of - This is used to add one or more boot + * constraints across one or more devices having the same compatibility in the + * device tree. + * + * @compat: This must match the compatible string of the devices to which we + * want to apply constraints. + * @constraints: This points to one or more boot constraints. + * @count: This contains the number of boot constraints pointed by the + * 'constraints' field. + * @dev_names: This is used to limit the application of boot constraints to only + * a subset of devices with matching compatibility. + * @dev_names_count: This is the number of devices pointed by the 'dev_names' + * array. + */ +struct dev_boot_constraint_of { + const char *compat; + struct dev_boot_constraint *constraints; + unsigned int count; + + const char * const *dev_names; + unsigned int dev_names_count; +}; + #ifdef CONFIG_DEV_BOOT_CONSTRAINT int dev_boot_constraint_add(struct device *dev, struct dev_boot_constraint_info *info); void dev_boot_constraints_remove(struct device *dev); +void dev_boot_constraint_add_deferrable_of(struct dev_boot_constraint_of *oconst, + int count); #else static inline int dev_boot_constraint_add(struct device *dev, struct dev_boot_constraint_info *info) { return 0; } static inline void dev_boot_constraints_remove(struct device *dev) {} +static inline void dev_boot_constraint_add_deferrable_of(struct dev_boot_constraint_of *oconst, int count) {} #endif /* CONFIG_DEV_BOOT_CONSTRAINT */ #endif /* _LINUX_BOOT_CONSTRAINT_H */ From patchwork Thu Dec 14 15:33:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121977 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6960454qgn; Thu, 14 Dec 2017 07:34:26 -0800 (PST) X-Google-Smtp-Source: ACJfBotJnzWWg7W3efey3oCr5Ybz50BoIPcdYBZVcNkSXJzJojrrnsNrKr4Z3SzW4yUYkth3Q+8m X-Received: by 10.98.39.68 with SMTP id n65mr9955518pfn.175.1513265666654; Thu, 14 Dec 2017 07:34:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265666; cv=none; d=google.com; s=arc-20160816; b=LsrqiIEfuF+MmgxgNcxKV4QSxzqGBLC5COlVluHzCQTLZs/KjtAJKIN2rMP5OPJOlq k778L+Ev8y/6qaCWw1BwJHb7GNTVfYkjTi39c8xtLPHz9CjgGQ7VNnPtRVMNkfppnULB oDapi0CIoKruvrd6Gu+PzWPdVRTsHTWN5q0EspTVacRGxW3uj8UG9prGu2C/4ZKtyeHF WyEFHfZVDR+sfxP2RcosBQvhr2VX0u7QAqmRIKfsU4hP2v1mLvSP2HdU7/DMC3kyfiot YHazHSvOge0Q01Sjr8suAkSBCNRLMOkcO1JyukzFcH5zVop/nEL7y3Uyhm89jeA8K/2u VkgA== 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=n4ehJD1+yKwW2AxoOUVUm5GlfZ51/lPswpnsFynL80s=; b=GPMgH4x5Py6j41HStVc2tELdMP7XENqgCx2U/CWn92sqRTYDB89XqPU66ynetNWS06 bPpDXsLwcAb6oc04DZLZEj4zA6aZHj+WR6uMOEfvVqnfyiQ9mE+Kh+oVUb5/T5mHFuAl YYIGCGwnCo9KEuMnpvjXvM+ssMw1coQ6uMK0H4e5AWe0bsEmK+gt+LANE53ekjYus/IV kWg2pioJQMC2mmXD3r0hkW3/v91iYgGcmepymtO3pCZUgzeyutYnqIO9eOPWRi4CP9rt N6oQZ/hK9mMspYX1XyOs9iAAdyqi5fa1jrREXrfasrzGSv8/jhk3+Coll8GDyM5zpYfD sUlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z1XEk+5P; 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 m5si3312916pli.463.2017.12.14.07.34.26; Thu, 14 Dec 2017 07:34:26 -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=Z1XEk+5P; 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 S1753499AbdLNPeY (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:24 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:37710 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbdLNPeR (ORCPT ); Thu, 14 Dec 2017 10:34:17 -0500 Received: by mail-pg0-f66.google.com with SMTP id y6so3631299pgp.4 for ; Thu, 14 Dec 2017 07:34:17 -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=n4ehJD1+yKwW2AxoOUVUm5GlfZ51/lPswpnsFynL80s=; b=Z1XEk+5Pu1CKWrec6nOcOvZDgoLPqzwQI+OU+S4VTF7r1w7gijlEOtgDyrhpOKCjW6 TFwlF/um/MtwOr3AGE+i45rzm1Wi/9SRGd2Jy/CqBVWlpX56U723dGy5A4rlsZOsEl3v EqVwYWR9JiLsQyZJk9rtvScqvdV1OnxbFsOoc= 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=n4ehJD1+yKwW2AxoOUVUm5GlfZ51/lPswpnsFynL80s=; b=tOrC/G0lSf7WFkQcc2vPwswvGMvckN7Eh+HM+CgA53YK2bZdVcLEEBjjtnSFNUBkwh DEMIWv3++zmwDGKCtZizEKltJwPE6gfZNe2NqDwGjFATz/X9O0dm9Rgwq6kMTEi/j2eM 7yGJtSq+g3pevzC1nio3ikpyYGjg33B2TcH+cClJGMeYnjDa7/+Tl8t1QkVms3GzLT8u hrhGx3+OeszMBif23xEUVipuJrSBfG0uWWPmy3F8G42iKdCuPUII4+HoMWvGeLdRV6vC TunowU0YV4ogIKpTiseVrkfGlyngHl9LZ0o34RUqYI3oQxnRCy4p064Ejwzwa+6TMOmC uh3w== X-Gm-Message-State: AKGB3mKc3xkWIfeLrzyfSgBGYeKv5IEHlWN/utZkTszvCzu/ph3kS6F1 pAMQkX52W8Nd+UnM2SBM2j+Kc7fhebg= X-Received: by 10.84.234.135 with SMTP id n7mr9478922plk.298.1513265656723; Thu, 14 Dec 2017 07:34:16 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id d66sm7975852pgc.67.2017.12.14.07.34.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:16 -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 Subject: [PATCH V5 09/13] boot_constraint: Add support for Hisilicon platforms Date: Thu, 14 Dec 2017 21:03:16 +0530 Message-Id: <7173cc03ee1ec160f6c0b4734dfdfcd4508ea9ff.1513264961.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 adds boot constraint support for Hisilicon platforms. Currently only one use case is supported: earlycon. One of the UART is enabled by the bootloader and is used for early console in the kernel. The boot constraint core handles it properly and removes constraints once the serial device is probed by its driver. This is tested on hi6220-hikey 96board. Signed-off-by: Viresh Kumar --- arch/arm64/Kconfig.platforms | 1 + drivers/boot_constraint/Makefile | 2 + drivers/boot_constraint/hikey.c | 158 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+) create mode 100644 drivers/boot_constraint/hikey.c -- 2.15.0.194.g9af6a3dea062 diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms index 2401373565ff..a586ed728393 100644 --- a/arch/arm64/Kconfig.platforms +++ b/arch/arm64/Kconfig.platforms @@ -87,6 +87,7 @@ config ARCH_HISI select ARM_TIMER_SP804 select HISILICON_IRQ_MBIGEN if PCI select PINCTRL + select DEV_BOOT_CONSTRAINT help This enables support for Hisilicon ARMv8 SoC family diff --git a/drivers/boot_constraint/Makefile b/drivers/boot_constraint/Makefile index a765094623a3..5609280162c4 100644 --- a/drivers/boot_constraint/Makefile +++ b/drivers/boot_constraint/Makefile @@ -1,3 +1,5 @@ # Makefile for device boot constraints obj-y := clk.o deferrable_dev.o core.o pm.o supply.o + +obj-$(CONFIG_ARCH_HISI) += hikey.o diff --git a/drivers/boot_constraint/hikey.c b/drivers/boot_constraint/hikey.c new file mode 100644 index 000000000000..25acb4070569 --- /dev/null +++ b/drivers/boot_constraint/hikey.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * This takes care of Hisilicon boot time device constraints, normally set by + * the Bootloader. + * + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ + +#include +#include +#include +#include + +static bool earlycon_boot_constraints_enabled __initdata; + +static int __init enable_earlycon_boot_constraints(char *str) +{ + earlycon_boot_constraints_enabled = true; + + return 0; +} + +__setup_param("earlycon", boot_constraint_earlycon, + enable_earlycon_boot_constraints, 0); +__setup_param("earlyprintk", boot_constraint_earlyprintk, + enable_earlycon_boot_constraints, 0); + + +struct hikey_machine_constraints { + struct dev_boot_constraint_of *dev_constraints; + unsigned int count; +}; + +static struct dev_boot_constraint_clk_info uart_iclk_info = { + .name = "uartclk", +}; + +static struct dev_boot_constraint_clk_info uart_pclk_info = { + .name = "apb_pclk", +}; + +static struct dev_boot_constraint hikey3660_uart_constraints[] = { + { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &uart_iclk_info, + }, { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &uart_pclk_info, + }, +}; + +static const char * const uarts_hikey3660[] = { + "serial@fff32000", /* UART 6 */ +}; + +static struct dev_boot_constraint_of hikey3660_dev_constraints[] = { + { + .compat = "arm,pl011", + .constraints = hikey3660_uart_constraints, + .count = ARRAY_SIZE(hikey3660_uart_constraints), + + .dev_names = uarts_hikey3660, + .dev_names_count = ARRAY_SIZE(uarts_hikey3660), + }, +}; + +static struct hikey_machine_constraints hikey3660_constraints = { + .dev_constraints = hikey3660_dev_constraints, + .count = ARRAY_SIZE(hikey3660_dev_constraints), +}; + +static const char * const uarts_hikey6220[] = { + "uart@f7113000", /* UART 3 */ +}; + +static struct dev_boot_constraint_of hikey6220_dev_constraints[] = { + { + .compat = "arm,pl011", + .constraints = hikey3660_uart_constraints, + .count = ARRAY_SIZE(hikey3660_uart_constraints), + + .dev_names = uarts_hikey6220, + .dev_names_count = ARRAY_SIZE(uarts_hikey6220), + }, +}; + +static struct hikey_machine_constraints hikey6220_constraints = { + .dev_constraints = hikey6220_dev_constraints, + .count = ARRAY_SIZE(hikey6220_dev_constraints), +}; + +static struct dev_boot_constraint hikey3798cv200_uart_constraints[] = { + { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &uart_pclk_info, + }, +}; + +static const char * const uarts_hikey3798cv200[] = { + "serial@8b00000", /* UART 0 */ +}; + +static struct dev_boot_constraint_of hikey3798cv200_dev_constraints[] = { + { + .compat = "arm,pl011", + .constraints = hikey3798cv200_uart_constraints, + .count = ARRAY_SIZE(hikey3798cv200_uart_constraints), + + .dev_names = uarts_hikey3798cv200, + .dev_names_count = ARRAY_SIZE(uarts_hikey3798cv200), + }, +}; + +static struct hikey_machine_constraints hikey3798cv200_constraints = { + .dev_constraints = hikey3798cv200_dev_constraints, + .count = ARRAY_SIZE(hikey3798cv200_dev_constraints), +}; + +static const struct of_device_id machines[] __initconst = { + { .compatible = "hisilicon,hi3660", .data = &hikey3660_constraints }, + { .compatible = "hisilicon,hi3798cv200", .data = &hikey3798cv200_constraints }, + { .compatible = "hisilicon,hi6220", .data = &hikey6220_constraints }, + { } +}; + +static int __init hikey_constraints_init(void) +{ + const struct hikey_machine_constraints *constraints; + const struct of_device_id *match; + struct device_node *np; + + if (!earlycon_boot_constraints_enabled) + return 0; + + np = of_find_node_by_path("/"); + if (!np) + return -ENODEV; + + match = of_match_node(machines, np); + of_node_put(np); + + if (!match) + return 0; + + constraints = match->data; + + dev_boot_constraint_add_deferrable_of(constraints->dev_constraints, + constraints->count); + + return 0; +} + +/* + * The amba-pl011 driver registers itself from arch_initcall level. Setup the + * serial boot constraints before that in order not to miss any boot messages. + */ +postcore_initcall_sync(hikey_constraints_init); From patchwork Thu Dec 14 15:33:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121981 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6961630qgn; Thu, 14 Dec 2017 07:35:25 -0800 (PST) X-Google-Smtp-Source: ACJfBotI3E5fTOXeePr7tIGt8ywbSPPhKLnabxNCyTwZNF9ADoIONwzAjlY7LNvzEnKQsBG6jScx X-Received: by 10.159.198.148 with SMTP id g20mr9796641plo.89.1513265724959; Thu, 14 Dec 2017 07:35:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265724; cv=none; d=google.com; s=arc-20160816; b=Tg63T9szfDD8sz/SNM5BBdxcWpObTe9J8SxLW2m0+bHmgc/a2nNATFkNn1yPyMyySU f+UHw/pf4FPhAqnD2Qv/HLDO1GrTBrgnQK2oImznqKOsFCs1+k5yU0C0bIvJWpjfGtI0 Vh2mYqSBmQwiOuQCfveeg/uphMvxcf904Lk0Lj8fnwRjkH9H0pE6omuRf+3PSN4mPhD3 mMPGksIjs7PzA5CZ172qtlLTe9xWQM0T4EIL4U7Js+lZAw98senR4NAYChsYcWimtIv2 dnAJUfg0VKgLvBo8eudUIrbZwh+p3xx2daU4c30ps/XbuG44HQE2x9LPRrdZ0elf8pRX WPGg== 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=hUnDVCsM+3mG1cw0Vh2Qci495u5SCUtGl9LwwWeOOr0=; b=RaSZmgHcmTKiCPnbmgXR3yCPfHULtCOUfxYWwOsA2hkcp50v0KdyCt4N65dMio2DBM EZGJqDi0tw6vuJ2KR9ejMwKLGxO+ZhHvqZA2chRUz9OZLf8hl9W9p5M01oW6wkoU4j7+ SIXc/k04LJoRJEyPwJtY4XY5MArSLxOOiC2jA4MKxs4dCjxZygt78jWHW3+Snh/8YTEB Xy79ndp2VxB8t883XLJdr8JF2JJ9Rfl44z1XWPV/TyM4aDXQNE2glXWL0f+tpmOexQAK Zzaht/tc4S9Y2GX99T7hT/WrelRqn3AFpFWl/Mav3iJ/zkE7Jp1KwYOWo8OjkefvkfCb 9mzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SF2vWSd1; 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 c26si3412776pfh.105.2017.12.14.07.35.24; Thu, 14 Dec 2017 07:35:24 -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=SF2vWSd1; 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 S1753576AbdLNPfV (ORCPT + 19 others); Thu, 14 Dec 2017 10:35:21 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37914 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753370AbdLNPeU (ORCPT ); Thu, 14 Dec 2017 10:34:20 -0500 Received: by mail-pf0-f196.google.com with SMTP id u25so3849581pfg.5 for ; Thu, 14 Dec 2017 07:34:20 -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=hUnDVCsM+3mG1cw0Vh2Qci495u5SCUtGl9LwwWeOOr0=; b=SF2vWSd15jKaglRWNVG0We9sHcBOLWEE8eaPggI7SJ//Xo69zmTldHQyAAq0ovJe9L WYnB9ZRqNyu671dLmiBDbFstn8hwFY4KhVEk0f6wHamrJPv9cM1pmqfe2yx/lsPk95Yk VHN+mFtAzjc/qK4GaIToA69C0pcGzgblWxRts= 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=hUnDVCsM+3mG1cw0Vh2Qci495u5SCUtGl9LwwWeOOr0=; b=NoCI4TDm3LyXunWz2oqyk7127Vkiu+q4scDl6P3rdmrD4iY4iaVBJhZMRhwIIYqzdX zw7JDKIaRUI0DVoZ26zG47aAHZKE2Nl9bRXe8zd6dF5CtVVNNXuAk8FMkPmx0REOgn16 +SQJf2gVU4CPuBv1n0wf2qhkUYQpPZ38SOBzBuurl+cxOc7z7URWSRRr6Hw/2rduQOI4 sZPswZ4QEHykozGay3ZMU9/Q50Tm02ZGfV2iy+nyB8csJJXwBFSPlftdcq6UZnd1Y5Oc L31+/dNXfStwDRdgSNPhygSSZU7MXjdQJCNouBfA7hDX4ZciS5lBoNvUdNoLTMUs0DLw FT8w== X-Gm-Message-State: AKGB3mIHg3+ZLkuZ8RbMyCIf4jNXasPLlZqGBT6TaLm/f2XLUfuS3EK+ HKabdr3422RIMGDBPP9/R0bGUQ== X-Received: by 10.98.62.17 with SMTP id l17mr10050999pfa.83.1513265659583; Thu, 14 Dec 2017 07:34:19 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id x6sm9110967pff.55.2017.12.14.07.34.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:18 -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 Subject: [PATCH V5 10/13] boot_constraint: Add support for IMX platform Date: Thu, 14 Dec 2017 21:03:17 +0530 Message-Id: <1b1a15d5a39e26a5e4a3d1b18473bdbc8d1dd95f.1513264961.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 adds boot constraint support for IMX platforms. Currently only one use case is supported: earlycon. Some of the UARTs are enabled by the bootloader and are used for early console in the kernel. The boot constraint core handles them properly and removes them once the serial device is probed by its driver. This gets rid of lots of hacky code in the clock drivers. Signed-off-by: Viresh Kumar --- arch/arm/mach-imx/Kconfig | 1 + drivers/boot_constraint/Makefile | 1 + drivers/boot_constraint/imx.c | 126 ++++++++++++++++++++++++++++++++++++++ drivers/clk/imx/clk-imx25.c | 12 ---- drivers/clk/imx/clk-imx27.c | 13 ---- drivers/clk/imx/clk-imx31.c | 12 ---- drivers/clk/imx/clk-imx35.c | 10 --- drivers/clk/imx/clk-imx51-imx53.c | 16 ----- drivers/clk/imx/clk-imx6q.c | 8 --- drivers/clk/imx/clk-imx6sl.c | 8 --- drivers/clk/imx/clk-imx6sx.c | 8 --- drivers/clk/imx/clk-imx7d.c | 14 ----- drivers/clk/imx/clk.c | 38 ------------ drivers/clk/imx/clk.h | 1 - 14 files changed, 128 insertions(+), 140 deletions(-) create mode 100644 drivers/boot_constraint/imx.c -- 2.15.0.194.g9af6a3dea062 diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 782699e67600..f4d505fed092 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -4,6 +4,7 @@ menuconfig ARCH_MXC select ARCH_SUPPORTS_BIG_ENDIAN select CLKSRC_IMX_GPT select GENERIC_IRQ_CHIP + select DEV_BOOT_CONSTRAINT select GPIOLIB select PINCTRL select PM_OPP if PM diff --git a/drivers/boot_constraint/Makefile b/drivers/boot_constraint/Makefile index 5609280162c4..f3e123b5d854 100644 --- a/drivers/boot_constraint/Makefile +++ b/drivers/boot_constraint/Makefile @@ -3,3 +3,4 @@ obj-y := clk.o deferrable_dev.o core.o pm.o supply.o obj-$(CONFIG_ARCH_HISI) += hikey.o +obj-$(CONFIG_ARCH_MXC) += imx.o diff --git a/drivers/boot_constraint/imx.c b/drivers/boot_constraint/imx.c new file mode 100644 index 000000000000..a4f3af33ba86 --- /dev/null +++ b/drivers/boot_constraint/imx.c @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * This takes care of IMX boot time device constraints, normally set by the + * Bootloader. + * + * Copyright (C) 2017 Linaro. + * Viresh Kumar + */ + +#include +#include +#include +#include + +static bool earlycon_boot_constraints_enabled __initdata; + +static int __init enable_earlycon_boot_constraints(char *str) +{ + earlycon_boot_constraints_enabled = true; + + return 0; +} + +__setup_param("earlycon", boot_constraint_earlycon, + enable_earlycon_boot_constraints, 0); +__setup_param("earlyprintk", boot_constraint_earlyprintk, + enable_earlycon_boot_constraints, 0); + + +struct imx_machine_constraints { + struct dev_boot_constraint_of *dev_constraints; + unsigned int count; +}; + +static struct dev_boot_constraint_clk_info uart_ipg_clk_info = { + .name = "ipg", +}; + +static struct dev_boot_constraint_clk_info uart_per_clk_info = { + .name = "per", +}; + +static struct dev_boot_constraint imx_uart_constraints[] = { + { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &uart_ipg_clk_info, + }, { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &uart_per_clk_info, + }, +}; + +static struct dev_boot_constraint_of imx_dev_constraints[] = { + { + .compat = "fsl,imx21-uart", + .constraints = imx_uart_constraints, + .count = ARRAY_SIZE(imx_uart_constraints), + }, +}; + +static struct imx_machine_constraints imx_constraints = { + .dev_constraints = imx_dev_constraints, + .count = ARRAY_SIZE(imx_dev_constraints), +}; + +/* imx7 */ +static struct dev_boot_constraint_of imx7_dev_constraints[] = { + { + .compat = "fsl,imx6q-uart", + .constraints = imx_uart_constraints, + .count = ARRAY_SIZE(imx_uart_constraints), + }, +}; + +static struct imx_machine_constraints imx7_constraints = { + .dev_constraints = imx7_dev_constraints, + .count = ARRAY_SIZE(imx7_dev_constraints), +}; + +static const struct of_device_id machines[] __initconst = { + { .compatible = "fsl,imx25", .data = &imx_constraints }, + { .compatible = "fsl,imx27", .data = &imx_constraints }, + { .compatible = "fsl,imx31", .data = &imx_constraints }, + { .compatible = "fsl,imx35", .data = &imx_constraints }, + { .compatible = "fsl,imx50", .data = &imx_constraints }, + { .compatible = "fsl,imx51", .data = &imx_constraints }, + { .compatible = "fsl,imx53", .data = &imx_constraints }, + { .compatible = "fsl,imx6dl", .data = &imx_constraints }, + { .compatible = "fsl,imx6q", .data = &imx_constraints }, + { .compatible = "fsl,imx6qp", .data = &imx_constraints }, + { .compatible = "fsl,imx6sl", .data = &imx_constraints }, + { .compatible = "fsl,imx6sx", .data = &imx_constraints }, + { .compatible = "fsl,imx6ul", .data = &imx_constraints }, + { .compatible = "fsl,imx6ull", .data = &imx_constraints }, + { .compatible = "fsl,imx7d", .data = &imx7_constraints }, + { .compatible = "fsl,imx7s", .data = &imx7_constraints }, + { } +}; + +static int __init imx_constraints_init(void) +{ + const struct imx_machine_constraints *constraints; + const struct of_device_id *match; + struct device_node *np; + + if (!earlycon_boot_constraints_enabled) + return 0; + + np = of_find_node_by_path("/"); + if (!np) + return -ENODEV; + + match = of_match_node(machines, np); + of_node_put(np); + + if (!match) + return 0; + + constraints = match->data; + + dev_boot_constraint_add_deferrable_of(constraints->dev_constraints, + constraints->count); + + return 0; +} +subsys_initcall(imx_constraints_init); diff --git a/drivers/clk/imx/clk-imx25.c b/drivers/clk/imx/clk-imx25.c index 23686f756b5e..4df652cd912c 100644 --- a/drivers/clk/imx/clk-imx25.c +++ b/drivers/clk/imx/clk-imx25.c @@ -86,16 +86,6 @@ enum mx25_clks { static struct clk *clk[clk_max]; -static struct clk ** const uart_clks[] __initconst = { - &clk[uart_ipg_per], - &clk[uart1_ipg], - &clk[uart2_ipg], - &clk[uart3_ipg], - &clk[uart4_ipg], - &clk[uart5_ipg], - NULL -}; - static int __init __mx25_clocks_init(void __iomem *ccm_base) { BUG_ON(!ccm_base); @@ -241,8 +231,6 @@ static int __init __mx25_clocks_init(void __iomem *ccm_base) */ clk_set_parent(clk[cko_sel], clk[ipg]); - imx_register_uart_clocks(uart_clks); - return 0; } diff --git a/drivers/clk/imx/clk-imx27.c b/drivers/clk/imx/clk-imx27.c index 0a0ab95d16fe..379709d21b04 100644 --- a/drivers/clk/imx/clk-imx27.c +++ b/drivers/clk/imx/clk-imx27.c @@ -48,17 +48,6 @@ static const char *ssi_sel_clks[] = { "spll_gate", "mpll", }; static struct clk *clk[IMX27_CLK_MAX]; static struct clk_onecell_data clk_data; -static struct clk ** const uart_clks[] __initconst = { - &clk[IMX27_CLK_PER1_GATE], - &clk[IMX27_CLK_UART1_IPG_GATE], - &clk[IMX27_CLK_UART2_IPG_GATE], - &clk[IMX27_CLK_UART3_IPG_GATE], - &clk[IMX27_CLK_UART4_IPG_GATE], - &clk[IMX27_CLK_UART5_IPG_GATE], - &clk[IMX27_CLK_UART6_IPG_GATE], - NULL -}; - static void __init _mx27_clocks_init(unsigned long fref) { BUG_ON(!ccm); @@ -175,8 +164,6 @@ static void __init _mx27_clocks_init(unsigned long fref) clk_prepare_enable(clk[IMX27_CLK_EMI_AHB_GATE]); - imx_register_uart_clocks(uart_clks); - imx_print_silicon_rev("i.MX27", mx27_revision()); } diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c index cbce308aad04..d0a720b61aca 100644 --- a/drivers/clk/imx/clk-imx31.c +++ b/drivers/clk/imx/clk-imx31.c @@ -63,16 +63,6 @@ enum mx31_clks { static struct clk *clk[clk_max]; static struct clk_onecell_data clk_data; -static struct clk ** const uart_clks[] __initconst = { - &clk[ipg], - &clk[uart1_gate], - &clk[uart2_gate], - &clk[uart3_gate], - &clk[uart4_gate], - &clk[uart5_gate], - NULL -}; - static void __init _mx31_clocks_init(void __iomem *base, unsigned long fref) { clk[dummy] = imx_clk_fixed("dummy", 0); @@ -208,8 +198,6 @@ int __init mx31_clocks_init(unsigned long fref) clk_register_clkdev(clk[sdma_gate], NULL, "imx31-sdma"); clk_register_clkdev(clk[iim_gate], "iim", NULL); - - imx_register_uart_clocks(uart_clks); mxc_timer_init(MX31_GPT1_BASE_ADDR, MX31_INT_GPT, GPT_TYPE_IMX31); return 0; diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c index 203cad6c9aab..081aacd2335b 100644 --- a/drivers/clk/imx/clk-imx35.c +++ b/drivers/clk/imx/clk-imx35.c @@ -86,14 +86,6 @@ enum mx35_clks { static struct clk *clk[clk_max]; -static struct clk ** const uart_clks[] __initconst = { - &clk[ipg], - &clk[uart1_gate], - &clk[uart2_gate], - &clk[uart3_gate], - NULL -}; - static void __init _mx35_clocks_init(void) { void __iomem *base; @@ -247,8 +239,6 @@ static void __init _mx35_clocks_init(void) */ clk_prepare_enable(clk[scc_gate]); - imx_register_uart_clocks(uart_clks); - imx_print_silicon_rev("i.MX35", mx35_revision()); } diff --git a/drivers/clk/imx/clk-imx51-imx53.c b/drivers/clk/imx/clk-imx51-imx53.c index 7bcaf270db11..2da06f8ffae1 100644 --- a/drivers/clk/imx/clk-imx51-imx53.c +++ b/drivers/clk/imx/clk-imx51-imx53.c @@ -131,20 +131,6 @@ static const char *ieee1588_sels[] = { "pll3_sw", "pll4_sw", "dummy" /* usbphy2_ static struct clk *clk[IMX5_CLK_END]; static struct clk_onecell_data clk_data; -static struct clk ** const uart_clks[] __initconst = { - &clk[IMX5_CLK_UART1_IPG_GATE], - &clk[IMX5_CLK_UART1_PER_GATE], - &clk[IMX5_CLK_UART2_IPG_GATE], - &clk[IMX5_CLK_UART2_PER_GATE], - &clk[IMX5_CLK_UART3_IPG_GATE], - &clk[IMX5_CLK_UART3_PER_GATE], - &clk[IMX5_CLK_UART4_IPG_GATE], - &clk[IMX5_CLK_UART4_PER_GATE], - &clk[IMX5_CLK_UART5_IPG_GATE], - &clk[IMX5_CLK_UART5_PER_GATE], - NULL -}; - static void __init mx5_clocks_common_init(void __iomem *ccm_base) { clk[IMX5_CLK_DUMMY] = imx_clk_fixed("dummy", 0); @@ -325,8 +311,6 @@ static void __init mx5_clocks_common_init(void __iomem *ccm_base) clk_prepare_enable(clk[IMX5_CLK_TMAX1]); clk_prepare_enable(clk[IMX5_CLK_TMAX2]); /* esdhc2, fec */ clk_prepare_enable(clk[IMX5_CLK_TMAX3]); /* esdhc1, esdhc4 */ - - imx_register_uart_clocks(uart_clks); } static void __init mx50_clocks_init(struct device_node *np) diff --git a/drivers/clk/imx/clk-imx6q.c b/drivers/clk/imx/clk-imx6q.c index 8d518ad5dc13..255f571c0b0d 100644 --- a/drivers/clk/imx/clk-imx6q.c +++ b/drivers/clk/imx/clk-imx6q.c @@ -150,12 +150,6 @@ static inline int clk_on_imx6dl(void) return of_machine_is_compatible("fsl,imx6dl"); } -static struct clk ** const uart_clks[] __initconst = { - &clk[IMX6QDL_CLK_UART_IPG], - &clk[IMX6QDL_CLK_UART_SERIAL], - NULL -}; - static int ldb_di_sel_by_clock_id(int clock_id) { switch (clock_id) { @@ -918,7 +912,5 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) clk_set_parent(clk[IMX6QDL_CLK_GPU2D_CORE_SEL], clk[IMX6QDL_CLK_PLL3_USB_OTG]); } - - imx_register_uart_clocks(uart_clks); } CLK_OF_DECLARE(imx6q, "fsl,imx6q-ccm", imx6q_clocks_init); diff --git a/drivers/clk/imx/clk-imx6sl.c b/drivers/clk/imx/clk-imx6sl.c index 9642cdf0fb88..97ab67783609 100644 --- a/drivers/clk/imx/clk-imx6sl.c +++ b/drivers/clk/imx/clk-imx6sl.c @@ -185,12 +185,6 @@ void imx6sl_set_wait_clk(bool enter) imx6sl_enable_pll_arm(false); } -static struct clk ** const uart_clks[] __initconst = { - &clks[IMX6SL_CLK_UART], - &clks[IMX6SL_CLK_UART_SERIAL], - NULL -}; - static void __init imx6sl_clocks_init(struct device_node *ccm_node) { struct device_node *np; @@ -447,7 +441,5 @@ static void __init imx6sl_clocks_init(struct device_node *ccm_node) clk_set_parent(clks[IMX6SL_CLK_LCDIF_AXI_SEL], clks[IMX6SL_CLK_PLL2_PFD2]); - - imx_register_uart_clocks(uart_clks); } CLK_OF_DECLARE(imx6sl, "fsl,imx6sl-ccm", imx6sl_clocks_init); diff --git a/drivers/clk/imx/clk-imx6sx.c b/drivers/clk/imx/clk-imx6sx.c index e6d389e333d7..e38dfb855ae8 100644 --- a/drivers/clk/imx/clk-imx6sx.c +++ b/drivers/clk/imx/clk-imx6sx.c @@ -137,12 +137,6 @@ static u32 share_count_ssi3; static u32 share_count_sai1; static u32 share_count_sai2; -static struct clk ** const uart_clks[] __initconst = { - &clks[IMX6SX_CLK_UART_IPG], - &clks[IMX6SX_CLK_UART_SERIAL], - NULL -}; - static void __init imx6sx_clocks_init(struct device_node *ccm_node) { struct device_node *np; @@ -566,7 +560,5 @@ static void __init imx6sx_clocks_init(struct device_node *ccm_node) clk_set_parent(clks[IMX6SX_CLK_QSPI1_SEL], clks[IMX6SX_CLK_PLL2_BUS]); clk_set_parent(clks[IMX6SX_CLK_QSPI2_SEL], clks[IMX6SX_CLK_PLL2_BUS]); - - imx_register_uart_clocks(uart_clks); } CLK_OF_DECLARE(imx6sx, "fsl,imx6sx-ccm", imx6sx_clocks_init); diff --git a/drivers/clk/imx/clk-imx7d.c b/drivers/clk/imx/clk-imx7d.c index 80dc211eb74b..91e5bda48df2 100644 --- a/drivers/clk/imx/clk-imx7d.c +++ b/drivers/clk/imx/clk-imx7d.c @@ -387,17 +387,6 @@ static int const clks_init_on[] __initconst = { static struct clk_onecell_data clk_data; -static struct clk ** const uart_clks[] __initconst = { - &clks[IMX7D_UART1_ROOT_CLK], - &clks[IMX7D_UART2_ROOT_CLK], - &clks[IMX7D_UART3_ROOT_CLK], - &clks[IMX7D_UART4_ROOT_CLK], - &clks[IMX7D_UART5_ROOT_CLK], - &clks[IMX7D_UART6_ROOT_CLK], - &clks[IMX7D_UART7_ROOT_CLK], - NULL -}; - static void __init imx7d_clocks_init(struct device_node *ccm_node) { struct device_node *np; @@ -884,8 +873,5 @@ static void __init imx7d_clocks_init(struct device_node *ccm_node) /* set uart module clock's parent clock source that must be great then 80MHz */ clk_set_parent(clks[IMX7D_UART1_ROOT_SRC], clks[IMX7D_OSC_24M_CLK]); - - imx_register_uart_clocks(uart_clks); - } CLK_OF_DECLARE(imx7d, "fsl,imx7d-ccm", imx7d_clocks_init); diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c index 9074e6974b6d..d8a64367a061 100644 --- a/drivers/clk/imx/clk.c +++ b/drivers/clk/imx/clk.c @@ -74,41 +74,3 @@ void imx_cscmr1_fixup(u32 *val) *val ^= CSCMR1_FIXUP; return; } - -static int imx_keep_uart_clocks __initdata; -static struct clk ** const *imx_uart_clocks __initdata; - -static int __init imx_keep_uart_clocks_param(char *str) -{ - imx_keep_uart_clocks = 1; - - return 0; -} -__setup_param("earlycon", imx_keep_uart_earlycon, - imx_keep_uart_clocks_param, 0); -__setup_param("earlyprintk", imx_keep_uart_earlyprintk, - imx_keep_uart_clocks_param, 0); - -void __init imx_register_uart_clocks(struct clk ** const clks[]) -{ - if (imx_keep_uart_clocks) { - int i; - - imx_uart_clocks = clks; - for (i = 0; imx_uart_clocks[i]; i++) - clk_prepare_enable(*imx_uart_clocks[i]); - } -} - -static int __init imx_clk_disable_uart(void) -{ - if (imx_keep_uart_clocks && imx_uart_clocks) { - int i; - - for (i = 0; imx_uart_clocks[i]; i++) - clk_disable_unprepare(*imx_uart_clocks[i]); - } - - return 0; -} -late_initcall_sync(imx_clk_disable_uart); diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h index d69c4bbf3597..c5edde073cea 100644 --- a/drivers/clk/imx/clk.h +++ b/drivers/clk/imx/clk.h @@ -8,7 +8,6 @@ extern spinlock_t imx_ccm_lock; void imx_check_clocks(struct clk *clks[], unsigned int count); -void imx_register_uart_clocks(struct clk ** const clks[]); extern void imx_cscmr1_fixup(u32 *val); From patchwork Thu Dec 14 15:33:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121979 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6960961qgn; Thu, 14 Dec 2017 07:34:51 -0800 (PST) X-Google-Smtp-Source: ACJfBoucRTIDfwouzX7b653qNromOvNtpJK7cU5U2TCyKQS7L7cGNcah+8+J0U79zsBaFRKnRRHu X-Received: by 10.84.252.137 with SMTP id y9mr9737442pll.153.1513265690847; Thu, 14 Dec 2017 07:34:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265690; cv=none; d=google.com; s=arc-20160816; b=LOXXaznWkm8HZYjVD3uo03V+cfjfQcUAtY7c8xHPE7yzYhJLqu7v2eUYegsAjwLdaT G9sJA+CNIWxYu7+RMND2WaYaiwvhCa5pIu1fUmxZGL+RRO7Smbapps3z777Cg5aDiCyI fjFUI/PfLE1izpZN7/KdKxsvqSpGlGEzDrZJ5mi0kqyqLNejuI7SWyr8e+JDOk9QJ4xJ zlgxaXjWXbRHaMbMF5Fe/g5m5tYIF9Eym6Lh3/3A1/x7//TJdYC+lrIXJtriNWhDouuh vp7XsWkFvWjH2Q0aQ8ZZN9nGwseKicKTxOOsYiyc3ea3q67HMC2PEUzk039Hsz2nGHVN caaA== 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=SjXMPtCgr7kmgW6Sc3OPuAZH24KsIrVGddQxvD6R5y0=; b=zrWFD6YDP8XeFXzfIBjphkWe5CE1joURQRJeDo+ZgekV188Q/ZNwPJR4QaDNN+/h8q cNy35j8aB1kX4OsSTAlsArjNEM0XEvEbWROx882E/SNx0yNs+q8qlsJLCGJtrBpFJ8V/ KOrjJJQrzXiNklU3i0ePdY5goTfMf6chliZoiRAKo6l57ak3qnrLf1s6GfyfNUFBHzna Js4orz32SN922sVu77nfmXCFYNpJ+DHH9wbHfc/isu6nXgoEM0sjJcS0vtL1/88s8o2w ntw7CMSBRjP6XspgGWVkuUl+Vlj5M6K6+WE5ZHbh8yhr1S6xqe8s4KNUBnHe/SoZLhCr 72Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LI+oPMH4; 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 c26si3412776pfh.105.2017.12.14.07.34.50; Thu, 14 Dec 2017 07:34:50 -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=LI+oPMH4; 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 S1753550AbdLNPeq (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:46 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34356 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753488AbdLNPeX (ORCPT ); Thu, 14 Dec 2017 10:34:23 -0500 Received: by mail-pf0-f196.google.com with SMTP id a90so3862401pfk.1 for ; Thu, 14 Dec 2017 07:34: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=SjXMPtCgr7kmgW6Sc3OPuAZH24KsIrVGddQxvD6R5y0=; b=LI+oPMH4R9c2x7tUfCZ45Gcatv9F0d5zcKlhxNoKKdVDMP1kevEWhK+MOKho5LFrCg AEclw8sYgQTLaRLitS37tHsVfiDJjW025jP7RVTRd2fx+hcphXbvvBiTkoV6/P51ZjsW gApQPA0yE4y9lbbZ8Wjud7nUtxbIKjNwNMV14= 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=SjXMPtCgr7kmgW6Sc3OPuAZH24KsIrVGddQxvD6R5y0=; b=ay02YL92gSjlCPsMYG8Ve64ikj4HeboMf3hB9a1qvXA+Dbx8n+GFlDLlYdtCd9ysR8 UTu3izFHjojZN8Gkc1K3TVAmZCRjFSoOqqzS4Y8rDvO5NatYmepZLpuIAijU50HvrO03 yyee54OYQF5MXyvYBm1sROkr1Sgm+aehUlRZtobN2uluHzlgEhAIww/Kp4QaGKYW7A9P bcxpVil9HzyHxElpgIVzsVFaJ/py/QlnoN5aOZMF13JqpvQPzU6Mp7SvfYJG85pLU4xp DPiq+rfp+KO/j6exbD583JGPJR68SvDKNfMQYHC1pB+RGjskHdzzUwVFoK6aORpBlG+N qqRw== X-Gm-Message-State: AKGB3mJmBo9pNem1rm+AAiVEUffLcqkdZPTwokdTi1EFuuPLLgR7tAPM i8woY98KEQ4KlVG7k4onVHFbmw== X-Received: by 10.101.81.72 with SMTP id g8mr8930870pgq.135.1513265662413; Thu, 14 Dec 2017 07:34:22 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id b25sm9241551pfd.182.2017.12.14.07.34.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:21 -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 Subject: [PATCH V5 11/13] boot_constraint: Add Qualcomm display controller constraints Date: Thu, 14 Dec 2017 21:03:18 +0530 Message-Id: <22b3eec1377cc64242bede04f03bb65b8d2ba00a.1513264961.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 From: Rajendra Nayak This sets boot constraints for the display controller used on Qualcomm dragonboard 410c. The display controlled is enabled by the bootloader to show a flash screen during kernel boot. The handover to kernel should be without any glitches on the screen.The resources of the display controller (like regulators) are shared with other peripherals, which may reconfigure those resources before the display driver comes up. The same problem can happen if the display driver probes first, as the constraints of the other devices (sharing same resources with display controller) may not be honored anymore by the kernel. Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- arch/arm64/Kconfig.platforms | 1 + drivers/boot_constraint/Makefile | 1 + drivers/boot_constraint/qcom.c | 122 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 drivers/boot_constraint/qcom.c -- 2.15.0.194.g9af6a3dea062 diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms index a586ed728393..b514327290ca 100644 --- a/arch/arm64/Kconfig.platforms +++ b/arch/arm64/Kconfig.platforms @@ -136,6 +136,7 @@ config ARCH_QCOM bool "Qualcomm Platforms" select GPIOLIB select PINCTRL + select DEV_BOOT_CONSTRAINT help This enables support for the ARMv8 based Qualcomm chipsets. diff --git a/drivers/boot_constraint/Makefile b/drivers/boot_constraint/Makefile index f3e123b5d854..7b6b5966c908 100644 --- a/drivers/boot_constraint/Makefile +++ b/drivers/boot_constraint/Makefile @@ -4,3 +4,4 @@ obj-y := clk.o deferrable_dev.o core.o pm.o supply.o obj-$(CONFIG_ARCH_HISI) += hikey.o obj-$(CONFIG_ARCH_MXC) += imx.o +obj-$(CONFIG_ARCH_QCOM) += qcom.o diff --git a/drivers/boot_constraint/qcom.c b/drivers/boot_constraint/qcom.c new file mode 100644 index 000000000000..0498f464da05 --- /dev/null +++ b/drivers/boot_constraint/qcom.c @@ -0,0 +1,122 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * This sets up Dragonboard 410c constraints on behalf of the bootloader, which + * uses display controller to display a flash screen during system boot. + * + * Copyright (C) 2017 Linaro. + * Viresh Kumar + * Rajendra Nayak + */ + +#include +#include +#include +#include + +static struct dev_boot_constraint_clk_info iface_clk_info = { + .name = "iface_clk", +}; + +static struct dev_boot_constraint_clk_info bus_clk_info = { + .name = "bus_clk", +}; + +static struct dev_boot_constraint_clk_info core_clk_info = { + .name = "core_clk", +}; + +static struct dev_boot_constraint_clk_info vsync_clk_info = { + .name = "vsync_clk", +}; + +static struct dev_boot_constraint_clk_info esc0_clk_info = { + .name = "core_clk", +}; + +static struct dev_boot_constraint_clk_info byte_clk_info = { + .name = "byte_clk", +}; + +static struct dev_boot_constraint_clk_info pixel_clk_info = { + .name = "pixel_clk", +}; + +static struct dev_boot_constraint_supply_info vdda_info = { + .name = "vdda" +}; + +static struct dev_boot_constraint_supply_info vddio_info = { + .name = "vddio" +}; + +static struct dev_boot_constraint constraints_mdss[] = { + { + .type = DEV_BOOT_CONSTRAINT_PM, + .data = NULL, + }, +}; + +static struct dev_boot_constraint constraints_mdp[] = { + { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &iface_clk_info, + }, { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &bus_clk_info, + }, { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &core_clk_info, + }, { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &vsync_clk_info, + }, +}; + +static struct dev_boot_constraint constraints_dsi[] = { + { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &esc0_clk_info, + }, { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &byte_clk_info, + }, { + .type = DEV_BOOT_CONSTRAINT_CLK, + .data = &pixel_clk_info, + }, { + .type = DEV_BOOT_CONSTRAINT_SUPPLY, + .data = &vdda_info, + + }, { + .type = DEV_BOOT_CONSTRAINT_SUPPLY, + .data = &vddio_info, + }, +}; + +static struct dev_boot_constraint_of constraints[] = { + { + .compat = "qcom,mdss", + .constraints = constraints_mdss, + .count = ARRAY_SIZE(constraints_mdss), + }, { + .compat = "qcom,mdp5", + .constraints = constraints_mdp, + .count = ARRAY_SIZE(constraints_mdp), + }, { + .compat = "qcom,mdss-dsi-ctrl", + .constraints = constraints_dsi, + .count = ARRAY_SIZE(constraints_dsi), + }, +}; + +static int __init qcom_constraints_init(void) +{ + /* Only Dragonboard 410c is supported for now */ + if (!of_machine_is_compatible("qcom,apq8016-sbc")) + return 0; + + dev_boot_constraint_add_deferrable_of(constraints, + ARRAY_SIZE(constraints)); + + return 0; +} +subsys_initcall(qcom_constraints_init); From patchwork Thu Dec 14 15:33:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121978 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6960635qgn; Thu, 14 Dec 2017 07:34:34 -0800 (PST) X-Google-Smtp-Source: ACJfBotEnNNYzztm4Ls2wKUIcIMEMBwk+HRxB5ZjfHZMlo9XYOqLwNuuYda+YxqteJ7FrVj8QnBH X-Received: by 10.84.176.3 with SMTP id u3mr9916056plb.242.1513265674557; Thu, 14 Dec 2017 07:34:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265674; cv=none; d=google.com; s=arc-20160816; b=UnS7+poO8N0WKUSC7OUY3JpSNh9sjPbYOQxB9QnaCHapWRdeQp1jfGlCg2nMvk+Xck M99V/zTSvVHk1lsEMD4WqjcdYwUQriEem2tp7yTZr0AZ0wi/oBTaoIvvXLGhd0uZUK+L XX8NGcb57Yv+JlO41hHp3TfGbwMFOLA2VroXMIoef3HYPzwYzDyFSK1ohHSzF6J18IZY pn1vguHBCPSzyO3XlR+WuNb9K0KWa0ekfojqCd59FAFUoKcfubG3aVygoQVAov+gp0/o wBjSX4f+bRhz14C7R2//pffEnSJBZPnZGGCViR8zDTr2ubp1L8xthGEZu+1HiZn7Doq/ djxA== 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=xxiSqICwJ47umMARwVNGCSfxLqi7YR/jbmMWfpOovYI=; b=sMni5kA1Vq6B7BkB8TPWrg4lbI/uTJxDINjgD4HwxBhdoj5fgwuPtu4VK4bOb9wzt/ SEwu9t+afmYyqazHV5YkArGwlMMG+Bm7A3T4bHaooAh78phcAOQWbKf+1vyJ9ETtcVy2 aUOT8HsHFUBkhAMiWcTFz0Hsw2N19Wr//DnomlidT+Q2h3aQ0guPvcc/9eo+LWBQx+Nm wC0/RkLDrK5fqGi4n++p86xU7oX416KaM3Bgi7E64ZXjIxEZ7QgrYaSGERGOhgoIdiZx 3Vib3c6NO65XmyMlH/LpPjBB0eZEsM+DkePDxbsi9DzXLF2VNiIwSkQ4guFoEqkFMyyT 8MrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FqJr7ywa; 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 i1si3392074pll.813.2017.12.14.07.34.34; Thu, 14 Dec 2017 07:34:34 -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=FqJr7ywa; 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 S1753519AbdLNPea (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:30 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:42776 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbdLNPeZ (ORCPT ); Thu, 14 Dec 2017 10:34:25 -0500 Received: by mail-pf0-f195.google.com with SMTP id d23so3842377pfe.9 for ; Thu, 14 Dec 2017 07:34:25 -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=xxiSqICwJ47umMARwVNGCSfxLqi7YR/jbmMWfpOovYI=; b=FqJr7ywacLFxA7WPk0mE/iC9cXNexJIdVHYjj+4hWmUf07gCAsJqmUQ51dFyhAAfir 6j7YHq06Tcd7/fyR9tJHAYahZQEwT3BPu/Ke/XGjylOTfRXy+e1OGUqjCteHgAS4S2BD WCGUFz3zj19tbbHOfk0F/Ktd8vwWQn1fXQGh0= 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=xxiSqICwJ47umMARwVNGCSfxLqi7YR/jbmMWfpOovYI=; b=Z0fYn0V4eIz9hR/m9T8fnrPMJwJfDcCkJ7ijKNymdvoIi25V/hzPrPNfT0xTLKI2sM +F1AKwOgecg50KAfzg/yFvTJ++3p+qBe9+Okiki0vbPKdwayuwWEozE4Z/pL5Dt7v9YV J3+WSob7qugKEGUzZU+mSCCSrRXCCNOxj1YY69myjLzzmBTNpHFlYvNNYzO+D7h446jN UxVKDwXRxLQ+djtqkz2CneXEnX3NFV8HgsJilbJ2NB+TxkYJfMEgbLQLlf4LWlcB7Jll +yV8SlVVCqGHtliuPSvlEUYfGwnIzZXmdq8T94Tv5d+MtGGyRdMvfT8ROUHpbIUdBxEP 39mw== X-Gm-Message-State: AKGB3mLtGFjjr3m14i0HE5UM+1Pr/BrDyt/0BJgpoDzsivhnF2bebmO5 6o5aNxZBZdmGSA8yAknssE/jqQ== X-Received: by 10.84.240.4 with SMTP id y4mr9945736plk.247.1513265665311; Thu, 14 Dec 2017 07:34:25 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id n12sm9012731pfb.5.2017.12.14.07.34.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:24 -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 Subject: [PATCH V5 12/13] boot_constraint: Update MAINTAINERS Date: Thu, 14 Dec 2017 21:03:19 +0530 Message-Id: <3037a6e5fb72f922b479f882fa710e60097c9f6c.1513264961.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 Add entry for boot constraint subsystem in MAINTAINERS. Signed-off-by: Viresh Kumar --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.15.0.194.g9af6a3dea062 diff --git a/MAINTAINERS b/MAINTAINERS index e716cdafa784..81823de0d655 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2723,6 +2723,15 @@ S: Supported F: drivers/net/bonding/ F: include/uapi/linux/if_bonding.h +BOOT CONSTRAINT SUBSYSTEM +M: Viresh Kumar +L: linux-kernel@vger.kernel.org +S: Maintained +T: git git://git.linaro.org/people/vireshk/linux.git +F: Documentation/driver-api/boot_constraint/ +F: drivers/boot_constraint/ +F: include/linux/boot_constraint.h + BPF (Safe dynamic programs and tools) M: Alexei Starovoitov M: Daniel Borkmann From patchwork Thu Dec 14 15:33:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 121980 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6961182qgn; Thu, 14 Dec 2017 07:35:01 -0800 (PST) X-Google-Smtp-Source: ACJfBotBjlbt3dxeETlP4AaDVRaZ68cg/W4jhRkYdL3lwO7yk5dGcW97WDh5Jzgdd9rwOPEIaRq/ X-Received: by 10.159.195.12 with SMTP id bd12mr10097945plb.14.1513265701035; Thu, 14 Dec 2017 07:35:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513265701; cv=none; d=google.com; s=arc-20160816; b=CbKlrsXOmGqBF0+282VF/KiJD1k6jwEow0+fb26o1we1UXLzm2erX9es+ni8mum9Ra Pd4KnKtsg9Nrp5VvCaoIQoyfIw2T3zl22B/HHzCbMM5LbKvvs0iaX5p9AeLoWvfLVv/1 hHUWDjFKMlrDllZEZ+KG/LrVml0M2Yh3IAELjN/pu+9acnXwAh2I2Aj4vKoS38pRYFHb axWjnrUiaTNOFbR1hJvWLSFhCvGwpQatzVzwz4iDh3IPSOyAEks9DrD5r5Qp16WdOevg QcrklA6wYbSfi0xtvNSN5hdgXkHBPy30QdTK97mzqcSllgFjSZei/lTDWJrSOl99rAtv cMJA== 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=api11LEndXJusHFPvHzUNPAysLOMa4YH5yakyeuJ+c0=; b=wMINzgK7/4GwZi1B4IIdm+vm/TZ9FeIWKRoG6o3GV1u6Z0omwFYN37K0lwlsZ9iDcx zln6+EtMWgTJ8hS5iCOg3g1ygm3ycO2+ZwD3VF4Qd2Cm68CTwUDsKpeg1w67rwnEgIH5 AH1biFqXlxrY4Tb0zZGoEynkSzRTYCN96ftlySsip43ampd7L1apoL0uskFqLbM49S8q X60ZhJ4iKUzVYN7+2Gm/FDQN0PZn/a88lc0tDWW0Zap5736DtL/9gWtOtcsRfhGDGtpx IXlSTeTXfM4/vjyaKMELL0LLtjx/p1N94zQ9TEtMLgGtUzmOj8FDReL1BzQX4iUCM3t1 5rrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i8uuwGK8; 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 c26si3412776pfh.105.2017.12.14.07.35.00; Thu, 14 Dec 2017 07:35:01 -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=i8uuwGK8; 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 S1753532AbdLNPeo (ORCPT + 19 others); Thu, 14 Dec 2017 10:34:44 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:43373 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753249AbdLNPe2 (ORCPT ); Thu, 14 Dec 2017 10:34:28 -0500 Received: by mail-pg0-f66.google.com with SMTP id b18so3621260pgv.10 for ; Thu, 14 Dec 2017 07:34:28 -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=api11LEndXJusHFPvHzUNPAysLOMa4YH5yakyeuJ+c0=; b=i8uuwGK8/7YyIG7MOlPIzZEGoySM01O92fmsykZ3H7TLG8+rHE/GJlZUF7K2YfZ94a 3UwmRR4Idcnnv7Piu+x8Bl/vbDS/b8oh4Yijf5qqITu8dIVm88Kx9awFIlqL9OuJYjc9 QWHnFuiLWC02ZH9NII+ccKx9TiVS+UGKtJy+o= 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=api11LEndXJusHFPvHzUNPAysLOMa4YH5yakyeuJ+c0=; b=LdpXs1zpn4xM8nNOtZI/9YENQ0cPszxWFxq6qpoJrJfvsOQnaOIBAdMfi8iNM7rqZ6 1T+AGnbPBD/Jei/SKPg5Q5KSX2CLWEOmK7FLmKT/vJPKp/SOtodsGzQlJdgAt4qLRNrs GztCwjHL4E12QgYA3quN0gmZDvhRZ1dSU4vH/z/AnXnRAaJDjnI5FwbOhBmTSO/HFHV3 Lf2Mvc7oSYMcMNm2/kG4rt6QLER+8JE2qysAZWODH/8V0BrpqOq7s2gjY9IZXqa/fAen oaH+Cs/OYgPYOhXVBwNrCyZQhPTT4TqKc4GIvN1AqkDDOUFggKDffLTz4svYFvXYGm95 +/Gg== X-Gm-Message-State: AKGB3mKOSLYQHegzypyHzeMEKywTvqaeDBAytMFBa//aC885+bv/9fjD ar4iKRv3ddrOAiNORczDaVZVZQ== X-Received: by 10.99.177.75 with SMTP id g11mr8981330pgp.268.1513265667911; Thu, 14 Dec 2017 07:34:27 -0800 (PST) Received: from localhost ([122.172.99.7]) by smtp.gmail.com with ESMTPSA id e2sm7190342pgv.34.2017.12.14.07.34.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 07:34:27 -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 Subject: [PATCH V5 13/13] boot_constraint: Add documentation Date: Thu, 14 Dec 2017 21:03:20 +0530 Message-Id: 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 adds boot constraint documentation. Signed-off-by: Viresh Kumar --- .../driver-api/boot-constraint/constraints.rst | 98 ++++++++++++++++++++++ Documentation/driver-api/boot-constraint/index.rst | 4 + Documentation/driver-api/index.rst | 1 + 3 files changed, 103 insertions(+) create mode 100644 Documentation/driver-api/boot-constraint/constraints.rst create mode 100644 Documentation/driver-api/boot-constraint/index.rst -- 2.15.0.194.g9af6a3dea062 diff --git a/Documentation/driver-api/boot-constraint/constraints.rst b/Documentation/driver-api/boot-constraint/constraints.rst new file mode 100644 index 000000000000..036bb77a26f9 --- /dev/null +++ b/Documentation/driver-api/boot-constraint/constraints.rst @@ -0,0 +1,98 @@ +.. include:: + +========================= +Boot Constraint Subsystem +========================= + +:Copyright: |copy| 2017 Viresh Kumar , Linaro Ltd. + +Introduction +============ + +A lot of devices are configured and powered ON by the bootloader before passing +on control to the operating system, Linux in our case. It is important for some +of them to keep working until the time a Linux device driver probes the device +and reconfigure it. + +A typical example of that can be the LCD controller, which is used by the +bootloaders to show image(s) while the platform boots Linux. The LCD controller +can be using resources like clk, regulators, etc, that are shared with other +devices. These shared resources should be configured in such a way that they +satisfy need of all the user devices. If another device's (X) driver gets +probed before the LCD controller driver, then it may end up disabling or +reconfiguring these resources to ranges satisfying only the current user (device +X) and that may make the LCD screen unstable and present a bad user experience. + +Another case can be a debug serial port (earlycon) enabled from the bootloader, +which may be used to debug early kernel oops. + +There are also cases where the resources may not be shared, but the kernel will +disable them forcefully as no users may have appeared until a certain point in +the kernel boot. + +Of course we can have more complex cases where the same resource is getting used +by multiple devices while the kernel boots and the order in which the devices +get probed wouldn't matter as the other devices may break because of the chosen +configuration of the first probed device. + +Adding boot constraints +======================= + +A boot constraint defines a configuration requirement set for the device by the +boot loader. For example, if a clock is enabled for a device by the bootloader +and we want the device to be working as is until the time the device is probed +by its driver, then keeping this clock enabled is one of the boot constraint. + +Following are the different type of boot constraints supported currently by the +core: + +.. kernel-doc:: include/linux/boot_constraint.h + :functions: dev_boot_constraint_type + + +A single boot constraint can be added using the following helper: + +.. kernel-doc:: drivers/boot_constraint/core.c + :functions: dev_boot_constraint_add + + +The second parameter to this routine describes the constraint to add and is +represented by following structures: + +.. kernel-doc:: include/linux/boot_constraint.h + :functions: dev_boot_constraint dev_boot_constraint_info + +The power domain boot constraint doesn't need any data, while the clock and +power supply boot constraint specific data is represented by following +structures: + +.. kernel-doc:: include/linux/boot_constraint.h + :functions: dev_boot_constraint_supply_info dev_boot_constraint_clk_info + + +In order to simplify adding multiple boot constraints for a platform, the boot +constraints core supplies another helper which can be used to add all +constraints for the platform. + +.. kernel-doc:: drivers/boot_constraint/deferrable_dev.c + :functions: dev_boot_constraint_add_deferrable_of + + +The argument of this routine is described by following structure: + +.. kernel-doc:: include/linux/boot_constraint.h + :functions: dev_boot_constraint_of + + +Removing boot constraints +========================= + +Once the boot constraints are added, they will be honored by the boot constraint +core until the time a driver tries to probe the device. The constraints are +removed by the driver core if either the driver successfully probed the device +or failed with an error value other than -EPROBE_DEFER. The constraints are kept +as is for deferred probe. The driver core removes the constraints using the +following helper, which must not be called directly by the platforms: + +.. kernel-doc:: drivers/boot_constraint/core.c + :functions: dev_boot_constraints_remove diff --git a/Documentation/driver-api/boot-constraint/index.rst b/Documentation/driver-api/boot-constraint/index.rst new file mode 100644 index 000000000000..d6fce17626a2 --- /dev/null +++ b/Documentation/driver-api/boot-constraint/index.rst @@ -0,0 +1,4 @@ +.. toctree:: + :maxdepth: 1 + + constraints diff --git a/Documentation/driver-api/index.rst b/Documentation/driver-api/index.rst index d17a9876b473..e591c172b5b5 100644 --- a/Documentation/driver-api/index.rst +++ b/Documentation/driver-api/index.rst @@ -47,6 +47,7 @@ available subsections can be seen below. gpio misc_devices dmaengine/index + boot-constraint/index .. only:: subproject and html