Skip to contentSkip to conversation

gpio: Added zynq specific check for special pins on bank zero

PATCH In review Nava kishore Manne 3 participants 3 messages Sep 23, 2016 – Sep 24, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 gpio: Added zynq specific check for special pins on bank zero

From: Nava kishore Manne <[email protected]>

This patch adds zynq specific check for bank 0 pins 7 and 8 are special and cannot be used as inputs

---
Changes for v3:
-Fixed some minor comments.
Changes for v2:
-Removed un-used quirks for zynqmp.

 drivers/gpio/gpio-zynq.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpio/gpio-zynq.c +13 -2
index e72794e..6b4d10d 100644
@@ -96,6 +96,9 @@
 /* GPIO upper 16 bit mask */
 #define ZYNQ_GPIO_UPPER_MASK 0xFFFF0000
 
+/* For GPIO quirks */
+#define ZYNQ_GPIO_QUIRK_FOO	BIT(0)
+
 /**
  * struct zynq_gpio - gpio device private data structure
  * @chip:	instance of the gpio_chip
@@ -122,6 +125,7 @@ struct zynq_gpio {
 */
 struct zynq_platform_data {
 	const char *label;
+	u32 quirks;
 	u16 ngpio;
 	int max_bank;
 	int bank_min[ZYNQMP_GPIO_MAX_BANK];
@@ -238,13 +242,19 @@ static void zynq_gpio_set_value(struct gpio_chip *chip, unsigned int pin,
 static int zynq_gpio_dir_in(struct gpio_chip *chip, unsigned int pin)
 {
 	u32 reg;
+	bool is_zynq_gpio;
 	unsigned int bank_num, bank_pin_num;
 	struct zynq_gpio *gpio = gpiochip_get_data(chip);
 
+	is_zynq_gpio = gpio->p_data->quirks & ZYNQ_GPIO_QUIRK_FOO;
 	zynq_gpio_get_bank_pin(pin, &bank_num, &bank_pin_num, gpio);
 
-	/* bank 0 pins 7 and 8 are special and cannot be used as inputs */
-	if (bank_num == 0 && (bank_pin_num == 7 || bank_pin_num == 8))
+	/*
+	 * On zynq bank 0 pins 7 and 8 are special and cannot be used
+	 * as inputs.
+	 */
+	if (is_zynq_gpio && bank_num == 0 &&
+		(bank_pin_num == 7 || bank_pin_num == 8))
 		return -EINVAL;
 
 	/* clear the bit in direction mode reg to set the pin as input */
@@ -627,6 +637,7 @@ static const struct zynq_platform_data zynqmp_gpio_def = {
 
 static const struct zynq_platform_data zynq_gpio_def = {
 	.label = "zynq_gpio",
+	.quirks = ZYNQ_GPIO_QUIRK_FOO,
 	.ngpio = ZYNQ_GPIO_NR_GPIOS,
 	.max_bank = ZYNQ_GPIO_MAX_BANK,
 	.bank_min[0] = ZYNQ_GPIO_BANK0_PIN_MIN(),
Signature · 1 line
2.1.2
#1 lore raw
Quoted 5 lines · Nava kishore Manne

From: Nava kishore Manne <[email protected]>

This patch adds zynq specific check for bank 0 pins 7 and 8 are special and cannot be used as inputs

Quoted 7 lines

---
Changes for v3:
-Fixed some minor comments.

Patch applied.

Yours,
Linus Walleij

#2 lore raw
In reply to Nava kishore Manne
Quoted 23 lines · Nava kishore Manne

From: Nava kishore Manne <[email protected]>

This patch adds zynq specific check for bank 0 pins 7 and 8 are special and cannot be used as inputs

---
Changes for v3:
-Fixed some minor comments.
Changes for v2:
-Removed un-used quirks for zynqmp.

  drivers/gpio/gpio-zynq.c | 15 +++++++++++++--
  1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpio/gpio-zynq.c +0 -0
index e72794e..6b4d10d 100644

drivers/gpio/gpio-zynq.c line 100

Quoted 5 lines
drivers/gpio/gpio-zynq.c +2 -0
@@ -96,6 +96,9 @@
  /* GPIO upper 16 bit mask */
  #define ZYNQ_GPIO_UPPER_MASK 0xFFFF0000
 
+/* For GPIO quirks */
+#define ZYNQ_GPIO_QUIRK_FOO	BIT(0)

Should this be a bit more descriptive than FOO?