All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/11] enhance DT support on gpio pxa
@ 2013-02-19 16:22 Haojian Zhuang
  2013-02-19 16:22 ` [PATCH v4 01/11] gpio: pxa: identify ed mask reg with platform data Haojian Zhuang
                   ` (11 more replies)
  0 siblings, 12 replies; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Changelog:

v4:
* Re-oragnize these patches.
* Append document for new properties binding.
* Discard the full support on irq domain. It will be appended in other
  series.

v3:
* Fix the gpio irq issue on legacy platform.
* Discard irq_base & use irq domain instead in pxa_gpio_chip structure.
* Update DTS file since it's depend on latest pinctrl single driver.

v2:
* Fix the build issue without CONFIG_OF
* Append to check PINCTRL_SINGLE because of arch pxa not moved to DT
* Use bool for inverted, ed_mask, gafr variable

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

* [PATCH v4 01/11] gpio: pxa: identify ed mask reg with platform data
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-19 16:22 ` [PATCH v4 02/11] gpio: pxa: clean code with same variable name Haojian Zhuang
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Avoid to judge whether edge mask register exists by CPU. Use platform
data to identify it instead. The gpio edge mask register exists in MMP
series SoC.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 arch/arm/mach-mmp/aspenite.c      |    7 +++++++
 arch/arm/mach-mmp/avengers_lite.c |    7 +++++++
 arch/arm/mach-mmp/brownstone.c    |    7 +++++++
 arch/arm/mach-mmp/flint.c         |    7 +++++++
 arch/arm/mach-mmp/gplugd.c        |    7 +++++++
 arch/arm/mach-mmp/tavorevb.c      |    7 +++++++
 arch/arm/mach-mmp/teton_bga.c     |    7 +++++++
 arch/arm/mach-mmp/ttc_dkb.c       |    7 +++++++
 drivers/gpio/gpio-pxa.c           |   10 +++++++++-
 include/linux/gpio-pxa.h          |    1 +
 10 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c
index 9f64d56..36f5781 100644
--- a/arch/arm/mach-mmp/aspenite.c
+++ b/arch/arm/mach-mmp/aspenite.c
@@ -9,6 +9,7 @@
  *  publishhed by the Free Software Foundation.
  */
 #include <linux/gpio.h>
+#include <linux/gpio-pxa.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
@@ -110,6 +111,10 @@ static unsigned long common_pin_config[] __initdata = {
 	GPIO121_KP_MKIN4,
 };
 
+static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
+	.ed_mask	= true,
+};
+
 static struct smc91x_platdata smc91x_info = {
 	.flags	= SMC91X_USE_16BIT | SMC91X_NOWAIT,
 };
@@ -248,6 +253,8 @@ static void __init common_init(void)
 	pxa168_add_nand(&aspenite_nand_info);
 	pxa168_add_fb(&aspenite_lcd_info);
 	pxa168_add_keypad(&aspenite_keypad_info);
+	platform_device_add_data(&pxa168_device_gpio, &pxa168_gpio_pdata,
+				 sizeof(struct pxa_gpio_platform_data));
 	platform_device_register(&pxa168_device_gpio);
 
 	/* off-chip devices */
diff --git a/arch/arm/mach-mmp/avengers_lite.c b/arch/arm/mach-mmp/avengers_lite.c
index 1f94957..b8fe447 100644
--- a/arch/arm/mach-mmp/avengers_lite.c
+++ b/arch/arm/mach-mmp/avengers_lite.c
@@ -12,6 +12,7 @@
 
 #include <linux/init.h>
 #include <linux/kernel.h>
+#include <linux/gpio-pxa.h>
 #include <linux/platform_device.h>
 
 #include <asm/mach-types.h>
@@ -32,12 +33,18 @@ static unsigned long avengers_lite_pin_config_V16F[] __initdata = {
 	GPIO89_UART2_RXD,
 };
 
+static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
+	.ed_mask	= true,
+};
+
 static void __init avengers_lite_init(void)
 {
 	mfp_config(ARRAY_AND_SIZE(avengers_lite_pin_config_V16F));
 
 	/* on-chip devices */
 	pxa168_add_uart(2);
+	platform_device_add_data(&pxa168_device_gpio, &pxa168_gpio_pdata,
+				 sizeof(struct pxa_gpio_platform_data));
 	platform_device_register(&pxa168_device_gpio);
 }
 
diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index 2358011..d6ea5c4 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/gpio-pxa.h>
 #include <linux/regulator/machine.h>
 #include <linux/regulator/max8649.h>
 #include <linux/regulator/fixed.h>
@@ -104,6 +105,10 @@ static unsigned long brownstone_pin_config[] __initdata = {
 	GPIO89_GPIO,
 };
 
+static struct pxa_gpio_platform_data mmp2_gpio_pdata = {
+	.ed_mask	= true,
+};
+
 static struct regulator_consumer_supply max8649_supply[] = {
 	REGULATOR_SUPPLY("vcc_core", NULL),
 };
@@ -202,6 +207,8 @@ static void __init brownstone_init(void)
 	/* on-chip devices */
 	mmp2_add_uart(1);
 	mmp2_add_uart(3);
+	platform_device_add_data(&mmp2_device_gpio, &mmp2_gpio_pdata,
+				 sizeof(struct pxa_gpio_platform_data));
 	platform_device_register(&mmp2_device_gpio);
 	mmp2_add_twsi(1, NULL, ARRAY_AND_SIZE(brownstone_twsi1_info));
 	mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */
diff --git a/arch/arm/mach-mmp/flint.c b/arch/arm/mach-mmp/flint.c
index 754c352..0955f44 100644
--- a/arch/arm/mach-mmp/flint.c
+++ b/arch/arm/mach-mmp/flint.c
@@ -16,6 +16,7 @@
 #include <linux/smc91x.h>
 #include <linux/io.h>
 #include <linux/gpio.h>
+#include <linux/gpio-pxa.h>
 #include <linux/interrupt.h>
 
 #include <asm/mach-types.h>
@@ -77,6 +78,10 @@ static unsigned long flint_pin_config[] __initdata = {
 	GPIO160_ND_RDY1,
 };
 
+static struct pxa_gpio_platform_data mmp2_gpio_pdata = {
+	.ed_mask	= true,
+};
+
 static struct smc91x_platdata flint_smc91x_info = {
 	.flags  = SMC91X_USE_16BIT | SMC91X_NOWAIT,
 };
@@ -111,6 +116,8 @@ static void __init flint_init(void)
 	/* on-chip devices */
 	mmp2_add_uart(1);
 	mmp2_add_uart(2);
+	platform_device_add_data(&mmp2_device_gpio, &mmp2_gpio_pdata,
+				 sizeof(struct pxa_gpio_platform_data));
 	platform_device_register(&mmp2_device_gpio);
 
 	/* off-chip devices */
diff --git a/arch/arm/mach-mmp/gplugd.c b/arch/arm/mach-mmp/gplugd.c
index d1e2d59..2315cce 100644
--- a/arch/arm/mach-mmp/gplugd.c
+++ b/arch/arm/mach-mmp/gplugd.c
@@ -10,6 +10,7 @@
 
 #include <linux/init.h>
 #include <linux/gpio.h>
+#include <linux/gpio-pxa.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach-types.h>
@@ -127,6 +128,10 @@ static unsigned long gplugd_pin_config[] __initdata = {
 	GPIO116_I2S_TXD
 };
 
+static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
+	.ed_mask	= true,
+};
+
 static struct i2c_board_info gplugd_i2c_board_info[] = {
 	{
 		.type = "isl1208",
@@ -185,6 +190,8 @@ static void __init gplugd_init(void)
 	pxa168_add_uart(3);
 	pxa168_add_ssp(1);
 	pxa168_add_twsi(0, NULL, ARRAY_AND_SIZE(gplugd_i2c_board_info));
+	platform_device_add_data(&pxa168_device_gpio, &pxa168_gpio_pdata,
+				 sizeof(struct pxa_gpio_platform_data));
 	platform_device_register(&pxa168_device_gpio);
 
 	pxa168_add_eth(&gplugd_eth_platform_data);
diff --git a/arch/arm/mach-mmp/tavorevb.c b/arch/arm/mach-mmp/tavorevb.c
index 4c127d2..eaec649 100644
--- a/arch/arm/mach-mmp/tavorevb.c
+++ b/arch/arm/mach-mmp/tavorevb.c
@@ -8,6 +8,7 @@
  *  publishhed by the Free Software Foundation.
  */
 #include <linux/gpio.h>
+#include <linux/gpio-pxa.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
@@ -60,6 +61,10 @@ static unsigned long tavorevb_pin_config[] __initdata = {
 	DF_RDY0_DF_RDY0,
 };
 
+static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = {
+	.ed_mask	= true,
+};
+
 static struct smc91x_platdata tavorevb_smc91x_info = {
 	.flags	= SMC91X_USE_16BIT | SMC91X_NOWAIT,
 };
@@ -93,6 +98,8 @@ static void __init tavorevb_init(void)
 
 	/* on-chip devices */
 	pxa910_add_uart(1);
+	platform_device_add_data(&pxa910_device_gpio, &ttc_dkb_gpio_pdata,
+				 sizeof(struct pxa_gpio_platform_data));
 	platform_device_register(&pxa910_device_gpio);
 
 	/* off-chip devices */
diff --git a/arch/arm/mach-mmp/teton_bga.c b/arch/arm/mach-mmp/teton_bga.c
index 8609967..6682100 100644
--- a/arch/arm/mach-mmp/teton_bga.c
+++ b/arch/arm/mach-mmp/teton_bga.c
@@ -16,6 +16,7 @@
 #include <linux/kernel.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/gpio-pxa.h>
 #include <linux/input.h>
 #include <linux/platform_data/keypad-pxa27x.h>
 #include <linux/i2c.h>
@@ -49,6 +50,10 @@ static unsigned long teton_bga_pin_config[] __initdata = {
 	GPIO78_GPIO,
 };
 
+static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
+	.ed_mask	= true,
+};
+
 static unsigned int teton_bga_matrix_key_map[] = {
 	KEY(0, 6, KEY_ESC),
 	KEY(0, 7, KEY_ENTER),
@@ -79,6 +84,8 @@ static void __init teton_bga_init(void)
 	pxa168_add_uart(1);
 	pxa168_add_keypad(&teton_bga_keypad_info);
 	pxa168_add_twsi(0, NULL, ARRAY_AND_SIZE(teton_bga_i2c_info));
+	platform_device_add_data(&pxa168_device_gpio, &pxa168_gpio_pdata,
+				 sizeof(struct pxa_gpio_platform_data));
 	platform_device_register(&pxa168_device_gpio);
 }
 
diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index 22a9058..d8df90b 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -17,6 +17,7 @@
 #include <linux/interrupt.h>
 #include <linux/i2c/pca953x.h>
 #include <linux/gpio.h>
+#include <linux/gpio-pxa.h>
 #include <linux/mfd/88pm860x.h>
 #include <linux/platform_data/mv_usb.h>
 #include <linux/spi/spi.h>
@@ -75,6 +76,10 @@ static unsigned long ttc_dkb_pin_config[] __initdata = {
 	DF_RDY0_DF_RDY0,
 };
 
+static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = {
+	.ed_mask	= true,
+};
+
 static struct mtd_partition ttc_dkb_onenand_partitions[] = {
 	{
 		.name		= "bootloader",
@@ -284,6 +289,8 @@ static void __init ttc_dkb_init(void)
 
 	/* off-chip devices */
 	pxa910_add_twsi(0, NULL, ARRAY_AND_SIZE(ttc_dkb_i2c_info));
+	platform_device_add_data(&pxa910_device_gpio, &ttc_dkb_gpio_pdata,
+				 sizeof(struct pxa_gpio_platform_data));
 	platform_add_devices(ARRAY_AND_SIZE(ttc_dkb_devices));
 
 #ifdef CONFIG_USB_MV_UDC
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 9cc108d..a4c6687 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -493,6 +493,7 @@ const struct irq_domain_ops pxa_irq_domain_ops = {
 static int pxa_gpio_probe_dt(struct platform_device *pdev)
 {
 	int ret, nr_banks, nr_gpios;
+	struct pxa_gpio_platform_data *pdata;
 	struct device_node *prev, *next, *np = pdev->dev.of_node;
 	const struct of_device_id *of_id =
 				of_match_device(pxa_gpio_dt_ids, &pdev->dev);
@@ -501,6 +502,13 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Failed to find gpio controller\n");
 		return -EFAULT;
 	}
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
+	if (of_find_property(np, "marvell,gpio-ed-mask", NULL))
+		pdata->ed_mask = true;
+	/* set the platform data */
+	pdev->dev.platform_data = pdata;
 	gpio_type = (int)of_id->data;
 
 	next = of_get_next_child(np, NULL);
@@ -604,7 +612,7 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 		writel_relaxed(0, c->regbase + GRER_OFFSET);
 		writel_relaxed(~0,c->regbase + GEDR_OFFSET);
 		/* unmask GPIO edge detect for AP side */
-		if (gpio_is_mmp_type(gpio_type))
+		if (info->ed_mask)
 			writel_relaxed(~0, c->regbase + ED_MASK_OFFSET);
 	}
 
diff --git a/include/linux/gpio-pxa.h b/include/linux/gpio-pxa.h
index d755b28..bc5cae5 100644
--- a/include/linux/gpio-pxa.h
+++ b/include/linux/gpio-pxa.h
@@ -14,6 +14,7 @@ extern int pxa_last_gpio;
 extern int pxa_irq_to_gpio(int irq);
 
 struct pxa_gpio_platform_data {
+	bool ed_mask;	/* true means that ed_mask reg is available */
 	int (*gpio_set_wake)(unsigned int gpio, unsigned int on);
 };
 
-- 
1.7.10.4

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

* [PATCH v4 02/11] gpio: pxa: clean code with same variable name
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
  2013-02-19 16:22 ` [PATCH v4 01/11] gpio: pxa: identify ed mask reg with platform data Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-20  8:13   ` Igor Grinberg
  2013-02-19 16:22 ` [PATCH v4 03/11] gpio: pxa: use platform data for gpio inverted Haojian Zhuang
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Clean code to avoid similar variable. Now use gc for gpio_chip,
and use c/chip for pxa_gpio_chip. It's used to avoid confusion.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 drivers/gpio/gpio-pxa.c |  102 +++++++++++++++++++++++------------------------
 1 file changed, 50 insertions(+), 52 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index a4c6687..e611bed 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -69,20 +69,20 @@ static struct device_node *pxa_gpio_of_node;
 #endif
 
 struct pxa_gpio_chip {
-	struct gpio_chip chip;
-	void __iomem	*regbase;
-	char label[10];
+	struct gpio_chip	gc;
+	void __iomem		*regbase;
+	char			label[10];
 
-	unsigned long	irq_mask;
-	unsigned long	irq_edge_rise;
-	unsigned long	irq_edge_fall;
-	int (*set_wake)(unsigned int gpio, unsigned int on);
+	unsigned long		irq_mask;
+	unsigned long		irq_edge_rise;
+	unsigned long		irq_edge_fall;
+	int			(*set_wake)(unsigned int gpio, unsigned int on);
 
 #ifdef CONFIG_PM
-	unsigned long	saved_gplr;
-	unsigned long	saved_gpdr;
-	unsigned long	saved_grer;
-	unsigned long	saved_gfer;
+	unsigned long		saved_gplr;
+	unsigned long		saved_gpdr;
+	unsigned long		saved_grer;
+	unsigned long		saved_gfer;
 #endif
 };
 
