From patchwork Mon Jun 8 13:42:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1305141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49gZG82GFGz9sSS for ; Mon, 8 Jun 2020 23:43:28 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729842AbgFHNnI (ORCPT ); Mon, 8 Jun 2020 09:43:08 -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 S1729761AbgFHNnG (ORCPT ); Mon, 8 Jun 2020 09:43:06 -0400 IronPort-SDR: FKBOsi3t6VzgCk1YuqD7g9u4FX0vPLHlGX2TKoWsHpVeKXY7GKJM7Rq8+UwKLvedTKS0G9mUM+ mXjpQ5IfuLaw== 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: LabP5zzfHpvMu5B5Gwbe1V4+VQ5qBqJfN1/z3ptdv0sL11b7+acwfOnqWJDYLAbi5E1AeOrNH2 4z/bMx62e1Ww== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="472692070" 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 BA2E7111; 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 1/6] gpio: dwapb: Replace irq_shared flag with fwnode type check Date: Mon, 8 Jun 2020 16:42:55 +0300 Message-Id: <20200608134300.76091-2-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 Shared IRQ is only enabled for ACPI platforms or pure platform drivers, there is no need to have a special flag for that, since we simple can test port fwnode to be type of OF. While at it, drop duplicate declaration of loop variable. Signed-off-by: Andy Shevchenko Cc: Lee Jones --- drivers/gpio/gpio-dwapb.c | 5 +---- drivers/mfd/intel_quark_i2c_gpio.c | 1 - include/linux/platform_data/gpio-dwapb.h | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index 1d8d55bd63aa..a7ca72086511 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -418,9 +418,7 @@ static void dwapb_configure_irqs(struct dwapb_gpio *gpio, irq_gc->chip_types[1].type = IRQ_TYPE_EDGE_BOTH; irq_gc->chip_types[1].handler = handle_edge_irq; - if (!pp->irq_shared) { - int i; - + if (to_of_node(pp->fwnode)) { for (i = 0; i < pp->ngpio; i++) { if (pp->irq[i]) irq_set_chained_handler_and_data(pp->irq[i], @@ -601,7 +599,6 @@ static struct dwapb_platform_data *dwapb_gpio_get_pdata(struct device *dev) pp->ngpio = 32; } - pp->irq_shared = false; pp->gpio_base = -1; /* diff --git a/drivers/mfd/intel_quark_i2c_gpio.c b/drivers/mfd/intel_quark_i2c_gpio.c index 84ca7902e1df..06b538dd124c 100644 --- a/drivers/mfd/intel_quark_i2c_gpio.c +++ b/drivers/mfd/intel_quark_i2c_gpio.c @@ -216,7 +216,6 @@ static int intel_quark_gpio_setup(struct pci_dev *pdev, struct mfd_cell *cell) pdata->properties->ngpio = INTEL_QUARK_MFD_NGPIO; pdata->properties->gpio_base = INTEL_QUARK_MFD_GPIO_BASE; pdata->properties->irq[0] = pdev->irq; - pdata->properties->irq_shared = true; cell->platform_data = pdata; cell->pdata_size = sizeof(*pdata); diff --git a/include/linux/platform_data/gpio-dwapb.h b/include/linux/platform_data/gpio-dwapb.h index ff1be737bad6..a63010b6e898 100644 --- a/include/linux/platform_data/gpio-dwapb.h +++ b/include/linux/platform_data/gpio-dwapb.h @@ -12,7 +12,6 @@ struct dwapb_port_property { unsigned int ngpio; unsigned int gpio_base; int irq[32]; - bool irq_shared; }; struct dwapb_platform_data { 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: 1305140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49gZFl5ktWz9sRN for ; Mon, 8 Jun 2020 23:43:07 +1000 (AEST) 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: 1305142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49gZG92Z5Bz9sSc for ; Mon, 8 Jun 2020 23:43:29 +1000 (AEST) 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:42:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1305145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49gZGN4S2lz9sSd for ; Mon, 8 Jun 2020 23:43:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729825AbgFHNnH (ORCPT ); Mon, 8 Jun 2020 09:43:07 -0400 Received: from mga12.intel.com ([192.55.52.136]:64831 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbgFHNnG (ORCPT ); Mon, 8 Jun 2020 09:43:06 -0400 IronPort-SDR: 3L1th1NbUJbDpUkIBAdQwh1AShhmjeCFWhaVBnnqEpeyfA/zTLwJiJpfCn1R6MsSi5pwS9wNLf h0+zNNAePIAA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 06:43:05 -0700 IronPort-SDR: gkoKqzml1kBmlnYLlgZ0wp4CiJttFAFB4LjXsNwJlOqkPcWpVY1mDhytMIfPeNYlbOZF6vnSlD Tobc6lqkB+ug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="379426399" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Jun 2020 06:43:03 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D1B193CA; 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 4/6] mfd: intel_quark_i2c_gpio: Convert to use software nodes Date: Mon, 8 Jun 2020 16:42:58 +0300 Message-Id: <20200608134300.76091-5-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 The driver can provide a software node group instead of passing legacy platform data. This will allow to drop the legacy platform data structures along with unifying a child device driver to use same interface for all property providers, i.e. Device Tree, ACPI, and board files. Signed-off-by: Andy Shevchenko --- drivers/mfd/intel_quark_i2c_gpio.c | 63 ++++++++++++++---------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/drivers/mfd/intel_quark_i2c_gpio.c b/drivers/mfd/intel_quark_i2c_gpio.c index 06b538dd124c..fb8c0b042ecc 100644 --- a/drivers/mfd/intel_quark_i2c_gpio.c +++ b/drivers/mfd/intel_quark_i2c_gpio.c @@ -16,8 +16,8 @@ #include #include #include -#include #include +#include /* PCI BAR for register base address */ #define MFD_I2C_BAR 0 @@ -27,15 +27,6 @@ #define MFD_ACPI_MATCH_GPIO 0ULL #define MFD_ACPI_MATCH_I2C 1ULL -/* The base GPIO number under GPIOLIB framework */ -#define INTEL_QUARK_MFD_GPIO_BASE 8 - -/* The default number of South-Cluster GPIO on Quark. */ -#define INTEL_QUARK_MFD_NGPIO 8 - -/* The DesignWare GPIO ports on Quark. */ -#define INTEL_QUARK_GPIO_NPORTS 1 - #define INTEL_QUARK_IORES_MEM 0 #define INTEL_QUARK_IORES_IRQ 1 @@ -89,17 +80,44 @@ static struct resource intel_quark_gpio_res[] = { [INTEL_QUARK_IORES_MEM] = { .flags = IORESOURCE_MEM, }, + [INTEL_QUARK_IORES_IRQ] = { + .flags = IORESOURCE_IRQ, + }, }; static struct mfd_cell_acpi_match intel_quark_acpi_match_gpio = { .adr = MFD_ACPI_MATCH_GPIO, }; +static const struct software_node intel_quark_gpio_controller_node = { + .name = "intel-quark-gpio-controller", +}; + +static const struct property_entry intel_quark_gpio_portA_properties[] = { + PROPERTY_ENTRY_U32("reg", 0), + PROPERTY_ENTRY_U32("snps,nr-gpios", 8), + PROPERTY_ENTRY_U32("snps,gpio-base", 8), + { } +}; + +static const struct software_node intel_quark_gpio_portA_node = { + .name = "portA", + .parent = &intel_quark_gpio_controller_node, + .properties = intel_quark_gpio_portA_properties, +}; + +static const struct software_node *intel_quark_gpio_node_group[] = { + &intel_quark_gpio_controller_node, + &intel_quark_gpio_portA_node, + NULL +}; + static struct mfd_cell intel_quark_mfd_cells[] = { { .id = MFD_GPIO_BAR, .name = "gpio-dwapb", .acpi_match = &intel_quark_acpi_match_gpio, + .node_group = intel_quark_gpio_node_group, .num_resources = ARRAY_SIZE(intel_quark_gpio_res), .resources = intel_quark_gpio_res, .ignore_resource_conflicts = true, @@ -189,36 +207,15 @@ static int intel_quark_i2c_setup(struct pci_dev *pdev, struct mfd_cell *cell) static int intel_quark_gpio_setup(struct pci_dev *pdev, struct mfd_cell *cell) { - struct dwapb_platform_data *pdata; struct resource *res = (struct resource *)cell->resources; - struct device *dev = &pdev->dev; res[INTEL_QUARK_IORES_MEM].start = pci_resource_start(pdev, MFD_GPIO_BAR); res[INTEL_QUARK_IORES_MEM].end = pci_resource_end(pdev, MFD_GPIO_BAR); - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - - /* For intel quark x1000, it has only one port: portA */ - pdata->nports = INTEL_QUARK_GPIO_NPORTS; - pdata->properties = devm_kcalloc(dev, pdata->nports, - sizeof(*pdata->properties), - GFP_KERNEL); - if (!pdata->properties) - return -ENOMEM; - - /* Set the properties for portA */ - pdata->properties->fwnode = NULL; - pdata->properties->idx = 0; - pdata->properties->ngpio = INTEL_QUARK_MFD_NGPIO; - pdata->properties->gpio_base = INTEL_QUARK_MFD_GPIO_BASE; - pdata->properties->irq[0] = pdev->irq; - - cell->platform_data = pdata; - cell->pdata_size = sizeof(*pdata); + res[INTEL_QUARK_IORES_IRQ].start = pdev->irq; + res[INTEL_QUARK_IORES_IRQ].end = pdev->irq; return 0; } From patchwork Mon Jun 8 13:42:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1305143 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49gZGM33Smz9sSd for ; Mon, 8 Jun 2020 23:43:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729897AbgFHNn1 (ORCPT ); Mon, 8 Jun 2020 09:43:27 -0400 Received: from mga14.intel.com ([192.55.52.115]:11264 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729847AbgFHNnI (ORCPT ); Mon, 8 Jun 2020 09:43:08 -0400 IronPort-SDR: c1flsy9Laug+B+P7BejazEFSoUIKG3Is4UeJXRZttg5mwck+T4D6nrP8FPdudzFUYfIfSvRXi2 RngJx404mRRA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2020 06:43:08 -0700 IronPort-SDR: wkoB6TaGPVjkzPD8OvsgRFGE8/+y4/6TtE/A/9P7z9q1TvTJMdXxyxl8O1Cg4Dzh3PVrWFSP7u tgofj3AZ2lBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,487,1583222400"; d="scan'208";a="472584278" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 08 Jun 2020 06:43:06 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id D91683CE; 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 5/6] gpio: dwapb: Get rid of legacy platform data Date: Mon, 8 Jun 2020 16:42:59 +0300 Message-Id: <20200608134300.76091-6-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 Platform data is a legacy interface to supply device properties to the driver. In this case we don't have anymore in-kernel users for it. Just remove it for good. Signed-off-by: Andy Shevchenko --- drivers/gpio/gpio-dwapb.c | 27 +++++++++++++++--------- include/linux/platform_data/gpio-dwapb.h | 22 ------------------- 2 files changed, 17 insertions(+), 32 deletions(-) delete mode 100644 include/linux/platform_data/gpio-dwapb.h diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c index e3d7589434eb..de01b8943bd2 100644 --- a/drivers/gpio/gpio-dwapb.c +++ b/drivers/gpio/gpio-dwapb.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "gpiolib.h" @@ -66,6 +65,19 @@ #define DWAPB_NR_CLOCKS 2 +struct dwapb_port_property { + struct fwnode_handle *fwnode; + unsigned int idx; + unsigned int ngpio; + unsigned int gpio_base; + int irq[32]; +}; + +struct dwapb_platform_data { + struct dwapb_port_property *properties; + unsigned int nports; +}; + struct dwapb_gpio; #ifdef CONFIG_PM_SLEEP @@ -633,17 +645,12 @@ static int dwapb_gpio_probe(struct platform_device *pdev) unsigned int i; struct dwapb_gpio *gpio; int err; + struct dwapb_platform_data *pdata; struct device *dev = &pdev->dev; - struct dwapb_platform_data *pdata = dev_get_platdata(dev); - - if (!pdata) { - pdata = dwapb_gpio_get_pdata(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - } - if (!pdata->nports) - return -ENODEV; + pdata = dwapb_gpio_get_pdata(dev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL); if (!gpio) diff --git a/include/linux/platform_data/gpio-dwapb.h b/include/linux/platform_data/gpio-dwapb.h deleted file mode 100644 index a63010b6e898..000000000000 --- a/include/linux/platform_data/gpio-dwapb.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright(c) 2014 Intel Corporation. - */ - -#ifndef GPIO_DW_APB_H -#define GPIO_DW_APB_H - -struct dwapb_port_property { - struct fwnode_handle *fwnode; - unsigned int idx; - unsigned int ngpio; - unsigned int gpio_base; - int irq[32]; -}; - -struct dwapb_platform_data { - struct dwapb_port_property *properties; - unsigned int nports; -}; - -#endif 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: 1305144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 49gZGN0ZLWz9sSf for ; Mon, 8 Jun 2020 23:43:40 +1000 (AEST) 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))