Skip to contentSkip to conversation

MFD and GPIO for STA2X11

PATCH In review Alessandro Rubini 5 participants 20 messages Apr 12, 2012 – May 18, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover MFD and GPIO for STA2X11

These two patches introduce the multi-function device and GPIO support for the STA2X11 I/O Hub. Core PCI support is already in linux-next.

V1: sent on Jan 26th as RFC and got no comments back

V2: sent on Feb 16th, fixed a number of minor details, got comments from Linus Walleij and Samuel Ortiz.

V3: accepted all suggestions. I delayed this resending a while because I hoped the base STA2X11 patches to be accepted, but despite the positive comments I got on those patches, they are not in linux-next as of today

This set, thus, refers to CONFIG_STA2X11 which is not yet upstream.linux-next.

Like in V2, I Cc'd both patches to all interested parties, because the MFD patch must be fore the GPIO one, so they're better merged to the same tree.

Alessandro Rubini (2):
mfd: Add driver for STA2X11 MFD block
gpio: add STA2X11 GPIO block

 arch/x86/include/asm/sta2x11.h  |   12 +
 drivers/gpio/Kconfig            |    8 +
 drivers/gpio/Makefile           |    1 +
 drivers/gpio/gpio-sta2x11.c     |  435 ++++++++++++++++++++++++++++++++++++
 drivers/mfd/Kconfig             |    6 +
 drivers/mfd/Makefile            |    1 +
 drivers/mfd/sta2x11-mfd.c       |  467 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/sta2x11-mfd.h |  324 +++++++++++++++++++++++++++
 8 files changed, 1254 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/sta2x11.h
 create mode 100644 drivers/gpio/gpio-sta2x11.c
 create mode 100644 drivers/mfd/sta2x11-mfd.c
 create mode 100644 include/linux/mfd/sta2x11-mfd.h
Signature · 1 line
1.7.7.2
#1 lore raw

PATCH v3 1/2 mfd: Add driver for STA2X11 MFD block

This also introduces <asm/sta2x11.h> to export a function that is in the base sta2x11 support patches. The header will increase with other prototypes and constants over time.

---
 arch/x86/include/asm/sta2x11.h  |   12 +
 drivers/mfd/Kconfig             |    6 +
 drivers/mfd/Makefile            |    1 +
 drivers/mfd/sta2x11-mfd.c       |  467 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/sta2x11-mfd.h |  324 +++++++++++++++++++++++++++
 5 files changed, 810 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/include/asm/sta2x11.h
 create mode 100644 drivers/mfd/sta2x11-mfd.c
 create mode 100644 include/linux/mfd/sta2x11-mfd.h
arch/x86/include/asm/sta2x11.h new file +12 -0
new file mode 100644
index 0000000..e9d32df
@@ -0,0 +1,12 @@
+/*
+ * Header file for STMicroelectronics ConneXt (STA2X11) IOHub
+ */
+#ifndef __ASM_STA2X11_H
+#define __ASM_STA2X11_H
+
+#include <linux/pci.h>
+
+/* This needs to be called from the MFD to configure its sub-devices */
+struct sta2x11_instance *sta2x11_get_instance(struct pci_dev *pdev);
+
+#endif /* __ASM_STA2X11_H */
drivers/mfd/Kconfig +6 -0
index 29f463c..c194c67 100644
@@ -873,6 +873,12 @@ config MFD_RC5T583
 	  Additional drivers must be enabled in order to use the
 	  different functionality of the device.
 
+config MFD_STA2X11
+	bool "STA2X11 multi function device support"
+	depends on STA2X11
+	select MFD_CORE
+	select GPIO_STA2X11
+
 config MFD_ANATOP
 	bool "Support for Freescale i.MX on-chip ANATOP controller"
 	depends on SOC_IMX6Q
drivers/mfd/Makefile +1 -0
index 05fa538..7cd8f02 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)	+= davinci_voicecodec.o
 obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
 obj-$(CONFIG_MFD_TI_SSP)	+= ti-ssp.o
 
+obj-$(CONFIG_MFD_STA2X11)	+= sta2x11-mfd.o
 obj-$(CONFIG_MFD_STMPE)		+= stmpe.o
 obj-$(CONFIG_STMPE_I2C)		+= stmpe-i2c.o
 obj-$(CONFIG_STMPE_SPI)		+= stmpe-spi.o
drivers/mfd/sta2x11-mfd.c new file +467 -0

467 lines not on this page · raw message

include/linux/mfd/sta2x11-mfd.h new file +324 -0

324 lines not on this page · raw message

Signature · 1 line
1.7.7.2
#2 lore raw

Re: [PATCH V3 1/2] mfd: Add driver for STA2X11 MFD block

Hi Alessandro,

drivers/mfd/Kconfig config MFD_RC5T583 · line 880

Quoted 13 lines · Alessandro Rubini
drivers/mfd/Kconfig +5 -0
index 29f463c..c194c67 100644
@@ -873,6 +873,12 @@ config MFD_RC5T583
 	  Additional drivers must be enabled in order to use the
 	  different functionality of the device.
 
+config MFD_STA2X11
+	bool "STA2X11 multi function device support"
+	depends on STA2X11
+	select MFD_CORE
+	select GPIO_STA2X11

So you haven't fixed that one:

- You should not select GPIO_STA2X11 as this won't select the STA2X211 gpio driver dependencies for you. So if you build this driver with GPIOLIB=n then your build will fail.
- Why would this one depend on STA2X11 ? I see that you're calling sta2x11_get_instance() from this driver but I wonder if you could simply replace the mfd->instance pointer with one pointing to the pci_dev. Not depending on STA2X11 at all gives you the benefit of a much larger build coverage from linux-next for example.

drivers/mfd/Kconfig config MFD_RC5T583

Quoted 10 lines
drivers/mfd/Kconfig +10 -0
+/* Bar 0 */
+enum bar0_cells {
+	GPIO_0 = 0,
+	GPIO_1,
+	GPIO_2,
+	GPIO_3,
+	SCTL,
+	SCR,
+	TIME,
+};

Please protect those ones with a proper namespace.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#3 lore raw

Re: [PATCH V3 1/2] mfd: Add driver for STA2X11 MFD block

Hello Samuel, thanks for commenting.

Quoted 3 lines

- You should not select GPIO_STA2X11 as this won't select the STA2X211 gpio driver dependencies for you. So if you build this driver with GPIOLIB=n then your build will fail.

Ok. I recall this now, but I've forgotten while editing.

Quoted 5 lines

- Why would this one depend on STA2X11 ? I see that you're calling sta2x11_get_instance() from this driver but I wonder if you could simply replace the mfd->instance pointer with one pointing to the pci_dev. Not depending on STA2X11 at all gives you the benefit of a much larger build coverage from linux-next for example.

Right. But I need to know the instance, because other drivers will call on mfd for some configuration, and I need to match their device instance with the mfd one. The sta2x11 is a complex bridge, with 4 sub-buses, but being pci you can in theory plug two such boards in the same computer, and I'd love that setup to work properly.

Quoted 11 lines

drivers/mfd/sta2x11-mfd.c line 297

Quoted 10 lines
drivers/mfd/sta2x11-mfd.c new file +10 -0
+/* Bar 0 */
+enum bar0_cells {
+	GPIO_0 = 0,
+	GPIO_1,
+	GPIO_2,
+	GPIO_3,
+	SCTL,
+	SCR,
+	TIME,
+};

Please protect those ones with a proper namespace.