@@ -103,9 +103,9 @@ static void __iomem *gpio_reg_base;
 #define for_each_gpio_chip(i, c)			\
 	for (i = 0, c = &pxa_gpio_chips[0]; i <= pxa_last_gpio; i += 32, c++)
 
-static inline void __iomem *gpio_chip_base(struct gpio_chip *c)
+static inline void __iomem *gpio_chip_base(struct gpio_chip *gc)
 {
-	return container_of(c, struct pxa_gpio_chip, chip)->regbase;
+	return container_of(gc, struct pxa_gpio_chip, gc)->regbase;
 }
 
 static inline struct pxa_gpio_chip *gpio_to_pxachip(unsigned gpio)
@@ -147,7 +147,7 @@ static inline int __gpio_is_occupied(unsigned gpio)
 	int ret, af = 0, dir = 0;
 
 	pxachip = gpio_to_pxachip(gpio);
-	base = gpio_chip_base(&pxachip->chip);
+	base = gpio_chip_base(&pxachip->gc);
 	gpdr = readl_relaxed(base + GPDR_OFFSET);
 
 	switch (gpio_type) {
@@ -170,9 +170,9 @@ static inline int __gpio_is_occupied(unsigned gpio)
 	return ret;
 }
 
-static int pxa_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+static int pxa_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
 {
-	return chip->base + offset + irq_base;
+	return gc->base + offset + irq_base;
 }
 
 int pxa_irq_to_gpio(int irq)
@@ -180,16 +180,16 @@ int pxa_irq_to_gpio(int irq)
 	return irq - irq_base;
 }
 
-static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
+static int pxa_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
 {
-	void __iomem *base = gpio_chip_base(chip);
+	void __iomem *base = gpio_chip_base(gc);
 	uint32_t value, mask = 1 << offset;
 	unsigned long flags;
 
 	spin_lock_irqsave(&gpio_lock, flags);
 
 	value = readl_relaxed(base + GPDR_OFFSET);
-	if (__gpio_is_inverted(chip->base + offset))
+	if (__gpio_is_inverted(gc->base + offset))
 		value |= mask;
 	else
 		value &= ~mask;
@@ -199,10 +199,10 @@ static int pxa_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 	return 0;
 }
 
