diff options
author | Huacai Chen <chenhc@lemote.com> | 2015-03-31 22:20:08 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-04-07 05:15:56 -0400 |
commit | 991ff4e3d71dcad184d18f9b1b241f3191601909 (patch) | |
tree | 43f63402b1235ec66be75d95aa11ba29c1398e19 /arch/mips | |
parent | df5dade4a7b29b003e000c5db5c35612e0b1019b (diff) |
MIPS: Move Loongson GPIO driver to drivers/gpio
Move Loongson-2's GPIO driver to drivers/gpio and add Kconfig options.
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Huacai Chen <chenhc@lemote.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/configs/lemote2f_defconfig | 1 | ||||
-rw-r--r-- | arch/mips/loongson/common/Makefile | 1 | ||||
-rw-r--r-- | arch/mips/loongson/common/gpio.c | 105 |
3 files changed, 1 insertions, 106 deletions
diff --git a/arch/mips/configs/lemote2f_defconfig b/arch/mips/configs/lemote2f_defconfig index e51aad9a94b1..0cbc9863c7c8 100644 --- a/arch/mips/configs/lemote2f_defconfig +++ b/arch/mips/configs/lemote2f_defconfig | |||
@@ -171,6 +171,7 @@ CONFIG_SERIAL_8250_FOURPORT=y | |||
171 | CONFIG_LEGACY_PTY_COUNT=16 | 171 | CONFIG_LEGACY_PTY_COUNT=16 |
172 | CONFIG_HW_RANDOM=y | 172 | CONFIG_HW_RANDOM=y |
173 | CONFIG_RTC=y | 173 | CONFIG_RTC=y |
174 | CONFIG_GPIO_LOONGSON=y | ||
174 | CONFIG_THERMAL=y | 175 | CONFIG_THERMAL=y |
175 | CONFIG_MEDIA_SUPPORT=m | 176 | CONFIG_MEDIA_SUPPORT=m |
176 | CONFIG_VIDEO_DEV=m | 177 | CONFIG_VIDEO_DEV=m |
diff --git a/arch/mips/loongson/common/Makefile b/arch/mips/loongson/common/Makefile index d87e03330b29..e70c33fdb881 100644 --- a/arch/mips/loongson/common/Makefile +++ b/arch/mips/loongson/common/Makefile | |||
@@ -4,7 +4,6 @@ | |||
4 | 4 | ||
5 | obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \ | 5 | obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \ |
6 | bonito-irq.o mem.o machtype.o platform.o | 6 | bonito-irq.o mem.o machtype.o platform.o |
7 | obj-$(CONFIG_GPIOLIB) += gpio.o | ||
8 | obj-$(CONFIG_PCI) += pci.o | 7 | obj-$(CONFIG_PCI) += pci.o |
9 | 8 | ||
10 | # | 9 | # |
diff --git a/arch/mips/loongson/common/gpio.c b/arch/mips/loongson/common/gpio.c deleted file mode 100644 index b4e69e0ed92b..000000000000 --- a/arch/mips/loongson/common/gpio.c +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | /* | ||
2 | * STLS2F GPIO Support | ||
3 | * | ||
4 | * Copyright (c) 2008 Richard Liu, STMicroelectronics <richard.liu@st.com> | ||
5 | * Copyright (c) 2008-2010 Arnaud Patard <apatard@mandriva.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/spinlock.h> | ||
17 | #include <linux/err.h> | ||
18 | #include <asm/types.h> | ||
19 | #include <loongson.h> | ||
20 | #include <linux/gpio.h> | ||
21 | |||
22 | #define STLS2F_N_GPIO 4 | ||
23 | #define STLS2F_GPIO_IN_OFFSET 16 | ||
24 | |||
25 | static DEFINE_SPINLOCK(gpio_lock); | ||
26 | |||
27 | static int ls2f_gpio_direction_input(struct gpio_chip *chip, unsigned gpio) | ||
28 | { | ||
29 | u32 temp; | ||
30 | u32 mask; | ||
31 | |||
32 | spin_lock(&gpio_lock); | ||
33 | mask = 1 << gpio; | ||
34 | temp = LOONGSON_GPIOIE; | ||
35 | temp |= mask; | ||
36 | LOONGSON_GPIOIE = temp; | ||
37 | spin_unlock(&gpio_lock); | ||
38 | |||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | static int ls2f_gpio_direction_output(struct gpio_chip *chip, | ||
43 | unsigned gpio, int level) | ||
44 | { | ||
45 | u32 temp; | ||
46 | u32 mask; | ||
47 | |||
48 | gpio_set_value(gpio, level); | ||
49 | spin_lock(&gpio_lock); | ||
50 | mask = 1 << gpio; | ||
51 | temp = LOONGSON_GPIOIE; | ||
52 | temp &= (~mask); | ||
53 | LOONGSON_GPIOIE = temp; | ||
54 | spin_unlock(&gpio_lock); | ||
55 | |||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static int ls2f_gpio_get_value(struct gpio_chip *chip, unsigned gpio) | ||
60 | { | ||
61 | u32 val; | ||
62 | u32 mask; | ||
63 | |||
64 | mask = 1 << (gpio + STLS2F_GPIO_IN_OFFSET); | ||
65 | spin_lock(&gpio_lock); | ||
66 | val = LOONGSON_GPIODATA; | ||
67 | spin_unlock(&gpio_lock); | ||
68 | |||
69 | return (val & mask) != 0; | ||
70 | } | ||
71 | |||
72 | static void ls2f_gpio_set_value(struct gpio_chip *chip, | ||
73 | unsigned gpio, int value) | ||
74 | { | ||
75 | u32 val; | ||
76 | u32 mask; | ||
77 | |||
78 | mask = 1 << gpio; | ||
79 | |||
80 | spin_lock(&gpio_lock); | ||
81 | val = LOONGSON_GPIODATA; | ||
82 | if (value) | ||
83 | val |= mask; | ||
84 | else | ||
85 | val &= (~mask); | ||
86 | LOONGSON_GPIODATA = val; | ||
87 | spin_unlock(&gpio_lock); | ||
88 | } | ||
89 | |||
90 | static struct gpio_chip ls2f_chip = { | ||
91 | .label = "ls2f", | ||
92 | .direction_input = ls2f_gpio_direction_input, | ||
93 | .get = ls2f_gpio_get_value, | ||
94 | .direction_output = ls2f_gpio_direction_output, | ||
95 | .set = ls2f_gpio_set_value, | ||
96 | .base = 0, | ||
97 | .ngpio = STLS2F_N_GPIO, | ||
98 | .can_sleep = false, | ||
99 | }; | ||
100 | |||
101 | static int __init ls2f_gpio_setup(void) | ||
102 | { | ||
103 | return gpiochip_add(&ls2f_chip); | ||
104 | } | ||
105 | arch_initcall(ls2f_gpio_setup); | ||