I remember this and I didn't do it on purpose (but I didn't comment on the submission because so much time had passed). I protected all the gpio bits, but this is only a local shortcut (it's in the .c file), to name the ordering of the hardware blocks in the mfd. It's only used a few lines later to build resource addresses.

Thanks
/alessandro

#4 lore raw

Re: [PATCH V3 1/2] mfd: Add driver for STA2X11 MFD block

In reply to Alessandro Rubini

Hi Alessandro,

Quoted 3 lines · Alessandro Rubini

This also introduces <asm/sta2x11.h> to export a function that is in the base sta2x11 support patches. The header will increase with other prototypes and constants over time.

I applied this one, after removing the GPIO_STA2X11 selection from the Kconfig entry, and after protecting bar0_cells and bar1_cells namespace with a STA2X11 prefix.
Please have a look at it and let me know if there are some issues with it.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#5 lore raw

PATCH v3 2/2 gpio: add STA2X11 GPIO block

In reply to Alessandro Rubini

This introduces 128 gpio bits (for each PCI device installed) with working interrupt support.

---
 drivers/gpio/Kconfig        |    8 +
 drivers/gpio/Makefile       |    1 +
 drivers/gpio/gpio-sta2x11.c |  435 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 444 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpio/gpio-sta2x11.c
drivers/gpio/Kconfig +8 -0
index 7875c3f..d2dbd1d 100644
@@ -153,6 +153,14 @@ config GPIO_PXA
 	help
 	  Say yes here to support the PXA GPIO device
 
+config GPIO_STA2X11
+	bool "STA2x11/ConneXt GPIO support"
+	depends on MFD_STA2X11
+	select GENERIC_IRQ_CHIP
+	help
+	  Say yes here to support the STA2x11/ConneXt GPIO device.
+	  The GPIO module has 128 GPIO pins with alternate functions.
+
 config GPIO_XILINX
 	bool "Xilinx GPIO support"
 	depends on PPC_OF || MICROBLAZE
drivers/gpio/Makefile +1 -0
index 1c2f6c0..fb749b1 100644
@@ -49,6 +49,7 @@ obj-$(CONFIG_PLAT_SAMSUNG)	+= gpio-samsung.o
 obj-$(CONFIG_ARCH_SA1100)	+= gpio-sa1100.o
 obj-$(CONFIG_GPIO_SCH)		+= gpio-sch.o
 obj-$(CONFIG_GPIO_SODAVILLE)	+= gpio-sodaville.o
+obj-$(CONFIG_GPIO_STA2X11)	+= gpio-sta2x11.o
 obj-$(CONFIG_GPIO_STMPE)	+= gpio-stmpe.o
 obj-$(CONFIG_GPIO_SX150X)	+= gpio-sx150x.o
 obj-$(CONFIG_GPIO_TC3589X)	+= gpio-tc3589x.o
drivers/gpio/gpio-sta2x11.c new file +435 -0

435 lines not on this page · raw message

Signature · 1 line
1.7.7.2
#6 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Quoted 57 lines · Alessandro Rubini
drivers/gpio/gpio-sta2x11.c new file +57 -0
+/*
+ * Special method: alternate functions and pullup/pulldown. This is only
+ * invoked on startup to configure gpio's according to platform data.
+ * FIXME : this functionality shall be managed (and exported to other drivers)
+ * via the pin control subsystem.
+ */
+static void gsta_set_config(struct gsta_gpio *chip, int nr, unsigned cfg)
+{
+       struct gsta_regs __iomem *regs = __regs(chip, nr);
+       unsigned long flags;
+       u32 bit = __bit(nr);
+       u32 val;
+       int err = 0;
+
+       pr_info("%s: %p %i %i\n", __func__, chip, nr, cfg);
+
+       if (cfg == PINMUX_TYPE_NONE)
+               return;
+
+       /* Alternate function or not? */
+       spin_lock_irqsave(&chip->lock, flags);
+       val = readl(&regs->afsela);
+       if (cfg == PINMUX_TYPE_FUNCTION)
+               val |= bit;
+       else
+               val &= ~bit;
+       writel(val | bit, &regs->afsela);
+       if (cfg == PINMUX_TYPE_FUNCTION) {
+               spin_unlock_irqrestore(&chip->lock, flags);
+               return;
+       }
+
+       /* not alternate function: set details */
+       switch (cfg) {
+       case PINMUX_TYPE_OUTPUT_LOW:
+               writel(bit, &regs->dirs);
+               writel(bit, &regs->datc);
+               break;
+       case PINMUX_TYPE_OUTPUT_HIGH:
+               writel(bit, &regs->dirs);
+               writel(bit, &regs->dats);
+               break;
+       case PINMUX_TYPE_INPUT:
+               writel(bit, &regs->dirc);
+               val = readl(&regs->pdis) | bit;
+               writel(val, &regs->pdis);
+               break;
+       case PINMUX_TYPE_INPUT_PULLUP:
+               writel(bit, &regs->dirc);
+               val = readl(&regs->pdis) & ~bit;
+               writel(val, &regs->pdis);
+               writel(bit, &regs->dats);
+               break;
+       case PINMUX_TYPE_INPUT_PULLDOWN:
+               writel(bit, &regs->dirc);
+               val = readl(&regs->pdis) & ~bit;
+               writel(val, &regs->pdis);

drivers/gpio/gpio-sta2x11.c line 226

Quoted 10 lines
drivers/gpio/gpio-sta2x11.c new file +10 -0
+               writel(bit, &regs->datc);
+               break;
+       default:
+               err = 1;
+       }
+       spin_unlock_irqrestore(&chip->lock, flags);
+       if (err)
+               pr_err("%s: chip %p, pin %i, cfg %i is invalid\n",
+                      __func__, chip, nr, cfg);
+}

I would still prefer to use the pinctrl subsystem for this from day 1 instead of adding more custom stuff for later refactoring...

Yours,
Linus Walleij

#7 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Quoted 2 lines

I would still prefer to use the pinctrl subsystem for this from day 1 instead of adding more custom stuff for later refactoring...

I see your point. I attacked pinctrl some time ago, but it is overly complex for this simple stuff. We have static configuration that is enacted at boot, and that's it. Using pinctrl would mean much more code (and more bugs, as a side effect) for no real advantage. I appreciate the flexibility of pinctrl, and I see it's really good to have a way to describe complex SoC hardware, but it just isn't always needed.

Besides, it's still marked as experimental, which on one side is not reassuring about its stability, and on the other means my whole chipset should depend on experimental as a consequence.

thanks
/alessandro

#8 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Quoted 3 lines · Alessandro Rubini

Besides, it's still marked as experimental, which on one side is not reassuring about its stability, and on the other means my whole chipset should depend on experimental as a consequence.

Yeah I heard that having it marked experimental was considered harmful for adoption so we have pushed a patch removing the experimental status. It should appear in -next tomorrow or so...

Yours,
Linus Walleij

#9 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

In reply to Alessandro Rubini
Quoted 6 lines · Alessandro Rubini

This introduces 128 gpio bits (for each PCI device installed) with working interrupt support.

Grant, I prefer that you make a decision on this driver since I have a conflict of interest (it's written for ST).

Yours,
Linus Walleij

#10 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

In reply to Alessandro Rubini

Hi Alessandro,

Quoted 2 lines · Alessandro Rubini

This introduces 128 gpio bits (for each PCI device installed) with working interrupt support.

I also applied this one, although I'd prefer to get Grant's ACK on it. Grant could also apply it to his tree as the build time dependencies are protected by the MFD_STA2X11 symbol.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#11 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

In reply to Alessandro Rubini
Quoted 7 lines · Alessandro Rubini

This introduces 128 gpio bits (for each PCI device installed) with working interrupt support.

---

[...]

Quoted 32 lines
drivers/gpio/gpio-sta2x11.c new file +32 -0
+/* The platform device used here is instantiated by the MFD device */
+static int __devinit gsta_probe(struct platform_device *dev)
+{
+	int i, err;
+	struct pci_dev *pdev;
+	struct sta2x11_gpio_pdata *gpio_pdata;
+	struct gsta_gpio *chip;
+	struct resource *res;
+
+	pdev = *(struct pci_dev **)(dev->dev.platform_data);
+	gpio_pdata = dev_get_platdata(&pdev->dev);
+
+	if (gpio_pdata == NULL)
+		dev_err(&dev->dev, "no gpio config\n");
+	pr_debug("gpio config: %p\n", gpio_pdata);
+
+	res = platform_get_resource(dev, IORESOURCE_MEM, 0);
+
+	chip = devm_kzalloc(&dev->dev, sizeof(*chip), GFP_KERNEL);
+	chip->dev = &dev->dev;
+	chip->reg_base = devm_request_and_ioremap(&dev->dev, res);
+
+	for (i = 0; i < GSTA_NR_BLOCKS; i++) {
+		chip->regs[i] = chip->reg_base + i * 4096;
+		/* disable all irqs */
+		writel(0, &chip->regs[i]->rimsc);
+		writel(0, &chip->regs[i]->fimsc);
+		writel(~0, &chip->regs[i]->ic);
+	}
+	spin_lock_init(&chip->lock);
+	gsta_gpio_setup(chip);
+	for (i = 0; i < GSTA_NR_GPIO; i++)

drivers/gpio/gpio-sta2x11.c line 396

Quoted 10 lines
drivers/gpio/gpio-sta2x11.c new file +10 -0
+		gsta_set_config(chip, i, gpio_pdata->pinconfig[i]);
+
+	/* 384 was used in previous code: be compatible for other drivers */
+	err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE);
+	if (err < 0) {
+		dev_warn(&dev->dev, "sta2x11 gpio: Can't get irq base (%i)\n",
+			 -err);
+		return err;
+	}
+	chip->irq_base = err;

Where does the number 384 come from? It looks like the driver only needs to allocate a range of irqs and that it doesn't actually matter what the real numbers are. Can 0 be used instead?

Actually, I'd rather see this driver switched to using irq_domain_add_linear so that irq_descs can be allocated on demand instead of all at once. That way only gpios actually used for irqs get setup.

To convert, use irq_domain_add_linear() and then irq_data->hwirq gets populated with the gpio number automatically for you and irq_find_mapping takes care of the hwirq->irq reverse lookup.

#12 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Hello Grant. Sorry for the delay.

Quoted 6 lines

drivers/gpio/gpio-sta2x11.c line 390

Quoted 2 lines
drivers/gpio/gpio-sta2x11.c new file +2 -0
+	/* 384 was used in previous code: be compatible for other drivers */
+	err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE);

Where does the number 384 come from? It looks like the driver only needs to allocate a range of irqs and that it doesn't actually matter what the real numbers are. Can 0 be used instead?

The problem is that there are a number of drivers already working (but not ready to be upstreamed), and we'd better continue using them. So, the mmc driver is requesting a specific interrupt number. The code is GPL (published on sourceforge) and I'd better remain compatible.

I'm not completely clear (yet) about how to get the right interrupt number in those other drivers, but I'm willing to remove the constraint as they are cleaned up and submitted.

Quoted 4 lines

Actually, I'd rather see this driver switched to using irq_domain_add_linear so that irq_descs can be allocated on demand instead of all at once. That way only gpios actually used for irqs get setup.

If it is a request, I'll evaluate it soon. I assume an incremental patch over what Samuel has already picked up is fine.

thanks
/alessandro

#13 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Quoted 7 lines · Alessandro Rubini
Quoted 6 lines

drivers/gpio/gpio-sta2x11.c line 390

Quoted 2 lines
drivers/gpio/gpio-sta2x11.c new file +2 -0
+	/* 384 was used in previous code: be compatible for other drivers */
+	err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE);

