Skip to contentSkip to conversation

gpio: ab8500: Bring AB8500 back to life

PATCH In review Lee Jones 3 participants 28 messages Dec 14, 2012 – Jan 4, 2013

Subsystems (2)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

cover gpio: ab8500: Bring AB8500 back to life

The ab8500 GPIO driver is currently 'BROKEN', due to a lack of updates and recent frame-work adoption. This patch-set aims to bring the driver back to life so we may make use of it again.

This first stage is to bring it into line with ST-Ericsson's internal track, which has been keeping up-to-date. After these patches have been accepted I will then overhaul the driver to use the most recent APIs and frame-works, such as pinctrl and Device Tree.

Please give these patches an easy ride. I know they're not perfect, but they do provide a great base on with I can form the overhaul. Thanks for your understanding.

author
#1 lore raw

PATCH 1/21 gpio: ab8500: Activate and port AB8500 GPIO driver to new framework

From: Philippe Langlais <[email protected]>

The AB8500 GPIO driver is currently marked as broken, as it's still using the old framework. This patch brings it back up to scratch and enables it so we can make good use of it once more.

---
 drivers/gpio/Kconfig       |    2 +-
 drivers/gpio/gpio-ab8500.c |   60 +++++++++++++++++++++++---------------------
 2 files changed, 32 insertions(+), 30 deletions(-)
drivers/gpio/Kconfig +1 -1
index 47150f5..6bf9575 100644
@@ -624,7 +624,7 @@ config GPIO_JANZ_TTL
 
 config GPIO_AB8500
 	bool "ST-Ericsson AB8500 Mixed Signal Circuit gpio functions"
-	depends on AB8500_CORE && BROKEN
+	depends on AB8500_CORE
 	help
 	  Select this to enable the AB8500 IC GPIO driver
 
drivers/gpio/gpio-ab8500.c +31 -29

131 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/21 gpio: ab8500: Make pins configurable

In reply to Lee Jones

From: Mian Yousaf Kaukab <[email protected]>

Make it possible to set the pin configuration either as gpio or specific functionality through the driver interface.

---
 drivers/gpio/gpio-ab8500.c             |   63 ++++++++++++++++++++++++++++++++
 include/linux/mfd/abx500/ab8500-gpio.h |   51 ++++++++++++++++++++++++++
 2 files changed, 114 insertions(+)
drivers/gpio/gpio-ab8500.c +63 -0
index db40acb..c3c7c5a 100644
@@ -495,6 +495,69 @@ static int __devexit ab8500_gpio_remove(struct platform_device *pdev)
 	return 0;
 }
 