-static int pxa_gpio_direction_output(struct gpio_chip *chip,
+static int pxa_gpio_direction_output(struct gpio_chip *gc,
 				     unsigned offset, int value)
 {
-	void __iomem *base = gpio_chip_base(chip);
+	void __iomem *base = gpio_chip_base(gc);
 	uint32_t tmp, mask = 1 << offset;
 	unsigned long flags;
 
@@ -211,7 +211,7 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip,
 	spin_lock_irqsave(&gpio_lock, flags);
 
 	tmp = readl_relaxed(base + GPDR_OFFSET);
-	if (__gpio_is_inverted(chip->base + offset))
+	if (__gpio_is_inverted(gc->base + offset))
 		tmp &= ~mask;
 	else
 		tmp |= mask;
@@ -221,15 +221,15 @@ static int pxa_gpio_direction_output(struct gpio_chip *chip,
 	return 0;
 }
 
-static int pxa_gpio_get(struct gpio_chip *chip, unsigned offset)
+static int pxa_gpio_get(struct gpio_chip *gc, unsigned offset)
 {
-	return readl_relaxed(gpio_chip_base(chip) + GPLR_OFFSET) & (1 << offset);
+	return readl_relaxed(gpio_chip_base(gc) + GPLR_OFFSET) & (1 << offset);
 }
 
-static void pxa_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
+static void pxa_gpio_set(struct gpio_chip *gc, unsigned offset, int value)
 {
-	writel_relaxed(1 << offset, gpio_chip_base(chip) +
-				(value ? GPSR_OFFSET : GPCR_OFFSET));
+	writel_relaxed(1 << offset, gpio_chip_base(gc) +
+		       (value ? GPSR_OFFSET : GPCR_OFFSET));
 }
 
 #ifdef CONFIG_OF_GPIO
@@ -240,7 +240,7 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc,
 	if (gpiospec->args[0] > pxa_last_gpio)
 		return -EINVAL;
 
-	if (gc != &pxa_gpio_chips[gpiospec->args[0] / 32].chip)
+	if (gc != &pxa_gpio_chips[gpiospec->args[0] / 32].gc)
 		return -EINVAL;
 
 	if (flags)
@@ -250,42 +250,43 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc,
 }
 #endif
 
-static int pxa_init_gpio_chip(int gpio_end,
-					int (*set_wake)(unsigned int, unsigned int))
+static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end)
 {
 	int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1;
 	struct pxa_gpio_chip *chips;
+	struct pxa_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
 
-	chips = kzalloc(nbanks * sizeof(struct pxa_gpio_chip), GFP_KERNEL);
-	if (chips == NULL) {
-		pr_err("%s: failed to allocate GPIO chips\n", __func__);
+	chips = devm_kzalloc(&pdev->dev, nbanks * sizeof(*chips), GFP_KERNEL);
+	if (!chips) {
+		dev_err(&pdev->dev, "failed to allocate GPIO chips\n");
 		return -ENOMEM;
 	}
 
 	for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) {
-		struct gpio_chip *c = &chips[i].chip;
+		struct gpio_chip *gc = &chips[i].gc;
 
 		sprintf(chips[i].label, "gpio-%d", i);
 		chips[i].regbase = gpio_reg_base + BANK_OFF(i);
-		chips[i].set_wake = set_wake;
+		if (pdata->gpio_set_wake)
+			chips[i].set_wake = pdata->gpio_set_wake;
 
-		c->base  = gpio;
-		c->label = chips[i].label;
+		gc->base  = gpio;
+		gc->label = chips[i].label;
 
-		c->direction_input  = pxa_gpio_direction_input;
-		c->direction_output = pxa_gpio_direction_output;
-		c->get = pxa_gpio_get;
-		c->set = pxa_gpio_set;
-		c->to_irq = pxa_gpio_to_irq;
+		gc->direction_input  = pxa_gpio_direction_input;
+		gc->direction_output = pxa_gpio_direction_output;
+		gc->get = pxa_gpio_get;
+		gc->set = pxa_gpio_set;
+		gc->to_irq = pxa_gpio_to_irq;
 #ifdef CONFIG_OF_GPIO
-		c->of_node = pxa_gpio_of_node;
-		c->of_xlate = pxa_gpio_of_xlate;
-		c->of_gpio_n_cells = 2;
+		gc->of_node = pxa_gpio_of_node;
+		gc->of_xlate = pxa_gpio_of_xlate;
+		gc->of_gpio_n_cells = 2;
 #endif
 
 		/* number of GPIOs on last bank may be less than 32 */
-		c->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32;
-		gpiochip_add(c);
+		gc->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32;
+		gpiochip_add(gc);
 	}
 	pxa_gpio_chips = chips;
 	return 0;
@@ -364,7 +365,7 @@ static void pxa_gpio_demux_handler(unsigned int irq, struct irq_desc *desc)
 	do {
 		loop = 0;
 		for_each_gpio_chip(gpio, c) {
-			gpio_base = c->chip.base;
+			gpio_base = c->gc.base;
 
 			gedr = readl_relaxed(c->regbase + GEDR_OFFSET);
 			gedr = gedr & c->irq_mask;
@@ -537,9 +538,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 				       &pxa_irq_domain_ops, NULL);
 	pxa_gpio_of_node = np;
 	return 0;
-err:
-	iounmap(gpio_reg_base);
-	return ret;
 }
 #else
 #define pxa_gpio_probe_dt(pdev)		(-1)
@@ -604,7 +602,7 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 
 	/* Initialize GPIO chips */
 	info = dev_get_platdata(&pdev->dev);
-	pxa_init_gpio_chip(pxa_last_gpio, info ? info->gpio_set_wake : NULL);
+	pxa_init_gpio_chip(pdev, pxa_last_gpio);
 
 	/* clear all GPIO edge detects */
 	for_each_gpio_chip(gpio, c) {
-- 
1.7.10.4

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

* [PATCH v4 03/11] gpio: pxa: use platform data for gpio inverted
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
  2013-02-19 16:22 ` [PATCH v4 01/11] gpio: pxa: identify ed mask reg with platform data Haojian Zhuang
  2013-02-19 16:22 ` [PATCH v4 02/11] gpio: pxa: clean code with same variable name Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-19 16:22 ` [PATCH v4 04/11] gpio: pxa: remove gpio_type Haojian Zhuang
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Avoid to judge whether gpio is inverted by identifying cpu in
gpio driver. Move this into platform data of gpio driver.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 arch/arm/mach-pxa/pxa25x.c |    3 +++
 drivers/gpio/gpio-pxa.c    |   31 ++++++++++++++++++++-----------
 include/linux/gpio-pxa.h   |    1 +
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index 3f5171e..9c9c224 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -340,6 +340,9 @@ void __init pxa25x_map_io(void)
 }
 
 static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = {
+#ifdef CONFIG_CPU_PXA26x
+	.inverted = true,
+#endif
 	.gpio_set_wake = gpio_set_wake,
 };
 
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index e611bed..11a732e 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -71,6 +71,7 @@ static struct device_node *pxa_gpio_of_node;
 struct pxa_gpio_chip {
 	struct gpio_chip	gc;
 	void __iomem		*regbase;
+	bool			inverted;
 	char			label[10];
 
 	unsigned long		irq_mask;
@@ -126,9 +127,9 @@ static inline int gpio_is_mmp_type(int type)
 /* GPIO86/87/88/89 on PXA26x have their direction bits in PXA_GPDR(2 inverted,
  * as well as their Alternate Function value being '1' for GPIO in GAFRx.
  */
-static inline int __gpio_is_inverted(int gpio)
+static inline int __gpio_is_inverted(struct pxa_gpio_chip *chip, int gpio)
 {
-	if ((gpio_type == PXA26X_GPIO) && (gpio > 85))
+	if ((chip->inverted) && (gpio > 85))
 		return 1;
 	return 0;
 }
@@ -139,15 +140,13 @@ static inline int __gpio_is_inverted(int gpio)
  * is attributed as "occupied" here (I know this terminology isn't
  * accurate, you are welcome to propose a better one :-)
  */
-static inline int __gpio_is_occupied(unsigned gpio)
+static inline int __gpio_is_occupied(struct pxa_gpio_chip *chip, unsigned gpio)
 {
-	struct pxa_gpio_chip *pxachip;
 	void __iomem *base;
 	unsigned long gafr = 0, gpdr = 0;
 	int ret, af = 0, dir = 0;
 
-	pxachip = gpio_to_pxachip(gpio);
-	base = gpio_chip_base(&pxachip->gc);
+	base = gpio_chip_base(&chip->gc);
 	gpdr = readl_relaxed(base + GPDR_OFFSET);
 
 	switch (gpio_type) {
@@ -158,7 +157,7 @@ static inline int __gpio_is_occupied(unsigned gpio)
 		af = (gafr >> ((gpio & 0xf) * 2)) & 0x3;
 		dir = gpdr & GPIO_bit(gpio);
 
-		if (__gpio_is_inverted(gpio))
+		if (__gpio_is_inverted(chip, gpio))
 			ret = (af != 1) || (dir == 0);
 		else
 			ret = (af != 0) || (dir != 0);
@@ -183,13 +182,16 @@ int pxa_irq_to_gpio(int irq)
 static int pxa_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
 {
 	void __iomem *base = gpio_chip_base(gc);
+	struct pxa_gpio_chip *chip;
 	uint32_t value, mask = 1 << offset;
 	unsigned long flags;
 
+	chip = container_of(gc, struct pxa_gpio_chip, gc);
+
 	spin_lock_irqsave(&gpio_lock, flags);
 
 	value = readl_relaxed(base + GPDR_OFFSET);
-	if (__gpio_is_inverted(gc->base + offset))
+	if (__gpio_is_inverted(chip, gc->base + offset))
 		value |= mask;
 	else
 		value &= ~mask;
@@ -203,15 +205,17 @@ static int pxa_gpio_direction_output(struct gpio_chip *gc,
 				     unsigned offset, int value)
 {
 	void __iomem *base = gpio_chip_base(gc);
+	struct pxa_gpio_chip *chip;
 	uint32_t tmp, mask = 1 << offset;
 	unsigned long flags;
 
+	chip = container_of(gc, struct pxa_gpio_chip, gc);
 	writel_relaxed(mask, base + (value ? GPSR_OFFSET : GPCR_OFFSET));
 
 	spin_lock_irqsave(&gpio_lock, flags);
 
 	tmp = readl_relaxed(base + GPDR_OFFSET);
-	if (__gpio_is_inverted(gc->base + offset))
+	if (__gpio_is_inverted(chip, gc->base + offset))
 		tmp &= ~mask;
 	else
 		tmp |= mask;
@@ -322,7 +326,7 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type)
 		if ((c->irq_edge_rise | c->irq_edge_fall) & GPIO_bit(gpio))
 			return 0;
 
-		if (__gpio_is_occupied(gpio))
+		if (__gpio_is_occupied(c, gpio))
 			return 0;
 
 		type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
@@ -330,7 +334,7 @@ static int pxa_gpio_irq_type(struct irq_data *d, unsigned int type)
 
 	gpdr = readl_relaxed(c->regbase + GPDR_OFFSET);
 
-	if (__gpio_is_inverted(gpio))
+	if (__gpio_is_inverted(c, gpio))
 		writel_relaxed(gpdr | mask,  c->regbase + GPDR_OFFSET);
 	else
 		writel_relaxed(gpdr & ~mask, c->regbase + GPDR_OFFSET);
@@ -508,6 +512,9 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 		return -ENOMEM;
 	if (of_find_property(np, "marvell,gpio-ed-mask", NULL))
 		pdata->ed_mask = true;
+	/* It's only valid for PXA26x */
+	if (of_find_property(np, "marvell,gpio-inverted", NULL))
+		pdata->inverted = true;
 	/* set the platform data */
 	pdev->dev.platform_data = pdata;
 	gpio_type = (int)of_id->data;
@@ -612,6 +619,8 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 		/* unmask GPIO edge detect for AP side */
 		if (info->ed_mask)
 			writel_relaxed(~0, c->regbase + ED_MASK_OFFSET);
+		/* update for gpio inverted */
+		c->inverted = info->inverted;
 	}
 
 	if (!use_of) {
diff --git a/include/linux/gpio-pxa.h b/include/linux/gpio-pxa.h
index bc5cae5..759e865 100644
--- a/include/linux/gpio-pxa.h
+++ b/include/linux/gpio-pxa.h
@@ -15,6 +15,7 @@ extern int pxa_irq_to_gpio(int irq);
 
 struct pxa_gpio_platform_data {
 	bool ed_mask;	/* true means that ed_mask reg is available */
+	bool inverted;	/* only valid for PXA26x */
 	int (*gpio_set_wake)(unsigned int gpio, unsigned int on);
 };
 
-- 
1.7.10.4

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

* [PATCH v4 04/11] gpio: pxa: remove gpio_type
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (2 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 03/11] gpio: pxa: use platform data for gpio inverted Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-20  8:18   ` Igor Grinberg
  2013-03-01  0:33   ` Linus Walleij
  2013-02-19 16:22 ` [PATCH v4 05/11] gpio: pxa: define nr gpios in platform data Haojian Zhuang
                   ` (7 subsequent siblings)
  11 siblings, 2 replies; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Since gpio_type is used to check whether gafr register is valid. So
move it into platform data.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 arch/arm/mach-pxa/pxa25x.c |    1 +
 arch/arm/mach-pxa/pxa27x.c |    1 +
 drivers/gpio/gpio-pxa.c    |   54 +++++++++-----------------------------------
 include/linux/gpio-pxa.h   |    1 +
 4 files changed, 14 insertions(+), 43 deletions(-)

diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index 9c9c224..ef1bb41 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -343,6 +343,7 @@ static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = {
 #ifdef CONFIG_CPU_PXA26x
 	.inverted = true,
 #endif
+	.gafr = true,
 	.gpio_set_wake = gpio_set_wake,
 };
 
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index 3203a9f..7f1f18a 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -431,6 +431,7 @@ void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info)
 }
 
 static struct pxa_gpio_platform_data pxa27x_gpio_info __initdata = {
+	.gafr = true,
 	.gpio_set_wake = gpio_set_wake,
 };
 
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 11a732e..f31509e 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -72,6 +72,7 @@ struct pxa_gpio_chip {
 	struct gpio_chip	gc;
 	void __iomem		*regbase;
 	bool			inverted;
+	bool			gafr;
 	char			label[10];
 
 	unsigned long		irq_mask;
@@ -87,18 +88,8 @@ struct pxa_gpio_chip {
 #endif
 };
 
-enum {
-	PXA25X_GPIO = 0,
-	PXA26X_GPIO,
-	PXA27X_GPIO,
-	PXA3XX_GPIO,
-	PXA93X_GPIO,
-	MMP_GPIO = 0x10,
-};
-
 static DEFINE_SPINLOCK(gpio_lock);
 static struct pxa_gpio_chip *pxa_gpio_chips;
-static int gpio_type;
 static void __iomem *gpio_reg_base;
 
 #define for_each_gpio_chip(i, c)			\
@@ -114,16 +105,6 @@ static inline struct pxa_gpio_chip *gpio_to_pxachip(unsigned gpio)
 	return &pxa_gpio_chips[gpio_to_bank(gpio)];
 }
 
-static inline int gpio_is_pxa_type(int type)
-{
-	return (type & MMP_GPIO) == 0;
-}
-
-static inline int gpio_is_mmp_type(int type)
-{
-	return (type & MMP_GPIO) != 0;
-}
-
 /* GPIO86/87/88/89 on PXA26x have their direction bits in PXA_GPDR(2 inverted,
  * as well as their Alternate Function value being '1' for GPIO in GAFRx.
  */
@@ -149,10 +130,7 @@ static inline int __gpio_is_occupied(struct pxa_gpio_chip *chip, unsigned gpio)
 	base = gpio_chip_base(&chip->gc);
 	gpdr = readl_relaxed(base + GPDR_OFFSET);
 
-	switch (gpio_type) {
-	case PXA25X_GPIO:
-	case PXA26X_GPIO:
-	case PXA27X_GPIO:
+	if (chip->gafr) {
 		gafr = readl_relaxed(base + GAFR_OFFSET);
 		af = (gafr >> ((gpio & 0xf) * 2)) & 0x3;
 		dir = gpdr & GPIO_bit(gpio);
@@ -161,10 +139,8 @@ static inline int __gpio_is_occupied(struct pxa_gpio_chip *chip, unsigned gpio)
 			ret = (af != 1) || (dir == 0);
 		else
 			ret = (af != 0) || (dir != 0);
-		break;
-	default:
+	} else {
 		ret = gpdr & GPIO_bit(gpio);
-		break;
 	}
 	return ret;
 }
@@ -445,30 +421,23 @@ static int pxa_gpio_nums(void)
 	if (cpu_is_pxa25x()) {
 #ifdef CONFIG_CPU_PXA26x
 		count = 89;
-		gpio_type = PXA26X_GPIO;
 #elif defined(CONFIG_PXA25x)
 		count = 84;
-		gpio_type = PXA26X_GPIO;
 #endif /* CONFIG_CPU_PXA26x */
 	} else if (cpu_is_pxa27x()) {
 		count = 120;
-		gpio_type = PXA27X_GPIO;
 	} else if (cpu_is_pxa93x()) {
 		count = 191;
-		gpio_type = PXA93X_GPIO;
 	} else if (cpu_is_pxa3xx()) {
 		count = 127;
-		gpio_type = PXA3XX_GPIO;
 	}
 #endif /* CONFIG_ARCH_PXA */
 
 #ifdef CONFIG_ARCH_MMP
 	if (cpu_is_pxa168() || cpu_is_pxa910()) {
 		count = 127;
-		gpio_type = MMP_GPIO;
 	} else if (cpu_is_mmp2()) {
 		count = 191;
-		gpio_type = MMP_GPIO;
 	}
 #endif /* CONFIG_ARCH_MMP */
 	return count;
@@ -477,7 +446,7 @@ static int pxa_gpio_nums(void)
 #ifdef CONFIG_OF
 static struct of_device_id pxa_gpio_dt_ids[] = {
 	{ .compatible = "mrvl,pxa-gpio" },
-	{ .compatible = "mrvl,mmp-gpio", .data = (void *)MMP_GPIO },
+	{ .compatible = "mrvl,mmp-gpio" },
 	{}
 };
 
@@ -517,7 +486,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 		pdata->inverted = true;
 	/* set the platform data */
 	pdev->dev.platform_data = pdata;
-	gpio_type = (int)of_id->data;
 
 	next = of_get_next_child(np, NULL);
 	prev = next;
@@ -563,12 +531,11 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		pxa_last_gpio = pxa_gpio_nums();
 #ifdef CONFIG_ARCH_PXA
-		if (gpio_is_pxa_type(gpio_type))
-			irq_base = PXA_GPIO_TO_IRQ(0);
-#endif
-#ifdef CONFIG_ARCH_MMP
-		if (gpio_is_mmp_type(gpio_type))
-			irq_base = MMP_GPIO_TO_IRQ(0);
+		irq_base = PXA_GPIO_TO_IRQ(0);
+#elif defined(CONFIG_ARCH_MMP)
+		irq_base = MMP_GPIO_TO_IRQ(0);
+#else
+#error "gpio-pxa driver can't be used for your architecture"
 #endif
 	} else {
 		use_of = 1;
@@ -619,8 +586,9 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 		/* unmask GPIO edge detect for AP side */
 		if (info->ed_mask)
 			writel_relaxed(~0, c->regbase + ED_MASK_OFFSET);
-		/* update for gpio inverted */
+		/* update for gpio inverted & gafr */
 		c->inverted = info->inverted;
+		c->gafr = info->gafr;
 	}
 
 	if (!use_of) {
diff --git a/include/linux/gpio-pxa.h b/include/linux/gpio-pxa.h
index 759e865..a5670c5 100644
--- a/include/linux/gpio-pxa.h
+++ b/include/linux/gpio-pxa.h
@@ -16,6 +16,7 @@ extern int pxa_irq_to_gpio(int irq);
 struct pxa_gpio_platform_data {
 	bool ed_mask;	/* true means that ed_mask reg is available */
 	bool inverted;	/* only valid for PXA26x */
+	bool gafr;	/* only valid for PXA25x/PXA26x/PXA27x */
 	int (*gpio_set_wake)(unsigned int gpio, unsigned int on);
 };
 
-- 
1.7.10.4

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

* [PATCH v4 05/11] gpio: pxa: define nr gpios in platform data
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (3 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 04/11] gpio: pxa: remove gpio_type Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-20 14:02   ` Igor Grinberg
  2013-02-19 16:22 ` [PATCH v4 06/11] gpio: pxa: add irq base " Haojian Zhuang
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Avoid to identify gpio numbers in gpio driver. Identify it in platform data
instead. So we can remove code of identifying cpu.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 arch/arm/mach-mmp/aspenite.c      |    1 +
 arch/arm/mach-mmp/avengers_lite.c |    1 +
 arch/arm/mach-mmp/brownstone.c    |    1 +
 arch/arm/mach-mmp/flint.c         |    1 +
 arch/arm/mach-mmp/gplugd.c        |    1 +
 arch/arm/mach-mmp/tavorevb.c      |    1 +
 arch/arm/mach-mmp/teton_bga.c     |    1 +
 arch/arm/mach-mmp/ttc_dkb.c       |    1 +
 arch/arm/mach-pxa/pxa25x.c        |    3 +++
 arch/arm/mach-pxa/pxa27x.c        |    1 +
 arch/arm/mach-pxa/pxa3xx.c        |   17 +++++++++++--
 drivers/gpio/gpio-pxa.c           |   49 +++++++------------------------------
 include/linux/gpio-pxa.h          |    1 +
 13 files changed, 37 insertions(+), 42 deletions(-)

diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c
index 36f5781..a3e42dc 100644
--- a/arch/arm/mach-mmp/aspenite.c
+++ b/arch/arm/mach-mmp/aspenite.c
@@ -112,6 +112,7 @@ static unsigned long common_pin_config[] __initdata = {
 };
 
 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
+	.nr_gpios	= 128,
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/avengers_lite.c b/arch/arm/mach-mmp/avengers_lite.c
index b8fe447..1ea6502 100644
--- a/arch/arm/mach-mmp/avengers_lite.c
+++ b/arch/arm/mach-mmp/avengers_lite.c
@@ -34,6 +34,7 @@ static unsigned long avengers_lite_pin_config_V16F[] __initdata = {
 };
 
 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
+	.nr_gpios	= 128,
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index d6ea5c4..a32156f 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -106,6 +106,7 @@ static unsigned long brownstone_pin_config[] __initdata = {
 };
 
 static struct pxa_gpio_platform_data mmp2_gpio_pdata = {
+	.nr_gpios	= 192,
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/flint.c b/arch/arm/mach-mmp/flint.c
index 0955f44..3f301b5 100644
--- a/arch/arm/mach-mmp/flint.c
+++ b/arch/arm/mach-mmp/flint.c
@@ -79,6 +79,7 @@ static unsigned long flint_pin_config[] __initdata = {
 };
 
 static struct pxa_gpio_platform_data mmp2_gpio_pdata = {
+	.nr_gpios	= 192,
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/gplugd.c b/arch/arm/mach-mmp/gplugd.c
index 2315cce..019b178 100644
--- a/arch/arm/mach-mmp/gplugd.c
+++ b/arch/arm/mach-mmp/gplugd.c
@@ -129,6 +129,7 @@ static unsigned long gplugd_pin_config[] __initdata = {
 };
 
 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
+	.nr_gpios	= 128,
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/tavorevb.c b/arch/arm/mach-mmp/tavorevb.c
index eaec649..6e8cf80 100644
--- a/arch/arm/mach-mmp/tavorevb.c
+++ b/arch/arm/mach-mmp/tavorevb.c
@@ -62,6 +62,7 @@ static unsigned long tavorevb_pin_config[] __initdata = {
 };
 
 static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = {
+	.nr_gpios	= 128,
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/teton_bga.c b/arch/arm/mach-mmp/teton_bga.c
index 6682100..b5146bb 100644
--- a/arch/arm/mach-mmp/teton_bga.c
+++ b/arch/arm/mach-mmp/teton_bga.c
@@ -51,6 +51,7 @@ static unsigned long teton_bga_pin_config[] __initdata = {
 };
 
 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
+	.nr_gpios	= 128,
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index d8df90b..387e3f8 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -77,6 +77,7 @@ static unsigned long ttc_dkb_pin_config[] __initdata = {
 };
 
 static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = {
+	.nr_gpios	= 128,
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index ef1bb41..52f94f3 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -342,6 +342,9 @@ void __init pxa25x_map_io(void)
 static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = {
 #ifdef CONFIG_CPU_PXA26x
 	.inverted = true,
+	.nr_gpios = 90,
+#else
+	.nr_gpios = 85,
 #endif
 	.gafr = true,
 	.gpio_set_wake = gpio_set_wake,
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index 7f1f18a..619b2f2 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -432,6 +432,7 @@ void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info)
 
 static struct pxa_gpio_platform_data pxa27x_gpio_info __initdata = {
 	.gafr = true,
+	.nr_gpios = 121,
 	.gpio_set_wake = gpio_set_wake,
 };
 
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index 656a1bb..f6bff16 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/gpio-pxa.h>
 #include <linux/pm.h>
 #include <linux/platform_device.h>
 #include <linux/irq.h>
@@ -435,6 +436,10 @@ void __init pxa3xx_set_i2c_power_info(struct i2c_pxa_platform_data *info)
 	pxa_register_device(&pxa3xx_device_i2c_power, info);
 }
 
+static struct pxa_gpio_platform_data pxa3xx_gpio_info __initdata = {
+	.nr_gpios = 128,
+};
+
 static struct platform_device *devices[] __initdata = {
 	&pxa_device_gpio,
 	&pxa27x_device_udc,
@@ -482,8 +487,16 @@ static int __init pxa3xx_init(void)
 		register_syscore_ops(&pxa3xx_mfp_syscore_ops);
 		register_syscore_ops(&pxa3xx_clock_syscore_ops);
 
-		if (!of_have_populated_dt())
-			ret = platform_add_devices(devices, ARRAY_SIZE(devices));
+		if (!of_have_populated_dt()) {
+			if (cpu_is_pxa93x())
+				pxa3xx_gpio_info.nr_gpios = 192;
+			ret = platform_device_add_data(&pxa_device_gpio,
+					&pxa3xx_gpio_info,
+					sizeof(struct pxa_gpio_platform_data));
+			if (!ret)
+				ret = platform_add_devices(devices,
+							   ARRAY_SIZE(devices));
+		}
 	}
 
 	return ret;
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index f31509e..472c006 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -413,36 +413,6 @@ static struct irq_chip pxa_muxed_gpio_chip = {
 	.irq_set_wake	= pxa_gpio_set_wake,
 };
 
-static int pxa_gpio_nums(void)
-{
-	int count = 0;
-
-#ifdef CONFIG_ARCH_PXA
-	if (cpu_is_pxa25x()) {
-#ifdef CONFIG_CPU_PXA26x
-		count = 89;
-#elif defined(CONFIG_PXA25x)
-		count = 84;
-#endif /* CONFIG_CPU_PXA26x */
-	} else if (cpu_is_pxa27x()) {
-		count = 120;
-	} else if (cpu_is_pxa93x()) {
-		count = 191;
-	} else if (cpu_is_pxa3xx()) {
-		count = 127;
-	}
-#endif /* CONFIG_ARCH_PXA */
-
-#ifdef CONFIG_ARCH_MMP
-	if (cpu_is_pxa168() || cpu_is_pxa910()) {
-		count = 127;
-	} else if (cpu_is_mmp2()) {
-		count = 191;
-	}
-#endif /* CONFIG_ARCH_MMP */
-	return count;
-}
-
 #ifdef CONFIG_OF
 static struct of_device_id pxa_gpio_dt_ids[] = {
 	{ .compatible = "mrvl,pxa-gpio" },
@@ -466,7 +436,7 @@ const struct irq_domain_ops pxa_irq_domain_ops = {
 
 static int pxa_gpio_probe_dt(struct platform_device *pdev)
 {
-	int ret, nr_banks, nr_gpios;
+	int ret, nr_banks;
 	struct pxa_gpio_platform_data *pdata;
 	struct device_node *prev, *next, *np = pdev->dev.of_node;
 	const struct of_device_id *of_id =
@@ -484,6 +454,11 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 	/* It's only valid for PXA26x */
 	if (of_find_property(np, "marvell,gpio-inverted", NULL))
 		pdata->inverted = true;
+	ret = of_property_read_u32(np, "marvell,nr-gpios", &pdata->nr_gpios);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "nr-gpios isn't specified\n");
+		return -ENOTSUPP;
+	}
 	/* set the platform data */
 	pdev->dev.platform_data = pdata;
 
@@ -501,8 +476,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 		prev = next;
 	}
 	of_node_put(prev);
-	nr_gpios = nr_banks << 5;
-	pxa_last_gpio = nr_gpios - 1;
 
 	irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0);
 	if (irq_base < 0) {
@@ -524,12 +497,11 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct clk *clk;
 	struct pxa_gpio_platform_data *info;
-	int gpio, irq, ret, use_of = 0;
+	int gpio, irq, ret, use_of = 1;
 	int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0;
 
 	ret = pxa_gpio_probe_dt(pdev);
 	if (ret < 0) {
-		pxa_last_gpio = pxa_gpio_nums();
 #ifdef CONFIG_ARCH_PXA
 		irq_base = PXA_GPIO_TO_IRQ(0);
 #elif defined(CONFIG_ARCH_MMP)
@@ -537,13 +509,9 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 #else
 #error "gpio-pxa driver can't be used for your architecture"
 #endif
-	} else {
-		use_of = 1;
+		use_of = 0;
 	}
 
-	if (!pxa_last_gpio)
-		return -EINVAL;
-
 	irq0 = platform_get_irq_byname(pdev, "gpio0");
 	irq1 = platform_get_irq_byname(pdev, "gpio1");
 	irq_mux = platform_get_irq_byname(pdev, "gpio_mux");
@@ -576,6 +544,7 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 
 	/* Initialize GPIO chips */
 	info = dev_get_platdata(&pdev->dev);
+	pxa_last_gpio = info->nr_gpios - 1;
 	pxa_init_gpio_chip(pdev, pxa_last_gpio);
 
 	/* clear all GPIO edge detects */
diff --git a/include/linux/gpio-pxa.h b/include/linux/gpio-pxa.h
index a5670c5..d2fa8e0 100644
--- a/include/linux/gpio-pxa.h
+++ b/include/linux/gpio-pxa.h
@@ -17,6 +17,7 @@ struct pxa_gpio_platform_data {
 	bool ed_mask;	/* true means that ed_mask reg is available */
 	bool inverted;	/* only valid for PXA26x */
 	bool gafr;	/* only valid for PXA25x/PXA26x/PXA27x */
+	unsigned int nr_gpios;
 	int (*gpio_set_wake)(unsigned int gpio, unsigned int on);
 };
 
-- 
1.7.10.4

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

* [PATCH v4 06/11] gpio: pxa: add irq base in platform data
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (4 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 05/11] gpio: pxa: define nr gpios in platform data Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-20 14:08   ` Igor Grinberg
  2013-02-19 16:22 ` [PATCH v4 07/11] document: devicetree: add properties in mrvl gpio Haojian Zhuang
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Macro PXA_GPIO_TO_IRQ() & MMP_GPIO_TO_IRQ() is used in machine driver
without DT. So move them into machine driver.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 arch/arm/mach-mmp/aspenite.c      |    1 +
 arch/arm/mach-mmp/avengers_lite.c |    1 +
 arch/arm/mach-mmp/brownstone.c    |    1 +
 arch/arm/mach-mmp/flint.c         |    1 +
 arch/arm/mach-mmp/gplugd.c        |    1 +
 arch/arm/mach-mmp/tavorevb.c      |    1 +
 arch/arm/mach-mmp/teton_bga.c     |    1 +
 arch/arm/mach-mmp/ttc_dkb.c       |    1 +
 arch/arm/mach-pxa/pxa25x.c        |    1 +
 arch/arm/mach-pxa/pxa27x.c        |    1 +
 arch/arm/mach-pxa/pxa3xx.c        |    1 +
 drivers/gpio/gpio-pxa.c           |   22 +++++++++-------------
 include/linux/gpio-pxa.h          |    1 +
 13 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c
index a3e42dc..5785931 100644
--- a/arch/arm/mach-mmp/aspenite.c
+++ b/arch/arm/mach-mmp/aspenite.c
@@ -113,6 +113,7 @@ static unsigned long common_pin_config[] __initdata = {
 
 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
 	.nr_gpios	= 128,
+	.irq_base	= MMP_GPIO_TO_IRQ(0),
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/avengers_lite.c b/arch/arm/mach-mmp/avengers_lite.c
index 1ea6502..074fbbe 100644
--- a/arch/arm/mach-mmp/avengers_lite.c
+++ b/arch/arm/mach-mmp/avengers_lite.c
@@ -35,6 +35,7 @@ static unsigned long avengers_lite_pin_config_V16F[] __initdata = {
 
 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
 	.nr_gpios	= 128,
+	.irq_base	= MMP_GPIO_TO_IRQ(0),
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index a32156f..3b4224c 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -107,6 +107,7 @@ static unsigned long brownstone_pin_config[] __initdata = {
 
 static struct pxa_gpio_platform_data mmp2_gpio_pdata = {
 	.nr_gpios	= 192,
+	.irq_base	= MMP_GPIO_TO_IRQ(0),
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/flint.c b/arch/arm/mach-mmp/flint.c
index 3f301b5..00cdf62 100644
--- a/arch/arm/mach-mmp/flint.c
+++ b/arch/arm/mach-mmp/flint.c
@@ -80,6 +80,7 @@ static unsigned long flint_pin_config[] __initdata = {
 
 static struct pxa_gpio_platform_data mmp2_gpio_pdata = {
 	.nr_gpios	= 192,
+	.irq_base	= MMP_GPIO_TO_IRQ(0),
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/gplugd.c b/arch/arm/mach-mmp/gplugd.c
index 019b178..78acca4 100644
--- a/arch/arm/mach-mmp/gplugd.c
+++ b/arch/arm/mach-mmp/gplugd.c
@@ -130,6 +130,7 @@ static unsigned long gplugd_pin_config[] __initdata = {
 
 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
 	.nr_gpios	= 128,
+	.irq_base	= MMP_GPIO_TO_IRQ(0),
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/tavorevb.c b/arch/arm/mach-mmp/tavorevb.c
index 6e8cf80..86ed017 100644
--- a/arch/arm/mach-mmp/tavorevb.c
+++ b/arch/arm/mach-mmp/tavorevb.c
@@ -63,6 +63,7 @@ static unsigned long tavorevb_pin_config[] __initdata = {
 
 static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = {
 	.nr_gpios	= 128,
+	.irq_base	= MMP_GPIO_TO_IRQ(0),
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/teton_bga.c b/arch/arm/mach-mmp/teton_bga.c
index b5146bb..db65631 100644
--- a/arch/arm/mach-mmp/teton_bga.c
+++ b/arch/arm/mach-mmp/teton_bga.c
@@ -52,6 +52,7 @@ static unsigned long teton_bga_pin_config[] __initdata = {
 
 static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
 	.nr_gpios	= 128,
+	.irq_base	= MMP_GPIO_TO_IRQ(0),
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index 387e3f8..0e0ea87 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -78,6 +78,7 @@ static unsigned long ttc_dkb_pin_config[] __initdata = {
 
 static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = {
 	.nr_gpios	= 128,
+	.irq_base	= MMP_GPIO_TO_IRQ(0),
 	.ed_mask	= true,
 };
 
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index 52f94f3..2195e1a 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -346,6 +346,7 @@ static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = {
 #else
 	.nr_gpios = 85,
 #endif
+	.irq_base = PXA_GPIO_TO_IRQ(0),
 	.gafr = true,
 	.gpio_set_wake = gpio_set_wake,
 };
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index 619b2f2..cb3f443 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -433,6 +433,7 @@ void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info)
 static struct pxa_gpio_platform_data pxa27x_gpio_info __initdata = {
 	.gafr = true,
 	.nr_gpios = 121,
+	.irq_base = PXA_GPIO_TO_IRQ(0),
 	.gpio_set_wake = gpio_set_wake,
 };
 
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index f6bff16..ef0634b 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -438,6 +438,7 @@ void __init pxa3xx_set_i2c_power_info(struct i2c_pxa_platform_data *info)
 
 static struct pxa_gpio_platform_data pxa3xx_gpio_info __initdata = {
 	.nr_gpios = 128,
+	.irq_base = PXA_GPIO_TO_IRQ(0),
 };
 
 static struct platform_device *devices[] __initdata = {
diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 472c006..5879f76 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -459,8 +459,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 		dev_err(&pdev->dev, "nr-gpios isn't specified\n");
 		return -ENOTSUPP;
 	}
-	/* set the platform data */
-	pdev->dev.platform_data = pdata;
 
 	next = of_get_next_child(np, NULL);
 	prev = next;
@@ -482,6 +480,9 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n");
 		goto err;
 	}
+	pdata->irq_base = irq_base;
+	/* set the platform data */
+	pdev->dev.platform_data = pdata;
 	domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0,
 				       &pxa_irq_domain_ops, NULL);
 	pxa_gpio_of_node = np;
@@ -501,16 +502,13 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 	int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0;
 
 	ret = pxa_gpio_probe_dt(pdev);
-	if (ret < 0) {
-#ifdef CONFIG_ARCH_PXA
-		irq_base = PXA_GPIO_TO_IRQ(0);
-#elif defined(CONFIG_ARCH_MMP)
-		irq_base = MMP_GPIO_TO_IRQ(0);
-#else
-#error "gpio-pxa driver can't be used for your architecture"
-#endif
+	if (ret < 0)
 		use_of = 0;
-	}
+	info = dev_get_platdata(&pdev->dev);
+	pxa_last_gpio = info->nr_gpios - 1;
+	irq_base = info->irq_base;
+	if (pxa_last_gpio <=0 || irq_base <= 0)
+		return -EINVAL;
 
 	irq0 = platform_get_irq_byname(pdev, "gpio0");
 	irq1 = platform_get_irq_byname(pdev, "gpio1");
@@ -543,8 +541,6 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 	}
 
 	/* Initialize GPIO chips */
-	info = dev_get_platdata(&pdev->dev);
-	pxa_last_gpio = info->nr_gpios - 1;
 	pxa_init_gpio_chip(pdev, pxa_last_gpio);
 
 	/* clear all GPIO edge detects */
diff --git a/include/linux/gpio-pxa.h b/include/linux/gpio-pxa.h
index d2fa8e0..82c3e73 100644
--- a/include/linux/gpio-pxa.h
+++ b/include/linux/gpio-pxa.h
@@ -18,6 +18,7 @@ struct pxa_gpio_platform_data {
 	bool inverted;	/* only valid for PXA26x */
 	bool gafr;	/* only valid for PXA25x/PXA26x/PXA27x */
 	unsigned int nr_gpios;
+	unsigned int irq_base;
 	int (*gpio_set_wake)(unsigned int gpio, unsigned int on);
 };
 
-- 
1.7.10.4

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

* [PATCH v4 07/11] document: devicetree: add properties in mrvl gpio
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (5 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 06/11] gpio: pxa: add irq base " Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-19 16:22 ` [PATCH v4 08/11] gpio: pxa: remove arch related macro Haojian Zhuang
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Append new properties for mrvl gpio. They're in below.
marvell,gpio-ed-mask marvell,gpio-inverted & marvell,nr_gpios.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 Documentation/devicetree/bindings/gpio/mrvl-gpio.txt |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Documentation/devicetree/bindings/gpio/mrvl-gpio.txt b/Documentation/devicetree/bindings/gpio/mrvl-gpio.txt
index e137874..8cd5252 100644
--- a/Documentation/devicetree/bindings/gpio/mrvl-gpio.txt
+++ b/Documentation/devicetree/bindings/gpio/mrvl-gpio.txt
@@ -14,6 +14,13 @@ Required properties:
   interrupt source.
 - gpio-controller : Marks the device node as a gpio controller.
 - #gpio-cells : Should be one.  It is the pin number.
+- marvell,nr-gpios : Should be the number of total gpio pins.
+
+Optional properties:
+- marvell,gpio-ed-mask : It means that there's gpio edge mask register.
+  It only exists in mmp family SoC.
+- marvell,gpio-inverted : It means that some gpio pins are inverted.
+  It only exists in PXA26x SoC.
 
 Example:
 
@@ -26,6 +33,8 @@ Example:
 		#gpio-cells = <1>;
 		interrupt-controller;
 		#interrupt-cells = <1>;
+		marvell,gpio-ed-mask;
+		marvell,nr-gpios = <128>;
       };
 
 * Marvell Orion GPIO Controller
-- 
1.7.10.4

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

* [PATCH v4 08/11] gpio: pxa: remove arch related macro
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (6 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 07/11] document: devicetree: add properties in mrvl gpio Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-20 14:13   ` Igor Grinberg
  2013-02-19 16:22 ` [PATCH v4 09/11] gpio: pxa: move gpio properties into child node Haojian Zhuang
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Remove macro CONFIG_ARCH_PXA.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 drivers/gpio/gpio-pxa.c |   30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 5879f76..983758f 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -557,21 +557,21 @@ static int pxa_gpio_probe(struct platform_device *pdev)
 	}
 
 	if (!use_of) {
-#ifdef CONFIG_ARCH_PXA
-		irq = gpio_to_irq(0);
-		irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip,
-					 handle_edge_irq);
-		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
-		irq_set_chained_handler(IRQ_GPIO0, pxa_gpio_demux_handler);
-
-		irq = gpio_to_irq(1);
-		irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip,
-					 handle_edge_irq);
-		set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
-		irq_set_chained_handler(IRQ_GPIO1, pxa_gpio_demux_handler);
-#endif
-
-		for (irq  = gpio_to_irq(gpio_offset);
+		if (irq0 > 0) {
+			irq = gpio_to_irq(0);
+			irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip,
+						 handle_edge_irq);
+			set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
+			irq_set_chained_handler(irq0, pxa_gpio_demux_handler);
+		}
+		if (irq1 > 0) {
+			irq = gpio_to_irq(1);
+			irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip,
+						 handle_edge_irq);
+			set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
+			irq_set_chained_handler(irq1, pxa_gpio_demux_handler);
+		}
+		for (irq = gpio_to_irq(gpio_offset);
 			irq <= gpio_to_irq(pxa_last_gpio); irq++) {
 			irq_set_chip_and_handler(irq, &pxa_muxed_gpio_chip,
 						 handle_edge_irq);
-- 
1.7.10.4

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

* [PATCH v4 09/11] gpio: pxa: move gpio properties into child node
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (7 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 08/11] gpio: pxa: remove arch related macro Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-20 14:17   ` Igor Grinberg
  2013-02-19 16:22 ` [PATCH v4 10/11] gpio: pxa: bind to pinctrl by request Haojian Zhuang
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Move gpio properties into child node. So pinctrl driver could binds to
each gpio chip with gpio range.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 drivers/gpio/gpio-pxa.c |   44 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 983758f..0f3a350 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -65,7 +65,6 @@ static int irq_base;
 
 #ifdef CONFIG_OF
 static struct irq_domain *domain;
-static struct device_node *pxa_gpio_of_node;
 #endif
 
 struct pxa_gpio_chip {
@@ -233,8 +232,9 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc,
 static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end)
 {
 	int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1;
-	struct pxa_gpio_chip *chips;
 	struct pxa_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev);
+	struct pxa_gpio_chip *chips;
+	struct device_node *next = NULL, *np = NULL;
 
 	chips = devm_kzalloc(&pdev->dev, nbanks * sizeof(*chips), GFP_KERNEL);
 	if (!chips) {
@@ -242,6 +242,11 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end)
 		return -ENOMEM;
 	}
 
