* [RFC PATCH 1/5] gemini: convert to basic-mmio-gpio
2011-04-11 11:48 [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio Jamie Iles
@ 2011-04-11 11:48 ` Jamie Iles
2011-04-12 14:37 ` Anton Vorontsov
2011-04-11 11:48 ` [RFC PATCH 2/5] sa1100: " Jamie Iles
` (5 subsequent siblings)
6 siblings, 1 reply; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 11:48 UTC (permalink / raw)
To: linux-arm-kernel
The basic-mmio-gpio driver is capable of supporting this controller so
convert the platform to use it for basic GPIO support.
Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
arch/arm/mach-gemini/gpio.c | 83 ++++++++++++++----------------------------
1 files changed, 28 insertions(+), 55 deletions(-)
diff --git a/arch/arm/mach-gemini/gpio.c b/arch/arm/mach-gemini/gpio.c
index fdc7ef1..08cc1f8 100644
--- a/arch/arm/mach-gemini/gpio.c
+++ b/arch/arm/mach-gemini/gpio.c
@@ -18,6 +18,9 @@
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/basic_mmio_gpio.h>
+#include <linux/err.h>
#include <mach/hardware.h>
#include <mach/irqs.h>
@@ -150,60 +153,13 @@ static struct irq_chip gpio_irq_chip = {
.irq_set_type = gpio_set_irq_type,
};
-static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset,
- int dir)
-{
- unsigned int base = GPIO_BASE(offset / 32);
- unsigned int reg;
-
- reg = __raw_readl(base + GPIO_DIR);
- if (dir)
- reg |= 1 << (offset % 32);
- else
- reg &= ~(1 << (offset % 32));
- __raw_writel(reg, base + GPIO_DIR);
-}
-
-static void gemini_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
-{
- unsigned int base = GPIO_BASE(offset / 32);
-
- if (value)
- __raw_writel(1 << (offset % 32), base + GPIO_DATA_SET);
- else
- __raw_writel(1 << (offset % 32), base + GPIO_DATA_CLR);
-}
-
-static int gemini_gpio_get(struct gpio_chip *chip, unsigned offset)
-{
- unsigned int base = GPIO_BASE(offset / 32);
-
- return (__raw_readl(base + GPIO_DATA_IN) >> (offset % 32)) & 1;
-}
-
-static int gemini_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
-{
- _set_gpio_direction(chip, offset, 0);
- return 0;
-}
-
-static int gemini_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
- int value)
-{
- _set_gpio_direction(chip, offset, 1);
- gemini_gpio_set(chip, offset, value);
- return 0;
-}
-
-static struct gpio_chip gemini_gpio_chip = {
- .label = "Gemini",
- .direction_input = gemini_gpio_direction_input,
- .get = gemini_gpio_get,
- .direction_output = gemini_gpio_direction_output,
- .set = gemini_gpio_set,
- .base = 0,
- .ngpio = GPIO_PORT_NUM * 32,
-};
+#define GPIO_RES(__name, __addr) \
+ { \
+ .start = (__addr), \
+ .end = (__addr) + 0x3, \
+ .flags = IORESOURCE_MEM, \
+ .name = #__name, \
+ }
void __init gemini_gpio_init(void)
{
@@ -226,5 +182,22 @@ void __init gemini_gpio_init(void)
irq_set_handler_data(IRQ_GPIO(i), (void *)i);
}
- BUG_ON(gpiochip_add(&gemini_gpio_chip));
+ for (i = 0; i < GPIO_PORT_NUM; ++i) {
+ struct resource res[] = {
+ GPIO_RES(dirout, GEMINI_GPIO_BASE(i) + GPIO_DIR),
+ GPIO_RES(set, GEMINI_GPIO_BASE(i) + GPIO_DATA_SET),
+ GPIO_RES(clr, GEMINI_GPIO_BASE(i) + GPIO_DATA_CLR),
+ GPIO_RES(dat, GEMINI_GPIO_BASE(i) + GPIO_DATA_IN),
+ };
+ struct bgpio_pdata pdata = {
+ .base = i * 32,
+ .ngpio = 32,
+ };
+ struct platform_device *pdev;
+
+ pdev = platform_device_register_resndata(NULL,
+ "basic-mmio-gpio", i, res, ARRAY_SIZE(res), &pdata,
+ sizeof(pdata));
+ WARN_ON(IS_ERR(pdev));
+ }
}
--
1.7.4.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [RFC PATCH 1/5] gemini: convert to basic-mmio-gpio
2011-04-11 11:48 ` [RFC PATCH 1/5] gemini: convert " Jamie Iles
@ 2011-04-12 14:37 ` Anton Vorontsov
2011-04-12 15:01 ` Jamie Iles
2011-04-13 11:46 ` Sergei Shtylyov
0 siblings, 2 replies; 21+ messages in thread
From: Anton Vorontsov @ 2011-04-12 14:37 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Apr 11, 2011 at 12:48:18PM +0100, Jamie Iles wrote:
> The basic-mmio-gpio driver is capable of supporting this controller so
> convert the platform to use it for basic GPIO support.
>
> Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com>
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> ---
[...]
> +#define GPIO_RES(__name, __addr) \
> + { \
> + .start = (__addr), \
> + .end = (__addr) + 0x3, \
> + .flags = IORESOURCE_MEM, \
> + .name = #__name, \
> + }
Btw, how about moving this (repetitive) macro into basic_mmio_gpio.h?
Assuming, that there could be IRQ resources later, making
something like BGPIO_MEM_RES(name, addr, sz)?
Or, even better, some generic shorthand macro in linux/ioport.h?
#define IORES(__type, __name, __addr, __size) \
{ \
.start = (__addr), \
.end = (__addr) + (__size), \
.flags = IORESOURCE_##__type, \
.name = #__name, \
}
Would translate to
IORES(MEM, set, GEMINI_GPIO_BASE(i) + GPIO_DATA_SET), 3),
vs.
GPIO_RES(set, GEMINI_GPIO_BASE(i) + GPIO_DATA_SET),
Thanks,
--
Anton Vorontsov
Email: cbouatmailru at gmail.com
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 1/5] gemini: convert to basic-mmio-gpio
2011-04-12 14:37 ` Anton Vorontsov
@ 2011-04-12 15:01 ` Jamie Iles
2011-04-13 11:46 ` Sergei Shtylyov
1 sibling, 0 replies; 21+ messages in thread
From: Jamie Iles @ 2011-04-12 15:01 UTC (permalink / raw)
To: linux-arm-kernel
Hi Anton,
On Tue, Apr 12, 2011 at 06:37:14PM +0400, Anton Vorontsov wrote:
> On Mon, Apr 11, 2011 at 12:48:18PM +0100, Jamie Iles wrote:
> > The basic-mmio-gpio driver is capable of supporting this controller so
> > convert the platform to use it for basic GPIO support.
> >
> > Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com>
> > Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> > ---
> [...]
> > +#define GPIO_RES(__name, __addr) \
> > + { \
> > + .start = (__addr), \
> > + .end = (__addr) + 0x3, \
> > + .flags = IORESOURCE_MEM, \
> > + .name = #__name, \
> > + }
>
> Btw, how about moving this (repetitive) macro into basic_mmio_gpio.h?
>
> Assuming, that there could be IRQ resources later, making
> something like BGPIO_MEM_RES(name, addr, sz)?
Yes, that sounds reasonable.
> Or, even better, some generic shorthand macro in linux/ioport.h?
>
> #define IORES(__type, __name, __addr, __size) \
> { \
> .start = (__addr), \
> .end = (__addr) + (__size), \
> .flags = IORESOURCE_##__type, \
> .name = #__name, \
> }
I'm not sure about this - it looks multiple flags can be OR'd together
and resources nested so singling out this particular case for a macro
doesn't feel right to me.
Jamie
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 1/5] gemini: convert to basic-mmio-gpio
2011-04-12 14:37 ` Anton Vorontsov
2011-04-12 15:01 ` Jamie Iles
@ 2011-04-13 11:46 ` Sergei Shtylyov
1 sibling, 0 replies; 21+ messages in thread
From: Sergei Shtylyov @ 2011-04-13 11:46 UTC (permalink / raw)
To: linux-arm-kernel
Hello.
On 12-04-2011 18:37, Anton Vorontsov wrote:
>> The basic-mmio-gpio driver is capable of supporting this controller so
>> convert the platform to use it for basic GPIO support.
>> Cc: Hans Ulli Kroll<ulli.kroll@googlemail.com>
>> Signed-off-by: Jamie Iles<jamie@jamieiles.com>
>> ---
> [...]
>> +#define GPIO_RES(__name, __addr) \
>> + { \
>> + .start = (__addr), \
>> + .end = (__addr) + 0x3, \
>> + .flags = IORESOURCE_MEM, \
>> + .name = #__name, \
>> + }
> Btw, how about moving this (repetitive) macro into basic_mmio_gpio.h?
> Assuming, that there could be IRQ resources later, making
> something like BGPIO_MEM_RES(name, addr, sz)?
> Or, even better, some generic shorthand macro in linux/ioport.h?
> #define IORES(__type, __name, __addr, __size) \
> { \
> .start = (__addr), \
> .end = (__addr) + (__size), \
You forgot to subtract 1.
> Thanks,
WBR, Sergei
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 2/5] sa1100: convert to basic-mmio-gpio
2011-04-11 11:48 [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio Jamie Iles
2011-04-11 11:48 ` [RFC PATCH 1/5] gemini: convert " Jamie Iles
@ 2011-04-11 11:48 ` Jamie Iles
2011-04-11 16:00 ` Jamie Iles
2011-04-11 11:48 ` [RFC PATCH 3/5] w90x900: " Jamie Iles
` (4 subsequent siblings)
6 siblings, 1 reply; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 11:48 UTC (permalink / raw)
To: linux-arm-kernel
The basic-mmio-gpio driver is capable of supporting this controller so
convert the platform to use it for basic GPIO support.
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
arch/arm/mach-sa1100/gpio.c | 69 +++++++++++++++---------------------------
1 files changed, 25 insertions(+), 44 deletions(-)
diff --git a/arch/arm/mach-sa1100/gpio.c b/arch/arm/mach-sa1100/gpio.c
index 0d3829a..f7bd975 100644
--- a/arch/arm/mach-sa1100/gpio.c
+++ b/arch/arm/mach-sa1100/gpio.c
@@ -8,58 +8,39 @@
* published by the Free Software Foundation.
*/
+#include <linux/basic_mmio_gpio.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
+#include <linux/platform_device.h>
#include <asm/gpio.h>
#include <mach/hardware.h>
#include "generic.h"
-static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset)
-{
- return GPLR & GPIO_GPIO(offset);
-}
-
-static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
-{
- if (value)
- GPSR = GPIO_GPIO(offset);
- else
- GPCR = GPIO_GPIO(offset);
-}
-
-static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- GPDR &= ~GPIO_GPIO(offset);
- local_irq_restore(flags);
- return 0;
-}
-
-static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- sa1100_gpio_set(chip, offset, value);
- GPDR |= GPIO_GPIO(offset);
- local_irq_restore(flags);
- return 0;
-}
-
-static struct gpio_chip sa1100_gpio_chip = {
- .label = "gpio",
- .direction_input = sa1100_direction_input,
- .direction_output = sa1100_direction_output,
- .set = sa1100_gpio_set,
- .get = sa1100_gpio_get,
- .base = 0,
- .ngpio = GPIO_MAX + 1,
-};
+#define GPIO_RES(__name, __addr) \
+ { \
+ .start = (__addr), \
+ .end = (__addr) + 0x3, \
+ .flags = IORESOURCE_MEM, \
+ .name = #__name, \
+ }
void __init sa1100_init_gpio(void)
{
- gpiochip_add(&sa1100_gpio_chip);
+ struct resource res[] = {
+ GPIO_RES(set, 0x90040008),
+ GPIO_RES(clr, 0x9004000C),
+ GPIO_RES(dat, 0x90040000),
+ GPIO_RES(dirout, 0x90040004),
+ };
+ struct bgpio_pdata pdata = {
+ .ngpio = GPIO_MAX + 1,
+ };
+ struct platform_device *pdev;
+
+ pdev = platform_device_register_resndata(NULL, "basic-mmio-gpio", 0,
+ res, ARRAY_SIZE(res), &pdata,
+ sizeof(pdata));
+ WARN_ON(IS_ERR(pdev));
}
--
1.7.4.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [RFC PATCH 3/5] w90x900: convert to basic-mmio-gpio
2011-04-11 11:48 [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio Jamie Iles
2011-04-11 11:48 ` [RFC PATCH 1/5] gemini: convert " Jamie Iles
2011-04-11 11:48 ` [RFC PATCH 2/5] sa1100: " Jamie Iles
@ 2011-04-11 11:48 ` Jamie Iles
2011-04-11 14:27 ` Wan ZongShun
2011-04-11 11:48 ` [RFC PATCH 4/5] iop: " Jamie Iles
` (3 subsequent siblings)
6 siblings, 1 reply; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 11:48 UTC (permalink / raw)
To: linux-arm-kernel
The basic-mmio-gpio driver is capable of supporting this controller so
convert the platform to use it for basic GPIO support.
Cc: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
arch/arm/mach-w90x900/gpio.c | 162 +++++++++++-------------------------------
1 files changed, 43 insertions(+), 119 deletions(-)
diff --git a/arch/arm/mach-w90x900/gpio.c b/arch/arm/mach-w90x900/gpio.c
index ba05aec..5dd7efe 100644
--- a/arch/arm/mach-w90x900/gpio.c
+++ b/arch/arm/mach-w90x900/gpio.c
@@ -10,145 +10,69 @@
* published by the Free Software Foundation.
*/
-#include <linux/clk.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/irq.h>
-#include <linux/debugfs.h>
-#include <linux/seq_file.h>
+#include <linux/basic_mmio_gpio.h>
+#include <linux/err.h>
#include <linux/kernel.h>
-#include <linux/list.h>
#include <linux/module.h>
-#include <linux/io.h>
#include <linux/gpio.h>
+#include <linux/platform_device.h>
#include <mach/hardware.h>
-#define GPIO_BASE (W90X900_VA_GPIO)
#define GPIO_DIR (0x04)
#define GPIO_OUT (0x08)
#define GPIO_IN (0x0C)
#define GROUPINERV (0x10)
-#define GPIO_GPIO(Nb) (0x00000001 << (Nb))
-#define to_nuc900_gpio_chip(c) container_of(c, struct nuc900_gpio_chip, chip)
-#define NUC900_GPIO_CHIP(name, base_gpio, nr_gpio) \
- { \
- .chip = { \
- .label = name, \
- .direction_input = nuc900_dir_input, \
- .direction_output = nuc900_dir_output, \
- .get = nuc900_gpio_get, \
- .set = nuc900_gpio_set, \
- .base = base_gpio, \
- .ngpio = nr_gpio, \
- } \
+#define GPIO_RES(__name, __addr) \
+ { \
+ .start = (__addr), \
+ .end = (__addr) + 0x3, \
+ .flags = IORESOURCE_MEM, \
+ .name = #__name, \
}
-struct nuc900_gpio_chip {
- struct gpio_chip chip;
- void __iomem *regbase; /* Base of group register*/
- spinlock_t gpio_lock;
-};
-
-static int nuc900_gpio_get(struct gpio_chip *chip, unsigned offset)
-{
- struct nuc900_gpio_chip *nuc900_gpio = to_nuc900_gpio_chip(chip);
- void __iomem *pio = nuc900_gpio->regbase + GPIO_IN;
- unsigned int regval;
-
- regval = __raw_readl(pio);
- regval &= GPIO_GPIO(offset);
-
- return (regval != 0);
-}
-
-static void nuc900_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
-{
- struct nuc900_gpio_chip *nuc900_gpio = to_nuc900_gpio_chip(chip);
- void __iomem *pio = nuc900_gpio->regbase + GPIO_OUT;
- unsigned int regval;
- unsigned long flags;
-
- spin_lock_irqsave(&nuc900_gpio->gpio_lock, flags);
-
- regval = __raw_readl(pio);
-
- if (val)
- regval |= GPIO_GPIO(offset);
- else
- regval &= ~GPIO_GPIO(offset);
-
- __raw_writel(regval, pio);
-
- spin_unlock_irqrestore(&nuc900_gpio->gpio_lock, flags);
-}
-
-static int nuc900_dir_input(struct gpio_chip *chip, unsigned offset)
-{
- struct nuc900_gpio_chip *nuc900_gpio = to_nuc900_gpio_chip(chip);
- void __iomem *pio = nuc900_gpio->regbase + GPIO_DIR;
- unsigned int regval;
- unsigned long flags;
-
- spin_lock_irqsave(&nuc900_gpio->gpio_lock, flags);
-
- regval = __raw_readl(pio);
- regval &= ~GPIO_GPIO(offset);
- __raw_writel(regval, pio);
-
- spin_unlock_irqrestore(&nuc900_gpio->gpio_lock, flags);
-
- return 0;
-}
-
-static int nuc900_dir_output(struct gpio_chip *chip, unsigned offset, int val)
-{
- struct nuc900_gpio_chip *nuc900_gpio = to_nuc900_gpio_chip(chip);
- void __iomem *outreg = nuc900_gpio->regbase + GPIO_OUT;
- void __iomem *pio = nuc900_gpio->regbase + GPIO_DIR;
- unsigned int regval;
- unsigned long flags;
-
- spin_lock_irqsave(&nuc900_gpio->gpio_lock, flags);
-
- regval = __raw_readl(pio);
- regval |= GPIO_GPIO(offset);
- __raw_writel(regval, pio);
-
- regval = __raw_readl(outreg);
-
- if (val)
- regval |= GPIO_GPIO(offset);
- else
- regval &= ~GPIO_GPIO(offset);
-
- __raw_writel(regval, outreg);
-
- spin_unlock_irqrestore(&nuc900_gpio->gpio_lock, flags);
-
- return 0;
-}
+#define NUC900_GPIO_BANK(base_gpio, nr_gpio) \
+ { \
+ .ngpio = (nr_gpio), \
+ .base = (base_gpio), \
+ }
-static struct nuc900_gpio_chip nuc900_gpio[] = {
- NUC900_GPIO_CHIP("GROUPC", 0, 16),
- NUC900_GPIO_CHIP("GROUPD", 16, 10),
- NUC900_GPIO_CHIP("GROUPE", 26, 14),
- NUC900_GPIO_CHIP("GROUPF", 40, 10),
- NUC900_GPIO_CHIP("GROUPG", 50, 17),
- NUC900_GPIO_CHIP("GROUPH", 67, 8),
- NUC900_GPIO_CHIP("GROUPI", 75, 17),
+struct nuc900_gpio_bank {
+ unsigned int base;
+ unsigned int ngpio;
};
void __init nuc900_init_gpio(int nr_group)
{
unsigned i;
- struct nuc900_gpio_chip *gpio_chip;
+
+ struct nuc900_gpio_bank nuc900_gpio[] = {
+ NUC900_GPIO_BANK(0, 16),
+ NUC900_GPIO_BANK(16, 10),
+ NUC900_GPIO_BANK(26, 14),
+ NUC900_GPIO_BANK(40, 10),
+ NUC900_GPIO_BANK(50, 17),
+ NUC900_GPIO_BANK(67, 8),
+ NUC900_GPIO_BANK(75, 17),
+ };
for (i = 0; i < nr_group; i++) {
- gpio_chip = &nuc900_gpio[i];
- spin_lock_init(&gpio_chip->gpio_lock);
- gpio_chip->regbase = GPIO_BASE + i * GROUPINERV;
- gpiochip_add(&gpio_chip->chip);
+ unsigned long addr = W90X900_PA_GPIO + i * GROUPINERV;
+ struct resource res[] = {
+ GPIO_RES(dat, addr + GPIO_IN),
+ GPIO_RES(set, addr + GPIO_OUT),
+ GPIO_RES(dirout, addr + GPIO_DIR),
+ };
+ struct bgpio_pdata pdata = {
+ .ngpio = nuc900_gpio[i].ngpio,
+ .base = nuc900_gpio[i].base,
+ };
+ struct platform_device *pdev;
+
+ pdev = platform_device_register_resndata(NULL,
+ "basic-mmio-gpio", i, res, ARRAY_SIZE(res), &pdata,
+ sizeof(pdata));
+ WARN_ON(IS_ERR(pdev));
}
}
--
1.7.4.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [RFC PATCH 3/5] w90x900: convert to basic-mmio-gpio
2011-04-11 11:48 ` [RFC PATCH 3/5] w90x900: " Jamie Iles
@ 2011-04-11 14:27 ` Wan ZongShun
2011-06-10 12:50 ` Jamie Iles
0 siblings, 1 reply; 21+ messages in thread
From: Wan ZongShun @ 2011-04-11 14:27 UTC (permalink / raw)
To: linux-arm-kernel
2011/4/11 Jamie Iles <jamie@jamieiles.com>:
> The basic-mmio-gpio driver is capable of supporting this controller so
> convert the platform to use it for basic GPIO support.
>
> Cc: Wan ZongShun <mcuos.com@gmail.com>
> Signed-off-by: Jamie Iles <jamie@jamieiles.com>
Acked-by: Wan ZongShun <mcuos.com@gmail.com>
Thanks, so you can submit it to Russell for merging.
> ---
> ?arch/arm/mach-w90x900/gpio.c | ?162 +++++++++++-------------------------------
> ?1 files changed, 43 insertions(+), 119 deletions(-)
>
> diff --git a/arch/arm/mach-w90x900/gpio.c b/arch/arm/mach-w90x900/gpio.c
> index ba05aec..5dd7efe 100644
> --- a/arch/arm/mach-w90x900/gpio.c
> +++ b/arch/arm/mach-w90x900/gpio.c
> @@ -10,145 +10,69 @@
> ?* published by the Free Software Foundation.
> ?*/
>
> -#include <linux/clk.h>
> -#include <linux/errno.h>
> -#include <linux/interrupt.h>
> -#include <linux/irq.h>
> -#include <linux/debugfs.h>
> -#include <linux/seq_file.h>
> +#include <linux/basic_mmio_gpio.h>
> +#include <linux/err.h>
> ?#include <linux/kernel.h>
> -#include <linux/list.h>
> ?#include <linux/module.h>
> -#include <linux/io.h>
> ?#include <linux/gpio.h>
> +#include <linux/platform_device.h>
>
> ?#include <mach/hardware.h>
>
> -#define GPIO_BASE ? ? ? ? ? ? ?(W90X900_VA_GPIO)
> ?#define GPIO_DIR ? ? ? ? ? ? ? (0x04)
> ?#define GPIO_OUT ? ? ? ? ? ? ? (0x08)
> ?#define GPIO_IN ? ? ? ? ? ? ? ? ? ? ? ?(0x0C)
> ?#define GROUPINERV ? ? ? ? ? ? (0x10)
> -#define GPIO_GPIO(Nb) ? ? ? ? ?(0x00000001 << (Nb))
> -#define to_nuc900_gpio_chip(c) container_of(c, struct nuc900_gpio_chip, chip)
>
> -#define NUC900_GPIO_CHIP(name, base_gpio, nr_gpio) ? ? ? ? ? ? ? ? ? ? \
> - ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> - ? ? ? ? ? ? ? .chip = { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> - ? ? ? ? ? ? ? ? ? ? ? .label ? ? ? ? ? ?= name, ? ? ? ? ? ? ? ? ? ? ? \
> - ? ? ? ? ? ? ? ? ? ? ? .direction_input ?= nuc900_dir_input, ? ? ? ? ? \
> - ? ? ? ? ? ? ? ? ? ? ? .direction_output = nuc900_dir_output, ? ? ? ? ?\
> - ? ? ? ? ? ? ? ? ? ? ? .get ? ? ? ? ? ? ?= nuc900_gpio_get, ? ? ? ? ? ?\
> - ? ? ? ? ? ? ? ? ? ? ? .set ? ? ? ? ? ? ?= nuc900_gpio_set, ? ? ? ? ? ?\
> - ? ? ? ? ? ? ? ? ? ? ? .base ? ? ? ? ? ? = base_gpio, ? ? ? ? ? ? ? ? ?\
> - ? ? ? ? ? ? ? ? ? ? ? .ngpio ? ? ? ? ? ?= nr_gpio, ? ? ? ? ? ? ? ? ? ?\
> - ? ? ? ? ? ? ? } ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> +#define GPIO_RES(__name, __addr) \
> + ? ? ? { \
> + ? ? ? ? ? ? ? .start = (__addr), \
> + ? ? ? ? ? ? ? .end = (__addr) + 0x3, \
> + ? ? ? ? ? ? ? .flags = IORESOURCE_MEM, \
> + ? ? ? ? ? ? ? .name = #__name, \
> ? ? ? ?}
>
> -struct nuc900_gpio_chip {
> - ? ? ? struct gpio_chip ? ? ? ?chip;
> - ? ? ? void __iomem ? ? ? ? ? ?*regbase; ? ? ? /* Base of group register*/
> - ? ? ? spinlock_t ? ? ? ? ? ? ?gpio_lock;
> -};
> -
> -static int nuc900_gpio_get(struct gpio_chip *chip, unsigned offset)
> -{
> - ? ? ? struct nuc900_gpio_chip *nuc900_gpio = to_nuc900_gpio_chip(chip);
> - ? ? ? void __iomem *pio = nuc900_gpio->regbase + GPIO_IN;
> - ? ? ? unsigned int regval;
> -
> - ? ? ? regval = __raw_readl(pio);
> - ? ? ? regval &= GPIO_GPIO(offset);
> -
> - ? ? ? return (regval != 0);
> -}
> -
> -static void nuc900_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
> -{
> - ? ? ? struct nuc900_gpio_chip *nuc900_gpio = to_nuc900_gpio_chip(chip);
> - ? ? ? void __iomem *pio = nuc900_gpio->regbase + GPIO_OUT;
> - ? ? ? unsigned int regval;
> - ? ? ? unsigned long flags;
> -
> - ? ? ? spin_lock_irqsave(&nuc900_gpio->gpio_lock, flags);
> -
> - ? ? ? regval = __raw_readl(pio);
> -
> - ? ? ? if (val)
> - ? ? ? ? ? ? ? regval |= GPIO_GPIO(offset);
> - ? ? ? else
> - ? ? ? ? ? ? ? regval &= ~GPIO_GPIO(offset);
> -
> - ? ? ? __raw_writel(regval, pio);
> -
> - ? ? ? spin_unlock_irqrestore(&nuc900_gpio->gpio_lock, flags);
> -}
> -
> -static int nuc900_dir_input(struct gpio_chip *chip, unsigned offset)
> -{
> - ? ? ? struct nuc900_gpio_chip *nuc900_gpio = to_nuc900_gpio_chip(chip);
> - ? ? ? void __iomem *pio = nuc900_gpio->regbase + GPIO_DIR;
> - ? ? ? unsigned int regval;
> - ? ? ? unsigned long flags;
> -
> - ? ? ? spin_lock_irqsave(&nuc900_gpio->gpio_lock, flags);
> -
> - ? ? ? regval = __raw_readl(pio);
> - ? ? ? regval &= ~GPIO_GPIO(offset);
> - ? ? ? __raw_writel(regval, pio);
> -
> - ? ? ? spin_unlock_irqrestore(&nuc900_gpio->gpio_lock, flags);
> -
> - ? ? ? return 0;
> -}
> -
> -static int nuc900_dir_output(struct gpio_chip *chip, unsigned offset, int val)
> -{
> - ? ? ? struct nuc900_gpio_chip *nuc900_gpio = to_nuc900_gpio_chip(chip);
> - ? ? ? void __iomem *outreg = nuc900_gpio->regbase + GPIO_OUT;
> - ? ? ? void __iomem *pio = nuc900_gpio->regbase + GPIO_DIR;
> - ? ? ? unsigned int regval;
> - ? ? ? unsigned long flags;
> -
> - ? ? ? spin_lock_irqsave(&nuc900_gpio->gpio_lock, flags);
> -
> - ? ? ? regval = __raw_readl(pio);
> - ? ? ? regval |= GPIO_GPIO(offset);
> - ? ? ? __raw_writel(regval, pio);
> -
> - ? ? ? regval = __raw_readl(outreg);
> -
> - ? ? ? if (val)
> - ? ? ? ? ? ? ? regval |= GPIO_GPIO(offset);
> - ? ? ? else
> - ? ? ? ? ? ? ? regval &= ~GPIO_GPIO(offset);
> -
> - ? ? ? __raw_writel(regval, outreg);
> -
> - ? ? ? spin_unlock_irqrestore(&nuc900_gpio->gpio_lock, flags);
> -
> - ? ? ? return 0;
> -}
> +#define NUC900_GPIO_BANK(base_gpio, nr_gpio) ? ? ? ? ? ? ? ? ? \
> + ? ? ? { ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> + ? ? ? ? ? ? ? .ngpio ?= (nr_gpio), ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ? ? ? ? ? ? ? .base ? = (base_gpio), ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ? ? ? }
>
> -static struct nuc900_gpio_chip nuc900_gpio[] = {
> - ? ? ? NUC900_GPIO_CHIP("GROUPC", 0, 16),
> - ? ? ? NUC900_GPIO_CHIP("GROUPD", 16, 10),
> - ? ? ? NUC900_GPIO_CHIP("GROUPE", 26, 14),
> - ? ? ? NUC900_GPIO_CHIP("GROUPF", 40, 10),
> - ? ? ? NUC900_GPIO_CHIP("GROUPG", 50, 17),
> - ? ? ? NUC900_GPIO_CHIP("GROUPH", 67, 8),
> - ? ? ? NUC900_GPIO_CHIP("GROUPI", 75, 17),
> +struct nuc900_gpio_bank {
> + ? ? ? unsigned int ? ? ? ? ? ?base;
> + ? ? ? unsigned int ? ? ? ? ? ?ngpio;
> ?};
>
> ?void __init nuc900_init_gpio(int nr_group)
> ?{
> ? ? ? ?unsigned ? ? ? ?i;
> - ? ? ? struct nuc900_gpio_chip *gpio_chip;
> +
> + ? ? ? struct nuc900_gpio_bank nuc900_gpio[] = {
> + ? ? ? ? ? ? ? NUC900_GPIO_BANK(0, 16),
> + ? ? ? ? ? ? ? NUC900_GPIO_BANK(16, 10),
> + ? ? ? ? ? ? ? NUC900_GPIO_BANK(26, 14),
> + ? ? ? ? ? ? ? NUC900_GPIO_BANK(40, 10),
> + ? ? ? ? ? ? ? NUC900_GPIO_BANK(50, 17),
> + ? ? ? ? ? ? ? NUC900_GPIO_BANK(67, 8),
> + ? ? ? ? ? ? ? NUC900_GPIO_BANK(75, 17),
> + ? ? ? };
>
> ? ? ? ?for (i = 0; i < nr_group; i++) {
> - ? ? ? ? ? ? ? gpio_chip = &nuc900_gpio[i];
> - ? ? ? ? ? ? ? spin_lock_init(&gpio_chip->gpio_lock);
> - ? ? ? ? ? ? ? gpio_chip->regbase = GPIO_BASE + i * GROUPINERV;
> - ? ? ? ? ? ? ? gpiochip_add(&gpio_chip->chip);
> + ? ? ? ? ? ? ? unsigned long addr = W90X900_PA_GPIO + i * GROUPINERV;
> + ? ? ? ? ? ? ? struct resource res[] = {
> + ? ? ? ? ? ? ? ? ? ? ? GPIO_RES(dat, addr + GPIO_IN),
> + ? ? ? ? ? ? ? ? ? ? ? GPIO_RES(set, addr + GPIO_OUT),
> + ? ? ? ? ? ? ? ? ? ? ? GPIO_RES(dirout, addr + GPIO_DIR),
> + ? ? ? ? ? ? ? };
> + ? ? ? ? ? ? ? struct bgpio_pdata pdata = {
> + ? ? ? ? ? ? ? ? ? ? ? .ngpio ?= nuc900_gpio[i].ngpio,
> + ? ? ? ? ? ? ? ? ? ? ? .base ? = nuc900_gpio[i].base,
> + ? ? ? ? ? ? ? };
> + ? ? ? ? ? ? ? struct platform_device *pdev;
> +
> + ? ? ? ? ? ? ? pdev = platform_device_register_resndata(NULL,
> + ? ? ? ? ? ? ? ? ? ? ? "basic-mmio-gpio", i, res, ARRAY_SIZE(res), &pdata,
> + ? ? ? ? ? ? ? ? ? ? ? sizeof(pdata));
> + ? ? ? ? ? ? ? WARN_ON(IS_ERR(pdev));
> ? ? ? ?}
> ?}
> --
> 1.7.4.2
>
>
--
*linux-arm-kernel mailing list
mail addr:linux-arm-kernel at lists.infradead.org
you can subscribe by:
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
* linux-arm-NUC900 mailing list
mail addr:NUC900 at googlegroups.com
main web: https://groups.google.com/group/NUC900
you can subscribe it by sending me mail:
mcuos.com at gmail.com
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 3/5] w90x900: convert to basic-mmio-gpio
2011-04-11 14:27 ` Wan ZongShun
@ 2011-06-10 12:50 ` Jamie Iles
0 siblings, 0 replies; 21+ messages in thread
From: Jamie Iles @ 2011-06-10 12:50 UTC (permalink / raw)
To: linux-arm-kernel
Hi Russell,
On Mon, Apr 11, 2011 at 10:27:56PM +0800, Wan ZongShun wrote:
> 2011/4/11 Jamie Iles <jamie@jamieiles.com>:
> > The basic-mmio-gpio driver is capable of supporting this controller so
> > convert the platform to use it for basic GPIO support.
> >
> > Cc: Wan ZongShun <mcuos.com@gmail.com>
> > Signed-off-by: Jamie Iles <jamie@jamieiles.com>
>
> Acked-by: Wan ZongShun <mcuos.com@gmail.com>
>
> Thanks, so you can submit it to Russell for merging.
All of the dependencies for this are now merged, is it okay to put this
one in the patch system?
Jamie
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 4/5] iop: convert to basic-mmio-gpio
2011-04-11 11:48 [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio Jamie Iles
` (2 preceding siblings ...)
2011-04-11 11:48 ` [RFC PATCH 3/5] w90x900: " Jamie Iles
@ 2011-04-11 11:48 ` Jamie Iles
2011-04-11 11:48 ` [RFC PATCH 5/5] mxc: " Jamie Iles
` (2 subsequent siblings)
6 siblings, 0 replies; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 11:48 UTC (permalink / raw)
To: linux-arm-kernel
The basic-mmio-gpio driver is capable of supporting this controller so
convert the platform to use it for basic GPIO support.
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
arch/arm/include/asm/hardware/iop3xx.h | 6 +-
arch/arm/mach-iop32x/include/mach/iop32x.h | 2 +-
arch/arm/mach-iop33x/include/mach/iop33x.h | 2 +-
arch/arm/plat-iop/gpio.c | 89 +++++++--------------------
4 files changed, 28 insertions(+), 71 deletions(-)
diff --git a/arch/arm/include/asm/hardware/iop3xx.h b/arch/arm/include/asm/hardware/iop3xx.h
index 5daea29..078c07a 100644
--- a/arch/arm/include/asm/hardware/iop3xx.h
+++ b/arch/arm/include/asm/hardware/iop3xx.h
@@ -169,9 +169,9 @@ extern int iop3xx_get_init_atu(void);
#define IOP3XX_PERCR0 (volatile u32 *)IOP3XX_REG_ADDR(0x0710)
/* General Purpose I/O */
-#define IOP3XX_GPOE (volatile u32 *)IOP3XX_GPIO_REG(0x0000)
-#define IOP3XX_GPID (volatile u32 *)IOP3XX_GPIO_REG(0x0004)
-#define IOP3XX_GPOD (volatile u32 *)IOP3XX_GPIO_REG(0x0008)
+#define IOP3XX_GPOE IOP3XX_GPIO_REG(0x0000)
+#define IOP3XX_GPID IOP3XX_GPIO_REG(0x0004)
+#define IOP3XX_GPOD IOP3XX_GPIO_REG(0x0008)
/* Timers */
#define IOP3XX_TU_TMR0 (volatile u32 *)IOP3XX_TIMER_REG(0x0000)
diff --git a/arch/arm/mach-iop32x/include/mach/iop32x.h b/arch/arm/mach-iop32x/include/mach/iop32x.h
index 941f363..880441b 100644
--- a/arch/arm/mach-iop32x/include/mach/iop32x.h
+++ b/arch/arm/mach-iop32x/include/mach/iop32x.h
@@ -19,7 +19,7 @@
* Peripherals that are shared between the iop32x and iop33x but
* located at different addresses.
*/
-#define IOP3XX_GPIO_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07c4 + (reg))
+#define IOP3XX_GPIO_REG(reg) (IOP3XX_PERIPHERAL_PHYS_BASE + 0x07c4 + (reg))
#define IOP3XX_TIMER_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07e0 + (reg))
#include <asm/hardware/iop3xx.h>
diff --git a/arch/arm/mach-iop33x/include/mach/iop33x.h b/arch/arm/mach-iop33x/include/mach/iop33x.h
index a89c0a2..acf8b23 100644
--- a/arch/arm/mach-iop33x/include/mach/iop33x.h
+++ b/arch/arm/mach-iop33x/include/mach/iop33x.h
@@ -18,7 +18,7 @@
* Peripherals that are shared between the iop32x and iop33x but
* located at different addresses.
*/
-#define IOP3XX_GPIO_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x1780 + (reg))
+#define IOP3XX_GPIO_REG(reg) (IOP3XX_PERIPHERAL_PHYS_BASE + 0x1780 + (reg))
#define IOP3XX_TIMER_REG(reg) (IOP3XX_PERIPHERAL_VIRT_BASE + 0x07d0 + (reg))
#include <asm/hardware/iop3xx.h>
diff --git a/arch/arm/plat-iop/gpio.c b/arch/arm/plat-iop/gpio.c
index 640e498..c4f7f24 100644
--- a/arch/arm/plat-iop/gpio.c
+++ b/arch/arm/plat-iop/gpio.c
@@ -10,82 +10,39 @@
* your option) any later version.
*/
+#include <linux/basic_mmio_gpio.h>
#include <linux/device.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/gpio.h>
+#include <linux/platform_device.h>
#include <asm/hardware/iop3xx.h>
-void gpio_line_config(int line, int direction)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- if (direction == GPIO_IN) {
- *IOP3XX_GPOE |= 1 << line;
- } else if (direction == GPIO_OUT) {
- *IOP3XX_GPOE &= ~(1 << line);
- }
- local_irq_restore(flags);
-}
-EXPORT_SYMBOL(gpio_line_config);
-
-int gpio_line_get(int line)
-{
- return !!(*IOP3XX_GPID & (1 << line));
-}
-EXPORT_SYMBOL(gpio_line_get);
-
-void gpio_line_set(int line, int value)
-{
- unsigned long flags;
-
- local_irq_save(flags);
- if (value == GPIO_LOW) {
- *IOP3XX_GPOD &= ~(1 << line);
- } else if (value == GPIO_HIGH) {
- *IOP3XX_GPOD |= 1 << line;
+#define GPIO_RES(__name, __addr) \
+ { \
+ .start = (__addr), \
+ .end = (__addr) + 0x3, \
+ .flags = IORESOURCE_MEM, \
+ .name = #__name, \
}
- local_irq_restore(flags);
-}
-EXPORT_SYMBOL(gpio_line_set);
-
-static int iop3xx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
-{
- gpio_line_config(gpio, GPIO_IN);
- return 0;
-}
-
-static int iop3xx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int level)
-{
- gpio_line_set(gpio, level);
- gpio_line_config(gpio, GPIO_OUT);
- return 0;
-}
-
-static int iop3xx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
-{
- return gpio_line_get(gpio);
-}
-
-static void iop3xx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
-{
- gpio_line_set(gpio, value);
-}
-
-static struct gpio_chip iop3xx_chip = {
- .label = "iop3xx",
- .direction_input = iop3xx_gpio_direction_input,
- .get = iop3xx_gpio_get_value,
- .direction_output = iop3xx_gpio_direction_output,
- .set = iop3xx_gpio_set_value,
- .base = 0,
- .ngpio = IOP3XX_N_GPIOS,
-};
static int __init iop3xx_gpio_setup(void)
{
- return gpiochip_add(&iop3xx_chip);
+ struct resource res[] = {
+ GPIO_RES(dat, IOP3XX_GPID),
+ GPIO_RES(set, IOP3XX_GPOD),
+ GPIO_RES(dirin, IOP3XX_GPOE),
+ };
+ struct bgpio_pdata pdata = {
+ .ngpio = IOP3XX_N_GPIOS,
+ };
+ struct platform_device *pdev;
+
+ pdev = platform_device_register_resndata(NULL, "basic-mmio-gpio", 0,
+ res, ARRAY_SIZE(res), &pdata,
+ sizeof(pdata));
+ return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
}
arch_initcall(iop3xx_gpio_setup);
--
1.7.4.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [RFC PATCH 5/5] mxc: convert to basic-mmio-gpio
2011-04-11 11:48 [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio Jamie Iles
` (3 preceding siblings ...)
2011-04-11 11:48 ` [RFC PATCH 4/5] iop: " Jamie Iles
@ 2011-04-11 11:48 ` Jamie Iles
2011-04-11 13:43 ` [RFC PATCH 0/5] Convert some ARM platforms " Uwe Kleine-König
2011-04-11 15:17 ` Linus Walleij
6 siblings, 0 replies; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 11:48 UTC (permalink / raw)
To: linux-arm-kernel
The basic-mmio-gpio driver is capable of supporting this controller so
convert the platform to use it for basic GPIO support.
Cc: Sascha Hauer <kernel@pengutronix.de>
Signed-off-by: Jamie Iles <jamie@jamieiles.com>
---
arch/arm/plat-mxc/gpio.c | 96 +++++++++-----------------------
arch/arm/plat-mxc/include/mach/gpio.h | 3 +-
2 files changed, 29 insertions(+), 70 deletions(-)
diff --git a/arch/arm/plat-mxc/gpio.c b/arch/arm/plat-mxc/gpio.c
index 7a10724..9c494b4 100644
--- a/arch/arm/plat-mxc/gpio.c
+++ b/arch/arm/plat-mxc/gpio.c
@@ -19,11 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include <linux/basic_mmio_gpio.h>
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/gpio.h>
+#include <linux/platform_device.h>
#include <mach/hardware.h>
#include <asm-generic/bug.h>
@@ -40,6 +43,14 @@ static int gpio_table_size;
#define GPIO_IMR (cpu_is_mx1_mx2() ? 0x30 : 0x14)
#define GPIO_ISR (cpu_is_mx1_mx2() ? 0x34 : 0x18)
+#define GPIO_RES(__name, __addr) \
+ { \
+ .start = (__addr), \
+ .end = (__addr) + 0x3, \
+ .flags = IORESOURCE_MEM, \
+ .name = #__name, \
+ }
+
#define GPIO_INT_LOW_LEV (cpu_is_mx1_mx2() ? 0x3 : 0x0)
#define GPIO_INT_HIGH_LEV (cpu_is_mx1_mx2() ? 0x2 : 0x1)
#define GPIO_INT_RISE_EDGE (cpu_is_mx1_mx2() ? 0x0 : 0x2)
@@ -81,8 +92,6 @@ static void gpio_unmask_irq(struct irq_data *d)
_set_gpio_irqenable(&mxc_gpio_ports[gpio / 32], gpio & 0x1f, 1);
}
-static int mxc_gpio_get(struct gpio_chip *chip, unsigned offset);
-
static int gpio_set_irq_type(struct irq_data *d, u32 type)
{
u32 gpio = irq_to_gpio(d->irq);
@@ -100,7 +109,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type)
edge = GPIO_INT_FALL_EDGE;
break;
case IRQ_TYPE_EDGE_BOTH:
- val = mxc_gpio_get(&port->chip, gpio & 31);
+ val = gpio_get_value(gpio);
if (val) {
edge = GPIO_INT_LOW_LEV;
pr_debug("mxc: set GPIO %d to low trigger\n", gpio);
@@ -241,60 +250,6 @@ static struct irq_chip gpio_irq_chip = {
.irq_set_wake = gpio_set_wake_irq,
};
-static void _set_gpio_direction(struct gpio_chip *chip, unsigned offset,
- int dir)
-{
- struct mxc_gpio_port *port =
- container_of(chip, struct mxc_gpio_port, chip);
- u32 l;
- unsigned long flags;
-
- spin_lock_irqsave(&port->lock, flags);
- l = __raw_readl(port->base + GPIO_GDIR);
- if (dir)
- l |= 1 << offset;
- else
- l &= ~(1 << offset);
- __raw_writel(l, port->base + GPIO_GDIR);
- spin_unlock_irqrestore(&port->lock, flags);
-}
-
-static void mxc_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
-{
- struct mxc_gpio_port *port =
- container_of(chip, struct mxc_gpio_port, chip);
- void __iomem *reg = port->base + GPIO_DR;
- u32 l;
- unsigned long flags;
-
- spin_lock_irqsave(&port->lock, flags);
- l = (__raw_readl(reg) & (~(1 << offset))) | (!!value << offset);
- __raw_writel(l, reg);
- spin_unlock_irqrestore(&port->lock, flags);
-}
-
-static int mxc_gpio_get(struct gpio_chip *chip, unsigned offset)
-{
- struct mxc_gpio_port *port =
- container_of(chip, struct mxc_gpio_port, chip);
-
- return (__raw_readl(port->base + GPIO_PSR) >> offset) & 1;
-}
-
-static int mxc_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
-{
- _set_gpio_direction(chip, offset, 0);
- return 0;
-}
-
-static int mxc_gpio_direction_output(struct gpio_chip *chip,
- unsigned offset, int value)
-{
- mxc_gpio_set(chip, offset, value);
- _set_gpio_direction(chip, offset, 1);
- return 0;
-}
-
int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)
{
int i, j;
@@ -306,6 +261,17 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)
printk(KERN_INFO "MXC GPIO hardware\n");
for (i = 0; i < cnt; i++) {
+ struct resource res[] = {
+ GPIO_RES(set, port[i].base_phys + GPIO_DR),
+ GPIO_RES(dat, port[i].base_phys + GPIO_PSR),
+ GPIO_RES(dirout, port[i].base_phys + GPIO_GDIR),
+ };
+ struct bgpio_pdata pdata = {
+ .base = i * 32,
+ .ngpio = 32,
+ };
+ struct platform_device *pdev;
+
/* disable the interrupt and clear the status */
__raw_writel(0, port[i].base + GPIO_IMR);
__raw_writel(~0, port[i].base + GPIO_ISR);
@@ -316,18 +282,10 @@ int __init mxc_gpio_init(struct mxc_gpio_port *port, int cnt)
set_irq_flags(j, IRQF_VALID);
}
- /* register gpio chip */
- port[i].chip.direction_input = mxc_gpio_direction_input;
- port[i].chip.direction_output = mxc_gpio_direction_output;
- port[i].chip.get = mxc_gpio_get;
- port[i].chip.set = mxc_gpio_set;
- port[i].chip.base = i * 32;
- port[i].chip.ngpio = 32;
-
- spin_lock_init(&port[i].lock);
-
- /* its a serious configuration bug when it fails */
- BUG_ON( gpiochip_add(&port[i].chip) < 0 );
+ pdev = platform_device_register_resndata(NULL,
+ "basic-mmio-gpio", i, res, ARRAY_SIZE(res), &pdata,
+ sizeof(pdata));
+ BUG_ON(IS_ERR(pdev));
if (cpu_is_mx1() || cpu_is_mx3() || cpu_is_mx25() || cpu_is_mx51()) {
/* setup one handler for each entry */
diff --git a/arch/arm/plat-mxc/include/mach/gpio.h b/arch/arm/plat-mxc/include/mach/gpio.h
index a2747f1..ba46be9 100644
--- a/arch/arm/plat-mxc/include/mach/gpio.h
+++ b/arch/arm/plat-mxc/include/mach/gpio.h
@@ -38,12 +38,12 @@
struct mxc_gpio_port {
void __iomem *base;
+ unsigned long base_phys;
int irq;
int irq_high;
int virtual_irq_start;
struct gpio_chip chip;
u32 both_edges;
- spinlock_t lock;
};
#define DEFINE_IMX_GPIO_PORT_IRQ_HIGH(soc, _id, _hwid, _irq, _irq_high) \
@@ -53,6 +53,7 @@ struct mxc_gpio_port {
.irq_high = _irq_high, \
.base = soc ## _IO_ADDRESS( \
soc ## _GPIO ## _hwid ## _BASE_ADDR), \
+ .base_phys = soc ## _GPIO ## _hwid ## _BASE_ADDR, \
.virtual_irq_start = MXC_GPIO_IRQ_START + (_id) * 32, \
}
--
1.7.4.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 11:48 [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio Jamie Iles
` (4 preceding siblings ...)
2011-04-11 11:48 ` [RFC PATCH 5/5] mxc: " Jamie Iles
@ 2011-04-11 13:43 ` Uwe Kleine-König
2011-04-11 13:52 ` Jamie Iles
2011-04-11 15:17 ` Linus Walleij
6 siblings, 1 reply; 21+ messages in thread
From: Uwe Kleine-König @ 2011-04-11 13:43 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Apr 11, 2011 at 12:48:17PM +0100, Jamie Iles wrote:
> The basic-mmio-gpio driver has been extended in
> <http://marc.info/?l=linux-kernel&m=130252092900804&w=2> to support a
> larger wider of controllers and this series converts the ARM platforms
> that do not implement I/O muxing in the GPIO driver or use the .to_irq
> method of gpio_chip to use the driver.
As these patches are necessary to test at least the mxc patch but they
are not present in todays next and I don't want to spend the time to
find the patches on marc.info (the "next in thread" link is greyed out)
and it's non-trivial to get patches from marc into git (
wget -O - 'http://marc.info/?l=linux-kernel&m=130252092900807&q=raw' | git am
fails with "Patch does not have a valid e-mail address." because the raw
view doesn't provide the From: header (Subject: is missing, too)) can
you please point out a repository that has all 12 patches?
Did you (or someone else) measure the performance difference these
patches introduce?
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 13:43 ` [RFC PATCH 0/5] Convert some ARM platforms " Uwe Kleine-König
@ 2011-04-11 13:52 ` Jamie Iles
2011-04-11 14:23 ` Uwe Kleine-König
0 siblings, 1 reply; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 13:52 UTC (permalink / raw)
To: linux-arm-kernel
Hi Uwe,
On Mon, Apr 11, 2011 at 03:43:20PM +0200, Uwe Kleine-K?nig wrote:
> On Mon, Apr 11, 2011 at 12:48:17PM +0100, Jamie Iles wrote:
> > The basic-mmio-gpio driver has been extended in
> > <http://marc.info/?l=linux-kernel&m=130252092900804&w=2> to support a
> > larger wider of controllers and this series converts the ARM platforms
> > that do not implement I/O muxing in the GPIO driver or use the .to_irq
> > method of gpio_chip to use the driver.
> As these patches are necessary to test at least the mxc patch but they
> are not present in todays next and I don't want to spend the time to
> find the patches on marc.info (the "next in thread" link is greyed out)
> and it's non-trivial to get patches from marc into git (
> wget -O - 'http://marc.info/?l=linux-kernel&m=130252092900807&q=raw' | git am
> fails with "Patch does not have a valid e-mail address." because the raw
> view doesn't provide the From: header (Subject: is missing, too)) can
> you please point out a repository that has all 12 patches?
Sure, they're all in:
git://github.com/jamieiles/linux-2.6-ji.git gpio
There's one extra slightly unrelated fix for gemini in there too.
> Did you (or someone else) measure the performance difference these
> patches introduce?
No, I haven't done any performance measurement, though from inspection I
don't think that I would expect any real measurable difference.
Jamie
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 13:52 ` Jamie Iles
@ 2011-04-11 14:23 ` Uwe Kleine-König
2011-04-11 14:33 ` Jamie Iles
0 siblings, 1 reply; 21+ messages in thread
From: Uwe Kleine-König @ 2011-04-11 14:23 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Apr 11, 2011 at 02:52:16PM +0100, Jamie Iles wrote:
> Hi Uwe,
>
> On Mon, Apr 11, 2011 at 03:43:20PM +0200, Uwe Kleine-K?nig wrote:
> > On Mon, Apr 11, 2011 at 12:48:17PM +0100, Jamie Iles wrote:
> > > The basic-mmio-gpio driver has been extended in
> > > <http://marc.info/?l=linux-kernel&m=130252092900804&w=2> to support a
> > > larger wider of controllers and this series converts the ARM platforms
> > > that do not implement I/O muxing in the GPIO driver or use the .to_irq
> > > method of gpio_chip to use the driver.
> > As these patches are necessary to test at least the mxc patch but they
> > are not present in todays next and I don't want to spend the time to
> > find the patches on marc.info (the "next in thread" link is greyed out)
> > and it's non-trivial to get patches from marc into git (
> > wget -O - 'http://marc.info/?l=linux-kernel&m=130252092900807&q=raw' | git am
> > fails with "Patch does not have a valid e-mail address." because the raw
> > view doesn't provide the From: header (Subject: is missing, too)) can
> > you please point out a repository that has all 12 patches?
>
> Sure, they're all in:
>
> git://github.com/jamieiles/linux-2.6-ji.git gpio
>
> There's one extra slightly unrelated fix for gemini in there too.
Thanks, compiles fine for a i.MX35 machine here, but fails to boot:
<6>[ 0.000000] MXC GPIO hardware
<4>[ 0.000000] ------------[ cut here ]------------
<4>[ 0.000000] WARNING: at lib/kref.c:34 kref_get+0x2c/0x48()
<4>[ 0.000000] Modules linked in:
<4>[ 0.000000] Backtrace:
<4>[ 0.000000] [<c0039f9c>] (dump_backtrace+0x0/0x110) from [<c02bff9c>] (dump_stack+0x1c/0x20)
<4>[ 0.000000] r7:00000000 r6:c01c1ed0 r5:c0367fd4 r4:00000022
<4>[ 0.000000] [<c02bff80>] (dump_stack+0x0/0x20) from [<c004b95c>] (warn_slowpath_common+0x5c/0x74)
<4>[ 0.000000] [<c004b900>] (warn_slowpath_common+0x0/0x74) from [<c004b99c>] (warn_slowpath_null+0x28/0x30)
<4>[ 0.000000] r8:00000000 r7:00000000 r6:00000003 r5:c7803008 r4:c03bce7c
<4>[ 0.000000] [<c004b974>] (warn_slowpath_null+0x0/0x30) from [<c01c1ed0>] (kref_get+0x2c/0x48)
<4>[ 0.000000] [<c01c1ea4>] (kref_get+0x0/0x48) from [<c01c0df0>] (kobject_get+0x20/0x28)
<4>[ 0.000000] r4:c03bce60
<4>[ 0.000000] [<c01c0dd0>] (kobject_get+0x0/0x28) from [<c02017e4>] (get_device+0x20/0x28)
<4>[ 0.000000] r4:c7803000
<4>[ 0.000000] [<c02017c4>] (get_device+0x0/0x28) from [<c0202b24>] (device_add+0x80/0x5c8)
<4>[ 0.000000] [<c0202aa4>] (device_add+0x0/0x5c8) from [<c0206d50>] (platform_device_add+0x110/0x16c)
<4>[ 0.000000] [<c0206c40>] (platform_device_add+0x0/0x16c) from [<c0207064>] (platform_device_register_resndata+0x90/0xb8)
<4>[ 0.000000] r7:00000000 r6:c0395f1c r5:c7803000 r4:00000000
<4>[ 0.000000] [<c0206fd4>] (platform_device_register_resndata+0x0/0xb8) from [<c000cb34>] (mxc_gpio_init+0x134/0x1f0)
<4>[ 0.000000] r8:c039a82c r7:f57cc000 r6:53fcc007 r5:00000000 r4:00000060
<4>[ 0.000000] [<c000ca00>] (mxc_gpio_init+0x0/0x1f0) from [<c000c3dc>] (mx35_init_irq+0x20/0x2c)
<4>[ 0.000000] [<c000c3bc>] (mx35_init_irq+0x0/0x2c) from [<c00096bc>] (init_IRQ+0x1c/0x24)
<4>[ 0.000000] [<c00096a0>] (init_IRQ+0x0/0x24) from [<c0008970>] (start_kernel+0x184/0x2b4)
<4>[ 0.000000] [<c00087ec>] (start_kernel+0x0/0x2b4) from [<8000803c>] (0x8000803c)
<4>[ 0.000000] r7:c0399cb8 r6:c0021e70 r5:c0396054 r4:00c5387d
<4>[ 0.000000] ---[ end trace 1b75b31a2719ed1c ]---
<1>[ 0.000000] Unable to handle kernel NULL pointer dereference at virtual address 00000031
<1>[ 0.000000] pgd = c0004000
<1>[ 0.000000] [00000031] *pgd=00000000
<0>[ 0.000000] Internal error: Oops: 5 [#1] PREEMPT
<0>[ 0.000000] last sysfs file:
<4>[ 0.000000] Modules linked in:
<4>[ 0.000000] CPU: 0 Tainted: G W (2.6.39-rc2-00013-gdc29556-dirty #59)
<4>[ 0.000000] PC is at sysfs_create_dir+0x34/0xf8
<4>[ 0.000000] LR is at kobject_add_internal+0xdc/0x1b0
<4>[ 0.000000] pc : [<c012d534>] lr : [<c01c0fc0>] psr: a00001d3
<4>[ 0.000000] sp : c0395dd8 ip : c0395e08 fp : c0395e04
<4>[ 0.000000] r10: c7803010 r9 : 00000003 r8 : c03bce60
<4>[ 0.000000] r7 : 00000000 r6 : 00000000 r5 : c7803010 r4 : c7803010
<4>[ 0.000000] r3 : c7805200 r2 : 00000002 r1 : c03bce60 r0 : c7803010
<4>[ 0.000000] Flags: NzCv IRQs off FIQs off Mode SVC_32 ISA ARM Segment kernel
<4>[ 0.000000] Control: 00c5387f Table: 80004008 DAC: 00000017
<0>[ 0.000000] Process swapper (pid: 0, stack limit = 0xc0394268)
<0>[ 0.000000] Stack: (0xc0395dd8 to 0xc0396000)
<0>[ 0.000000] 5dc0: c0395e0c c03bce60
<0>[ 0.000000] 5de0: c0395e04 c0395df0 c7803010 00000000 c03bce60 00000000 c0395e2c c0395e08
<0>[ 0.000000] 5e00: c01c0fc0 c012d50c c004b99c c7803010 00000000 c03bce60 00000000 00000000
<0>[ 0.000000] 5e20: c0395e4c c0395e30 c01c1198 c01c0ef0 c0395e54 c7803000 c7803008 00000003
<0>[ 0.000000] 5e40: c0395e5c c0395e50 c01c1230 c01c1160 c0395eac c0395e68 c0202b50 c01c11f4
<0>[ 0.000000] 5e60: 00000000 00000000 c03bce58 00000000 c0395e9c c0395e80 c00532bc c02c3200
<0>[ 0.000000] 5e80: c0395ea0 c7803000 00000054 00000003 00000000 c0395f70 00000003 00000000
<0>[ 0.000000] 5ea0: c0395ecc c0395eb0 c0206d50 c0202ab0 00000000 c7803000 c0395f1c 00000000
<0>[ 0.000000] 5ec0: c0395f04 c0395ed0 c0207064 c0206c4c 00000000 c0395f1c c0395f70 600001d3
<0>[ 0.000000] 5ee0: 0000005f 00000060 00000000 53fcc007 f57cc000 c039a82c c0395fa4 c0395f08
<0>[ 0.000000] 5f00: c000cb34 c0206fe0 00000003 c0395f70 00000008 c0390020 c007b2b8 53fcc000
<0>[ 0.000000] 5f20: 53fcc003 c0368645 00000200 00000000 00000000 00000000 53fcc008 53fcc00b
<0>[ 0.000000] 5f40: c034b35b 00000200 00000000 00000000 00000000 53fcc004 53fcc007 c034b35f
<0>[ 0.000000] 5f60: 00000200 00000000 00000000 00000000 00000000 00000020 c000cee0 bfffffff
<0>[ 0.000000] 5f80: c03c720c c0021a6c c03c7200 80000000 4117b363 8002011c c0395fb4 c0395fa8
<0>[ 0.000000] 5fa0: c000c3dc c000ca0c c0395fc4 c0395fb8 c00096bc c000c3c8 c0395ff4 c0395fc8
<0>[ 0.000000] 5fc0: c0008970 c00096ac c0008554 00000000 00000000 c0021a6c 00c5387d c0396054
<0>[ 0.000000] 5fe0: c0021e70 c0399cb8 00000000 c0395ff8 8000803c c00087f8 00000000 00000000
<4>[ 0.000000] Backtrace:
<4>[ 0.000000] [<c012d500>] (sysfs_create_dir+0x0/0xf8) from [<c01c0fc0>] (kobject_add_internal+0xdc/0x1b0)
<4>[ 0.000000] r7:00000000 r6:c03bce60 r5:00000000 r4:c7803010
<4>[ 0.000000] [<c01c0ee4>] (kobject_add_internal+0x0/0x1b0) from [<c01c1198>] (kobject_add_varg+0x44/0x54)
<4>[ 0.000000] r8:00000000 r7:00000000 r6:c03bce60 r5:00000000 r4:c7803010
<4>[ 0.000000] [<c01c1154>] (kobject_add_varg+0x0/0x54) from [<c01c1230>] (kobject_add+0x4c/0x58)
<4>[ 0.000000] r6:00000003 r5:c7803008 r4:c7803000
<4>[ 0.000000] [<c01c11e4>] (kobject_add+0x0/0x58) from [<c0202b50>] (device_add+0xac/0x5c8)
<4>[ 0.000000] r3:00000000 r2:00000000
<4>[ 0.000000] [<c0202aa4>] (device_add+0x0/0x5c8) from [<c0206d50>] (platform_device_add+0x110/0x16c)
<4>[ 0.000000] [<c0206c40>] (platform_device_add+0x0/0x16c) from [<c0207064>] (platform_device_register_resndata+0x90/0xb8)
<4>[ 0.000000] r7:00000000 r6:c0395f1c r5:c7803000 r4:00000000
<4>[ 0.000000] [<c0206fd4>] (platform_device_register_resndata+0x0/0xb8) from [<c000cb34>] (mxc_gpio_init+0x134/0x1f0)
<4>[ 0.000000] r8:c039a82c r7:f57cc000 r6:53fcc007 r5:00000000 r4:00000060
<4>[ 0.000000] [<c000ca00>] (mxc_gpio_init+0x0/0x1f0) from [<c000c3dc>] (mx35_init_irq+0x20/0x2c)
<4>[ 0.000000] [<c000c3bc>] (mx35_init_irq+0x0/0x2c) from [<c00096bc>] (init_IRQ+0x1c/0x24)
<4>[ 0.000000] [<c00096a0>] (init_IRQ+0x0/0x24) from [<c0008970>] (start_kernel+0x184/0x2b4)
<4>[ 0.000000] [<c00087ec>] (start_kernel+0x0/0x2b4) from [<8000803c>] (0x8000803c)
<4>[ 0.000000] r7:c0399cb8 r6:c0021e70 r5:c0396054 r4:00c5387d
<0>[ 0.000000] Code: e595100c e3510000 059f60b8 15916018 (e5d60031)
<4>[ 0.000000] ---[ end trace 1b75b31a2719ed1d ]---
<0>[ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task!
<4>[ 0.000000] Backtrace:
<4>[ 0.000000] [<c0039f9c>] (dump_backtrace+0x0/0x110) from [<c02bff9c>] (dump_stack+0x1c/0x20)
<4>[ 0.000000] r7:c0395d90 r6:c03985e8 r5:c0394000 r4:c03c75ac
<4>[ 0.000000] [<c02bff80>] (dump_stack+0x0/0x20) from [<c02c000c>] (panic+0x6c/0x19c)
<4>[ 0.000000] [<c02bffa0>] (panic+0x0/0x19c) from [<c004f56c>] (do_exit+0xa4/0x6c4)
<4>[ 0.000000] r3:00000000 r2:00000000 r1:c0394000 r0:c034c3cc
<4>[ 0.000000] [<c004f4c8>] (do_exit+0x0/0x6c4) from [<c003a540>] (die+0x198/0x1cc)
<4>[ 0.000000] [<c003a3a8>] (die+0x0/0x1cc) from [<c003c6c4>] (__do_kernel_fault+0x74/0x94)
<4>[ 0.000000] [<c003c650>] (__do_kernel_fault+0x0/0x94) from [<c003c8a8>] (do_page_fault+0x1c4/0x1dc)
<4>[ 0.000000] r8:00000031 r7:00000031 r6:c03985e8 r5:00000000 r4:c039a434
<4>[ 0.000000] [<c003c6e4>] (do_page_fault+0x0/0x1dc) from [<c003c95c>] (do_translation_fault+0x28/0xb4)
<4>[ 0.000000] [<c003c934>] (do_translation_fault+0x0/0xb4) from [<c0031264>] (do_DataAbort+0x40/0xa0)
<4>[ 0.000000] r7:c0395d90 r6:00000005 r5:c0395dc4 r4:c039a434
<4>[ 0.000000] [<c0031224>] (do_DataAbort+0x0/0xa0) from [<c003696c>] (__dabt_svc+0x4c/0x80)
<4>[ 0.000000] Exception stack(0xc0395d90 to 0xc0395dd8)
<4>[ 0.000000] 5d80: c7803010 c03bce60 00000002 c7805200
<4>[ 0.000000] 5da0: c7803010 c7803010 00000000 00000000 c03bce60 00000003 c7803010 c0395e04
<4>[ 0.000000] 5dc0: c0395e08 c0395dd8 c01c0fc0 c012d534 a00001d3 ffffffff
<4>[ 0.000000] r8:c03bce60 r7:00000000 r6:00000000 r5:c0395dc4 r4:ffffffff
<4>[ 0.000000] [<c012d500>] (sysfs_create_dir+0x0/0xf8) from [<c01c0fc0>] (kobject_add_internal+0xdc/0x1b0)
<4>[ 0.000000] r7:00000000 r6:c03bce60 r5:00000000 r4:c7803010
<4>[ 0.000000] [<c01c0ee4>] (kobject_add_internal+0x0/0x1b0) from [<c01c1198>] (kobject_add_varg+0x44/0x54)
<4>[ 0.000000] r8:00000000 r7:00000000 r6:c03bce60 r5:00000000 r4:c7803010
<4>[ 0.000000] [<c01c1154>] (kobject_add_varg+0x0/0x54) from [<c01c1230>] (kobject_add+0x4c/0x58)
<4>[ 0.000000] r6:00000003 r5:c7803008 r4:c7803000
<4>[ 0.000000] [<c01c11e4>] (kobject_add+0x0/0x58) from [<c0202b50>] (device_add+0xac/0x5c8)
<4>[ 0.000000] r3:00000000 r2:00000000
<4>[ 0.000000] [<c0202aa4>] (device_add+0x0/0x5c8) from [<c0206d50>] (platform_device_add+0x110/0x16c)
<4>[ 0.000000] [<c0206c40>] (platform_device_add+0x0/0x16c) from [<c0207064>] (platform_device_register_resndata+0x90/0xb8)
<4>[ 0.000000] r7:00000000 r6:c0395f1c r5:c7803000 r4:00000000
<4>[ 0.000000] [<c0206fd4>] (platform_device_register_resndata+0x0/0xb8) from [<c000cb34>] (mxc_gpio_init+0x134/0x1f0)
<4>[ 0.000000] r8:c039a82c r7:f57cc000 r6:53fcc007 r5:00000000 r4:00000060
<4>[ 0.000000] [<c000ca00>] (mxc_gpio_init+0x0/0x1f0) from [<c000c3dc>] (mx35_init_irq+0x20/0x2c)
<4>[ 0.000000] [<c000c3bc>] (mx35_init_irq+0x0/0x2c) from [<c00096bc>] (init_IRQ+0x1c/0x24)
<4>[ 0.000000] [<c00096a0>] (init_IRQ+0x0/0x24) from [<c0008970>] (start_kernel+0x184/0x2b4)
<4>[ 0.000000] [<c00087ec>] (start_kernel+0x0/0x2b4) from [<8000803c>] (0x8000803c)
<4>[ 0.000000] r7:c0399cb8 r6:c0021e70 r5:c0396054 r4:00c5387d
Booting a .39-rc2 works just fine.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 14:23 ` Uwe Kleine-König
@ 2011-04-11 14:33 ` Jamie Iles
2011-04-11 14:49 ` Uwe Kleine-König
0 siblings, 1 reply; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 14:33 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Apr 11, 2011 at 04:23:07PM +0200, Uwe Kleine-K?nig wrote:
> On Mon, Apr 11, 2011 at 02:52:16PM +0100, Jamie Iles wrote:
> > Hi Uwe,
> >
> > On Mon, Apr 11, 2011 at 03:43:20PM +0200, Uwe Kleine-K?nig wrote:
> > > On Mon, Apr 11, 2011 at 12:48:17PM +0100, Jamie Iles wrote:
> > > > The basic-mmio-gpio driver has been extended in
> > > > <http://marc.info/?l=linux-kernel&m=130252092900804&w=2> to support a
> > > > larger wider of controllers and this series converts the ARM platforms
> > > > that do not implement I/O muxing in the GPIO driver or use the .to_irq
> > > > method of gpio_chip to use the driver.
> > > As these patches are necessary to test at least the mxc patch but they
> > > are not present in todays next and I don't want to spend the time to
> > > find the patches on marc.info (the "next in thread" link is greyed out)
> > > and it's non-trivial to get patches from marc into git (
> > > wget -O - 'http://marc.info/?l=linux-kernel&m=130252092900807&q=raw' | git am
> > > fails with "Patch does not have a valid e-mail address." because the raw
> > > view doesn't provide the From: header (Subject: is missing, too)) can
> > > you please point out a repository that has all 12 patches?
> >
> > Sure, they're all in:
> >
> > git://github.com/jamieiles/linux-2.6-ji.git gpio
> >
> > There's one extra slightly unrelated fix for gemini in there too.
> Thanks, compiles fine for a i.MX35 machine here, but fails to boot:
>
> <6>[ 0.000000] MXC GPIO hardware
> <4>[ 0.000000] ------------[ cut here ]------------
> <4>[ 0.000000] WARNING: at lib/kref.c:34 kref_get+0x2c/0x48()
> <4>[ 0.000000] Modules linked in:
> <4>[ 0.000000] Backtrace:
> <4>[ 0.000000] [<c0039f9c>] (dump_backtrace+0x0/0x110) from [<c02bff9c>] (dump_stack+0x1c/0x20)
> <4>[ 0.000000] r7:00000000 r6:c01c1ed0 r5:c0367fd4 r4:00000022
> <4>[ 0.000000] [<c02bff80>] (dump_stack+0x0/0x20) from [<c004b95c>] (warn_slowpath_common+0x5c/0x74)
> <4>[ 0.000000] [<c004b900>] (warn_slowpath_common+0x0/0x74) from [<c004b99c>] (warn_slowpath_null+0x28/0x30)
> <4>[ 0.000000] r8:00000000 r7:00000000 r6:00000003 r5:c7803008 r4:c03bce7c
> <4>[ 0.000000] [<c004b974>] (warn_slowpath_null+0x0/0x30) from [<c01c1ed0>] (kref_get+0x2c/0x48)
> <4>[ 0.000000] [<c01c1ea4>] (kref_get+0x0/0x48) from [<c01c0df0>] (kobject_get+0x20/0x28)
> <4>[ 0.000000] r4:c03bce60
> <4>[ 0.000000] [<c01c0dd0>] (kobject_get+0x0/0x28) from [<c02017e4>] (get_device+0x20/0x28)
> <4>[ 0.000000] r4:c7803000
> <4>[ 0.000000] [<c02017c4>] (get_device+0x0/0x28) from [<c0202b24>] (device_add+0x80/0x5c8)
> <4>[ 0.000000] [<c0202aa4>] (device_add+0x0/0x5c8) from [<c0206d50>] (platform_device_add+0x110/0x16c)
> <4>[ 0.000000] [<c0206c40>] (platform_device_add+0x0/0x16c) from [<c0207064>] (platform_device_register_resndata+0x90/0xb8)
> <4>[ 0.000000] r7:00000000 r6:c0395f1c r5:c7803000 r4:00000000
> <4>[ 0.000000] [<c0206fd4>] (platform_device_register_resndata+0x0/0xb8) from [<c000cb34>] (mxc_gpio_init+0x134/0x1f0)
> <4>[ 0.000000] r8:c039a82c r7:f57cc000 r6:53fcc007 r5:00000000 r4:00000060
> <4>[ 0.000000] [<c000ca00>] (mxc_gpio_init+0x0/0x1f0) from [<c000c3dc>] (mx35_init_irq+0x20/0x2c)
> <4>[ 0.000000] [<c000c3bc>] (mx35_init_irq+0x0/0x2c) from [<c00096bc>] (init_IRQ+0x1c/0x24)
> <4>[ 0.000000] [<c00096a0>] (init_IRQ+0x0/0x24) from [<c0008970>] (start_kernel+0x184/0x2b4)
Hmm, so this looks like it's because mxc_gpio_init() is being called
from init_IRQ which is too early for platform devices. Is there a
suitable place where this can be called later in the boot process? I
guess the gpio irq stuff should remain where it is but the
platform_device registration should be moved to later.
Jamie
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 14:33 ` Jamie Iles
@ 2011-04-11 14:49 ` Uwe Kleine-König
2011-04-11 15:13 ` Jamie Iles
2011-04-12 15:06 ` Anton Vorontsov
0 siblings, 2 replies; 21+ messages in thread
From: Uwe Kleine-König @ 2011-04-11 14:49 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
On Mon, Apr 11, 2011 at 03:33:27PM +0100, Jamie Iles wrote:
> On Mon, Apr 11, 2011 at 04:23:07PM +0200, Uwe Kleine-K?nig wrote:
> > On Mon, Apr 11, 2011 at 02:52:16PM +0100, Jamie Iles wrote:
> > > On Mon, Apr 11, 2011 at 03:43:20PM +0200, Uwe Kleine-K?nig wrote:
> > > > On Mon, Apr 11, 2011 at 12:48:17PM +0100, Jamie Iles wrote:
> > > > > The basic-mmio-gpio driver has been extended in
> > > > > <http://marc.info/?l=linux-kernel&m=130252092900804&w=2> to support a
> > > > > larger wider of controllers and this series converts the ARM platforms
> > > > > that do not implement I/O muxing in the GPIO driver or use the .to_irq
> > > > > method of gpio_chip to use the driver.
> > > > As these patches are necessary to test at least the mxc patch but they
> > > > are not present in todays next and I don't want to spend the time to
> > > > find the patches on marc.info (the "next in thread" link is greyed out)
> > > > and it's non-trivial to get patches from marc into git (
> > > > wget -O - 'http://marc.info/?l=linux-kernel&m=130252092900807&q=raw' | git am
> > > > fails with "Patch does not have a valid e-mail address." because the raw
> > > > view doesn't provide the From: header (Subject: is missing, too)) can
> > > > you please point out a repository that has all 12 patches?
> > >
> > > Sure, they're all in:
> > >
> > > git://github.com/jamieiles/linux-2.6-ji.git gpio
> > >
> > > There's one extra slightly unrelated fix for gemini in there too.
> > Thanks, compiles fine for a i.MX35 machine here, but fails to boot:
> >
> > <6>[ 0.000000] MXC GPIO hardware
> > <4>[ 0.000000] ------------[ cut here ]------------
> > <4>[ 0.000000] WARNING: at lib/kref.c:34 kref_get+0x2c/0x48()
> > <4>[ 0.000000] Modules linked in:
> > <4>[ 0.000000] Backtrace:
> > <4>[ 0.000000] [<c0039f9c>] (dump_backtrace+0x0/0x110) from [<c02bff9c>] (dump_stack+0x1c/0x20)
> > <4>[ 0.000000] r7:00000000 r6:c01c1ed0 r5:c0367fd4 r4:00000022
> > <4>[ 0.000000] [<c02bff80>] (dump_stack+0x0/0x20) from [<c004b95c>] (warn_slowpath_common+0x5c/0x74)
> > <4>[ 0.000000] [<c004b900>] (warn_slowpath_common+0x0/0x74) from [<c004b99c>] (warn_slowpath_null+0x28/0x30)
> > <4>[ 0.000000] r8:00000000 r7:00000000 r6:00000003 r5:c7803008 r4:c03bce7c
> > <4>[ 0.000000] [<c004b974>] (warn_slowpath_null+0x0/0x30) from [<c01c1ed0>] (kref_get+0x2c/0x48)
> > <4>[ 0.000000] [<c01c1ea4>] (kref_get+0x0/0x48) from [<c01c0df0>] (kobject_get+0x20/0x28)
> > <4>[ 0.000000] r4:c03bce60
> > <4>[ 0.000000] [<c01c0dd0>] (kobject_get+0x0/0x28) from [<c02017e4>] (get_device+0x20/0x28)
> > <4>[ 0.000000] r4:c7803000
> > <4>[ 0.000000] [<c02017c4>] (get_device+0x0/0x28) from [<c0202b24>] (device_add+0x80/0x5c8)
> > <4>[ 0.000000] [<c0202aa4>] (device_add+0x0/0x5c8) from [<c0206d50>] (platform_device_add+0x110/0x16c)
> > <4>[ 0.000000] [<c0206c40>] (platform_device_add+0x0/0x16c) from [<c0207064>] (platform_device_register_resndata+0x90/0xb8)
> > <4>[ 0.000000] r7:00000000 r6:c0395f1c r5:c7803000 r4:00000000
> > <4>[ 0.000000] [<c0206fd4>] (platform_device_register_resndata+0x0/0xb8) from [<c000cb34>] (mxc_gpio_init+0x134/0x1f0)
> > <4>[ 0.000000] r8:c039a82c r7:f57cc000 r6:53fcc007 r5:00000000 r4:00000060
> > <4>[ 0.000000] [<c000ca00>] (mxc_gpio_init+0x0/0x1f0) from [<c000c3dc>] (mx35_init_irq+0x20/0x2c)
> > <4>[ 0.000000] [<c000c3bc>] (mx35_init_irq+0x0/0x2c) from [<c00096bc>] (init_IRQ+0x1c/0x24)
> > <4>[ 0.000000] [<c00096a0>] (init_IRQ+0x0/0x24) from [<c0008970>] (start_kernel+0x184/0x2b4)
>
> Hmm, so this looks like it's because mxc_gpio_init() is being called
> from init_IRQ which is too early for platform devices. Is there a
> suitable place where this can be called later in the boot process? I
> guess the gpio irq stuff should remain where it is but the
> platform_device registration should be moved to later.
I guess this means that using gpios in .init_machine (== arch_initcall
time) stops working then? Actually I wanted to test if this is broken
already now because the driver is registered too late. Actually my build
doesn't even have CONFIG_GPIO_BASIC_MMIO=y. I suggest to let the
converted platforms select it.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 14:49 ` Uwe Kleine-König
@ 2011-04-11 15:13 ` Jamie Iles
2011-04-12 15:06 ` Anton Vorontsov
1 sibling, 0 replies; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 15:13 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Apr 11, 2011 at 04:49:28PM +0200, Uwe Kleine-K?nig wrote:
> Hello,
>
> On Mon, Apr 11, 2011 at 03:33:27PM +0100, Jamie Iles wrote:
> > Hmm, so this looks like it's because mxc_gpio_init() is being called
> > from init_IRQ which is too early for platform devices. Is there a
> > suitable place where this can be called later in the boot process?
> > I guess the gpio irq stuff should remain where it is but the
> > platform_device registration should be moved to later.
> I guess this means that using gpios in .init_machine (== arch_initcall
> time) stops working then? Actually I wanted to test if this is broken
> already now because the driver is registered too late.
I've just tried this on my platform and no, the GPIO's won't be
available for .init_machine().
> Actually my build doesn't even have CONFIG_GPIO_BASIC_MMIO=y. I
> suggest to let the converted platforms select it.
OK, that sounds like a good plan.
Jamie
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 14:49 ` Uwe Kleine-König
2011-04-11 15:13 ` Jamie Iles
@ 2011-04-12 15:06 ` Anton Vorontsov
1 sibling, 0 replies; 21+ messages in thread
From: Anton Vorontsov @ 2011-04-12 15:06 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Apr 11, 2011 at 04:49:28PM +0200, Uwe Kleine-K?nig wrote:
[...]
> > Hmm, so this looks like it's because mxc_gpio_init() is being called
> > from init_IRQ which is too early for platform devices. Is there a
> > suitable place where this can be called later in the boot process? I
> > guess the gpio irq stuff should remain where it is but the
> > platform_device registration should be moved to later.
> I guess this means that using gpios in .init_machine (== arch_initcall
> time) stops working then?
Probably it's a bad sign for a platform if it wants to use it
that early (i.e. like init_IRQ).
But as GPIOs is quite essential part of an embedded system, and
some platform code might actually need it, I guess having the stuff
available in arch_initcall would be fine though (assuming
basic_mmio_gpio will be changed to use postcore_initcall).
Thanks,
--
Anton Vorontsov
Email: cbouatmailru at gmail.com
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 11:48 [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio Jamie Iles
` (5 preceding siblings ...)
2011-04-11 13:43 ` [RFC PATCH 0/5] Convert some ARM platforms " Uwe Kleine-König
@ 2011-04-11 15:17 ` Linus Walleij
2011-04-11 15:21 ` Jamie Iles
6 siblings, 1 reply; 21+ messages in thread
From: Linus Walleij @ 2011-04-11 15:17 UTC (permalink / raw)
To: linux-arm-kernel
2011/4/11 Jamie Iles <jamie@jamieiles.com>:
> The basic-mmio-gpio driver has been extended in
> <http://marc.info/?l=linux-kernel&m=130252092900804&w=2> to support a
> larger wider of controllers and this series converts the ARM platforms
> that do not implement I/O muxing in the GPIO driver or use the .to_irq
> method of gpio_chip to use the driver.
>
> Jamie Iles (5):
> ?gemini: convert to basic-mmio-gpio
> ?sa1100: convert to basic-mmio-gpio
> ?w90x900: convert to basic-mmio-gpio
> ?iop: convert to basic-mmio-gpio
> ?mxc: convert to basic-mmio-gpio
For all of these, maybe you can
select GPIO_BASIC_GPIO
In their mach-xxx/Kconfig so that the driver gets compiled-in by default?
Further the basic_mmio_gpio.c driver looks a bit dangerous: it only uses
__raw_* accessors for the GPIO registers, I'd very much like to replace that
with the non-__raw* versions if this is to have any generic impact.
The raw accessors can get stuck in things like write buffers and the like
IIRC, they usually won't so you don't notice first, then you start getting
all kind of real strange bugs.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 21+ messages in thread
* [RFC PATCH 0/5] Convert some ARM platforms to basic-mmio-gpio
2011-04-11 15:17 ` Linus Walleij
@ 2011-04-11 15:21 ` Jamie Iles
0 siblings, 0 replies; 21+ messages in thread
From: Jamie Iles @ 2011-04-11 15:21 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Apr 11, 2011 at 05:17:53PM +0200, Linus Walleij wrote:
> 2011/4/11 Jamie Iles <jamie@jamieiles.com>:
>
> > The basic-mmio-gpio driver has been extended in
> > <http://marc.info/?l=linux-kernel&m=130252092900804&w=2> to support a
> > larger wider of controllers and this series converts the ARM platforms
> > that do not implement I/O muxing in the GPIO driver or use the .to_irq
> > method of gpio_chip to use the driver.
> >
> > Jamie Iles (5):
> > ?gemini: convert to basic-mmio-gpio
> > ?sa1100: convert to basic-mmio-gpio
> > ?w90x900: convert to basic-mmio-gpio
> > ?iop: convert to basic-mmio-gpio
> > ?mxc: convert to basic-mmio-gpio
>
> For all of these, maybe you can
> select GPIO_BASIC_GPIO
>
> In their mach-xxx/Kconfig so that the driver gets compiled-in by default?
OK, Uwe has suggested that already so I'll fix that up for the next
attempt.
> Further the basic_mmio_gpio.c driver looks a bit dangerous: it only uses
> __raw_* accessors for the GPIO registers, I'd very much like to replace that
> with the non-__raw* versions if this is to have any generic impact.
>
> The raw accessors can get stuck in things like write buffers and the like
> IIRC, they usually won't so you don't notice first, then you start getting
> all kind of real strange bugs.
Sounds sensible. I'll create a patch to convert to use the non raw
versions then.
Jamie
^ permalink raw reply [flat|nested] 21+ messages in thread