Skip to contentSkip to conversation

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

PATCH Superseded Nava kishore Manne 5 participants 5 messages Sep 20, 2016 – Sep 23, 2016

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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

---
 drivers/gpio/gpio-zynq.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/gpio/gpio-zynq.c +15 -2
index e72794e..eae9d24 100644
@@ -96,6 +96,10 @@
 /* GPIO upper 16 bit mask */
 #define ZYNQ_GPIO_UPPER_MASK 0xFFFF0000
 
+/* For GPIO quirks */
+#define ZYNQ_GPIO	BIT(0)
+#define ZYNQMP_GPIO	BIT(1)
+
 /**
  * struct zynq_gpio - gpio device private data structure
  * @chip:	instance of the gpio_chip
@@ -122,6 +126,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 +243,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;
 	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 */
@@ -609,6 +620,7 @@ static const struct dev_pm_ops zynq_gpio_dev_pm_ops = {
 
 static const struct zynq_platform_data zynqmp_gpio_def = {
 	.label = "zynqmp_gpio",
+	.quirks = ZYNQMP_GPIO,
 	.ngpio = ZYNQMP_GPIO_NR_GPIOS,
 	.max_bank = ZYNQMP_GPIO_MAX_BANK,
 	.bank_min[0] = ZYNQ_GPIO_BANK0_PIN_MIN(MP),
@@ -627,6 +639,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,
 	.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
Acked-by on v1 1/1
#1 lore raw
Quoted 15 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

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

drivers/gpio/gpio-zynq.c line 101

Quoted 6 lines
drivers/gpio/gpio-zynq.c +3 -0
@@ -96,6 +96,10 @@
 /* GPIO upper 16 bit mask */
 #define ZYNQ_GPIO_UPPER_MASK 0xFFFF0000
 
+/* For GPIO quirks */
+#define ZYNQ_GPIO	BIT(0)
+#define ZYNQMP_GPIO	BIT(1)

I'd make sure all quirks are easily identifiable and call them something like 'ZYNQ_GPIO_QUIRK_FOO'

Apart from that:

S?ren

Acked-by
#2 lore raw
Quoted 26 lines · S?ren Brinkmann
Quoted 15 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

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

drivers/gpio/gpio-zynq.c line 101

Quoted 6 lines
drivers/gpio/gpio-zynq.c +3 -0
@@ -96,6 +96,10 @@
 /* GPIO upper 16 bit mask */
 #define ZYNQ_GPIO_UPPER_MASK 0xFFFF0000
 
+/* For GPIO quirks */
+#define ZYNQ_GPIO	BIT(0)
+#define ZYNQMP_GPIO	BIT(1)

I'd make sure all quirks are easily identifiable and call them something like 'ZYNQ_GPIO_QUIRK_FOO'

Quoted 3 lines

Apart from that:

This issue was:

And here is also my:

Thanks,
Michal

Signature · 14 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP SoCs


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160921/7059a368/attachment.sig>
#3 lore raw
In reply to Nava kishore Manne
Quoted 4 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

Is there any such pins for zynqmp?

Quoted 11 lines
---
 drivers/gpio/gpio-zynq.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/gpio/gpio-zynq.c +0 -0
index e72794e..eae9d24 100644

drivers/gpio/gpio-zynq.c line 101

Quoted 6 lines
drivers/gpio/gpio-zynq.c +3 -0
@@ -96,6 +96,10 @@
 /* GPIO upper 16 bit mask */
 #define ZYNQ_GPIO_UPPER_MASK 0xFFFF0000
 
+/* For GPIO quirks */
+#define ZYNQ_GPIO      BIT(0)
+#define ZYNQMP_GPIO    BIT(1)

if not can we remove ZYNQMP_GPIO ?