+	np = pdev->dev.of_node;
+#ifdef CONFIG_OF
+	if (np)
+		next = of_get_next_child(np, NULL);
+#endif
 	for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) {
 		struct gpio_chip *gc = &chips[i].gc;
 
@@ -258,16 +263,21 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end)
 		gc->get = pxa_gpio_get;
 		gc->set = pxa_gpio_set;
 		gc->to_irq = pxa_gpio_to_irq;
-#ifdef CONFIG_OF_GPIO
-		gc->of_node = pxa_gpio_of_node;
-		gc->of_xlate = pxa_gpio_of_xlate;
-		gc->of_gpio_n_cells = 2;
+#ifdef CONFIG_OF
+		if (np) {
+			gc->of_node = next;
+			next = of_get_next_child(np, next);
+
+			gc->of_xlate = pxa_gpio_of_xlate;
+			gc->of_gpio_n_cells = 2;
+		}
 #endif
 
 		/* number of GPIOs on last bank may be less than 32 */
 		gc->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32;
 		gpiochip_add(gc);
 	}
+	of_node_put(next);
 	pxa_gpio_chips = chips;
 	return 0;
 }
@@ -436,9 +446,9 @@ const struct irq_domain_ops pxa_irq_domain_ops = {
 
 static int pxa_gpio_probe_dt(struct platform_device *pdev)
 {
-	int ret, nr_banks;
+	int ret;
 	struct pxa_gpio_platform_data *pdata;
-	struct device_node *prev, *next, *np = pdev->dev.of_node;
+	struct device_node *np = pdev->dev.of_node;
 	const struct of_device_id *of_id =
 				of_match_device(pxa_gpio_dt_ids, &pdev->dev);
 
@@ -460,32 +470,16 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
 		return -ENOTSUPP;
 	}
 
-	next = of_get_next_child(np, NULL);
-	prev = next;
-	if (!next) {
-		dev_err(&pdev->dev, "Failed to find child gpio node\n");
-		ret = -EINVAL;
-		goto err;
-	}
-	for (nr_banks = 1; ; nr_banks++) {
-		next = of_get_next_child(np, prev);
-		if (!next)
-			break;
-		prev = next;
-	}
-	of_node_put(prev);
-
 	irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0);
 	if (irq_base < 0) {
 		dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n");
-		goto err;
+		return -EINVAL;
 	}
 	pdata->irq_base = irq_base;
 	/* set the platform data */
 	pdev->dev.platform_data = pdata;
 	domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0,
 				       &pxa_irq_domain_ops, NULL);
