From patchwork Fri Feb 23 10:23:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129340 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp435179lja; Fri, 23 Feb 2018 02:24:16 -0800 (PST) X-Google-Smtp-Source: AH8x224xAx0Dg2KaaM3hUAO12us2b0+MePPLOWSNBrijlXrvmT4zyaimbubnuI2O1m/U5Xm5QRud X-Received: by 10.101.93.82 with SMTP id e18mr1033969pgt.371.1519381456556; Fri, 23 Feb 2018 02:24:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381456; cv=none; d=google.com; s=arc-20160816; b=gXbUuQyctoLDGS1Q907aYCdO03kW84R3AGL+8fbqc5BH0XWN1rfx/9xshZaGJD2VYr p+dV4QWP5Xc3VePkEF16+RhUX0MZcBz1LzHGFxUgTXUZKhFD6Xm1sW2dmaBTxU3uB+H7 SBLrupKHku4fycMDqYboWgSZR0mdk9OpHvNHPvIYwAld53OhUQNTL9UKPi0/fCtdwi4g IlHtpQonKEHKub0mowFx7dmx3Fbl9FcSmbi0POyZaVnGKD3hK+rOlQVt81gxltoVkUYB 8X3AtAFjPFG+GQQPQXY4N7VZK2+hOKQ0cIzF2iWqYYRxwPp3AuDtloV6J/NkjKmcVwg3 3wCg== 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=hKE+dtbHYf0RuN0sOC8TzmR2sRg9XSryiPC5z8/Fkcs=; b=ADi5VNzFkGcqlEr3C+NE4YlT6qktZHwJoy3WqGLGV6IxcnnpDe/3MdANjuJwhhHOBY pGLHQG6MXv4zpQAJ8j99Ihegs8IRuiIz8TkWVQpOIjxmnkxHPROKtwYXKsCAOFl6z9GB JEUnWimluFMTfPKK2KQNpkTZzjTKnu3x4vbxnZVpcJ9GS1QcVhkaHTni+QwCC1rqxtc7 ftQl3BBAcr/KgvdQHN+7pFevSnDTnip8trVoIvwaTkpGhPDFR4p59x5F3FhLD4tXWGq1 bUFtYYEfQR4y4ZjESP7+eODIcgH+scO1KgRcGXgL6VncacpDQVCdKsoMic7FcJzMVsbO CCnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Mgg8E91s; 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 y184si1350278pgd.291.2018.02.23.02.24.16; Fri, 23 Feb 2018 02:24:16 -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=Mgg8E91s; 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 S1751469AbeBWKYL (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:11 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:39195 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750903AbeBWKYI (ORCPT ); Fri, 23 Feb 2018 05:24:08 -0500 Received: by mail-pl0-f66.google.com with SMTP id s13so4660830plq.6 for ; Fri, 23 Feb 2018 02:24: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=hKE+dtbHYf0RuN0sOC8TzmR2sRg9XSryiPC5z8/Fkcs=; b=Mgg8E91skrRWsa2B2JvNIkC6Ea3SOi685GMwsEzBqmJ4Jo3hscWGj4dVSC749q1ll+ 1P6cq1mTvcjxlD/jf52SKzz1tyvVNq+YVeF3ucZjC9tNfrDkORarukHDLglmsX1h3tIT V1WBoFLReBrwXUjigbfjjGWzC07BbHyuv2TSg= 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=hKE+dtbHYf0RuN0sOC8TzmR2sRg9XSryiPC5z8/Fkcs=; b=k4WA+cOprvUTTrSptt32sPKT6+gqA/+40n6kuFTflJp2FGeuBTrudS60trTj2rzmQ+ MZk5GO4T/95GxzjZzf25+cLhnc6co1J+Ch0l2PESTIXpn3DqFZ2P7cbzXzZ7eU4GvCSE 4/fpZyLiyquzNLR3H3fmnByDlfmNlZYsBseThLRmzNwRyGg6X1McjRh7DqmvVKCO/6Hw jthbkgBVDQEVFKYPv+p99bVUGXB7gTvJgudQARKe7CSNK7BEQEQHQYOuG0MdfOH3/yCL 1mGG7bUGziXCGWm8gbZPDkaMXKxL3LYnyGD4JVUcEYgJ4Qc760aXs2k0UlrLOc/BgibI FCkg== X-Gm-Message-State: APf1xPDwttSJZ8zRb0IYpS/sGbnfeKqWfC0th9BTmWcWuYcvfstbacW/ oY/tuRSrvqf8nZR/ex2Vy7LFVg== X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr1279789plg.294.1519381447793; Fri, 23 Feb 2018 02:24:07 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id a3sm4356866pfh.120.2018.02.23.02.24.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24: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, olof@lixom.net Subject: [PATCH V7 01/13] of: platform: Add of_find_any_device_by_node() Date: Fri, 23 Feb 2018 15:53:40 +0530 Message-Id: <483bc64db23821497d0634a86e801510e439fe3d.1519380923.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This 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 c00d81dfac0b..72853f9043e6 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -55,6 +55,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 84a966623e78..5fb20afaf895 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -54,11 +54,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 Fri Feb 23 10:23:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129351 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp437125lja; Fri, 23 Feb 2018 02:26:51 -0800 (PST) X-Google-Smtp-Source: AH8x226XbTnIQgMHpvvCQfc22rNYXCpqcf8MGNBa+Lgs6YLs6vGUbJJ1q3looBm7Kc9IEM/xp2If X-Received: by 10.98.117.139 with SMTP id q133mr1291095pfc.64.1519381611372; Fri, 23 Feb 2018 02:26:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381611; cv=none; d=google.com; s=arc-20160816; b=ZrhMrDsp3Nq+qCF45k+clvpo0XKqYPFvJ1Hx11ApMerkgblQQZtDe8ld7PJfhkFAKh 5u+AacyOawiJSzBD5eMAlwrx9olDs2fiHknIcwJI8aR4dytAsRxVcEP814uyu0/UNUP9 bLw0MdMExNwYy6qgirG4NqFi/Mdc705RB/kSEDhcFPvME9QFYmKqTu0k+2fdrwUyx/hg 1kO0t5k24X0cd/L2oKYAWqs+0jkReu4BA8MlRu/K2z5Z1lhQQtrx41MbPJoDiBJ+ocxN nWFbQQnN/W9P3wO8Ky5ypB4EyZKlFBbkijzMgWYkZwdXwRT1jARYzopi0S8VUhW6T+r3 QeJQ== 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=IX4N6db+RjJ2MZ+2zAzs8Pxe8B0/9+OqWz8edyDgGcE=; b=WEuSACRRogeCH9Xwsib5BvdDRlPVfi04p/XC3Nl9u77n5UVpbwvDfET+zbwYu1gjV5 BKDBteyi/IubaKWdrHrRLFlKKkMIXFpdNQLM3yPxZMzkqx3fa0+d4AKN3bsb5Fmk3uio x+oNVyiRy088llDiW4DG9nw4C0FFO2PcdZuuGqpTmYtGKLi6xWNd6ITx0Mhwz7qCvyU8 VYRkBaycczalarE3qGA30ZhKwEpqnaFEt2HbV3iQXL1/CVu63ZcBhNGqYrt+GDb8d//w shxdlnGjwsnbXIode3B6aTGejUWMPqf4xAEX1EoCx0VCzrJxCBxckhfz9lJaqJ7l/cHr iQQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Du3+6e4U; 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 a186si1359376pgc.36.2018.02.23.02.26.51; Fri, 23 Feb 2018 02:26:51 -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=Du3+6e4U; 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 S1751522AbeBWKYQ (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:16 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:43191 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbeBWKYL (ORCPT ); Fri, 23 Feb 2018 05:24:11 -0500 Received: by mail-pg0-f66.google.com with SMTP id f6so3193822pgs.10 for ; Fri, 23 Feb 2018 02:24: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=IX4N6db+RjJ2MZ+2zAzs8Pxe8B0/9+OqWz8edyDgGcE=; b=Du3+6e4UD3MMA3/xxe2MmIsOEbX6Ss88dkaF3te+A/egyfjjcqC9bZjA9bacRkdC5E pi7yhV7KyLGKTX8F6S7ylChztyR272rKb0eFkW82UYCcFPJOkzOiJ6r0NkUi8w7bZvbi 5OvDDX/H7QvUm6o410P4M1EAKRyMaXCHvHEkk= 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=IX4N6db+RjJ2MZ+2zAzs8Pxe8B0/9+OqWz8edyDgGcE=; b=SA4VD8/xmIoyk4FdVwoSB5TuuNWtZoIVN4liYjh55YEeh93aP/80bQrgyDYYaBged4 7RCnctHPx3Fu+PLQI9dazavANFsGisb1vLQvMznQ9fWsBFrs1Zls7lQzJ7VakZhmR/Hp yiOSjy5Xx2nAc8gm79K549FGUzU6XpC60Vay3B8xad6nRJSvcRM45r7XpFiycj87mhQU 5pEsTEmBmLIThq3T61JWvSZfaIIGPI/LvLfN4ujtfMc1Wzpw/1aMzk5RZh8tAfquT1vv nWEycD3Cx0NUsJAzPJIBTFwgljynzStYKtHX5xRFqAsazQSN0Rfou9E+IlGBlD3i7uef 02rQ== X-Gm-Message-State: APf1xPCbZrj3GohJ/TXHsINfMIUtEfLbbxkfO9DwwnqeRLDaB2tSHruB CoO0mlMKw91lNJ0QWNBwnD+8jQ== X-Received: by 10.98.166.85 with SMTP id t82mr1253182pfe.237.1519381450706; Fri, 23 Feb 2018 02:24:10 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id r28sm4389295pfl.9.2018.02.23.02.24.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:09 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 02/13] of: platform: Make of_platform_bus_create() global Date: Fri, 23 Feb 2018 15:53:41 +0530 Message-Id: <0f725b5b58bcdc22d03a436ad8243b98c962593a.1519380923.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 72853f9043e6..dfbb9f38cb37 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -392,10 +392,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 5fb20afaf895..7a5313553c2a 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -76,6 +76,10 @@ extern int of_platform_bus_probe(struct device_node *root, const struct of_device_id *matches, struct device *parent); #ifdef CONFIG_OF_ADDRESS +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_populate(struct device_node *root, const struct of_device_id *matches, const struct of_dev_auxdata *lookup, @@ -89,6 +93,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 Fri Feb 23 10:23:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129352 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp437711lja; Fri, 23 Feb 2018 02:27:31 -0800 (PST) X-Google-Smtp-Source: AH8x227vBSOgj5ZXwS+YZBfTctw4Ywh4fmSro/bvI/X6a4JXtrIxxxn8gveb/mwqYd4Pv9RcuQX/ X-Received: by 2002:a17:902:822:: with SMTP id 31-v6mr1286419plk.362.1519381651151; Fri, 23 Feb 2018 02:27:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381651; cv=none; d=google.com; s=arc-20160816; b=DPD+tFCuCZlWYV2pXGMFtkKF7eGYzSO8eYYmHznFOf4+p9sKoHSUjC8R4vQzFXof7y 24/R0t/mCL5Bt8yQMUla9Tj2qSwXMBhVBiazFTNPnUY8+cYed+nZdwGNcdUfCP7qfOmW urLg9qWPrFnJpAj6DrvcFO1ivDtdK6JB2pSjeeMOVXH7rJM9gAHHLTWTHD0j4CUhCWfI +MZRE5cVg6qmcQwIpzjyK2Pd3w3RMxFW3hrANdvOMOfH1I+WF2x4rIDvF7+eDAKHG4bD +t/D/ofmc+UOAGIaWubm6qwQbxpTmSf/N3FL+eLkZudLtwwmGE4S5X9f7P+vClRSX7G3 C65g== 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=Yiq+4mDSeJcpxSym51sFK47eecpTt1W1PgxA/jBkiLE=; b=0Kc0FgmNU5wy3oLLjXtGZRCHYto3OfPID2NCy7Vl6l0N49ng/iMgUHZLasEmPBIH4o 9DB950uvinSYerm7O0PX8v4SELYYupGwyBy1cPvbTTEw8vcFWYkAInsdB7v1tzIuav96 JfKae28CSY0ps12+lNdlPsjytbAWkhDs4AzK7XkuJOQg9NIWhcsAflU1P4oRQYz57m4w giImDak35OD7qM8l723/wfvSeesWzyOyG/LXDtP5fhj3EVB7qj2FM1Kp4J+tnbZNR+Kk T6Xe//WAuWp94xNgtKc3Gptx1zqIUeK+2QuTXleYXN/5LZWTDVV7MQ7WX/SMtOhYrP77 RkYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NcrabwPK; 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 w19si1351430pgc.340.2018.02.23.02.27.30; Fri, 23 Feb 2018 02:27:31 -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=NcrabwPK; 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 S1751761AbeBWK1Z (ORCPT + 28 others); Fri, 23 Feb 2018 05:27:25 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:43194 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750903AbeBWKYO (ORCPT ); Fri, 23 Feb 2018 05:24:14 -0500 Received: by mail-pg0-f66.google.com with SMTP id f6so3193876pgs.10 for ; Fri, 23 Feb 2018 02:24: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=Yiq+4mDSeJcpxSym51sFK47eecpTt1W1PgxA/jBkiLE=; b=NcrabwPKBh29Btb2ezlJ2yeAc0tSHpkRkYjeleVpl2wkvBUj3TMKdjhcmEi2VM7PlJ 0uj/mVi3NOnuG0Wr6UFZGiPDLmwLAmRSbynIqMJSqMHaPl4XruNtgbSZrFOWcF/1VoRh rZyIKMpKfc0U17tRCznLZYqdvZb+ilHDWQoBU= 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=Yiq+4mDSeJcpxSym51sFK47eecpTt1W1PgxA/jBkiLE=; b=dPYrsN5KHvOxaAuTVspY6ImsM0w2OtF3JyyBoCEBBVqJNsXICbXheZZP7UQaFOQ840 skfJmwoxph8FnvJMfG5cDdJGgLjwJkTW/sCd+Zpa0QuYIg6zvjZLKtJmVBqbUxPssdHe UXkMNyNXfBab4pZnaXjAnvaPrMaKHtGquPtp99gBUEG6hLyQ+mAsYx3Iftdk0MGoGo3j j0aV1XoKzoOiKe22TgL0oP4IYAV+0dZ3oSm8f1pLh13igPc/LcZE+gUCsiiePn6tPypi p7taiCn0ShlElO71TfdEoCyQBWR4rKp2eLsWsuuze/fjSvVUAWnXylNx/jiM95AnnOEh bveQ== X-Gm-Message-State: APf1xPCta9ZtWGaxO28om48Blp7pdXR7EHNH8sCgUoHOL7JCioP1LoOv ZIJG1kqn2yrERpfniGHZL7Xdvw== X-Received: by 10.98.147.27 with SMTP id b27mr1274856pfe.145.1519381453333; Fri, 23 Feb 2018 02:24:13 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id r70sm3335156pfk.177.2018.02.23.02.24.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:12 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 03/13] drivers: Add boot constraints core Date: Fri, 23 Feb 2018 15:53:42 +0530 Message-Id: <4b97ea6f509fe74bd5d3341f6b1f2d441962543a.1519380923.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/bootconstraint/Kconfig | 9 ++ drivers/bootconstraint/Makefile | 3 + drivers/bootconstraint/core.c | 219 ++++++++++++++++++++++++++++++++++++++++ drivers/bootconstraint/core.h | 30 ++++++ include/linux/boot_constraint.h | 66 ++++++++++++ 8 files changed, 343 insertions(+), 7 deletions(-) create mode 100644 drivers/bootconstraint/Kconfig create mode 100644 drivers/bootconstraint/Makefile create mode 100644 drivers/bootconstraint/core.c create mode 100644 drivers/bootconstraint/core.h create mode 100644 include/linux/boot_constraint.h -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/Kconfig b/drivers/Kconfig index 879dc0604cba..2cef3c2563b6 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -5,6 +5,8 @@ source "drivers/amba/Kconfig" source "drivers/base/Kconfig" +source "drivers/bootconstraint/Kconfig" + source "drivers/bus/Kconfig" source "drivers/connector/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 24cd47014657..a38c8b0af3af 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -70,6 +70,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) += bootconstraint/ 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 de6fd092bf2f..777267aa1710 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 @@ -445,15 +446,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/bootconstraint/Kconfig b/drivers/bootconstraint/Kconfig new file mode 100644 index 000000000000..9195f9a39fe2 --- /dev/null +++ b/drivers/bootconstraint/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/bootconstraint/Makefile b/drivers/bootconstraint/Makefile new file mode 100644 index 000000000000..0f2680177974 --- /dev/null +++ b/drivers/bootconstraint/Makefile @@ -0,0 +1,3 @@ +# Makefile for device boot constraints + +obj-y := core.o diff --git a/drivers/bootconstraint/core.c b/drivers/bootconstraint/core.c new file mode 100644 index 000000000000..a9f38a0febb3 --- /dev/null +++ b/drivers/bootconstraint/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) 2018 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/bootconstraint/core.h b/drivers/bootconstraint/core.h new file mode 100644 index 000000000000..d04bd484b2a7 --- /dev/null +++ b/drivers/bootconstraint/core.h @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 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..d56e33f3f921 --- /dev/null +++ b/include/linux/boot_constraint.h @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Boot constraints header. + * + * Copyright (C) 2018 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 Fri Feb 23 10:23:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129341 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp435283lja; Fri, 23 Feb 2018 02:24:24 -0800 (PST) X-Google-Smtp-Source: AH8x227SV2ggFBGPgzLyG3lRyzLarYc7zvpC/1zVk7DkHD2bizLgU6roYHSDCxRha1cNUkB1r2HF X-Received: by 2002:a17:902:5a3:: with SMTP id f32-v6mr1275117plf.48.1519381464276; Fri, 23 Feb 2018 02:24:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381464; cv=none; d=google.com; s=arc-20160816; b=B09+2DjDzOh44Q874khrfgb7Ej7+YFZxotVHIWqubV82qHOdkPz0JxlD4pHuC2gAVS mpZGxIkgIKFX3XJt+hJTj9Ljsjff48I+qEHUjrgv5qxTuOzOktnM0pZ+uPPStV3ffeHN kEQhh+SoCinlSYzBZoS7syyISxVBQm/SJTjyd0IkX0edx5VHuR/+8jg9xhcc/iaWJU2Z ksyybwbXVK0KLI2IfNKh+nj2YUZU92WXg90tJVvO7psYAigRUHSs0TwiWxd3Y94AQoL3 /t006P/dhVhsbeWDVHxSR9a9e7pZFkIuZDTG2lp6pbkmjbFpGgR8r1CyNClV/+lQpPyk sUvA== 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=NEHZacP+KL+rUypqnXnVYM/ZBgBS8SyS2IS4QXMto1Q=; b=ifULCUxvotp83bAfiV43KJCpV7w7r9XshYPpWAKAQnJMVn526B5Zs3tc4C6wnsrWRn 2HvKVlbAbZYW30VWibh7ussQOzdrRX1jNXvxj+sNJJ8iqdDE2QCVKjL1mBbRt6TST4GY zVzHNegmdWHyXT5xBl6PpL8A8NlR+Txrc0WgrqzAYU9TKVwWGiyUukZKR5s7xqUm97ie WL0IOe9mHR4d4Rn1Mmta1sgYWRltJetyr5d4pf58+2lQSKDHaFWrvqj3kDNI30yqu9N2 PXUr15QXRo+Hbfd7IxqiPRQ9R3QyDCbFnSQPTCAAaNwQLiJXr1L/Kz+LX0RuM3eFdKQG yzPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=evdnR6He; 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 y184si1350278pgd.291.2018.02.23.02.24.23; Fri, 23 Feb 2018 02:24: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=evdnR6He; 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 S1751567AbeBWKYU (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:20 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37201 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751521AbeBWKYQ (ORCPT ); Fri, 23 Feb 2018 05:24:16 -0500 Received: by mail-pg0-f67.google.com with SMTP id y26so3200897pgv.4 for ; Fri, 23 Feb 2018 02:24:16 -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=NEHZacP+KL+rUypqnXnVYM/ZBgBS8SyS2IS4QXMto1Q=; b=evdnR6He4LMJvgvRD6Vzy9TrtqNC03fb5h97koPNf+m461YiQHjN0tyLD6Bsvmm9dt jagX5MYz71ALr8OgbS68i+n6zNaSLfgwxy0gGcm2SebcpIP1vTh6EmYzF0LErbBpBCVG kSgpih1alB8VRKQaOzLfDXlcL2ge0HtMzv01I= 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=NEHZacP+KL+rUypqnXnVYM/ZBgBS8SyS2IS4QXMto1Q=; b=IOYX/lQhG4xFptnqwTJwX26mScCnuf1JCAESsNHHOPZ76a5duHaN/avtQHYrcqNApB lL7xOMzXcXbmMw1ILNFOxPmL1OpDINM7BuNa0k2K3Q69OOsZR5fqnIaxlbjrL2BSTKAr st31GIlNEilYIZazfQMPoH7+JNF67HBNPJ71u+wA+/glR/7G54g5iXjRJYR9mX2sa+f5 0kbiAcNLguZMpKBQLPoBn+pjI/m1AfKlvuhXL4FvG4S3wPlT82Lhfm4Tp7UNzeUmzAdI jRErDiGHWH56ohJWqK3bH//coNV1TdMr4YcVB8bBJAQ2M04I7jM1VBooJ3I3MCyV4YQS LRMA== X-Gm-Message-State: APf1xPA30jj3XCwsW9LMsGRcbRrQ44jpTXlxcNQk54S0aMr7iddHFO1R TaVDWNd7mAtswKTQ06jqMlVzIg== X-Received: by 10.98.198.1 with SMTP id m1mr1266712pfg.90.1519381455839; Fri, 23 Feb 2018 02:24:15 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id p3sm4024590pfh.7.2018.02.23.02.24.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:15 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 04/13] boot_constraint: Add support for supply constraints Date: Fri, 23 Feb 2018 15:53:43 +0530 Message-Id: <4425c187bddde1baf7a17cb52e36aae746626add.1519380923.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the 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/bootconstraint/Makefile | 2 +- drivers/bootconstraint/core.c | 4 ++ drivers/bootconstraint/core.h | 5 +++ drivers/bootconstraint/supply.c | 95 +++++++++++++++++++++++++++++++++++++++++ include/linux/boot_constraint.h | 17 +++++++- 5 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 drivers/bootconstraint/supply.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/bootconstraint/Makefile b/drivers/bootconstraint/Makefile index 0f2680177974..a45616f0c3b0 100644 --- a/drivers/bootconstraint/Makefile +++ b/drivers/bootconstraint/Makefile @@ -1,3 +1,3 @@ # Makefile for device boot constraints -obj-y := core.o +obj-y := core.o supply.o diff --git a/drivers/bootconstraint/core.c b/drivers/bootconstraint/core.c index a9f38a0febb3..2973f8dd9094 100644 --- a/drivers/bootconstraint/core.c +++ b/drivers/bootconstraint/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/bootconstraint/core.h b/drivers/bootconstraint/core.h index d04bd484b2a7..44c219716be5 100644 --- a/drivers/bootconstraint/core.h +++ b/drivers/bootconstraint/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/bootconstraint/supply.c b/drivers/bootconstraint/supply.c new file mode 100644 index 000000000000..352ded92d057 --- /dev/null +++ b/drivers/bootconstraint/supply.c @@ -0,0 +1,95 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 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 d56e33f3f921..736fe09a8589 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 Fri Feb 23 10:23:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129350 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp436933lja; Fri, 23 Feb 2018 02:26:38 -0800 (PST) X-Google-Smtp-Source: AH8x224MyXMuwqRs2eYLtCipjLvVYHc77OCCK/8ERzmHX+L94bFmku67OtrQFNMUJsJaj6QGSIDN X-Received: by 10.98.251.5 with SMTP id x5mr1317815pfm.18.1519381598572; Fri, 23 Feb 2018 02:26:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381598; cv=none; d=google.com; s=arc-20160816; b=yb+uUP0Df1eYjdpWtzLvYUzsvGyw3W4BjxGqvjkqTA8JYFtRMe0JufhEcIcs0LP0L7 zTjHwkYBoFSv0eswYVtfDOqQWor9Rxy3cXKf/bqzO053ciDmUPbuSXRahRUlKrGURTCv JB8W3U73BsFNUCTfinAapOnHFXdFk3+7bnlI4KQ8vwRrhyeP4McYaVk7O+DG8s7+oj0e AyE8yMgSJ8OgdCPNA5G0Ter6YfvuwU2DBK0n/QoHMPCgv/2Kah6u7CmJCM8CwMl7+x+Q L6g/StMyfaV+4XEwZrfLrvxVVZQD/xoV/iZqKD6nKY35WQ1mvTsvGwkYYVICip9UoWXo tAmQ== 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=G2f8VbzrMvNh40O8+d08UjmT09kaXNhp3e6FeRb5VQY=; b=K9M/ZNvw0OM2yMZcCWY8d0Lq9gKmHPMHhgbxidia2jdBh/3ifzsu+f5v6pdxLWJhv8 n7xp8NoiYL4Z1MlUj4/XQCiJl8VrwX9EhLVz+M5xOvvitgeO4ZmsXIc3/bXn1NlizLB6 rgjq9qNLs4CFYQ1dp2DlSrN0h3/c1+4pWW5WrYZ1WhIuOCJ6LTN3VplBWXj5TdixWLms 37hxG4lmui/BO9SeqJ6VLTa8ScRCj1H1/T2vqv0tUMzi1bUPjMTdqyU159tssWFH4edg b2oFD9Bl5lO+Yxxp63HCcCfUoq8XedU1+9n6B08APP0fYLqi7UnJO0jV7hssgqtdEYht o2gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ieTgY4Fm; 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 a186si1359376pgc.36.2018.02.23.02.26.38; Fri, 23 Feb 2018 02:26:38 -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=ieTgY4Fm; 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 S1751758AbeBWK0e (ORCPT + 28 others); Fri, 23 Feb 2018 05:26:34 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34613 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751530AbeBWKYT (ORCPT ); Fri, 23 Feb 2018 05:24:19 -0500 Received: by mail-pf0-f196.google.com with SMTP id k2so3347621pfi.1 for ; Fri, 23 Feb 2018 02:24:18 -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=G2f8VbzrMvNh40O8+d08UjmT09kaXNhp3e6FeRb5VQY=; b=ieTgY4Fmzd+a8q+lu4n/jC5yd5Cl5PiUfoIPP4qK/Bq49UFOZrvFI/aFBHGSbXXpG6 YG3d7UF8RhnHg4q7rCaISiN6O0WbiLyNE7/4mBLMzgGsuAa0P5znQh+TCuAYLlR63D2E MDd/2ETh2gCPUVGm2xL3MBz/oOOGWtTnCnRbE= 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=G2f8VbzrMvNh40O8+d08UjmT09kaXNhp3e6FeRb5VQY=; b=R5esuNCDilhukKRpZ7MGJNcw1ceoIdhoywvQRhdjYJmneSv43KbGcwQQO24Ihppujm 3YO/VSJtV+TLJXiCzsEP53nGd77Vjw5IQqUzW3F8bqm1Ibi9o75PZDGAtG34XMm5wly8 fwq+CVrpL6Yq8UBJoAaiixSeVl4MtLPDqqHVjgvfs5iXZ8BRfYawpQRv64AQVXOQFZN2 rFsOV8F5A+nUgri8wgai7uUMEyFvCEsR0TP3w/1lMgYPqsAN+/0IhotW/PzhmOIGdI/4 IfyIsTaiH1YXibKmYCGyuWGGaRJTPZrENFHkxfM9Ka6WYs1gGxC+k3WPzHgQv+3exNNc 4RIg== X-Gm-Message-State: APf1xPCxaPAossE2EepwhW84pNGNEPYnDtJ1sQy/ENNWc0JAwvpdaMvb eWnAGE0hOAysizJNHIEgRWSb9w== X-Received: by 10.98.100.131 with SMTP id y125mr1275293pfb.117.1519381458312; Fri, 23 Feb 2018 02:24:18 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id m22sm4335405pfg.188.2018.02.23.02.24.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:17 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 05/13] boot_constraint: Add support for clk constraints Date: Fri, 23 Feb 2018 15:53:44 +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 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/bootconstraint/Makefile | 2 +- drivers/bootconstraint/clk.c | 67 +++++++++++++++++++++++++++++++++++++++++ drivers/bootconstraint/core.c | 4 +++ drivers/bootconstraint/core.h | 3 ++ include/linux/boot_constraint.h | 11 +++++++ 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 drivers/bootconstraint/clk.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/bootconstraint/Makefile b/drivers/bootconstraint/Makefile index a45616f0c3b0..3424379fd1e4 100644 --- a/drivers/bootconstraint/Makefile +++ b/drivers/bootconstraint/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/bootconstraint/clk.c b/drivers/bootconstraint/clk.c new file mode 100644 index 000000000000..90262fe9057c --- /dev/null +++ b/drivers/bootconstraint/clk.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 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/bootconstraint/core.c b/drivers/bootconstraint/core.c index 2973f8dd9094..a73744c5d599 100644 --- a/drivers/bootconstraint/core.c +++ b/drivers/bootconstraint/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/bootconstraint/core.h b/drivers/bootconstraint/core.h index 44c219716be5..09a6176541d7 100644 --- a/drivers/bootconstraint/core.h +++ b/drivers/bootconstraint/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 736fe09a8589..4685ff55fff8 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 Fri Feb 23 10:23:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129342 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp435343lja; Fri, 23 Feb 2018 02:24:30 -0800 (PST) X-Google-Smtp-Source: AH8x225iabuFDJ6tNKNfNxtWDOCS4/DlZbHksI/Pwe9OUDJvPKB1MncBmDc6OBqAYm6SwtcB6utk X-Received: by 10.99.65.199 with SMTP id o190mr1081978pga.238.1519381470093; Fri, 23 Feb 2018 02:24:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381470; cv=none; d=google.com; s=arc-20160816; b=iwdk6Blb8YNLkROlm9593iCaXCzK4yUul0jB0mfhCn+6h60rOs5+b658JyFgtJs/ti sLbMR5oGGTfrtWO7UCa+OHK5peZ676O+crNWoM5HJ+E0BdNGP6H+FhXddEo4q05Fh6A/ o4xRgdseE4GI7DrwyoSwNApJHip8mgL5N1taQLTZ0q0fOptEujZ7oie4yI0/sUhitY4H HIyJJPPSgqcWe84sIo8pTtkDQn7I5agYCb2QWMVyzuTUS/L7IXTafOZGtk48u3rxm5aZ QnrHcotZTf34k14sHXr/8R4sOcFILiWHgNr9CPI1tIyuIsp4ISZjeNKCD+IhiKrioEt4 FJLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=yo/HwvWl5x7NgUYRRWuyvg7loN2thKGDdEcTTRAFKr0=; b=pRywea09/mo/3+sqET5EfaGAxaaY6EL6jDQOi0iUyX7EW+3HqNwjjoXlF6dQK+jbPv md47Y7TgPkKUUIUdDRRizYreGs3yFrSZ+/FvJXZFCu4zg9wrmFrExHtI6DdMqK7gFJyW wZKeyfZTUzn1TwW51zE1qlmKhpvNxXYqMSNwS4/KuKx7WCiS+EexqKK58e/XfVRsK5nP zh+u3KxroOT9z/WAkAIH5SjU66rY6KsvyKeeUsn6+AgDdkpjUGlhQHqT+r0yh9HTRnll z7b0BVKXZ/n+QYf74wtr/65Ui1C0TxHnFZiFzaU9BJSsv3uryKRvV46+RUlK4pviGyIv d3Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aFz0SBqc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 85si1592538pfq.374.2018.02.23.02.24.29; Fri, 23 Feb 2018 02:24:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aFz0SBqc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751623AbeBWKYX (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:23 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:42162 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbeBWKYV (ORCPT ); Fri, 23 Feb 2018 05:24:21 -0500 Received: by mail-pl0-f66.google.com with SMTP id 31so4654000ple.9 for ; Fri, 23 Feb 2018 02:24:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=yo/HwvWl5x7NgUYRRWuyvg7loN2thKGDdEcTTRAFKr0=; b=aFz0SBqc+gRhrVGUBICm8ttFtuifquZfT2oDiYL4TtVjfojhQIjv4Uo2gJ4HHlMqPJ 3AqWJtl90uxhQnxWEDH+LQNMkldqylR1crVKYBVehl6tZq3F99CIi0Mks22Gqb/dfkSm AiVc8uh1LaFfhAPsYXlEIM5EzqAybLKOIE7Ew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=yo/HwvWl5x7NgUYRRWuyvg7loN2thKGDdEcTTRAFKr0=; b=tdciQARMc0db7QsmykueN/YHXRQPnqtLDtVpk1ztaq0Q7ELiuOiD/CeAT3G6YD8cpq /2sveKCQhTrQMvyRUgQqqO63VPT0DH3ex6X3ecG8h8uG6iHetPc5xW5gUjEe0vQcZD5a jDIUDbYaY4xe8f5bR8ZMLe3a8aCJFA5cB16GTVfkUUb5ab5hQRjP6AIc64zevUyT16JO iE2eoI0ulY5CDCeBR6SXCLzly9j8XmCvGa+YahZ9vaAnMVS8hOA38zICrBGf5mnDsSYl a1s9Ge6UUaYIpR1a04VpIBNrNVWQTV2dsDQSSNTtVM8ff4T6r1P0Sf66N0cXnNVqrgdT vczQ== X-Gm-Message-State: APf1xPCGWTV19EYVRDHDx1xE/VH92qCKasRSMMJneStAkFch+ZSdjhLd mBD2M8yvk/mk0eXakZZT0+B0IA== X-Received: by 2002:a17:902:2823:: with SMTP id e32-v6mr1285128plb.44.1519381460853; Fri, 23 Feb 2018 02:24:20 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id r29sm4449111pfj.99.2018.02.23.02.24.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:20 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 06/13] boot_constraint: Add support for PM constraints Date: Fri, 23 Feb 2018 15:53:45 +0530 Message-Id: <9802d5501b0f22cc14e2043797ab995f7640b3c0.1519380923.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the PM constraint type. The constraint is set by attaching the power domain for the device, which will also enable the power domain. This guarantees that the power domain doesn't get shut down while being used. We don't need to detach the power domain to remove the constraint as the domain is attached only once, from here or before driver probe. Tested-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/bootconstraint/Makefile | 2 +- drivers/bootconstraint/core.c | 4 ++++ drivers/bootconstraint/core.h | 3 +++ drivers/bootconstraint/pm.c | 21 +++++++++++++++++++++ include/linux/boot_constraint.h | 2 ++ 5 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 drivers/bootconstraint/pm.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/bootconstraint/Makefile b/drivers/bootconstraint/Makefile index 3424379fd1e4..b7ade1a7afb5 100644 --- a/drivers/bootconstraint/Makefile +++ b/drivers/bootconstraint/Makefile @@ -1,3 +1,3 @@ # Makefile for device boot constraints -obj-y := clk.o core.o supply.o +obj-y := clk.o core.o pm.o supply.o diff --git a/drivers/bootconstraint/core.c b/drivers/bootconstraint/core.c index a73744c5d599..a6148b625b48 100644 --- a/drivers/bootconstraint/core.c +++ b/drivers/bootconstraint/core.c @@ -95,6 +95,10 @@ static struct constraint *constraint_allocate(struct constraint_dev *cdev, add = constraint_clk_add; remove = constraint_clk_remove; break; + case DEV_BOOT_CONSTRAINT_PM: + add = constraint_pm_add; + remove = constraint_pm_remove; + break; case DEV_BOOT_CONSTRAINT_SUPPLY: add = constraint_supply_add; remove = constraint_supply_remove; diff --git a/drivers/bootconstraint/core.h b/drivers/bootconstraint/core.h index 09a6176541d7..35ea984d74f0 100644 --- a/drivers/bootconstraint/core.h +++ b/drivers/bootconstraint/core.h @@ -32,6 +32,9 @@ struct constraint { int constraint_clk_add(struct constraint *constraint, void *data); void constraint_clk_remove(struct constraint *constraint); +int constraint_pm_add(struct constraint *constraint, void *data); +void constraint_pm_remove(struct constraint *constraint); + int constraint_supply_add(struct constraint *constraint, void *data); void constraint_supply_remove(struct constraint *constraint); diff --git a/drivers/bootconstraint/pm.c b/drivers/bootconstraint/pm.c new file mode 100644 index 000000000000..f52bff240dd5 --- /dev/null +++ b/drivers/bootconstraint/pm.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 Linaro. + * Viresh Kumar + */ + +#include + +#include "core.h" + +int constraint_pm_add(struct constraint *constraint, void *data) +{ + struct device *dev = constraint->cdev->dev; + + return dev_pm_domain_attach(dev, true); +} + +void constraint_pm_remove(struct constraint *constraint) +{ + /* Nothing to do for now */ +} diff --git a/include/linux/boot_constraint.h b/include/linux/boot_constraint.h index 4685ff55fff8..fbccb62f423d 100644 --- a/include/linux/boot_constraint.h +++ b/include/linux/boot_constraint.h @@ -17,10 +17,12 @@ struct device; * enum dev_boot_constraint_type - This defines different boot constraint types. * * @DEV_BOOT_CONSTRAINT_CLK: This represents a clock boot constraint. + * @DEV_BOOT_CONSTRAINT_PM: This represents a power domain boot constraint. * @DEV_BOOT_CONSTRAINT_SUPPLY: This represents a power supply boot constraint. */ enum dev_boot_constraint_type { DEV_BOOT_CONSTRAINT_CLK, + DEV_BOOT_CONSTRAINT_PM, DEV_BOOT_CONSTRAINT_SUPPLY, }; From patchwork Fri Feb 23 10:23:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129348 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp436420lja; Fri, 23 Feb 2018 02:25:57 -0800 (PST) X-Google-Smtp-Source: AH8x224p3eytGjfuQwas4QXlaExwovumC2g8gQWzLho6p4YYQwqx6I1KY1mYlZfVejGi6RsnmfT+ X-Received: by 2002:a17:902:7404:: with SMTP id g4-v6mr1246346pll.235.1519381556980; Fri, 23 Feb 2018 02:25:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381556; cv=none; d=google.com; s=arc-20160816; b=Oi8odgGDhpUnMUZIzXQ+kz75JrWEvmD7/ftWfxJvyo2pCpaJZ7DBURB1HLnr9Zz/P7 YllukZDPqUNLaISbvBOMKbSCmcASdIgyVsSd80crqhNYGrko8wgyEgH24bh+yxi0PZ+T SnZwkURzH1ZHDWDVYw6nM3s26GwhKMZ/YtJYEmkXqiBvCp/SxikAImccZBov+nxOa+AN AAgMjPpURbd+UEelqw6SDlswauoD0k0Sp4hKjdy3xGqPmDwjdvxyDhMB7QnJYEscjWTo sTcK6naJWvDwaAjlvQdVteIPSAP7k3wlEampKYzWXS3XEfSheF7o/BNA+Ht63nkXAlp7 0VJQ== 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=Tyw/mrJdFFjfo1YJuoZPOmEuLTwlV0np1KAhDQwf3+8=; b=RIBO2u2/HPNWUPVSsMmA/sABymm+mTyGmNwkLdoopLbdHmhVp1IkJsmu4ttFNnVaGC Fgxi+wkyzgqL5styMcKLI/osbGHHGiWh+xc71H5v4Av/xtopXed0Yw6pbPY5Lp6sqpNA sWtPUfo5KZncrPlJtCpe1LVMRq0mOuDqMGa0kbaPUBvGyP6CZXMem1x7CJ8hhFIYTsGa GYmAbJqIQBi/A4nFD/55zoCJK8XL4AsMcDsMJGbrb65JDcnO3fJWIbuajmwYb8a4r9P6 XJ67E1tL9fCA3JCG8crMpmzK9wGjOzTqh5VBZOvH4dldrSxrY/lmFGIGP1LAuXSDf+CH bTLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LKeAzf8z; 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 w124si1610705pfw.55.2018.02.23.02.25.56; Fri, 23 Feb 2018 02:25:56 -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=LKeAzf8z; 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 S1751698AbeBWKYb (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:31 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:41751 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbeBWKYY (ORCPT ); Fri, 23 Feb 2018 05:24:24 -0500 Received: by mail-pl0-f65.google.com with SMTP id k8so4658949pli.8 for ; Fri, 23 Feb 2018 02:24:23 -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=Tyw/mrJdFFjfo1YJuoZPOmEuLTwlV0np1KAhDQwf3+8=; b=LKeAzf8zPPJ7F1dgz9YajaImgKkBeGcob/kC3HnHdqWZMCp+FPq8G9gpsLG+5WFVj7 kYvhEVJ3bK5WzfwrspLhlotYNjzzcUMXYllY3nmmwBNq/Z8R1ZYy/uP+E63PvIzYwk+T nLM/GQleTWJAdO8TCZm4r6MiTwDRPMzwxfgw0= 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=Tyw/mrJdFFjfo1YJuoZPOmEuLTwlV0np1KAhDQwf3+8=; b=BNHNPekmq/G9ijzXrb3xxV8gFQnC4JSjRzyhDlJi8PndmUpz1Mf+SX7K1gaBAM7jIE DJIb8LUdVw4visBoM2KOMQ/yocqePdH+SOZADEth7F+dLlC9nxO9QekQwDQpw9GUWKkE vHo1cSGDolXMh7CgDrykiWhu+qCuKi8nY/WhEUHi6iv8qhj6gwP2Z5PzjusQ4rAlzXel 7YPyMdZcW8jiXqM3xAS8s9PJLdTqZnDsm+qTn6JHcGtuCEzrLyZKg2ITF37G/5BGIVFV ya+498KB15ciZgwH/MCYYG10B7SDmgiNUksqxk5/2bb+v7jLD2+0dG9LRdcGxCZ8z96F vR2Q== X-Gm-Message-State: APf1xPBm1sW5vRG9m64uAYsvTmc1wsakiYFWT8PRZ2s2V+8mZctx0sth Mo5xtvvYfjbWBnCq0XnWpT7vuw== X-Received: by 2002:a17:902:3124:: with SMTP id w33-v6mr1252362plb.356.1519381463462; Fri, 23 Feb 2018 02:24:23 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id g16sm4632893pfd.23.2018.02.23.02.24.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:22 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 07/13] boot_constraint: Add debugfs support Date: Fri, 23 Feb 2018 15:53:46 +0530 Message-Id: <745f7dea835174ff837af39a2ae6e9f2b8b94cc0.1519380923.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds 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/bootconstraint/clk.c | 3 +++ drivers/bootconstraint/core.c | 59 +++++++++++++++++++++++++++++++++++++++++ drivers/bootconstraint/core.h | 6 +++++ drivers/bootconstraint/pm.c | 11 ++++++-- drivers/bootconstraint/supply.c | 9 +++++++ 5 files changed, 86 insertions(+), 2 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/bootconstraint/clk.c b/drivers/bootconstraint/clk.c index 90262fe9057c..1ee8ab1978a5 100644 --- a/drivers/bootconstraint/clk.c +++ b/drivers/bootconstraint/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/bootconstraint/core.c b/drivers/bootconstraint/core.c index a6148b625b48..5a6984276139 100644 --- a/drivers/bootconstraint/core.c +++ b/drivers/bootconstraint/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/bootconstraint/core.h b/drivers/bootconstraint/core.h index 35ea984d74f0..3084baaee127 100644 --- a/drivers/bootconstraint/core.h +++ b/drivers/bootconstraint/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/bootconstraint/pm.c b/drivers/bootconstraint/pm.c index f52bff240dd5..65810d9485bc 100644 --- a/drivers/bootconstraint/pm.c +++ b/drivers/bootconstraint/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/bootconstraint/supply.c b/drivers/bootconstraint/supply.c index 352ded92d057..8965db534be6 100644 --- a/drivers/bootconstraint/supply.c +++ b/drivers/bootconstraint/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 Fri Feb 23 10:23:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129349 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp436574lja; Fri, 23 Feb 2018 02:26:09 -0800 (PST) X-Google-Smtp-Source: AH8x226VSMUwlVGgYxGvXgp9LkSpN+MXERBbHC4YiH1N2YXRnxT4bmHr0vw/MSX8gKxTHQY30ugW X-Received: by 10.101.65.131 with SMTP id a3mr1056589pgq.270.1519381569044; Fri, 23 Feb 2018 02:26:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381569; cv=none; d=google.com; s=arc-20160816; b=GvQmPP9uOWz60ioHWCathk/LazbNDhC8PqwbL9+SSNXy2Zf/kOxmpDBYaiqJesMe4C h4/vDpV3KgKkxKD+KXioIIoRna1Ob+gd2ou7Vhi61wvaUImmhIB0NNTk5kVXl+mm0QwS 9sPbKPtlS3KXUhdeMmuR1AlIDI/AoAoYGOhbwIRFQtm2lygyj/S26L6YaRPXT1DmrWGf vv9p9HL/2tXLwq84XDWCtwrYuTVTSEt7VeE3GfF7O1om+p7drWIce28SxO33B4cEDYCH gB/kC2mn/oEBHktGipWksTq2t5nx26l3+u4SioDsHsoFqIp4vgWI5R2fWvTvpDyLjgxr G9pA== 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=cZWpDkD2kN3WHB175w1F2nQGLpuE0VK/FoyazSQXwcs=; b=Q7VBAFN4ecZC6kN+2heEvCEFn06lBTXzkJAtdEH1pwdFADWMHkxt7fWwauTHHj+ERR DqaVNNjx73WHIn2QQvLX70PV8YY2vmwFlYeFCR5dY1ODszhZRIM18FOUuieMl68VJC4R nZy6V+YLkvlm28bE7hmPxTpRbRVjF1QVBRnrTOYa/+TTucdpk5CMr/YJmJ7+GGgDxFZL Nna7xdBMEx57HQ1VDewI/boTnkGenBJkS2nQ3fXHdHE74BKvUJD2gdsaHLagBd5MJUCj ce0ZthzSpbHW4ovj0JAjvunL7dVinGJNSmyo+8K0WNVjnyk4GmLnHF85Qre7Vez2tW2B ejbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NhCHa6PK; 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 w124si1610705pfw.55.2018.02.23.02.26.08; Fri, 23 Feb 2018 02:26: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=NhCHa6PK; 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 S1751662AbeBWKY3 (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:29 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:39993 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751576AbeBWKY0 (ORCPT ); Fri, 23 Feb 2018 05:24:26 -0500 Received: by mail-pf0-f195.google.com with SMTP id m5so3339636pff.7 for ; Fri, 23 Feb 2018 02:24:26 -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=cZWpDkD2kN3WHB175w1F2nQGLpuE0VK/FoyazSQXwcs=; b=NhCHa6PKhZ2kc4+3osFErmAABkZQYESeRqLGR67Mrgh3k5MNDqPxHpLYIaSUh6WD65 zkDud8lzjbNaYrCBDV2l/XoPvhlJedR4kKnutEiaxeeOoD+3SA6c/9rUyfhWHcUwZVI3 Cx3rIoQPqdSTx9Uz2McgpmthLy0q+m0ueoYBQ= 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=cZWpDkD2kN3WHB175w1F2nQGLpuE0VK/FoyazSQXwcs=; b=uU26VjKWQ03kULSPJVILHtwa3C8qKozLDT18+otXxtTpXNBbR5QsslGbs2ZJUqMdN0 OXKkeKOVRt0THIuuCNmluG7tqXdtjZ3Q7aNKvuW5tQNlYIiMsREBVYoc3VrKJtiPkLUB M1NJFJFE2rhHy2jfrfWZvofecbAqLiFgIuLCK5xFHZFO5VGr+yFb5TXSU1LDb3IuILDk krt2A/1Fal86u0JFKSUSdI3MTTFWKiB6WFdjgwC2mGxCswfIlZRGt017B6ubdQB0j4RT 2ZLOejIHrYeKK0gSWzFBYsUh6AL3m40I2BhoQzuBsWBzwKiv0y0YElWSKl/t55oYBHbx jI5w== X-Gm-Message-State: APf1xPDm8qqQoGyrHLF93sSAqJAmtnamrHFeecCai4WL9igDLUYhLuZF NDXrPiLBILnJXK9TaFB1WRqqAA== X-Received: by 10.98.72.10 with SMTP id v10mr1293274pfa.128.1519381466095; Fri, 23 Feb 2018 02:24:26 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id a3sm4361730pfh.120.2018.02.23.02.24.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:25 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 08/13] boot_constraint: Manage deferrable constraints Date: Fri, 23 Feb 2018 15:53:47 +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/bootconstraint/Makefile | 2 +- drivers/bootconstraint/deferrable_dev.c | 241 ++++++++++++++++++++++++++++++++ include/linux/boot_constraint.h | 27 ++++ 4 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 drivers/bootconstraint/deferrable_dev.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 777267aa1710..482d971ceac6 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/bootconstraint/Makefile b/drivers/bootconstraint/Makefile index b7ade1a7afb5..a765094623a3 100644 --- a/drivers/bootconstraint/Makefile +++ b/drivers/bootconstraint/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/bootconstraint/deferrable_dev.c b/drivers/bootconstraint/deferrable_dev.c new file mode 100644 index 000000000000..34c493812869 --- /dev/null +++ b/drivers/bootconstraint/deferrable_dev.c @@ -0,0 +1,241 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2018 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 fbccb62f423d..91cbcc66b2c3 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 Fri Feb 23 10:23:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129343 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp435432lja; Fri, 23 Feb 2018 02:24:37 -0800 (PST) X-Google-Smtp-Source: AH8x224MnxHgvyXmrIp4lsBIKi2glbqRJ0Sj7GFkjcwk2VdlrKu6GBvEobUqZttgndUwgxtkGNhj X-Received: by 10.101.101.10 with SMTP id x10mr1073043pgv.223.1519381477797; Fri, 23 Feb 2018 02:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381477; cv=none; d=google.com; s=arc-20160816; b=JDte8xF/YLgj2S9V67g6QFe4+BN1P2NHkqFjtjzRLIoP01uk6dukwLNolXDMKEMCtS wieb+PjtW491zeqNwW55m6ERPgsTeBNdZGVphFCG9tRT/dldWG78MySsdcTIlwrsEk0Y uhe2LFj7FYbGtbn92nh0eC74wupC/0MX38JWt/2cGVbENmOeiql9xIFJ9tEMjl/oV88k ir71HoYnQn2eTQEjawPvyPMZlQJRMzHJPsnBfzIxkiUsGjdM5HDiL154f0zofnZH7ptg oVGjcNzOoRVkZYjAGCLR+FiXNNpVM84cHsrrVgvwYl3YZGi6CU7s1kqcCUSR0vY0GKaz h8Tg== 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=SrMM0NVYzjnPGa3Htdpu08NtGVva1H4lk0FP2in38Iw=; b=Mcwx1Uzkq8U3d4F6PCGhs29gI9KiRyuNmy6ov7k7v5vVuSv/N2LNZm4p+vfC6rQjn4 IgNQ4zRjyfcVvfoO0qaKMCCFnA9HBv83rR7RoW1/7K+i6kJb3x7SbuGC4sFn41i+xesh w76eEziRgsff5ylwZrC/YaDeOrAUROQDehlhyRbViGciZjkQKGNGFU4HWQqU/PVja6Yp uOFRPiF2UdveiZ7OntNKhK/kXtA5+cJEGljcazIg8ZZO6Qddk2yRKdVsj3oQMWTqvIaV MqKYpgZvDqot/aJTCMRZs1ewaLVXAtvQszK+rvnQMny2RKQwDdeK4WHHBcAyVsVvkgol qa4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ON0P1ZhG; 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 p10si1601900pfd.250.2018.02.23.02.24.37; Fri, 23 Feb 2018 02:24:37 -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=ON0P1ZhG; 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 S1751511AbeBWKYd (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:33 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:38475 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751645AbeBWKY3 (ORCPT ); Fri, 23 Feb 2018 05:24:29 -0500 Received: by mail-pg0-f66.google.com with SMTP id l24so3201687pgc.5 for ; Fri, 23 Feb 2018 02:24:29 -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=SrMM0NVYzjnPGa3Htdpu08NtGVva1H4lk0FP2in38Iw=; b=ON0P1ZhG3sfucEjDb8hBhy7HlhNOOy3C2ybi/M6tI7qJ2v74p0wALT/p52VXv0OqvL w1t2Wo/tIXrdTJ1DdX6zItewGSdGaxjcG7uQRrnXSxSbKS/m/vFxjQTlB/+MD5FiQ1mt Y4mCeyg3t2NGwr8W5SLpRcnf3gWfHBXt953Gc= 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=SrMM0NVYzjnPGa3Htdpu08NtGVva1H4lk0FP2in38Iw=; b=hi4TVwzCyx6xGZkQyzps79SXo4VaNChD+cRhy1IancCR2XJHEKaq0zKemSRO9VqHhS hX88cdUcwF5ND4j+v83cnjrdGD6Jp0a4doPWCeJUXmJunEPz2fGk3sRwo3ixwxLemt/D 4eHGVDinOFHgT/Lxtrk0lGxbTCEnHzYsT5/UPDObgN3g3RrqdeVCVp+YwmJ5jsQZ3/Qo v9d5Bn61fQJ4QSvssXHcOTxEotU3QiygSBzVNCG0pQV0YQnFMsFQb8B39aK+sorrk+MQ d7pLe9/16g2/N2bjFrwS01gMuGUs92Gvl6dM7cZbH0buhz1AJ9BXeBwdfz/m4mpDbNMP hcxg== X-Gm-Message-State: APf1xPCymQjH/CfIEQQQD7SacQwWcUaX4MlrvaCHkUEZvl3aQ48b0IwD 0IoLYA+jkgKh46Rk2r6TGT3mgQ== X-Received: by 10.101.66.193 with SMTP id l1mr1046549pgp.57.1519381468764; Fri, 23 Feb 2018 02:24:28 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id z4sm3858558pgb.4.2018.02.23.02.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:28 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 09/13] boot_constraint: Add support for Hisilicon platforms Date: Fri, 23 Feb 2018 15:53:48 +0530 Message-Id: <0fc2fdf3744e1a0215a42c87759598db4160b659.1519380923.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This 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. Cc: Wei Xu Signed-off-by: Viresh Kumar --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/hisilicon/Kconfig | 15 +++ drivers/soc/hisilicon/Makefile | 3 + drivers/soc/hisilicon/boot_constraint.c | 158 ++++++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+) create mode 100644 drivers/soc/hisilicon/Kconfig create mode 100644 drivers/soc/hisilicon/Makefile create mode 100644 drivers/soc/hisilicon/boot_constraint.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index c07b4a85253f..7fd6d59f15bd 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -5,6 +5,7 @@ source "drivers/soc/amlogic/Kconfig" source "drivers/soc/atmel/Kconfig" source "drivers/soc/bcm/Kconfig" source "drivers/soc/fsl/Kconfig" +source "drivers/soc/hisilicon/Kconfig" source "drivers/soc/imx/Kconfig" source "drivers/soc/mediatek/Kconfig" source "drivers/soc/qcom/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 40523577bdaa..2daf7c1a52ee 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -10,6 +10,7 @@ obj-$(CONFIG_ARCH_DOVE) += dove/ obj-$(CONFIG_MACH_DOVE) += dove/ obj-y += fsl/ obj-$(CONFIG_ARCH_GEMINI) += gemini/ +obj-$(CONFIG_ARCH_HISI) += hisilicon/ obj-$(CONFIG_ARCH_MXC) += imx/ obj-$(CONFIG_SOC_XWAY) += lantiq/ obj-y += mediatek/ diff --git a/drivers/soc/hisilicon/Kconfig b/drivers/soc/hisilicon/Kconfig new file mode 100644 index 000000000000..7247b13a60a2 --- /dev/null +++ b/drivers/soc/hisilicon/Kconfig @@ -0,0 +1,15 @@ +# +# Hisilicon Soc drivers +# + +menu "Hisilicon SoC drivers" + +config HISI_BOOT_CONSTRAINT + bool "Hisilicon Boot Constraints" + depends on ARCH_HISI + select DEV_BOOT_CONSTRAINT + default y + help + Say y here to enable Boot Constraints on Hisilicon platforms. + +endmenu diff --git a/drivers/soc/hisilicon/Makefile b/drivers/soc/hisilicon/Makefile new file mode 100644 index 000000000000..c63cb9b17bed --- /dev/null +++ b/drivers/soc/hisilicon/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_HISI_BOOT_CONSTRAINT) += boot_constraint.o diff --git a/drivers/soc/hisilicon/boot_constraint.c b/drivers/soc/hisilicon/boot_constraint.c new file mode 100644 index 000000000000..fa0b25d6ab8e --- /dev/null +++ b/drivers/soc/hisilicon/boot_constraint.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) 2018 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 Fri Feb 23 10:23:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129347 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp436068lja; Fri, 23 Feb 2018 02:25:30 -0800 (PST) X-Google-Smtp-Source: AH8x225bZqgt40lSU+/vAcnsd97gJzKMg17U0Qs+j2L9b851tLgQD7zI+zCCSukzyoRzGkqJDqaZ X-Received: by 2002:a17:902:5609:: with SMTP id h9-v6mr1263896pli.302.1519381530602; Fri, 23 Feb 2018 02:25:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381530; cv=none; d=google.com; s=arc-20160816; b=y2oI8z0Ns10VUceglZnSvM0G934M3wBWf5Mx838qahauaMpQYIjXDLAsDp2bFvovJM qW32zOC59I2YWv8jwBL460Ry0Ewpq6sMCLqfzNefFpjIR4yh1MKin7eH7YrvVhz6eoEH DdR/jJMgXIhHWsLglhidAxo4XO8Onhr8eG792O2yPCmIGUhlnSTwFm/rpnLheR9N9E+2 YjgL0F3kEgctbS4mGQ0VWuwIAFM/QNRyvEkcHa79WC0vZaSK8jDA9eekPUf39RVP2utW XLm/4sdM8xHqBgbmKM//dxaNFw17tjXdkqieHH5mu5YfHBQZtw60xlyM6DaLKe9yfYNY pejA== 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=jy9bacmiEaTG8qZrphT1fmXsWxfWUGpNVs4UHp2CHVg=; b=hXwazCKOD32nAqD8KggMR2Iu0rHqXVqrL3HDvnGiL75EVFBpKNQQkIaQoFQJ1+AJ9s +kr5TPwIHA2Wv4FvTQE+OtyuuPdMt0jGpFnWbAJ8fbI95K+4I1de15x6c5qeBaKk5hZH gP0o2KZAbMwB6iGhBM7CfoXXFa/9yUpNndDrHbN2q33k9t1gafvZwXGpDdKnE9qERgO+ rg8WV1qlDHjSfWoVu8nqW+nmwA9C8TWfzxfjewFLEYgrS6WHSa1Oi2EdAIjlkZ2fYe4q +21/YlmcVpzTbHsCTlDE5Fgjua5L3kGOe1EGYFX9SMVt5h0iP8UAtDXy8q6wHArZpMIf Eo2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KtydCZma; 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 n7si1342493pga.505.2018.02.23.02.25.30; Fri, 23 Feb 2018 02:25:30 -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=KtydCZma; 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 S1751824AbeBWKZ0 (ORCPT + 28 others); Fri, 23 Feb 2018 05:25:26 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:40921 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbeBWKYc (ORCPT ); Fri, 23 Feb 2018 05:24:32 -0500 Received: by mail-pl0-f68.google.com with SMTP id i6so4660414plt.7 for ; Fri, 23 Feb 2018 02:24:32 -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=jy9bacmiEaTG8qZrphT1fmXsWxfWUGpNVs4UHp2CHVg=; b=KtydCZma6QfLjryeitSTKkAiuCqwLHeYl8n0YQsaZDVWEoH4i3ExULkhcl9fidQZYG Cfrxo3WV9bOlMsoN6wdnVn3cod/JMbV7QPhTPZqIGhO1gbWRch3PCLkd5ZSo8eHvhZZn w+8noMmY4viXhJRhpOpE6zaCfIeVsbk9Mi6JE= 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=jy9bacmiEaTG8qZrphT1fmXsWxfWUGpNVs4UHp2CHVg=; b=hUEEgtNonOOpan1TqmNfKRLwa1dhbWSwlAkwWOklifgiHECdTfHGIhnqhyOUC6z2mJ KJ0if9Yqc2K23b7gSh4fJ7715bJ+L3OKN/nr0xsU1WmT85WNzYQTJk8rg8hcynEnN/+8 4sbyunSenzEUp9j0X++9S5wVRmPhE9BOSrYknV99eg1nLlcsUb8vyBoSx17yT2pBeqzT 1xF8J3IJPdNAoQik0JviLczBS3I+j4/qNNLtjDZDd/mHnZk6kmt48Er4n7FBdy+2sNHp fe9xXisntdQVERirj6jcxrqW/soPIBg8gDlXfG2r/ds2iTnFcYQ3jOXZxqk8/UZyvud4 sMlw== X-Gm-Message-State: APf1xPCNVxpBULO/yrQWHd2dBoiqSVrlkvAoSpR+R+Zqo0R/KK3J7Y5w TvAsL5agtyOR6pa7BJauo8C8ww== X-Received: by 2002:a17:902:5203:: with SMTP id z3-v6mr1287606plh.392.1519381471526; Fri, 23 Feb 2018 02:24:31 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id b26sm4529898pfn.60.2018.02.23.02.24.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:30 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 10/13] boot_constraint: Add support for IMX platform Date: Fri, 23 Feb 2018 15:53:49 +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 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. Cc: Sascha Hauer Signed-off-by: Viresh Kumar --- 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 - drivers/soc/imx/Kconfig | 8 +++ drivers/soc/imx/Makefile | 1 + drivers/soc/imx/boot_constraint.c | 126 ++++++++++++++++++++++++++++++++++++++ 14 files changed, 135 insertions(+), 140 deletions(-) create mode 100644 drivers/soc/imx/boot_constraint.c -- 2.15.0.194.g9af6a3dea062 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 c864992e6983..d6af06129491 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); @@ -321,8 +307,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); diff --git a/drivers/soc/imx/Kconfig b/drivers/soc/imx/Kconfig index a5b86a28f343..7a3fbdfa9db9 100644 --- a/drivers/soc/imx/Kconfig +++ b/drivers/soc/imx/Kconfig @@ -7,4 +7,12 @@ config IMX7_PM_DOMAINS select PM_GENERIC_DOMAINS default y if SOC_IMX7D +config IMX_BOOT_CONSTRAINT + bool "i.MX Boot Constraints" + depends on ARCH_MXC + select DEV_BOOT_CONSTRAINT + default y + help + Say y here to enable Boot Constraints on i.MX platforms. + endmenu diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile index aab41a5cc317..49663200faac 100644 --- a/drivers/soc/imx/Makefile +++ b/drivers/soc/imx/Makefile @@ -1,2 +1,3 @@ +obj-$(IMXIG_IMX_BOOT_CONSTRAINT) += boot_constraint.o obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o obj-$(CONFIG_IMX7_PM_DOMAINS) += gpcv2.o diff --git a/drivers/soc/imx/boot_constraint.c b/drivers/soc/imx/boot_constraint.c new file mode 100644 index 000000000000..4c52fe3794be --- /dev/null +++ b/drivers/soc/imx/boot_constraint.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) 2018 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); From patchwork Fri Feb 23 10:23:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129344 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp435502lja; Fri, 23 Feb 2018 02:24:43 -0800 (PST) X-Google-Smtp-Source: AH8x224bRlF4zUtG+56R7SruEgv/heZnA2ANJGn8mSZ0KkZnOBCSky7E2e81+zD2f9QNgtxzC602 X-Received: by 10.101.74.208 with SMTP id c16mr1079396pgu.116.1519381483513; Fri, 23 Feb 2018 02:24:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381483; cv=none; d=google.com; s=arc-20160816; b=fgCBTIQrA1fgxPRq6IHL8Yx66xSlyW9P3g+SsETQdZ1N0faUEcfE0sErcPHvhi3iUS QW53f5w0m9UfiEMFaCWIOCuyNXEenHSguCfKfGuAcdWhc3UVVg3k6t4dmcF87wXhdxGv pYeWgT7g1XSt6XEACjn/1rHng8QhqeyJxXw+DYG27jh4E+IB52YZL4kO9GjWjphXaAFL XPnlOtOMJ+5yVrxpiZJ1fbCSDs1mSQtdF+p/5RbMT4tjuJiV+Y4YaMOP65Q7BFevV0FY TUUorLq3jCuJ123tMRHjSgqWN35lBDpNzUn4ijHahQtP64iqNZKvD8hCfM4RBKVr8XML VvEg== 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=TmqEy5tNbU3aZLQEfNdJekSwUZ5acIZD6DZ6mMrZ9EU=; b=RKkDybf7L3EMorr860fdMuDoQe+fcGjx2OKebeg6qVYRo7onUt16qgy5Z+Zfr8OL97 po2Q/6o45HEAN0EJNcSwfPqoa76oIkbtNoNh3elZMNpyfi+txczhCWKssfQLsKrvTu5Q n+K2dSc4T5yAdE5uZe+KpCwd/c9NpYfyYjsliI5K1jRdQP8wBhGZ2LpIbhoBZQRQJ+wM 46w4Om86lfGR5svEDGUnIqw4msbUm4QteS9XddnSer8/GheVhFPuGvv97zAdnCQvKlHm Fu+gxqj9uyrXk2wVOzxFScr8iBYYiE/Rw+rqBpcerANe9LuDGFcZAdUIkI5jQ9FEIIvD 19Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OqKN9T3/; 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 p10si1601900pfd.250.2018.02.23.02.24.43; Fri, 23 Feb 2018 02:24:43 -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=OqKN9T3/; 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 S1751765AbeBWKYk (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:40 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:46216 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751664AbeBWKYe (ORCPT ); Fri, 23 Feb 2018 05:24:34 -0500 Received: by mail-pg0-f68.google.com with SMTP id m1so3193879pgp.13 for ; Fri, 23 Feb 2018 02:24:34 -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=TmqEy5tNbU3aZLQEfNdJekSwUZ5acIZD6DZ6mMrZ9EU=; b=OqKN9T3/S4FJFhH7rpDZUyvkY6kw1r7ds+qEmMlEMTmCNl0n2vhOtI3Rk0OIkzH71l ji23k5jXr2n8G06W17D1DsLSLfpoWQTwiW7R+McxpHs0IVW1SD3LH+xZNHPiPyDaknli I0bDfAmNhgBqFUo1peAXdWd7R9Nu7Kc+djHSs= 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=TmqEy5tNbU3aZLQEfNdJekSwUZ5acIZD6DZ6mMrZ9EU=; b=Kc2TqQlH+K4GbXX0J6JiC1b/9pUzmaL0rp6fCkTi2KAwvbspDCKQdKcA5uMWngNdvr ptyE8M+EYgaQy4iIeSmUT3J/YGNQbhqm7a+blNUk2F3d0i3+7IBRM8jnKFV6RDwiI8Zb TCHe7EAxRzHEZeXaRfoGz5TNpD4DEoK9P5LYCAVakIYiWWica5l8RxF7RPYNSnGMFbct 5kbz9Oyz0pI4KEQXrDetQx+0jE/XQvFtNMj+KwnJAER696YCDbMcwSg6gnwiPUljqnQ2 StIJ+BlffAntlwURUR3RbJFEU95IiootpWCNAfEHsUWHZ6e2BWUY0NnwBMU4rc+n43K1 N5eQ== X-Gm-Message-State: APf1xPBHtTANhgpl3RahTZCTfx9mE/eHlHmm0S4Vt18b8c23p+3HxmsP MfZ/PStGQuDhT8ceRWU6ioRZtw== X-Received: by 10.101.65.71 with SMTP id x7mr1057109pgp.203.1519381474360; Fri, 23 Feb 2018 02:24:34 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id q13sm3767693pgr.15.2018.02.23.02.24.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:33 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 11/13] boot_constraint: Add Qualcomm display controller constraints Date: Fri, 23 Feb 2018 15:53:50 +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 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 --- drivers/soc/qcom/Kconfig | 8 +++ drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/boot_constraint.c | 122 +++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 drivers/soc/qcom/boot_constraint.c -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index e050eb83341d..7bbe87f9c775 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -107,4 +107,12 @@ config QCOM_WCNSS_CTRL Client driver for the WCNSS_CTRL SMD channel, used to download nv firmware to a newly booted WCNSS chip. +config QCOM_BOOT_CONSTRAINT + bool "Qualcomm Boot Constraints" + depends on ARCH_QCOM + select DEV_BOOT_CONSTRAINT + default y + help + Say y here to enable Boot Constraints on Qualcomm platforms. + endmenu diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index dcebf2814e6d..fcff64ec6538 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_QCOM_BOOT_CONSTRAINT) += boot_constraint.o obj-$(CONFIG_QCOM_GLINK_SSR) += glink_ssr.o obj-$(CONFIG_QCOM_GSBI) += qcom_gsbi.o obj-$(CONFIG_QCOM_MDT_LOADER) += mdt_loader.o diff --git a/drivers/soc/qcom/boot_constraint.c b/drivers/soc/qcom/boot_constraint.c new file mode 100644 index 000000000000..ca01eb50d9a9 --- /dev/null +++ b/drivers/soc/qcom/boot_constraint.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) 2018 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 Fri Feb 23 10:23:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129346 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp435825lja; Fri, 23 Feb 2018 02:25:10 -0800 (PST) X-Google-Smtp-Source: AH8x226y92TlIN6hK9/etRoQvpT+P8D70yuI9J0x1997Nlw1J54/zhnlwkgzS4AYgvrOeMYEhoUb X-Received: by 10.98.198.156 with SMTP id x28mr1292122pfk.22.1519381510372; Fri, 23 Feb 2018 02:25:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381510; cv=none; d=google.com; s=arc-20160816; b=Vj1aksWoN16PSyhYKdpyfQ9jxG4puF9eMXgwNUhgdNDlrTMEedDyj3qtzBGOoXMTWz NITdnbdd/vyH5dBs3QlkET4oK4TUES25J2jP+n+9E0Dk2Qdy+eK6xwpaJ/1Mnf9PTULu 8oZ0lSLO1SDQp50TOyYnKfmxZH87SovrhrKa9evUhIXDn0o/MFBKAq6u8SNR0ZFSXFaQ wIDV5LOshfvRCChKMlR46fW8JeGepFC6uGObnIvyaRfBz//rGCExW+cQcQIy6QXZLXgA 3IxsVnnbyMkkCH1IAj52a8Tyngx7/4PVSVjJHntn49DGhpx6ahr11YGI8GR7eJkQszNg jacQ== 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=qvmDTN+8fSKPogaL58OOpt3TAEzMoLaSmMJYpcngC9A=; b=y6YJnT9Y/m8Go5s7hW+xldLSjG4tx3zRBrFsXxoXTHk/2dwAgWZTLKZG/kN008kEKf AIFND6GGoqsDYPQZNC16ojasDw/ps2j0EHhc6/aFq1uDsciyc9jGUq46OwJefL/GDbMl XSls6Cz08JJSKfjsH6q0t0oeA/NscSvaJUIipU1A8ulrTs23mA2XL6NK+vZ8YXWFBPef DwYg/b1pRzknCwXGlmkFEtLRjGEKkN8kDAaMnl8NfS+AxpsId8Fblnpuv/8AMr30n/Xl s9xs3S+rA2z52DoNuo42W8bWi/WFwOEIF6/5gOSBspYbLDomtbJhH1MNrqe/OGk0SMjI 6UgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vjx+Hg7P; 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 n7si1342493pga.505.2018.02.23.02.25.10; Fri, 23 Feb 2018 02:25:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vjx+Hg7P; 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 S1751799AbeBWKZH (ORCPT + 28 others); Fri, 23 Feb 2018 05:25:07 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:33573 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730AbeBWKYh (ORCPT ); Fri, 23 Feb 2018 05:24:37 -0500 Received: by mail-pl0-f65.google.com with SMTP id c11-v6so1251578plo.0 for ; Fri, 23 Feb 2018 02:24:37 -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=qvmDTN+8fSKPogaL58OOpt3TAEzMoLaSmMJYpcngC9A=; b=Vjx+Hg7P3HkT7gRV7+61Bb5z4T7YZqEXxn4HMLamgywfWElgSy6v1if1LaY8dFc+Xl 3kwBvhcdlpK604o9+M1bxtZvwBdNaYov9PIdVpdyEFrIQyHH1ZEXmj0fkaYniXG2i0wk R3wMLhU/JXTuBbUtdzOjtO/NSbJf1EPKDzMUg= 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=qvmDTN+8fSKPogaL58OOpt3TAEzMoLaSmMJYpcngC9A=; b=mHg9Pv/+EmxXJH1WOabcbJ0VTwfPv4EHgnXOUCwLam91reM3imHQIy0nLNQWttRCn+ OWMBdYlJNqtKBV/7Kl138hBUqUA0hmS47PR7OkwlNpTARwp7eTQ8phAsczHiAdv8G3NC T4Kgjsa52yORUTMrAp/SggHT5J+8e/ilHhM0B3GO3EGogBk8yKrNYzmv3duZfa/V0nS7 E8oQPROqVPQ6j8bDqvwn5ivfxigO90MZ+rMZSaMAL6V4HiclkOqAxZ2YmB4sXiOzDmhY /k00U49RePYi8dhGfefE78qFhYNYin+CofDt2qRUw7+bf9iFF0Cn57MHFPxcxZiyTfnc 6bxg== X-Gm-Message-State: APf1xPApsD4zWE3hwkdicRQDeW2yO1TeSq0qS2+FjUIJErmJpCvPD3gf guPGcypWegby+0JYJEtJw08esw== X-Received: by 2002:a17:902:7509:: with SMTP id i9-v6mr1303270pll.220.1519381476875; Fri, 23 Feb 2018 02:24:36 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id f5sm3296754pgo.58.2018.02.23.02.24.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:36 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 12/13] boot_constraint: Update MAINTAINERS Date: Fri, 23 Feb 2018 15:53:51 +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 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 9a7f76eadae9..e6a767245ea9 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/bootconstraint/ +F: include/linux/boot_constraint.h + BPF (Safe dynamic programs and tools) M: Alexei Starovoitov M: Daniel Borkmann From patchwork Fri Feb 23 10:23:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129345 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp435603lja; Fri, 23 Feb 2018 02:24:51 -0800 (PST) X-Google-Smtp-Source: AH8x226/8XQfERrX35zjBRsL9tQpjB+/y9YAMW0jJvggM60pm7DWyYp5RfFAmzwecfxHAFD2DW8p X-Received: by 10.99.152.10 with SMTP id q10mr1095640pgd.212.1519381491047; Fri, 23 Feb 2018 02:24:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519381491; cv=none; d=google.com; s=arc-20160816; b=IgKiX52xUUGWNj9bC2w2dNOo3uj5pmNeyXXVrz+XYmH2SzRxEpljoD8RD3wNdABQZd 3VxD/stXHbs7mqmct5e0smk46SRPooq6ztQNHUF6h6i/6JUhtcGodh7Ew4Lb4/tD6oEr yOs4dO+IxKIDTnotiGRtSpnpVfm7HimsMlEUakSIv8bpaj7cqcr68kcrl3+px+oXPM+e bH1GPfrzubz5zgPP5GRo5EuJqbxMwCGLkg0+/WpjMgQ0rHjam+l0QAuAvLo7WyvuvsgG u9ipCZ9ciesW+rhEZFJLs3V+oViBuK0A92ifg3lGrrsMxqt6MBjBWyKaR2sK2Iriwd07 yQBA== 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=yTtftKTuyk9mvnahI37UwUVpztG3niifWNi5R55vYwI=; b=IcZ/zce5Efo7i4RMHzH5gT1+vZTi3a3g370o9NakEg1Mi8mtSFp/bEUcDqlvZ673wn NepldT8fpCJ6DHeeSxLaX807V4Odu6LTVJehrVrfaAB1oIve8ZrzH0O1Zkv1vpjRRIAx 1XtPe/ZEs/o4PB8ptYq3eFwLf+O9MEaKIatojYtiwyRZNMjzAVJfKYoSxVz9UQ5gGvbP cG2DOkxxDS0eVeCriJw8Gq8nFMFVSc5aVSba/Yyzm4t8pukJBoj6v/Ox3ESSFAsdp89v rkSxbmcfnJUYq8vHNhJzR4D0sXTTtp+17UlTxVVEhAQBFYK17Ag+vuxjMZWJHlifm+Sk 8mvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OUG+LoH8; 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 n12si1344567pgf.289.2018.02.23.02.24.50; Fri, 23 Feb 2018 02:24:51 -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=OUG+LoH8; 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 S1751789AbeBWKYp (ORCPT + 28 others); Fri, 23 Feb 2018 05:24:45 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:36949 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751764AbeBWKYk (ORCPT ); Fri, 23 Feb 2018 05:24:40 -0500 Received: by mail-pl0-f67.google.com with SMTP id ay8so4655703plb.4 for ; Fri, 23 Feb 2018 02:24:40 -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=yTtftKTuyk9mvnahI37UwUVpztG3niifWNi5R55vYwI=; b=OUG+LoH8dIsk1gv/hPWAUqThZ6jFunNwSAMOP/vLHr2rHBGLfb1VWieOGTY8nkRF5h uOItBja6pCKV2ThPCNPZhRKWXMkScaDDQNxERbgQIzzKBcj8VHcufLZZeoRVUSTJMJth sE6dGur2xKS+yuhmizA/Px5Ztv+izbse4IfUg= 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=yTtftKTuyk9mvnahI37UwUVpztG3niifWNi5R55vYwI=; b=qXHkAjc3/WnbN69Jc3gORkQyVOfacJHsVG7HjCs5eBXBrJzt8kRGHwGKITyXqIrD0K GdY/NrJeeBBsPa6Rz0gTdrtEKm70TYWi3IBI+2wkM3UTCHRMTyUy2tBWKsIpNcjf400Y EyeUGYnl4fD3HXAurRa35ObgeDWgnAdgExdFd6F7q7lBeroWMxGjdtz+2aH7AujqApSk eF6svn1u8t+TJ3gMH4IJU8tUPIpSbs2VpjCAFYRIVYiwr+BFNQ4bHEn1QTrES9dj81dO mh3Vv/P3rQBwzCfBB5W2+XVBcKQJnDxnSPznPZ8umbo60s0y+2U9GZYFgKu7wL8pMtE6 J8WA== X-Gm-Message-State: APf1xPAbnpURmJcdiCWDGb3ZL5F2ggsImGAzddv0nRtc0OuPMvu0G4ew GoXl6YNmq/4LI9FS3Gpz/UBFqx5K4qc= X-Received: by 2002:a17:902:6116:: with SMTP id t22-v6mr1249503plj.307.1519381479586; Fri, 23 Feb 2018 02:24:39 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id z17sm3923443pfh.183.2018.02.23.02.24.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Feb 2018 02:24:39 -0800 (PST) From: Viresh Kumar To: Greg Kroah-Hartman Cc: Viresh Kumar , Vincent Guittot , Stephen Boyd , Rajendra Nayak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, robdclark@gmail.com, s.hauer@pengutronix.de, l.stach@pengutronix.de, shawnguo@kernel.org, fabio.estevam@nxp.com, nm@ti.com, xuwei5@hisilicon.com, robh+dt@kernel.org, olof@lixom.net Subject: [PATCH V7 13/13] boot_constraint: Add documentation Date: Fri, 23 Feb 2018 15:53:52 +0530 Message-Id: <6b17ffecd9917ff4a1fad848839ea667e92d715f.1519380923.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This 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..6da2df33f2c9 --- /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/bootconstraint/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/bootconstraint/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/bootconstraint/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 e9b41b1634f3..f982e71efb73 100644 --- a/Documentation/driver-api/index.rst +++ b/Documentation/driver-api/index.rst @@ -49,6 +49,7 @@ available subsections can be seen below. dmaengine/index slimbus soundwire/index + boot-constraint/index .. only:: subproject and html