+/*
+ * ab8500_gpio_config_select()
+ *
+ * Configure functionality of pin, either specific use or GPIO.
+ * @dev: device pointer
+ * @gpio: gpio number
+ * @gpio_select: true if the pin should be used as GPIO
+ */
+int ab8500_gpio_config_select(struct device *dev,
+				enum ab8500_pin gpio, bool gpio_select)
+{
+	u8 offset = gpio - AB8500_PIN_GPIO1;
+	u8 reg = AB8500_GPIO_SEL1_REG + (offset / 8);
+	u8 pos = offset % 8;
+	u8 val = gpio_select ? 1 : 0;
+	int ret;
+
+	ret = abx500_mask_and_set_register_interruptible(dev,
+		AB8500_MISC, reg, 1 << pos, val << pos);
+	if (ret < 0)
+		dev_err(dev, "%s write failed\n", __func__);
+
+	dev_vdbg(dev, "%s (bank, addr, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
+		__func__, AB8500_MISC, reg, 1 << pos, val << pos);
+
+	return ret;
+}
+
+/*
+ * ab8500_gpio_config_get_select()
+ *
+ * Read currently configured functionality, either specific use or GPIO.
+ * @dev: device pointer
+ * @gpio: gpio number
+ * @gpio_select: pointer to pin selection status
+ */
+int ab8500_gpio_config_get_select(struct device *dev,
+					enum ab8500_pin gpio, bool *gpio_select)
+{
+	u8 offset =  gpio - AB8500_PIN_GPIO1;
+	u8 reg = AB8500_GPIO_SEL1_REG + (offset / 8);
+	u8 pos = offset % 8;
+	u8 val;
+	int ret;
+
+	ret = abx500_get_register_interruptible(dev,
+				AB8500_MISC, reg, &val);
+	if (ret < 0) {
+		dev_err(dev, "%s read failed\n", __func__);
+		return ret;
+	}
+
+	if (val & (1 << pos))
+		*gpio_select = true;
+	else
+		*gpio_select = false;
+
+	dev_vdbg(dev, "%s (bank, addr, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
+		__func__, AB8500_MISC, reg, 1 << pos, val);
+
+	return 0;
+}
+
 static struct platform_driver ab8500_gpio_driver = {
 	.driver = {
 		.name = "ab8500-gpio",
include/linux/mfd/abx500/ab8500-gpio.h +51 -0

55 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH 3/21 gpio: ab8500: Fix alternate function register address

In reply to Lee Jones

From: Bibek Basu <[email protected]>

Alternate function register address is actually 0x50 and thus changed accordingly.

---
 drivers/gpio/gpio-ab8500.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-ab8500.c +1 -1
index c3c7c5a..b7d4416 100644
@@ -60,7 +60,7 @@
 #define AB8500_GPIO_IN4_REG	0x43
 #define AB8500_GPIO_IN5_REG	0x44
 #define AB8500_GPIO_IN6_REG	0x45
-#define AB8500_GPIO_ALTFUN_REG	0x45
+#define AB8500_GPIO_ALTFUN_REG	0x50
 #define ALTFUN_REG_INDEX	6
 #define AB8500_NUM_GPIO		42
 #define AB8500_NUM_VIR_GPIO_IRQ	16
Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH 4/21 gpio: ab8500: Read register corrected in get_value api

In reply to Lee Jones

From: Bibek Basu <[email protected]>

Read register is corrected from "AB8500_GPIO_OUT1_REG" to "AB8500_GPIO_IN1_REG" in get_value api

---
 drivers/gpio/gpio-ab8500.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-ab8500.c +1 -1
index b7d4416..77fe1d7 100644
@@ -115,7 +115,7 @@ static int ab8500_gpio_get(struct gpio_chip *chip, unsigned offset)
 {
 	struct ab8500_gpio *ab8500_gpio = to_ab8500_gpio(chip);
 	u8 mask = 1 << (offset % 8);
-	u8 reg = AB8500_GPIO_OUT1_REG + (offset / 8);
+	u8 reg = AB8500_GPIO_IN1_REG + (offset / 8);
 	int ret;
 	u8 data;
 	ret = abx500_get_register_interruptible(ab8500_gpio->dev, AB8500_MISC,
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH 5/21 gpio: ab8500: Allow direction and pullups configuration

In reply to Lee Jones

From: Mian Yousaf Kaukab <[email protected]>

This patch extends the the platform data to include gpio direction and pullups configurations. These configurations are applied during probe().

---
 drivers/gpio/gpio-ab8500.c             |   12 ++++++++++++
 include/linux/mfd/abx500/ab8500-gpio.h |    2 ++
 2 files changed, 14 insertions(+)
drivers/gpio/gpio-ab8500.c +12 -0
index 77fe1d7..dd95cb3 100644
@@ -445,6 +445,18 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 				pdata->config_reg[i]);
 		if (ret < 0)
 			goto out_free;
+
+		ret = abx500_set_register_interruptible(ab8500_gpio->dev,
+				AB8500_MISC, i + AB8500_GPIO_DIR1_REG,
+				pdata->config_direction[i]);
+		if (ret < 0)
+			goto out_free;
+
+		ret = abx500_set_register_interruptible(ab8500_gpio->dev,
+				AB8500_MISC, i + AB8500_GPIO_PUD1_REG,
+				pdata->config_pullups[i]);
+		if (ret < 0)
+			goto out_free;
 	}
 	ret = abx500_set_register_interruptible(ab8500_gpio->dev, AB8500_MISC,
 				AB8500_GPIO_ALTFUN_REG,
include/linux/mfd/abx500/ab8500-gpio.h +2 -0
index 5caa615..94e85ca 100644
@@ -18,6 +18,8 @@ struct ab8500_gpio_platform_data {
 	int gpio_base;
 	u32 irq_base;
 	u8  config_reg[8];
+	u8  config_direction[6];
+	u8  config_pullups[6];
 };
 
 enum ab8500_pin {
Signature · 1 line
1.7.9.5
author
#6 lore raw

PATCH 6/21 gpio: ab8500: Add api to enable pulldown

In reply to Lee Jones

From: Mian Yousaf Kaukab <[email protected]>

---
 drivers/gpio/gpio-ab8500.c             |   17 +++++++++++++++++
 include/linux/mfd/abx500/ab8500-gpio.h |    3 +++
 2 files changed, 20 insertions(+)
drivers/gpio/gpio-ab8500.c +17 -0
index dd95cb3..b71bb72 100644
@@ -507,6 +507,23 @@ static int __devexit ab8500_gpio_remove(struct platform_device *pdev)
 	return 0;
 }
 
+int ab8500_config_pulldown(struct device *dev,
+				enum ab8500_pin gpio, bool enable)
+{
+	u8 offset =  gpio - AB8500_PIN_GPIO1;
+	u8 pos = offset % 8;
+	u8 val = enable ? 0 : 1;
+	u8 reg = AB8500_GPIO_PUD1_REG + (offset / 8);
+	int ret;
+
+	ret = abx500_mask_and_set_register_interruptible(dev,
+				AB8500_MISC, reg, 1 << pos, val << pos);
+	if (ret < 0)
+		dev_err(dev, "%s write failed\n", __func__);
+	return ret;
+}
+EXPORT_SYMBOL(ab8500_config_pulldown);
+
 /*
  * ab8500_gpio_config_select()
  *
include/linux/mfd/abx500/ab8500-gpio.h +3 -0
index 94e85ca..48325db 100644
@@ -67,6 +67,9 @@ enum ab8500_pin {
 	AB8500_PIN_GPIO42,
 };
 
+int ab8500_config_pulldown(struct device *dev,
+				enum ab8500_pin gpio, bool enable);
+
 int ab8500_gpio_config_select(struct device *dev,
 				enum ab8500_pin gpio, bool gpio_select);
 
Signature · 1 line
1.7.9.5
author
#7 lore raw

PATCH 7/21 gpio: ab8500: Write argument value instead of hardwired 1

In reply to Lee Jones

From: Marcel Tunnissen <[email protected]>

This fixes a bug in gpio_set_value(xxx, 0) for ab8500 GPIOs.

---
 drivers/gpio/gpio-ab8500.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-ab8500.c +1 -1
index b71bb72..d3bbcce 100644
@@ -132,7 +132,7 @@ static void ab8500_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
 	struct ab8500_gpio *ab8500_gpio = to_ab8500_gpio(chip);
 	int ret;
 	/* Write the data */
-	ret = ab8500_gpio_set_bits(chip, AB8500_GPIO_OUT1_REG, offset, 1);
+	ret = ab8500_gpio_set_bits(chip, AB8500_GPIO_OUT1_REG, offset, val);
 	if (ret < 0)
 		dev_err(ab8500_gpio->dev, "%s write failed\n", __func__);
 }
Signature · 1 line
1.7.9.5
author
#8 lore raw

PATCH 8/21 gpio: ab8500: Fix gpio offset bounds for irq mapping

In reply to Lee Jones

From: Mian Yousaf Kaukab <[email protected]>

AB8500 gpio numbers start from 1 and not 0 so the offset 0 represents gpio 1. Fixing cluster bounds accordingly for irq mappings.

---
 drivers/gpio/gpio-ab8500.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpio/gpio-ab8500.c +3 -3
index d3bbcce..a0253ad 100644
@@ -174,9 +174,9 @@ static int ab8500_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 		int start;
 		int end;
 	} clusters[] = {
-		{.start = 6,  .end = 13},
-		{.start = 24, .end = 25},
-		{.start = 36, .end = 41},
+		{.start = 5,  .end = 12}, /* GPIO numbers start from 1 */
+		{.start = 23, .end = 24},
+		{.start = 35, .end = 40},
 	};
 	struct ab8500_gpio *ab8500_gpio = to_ab8500_gpio(chip);
 	int base = ab8500_gpio->irq_base;
Signature · 1 line
1.7.9.5
author
#9 lore raw

PATCH 9/21 gpio: ab8500: Fix bad include name after renaming

In reply to Lee Jones

From: Philippe Langlais <[email protected]>

---
 drivers/gpio/gpio-ab8500.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-ab8500.c +2 -2
index a0253ad..273f7ca 100644
@@ -18,9 +18,9 @@
 #include <linux/gpio.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
-#include <linux/mfd/ab8500.h>
 #include <linux/mfd/abx500.h>
-#include <linux/mfd/ab8500/gpio.h>
+#include <linux/mfd/abx500/ab8500-gpio.h>
+
 
 /*
  * GPIO registers offset
Signature · 1 line
1.7.9.5
author
#10 lore raw

PATCH 10/21 gpio: ab8500: Add support for the AB9540

In reply to Lee Jones

From: Michel JAOUEN <[email protected]>

---
 drivers/gpio/gpio-ab8500.c |   92 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 70 insertions(+), 22 deletions(-)
drivers/gpio/gpio-ab8500.c +70 -22
index 273f7ca..b78cf2f 100644
@@ -23,6 +23,13 @@
 
 
 /*
+ * The AB9540 GPIO support is an extended version of the
+ * AB8500 GPIO support. The AB9540 supports an additional
+ * (7th) register so that more GPIO may be configured and
+ * used.
+ */
+
+/*
  * GPIO registers offset
  * Bank: 0x10
  */
@@ -32,6 +39,7 @@
 #define AB8500_GPIO_SEL4_REG	0x03
 #define AB8500_GPIO_SEL5_REG	0x04
 #define AB8500_GPIO_SEL6_REG	0x05
+#define AB9540_GPIO_SEL7_REG	0x06
 
 #define AB8500_GPIO_DIR1_REG	0x10
 #define AB8500_GPIO_DIR2_REG	0x11
@@ -39,6 +47,7 @@
 #define AB8500_GPIO_DIR4_REG	0x13
 #define AB8500_GPIO_DIR5_REG	0x14
 #define AB8500_GPIO_DIR6_REG	0x15
+#define AB9540_GPIO_DIR7_REG	0x16
 
 #define AB8500_GPIO_OUT1_REG	0x20
 #define AB8500_GPIO_OUT2_REG	0x21
@@ -46,6 +55,7 @@
 #define AB8500_GPIO_OUT4_REG	0x23
 #define AB8500_GPIO_OUT5_REG	0x24
 #define AB8500_GPIO_OUT6_REG	0x25
+#define AB9540_GPIO_OUT7_REG	0x26
 
 #define AB8500_GPIO_PUD1_REG	0x30
 #define AB8500_GPIO_PUD2_REG	0x31
@@ -53,6 +63,7 @@
 #define AB8500_GPIO_PUD4_REG	0x33
 #define AB8500_GPIO_PUD5_REG	0x34
 #define AB8500_GPIO_PUD6_REG	0x35
+#define AB9540_GPIO_PUD7_REG	0x36
 
 #define AB8500_GPIO_IN1_REG	0x40
 #define AB8500_GPIO_IN2_REG	0x41
@@ -60,9 +71,12 @@
 #define AB8500_GPIO_IN4_REG	0x43
 #define AB8500_GPIO_IN5_REG	0x44
 #define AB8500_GPIO_IN6_REG	0x45
+#define AB9540_GPIO_IN7_REG	0x46
 #define AB8500_GPIO_ALTFUN_REG	0x50
-#define ALTFUN_REG_INDEX	6
+#define AB8500_ALTFUN_REG_INDEX	6
+#define AB9540_ALTFUN_REG_INDEX	7
 #define AB8500_NUM_GPIO		42
+#define AB9540_NUM_GPIO		54
 #define AB8500_NUM_VIR_GPIO_IRQ	16
 
 enum ab8500_gpio_action {
@@ -73,6 +87,11 @@ enum ab8500_gpio_action {
 	UNMASK
 };
 
+struct ab8500_gpio_irq_cluster {
+	int start;
+	int end;
+};
+
 struct ab8500_gpio {
 	struct gpio_chip chip;
 	struct ab8500 *parent;
@@ -82,7 +101,32 @@ struct ab8500_gpio {
 	enum ab8500_gpio_action irq_action;
 	u16 rising;
 	u16 falling;
+	struct ab8500_gpio_irq_cluster *irq_cluster;
+	int irq_cluster_size;
+};
+
+/*
+ * Only some GPIOs are interrupt capable, and they are
+ * organized in discontiguous clusters:
+ *
+ *	GPIO6 to GPIO13
+ *	GPIO24 and GPIO25
+ *	GPIO36 to GPIO41
+ *	GPIO50 to GPIO54 (AB9540 only)
+ */
+static struct ab8500_gpio_irq_cluster ab8500_irq_clusters[] = {
+	{.start = 5,  .end = 12}, /* GPIO numbers start from 1 */
+	{.start = 23, .end = 24},
+	{.start = 35, .end = 40},
+};
+
+static struct ab8500_gpio_irq_cluster ab9540_irq_clusters[] = {
+	{.start = 5,  .end = 12}, /* GPIO numbers start from 1 */
+	{.start = 23, .end = 24},
+	{.start = 35, .end = 40},
+	{.start = 49, .end = 53},
 };
+
 /**
  * to_ab8500_gpio() - get the pointer to ab8500_gpio
  * @chip:	Member of the structure ab8500_gpio
@@ -162,28 +206,13 @@ static int ab8500_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
 
 static int ab8500_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
-	/*
-	 * Only some GPIOs are interrupt capable, and they are
-	 * organized in discontiguous clusters:
-	 *
-	 *	GPIO6 to GPIO13
-	 *	GPIO24 and GPIO25
-	 *	GPIO36 to GPIO41
-	 */
-	static struct ab8500_gpio_irq_cluster {
-		int start;
-		int end;
-	} clusters[] = {
-		{.start = 5,  .end = 12}, /* GPIO numbers start from 1 */
-		{.start = 23, .end = 24},
-		{.start = 35, .end = 40},
-	};
 	struct ab8500_gpio *ab8500_gpio = to_ab8500_gpio(chip);
 	int base = ab8500_gpio->irq_base;
 	int i;
 
-	for (i = 0; i < ARRAY_SIZE(clusters); i++) {
-		struct ab8500_gpio_irq_cluster *cluster = &clusters[i];
+	for (i = 0; i < ab8500_gpio->irq_cluster_size; i++) {
+		struct ab8500_gpio_irq_cluster *cluster =
+			&ab8500_gpio->irq_cluster[i];
 
 		if (offset >= cluster->start && offset <= cluster->end)
 			return base + offset - cluster->start;
@@ -412,6 +441,8 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 	struct ab8500_gpio *ab8500_gpio;
 	int ret;
 	int i;
+	int last_gpio_sel_reg;
+	int altfun_reg_index;
 
 	pdata = ab8500_pdata->gpio;
 	if (!pdata)	{
@@ -427,10 +458,27 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 	ab8500_gpio->dev = &pdev->dev;
 	ab8500_gpio->parent = dev_get_drvdata(pdev->dev.parent);
 	ab8500_gpio->chip = ab8500gpio_chip;
-	ab8500_gpio->chip.ngpio = AB8500_NUM_GPIO;
 	ab8500_gpio->chip.dev = &pdev->dev;
 	ab8500_gpio->chip.base = pdata->gpio_base;
 	ab8500_gpio->irq_base = pdata->irq_base;
+
+	/* Configure GPIO Settings for specific AB devices */
+	if (cpu_is_u9540()) {
+		ab8500_gpio->chip.ngpio = AB9540_NUM_GPIO;
+		ab8500_gpio->irq_cluster = ab9540_irq_clusters;
+		ab8500_gpio->irq_cluster_size =
+			ARRAY_SIZE(ab9540_irq_clusters);
+		last_gpio_sel_reg = AB9540_GPIO_SEL7_REG;
+		altfun_reg_index = AB9540_ALTFUN_REG_INDEX;
+	} else {
+		ab8500_gpio->chip.ngpio = AB8500_NUM_GPIO;
+		ab8500_gpio->irq_cluster = ab8500_irq_clusters;
+		ab8500_gpio->irq_cluster_size =
+			ARRAY_SIZE(ab8500_irq_clusters);
+		last_gpio_sel_reg = AB8500_GPIO_SEL6_REG;
+		altfun_reg_index = AB8500_ALTFUN_REG_INDEX;
+	}
+
 	/* initialize the lock */
 	mutex_init(&ab8500_gpio->lock);
 	/*
@@ -439,7 +487,7 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 	 * These values are for selecting the PINs as
 	 * GPIO or alternate function
 	 */
-	for (i = AB8500_GPIO_SEL1_REG; i <= AB8500_GPIO_SEL6_REG; i++)	{
+	for (i = AB8500_GPIO_SEL1_REG; i <= last_gpio_sel_reg; i++) {
 		ret = abx500_set_register_interruptible(ab8500_gpio->dev,
 				AB8500_MISC, i,
 				pdata->config_reg[i]);
@@ -460,7 +508,7 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 	}
 	ret = abx500_set_register_interruptible(ab8500_gpio->dev, AB8500_MISC,
 				AB8500_GPIO_ALTFUN_REG,
-				pdata->config_reg[ALTFUN_REG_INDEX]);
+				pdata->config_reg[altfun_reg_index]);
 	if (ret < 0)
 		goto out_free;
 
Signature · 1 line
1.7.9.5
author
#11 lore raw

PATCH 11/21 gpio: ab8500: Add support for AB8505 Chip

In reply to Lee Jones

From: Naga Radhesh <[email protected]>

Number of gpio pins has been changed for AB8505, so change gpio configurations according to AB8505.

---
 drivers/gpio/gpio-ab8500.c |   41 +++++++++++++++++++++++++++++++++++------
 1 file changed, 35 insertions(+), 6 deletions(-)
drivers/gpio/gpio-ab8500.c +35 -6
index b78cf2f..8616368 100644
@@ -77,6 +77,7 @@
 #define AB9540_ALTFUN_REG_INDEX	7
 #define AB8500_NUM_GPIO		42
 #define AB9540_NUM_GPIO		54
+#define AB8505_NUM_GPIO		53
 #define AB8500_NUM_VIR_GPIO_IRQ	16
 
 enum ab8500_gpio_action {
@@ -127,6 +128,24 @@ static struct ab8500_gpio_irq_cluster ab9540_irq_clusters[] = {
 	{.start = 49, .end = 53},
 };
 
+/*
+ * For AB8505 Only some GPIOs are interrupt capable, and they are
+ * organized in discontiguous clusters:
+ *
+ *	GPIO10 to GPIO11
+ *	GPIO13
+ *	GPIO40 and GPIO41
+ *	GPIO50
+ *	GPIO52 to GPIO53
+ */
+static struct ab8500_gpio_irq_cluster ab8505_irq_clusters[] = {
+	{.start = 9,  .end = 10}, /* GPIO numbers start from 1 */
+	{.start = 12, .end = 12},
+	{.start = 39, .end = 40},
+	{.start = 49, .end = 49},
+	{.start = 51, .end = 52},
+};
+
 /**
  * to_ab8500_gpio() - get the pointer to ab8500_gpio
  * @chip:	Member of the structure ab8500_gpio
@@ -435,6 +454,7 @@ static void ab8500_gpio_irq_remove(struct ab8500_gpio *ab8500_gpio)
 
 static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 {
+	struct ab8500 *parent = dev_get_drvdata(pdev->dev.parent);
 	struct ab8500_platform_data *ab8500_pdata =
 				dev_get_platdata(pdev->dev.parent);
 	struct ab8500_gpio_platform_data *pdata;
@@ -471,12 +491,21 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 		last_gpio_sel_reg = AB9540_GPIO_SEL7_REG;
 		altfun_reg_index = AB9540_ALTFUN_REG_INDEX;
 	} else {
-		ab8500_gpio->chip.ngpio = AB8500_NUM_GPIO;
-		ab8500_gpio->irq_cluster = ab8500_irq_clusters;
-		ab8500_gpio->irq_cluster_size =
-			ARRAY_SIZE(ab8500_irq_clusters);
-		last_gpio_sel_reg = AB8500_GPIO_SEL6_REG;
-		altfun_reg_index = AB8500_ALTFUN_REG_INDEX;
+		if (is_ab8505(parent)) {
+			ab8500_gpio->chip.ngpio = AB8505_NUM_GPIO;
+			ab8500_gpio->irq_cluster = ab8505_irq_clusters;
+			ab8500_gpio->irq_cluster_size =
+				ARRAY_SIZE(ab8505_irq_clusters);
+			last_gpio_sel_reg = AB9540_GPIO_SEL7_REG;
+			altfun_reg_index = AB9540_ALTFUN_REG_INDEX;
+		} else {
+			ab8500_gpio->chip.ngpio = AB8500_NUM_GPIO;
+			ab8500_gpio->irq_cluster = ab8500_irq_clusters;
+			ab8500_gpio->irq_cluster_size =
+				ARRAY_SIZE(ab8500_irq_clusters);
+			last_gpio_sel_reg = AB8500_GPIO_SEL6_REG;
+			altfun_reg_index = AB8500_ALTFUN_REG_INDEX;
+		}
 	}
 
 	/* initialize the lock */
Signature · 1 line
1.7.9.5
author
#12 lore raw

PATCH 12/21 gpio: ab8500: Allow gpios to wake the system from suspend

In reply to Lee Jones

From: Paer-Olof Haakansson <[email protected]>

---
 drivers/gpio/gpio-ab8500.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpio/gpio-ab8500.c +2 -2
index 8616368..ef75984 100644
@@ -329,12 +329,12 @@ static void ab8500_gpio_irq_sync_unlock(struct irq_data *data)
 		if (rising)
 			ret = request_threaded_irq(irq_to_rising(irq),
 					NULL, handle_rising,
-					IRQF_TRIGGER_RISING,
+					IRQF_TRIGGER_RISING | IRQF_NO_SUSPEND,
 					"ab8500-gpio-r", ab8500_gpio);
 		if (falling)
 			ret = request_threaded_irq(irq_to_falling(irq),
 				       NULL, handle_falling,
-				       IRQF_TRIGGER_FALLING,
+				       IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND,
 				       "ab8500-gpio-f", ab8500_gpio);
 		break;
 	case SHUTDOWN:
Signature · 1 line
1.7.9.5
author
#13 lore raw

PATCH 13/21 gpio: ab8500: Use most recent run-time platform checker

In reply to Lee Jones

From: Michel JAOUEN <[email protected]>

Use is_ab9540() instead of cpu_is_u9540() when checking platform.

---
 drivers/gpio/gpio-ab8500.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-ab8500.c +1 -1
index ef75984..200c605 100644
@@ -483,7 +483,7 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 	ab8500_gpio->irq_base = pdata->irq_base;
 
 	/* Configure GPIO Settings for specific AB devices */
-	if (cpu_is_u9540()) {
+	if (is_ab9540(parent)) {
 		ab8500_gpio->chip.ngpio = AB9540_NUM_GPIO;
 		ab8500_gpio->irq_cluster = ab9540_irq_clusters;
 		ab8500_gpio->irq_cluster_size =
Signature · 1 line
1.7.9.5
author
#14 lore raw

PATCH 14/21 gpio: ab8500: Remove ENUMs from linux/mfd/abx500/ab8500-gpio.h

In reply to Lee Jones

These are no longer used and will be replaced by a simple macro.

---
 drivers/gpio/gpio-ab8500.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpio/gpio-ab8500.c +6 -6
index 200c605..ab6ceac 100644
@@ -585,9 +585,9 @@ static int __devexit ab8500_gpio_remove(struct platform_device *pdev)
 }
 
 int ab8500_config_pulldown(struct device *dev,
-				enum ab8500_pin gpio, bool enable)
+				int gpio, bool enable)
 {
-	u8 offset =  gpio - AB8500_PIN_GPIO1;
+	u8 offset =  gpio - AB8500_PIN_GPIO(1);
 	u8 pos = offset % 8;
 	u8 val = enable ? 0 : 1;
 	u8 reg = AB8500_GPIO_PUD1_REG + (offset / 8);
@@ -610,9 +610,9 @@ EXPORT_SYMBOL(ab8500_config_pulldown);
  * @gpio_select: true if the pin should be used as GPIO
  */
 int ab8500_gpio_config_select(struct device *dev,
-				enum ab8500_pin gpio, bool gpio_select)
+				int gpio, bool gpio_select)
 {
-	u8 offset = gpio - AB8500_PIN_GPIO1;
+	u8 offset = gpio - AB8500_PIN_GPIO(1);
 	u8 reg = AB8500_GPIO_SEL1_REG + (offset / 8);
 	u8 pos = offset % 8;
 	u8 val = gpio_select ? 1 : 0;
@@ -638,9 +638,9 @@ int ab8500_gpio_config_select(struct device *dev,
  * @gpio_select: pointer to pin selection status
  */
 int ab8500_gpio_config_get_select(struct device *dev,
-					enum ab8500_pin gpio, bool *gpio_select)
+					int gpio, bool *gpio_select)
 {
-	u8 offset =  gpio - AB8500_PIN_GPIO1;
+	u8 offset =  gpio - AB8500_PIN_GPIO(1);
 	u8 reg = AB8500_GPIO_SEL1_REG + (offset / 8);
 	u8 pos = offset % 8;
 	u8 val;
Signature · 1 line
1.7.9.5
author
#15 lore raw

PATCH 15/21 gpio: ab8500: Add support for the ab8540

In reply to Lee Jones

From: Alexandre Torgue <[email protected]>

---
 drivers/gpio/gpio-ab8500.c |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/gpio/gpio-ab8500.c +18 -1
index ab6ceac..757ae34 100644
@@ -78,6 +78,7 @@
 #define AB8500_NUM_GPIO		42
 #define AB9540_NUM_GPIO		54
 #define AB8505_NUM_GPIO		53
+#define AB8540_NUM_GPIO		56
 #define AB8500_NUM_VIR_GPIO_IRQ	16
 
 enum ab8500_gpio_action {
@@ -146,6 +147,15 @@ static struct ab8500_gpio_irq_cluster ab8505_irq_clusters[] = {
 	{.start = 51, .end = 52},
 };
 
+/*
+ * For AB8540 Only some GPIOs are interrupt capable:
+ *	GPIO51 to GPIO54
+ */
+static struct ab8500_gpio_irq_cluster ab8540_irq_clusters[] = {
+	{.start = 50,  .end = 53}, /* GPIO numbers start from 1 */
+};
+
+
 /**
  * to_ab8500_gpio() - get the pointer to ab8500_gpio
  * @chip:	Member of the structure ab8500_gpio
@@ -483,7 +493,14 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 	ab8500_gpio->irq_base = pdata->irq_base;
 
 	/* Configure GPIO Settings for specific AB devices */
-	if (is_ab9540(parent)) {
+	if (is_ab8540(parent)) {
+		ab8500_gpio->chip.ngpio = AB8540_NUM_GPIO;
+		ab8500_gpio->irq_cluster = ab8540_irq_clusters;
+		ab8500_gpio->irq_cluster_size =
+			ARRAY_SIZE(ab8540_irq_clusters);
+		last_gpio_sel_reg = AB9540_GPIO_SEL7_REG;
+		altfun_reg_index = AB9540_ALTFUN_REG_INDEX;
+	} else if (is_ab9540(parent)) {
 		ab8500_gpio->chip.ngpio = AB9540_NUM_GPIO;
 		ab8500_gpio->irq_cluster = ab9540_irq_clusters;
 		ab8500_gpio->irq_cluster_size =
Signature · 1 line
1.7.9.5
author
#16 lore raw

PATCH 16/21 gpio: ab8500: Add internal pull up on GPIO of ab8540

In reply to Lee Jones

From: Alexandre Torgue <[email protected]>

Add 4 GPIOs named GPIOx_VBAT which have both internal pull up and pull down capability on ab8540. We can also select different voltage domains for GPIOx_VBAT.

---
 drivers/gpio/gpio-ab8500.c             |   64 ++++++++++++++++++++++++++++
 include/linux/mfd/abx500/ab8500-gpio.h |   71 +++++++++++---------------------
 2 files changed, 87 insertions(+), 48 deletions(-)
drivers/gpio/gpio-ab8500.c +64 -0
index 757ae34..ff8df1f 100644
@@ -72,6 +72,8 @@
 #define AB8500_GPIO_IN5_REG	0x44
 #define AB8500_GPIO_IN6_REG	0x45
 #define AB9540_GPIO_IN7_REG	0x46
+#define AB8540_GPIO_VINSEL_REG	0x47
+#define AB8540_GPIO_PULL_UPDOWN_REG	0x48
 #define AB8500_GPIO_ALTFUN_REG	0x50
 #define AB8500_ALTFUN_REG_INDEX	6
 #define AB9540_ALTFUN_REG_INDEX	7
@@ -80,6 +82,8 @@
 #define AB8505_NUM_GPIO		53
 #define AB8540_NUM_GPIO		56
 #define AB8500_NUM_VIR_GPIO_IRQ	16
+#define AB8540_GPIO_PULL_UPDOWN_MASK	0x03
+#define AB8540_GPIO_VINSEL_MASK	0x03
 
 enum ab8500_gpio_action {
 	NONE,
@@ -552,6 +556,20 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev)
 		if (ret < 0)
 			goto out_free;
 	}
+
+	if (is_ab8540(parent)) {
+		ret = abx500_set_register_interruptible(ab8500_gpio->dev,
+				AB8500_MISC, AB8540_GPIO_VINSEL_REG,
+				pdata->config_vinsel);
+		if (ret < 0)
+			goto out_free;
+		ret = abx500_set_register_interruptible(ab8500_gpio->dev,
+				AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG,
+				pdata->config_pullupdown);
+		if (ret < 0)
+			goto out_free;
+	}
+
 	ret = abx500_set_register_interruptible(ab8500_gpio->dev, AB8500_MISC,
 				AB8500_GPIO_ALTFUN_REG,
 				pdata->config_reg[altfun_reg_index]);
@@ -619,6 +637,52 @@ int ab8500_config_pulldown(struct device *dev,
 EXPORT_SYMBOL(ab8500_config_pulldown);
 
 /*
+ * ab8540_config_pull_updown() only available for following GPIOs:
+ * GPIO51(GPIO1_VBAT)
+ * GPIO52(GPIO2_VBAT)
+ * GPIO53(GPIO3_VBAT)
+ * GPIO54(GPIO4_VBAT)
+ */
+int ab8540_config_pull_updown(struct device *dev,
+				int gpio, enum ab8540_gpio_pull_updown reg)
+{
+	u8 offset =  gpio - AB8500_PIN_GPIO(51);
+	u8 pos = 2 * offset;
+	int ret;
+
+	ret = abx500_mask_and_set_register_interruptible(dev,
+			AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG,
+			AB8540_GPIO_PULL_UPDOWN_MASK << pos, reg << pos);
+	if (ret < 0)
+		dev_err(dev, "%s failed (%d)\n", __func__, ret);
+	return ret;
+}
+EXPORT_SYMBOL(ab8540_config_pull_updown);
+
+/*
+ * ab8540_gpio_config_vinsel() only available for following GPIOs:
+ * GPIO51(GPIO1_VBAT)
+ * GPIO52(GPIO2_VBAT)
+ * GPIO53(GPIO3_VBAT)
+ * GPIO54(GPIO4_VBAT)
+ */
+int ab8540_gpio_config_vinsel(struct device *dev,
+				int gpio, enum ab8540_gpio_vinsel reg)
+{
+	u8 offset =  gpio - AB8500_PIN_GPIO(51);
+	u8 pos = 2 * offset;
+	int ret;
+
+	ret = abx500_mask_and_set_register_interruptible(dev,
+			AB8500_MISC, AB8540_GPIO_VINSEL_REG,
+			AB8540_GPIO_VINSEL_MASK << pos, reg << pos);
+	if (ret < 0)
+		dev_err(dev, "%s failed (%d)\n", __func__, ret);
+	return ret;
+}
+EXPORT_SYMBOL(ab8540_gpio_config_vinsel);
+
+/*
  * ab8500_gpio_config_select()
  *
  * Configure functionality of pin, either specific use or GPIO.
include/linux/mfd/abx500/ab8500-gpio.h +23 -48

85 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author
#17 lore raw

PATCH 17/21 gpio: ab8500: Add the action range for the internal pull up function on GPIO

In reply to Lee Jones

From: Yang QU <[email protected]>

Only 4 GPIOs named GPIOx_VBAT have both internal pull up and pull down capability on ab8540. Limit the action range for this function.

---
 drivers/gpio/gpio-ab8500.c             |   54 +++++++++++++++++---------------
 include/linux/mfd/abx500/ab8500-gpio.h |    6 ++--
 2 files changed, 32 insertions(+), 28 deletions(-)
drivers/gpio/gpio-ab8500.c +28 -26
index ff8df1f..b4f631a 100644
@@ -23,10 +23,12 @@
 
 
 /*
- * The AB9540 GPIO support is an extended version of the
- * AB8500 GPIO support. The AB9540 supports an additional
- * (7th) register so that more GPIO may be configured and
- * used.
+ * The AB9540 and AB8540 GPIO support are extended versions
+ * of the AB8500 GPIO support.
+ * The AB9540 supports an additional (7th) register so that
+ * more GPIO may be configured and used.
+ * The AB8540 supports 4 new gpios (GPIOx_VBAT) that have
+ * internal pull-up and pull-down capabilities.
  */
 
 /*
@@ -636,46 +638,46 @@ int ab8500_config_pulldown(struct device *dev,
 }
 EXPORT_SYMBOL(ab8500_config_pulldown);
 
-/*
- * ab8540_config_pull_updown() only available for following GPIOs:
- * GPIO51(GPIO1_VBAT)
- * GPIO52(GPIO2_VBAT)
- * GPIO53(GPIO3_VBAT)
- * GPIO54(GPIO4_VBAT)
- */
 int ab8540_config_pull_updown(struct device *dev,
-				int gpio, enum ab8540_gpio_pull_updown reg)
+				int gpio, enum ab8540_gpio_pull_updown val)
 {
-	u8 offset =  gpio - AB8500_PIN_GPIO(51);
-	u8 pos = 2 * offset;
+	u8 pos;
 	int ret;
 
+	if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	pos = (gpio - AB8500_PIN_GPIO(51)) << 1;
+
 	ret = abx500_mask_and_set_register_interruptible(dev,
 			AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG,
-			AB8540_GPIO_PULL_UPDOWN_MASK << pos, reg << pos);
+			AB8540_GPIO_PULL_UPDOWN_MASK << pos, val << pos);
+
+out:
 	if (ret < 0)
 		dev_err(dev, "%s failed (%d)\n", __func__, ret);
 	return ret;
 }
 EXPORT_SYMBOL(ab8540_config_pull_updown);
 
-/*
- * ab8540_gpio_config_vinsel() only available for following GPIOs:
- * GPIO51(GPIO1_VBAT)
- * GPIO52(GPIO2_VBAT)
- * GPIO53(GPIO3_VBAT)
- * GPIO54(GPIO4_VBAT)
- */
 int ab8540_gpio_config_vinsel(struct device *dev,
-				int gpio, enum ab8540_gpio_vinsel reg)
+				int gpio, enum ab8540_gpio_vinsel val)
 {
-	u8 offset =  gpio - AB8500_PIN_GPIO(51);
-	u8 pos = 2 * offset;
+	u8 pos;
 	int ret;
 
+	if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	ret = abx500_mask_and_set_register_interruptible(dev,
 			AB8500_MISC, AB8540_GPIO_VINSEL_REG,
-			AB8540_GPIO_VINSEL_MASK << pos, reg << pos);
+			AB8540_GPIO_VINSEL_MASK << pos, val << pos);
+
+out:
 	if (ret < 0)
 		dev_err(dev, "%s failed (%d)\n", __func__, ret);
 	return ret;
include/linux/mfd/abx500/ab8500-gpio.h +4 -2
index 20df07d..86ccb33 100644
@@ -39,11 +39,13 @@ enum ab8540_gpio_vinsel {
 int ab8500_config_pulldown(struct device *dev,
 				int gpio, bool enable);
 
+/* Selects pull up/pull down for GPIOx_VBAT, x=1 to 4 */
 int ab8540_config_pull_updown(struct device *dev,
-				int gpio, enum ab8540_gpio_pull_updown reg);
+				int gpio, enum ab8540_gpio_pull_updown val);
 
+/* Selects voltage for GPIOx_VBAT, x=1 to 4 */
 int ab8540_gpio_config_vinsel(struct device *dev,
-				int gpio, enum ab8540_gpio_vinsel reg);
+				int gpio, enum ab8540_gpio_vinsel val);
 
 int ab8500_gpio_config_select(struct device *dev,
 				int gpio, bool gpio_select);
Signature · 1 line
1.7.9.5
author
#18 lore raw

PATCH 18/21 gpio: ab8500: Fix parameter uninitialized warning for ab8540

In reply to Lee Jones

From: Yang QU <[email protected]>

Missing initial value in ab8540 gpio configuration function. So initialize it and fix this warning.

---
 drivers/gpio/gpio-ab8500.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpio-ab8500.c +2 -0
index b4f631a..833d4c2 100644
@@ -673,6 +673,8 @@ int ab8540_gpio_config_vinsel(struct device *dev,
 		goto out;
 	}
 
+	pos = (gpio - AB8500_PIN_GPIO(51)) << 1;
+
 	ret = abx500_mask_and_set_register_interruptible(dev,
 			AB8500_MISC, AB8540_GPIO_VINSEL_REG,
 			AB8540_GPIO_VINSEL_MASK << pos, val << pos);
Signature · 1 line
1.7.9.5
author
#19 lore raw

PATCH 19/21 gpio: ab8500: Update gpio ab8540 interrupt mapping

In reply to Lee Jones

From: Yang QU <[email protected]>

Add some GPIOs used as interrupt on ab8540 and modify the setting strategy of the interrupt line.

---
 drivers/gpio/gpio-ab8500.c |   50 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 12 deletions(-)
drivers/gpio/gpio-ab8500.c +38 -12
index 833d4c2..edc3037 100644
@@ -98,6 +98,7 @@ enum ab8500_gpio_action {
 struct ab8500_gpio_irq_cluster {
 	int start;
 	int end;
+	int offset;
 };
 
 struct ab8500_gpio {
@@ -155,10 +156,12 @@ static struct ab8500_gpio_irq_cluster ab8505_irq_clusters[] = {
 
 /*
  * For AB8540 Only some GPIOs are interrupt capable:
+ *	GPIO43 to GPIO44
  *	GPIO51 to GPIO54
  */
 static struct ab8500_gpio_irq_cluster ab8540_irq_clusters[] = {
-	{.start = 50,  .end = 53}, /* GPIO numbers start from 1 */
+	{.start = 42,  .end = 43,  .offset = 2}, /* GPIO numbers start from 1 */
+	{.start = 50,  .end = 53},
 };
 
 
@@ -253,7 +256,7 @@ static int ab8500_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 			return base + offset - cluster->start;
 
 		/* Advance by the number of gpios in this cluster */
-		base += cluster->end - cluster->start + 1;
+		base += cluster->end + cluster->offset - cluster->start + 1;
 	}
 
 	return -EINVAL;
@@ -273,7 +276,12 @@ static unsigned int irq_to_rising(unsigned int irq)
 {
 	struct ab8500_gpio *ab8500_gpio = irq_get_chip_data(irq);
 	int offset = irq - ab8500_gpio->irq_base;
-	int new_irq = offset +  AB8500_INT_GPIO6R
+	int new_irq;
+	if (is_ab8540(ab8500_gpio->parent)) {
+		new_irq = offset * 2 +  AB8540_INT_GPIO43R
+			+ ab8500_gpio->parent->irq_base;
+	} else
+		new_irq = offset +  AB8500_INT_GPIO6R
 			+ ab8500_gpio->parent->irq_base;
 	return new_irq;
 }
@@ -282,8 +290,13 @@ static unsigned int irq_to_falling(unsigned int irq)
 {
 	struct ab8500_gpio *ab8500_gpio = irq_get_chip_data(irq);
 	int offset = irq - ab8500_gpio->irq_base;
-	int new_irq = offset +  AB8500_INT_GPIO6F
-			+  ab8500_gpio->parent->irq_base;
+	int new_irq;
+	if (is_ab8540(ab8500_gpio->parent)) {
+		new_irq = offset * 2 +  AB8540_INT_GPIO43F
+			+ ab8500_gpio->parent->irq_base;
+	} else
+		new_irq = offset +  AB8500_INT_GPIO6F
+			+ ab8500_gpio->parent->irq_base;
 	return new_irq;
 
 }
@@ -291,20 +304,33 @@ static unsigned int irq_to_falling(unsigned int irq)
 static unsigned int rising_to_irq(unsigned int irq, void *dev)
 {
 	struct ab8500_gpio *ab8500_gpio = dev;
-	int offset = irq - AB8500_INT_GPIO6R
-			- ab8500_gpio->parent->irq_base ;
-	int new_irq = offset + ab8500_gpio->irq_base;
+	int offset, new_irq;
+	if (is_ab8540(ab8500_gpio->parent)) {
+		offset = irq - AB8540_INT_GPIO43R
+			- ab8500_gpio->parent->irq_base;
+		new_irq = (offset >> 1) + ab8500_gpio->irq_base;
+	} else {
+		offset = irq - AB8500_INT_GPIO6R
+			- ab8500_gpio->parent->irq_base;
+		new_irq = offset + ab8500_gpio->irq_base;
+	}
 	return new_irq;
 }
 
 static unsigned int falling_to_irq(unsigned int irq, void *dev)
 {
 	struct ab8500_gpio *ab8500_gpio = dev;
-	int offset = irq - AB8500_INT_GPIO6F
-			- ab8500_gpio->parent->irq_base ;
-	int new_irq = offset + ab8500_gpio->irq_base;
+	int offset, new_irq;
+	if (is_ab8540(ab8500_gpio->parent)) {
+		offset = irq - AB8540_INT_GPIO43F
+			- ab8500_gpio->parent->irq_base;
+		new_irq = (offset >> 1) + ab8500_gpio->irq_base;
+	} else {
+		offset = irq - AB8500_INT_GPIO6F
+			- ab8500_gpio->parent->irq_base;
+		new_irq = offset + ab8500_gpio->irq_base;
+	}
 	return new_irq;
-
 }
 
 /*
Signature · 1 line
1.7.9.5
author
#20 lore raw

PATCH 20/21 gpio: ab8500: Fix ab8540 setting direction output error

In reply to Lee Jones

From: Yang QU <[email protected]>

Set GpioPullUpDownSel register for direction output function as GPIO51 to GPIO54 not share the same register with other GPIOs on AB8540.

---
 drivers/gpio/gpio-ab8500.c |   33 +++++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)
drivers/gpio/gpio-ab8500.c +25 -8
index edc3037..ed5832e 100644
@@ -86,6 +86,8 @@
 #define AB8500_NUM_VIR_GPIO_IRQ	16
 #define AB8540_GPIO_PULL_UPDOWN_MASK	0x03
 #define AB8540_GPIO_VINSEL_MASK	0x03
+#define AB8540_GPIOX_VBAT_START	51
+#define AB8540_GPIOX_VBAT_END	54
 
 enum ab8500_gpio_action {
 	NONE,
@@ -222,6 +224,7 @@ static void ab8500_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
 static int ab8500_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
 					int val)
 {
+	struct ab8500_gpio *ab8500_gpio = to_ab8500_gpio(chip);
 	int ret;
 	/* set direction as output */
 	ret = ab8500_gpio_set_bits(chip, AB8500_GPIO_DIR1_REG, offset, 1);
@@ -231,6 +234,18 @@ static int ab8500_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
 	ret = ab8500_gpio_set_bits(chip, AB8500_GPIO_PUD1_REG, offset, 1);
 	if (ret < 0)
 		return ret;
+	/*
+	 * Disable both pull down and pull up for GPIO51 to GPIO54 (GPIO1_VBAT
+	 * to GPIO4_VBAT).
+	 */
+	if (is_ab8540(ab8500_gpio->parent)) {
+		if (offset >= (AB8540_GPIOX_VBAT_START - 1)
+			&& offset <= (AB8540_GPIOX_VBAT_END - 1))
+			ret = ab8540_config_pull_updown(ab8500_gpio->dev,
+				AB8500_PIN_GPIO(offset + 1), AB8540_GPIO_PULL_NONE);
+		if (ret < 0)
+			return ret;
+	}
 	/* set the output as 1 or 0 */
 	return ab8500_gpio_set_bits(chip, AB8500_GPIO_OUT1_REG, offset, val);
 
@@ -278,10 +293,10 @@ static unsigned int irq_to_rising(unsigned int irq)
 	int offset = irq - ab8500_gpio->irq_base;
 	int new_irq;
 	if (is_ab8540(ab8500_gpio->parent)) {
-		new_irq = offset * 2 +  AB8540_INT_GPIO43R
+		new_irq = offset * 2 + AB8540_INT_GPIO43R
 			+ ab8500_gpio->parent->irq_base;
 	} else
-		new_irq = offset +  AB8500_INT_GPIO6R
+		new_irq = offset + AB8500_INT_GPIO6R
 			+ ab8500_gpio->parent->irq_base;
 	return new_irq;
 }
@@ -292,10 +307,10 @@ static unsigned int irq_to_falling(unsigned int irq)
 	int offset = irq - ab8500_gpio->irq_base;
 	int new_irq;
 	if (is_ab8540(ab8500_gpio->parent)) {
-		new_irq = offset * 2 +  AB8540_INT_GPIO43F
+		new_irq = offset * 2 + AB8540_INT_GPIO43F
 			+ ab8500_gpio->parent->irq_base;
 	} else
-		new_irq = offset +  AB8500_INT_GPIO6F
+		new_irq = offset + AB8500_INT_GPIO6F
 			+ ab8500_gpio->parent->irq_base;
 	return new_irq;
 
@@ -670,12 +685,13 @@ int ab8540_config_pull_updown(struct device *dev,
 	u8 pos;
 	int ret;
 
-	if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) {
+	if ((gpio < AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_START))
+		|| (gpio > AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_END))) {
 		ret = -EINVAL;
 		goto out;
 	}
 
-	pos = (gpio - AB8500_PIN_GPIO(51)) << 1;
+	pos = (gpio - AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_START)) << 1;
 
 	ret = abx500_mask_and_set_register_interruptible(dev,
 			AB8500_MISC, AB8540_GPIO_PULL_UPDOWN_REG,
@@ -694,12 +710,13 @@ int ab8540_gpio_config_vinsel(struct device *dev,
 	u8 pos;
 	int ret;
 
-	if ((gpio < AB8500_PIN_GPIO(51)) || (gpio > AB8500_PIN_GPIO(54))) {
+	if ((gpio < AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_START))
+		|| (gpio > AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_END))) {
 		ret = -EINVAL;
 		goto out;
 	}
 
-	pos = (gpio - AB8500_PIN_GPIO(51)) << 1;
+	pos = (gpio - AB8500_PIN_GPIO(AB8540_GPIOX_VBAT_START)) << 1;
 
 	ret = abx500_mask_and_set_register_interruptible(dev,
 			AB8500_MISC, AB8540_GPIO_VINSEL_REG,
Signature · 1 line
1.7.9.5
author
#21 lore raw

PATCH 21/21 gpio: ab8500: Add explicit dependencies

In reply to Lee Jones

From: Linus Walleij <[email protected]>

This driver is using symbols from <linux/mfd/abx500/ab8500.h> so include this file explicitly.

---
 drivers/gpio/gpio-ab8500.c |    1 +
 1 file changed, 1 insertion(+)
drivers/gpio/gpio-ab8500.c +1 -0
index ed5832e..d201de9 100644
@@ -19,6 +19,7 @@
 #include <linux/irq.h>
 #include <linux/interrupt.h>
 #include <linux/mfd/abx500.h>
+#include <linux/mfd/abx500/ab8500.h>
 #include <linux/mfd/abx500/ab8500-gpio.h>
 
 
Signature · 1 line
1.7.9.5
#22 lore raw
In reply to Lee Jones
Quoted 10 lines · Lee Jones

The ab8500 GPIO driver is currently 'BROKEN', due to a lack of updates and recent frame-work adoption. This patch-set aims to bring the driver back to life so we may make use of it again.

This first stage is to bring it into line with ST-Ericsson's internal track, which has been keeping up-to-date. After these patches have been accepted I will then overhaul the driver to use the most recent APIs and frame-works, such as pinctrl and Device Tree.

Quoted 3 lines

Please give these patches an easy ride. I know they're not perfect, but they do provide a great base on with I can form the overhaul. Thanks for your understanding.

OK I've applied these 21 patches on a branch in the pinctrl tree to be used as a merge base.

The only valid reason to have it in the pinctrl tree is obviously that it should be converted into a pinctrl driver in the next cycle, aiming at includion into kernel v3.9.

I know my colleague Patrice is already working on this, and thus I can plan for it :-) It is also an interesting subject since the ux500 will be the first platform with two pin controllers and the first with an off-SoC pin controller.

But any cleanups are welcome now, and I know you're already up to more patching...

Let us make sure we chisel out a real nice pinctrl/pinctrl-abx500.c driver by the end of this kernel cycle so things are under (pin)control again.

Yours,
Linus Walleij

#23 lore raw
Quoted 19 lines · Linus Walleij
Quoted 10 lines · Lee Jones

The ab8500 GPIO driver is currently 'BROKEN', due to a lack of updates and recent frame-work adoption. This patch-set aims to bring the driver back to life so we may make use of it again.

This first stage is to bring it into line with ST-Ericsson's internal track, which has been keeping up-to-date. After these patches have been accepted I will then overhaul the driver to use the most recent APIs and frame-works, such as pinctrl and Device Tree.

Quoted 3 lines

Please give these patches an easy ride. I know they're not perfect, but they do provide a great base on with I can form the overhaul. Thanks for your understanding.

OK I've applied these 21 patches on a branch in the pinctrl tree to be used as a merge base.

Quoted 8 lines

The only valid reason to have it in the pinctrl tree is obviously that it should be converted into a pinctrl driver in the next cycle, aiming at includion into kernel v3.9.

I know my colleague Patrice is already working on this, and thus I can plan for it :-) It is also an interesting subject since the ux500 will be the first platform with two pin controllers and the first with an off-SoC pin controller.

Okay, fine by me. I've looked through all the patches and I think they should be merged.

g.

author
#24 lore raw
Quoted 24 lines · Grant Likely
Quoted 23 lines · Linus Walleij
Quoted 10 lines · Lee Jones

The ab8500 GPIO driver is currently 'BROKEN', due to a lack of updates and recent frame-work adoption. This patch-set aims to bring the driver back to life so we may make use of it again.

This first stage is to bring it into line with ST-Ericsson's internal track, which has been keeping up-to-date. After these patches have been accepted I will then overhaul the driver to use the most recent APIs and frame-works, such as pinctrl and Device Tree.

Quoted 3 lines

Please give these patches an easy ride. I know they're not perfect, but they do provide a great base on with I can form the overhaul. Thanks for your understanding.

OK I've applied these 21 patches on a branch in the pinctrl tree to be used as a merge base.

The only valid reason to have it in the pinctrl tree is obviously that it should be converted into a pinctrl driver in the next cycle, aiming at includion into kernel v3.9.

Quoted 7 lines
Quoted 4 lines

I know my colleague Patrice is already working on this, and thus I can plan for it :-) It is also an interesting subject since the ux500 will be the first platform with two pin controllers and the first with an off-SoC pin controller.

Okay, fine by me. I've looked through all the patches and I think they should be merged.

Thanks for your understanding Grant.

Signature · 4 lines
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#25 lore raw
In reply to Linus Walleij
Quoted 12 lines · Linus Walleij
Quoted 10 lines · Lee Jones

The ab8500 GPIO driver is currently 'BROKEN', due to a lack of updates and recent frame-work adoption. This patch-set aims to bring the driver back to life so we may make use of it again.

This first stage is to bring it into line with ST-Ericsson's internal track, which has been keeping up-to-date. After these patches have been accepted I will then overhaul the driver to use the most recent APIs and frame-works, such as pinctrl and Device Tree.

Quoted 6 lines
Quoted 3 lines

Please give these patches an easy ride. I know they're not perfect, but they do provide a great base on with I can form the overhaul. Thanks for your understanding.

OK I've applied these 21 patches on a branch in the pinctrl tree to be used as a merge base.

No I'll have to scrap this topic branch, as it does not compile.

Analysing the problem I see that part of the reason why it does not compile is that it is adding stuff referencing the global numberspace, like biasing.

Which is pinctrl business. So the proper feedback is that it should be rewritten to use pinctrl.

Which is in the works.

So the plan is to mail out an all-in-one pinctrl replacement patch instead, deleting the old AB8500 GPIO driver and replacing it fully with a pinctrl driver.

Yours,
Linus Walleij

author
#26 lore raw
Quoted 26 lines · Linus Walleij
Quoted 12 lines · Linus Walleij
Quoted 10 lines · Lee Jones

The ab8500 GPIO driver is currently 'BROKEN', due to a lack of updates and recent frame-work adoption. This patch-set aims to bring the driver back to life so we may make use of it again.

This first stage is to bring it into line with ST-Ericsson's internal track, which has been keeping up-to-date. After these patches have been accepted I will then overhaul the driver to use the most recent APIs and frame-works, such as pinctrl and Device Tree.

Quoted 6 lines
Quoted 3 lines

Please give these patches an easy ride. I know they're not perfect, but they do provide a great base on with I can form the overhaul. Thanks for your understanding.

OK I've applied these 21 patches on a branch in the pinctrl tree to be used as a merge base.

No I'll have to scrap this topic branch, as it does not compile.

Analysing the problem I see that part of the reason why it does not compile is that it is adding stuff referencing the global numberspace, like biasing.

Quoted 8 lines

Which is pinctrl business. So the proper feedback is that it should be rewritten to use pinctrl.

Which is in the works.

So the plan is to mail out an all-in-one pinctrl replacement patch instead, deleting the old AB8500 GPIO driver and replacing it fully with a pinctrl driver.

Makes sense, although that's going to be a hell of a patch-set.

Signature · 4 lines
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#27 lore raw
In reply to Lee Jones
Quoted 10 lines · Lee Jones

The ab8500 GPIO driver is currently 'BROKEN', due to a lack of updates and recent frame-work adoption. This patch-set aims to bring the driver back to life so we may make use of it again.

This first stage is to bring it into line with ST-Ericsson's internal track, which has been keeping up-to-date. After these patches have been accepted I will then overhaul the driver to use the most recent APIs and frame-works, such as pinctrl and Device Tree.

Quoted 3 lines

Please give these patches an easy ride. I know they're not perfect, but they do provide a great base on with I can form the overhaul. Thanks for your understanding.

Since it's already broken, I'll probably pick up the majority of these as long as they make the world better. I'll reply to each in turn.

g.