Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd99758b authored by Mark Brown's avatar Mark Brown Committed by Samuel Ortiz
Browse files

mfd: Convert wm831x to irq_domain



The modern idiom is to use irq_domain to allocate interrupts. This is
useful partly to allow further infrastructure to be based on the domains
and partly because it makes it much easier to allocate virtual interrupts
to devices as we don't need to allocate a contiguous range of interrupt
numbers.

Convert the wm831x driver over to this infrastructure, using a legacy
IRQ mapping if an irq_base is specified in platform data and otherwise
using a linear mapping, always registering the interrupts even if they
won't ever be used. Only boards which need to use the GPIOs as
interrupts should need to use an irq_base.

This means that we can't use the MFD irq_base management since the
unless we're using an explicit irq_base from platform data we can't rely
on a linear mapping of interrupts.  Instead we need to map things via
the irq_domain - provide a conveniencem function wm831x_irq() to save a
small amount of typing when doing so. Looking at this I couldn't clearly
see anything the MFD core could do to make this nicer.

Since we're not supporting device tree yet there's no meaningful
advantage if we don't do this conversion in one, the fact that the
interrupt resources are used for repeated IP blocks makes accessor
functions for the irq_domain more trouble to do than they're worth.

Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 4492c4c3
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -102,10 +102,8 @@ static int wm831x_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
	struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
	struct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);
	struct wm831x *wm831x = wm831x_gpio->wm831x;
	struct wm831x *wm831x = wm831x_gpio->wm831x;


	if (!wm831x->irq_base)
	return irq_create_mapping(wm831x->irq_domain,
		return -EINVAL;
				  WM831X_IRQ_GPIO_1 + offset);

	return wm831x->irq_base + WM831X_IRQ_GPIO_1 + offset;
}
}


static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
static int wm831x_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
+1 −1
Original line number Original line Diff line number Diff line
@@ -73,7 +73,7 @@ static int __devinit wm831x_on_probe(struct platform_device *pdev)
{
{
	struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
	struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
	struct wm831x_on *wm831x_on;
	struct wm831x_on *wm831x_on;
	int irq = platform_get_irq(pdev, 0);
	int irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0));
	int ret;
	int ret;


	wm831x_on = kzalloc(sizeof(struct wm831x_on), GFP_KERNEL);
	wm831x_on = kzalloc(sizeof(struct wm831x_on), GFP_KERNEL);
+5 −4
Original line number Original line Diff line number Diff line
@@ -260,15 +260,16 @@ static __devinit int wm831x_ts_probe(struct platform_device *pdev)
	 * If we have a direct IRQ use it, otherwise use the interrupt
	 * If we have a direct IRQ use it, otherwise use the interrupt
	 * from the WM831x IRQ controller.
	 * from the WM831x IRQ controller.
	 */
	 */
	wm831x_ts->data_irq = wm831x_irq(wm831x,
					 platform_get_irq_byname(pdev,
								 "TCHDATA"));
	if (pdata && pdata->data_irq)
	if (pdata && pdata->data_irq)
		wm831x_ts->data_irq = pdata->data_irq;
		wm831x_ts->data_irq = pdata->data_irq;
	else
		wm831x_ts->data_irq = platform_get_irq_byname(pdev, "TCHDATA");


	wm831x_ts->pd_irq = wm831x_irq(wm831x,
				       platform_get_irq_byname(pdev, "TCHPD"));
	if (pdata && pdata->pd_irq)
	if (pdata && pdata->pd_irq)
		wm831x_ts->pd_irq = pdata->pd_irq;
		wm831x_ts->pd_irq = pdata->pd_irq;
	else
		wm831x_ts->pd_irq = platform_get_irq_byname(pdev, "TCHPD");


	if (pdata)
	if (pdata)
		wm831x_ts->pressure = pdata->pressure;
		wm831x_ts->pressure = pdata->pressure;
+2 −0
Original line number Original line Diff line number Diff line
@@ -496,6 +496,7 @@ config MFD_WM831X_I2C
	select MFD_CORE
	select MFD_CORE
	select MFD_WM831X
	select MFD_WM831X
	select REGMAP_I2C
	select REGMAP_I2C
	select IRQ_DOMAIN
	depends on I2C=y && GENERIC_HARDIRQS
	depends on I2C=y && GENERIC_HARDIRQS
	help
	help
	  Support for the Wolfson Microelecronics WM831x and WM832x PMICs
	  Support for the Wolfson Microelecronics WM831x and WM832x PMICs
@@ -508,6 +509,7 @@ config MFD_WM831X_SPI
	select MFD_CORE
	select MFD_CORE
	select MFD_WM831X
	select MFD_WM831X
	select REGMAP_SPI
	select REGMAP_SPI
	select IRQ_DOMAIN
	depends on SPI_MASTER && GENERIC_HARDIRQS
	depends on SPI_MASTER && GENERIC_HARDIRQS
	help
	help
	  Support for the Wolfson Microelecronics WM831x and WM832x PMICs
	  Support for the Wolfson Microelecronics WM831x and WM832x PMICs
+3 −3
Original line number Original line Diff line number Diff line
@@ -280,11 +280,11 @@ void wm831x_auxadc_init(struct wm831x *wm831x)
	mutex_init(&wm831x->auxadc_lock);
	mutex_init(&wm831x->auxadc_lock);
	INIT_LIST_HEAD(&wm831x->auxadc_pending);
	INIT_LIST_HEAD(&wm831x->auxadc_pending);


	if (wm831x->irq && wm831x->irq_base) {
	if (wm831x->irq) {
		wm831x->auxadc_read = wm831x_auxadc_read_irq;
		wm831x->auxadc_read = wm831x_auxadc_read_irq;


		ret = request_threaded_irq(wm831x->irq_base +
		ret = request_threaded_irq(wm831x_irq(wm831x,
					   WM831X_IRQ_AUXADC_DATA,
						      WM831X_IRQ_AUXADC_DATA),
					   NULL, wm831x_auxadc_irq, 0,
					   NULL, wm831x_auxadc_irq, 0,
					   "auxadc", wm831x);
					   "auxadc", wm831x);
		if (ret < 0) {
		if (ret < 0) {
Loading