mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [RFC PATCH 1/3] basic_mmio_gpio: split into a gpio library and platform device
@ 2011-05-05  0:06 H Hartley Sweeten
  0 siblings, 0 replies; 3+ messages in thread
From: H Hartley Sweeten @ 2011-05-05  0:06 UTC (permalink / raw)
  To: Linux Kernel; +Cc: jamie

Sorry if this is a re-post. I think my previous post got botched...

On Wed, 4 May 2011 16:07:35 +0100, Jamie Iles wrote,
>
> Allow GPIO_BASIC_MMIO_CORE to be used to provide an accessor library
> for implementing GPIO drivers whilst abstracting the register access
> detail.  Based on a patch from Anton Vorontsov[1] and adapted to allow
> bgpio_chip to be embedded in another structure.

[snip]

> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index cfbdef1..91a295d 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_GPIOLIB)		+= gpiolib.o
> 
>  obj-$(CONFIG_GPIO_ADP5520)	+= adp5520-gpio.o
>  obj-$(CONFIG_GPIO_ADP5588)	+= adp5588-gpio.o
> +obj-$(CONFIG_GPIO_BASIC_MMIO_CORE)	+= basic_mmio_gpio.o
>  obj-$(CONFIG_GPIO_BASIC_MMIO)	+= basic_mmio_gpio.o

The line above can be removed.  GPIO_BASIC_MMIO selects GPIO_BASIC_MMIO_CORE.

>  obj-$(CONFIG_GPIO_LANGWELL)	+= langwell_gpio.o
>  obj-$(CONFIG_GPIO_MAX730X)	+= max730x.o
> diff --git a/drivers/gpio/basic_mmio_gpio.c b/drivers/gpio/basic_mmio_gpio.c
> index b2ec45f..6b1c6e5 100644
> --- a/drivers/gpio/basic_mmio_gpio.c
> +++ b/drivers/gpio/basic_mmio_gpio.c

[snip]

> +static int __devinit bgpio_pdev_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct resource *r;
> +	void __iomem *dat;
> +	void __iomem *set;
> +	void __iomem *clr;
> +	void __iomem *dirout;
> +	void __iomem *dirin;
> +	unsigned long sz;
> +	bool be;
> +	int err;
> +	struct bgpio_chip *bgc;
> +	struct bgpio_pdata *pdata = dev_get_platdata(dev);
> +
> +	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat");
> +	if (!r)
> +		return -EINVAL;
> +
> +	sz = resource_size(r);
> +
> +	dat = bgpio_map(pdev, "dat", sz, &err);
> +	if (!dat)
> +		return err ? err : -EINVAL;
> +
> +	set = bgpio_map(pdev, "set", sz, &err);
> +	if (err)
> +		return err;
> +
> +	clr = bgpio_map(pdev, "clr", sz, &err);
> +	if (err)
> +		return err;
> +
> +	dirout = bgpio_map(pdev, "dirout", sz, &err);
> +	if (err)
> +		return err;
> +
> +	dirin = bgpio_map(pdev, "dirin", sz, &err);
> +	if (err)
> +		return err;
> +
> +	be = !strcmp(platform_get_device_id(pdev)->name, "basic-mmio-gpio-be");
> +
> +	bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL);
> +	if (!bgc)
> +		return -ENOMEM;
> +
> +	err = bgpio_init(bgc, dev, sz, dat, set, clr, dirout, dirin, be);
> +	if (err)
> +		return err;
> +
> +	if (pdata) {
> +		bgc->gc.base = pdata->base;
> +		if (pdata->ngpio > 0)
> +			bgc->gc.ngpio = pdata->ngpio;
> +	}
> +
> +	platform_set_drvdata(pdev, bgc);
> +
> +	return 0;
> +}

Unless I missed it, the probe should end by actually adding the gpiochip:

-	return 0;
+	return gpiochip_add(&bgc->gc);

Regards,
Hartley

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [RFC PATCH 1/3] basic_mmio_gpio: split into a gpio library and platform device
@ 2011-05-05  0:01 H Hartley Sweeten
  0 siblings, 0 replies; 3+ messages in thread
From: H Hartley Sweeten @ 2011-05-05  0:01 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jamie Iles

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2830 bytes --]

On Wed, 4 May 2011 16:07:35 +0100, Jamie Iles wrote,
>
> Allow GPIO_BASIC_MMIO_CORE to be used to provide an accessor library
> for implementing GPIO drivers whilst abstracting the register access
> detail.  Based on a patch from Anton Vorontsov[1] and adapted to allow
> bgpio_chip to be embedded in another structure.

[snip]

> diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
> index cfbdef1..91a295d 100644
> --- a/drivers/gpio/Makefile
> +++ b/drivers/gpio/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_GPIOLIB)		+= gpiolib.o
> 
>  obj-$(CONFIG_GPIO_ADP5520)	+= adp5520-gpio.o
>  obj-$(CONFIG_GPIO_ADP5588)	+= adp5588-gpio.o
> +obj-$(CONFIG_GPIO_BASIC_MMIO_CORE)	+= basic_mmio_gpio.o
>  obj-$(CONFIG_GPIO_BASIC_MMIO)	+= basic_mmio_gpio.o

The line above can be removed.  GPIO_BASIC_MMIO selects GPIO_BASIC_MMIO_CORE.

>  obj-$(CONFIG_GPIO_LANGWELL)	+= langwell_gpio.o
>  obj-$(CONFIG_GPIO_MAX730X)	+= max730x.o
> diff --git a/drivers/gpio/basic_mmio_gpio.c b/drivers/gpio/basic_mmio_gpio.c
> index b2ec45f..6b1c6e5 100644
> --- a/drivers/gpio/basic_mmio_gpio.c
> +++ b/drivers/gpio/basic_mmio_gpio.c

[snip]

> +static int __devinit bgpio_pdev_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct resource *r;
> +	void __iomem *dat;
> +	void __iomem *set;
> +	void __iomem *clr;
> +	void __iomem *dirout;
> +	void __iomem *dirin;
> +	unsigned long sz;
> +	bool be;
> +	int err;
> +	struct bgpio_chip *bgc;
> +	struct bgpio_pdata *pdata = dev_get_platdata(dev);
> +
> +	r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat");
> +	if (!r)
> +		return -EINVAL;
> +
> +	sz = resource_size(r);
> +
> +	dat = bgpio_map(pdev, "dat", sz, &err);
> +	if (!dat)
> +		return err ? err : -EINVAL;
> +
> +	set = bgpio_map(pdev, "set", sz, &err);
> +	if (err)
> +		return err;
> +
> +	clr = bgpio_map(pdev, "clr", sz, &err);
> +	if (err)
> +		return err;
> +
> +	dirout = bgpio_map(pdev, "dirout", sz, &err);
> +	if (err)
> +		return err;
> +
> +	dirin = bgpio_map(pdev, "dirin", sz, &err);
> +	if (err)
> +		return err;
> +
> +	be = !strcmp(platform_get_device_id(pdev)->name, "basic-mmio-gpio-be");
> +
> +	bgc = devm_kzalloc(&pdev->dev, sizeof(*bgc), GFP_KERNEL);
> +	if (!bgc)
> +		return -ENOMEM;
> +
> +	err = bgpio_init(bgc, dev, sz, dat, set, clr, dirout, dirin, be);
> +	if (err)
> +		return err;
> +
> +	if (pdata) {
> +		bgc->gc.base = pdata->base;
> +		if (pdata->ngpio > 0)
> +			bgc->gc.ngpio = pdata->ngpio;
> +	}
> +
> +	platform_set_drvdata(pdev, bgc);
> +
> +	return 0;
> +}

Unless I missed it, the probe should end by actually adding the gpiochip:

-	return 0;
+	return gpiochip_add(&bgc->gc);

Regards,
Hartley
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [RFC PATCH 0/3] Use basic_mmio_gpio to implement a generic gpio chip
@ 2011-05-04 15:07 Jamie Iles
  2011-05-04 15:07 ` [RFC PATCH 1/3] basic_mmio_gpio: split into a gpio library and platform device Jamie Iles
  0 siblings, 1 reply; 3+ messages in thread
From: Jamie Iles @ 2011-05-04 15:07 UTC (permalink / raw)
  To: linux-kernel
  Cc: grant.likely, cbouatmailru, linux, tglx, arnd, nico, alan, Jamie Iles

This series is based on my earlier set of GPIO patches[1] to extend the
basic_mmio_driver to be used as a library to implement a more generic gpio
chip as initially implemented by Anton Vorontsov[2].

I've modified Anton's patch slightly to allow the bgpio_chip to be embedded
into another structure and converted two drivers over - bt8xxgpio and
langwell.  bt8xxgpio seems to play nicely, but langwell not so much as it
didn't previously use a gpio_chip per bank but it is a nice illustration.

Note that this is the same set of patches as attached in "Re: [PATCHv3 0/7]
gpio: extend basic_mmio_gpio for different controllers" but reposted as a set
of patches for convenience.

1. http://article.gmane.org/gmane.linux.kernel/1124700
2. http://lkml.org/lkml/2011/4/19/401

Jamie Iles (3):
  basic_mmio_gpio: split into a gpio library and platform device
  gpio/bt8xxgpio: convert to use basic_mmio_gpio library
  gpio/langwell: convert to use basic_mmio_gpio library

 drivers/gpio/Kconfig            |    8 +
 drivers/gpio/Makefile           |    1 +
 drivers/gpio/basic_mmio_gpio.c  |  317 +++++++++++++++++++++------------------
 drivers/gpio/bt8xxgpio.c        |  119 +++------------
 drivers/gpio/langwell_gpio.c    |  253 +++++++++++++++----------------
 include/linux/basic_mmio_gpio.h |   55 +++++++
 6 files changed, 381 insertions(+), 372 deletions(-)

-- 
1.7.4.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-05  0:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05  0:06 [RFC PATCH 1/3] basic_mmio_gpio: split into a gpio library and platform device H Hartley Sweeten
  -- strict thread matches above, loose matches on Subject: below --
2011-05-05  0:01 H Hartley Sweeten
2011-05-04 15:07 [RFC PATCH 0/3] Use basic_mmio_gpio to implement a generic gpio chip Jamie Iles
2011-05-04 15:07 ` [RFC PATCH 1/3] basic_mmio_gpio: split into a gpio library and platform device Jamie Iles

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®