-	pxa_gpio_of_node = np;
 	return 0;
 }
 #else
-- 
1.7.10.4

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

* [PATCH v4 10/11] gpio: pxa: bind to pinctrl by request
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (8 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 09/11] gpio: pxa: move gpio properties into child node Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-20 14:26   ` Igor Grinberg
  2013-02-19 16:22 ` [PATCH v4 11/11] ARM: dts: support pinmux in pxa910 Haojian Zhuang
  2013-02-20 14:31 ` [PATCH v4 00/11] enhance DT support on gpio pxa Igor Grinberg
  11 siblings, 1 reply; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

While gpio pins is requested, request the pin of pinctrl driver first.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 drivers/gpio/gpio-pxa.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index 0f3a350..8cf7814 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -22,6 +22,7 @@
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/syscore_ops.h>
 #include <linux/slab.h>
@@ -154,6 +155,23 @@ int pxa_irq_to_gpio(int irq)
 	return irq - irq_base;
 }
 
+static int pxa_gpio_request(struct gpio_chip *gc, unsigned offset)
+{
+	/*
+	 * Map back to global GPIO space and request muxing, the direction
+	 * parameter does not matter for this controller.
+	 */
+	int gpio = gc->base + offset;
+
+	/*
+	 * Platforms in ARCH_PXA doesn't move to device tree yet,
+	 * and PINCTRL_SINGLE is depend on device tree.
+	 */ 
+	if (IS_ENABLED(CONFIG_PINCTRL_SINGLE))
+		return pinctrl_request_gpio(gpio);
+	return 0;
+}
+
 static int pxa_gpio_direction_input(struct gpio_chip *gc, unsigned offset)
 {
 	void __iomem *base = gpio_chip_base(gc);
@@ -258,6 +276,7 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end)
 		gc->base  = gpio;
 		gc->label = chips[i].label;
 
+		gc->request = pxa_gpio_request;
 		gc->direction_input  = pxa_gpio_direction_input;
 		gc->direction_output = pxa_gpio_direction_output;
 		gc->get = pxa_gpio_get;
-- 
1.7.10.4

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

* [PATCH v4 11/11] ARM: dts: support pinmux in pxa910
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (9 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 10/11] gpio: pxa: bind to pinctrl by request Haojian Zhuang
@ 2013-02-19 16:22 ` Haojian Zhuang
  2013-02-20 14:31 ` [PATCH v4 00/11] enhance DT support on gpio pxa Igor Grinberg
  11 siblings, 0 replies; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-19 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

Add gpio range, pinmux settings in pxa910 dkb DTS file.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 arch/arm/boot/dts/pxa910-dkb.dts |  248 ++++++++++++++++++++++++++++++++++++++
 arch/arm/boot/dts/pxa910.dtsi    |   29 ++++-
 2 files changed, 275 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/pxa910-dkb.dts b/arch/arm/boot/dts/pxa910-dkb.dts
index 595492a..04db0b6 100644
--- a/arch/arm/boot/dts/pxa910-dkb.dts
+++ b/arch/arm/boot/dts/pxa910-dkb.dts
@@ -170,6 +170,254 @@
 			rtc: rtc at d4010000 {
 				status = "okay";
 			};
+			gpio-keys {
+				compatible = "gpio-keys";
+
+				/* in6, out3, out4 */
+				right {
+					label = "right";
+					gpios = <&gcb0 12 0>;
+					linux,code = <106>;	/* KEY_RIGHT */
+				};
+				num5 {
+					label = "5";
+					gpios = <&gcb0 4 0>;
+					linux,code = <6>;	/* KEY_5 */
+				};
+			};
+			gpio at d4019000 {
+				status = "okay";
+
+				/*
+				 * In theorical, some gpios could be routed to
+				 * multiple pins. So define the gpio-ranges in
+				 * board file, not silicon file.
+				 */
+				gcb0: gpio at d4019000 {
+					/* <gpio_offset, pin_offset, nr_pins> */
+					gpio-ranges = <&pmx 0 55 32>;
+				};
+				gcb1: gpio at d4019004 {
+					/* <gpio_offset, pin_offset, nr_pins> */
+					gpio-ranges = <&pmx 0 87 23 &pmx 23 188 9>;
+				};
+				gcb2: gpio at d4019008 {
+					/* <gpio_offset, pin_offset, nr_pins> */
+					gpio-ranges = <&pmx 0 197 3 &pmx 3 110 29>;
+				};
+				gcb3: gpio at d4019100 {
+					/* <gpio_offset, pin_offset, nr_pins> */
+					gpio-ranges = < &pmx 0 139 14 &pmx 14 166 7
+							&pmx 21 45 4 &pmx 25 203 1
+							&pmx 26 50 4 &pmx 30 27 2>;
+				};
+			};
+			pmx: pinmux at d401e000 {
+				/* pin base, nr pins & gpio function */
+				pinctrl-single,gpio-range = <
+					/*
+					 * GPIO number is hardcoded for range@here.
+					 * In gpio chip, GPIO number is not hardcoded for range.
+					 * Since one gpio pin may be routed to multiple pins,
+					 * define these gpio range in pxa910-dkb.dts not pxa910.dtsi.
+					 */
+						&range 55 55 0	/* GPIO0 ~ GPIO54 */
+						&range 188 5 1	/* GPIO55 ~ GPIO59 */ 
+						&range 193 7 0	/* GPIO60 ~ GPIO66 */
+						&range 110 43 0	/* GPIO67 ~ GPIO109 */
+						&range 166 7 0	/* GPIO110 ~ GPIO116 */
+						&range 45 4 0	/* GPIO117 ~ GPIO120 */
+						&range 50 2 1	/* GPIO122 ~ GPIO123 */
+						&range 203 1 0	/* GPIO121 */
+						&range 52 1 0	/* GPIO124 */
+						&range 53 1 1	/* GPIO125 */
+						&range 27 2 0	/* GPIO126 ~ GPIO127 */
+					>;
+
+				pinctrl-names = "default";
+				pinctrl-0 = <&keypad_pmx_func>;
+
+				uart1_pmx_func: pinmux_uart1_pins at 0 {
+					pinctrl-single,pins = <
+						0x198 0x6	/* GPIO47_UART1_RXD */
+						0x19c 0x6	/* GPIO48_UART1_TXD */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0xc000 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				uart2_pmx_func: pinmux_uart2_pins at 0 {
+					pinctrl-single,pins = <
+						0x150 0x4	/* GPIO29_UART2_CTS */
+						0x154 0x4	/* GPIO30_UART2_RTS */
+						0x158 0x4	/* GPIO31_UART2_TXD */
+						0x15c 0x4	/* GPIO32_UART2_RXD */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				uart3_pmx_func: pinmux_uart3_pins at 0 {
+					pinctrl-single,pins = <
+						0x188 0x7	/* GPIO43_UART3_RXD */
+						0x18c 0x7	/* GPIO44_UART3_TXD */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				twsi1_pmx_func: pinmux_twsi1_pins at 0 {
+					pinctrl-single,pins = <
+						0x1b0 0x2	/* GPIO53_TWSI_SCL */
+						0x1b4 0x2	/* GPIO54_TWSI_SDA */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				nand_pmx_func: pinmux_nand_pins at 0 {
+					pinctrl-single,pins = <
+						0x040 0x0	/* ND_IO0 */
+						0x03c 0x0	/* ND_IO1 */
+						0x038 0x0	/* ND_IO2 */
+						0x034 0x0	/* ND_IO3 */
+						0x030 0x0	/* ND_IO4 */
+						0x02c 0x0	/* ND_IO5 */
+						0x028 0x0	/* ND_IO6 */
+						0x024 0x0	/* ND_IO7 */
+						0x020 0x0	/* ND_IO8 */
+						0x01c 0x0	/* ND_IO9 */
+						0x018 0x0	/* ND_IO10 */
+						0x014 0x0	/* ND_IO11 */
+						0x010 0x0	/* ND_IO12 */
+						0x00c 0x0	/* ND_IO13 */
+						0x008 0x0	/* ND_IO14 */
+						0x004 0x0	/* ND_IO15 */
+						0x044 0x0	/* ND_nCS0 */
+						0x060 0x1	/* ND_ALE */
+						0x05c 0x0	/* ND_CLE */
+						0x054 0x1	/* ND_nWE */
+						0x058 0x1	/* ND_nRE */
+						0x068 0x0	/* ND_RDY0 */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				mmc1_pmx_func1: pinmux_mmc1_pins at 0 {
+					pinctrl-single,pins = <
+						0x0a0 0x0	/* MMC1_DATA0 */
+						0x09c 0x0	/* MMC1_DATA1 */
+						0x098 0x0	/* MMC1_DATA2 */
+						0x094 0x0	/* MMC1_DATA3 */
+						0x090 0x0	/* MMC1_DATA4 */
+						0x08c 0x0	/* MMC1_DATA5 */
+						0x088 0x0	/* MMC1_DATA6 */
+						0x084 0x0	/* MMC1_DATA7 */
+						0x0a4 0x0	/* MMC1_CMD */
+						0x0a8 0x0	/* MMC1_CLK */
+					>;
+					pinctrl-single,slew-rate = <0x1800 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				mmc1_pmx_func2: pinmux_mmc1_pins at 1 {
+					pinctrl-single,pins = <
+						0x0ac 0x0	/* MMC1_CD */
+						0x0b0 0x0	/* MMC1_WP */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				mmc2_pmx_func: pinmux_mmc2_pins at 0 {
+					pinctrl-single,pins = <
+						0x180 0x1	/* MMC2_CMD */
+						0x184 0x1	/* MMC2_CLK */
+						0x17c 0x1	/* MMC2_DATA0 */
+						0x178 0x1	/* MMC2_DATA1 */
+						0x174 0x1	/* MMC2_DATA2 */
+						0x170 0x1	/* MMC2_DATA3 */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				ssp1_pmx_func: pinmux_ssp1_pins at 0 {
+					pinctrl-single,pins = <
+						0x130 0x1	/* GPIO21_SSP1_SCLK */
+						0x134 0x1	/* GPIO22_SSP1_FRM */
+						0x138 0x1	/* GPIO23_SSP1_TXD */
+						0x13c 0x1	/* GPIO24_SSP1_RXD */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				keypad_pmx_func: pinmux_keypad_pins at 0 {
+					pinctrl-single,pins = <
+						0x0dc 0x1	/* GPIO0_MKIN0 */
+						0x0e0 0x1	/* GPIO1_MKOUT0 */
+						0x0e4 0x1	/* GPIO2_MKIN1 */
+						0x0e8 0x1	/* GPIO3_MKOUT1 */
+						0x0ec 0x1	/* GPIO4_MKIN2 */
+						0x0f0 0x1	/* GPIO5_MKOUT2 */
+						0x0f4 0x1	/* GPIO6_MKIN3 */
+						0x0f8 0x1	/* GPIO7_MKOUT3 */
+						0x0fc 0x1	/* GPIO8_MKIN4 */
+						0x100 0x1	/* GPIO9_MKOUT4 */
+						0x10c 0x1	/* GPIO12_MKIN6 */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0xa000 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				nfc_pmx_func: pinmux_nfc_pins at 0 {
+					pinctrl-single,pins = <
+						0x120 0x0	/* GPIO17 */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0x0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+				wlan_pmx_func: pinmux_wlan_pins at 0 {
+					pinctrl-single,pins = <
+						0x114 0x0	/* GPIO14 */
+						0x12c 0x0	/* GPIO20 */
+						0x160 0x0	/* GPIO33 */
+						0x164 0x0	/* GPIO34 */
+						0x168 0x0	/* GPIO35 */
+						0x16c 0x0	/* GPIO36 */
+					>;
+					pinctrl-single,slew-rate = <0x1000 0x1800>;
+					pinctrl-single,bias-pullup = <0 0xc000 0 0xc000>;
+					pinctrl-single,bias-pulldown = <0 0xa000 0 0xa000>;
+					pinctrl-single,input-schmitt = <0 0x30>;
+					pinctrl-single,input-schmitt-enable = <0x40 0 0x40 0x40>;
+				};
+			};
 		};
 	};
 };
diff --git a/arch/arm/boot/dts/pxa910.dtsi b/arch/arm/boot/dts/pxa910.dtsi
index 825aaca..20a3418 100644
--- a/arch/arm/boot/dts/pxa910.dtsi
+++ b/arch/arm/boot/dts/pxa910.dtsi
@@ -93,28 +93,37 @@
 				#address-cells = <1>;
 				#size-cells = <1>;
 				reg = <0xd4019000 0x1000>;
-				gpio-controller;
-				#gpio-cells = <2>;
+				marvell,gpio-ed-mask = <1>;
+				marvell,nr-gpios = <128>;
 				interrupts = <49>;
 				interrupt-names = "gpio_mux";
 				interrupt-controller;
 				#interrupt-cells = <1>;
+				status = "disabled";
 				ranges;
 
 				gcb0: gpio at d4019000 {
 					reg = <0xd4019000 0x4>;
+					gpio-controller;
+					#gpio-cells = <2>;
 				};
 
 				gcb1: gpio at d4019004 {
 					reg = <0xd4019004 0x4>;
+					gpio-controller;
+					#gpio-cells = <2>;
 				};
 
 				gcb2: gpio at d4019008 {
 					reg = <0xd4019008 0x4>;
+					gpio-controller;
+					#gpio-cells = <2>;
 				};
 
 				gcb3: gpio at d4019100 {
 					reg = <0xd4019100 0x4>;
+					gpio-controller;
+					#gpio-cells = <2>;
 				};
 			};
 
@@ -144,6 +153,22 @@
 				interrupt-names = "rtc 1Hz", "rtc alarm";
 				status = "disabled";
 			};
+
+			pmx: pinmux at d401e000 {
+				compatible = "pinconf-single";
+				reg = <0xd401e000 0x330>;
+				#address-cells = <1>;
+				#size-cells = <1>;
+				#gpio-range-cells = <3>;
+				ranges;
+
+				pinctrl-single,register-width = <32>;
+				pinctrl-single,function-mask = <7>;
+
+				range: gpio-range {
+					#pinctrl-single,gpio-range-cells = <3>;
+				};
+			};
 		};
 	};
 };
-- 
1.7.10.4

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

* [PATCH v4 02/11] gpio: pxa: clean code with same variable name
  2013-02-19 16:22 ` [PATCH v4 02/11] gpio: pxa: clean code with same variable name Haojian Zhuang
