Skip to contentSkip to conversation

loongson 2f: Add gpio/gpioilb support

PATCH In review Arnaud Patard 3 participants 4 messages Apr 29, 2010 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loongson 2f: Add gpio/gpioilb support

This patch is adding support for the 4 GPIO availables on the ST LS2F cpus.

---

arch/mips/Kconfig | 2 2 + 0 - 0 !

 arch/mips/include/asm/mach-lemote/gpio.h |   33 	33 +	0 -	0 !
 arch/mips/loongson/common/Makefile           |    2 	2 +	0 -	0 !
 arch/mips/loongson/common/gpio.c             |  128 	128 +	0 -	0 !
 arch/mips/loongson/common/platform.c         |   25 	25 +	0 -	0 !
 5 files changed, 190 insertions(+)
arch/mips/Kconfig +2 -0
Index: linux-2.6/arch/mips/Kconfig
===================================================================
@@ -1073,6 +1073,8 @@ config CPU_LOONGSON2F
 	bool "Loongson 2F"
 	depends on SYS_HAS_CPU_LOONGSON2F
 	select CPU_LOONGSON2
+	select GENERIC_GPIO
+	select ARCH_REQUIRE_GPIOLIB
 	help
 	  The Loongson 2F processor implements the MIPS III instruction set
 	  with many extensions.
arch/mips/loongson/common/gpio.c new file +140 -0

140 lines not on this page · raw message

arch/mips/loongson/common/Makefile +1 -0
Index: linux-2.6/arch/mips/loongson/common/Makefile
===================================================================
@@ -4,6 +4,7 @@
 
 obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \
     pci.o bonito-irq.o mem.o machtype.o platform.o
+obj-$(CONFIG_GENERIC_GPIO) += gpio.o
 
 #
 # Serial port support
arch/mips/include/asm/mach-loongson/gpio.h new file +35 -0
Index: linux-2.6/arch/mips/include/asm/mach-loongson/gpio.h
===================================================================
@@ -0,0 +1,35 @@
+/*
+ * STLS2F GPIO Support
+ *
+ * Copyright (c) 2008  Richard Liu, STMicroelectronics <[email protected]>
+ * Copyright (c) 2008-2010  Arnaud Patard <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef	__STLS2F_GPIO_H
+#define	__STLS2F_GPIO_H
+
+#include <asm-generic/gpio.h>
+
+extern void gpio_set_value(unsigned gpio, int value);
+extern int gpio_get_value(unsigned gpio);
+extern int gpio_cansleep(unsigned gpio);
+
+/* The chip can do interrupt
+ * but it has not been tested and doc not clear
+ */
+static inline int gpio_to_irq(int gpio)
+{
+	return -EINVAL;
+}
+
+static inline int irq_to_gpio(int gpio)
+{
+	return -EINVAL;
+}
+
+#endif				/* __STLS2F_GPIO_H */
#1 lore raw
Quoted 5 lines · Arnaud Patard

This patch is adding support for the 4 GPIO availables on the ST LS2F cpus.

---

[...]

Quoted 1 line

Index: linux-2.6/arch/mips/loongson/common/gpio.c

[...]

arch/mips/loongson/common/gpio.c line 140

Quoted 7 lines
arch/mips/loongson/common/gpio.c new file +7 -0
+
+static int __init ls2f_gpio_setup(void)
+{
+	return gpiochip_add(&ls2f_chip);
+}
+arch_initcall(ls2f_gpio_setup);
+

The above blank line is at the end of the file, we can remove it, otherwise, "git am" will complain about it.

Regards,
Wu Zhangjin

#2 lore raw
Quoted 9 lines · Wu Zhangjin
Quoted 5 lines · Arnaud Patard

This patch is adding support for the 4 GPIO availables on the ST LS2F cpus.

---

[...]

Quoted 1 line

Index: linux-2.6/arch/mips/loongson/common/gpio.c

[...]

Quoted 10 lines

arch/mips/loongson/common/gpio.c line 140

Quoted 7 lines
arch/mips/loongson/common/gpio.c new file +7 -0
+
+static int __init ls2f_gpio_setup(void)
+{
+	return gpiochip_add(&ls2f_chip);
+}
+arch_initcall(ls2f_gpio_setup);
+

The above blank line is at the end of the file, we can remove it, otherwise, "git am" will complain about it.

Then, please, either fix your tool or fix it yourself. Last time I've looked at Documentation/SubmittingPatches, it was not mentionned. Moreover, checkpatch.pl is not complaining. If you really think, it's a must have, ask to fix checkpatch.pl first otherwise it's going to be missed again and again.

Thanks,
Arnaud

#3 lore raw
Quoted 8 lines · Arnaud Patard
Quoted 2 lines

The above blank line is at the end of the file, we can remove it, otherwise, "git am" will complain about it.

Then, please, either fix your tool or fix it yourself. Last time I've looked at Documentation/SubmittingPatches, it was not mentionned. Moreover, checkpatch.pl is not complaining. If you really think, it's a must have, ask to fix checkpatch.pl first otherwise it's going to be missed again and again.

git-am will complain about it - with a not terribly helpful message that does not mention the offending file. I've configured git to strip trailing whitespace and blank lines automatically. In a patch series this could lead to the problem where a subsequent patch fails to apply because got modified.

Quoted 6 lines
 arch/mips/Kconfig                        |    2      2 +     0 -     0 !
 arch/mips/include/asm/mach-lemote/gpio.h |   33      33 +    0 -     0 !
 arch/mips/loongson/common/Makefile           |    2  2 +     0 -     0 !
 arch/mips/loongson/common/gpio.c             |  128  128 +   0 -     0 !
 arch/mips/loongson/common/platform.c         |   25  25 +    0 -     0 !
 5 files changed, 190 insertions(+)

Your diffstat doesn't match what's in the patch:

 arch/mips/Kconfig                          |    2 
 arch/mips/loongson/common/gpio.c           |  140 ++++++++++++++++++++++++++++
 arch/mips/loongson/common/Makefile         |    1 
 arch/mips/include/asm/mach-loongson/gpio.h |   35 +++++++
 4 files changed, 178 insertions(+), 0 deletions(-)

So what's wrong, diffstat or patch?

Ralf