Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mfd: intel_quark_i2c_gpio: Convert GPIO 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@linux.intel.com>
Tested-by: Serge Semin <fancer.lancer@gmail.com>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

+37 -33
+37 -33
drivers/mfd/intel_quark_i2c_gpio.c
··· 17 17 #include <linux/clk-provider.h> 18 18 #include <linux/dmi.h> 19 19 #include <linux/i2c.h> 20 - #include <linux/platform_data/gpio-dwapb.h> 21 20 #include <linux/property.h> 22 21 23 22 /* PCI BAR for register base address */ ··· 26 27 /* ACPI _ADR value to match the child node */ 27 28 #define MFD_ACPI_MATCH_GPIO 0ULL 28 29 #define MFD_ACPI_MATCH_I2C 1ULL 29 - 30 - /* The base GPIO number under GPIOLIB framework */ 31 - #define INTEL_QUARK_MFD_GPIO_BASE 8 32 - 33 - /* The default number of South-Cluster GPIO on Quark. */ 34 - #define INTEL_QUARK_MFD_NGPIO 8 35 - 36 - /* The DesignWare GPIO ports on Quark. */ 37 - #define INTEL_QUARK_GPIO_NPORTS 1 38 30 39 31 #define INTEL_QUARK_IORES_MEM 0 40 32 #define INTEL_QUARK_IORES_IRQ 1 ··· 101 111 [INTEL_QUARK_IORES_MEM] = { 102 112 .flags = IORESOURCE_MEM, 103 113 }, 114 + [INTEL_QUARK_IORES_IRQ] = { 115 + .flags = IORESOURCE_IRQ, 116 + }, 104 117 }; 105 118 106 119 static struct mfd_cell_acpi_match intel_quark_acpi_match_gpio = { 107 120 .adr = MFD_ACPI_MATCH_GPIO, 121 + }; 122 + 123 + static const struct software_node intel_quark_gpio_controller_node = { 124 + .name = "intel-quark-gpio-controller", 125 + }; 126 + 127 + static const struct property_entry intel_quark_gpio_portA_properties[] = { 128 + PROPERTY_ENTRY_U32("reg", 0), 129 + PROPERTY_ENTRY_U32("snps,nr-gpios", 8), 130 + PROPERTY_ENTRY_U32("gpio-base", 8), 131 + { } 132 + }; 133 + 134 + static const struct software_node intel_quark_gpio_portA_node = { 135 + .name = "portA", 136 + .parent = &intel_quark_gpio_controller_node, 137 + .properties = intel_quark_gpio_portA_properties, 138 + }; 139 + 140 + static const struct software_node *intel_quark_gpio_node_group[] = { 141 + &intel_quark_gpio_controller_node, 142 + &intel_quark_gpio_portA_node, 143 + NULL 108 144 }; 109 145 110 146 static struct mfd_cell intel_quark_mfd_cells[] = { ··· 219 203 { 220 204 struct mfd_cell *cell = &intel_quark_mfd_cells[MFD_GPIO_BAR]; 221 205 struct resource *res = intel_quark_gpio_res; 222 - struct dwapb_platform_data *pdata; 223 - struct device *dev = &pdev->dev; 206 + int ret; 224 207 225 208 res[INTEL_QUARK_IORES_MEM].start = pci_resource_start(pdev, MFD_GPIO_BAR); 226 209 res[INTEL_QUARK_IORES_MEM].end = pci_resource_end(pdev, MFD_GPIO_BAR); 227 210 228 - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 229 - if (!pdata) 230 - return -ENOMEM; 211 + res[INTEL_QUARK_IORES_IRQ].start = pci_irq_vector(pdev, 0); 212 + res[INTEL_QUARK_IORES_IRQ].end = pci_irq_vector(pdev, 0); 231 213 232 - /* For intel quark x1000, it has only one port: portA */ 233 - pdata->nports = INTEL_QUARK_GPIO_NPORTS; 234 - pdata->properties = devm_kcalloc(dev, pdata->nports, 235 - sizeof(*pdata->properties), 236 - GFP_KERNEL); 237 - if (!pdata->properties) 238 - return -ENOMEM; 214 + ret = software_node_register_node_group(intel_quark_gpio_node_group); 215 + if (ret) 216 + return ret; 239 217 240 - /* Set the properties for portA */ 241 - pdata->properties->fwnode = NULL; 242 - pdata->properties->idx = 0; 243 - pdata->properties->ngpio = INTEL_QUARK_MFD_NGPIO; 244 - pdata->properties->gpio_base = INTEL_QUARK_MFD_GPIO_BASE; 245 - pdata->properties->irq[0] = pci_irq_vector(pdev, 0); 246 - 247 - cell->platform_data = pdata; 248 - cell->pdata_size = sizeof(*pdata); 249 - 218 + cell->swnode = &intel_quark_gpio_controller_node; 250 219 return 0; 251 220 } 252 221 ··· 274 273 ARRAY_SIZE(intel_quark_mfd_cells), NULL, 0, 275 274 NULL); 276 275 if (ret) 277 - goto err_free_irq_vectors; 276 + goto err_unregister_gpio_node_group; 278 277 279 278 return 0; 280 279 280 + err_unregister_gpio_node_group: 281 + software_node_unregister_node_group(intel_quark_gpio_node_group); 281 282 err_free_irq_vectors: 282 283 pci_free_irq_vectors(pdev); 283 284 err_unregister_i2c_clk: ··· 290 287 static void intel_quark_mfd_remove(struct pci_dev *pdev) 291 288 { 292 289 mfd_remove_devices(&pdev->dev); 290 + software_node_unregister_node_group(intel_quark_gpio_node_group); 293 291 pci_free_irq_vectors(pdev); 294 292 intel_quark_unregister_i2c_clk(&pdev->dev); 295 293 }