@ 2013-02-20  8:13   ` Igor Grinberg
       [not found]     ` <CAD6h2NQy4LAoUkS=b301huXRJ_kyPcMxoC8E99dud7d-842=cw@mail.gmail.com>
  0 siblings, 1 reply; 24+ messages in thread
From: Igor Grinberg @ 2013-02-20  8:13 UTC (permalink / raw)
  To: linux-arm-kernel

On 02/19/13 18:22, Haojian Zhuang wrote:
> Clean code to avoid similar variable. Now use gc for gpio_chip,
> and use c/chip for pxa_gpio_chip. It's used to avoid confusion.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Tested-by: Igor Grinberg <grinberg@compulab.co.il>

Minor issue below for your consideration.

> ---
>  drivers/gpio/gpio-pxa.c |  102 +++++++++++++++++++++++------------------------
>  1 file changed, 50 insertions(+), 52 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
> index a4c6687..e611bed 100644
> --- a/drivers/gpio/gpio-pxa.c
> +++ b/drivers/gpio/gpio-pxa.c

[...]

> @@ -147,7 +147,7 @@ static inline int __gpio_is_occupied(unsigned gpio)
>  	int ret, af = 0, dir = 0;
>  
>  	pxachip = gpio_to_pxachip(gpio);
> -	base = gpio_chip_base(&pxachip->chip);
> +	base = gpio_chip_base(&pxachip->gc);

