[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200608134300.76091-5-andriy.shevchenko@linux.intel.com>
Date: Mon, 8 Jun 2020 16:42:58 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Serge Semin <fancer.lancer@...il.com>, linux-gpio@...r.kernel.org,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>,
linux-kernel@...r.kernel.org, Lee Jones <lee.jones@...aro.org>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v1 4/6] mfd: intel_quark_i2c_gpio: Convert to use software nodes
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 <andriy.shevchenko@...ux.intel.com>
---
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 <linux/clkdev.h>
#include <linux/clk-provider.h>
#include <linux/dmi.h>
-#include <linux/platform_data/gpio-dwapb.h>
#include <linux/platform_data/i2c-designware.h>
+#include <linux/property.h>
/* 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;
}
--
2.27.0.rc2
Powered by blists - more mailing lists