From patchwork Mon Jun 8 13:42:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 206831 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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 A0605C433DF for ; Mon, 8 Jun 2020 13:43:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A8B5206C3 for ; Mon, 8 Jun 2020 13:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729790AbgFHNnG (ORCPT ); Mon, 8 Jun 2020 09:43:06 -0400 Received: from mga02.intel.com ([134.134.136.20]:9553 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729756AbgFHNnG (ORCPT ); Mon, 8 Jun 2020 09:43:06 -0400 IronPort-SDR: X9OPMhA53h/0GN44i6DWQXB8mLFPoinmmhMeXJawz4G2rAf9fxcliZvMDJ5GMtfLwOAZtMVAIr yBVTTTG8wfkw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 06:43:05 -0700 IronPort-SDR: jlP4ACtujYUFPKSI7IHQNnMLxEbV3MD2WRokO8F42qlaYwu9PuCIcD0eOodJmeUxhBtK6iYsfE Zd+ujxYPLL/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="472692071" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 08 Jun 2020 06:43:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C19A81D4; Mon, 8 Jun 2020 16:43:02 +0300 (EEST) From: Andy Shevchenko To: Serge Semin , linux-gpio@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , linux-kernel@vger.kernel.org, Lee Jones Cc: Andy Shevchenko Subject: [PATCH v1 2/6] gpio: dwapb: Read GPIO base from snps, gpio-base property Date: Mon, 8 Jun 2020 16:42:56 +0300 Message-Id: <20200608134300.76091-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0.rc2 In-Reply-To: <20200608134300.76091-1-andriy.shevchenko@linux.intel.com> References: <20200608134300.76091-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org For backward compatibility with some legacy devices, introduce a new property snps,gpio-base to read GPIO base. Don't advertise to discourage users from utilizing it. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-dwapb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index a7ca72086511..e3d7589434eb 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -599,7 +599,8 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) pp->ngpio = 32; } - pp->gpio_base = -1; + if (fwnode_property_read_u32(fwnode, "snps,gpio-base", &pp->gpio_base)) + pp->gpio_base = -1; /* * Only port A can provide interrupts in all configurations of From patchwork Mon Jun 8 13:42:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 206830 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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 3FFD2C433DF for ; Mon, 8 Jun 2020 13:43:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28D6F206C3 for ; Mon, 8 Jun 2020 13:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729833AbgFHNnH (ORCPT ); Mon, 8 Jun 2020 09:43:07 -0400 Received: from mga06.intel.com ([134.134.136.31]:2281 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729737AbgFHNnG (ORCPT ); Mon, 8 Jun 2020 09:43:06 -0400 IronPort-SDR: GdvxRa0FANwHikpLVVpc0DgQcxjPORATnlrtSH/I0rap9OR5zqc2o1iaqSsLNvn5dZgDgsQ2gx PwjUwQkJsaNw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 06:43:05 -0700 IronPort-SDR: h/PFo407aJk9EmuzuzJ6NoYruAzwMV2F6U/qEK6AomvC3IvWFbwJDLCTkwWryOuqkQaEBBWGuN jm6RXcguRyJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="288473531" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 08 Jun 2020 06:43:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id C9DE925A; Mon, 8 Jun 2020 16:43:02 +0300 (EEST) From: Andy Shevchenko To: Serge Semin , linux-gpio@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , linux-kernel@vger.kernel.org, Lee Jones Cc: Heikki Krogerus , Andy Shevchenko Subject: [PATCH v1 3/6] mfd: core: Propagate software node group to the sub devices Date: Mon, 8 Jun 2020 16:42:57 +0300 Message-Id: <20200608134300.76091-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0.rc2 In-Reply-To: <20200608134300.76091-1-andriy.shevchenko@linux.intel.com> References: <20200608134300.76091-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Heikki Krogerus When ever device properties are supplied for a sub device, a software node (fwnode) is actually created and then associated with that device. By allowing the drivers to supply the complete software node group instead of just the properties in it, the drivers can take advantage of the other features the software nodes have on top of supplying the device properties. Signed-off-by: Heikki Krogerus Signed-off-by: Andy Shevchenko --- drivers/mfd/mfd-core.c | 31 +++++++++++++++++++++++++++---- include/linux/mfd/core.h | 3 +++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index f5a73af60dd4..1a256f64dc9d 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -173,7 +173,24 @@ static int mfd_add_device(struct device *parent, int id, goto fail_alias; } - if (cell->properties) { + /* If software node group exists, use it, otherwise try properties */ + if (cell->node_group) { + struct fwnode_handle *fwnode; + + ret = software_node_register_node_group(cell->node_group); + if (ret) + goto fail_alias; + + /* + * The very first software node in the group is related to + * the device itself. The rest can be device-less children to + * fulfill the case of sub nodes (LEDs, GPIO keys, etc). + */ + fwnode = software_node_fwnode(cell->node_group[0]); + + /* Assign this firmware node as a secondary one of the device */ + set_secondary_fwnode(&pdev->dev, fwnode); + } else if (cell->properties) { ret = platform_device_add_properties(pdev, cell->properties); if (ret) goto fail_alias; @@ -213,18 +230,18 @@ static int mfd_add_device(struct device *parent, int id, if (has_acpi_companion(&pdev->dev)) { ret = acpi_check_resource_conflict(&res[r]); if (ret) - goto fail_alias; + goto fail_resources; } } } ret = platform_device_add_resources(pdev, res, cell->num_resources); if (ret) - goto fail_alias; + goto fail_resources; ret = platform_device_add(pdev); if (ret) - goto fail_alias; + goto fail_resources; if (cell->pm_runtime_no_callbacks) pm_runtime_no_callbacks(&pdev->dev); @@ -233,6 +250,9 @@ static int mfd_add_device(struct device *parent, int id, return 0; +fail_resources: + set_secondary_fwnode(&pdev->dev, NULL); + software_node_unregister_node_group(cell->node_group); fail_alias: regulator_bulk_unregister_supply_alias(&pdev->dev, cell->parent_supplies, @@ -294,6 +314,9 @@ static int mfd_remove_devices_fn(struct device *dev, void *data) pdev = to_platform_device(dev); cell = mfd_get_cell(pdev); + set_secondary_fwnode(&pdev->dev, NULL); + software_node_unregister_node_group(cell->node_group); + regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies, cell->num_parent_supplies); diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index d01d1299e49d..9a998568759f 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -72,6 +72,9 @@ struct mfd_cell { /* device properties passed to the sub devices drivers */ struct property_entry *properties; + /* Software node group for the sub device */ + const struct software_node **node_group; + /* * Device Tree compatible string * See: Documentation/devicetree/usage-model.txt Chapter 2.2 for details From patchwork Mon Jun 8 13:43:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 206829 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=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 77897C433E1 for ; Mon, 8 Jun 2020 13:43:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52A20206C3 for ; Mon, 8 Jun 2020 13:43:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729761AbgFHNn1 (ORCPT ); Mon, 8 Jun 2020 09:43:27 -0400 Received: from mga06.intel.com ([134.134.136.31]:2281 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729840AbgFHNnI (ORCPT ); Mon, 8 Jun 2020 09:43:08 -0400 IronPort-SDR: Pvd/IdgEcfIttSDh+1lQ+azh6WkT0mLo+fpmRCX7dWlU8xXuMSkd8tFPTaC8S/a8rk2C8jgVSg sY/n/pL+/dbA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 06:43:08 -0700 IronPort-SDR: uYYuKJygUPTNNSnZ5lPujlqYfkWFp71cyRYTrmZ5fP3PxmPbp4R/L2gAUQc58Tg88diMCmqlZ2 Lf2xm6ZcRAOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="288473542" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 08 Jun 2020 06:43:06 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id E09583CF; Mon, 8 Jun 2020 16:43:02 +0300 (EEST) From: Andy Shevchenko To: Serge Semin , linux-gpio@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , linux-kernel@vger.kernel.org, Lee Jones Cc: Andy Shevchenko Subject: [PATCH v1 6/6] gpio: dwapb: Define magic number for IRQ and GPIO lines Date: Mon, 8 Jun 2020 16:43:00 +0300 Message-Id: <20200608134300.76091-7-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.27.0.rc2 In-Reply-To: <20200608134300.76091-1-andriy.shevchenko@linux.intel.com> References: <20200608134300.76091-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Define maximum number of IRQ and GPIO lines per port and replace magic number by it. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-dwapb.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index de01b8943bd2..77a86a8eaee0 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -63,6 +63,7 @@ #define GPIO_INTSTATUS_V2 0x3c #define GPIO_PORTA_EOI_V2 0x40 +#define DWAPB_NR_GPIOS 32 #define DWAPB_NR_CLOCKS 2 struct dwapb_port_property { @@ -70,7 +71,7 @@ struct dwapb_port_property { unsigned int idx; unsigned int ngpio; unsigned int gpio_base; - int irq[32]; + int irq[DWAPB_NR_GPIOS]; }; struct dwapb_platform_data { @@ -174,7 +175,7 @@ static struct dwapb_gpio_port *dwapb_offs_to_port(struct dwapb_gpio *gpio, unsig for (i = 0; i < gpio->nr_ports; i++) { port = &gpio->ports[i]; - if (port->idx == offs / 32) + if (port->idx == offs / DWAPB_NR_GPIOS) return port; } @@ -194,7 +195,7 @@ static void dwapb_toggle_trigger(struct dwapb_gpio *gpio, unsigned int offs) pol = dwapb_read(gpio, GPIO_INT_POLARITY); /* Just read the current value right out of the data register */ - val = gc->get(gc, offs % 32); + val = gc->get(gc, offs % DWAPB_NR_GPIOS); if (val) pol &= ~BIT(offs); else @@ -209,7 +210,7 @@ static u32 dwapb_do_irq(struct dwapb_gpio *gpio) irq_hw_number_t hwirq; irq_status = dwapb_read(gpio, GPIO_INTSTATUS); - for_each_set_bit(hwirq, &irq_status, 32) { + for_each_set_bit(hwirq, &irq_status, DWAPB_NR_GPIOS) { int gpio_irq = irq_find_mapping(gpio->domain, hwirq); u32 irq_type = irq_get_trigger_type(gpio_irq); @@ -608,7 +609,7 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) dev_info(dev, "failed to get number of gpios for port%d\n", i); - pp->ngpio = 32; + pp->ngpio = DWAPB_NR_GPIOS; } if (fwnode_property_read_u32(fwnode, "snps,gpio-base", &pp->gpio_base))