I don't mind leaving this as it is, but according
to your commit message, the above should be:
c/chip = gpio_to_pxachip(gpio);
base = gpio_chip_base(&c/chip->gc);

For your consideration.

>  	gpdr = readl_relaxed(base + GPDR_OFFSET);
>  
>  	switch (gpio_type) {

[...]


-- 
Regards,
Igor.

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

* [PATCH v4 04/11] gpio: pxa: remove gpio_type
  2013-02-19 16:22 ` [PATCH v4 04/11] gpio: pxa: remove gpio_type Haojian Zhuang
@ 2013-02-20  8:18   ` Igor Grinberg
  2013-03-01  0:33   ` Linus Walleij
  1 sibling, 0 replies; 24+ messages in thread
From: Igor Grinberg @ 2013-02-20  8:18 UTC (permalink / raw)
  To: linux-arm-kernel



On 02/19/13 18:22, Haojian Zhuang wrote:
> Since gpio_type is used to check whether gafr register is valid. So
> move it into platform data.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Tested-by: Igor Grinberg <grinberg@compulab.co.il>

-- 
Regards,
Igor.

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

* [PATCH v4 05/11] gpio: pxa: define nr gpios in platform data
  2013-02-19 16:22 ` [PATCH v4 05/11] gpio: pxa: define nr gpios in platform data Haojian Zhuang
@ 2013-02-20 14:02   ` Igor Grinberg
  0 siblings, 0 replies; 24+ messages in thread
From: Igor Grinberg @ 2013-02-20 14:02 UTC (permalink / raw)
  To: linux-arm-kernel

On 02/19/13 18:22, Haojian Zhuang wrote:
> Avoid to identify gpio numbers in gpio driver. Identify it in platform data
> instead. So we can remove code of identifying cpu.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Tested-by: Igor Grinberg <grinberg@compulab.co.il>

-- 
Regards,
Igor.

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

* [PATCH v4 06/11] gpio: pxa: add irq base in platform data
  2013-02-19 16:22 ` [PATCH v4 06/11] gpio: pxa: add irq base " Haojian Zhuang
@ 2013-02-20 14:08   ` Igor Grinberg
  0 siblings, 0 replies; 24+ messages in thread
From: Igor Grinberg @ 2013-02-20 14:08 UTC (permalink / raw)
  To: linux-arm-kernel



On 02/19/13 18:22, Haojian Zhuang wrote:
> Macro PXA_GPIO_TO_IRQ() & MMP_GPIO_TO_IRQ() is used in machine driver
> without DT. So move them into machine driver.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Tested-by: Igor Grinberg <grinberg@compulab.co.il>


-- 
Regards,
Igor.

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

* [PATCH v4 08/11] gpio: pxa: remove arch related macro
  2013-02-19 16:22 ` [PATCH v4 08/11] gpio: pxa: remove arch related macro Haojian Zhuang
@ 2013-02-20 14:13   ` Igor Grinberg
  0 siblings, 0 replies; 24+ messages in thread
From: Igor Grinberg @ 2013-02-20 14:13 UTC (permalink / raw)
  To: linux-arm-kernel



On 02/19/13 18:22, Haojian Zhuang wrote:
> Remove macro CONFIG_ARCH_PXA.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Tested-by: Igor Grinberg <grinberg@compulab.co.il>

-- 
Regards,
Igor.

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

* [PATCH v4 09/11] gpio: pxa: move gpio properties into child node
  2013-02-19 16:22 ` [PATCH v4 09/11] gpio: pxa: move gpio properties into child node Haojian Zhuang
@ 2013-02-20 14:17   ` Igor Grinberg
  0 siblings, 0 replies; 24+ messages in thread
From: Igor Grinberg @ 2013-02-20 14:17 UTC (permalink / raw)
  To: linux-arm-kernel



On 02/19/13 18:22, Haojian Zhuang wrote:
> Move gpio properties into child node. So pinctrl driver could binds to
> each gpio chip with gpio range.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

non-DT:
Tested-by: Igor Grinberg <grinberg@compulab.co.il>


-- 
Regards,
Igor.

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

* [PATCH v4 10/11] gpio: pxa: bind to pinctrl by request
  2013-02-19 16:22 ` [PATCH v4 10/11] gpio: pxa: bind to pinctrl by request Haojian Zhuang
@ 2013-02-20 14:26   ` Igor Grinberg
  0 siblings, 0 replies; 24+ messages in thread
From: Igor Grinberg @ 2013-02-20 14:26 UTC (permalink / raw)
  To: linux-arm-kernel



On 02/19/13 18:22, Haojian Zhuang wrote:
> While gpio pins is requested, request the pin of pinctrl driver first.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

non-DT:
Tested-by: Igor Grinberg <grinberg@compulab.co.il>

-- 
Regards,
Igor.

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

* [PATCH v4 00/11] enhance DT support on gpio pxa
  2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
                   ` (10 preceding siblings ...)
  2013-02-19 16:22 ` [PATCH v4 11/11] ARM: dts: support pinmux in pxa910 Haojian Zhuang
@ 2013-02-20 14:31 ` Igor Grinberg
       [not found]   ` <CAD6h2NTe5K=6fKkm=n=ZawjhoR+_sOe5McX2soT7_Af22wKvDg@mail.gmail.com>
  11 siblings, 1 reply; 24+ messages in thread
From: Igor Grinberg @ 2013-02-20 14:31 UTC (permalink / raw)
  To: linux-arm-kernel

On 02/19/13 18:22, Haojian Zhuang wrote:
> Changelog:
> 
> v4:
> * Re-oragnize these patches.
> * Append document for new properties binding.
> * Discard the full support on irq domain. It will be appended in other
>   series.

Thanks Haojian.

I've tested these series on PXA3xx and PXA270 (non-DT configuration)
and it proved to be working - at least no new regressions are seen.
I've sent tested-bys to the relevant patches and IMHO this can be merged.

Linus, I wonder if you still can get this into 3.9?

> 
> v3:
> * Fix the gpio irq issue on legacy platform.
> * Discard irq_base & use irq domain instead in pxa_gpio_chip structure.
> * Update DTS file since it's depend on latest pinctrl single driver.
> 
> v2:
> * Fix the build issue without CONFIG_OF
> * Append to check PINCTRL_SINGLE because of arch pxa not moved to DT
> * Use bool for inverted, ed_mask, gafr variable


-- 
Regards,
Igor.

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

* [PATCH v4 00/11] enhance DT support on gpio pxa
       [not found]   ` <CAD6h2NTe5K=6fKkm=n=ZawjhoR+_sOe5McX2soT7_Af22wKvDg@mail.gmail.com>
@ 2013-02-22 17:30     ` Linus Walleij
  2013-02-25  3:45       ` Haojian Zhuang
  0 siblings, 1 reply; 24+ messages in thread
From: Linus Walleij @ 2013-02-22 17:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Feb 20, 2013 at 4:58 PM, Haojian Zhuang
<haojian.zhuang@linaro.org> wrote:

>> Linus, I wonder if you still can get this into 3.9?
>>
> Now it's a little late. So let's see them in 3.10.

Sorry no chance for v3.9.

But I'm sad that you dropped the irqdomain patches. I'd really
like to have that as part of the patch set.

I'm not merging anything right now during the merge window,
and I'm travelling as well, so I recommend you make a v5 which
is complete in the sense that it includes a patch that switches
the result to use irqdomain as well.

Sorry for all the back-and-forth. :-/

Yours,
Linus Walleij

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

* [PATCH v4 00/11] enhance DT support on gpio pxa
  2013-02-22 17:30     ` Linus Walleij
@ 2013-02-25  3:45       ` Haojian Zhuang
  0 siblings, 0 replies; 24+ messages in thread
From: Haojian Zhuang @ 2013-02-25  3:45 UTC (permalink / raw)
  To: linux-arm-kernel

On 23 February 2013 01:30, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Feb 20, 2013 at 4:58 PM, Haojian Zhuang
> <haojian.zhuang@linaro.org> wrote:
>
>>> Linus, I wonder if you still can get this into 3.9?
>>>
>> Now it's a little late. So let's see them in 3.10.
>
> Sorry no chance for v3.9.
>
> But I'm sad that you dropped the irqdomain patches. I'd really
> like to have that as part of the patch set.
>
> I'm not merging anything right now during the merge window,
> and I'm travelling as well, so I recommend you make a v5 which
> is complete in the sense that it includes a patch that switches
> the result to use irqdomain as well.
>
> Sorry for all the back-and-forth. :-/
>
> Yours,
> Linus Walleij

We have two months for 3.10. I'll append irqdomain support later
since I don't have enough time on debugging the irq issue.

Let's focus on the DT patches first. Then I could finish the irqdomain
patch based on them.

Regards
Haojian

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

* [PATCH v4 04/11] gpio: pxa: remove gpio_type
  2013-02-19 16:22 ` [PATCH v4 04/11] gpio: pxa: remove gpio_type Haojian Zhuang
  2013-02-20  8:18   ` Igor Grinberg
@ 2013-03-01  0:33   ` Linus Walleij
  1 sibling, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2013-03-01  0:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Feb 19, 2013 at 5:22 PM, Haojian Zhuang
<haojian.zhuang@linaro.org> wrote:

> Since gpio_type is used to check whether gafr register is valid. So
> move it into platform data.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Hm didn't I already ACK this? (hint, changelog maybe?)

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* [PATCH v4 02/11] gpio: pxa: clean code with same variable name
       [not found]     ` <CAD6h2NQy4LAoUkS=b301huXRJ_kyPcMxoC8E99dud7d-842=cw@mail.gmail.com>
@ 2013-03-01  0:37       ` Linus Walleij
  0 siblings, 0 replies; 24+ messages in thread
From: Linus Walleij @ 2013-03-01  0:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Feb 20, 2013 at 3:17 PM, Haojian Zhuang
<haojian.zhuang@linaro.org> wrote:

> Linus,
> Could you help to review these patches and give an Ack?

Can you provide a changelog to what was changed in each
patch for the various versions? Else I have to go back and
check my own replies to see if comments have been taken into
account.

For example I asked if the of_property_read_bool() function
could be used in a few places and this seems to have been
ignored and now I want to know why.

Yours,
Linus Walleij

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

end of thread, other threads:[~2013-03-01  0:37 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-19 16:22 [PATCH v4 00/11] enhance DT support on gpio pxa Haojian Zhuang
2013-02-19 16:22 ` [PATCH v4 01/11] gpio: pxa: identify ed mask reg with platform data Haojian Zhuang
2013-02-19 16:22 ` [PATCH v4 02/11] gpio: pxa: clean code with same variable name Haojian Zhuang
2013-02-20  8:13   ` Igor Grinberg
     [not found]     ` <CAD6h2NQy4LAoUkS=b301huXRJ_kyPcMxoC8E99dud7d-842=cw@mail.gmail.com>
2013-03-01  0:37       ` Linus Walleij
2013-02-19 16:22 ` [PATCH v4 03/11] gpio: pxa: use platform data for gpio inverted Haojian Zhuang
2013-02-19 16:22 ` [PATCH v4 04/11] gpio: pxa: remove gpio_type Haojian Zhuang
2013-02-20  8:18   ` Igor Grinberg
2013-03-01  0:33   ` Linus Walleij
2013-02-19 16:22 ` [PATCH v4 05/11] gpio: pxa: define nr gpios in platform data Haojian Zhuang
2013-02-20 14:02   ` Igor Grinberg
2013-02-19 16:22 ` [PATCH v4 06/11] gpio: pxa: add irq base " Haojian Zhuang
2013-02-20 14:08   ` Igor Grinberg
2013-02-19 16:22 ` [PATCH v4 07/11] document: devicetree: add properties in mrvl gpio Haojian Zhuang
2013-02-19 16:22 ` [PATCH v4 08/11] gpio: pxa: remove arch related macro Haojian Zhuang
2013-02-20 14:13   ` Igor Grinberg
2013-02-19 16:22 ` [PATCH v4 09/11] gpio: pxa: move gpio properties into child node Haojian Zhuang
2013-02-20 14:17   ` Igor Grinberg
2013-02-19 16:22 ` [PATCH v4 10/11] gpio: pxa: bind to pinctrl by request Haojian Zhuang
2013-02-20 14:26   ` Igor Grinberg
2013-02-19 16:22 ` [PATCH v4 11/11] ARM: dts: support pinmux in pxa910 Haojian Zhuang
2013-02-20 14:31 ` [PATCH v4 00/11] enhance DT support on gpio pxa Igor Grinberg
     [not found]   ` <CAD6h2NTe5K=6fKkm=n=ZawjhoR+_sOe5McX2soT7_Af22wKvDg@mail.gmail.com>
2013-02-22 17:30     ` Linus Walleij
2013-02-25  3:45       ` Haojian Zhuang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.