Where does the number 384 come from? It looks like the driver only needs to allocate a range of irqs and that it doesn't actually matter what the real numbers are. Can 0 be used instead?

Quoted 8 lines

The problem is that there are a number of drivers already working (but not ready to be upstreamed), and we'd better continue using them. So, the mmc driver is requesting a specific interrupt number. The code is GPL (published on sourceforge) and I'd better remain compatible.

I'm not completely clear (yet) about how to get the right interrupt number in those other drivers, but I'm willing to remove the constraint as they are cleaned up and submitted.

Use platform data for both this driver and the other drivers (or device tree if you're doing that). This will hard code the magic numbers in the board files, not in the driver.

#14 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Me:

Quoted 3 lines
Quoted 3 lines

I'm not completely clear (yet) about how to get the right interrupt number in those other drivers, but I'm willing to remove the constraint as they are cleaned up and submitted.

Mark Brown:

Quoted 3 lines

Use platform data for both this driver and the other drivers (or device tree if you're doing that). This will hard code the magic numbers in the board files, not in the driver.

Yes, but it's not that easy. If the gpio driver gets unpredictable interrupt numbers associated to the pins, the other drivers must recover those numbers in some way. That's why I currently started from 384, like the prevoous gpio driver was doing: the platform data uses that knowledge in the drivers I'm still using internally (but are not submittable as-is, so I'm working on them).

thanks
/alessandro

#15 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Quoted 10 lines · Alessandro Rubini

Me:

Quoted 3 lines
Quoted 3 lines

I'm not completely clear (yet) about how to get the right interrupt number in those other drivers, but I'm willing to remove the constraint as they are cleaned up and submitted.

Mark Brown:

Quoted 3 lines

Use platform data for both this driver and the other drivers (or device tree if you're doing that). This will hard code the magic numbers in the board files, not in the driver.

Quoted 6 lines

Yes, but it's not that easy. If the gpio driver gets unpredictable interrupt numbers associated to the pins, the other drivers must recover those numbers in some way. That's why I currently started from 384, like the prevoous gpio driver was doing: the platform data uses that knowledge in the drivers I'm still using internally (but are not submittable as-is, so I'm working on them).

If you use platform data why would you get unpredicatable numbers?

#16 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Quoted 1 line

If you use platform data why would you get unpredicatable numbers?

Because I request the irq numbers from the gpio driver (now I request a free slot starting from 384, because previous drivers had it hardwired). So if the gpio driver requests a slot starting from 0 it may get different values -- in general I can't now what it gets.

So the irq number is unknown at compile time, and can't be written in the platform data.

Actually, the problem is there in any case if you plug two chips in the same computer -- this is extremely unlikely because the sta2x11 is currently only used as a motherboard chipset. The thing must be fixed in any case, because it's a pci device, but still using 384 allows me to use platform data for the current drivers that I'm running until they are ported to upstream quality standards.

/alessandro

#17 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

Quoted 6 lines · Alessandro Rubini
Quoted 1 line

If you use platform data why would you get unpredicatable numbers?

Because I request the irq numbers from the gpio driver (now I request a free slot starting from 384, because previous drivers had it hardwired). So if the gpio driver requests a slot starting from 0 it may get different values -- in general I can't now what it gets.

But this is because you're not using platform data! If you use platform data to tell all the drivers including the gpio driver which ranges to use then this problem does not exist.

#18 lore raw

Re: [PATCH V3 2/2] gpio: add STA2X11 GPIO block

In reply to Alessandro Rubini

Hi Alessandro,

Quoted 18 lines · Alessandro Rubini

Hello Grant. Sorry for the delay.

Quoted 6 lines

drivers/gpio/gpio-sta2x11.c line 390

Quoted 2 lines
drivers/gpio/gpio-sta2x11.c new file +2 -0
+	/* 384 was used in previous code: be compatible for other drivers */
+	err = irq_alloc_descs(-1, 384, GSTA_NR_GPIO, NUMA_NO_NODE);

Where does the number 384 come from? It looks like the driver only needs to allocate a range of irqs and that it doesn't actually matter what the real numbers are. Can 0 be used instead?

The problem is that there are a number of drivers already working (but not ready to be upstreamed), and we'd better continue using them. So, the mmc driver is requesting a specific interrupt number. The code is GPL (published on sourceforge) and I'd better remain compatible.

I'm not completely clear (yet) about how to get the right interrupt number in those other drivers, but I'm willing to remove the constraint as they are cleaned up and submitted.

Quoted 7 lines
Quoted 4 lines

Actually, I'd rather see this driver switched to using irq_domain_add_linear so that irq_descs can be allocated on demand instead of all at once. That way only gpios actually used for irqs get setup.

If it is a request, I'll evaluate it soon. I assume an incremental patch over what Samuel has already picked up is fine.

That is fine with me at least.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#19 lore raw
In reply to Alessandro Rubini

Hi Alessandro,

Quoted 11 lines · Alessandro Rubini

These two patches introduce the multi-function device and GPIO support for the STA2X11 I/O Hub. Core PCI support is already in linux-next.

V1: sent on Jan 26th as RFC and got no comments back

V2: sent on Feb 16th, fixed a number of minor details, got comments from Linus Walleij and Samuel Ortiz.

V3: accepted all suggestions. I delayed this resending a while because I hoped the base STA2X11 patches to be accepted, but despite the positive comments I got on those patches, they are not in linux-next as of today

There was a misunderstanding here: I was expecting a new patchset from you before applying it, since v2 had some unresolved comments.
In fact, there are still some minor issues with it, see my comments on the MFD patch.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/