From patchwork Wed Mar 24 08:19:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= X-Patchwork-Id: 12160463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B1B3C433C1 for ; Wed, 24 Mar 2021 08:21:41 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A389361992 for ; Wed, 24 Mar 2021 08:21:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A389361992 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=UxkeovDFmIXljm1R2XQM1aqwI3cEg7DYcieWieQn4gk=; b=JUM3Sk1R/MuRrLmTlKUXU01ib QU2/gM+r8+Kh0k3RFEZGE0bIWLGpVS+HVS+hEzA3uXUX5/xDTfug0NjxdEP0mCiaEjgdTrZtiM7q2 /YDZ9ZtAYb0PNoS8dEuATug+kyvCuJqsskiFGv/2oiTzHYWGrYdqLP4yEp6mn7l5AXxR+YuRTqnFK PskE9SIqNiivwkd+D8OAIe6f8+mSXlgLOZ1sP3F/lvhNXAqXvUP9ZNZX9+YMA5GwbkorWLg0pxVoe 3CIw8eMjd08nSaIJTMKc6PZ/p0zaCLKMp7eWpqX4U6Tt5NM5yqrsmdzwgeEKgLZmh8dbNqBoRH22M XcBAwhC4Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOyk6-00GYxN-SY; Wed, 24 Mar 2021 08:19:55 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lOyjg-00GYnm-5O for linux-arm-kernel@lists.infradead.org; Wed, 24 Mar 2021 08:19:31 +0000 Received: by mail-wr1-x432.google.com with SMTP id c8so10563822wrq.11 for ; Wed, 24 Mar 2021 01:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lFz+2D7nsBaAJ+OWvlcX4/oaiVSFj8mrftl1vqct/ok=; b=jBoP+CYtFmJ86y5RlfUYyT2zwAI/FDy4LPd3IfP/puTQU7zHGu963JR29S4X4LpkNJ 9qUza5bDfIn6hDOpJ2bzF8ikXhhkgoT1x79V02YGaK816+Z2ctsQJNGcvEdCmDw75obZ wm/hwYKPB9e0XRmldmhx9eUsFn7ARtNPsWmQdSIJzl6pr0MFy5R37JX7tMhg3xvGg86T TxAM0nlElwVWzRtrV7DQlSFbRrUC4dguvGcMSwKt1e4sSmM1brz43F/LCA+QYHLdbi+0 RFmyKNQuLwHyMkWPPqIUhaPZ+gEhtP5+BTexNTkar3SKyMEWrpJyz8ZXuTqmPfk6cOkt YCZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lFz+2D7nsBaAJ+OWvlcX4/oaiVSFj8mrftl1vqct/ok=; b=gGNESQoQgI9PC4RqRd0y4YshtZMWUHcQM3tjdqw/QMygwQ5fPj+mwSi3tDy0WhxbPL syvvn6K/5pZ0tmMQ3kYE6By3hNQ/Z1l1r4XD9PwBxjQntN+FtmDWJh8R5SMZDjXc2SG6 l5qqYZ6LohRv01rHevdu6blZmyFnoujo2i9CZuqso7NkygHWAWzul+f2JdGdVHyLYjdP HWbNjfXUzkhCtUHjDUCsxjw5mjr1Zi9T8YNbzCmTo3KxFKdy0JVzCxC8Ip0iuh2OpqhC EuHn5EkmEl7cmUYAq1RN02gKJo3ALP7taaoDSfWWcHKb7g8SX8XSWgbySJbsLqwkMOP/ Uw6Q== X-Gm-Message-State: AOAM533wjVEpRp5Ly/tY3cAjxOIbCaXpk+dwKyayyNsqBhacIzL6hD6N as4yVqai+faNduomQgBQSqo= X-Google-Smtp-Source: ABdhPJw+S3U/f/vdrr8CtSESAp0hQqhFwh05tfG4srcbCJYbM5qX7m6mwa+N4IANpknjymRdChej1w== X-Received: by 2002:a5d:6152:: with SMTP id y18mr2107182wrt.255.1616573967593; Wed, 24 Mar 2021 01:19:27 -0700 (PDT) Received: from skynet.lan (51.red-83-44-13.dynamicip.rima-tde.net. [83.44.13.51]) by smtp.gmail.com with ESMTPSA id x25sm1498578wmj.14.2021.03.24.01.19.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Mar 2021 01:19:27 -0700 (PDT) From: =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= To: Linus Walleij , Bartosz Golaszewski , Rob Herring , Lee Jones , Michael Walle , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, Jonas Gorski , =?utf-8?q?=C3=81lvaro_Fern=C3=A1ndez_Rojas?= , Necip Fazil Yildiran , Andy Shevchenko , linux-gpio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v9 02/22] gpio: regmap: set gpio_chip of_node Date: Wed, 24 Mar 2021 09:19:03 +0100 Message-Id: <20210324081923.20379-3-noltari@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210324081923.20379-1-noltari@gmail.com> References: <20210324081923.20379-1-noltari@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210324_081928_385342_A0541ED7 X-CRM114-Status: GOOD ( 15.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is needed for properly registering GPIO regmap as a child of a regmap pin controller. Signed-off-by: Álvaro Fernández Rojas Reviewed-by: Michael Walle Reviewed-by: Andy Shevchenko Acked-by: Bartosz Golaszewski --- v9: guard of_node assignment with CONFIG_OF_GPIO v8: no changes v7: add gpio-regmap.c comment v6: add comment and simplify of_node assignment v5: switch to fwnode v4: fix documentation v3: introduce patch needed for properly parsing gpio-range drivers/gpio/gpio-regmap.c | 5 +++++ include/linux/gpio/regmap.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c index 5412cb3b0b2a..134cedf151a7 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -254,6 +254,11 @@ struct gpio_regmap *gpio_regmap_register(const struct gpio_regmap_config *config chip->names = config->names; chip->label = config->label ?: dev_name(config->parent); +#if defined(CONFIG_OF_GPIO) + /* gpiolib will use of_node of the parent if chip->of_node is NULL */ + chip->of_node = to_of_node(config->fwnode); +#endif /* CONFIG_OF_GPIO */ + /* * If our regmap is fast_io we should probably set can_sleep to false. * Right now, the regmap doesn't save this property, nor is there any diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h index ad76f3d0a6ba..334dd928042b 100644 --- a/include/linux/gpio/regmap.h +++ b/include/linux/gpio/regmap.h @@ -4,6 +4,7 @@ #define _LINUX_GPIO_REGMAP_H struct device; +struct fwnode_handle; struct gpio_regmap; struct irq_domain; struct regmap; @@ -16,6 +17,8 @@ struct regmap; * @parent: The parent device * @regmap: The regmap used to access the registers * given, the name of the device is used + * @fwnode: (Optional) The firmware node. + * If not given, the fwnode of the parent is used. * @label: (Optional) Descriptive name for GPIO controller. * If not given, the name of the device is used. * @ngpio: Number of GPIOs @@ -57,6 +60,7 @@ struct regmap; struct gpio_regmap_config { struct device *parent; struct regmap *regmap; + struct fwnode_handle *fwnode; const char *label; int ngpio;