Skip to contentSkip to conversation

gpio: xtensa: Implement .direction_input and .direction_output callbacks

PATCH In review Axel Lin 2 participants 2 messages Apr 25, 2014 – Apr 26, 2014 GPIO

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 gpio: xtensa: Implement .direction_input and .direction_output callbacks

The implementation of _gpiod_direction_output_raw() checks both .set and .direction_output callbacks. To make gpio_direction_output() works, both .set and .direction_output callbacks needs to be implemented in the driver.

Similarly, gpiod_direction_input() checks both .get and .direction_input callbacks. To make gpio_direction_input() works, both .get and .direction_input needs to be implemented in the driver.

---
Hi Baruch,
I don't have this h/w to test, so this patch needs test.
I think both gpio_direction_output() and gpio_direction_input() do not work without this patch. Which means gpio_request_one() also does not work.

BTW, I also hit below build error.
CC drivers/gpio/gpio-xtensa.o
drivers/gpio/gpio-xtensa.c: Assembler messages:
drivers/gpio/gpio-xtensa.c:87: Error: unknown opcode or format name 'read_impwire' drivers/gpio/gpio-xtensa.c:116: Error: unknown opcode or format name 'rur.expstate' drivers/gpio/gpio-xtensa.c:130: Error: unknown opcode or format name 'wrmsk_expstate' make[2]: *** [drivers/gpio/gpio-xtensa.o] Error 1
make[1]: *** [drivers/gpio] Error 2
make: *** [drivers] Error 2
(I found the same build error is already reported by Geert Uytterhoeven.)

Regards,
Axel

 drivers/gpio/gpio-xtensa.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpio/gpio-xtensa.c +15 -0
index 7081304..ed6d874 100644
@@ -96,6 +96,12 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
 	BUG(); /* output only; should never be called */
 }
 
+static int xtensa_impwire_direction_input(struct gpio_chip *gc,
+					  unsigned offset)
+{
+	return 0;
+}
+
 static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	return 0; /* output only */
@@ -126,6 +132,13 @@ static void xtensa_expstate_set_value(struct gpio_chip *gc, unsigned offset,
 	disable_cp(flags, saved_cpenable);
 }
 
+static int xtensa_expstate_direction_output(struct gpio_chip *gc,
+					    unsigned offset, int value)
+{
+	xtensa_expstate_set_value(gc, offset, value);
+	return 0;
+}
+
 static struct gpio_chip impwire_chip = {
 	.label		= "impwire",
 	.base		= -1,
@@ -133,6 +146,7 @@ static struct gpio_chip impwire_chip = {
 	.get_direction	= xtensa_impwire_get_direction,
 	.get		= xtensa_impwire_get_value,
 	.set		= xtensa_impwire_set_value,
+	.direction_input = xtensa_impwire_direction_input,
 };
 
 static struct gpio_chip expstate_chip = {
@@ -142,6 +156,7 @@ static struct gpio_chip expstate_chip = {
 	.get_direction	= xtensa_expstate_get_direction,
 	.get		= xtensa_expstate_get_value,
 	.set		= xtensa_expstate_set_value,
+	.direction_output = xtensa_expstate_direction_output,
 };
 
 static int xtensa_gpio_probe(struct platform_device *pdev)
Signature · 1 line
1.8.3.2
#1 lore raw

Hi Axel,

Quoted 8 lines · Axel Lin

The implementation of _gpiod_direction_output_raw() checks both .set and .direction_output callbacks. To make gpio_direction_output() works, both .set and .direction_output callbacks needs to be implemented in the driver.

Similarly, gpiod_direction_input() checks both .get and .direction_input callbacks. To make gpio_direction_input() works, both .get and .direction_input needs to be implemented in the driver.

Quoted 6 lines

---
Hi Baruch,
I don't have this h/w to test, so this patch needs test.
I think both gpio_direction_output() and gpio_direction_input() do not work without this patch. Which means gpio_request_one() also does not work.

I don't have access to this hardware anymore either. Adding the Xtensa list to Cc.

Quoted 10 lines

BTW, I also hit below build error.
CC drivers/gpio/gpio-xtensa.o
drivers/gpio/gpio-xtensa.c: Assembler messages:
drivers/gpio/gpio-xtensa.c:87: Error: unknown opcode or format name 'read_impwire' drivers/gpio/gpio-xtensa.c:116: Error: unknown opcode or format name 'rur.expstate' drivers/gpio/gpio-xtensa.c:130: Error: unknown opcode or format name 'wrmsk_expstate' make[2]: *** [drivers/gpio/gpio-xtensa.o] Error 1
make[1]: *** [drivers/gpio] Error 2
make: *** [drivers] Error 2
(I found the same build error is already reported by Geert Uytterhoeven.)

This should be fixed by commit 8e9356c6146d0 (xtensa: fsf: drop nonexistent GPIO32 support) for the fsf variant. This commit is included in v3.14. If you build a different variant you must use a matching toolchain.

baruch

Quoted 51 lines
 drivers/gpio/gpio-xtensa.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/gpio/gpio-xtensa.c +15 -0
index 7081304..ed6d874 100644
@@ -96,6 +96,12 @@ static void xtensa_impwire_set_value(struct gpio_chip *gc, unsigned offset,
 	BUG(); /* output only; should never be called */
 }
 
+static int xtensa_impwire_direction_input(struct gpio_chip *gc,
+					  unsigned offset)
+{
+	return 0;
+}
+
 static int xtensa_expstate_get_direction(struct gpio_chip *gc, unsigned offset)
 {
 	return 0; /* output only */
@@ -126,6 +132,13 @@ static void xtensa_expstate_set_value(struct gpio_chip *gc, unsigned offset,
 	disable_cp(flags, saved_cpenable);
 }
 
+static int xtensa_expstate_direction_output(struct gpio_chip *gc,
+					    unsigned offset, int value)
+{
+	xtensa_expstate_set_value(gc, offset, value);
+	return 0;
+}
+
 static struct gpio_chip impwire_chip = {
 	.label		= "impwire",
 	.base		= -1,
@@ -133,6 +146,7 @@ static struct gpio_chip impwire_chip = {
 	.get_direction	= xtensa_impwire_get_direction,
 	.get		= xtensa_impwire_get_value,
 	.set		= xtensa_impwire_set_value,
+	.direction_input = xtensa_impwire_direction_input,
 };
 
 static struct gpio_chip expstate_chip = {
@@ -142,6 +156,7 @@ static struct gpio_chip expstate_chip = {
 	.get_direction	= xtensa_expstate_get_direction,
 	.get		= xtensa_expstate_get_value,
 	.set		= xtensa_expstate_set_value,
+	.direction_output = xtensa_expstate_direction_output,
 };
 
 static int xtensa_gpio_probe(struct platform_device *pdev)
Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -