aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-18 08:22:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-18 08:22:10 -0400
commit510965dd4a0a59504ba38455f77339ea8b4c6a70 (patch)
tree36492629ac68de94457482562660154f28e9e039 /arch/mips
parent40d7839879b4584f91522d841afb22ed401cf40f (diff)
parent03daa6f82f2b634019fe8261698f6af3c133497f (diff)
Merge tag 'gpio-v4.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO updates from Linus Walleij: "This is the bulk of GPIO changes for the v4.1 development cycle: - A new GPIO hogging mechanism has been added. This can be used on boards that want to drive some GPIO line high, low, or set it as input on boot and then never touch it again. For some embedded systems this is bliss and simplifies things to a great extent. - Some API cleanup and closure: gpiod_get_array() and gpiod_put_array() has been added to get and put GPIOs in bulk as was possible with the non-descriptor API. - Encapsulate cross-calls to the pin control subsystem in <linux/gpio/driver.h>. Now this should be the only header any GPIO driver needs to include or something is wrong. Cleanups restricting drivers to this include are welcomed if tested. - Sort the GPIO Kconfig and split it into submenus, as it was becoming and unstructured, illogical and unnavigatable mess. I hope this is easier to follow. Menus that require a certain subsystem like I2C can now be hidden nicely for example, still working on others. - New drivers: - New driver for the Altera Soft GPIO. - The F7188x driver now handles the F71869 and F71869A variants. - The MIPS Loongson driver has been moved to drivers/gpio for consolidation and cleanup. - Cleanups: - The MAX732x is converted to use the GPIOLIB_IRQCHIP infrastructure. - The PCF857x is converted to use the GPIOLIB_IRQCHIP infrastructure. - Radical cleanup of the OMAP driver. - Misc: - Enable the DWAPB GPIO for all architectures. This is a "hard IP" block from Synopsys which has started to turn up in so diverse architectures as X86 Quark, ARC and a slew of ARM systems. So even though it's not an expander, it's generic enough to be available for all. - We add a mock GPIO on Crystalcove PMIC after a long discussion with Daniel Vetter et al, tracing back to the shootout at the kernel summit where DRM drivers and sub-componentization was discussed. In this case a mock GPIO is assumed to be the best compromise gaining some reuse of infrastructure without making DRM drivers overly complex at the same time. Let's see" * tag 'gpio-v4.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: (62 commits) Revert "gpio: sch: use uapi/linux/pci_ids.h directly" gpio: dwapb: remove dependencies gpio: dwapb: enable for ARC gpio: removing kfree remove functionality gpio: mvebu: Fix mask/unmask managment per irq chip type gpio: split GPIO drivers in submenus gpio: move MFD GPIO drivers under their own comment gpio: move BCM Kona Kconfig option gpio: arrange SPI Kconfig symbols alphabetically gpio: arrange PCI GPIO controllers alphabetically gpio: arrange I2C Kconfig symbols alphabetically gpio: arrange Kconfig symbols alphabetically gpio: ich: Implement get_direction function gpio: use (!foo) instead of (foo == NULL) gpio: arizona: drop owner assignment from platform_drivers gpio: max7300: remove 'ret' variable gpio: use devm_kzalloc gpio: sch: use uapi/linux/pci_ids.h directly gpio: x-gene: fix devm_ioremap_resource() check gpio: loongson: Add Loongson-3A/3B GPIO driver support ...
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/mips/configs/lemote2f_defconfig1
-rw-r--r--arch/mips/configs/loongson3_defconfig1
-rw-r--r--arch/mips/include/asm/mach-loongson/gpio.h15
-rw-r--r--arch/mips/loongson/common/Makefile1
-rw-r--r--arch/mips/loongson/common/gpio.c139
6 files changed, 11 insertions, 147 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 2198837c256f..f5016656494f 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1288,6 +1288,7 @@ config CPU_LOONGSON3
1288 select CPU_SUPPORTS_HUGEPAGES 1288 select CPU_SUPPORTS_HUGEPAGES
1289 select WEAK_ORDERING 1289 select WEAK_ORDERING
1290 select WEAK_REORDERING_BEYOND_LLSC 1290 select WEAK_REORDERING_BEYOND_LLSC
1291 select ARCH_REQUIRE_GPIOLIB
1291 help 1292 help
1292 The Loongson 3 processor implements the MIPS64R2 instruction 1293 The Loongson 3 processor implements the MIPS64R2 instruction
1293 set with many extensions. 1294 set with many extensions.
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
171CONFIG_LEGACY_PTY_COUNT=16 171CONFIG_LEGACY_PTY_COUNT=16
172CONFIG_HW_RANDOM=y 172CONFIG_HW_RANDOM=y
173CONFIG_RTC=y 173CONFIG_RTC=y
174CONFIG_GPIO_LOONGSON=y
174CONFIG_THERMAL=y 175CONFIG_THERMAL=y
175CONFIG_MEDIA_SUPPORT=m 176CONFIG_MEDIA_SUPPORT=m
176CONFIG_VIDEO_DEV=m 177CONFIG_VIDEO_DEV=m
diff --git a/arch/mips/configs/loongson3_defconfig b/arch/mips/configs/loongson3_defconfig
index 7eabcd2031ea..c8442997477b 100644
--- a/arch/mips/configs/loongson3_defconfig
+++ b/arch/mips/configs/loongson3_defconfig
@@ -243,6 +243,7 @@ CONFIG_HW_RANDOM=y
243CONFIG_RAW_DRIVER=m 243CONFIG_RAW_DRIVER=m
244CONFIG_I2C_CHARDEV=y 244CONFIG_I2C_CHARDEV=y
245CONFIG_I2C_PIIX4=y 245CONFIG_I2C_PIIX4=y
246CONFIG_GPIO_LOONGSON=y
246CONFIG_SENSORS_LM75=m 247CONFIG_SENSORS_LM75=m
247CONFIG_SENSORS_LM93=m 248CONFIG_SENSORS_LM93=m
248CONFIG_SENSORS_W83627HF=m 249CONFIG_SENSORS_W83627HF=m
diff --git a/arch/mips/include/asm/mach-loongson/gpio.h b/arch/mips/include/asm/mach-loongson/gpio.h
index 211a7b7138fe..b3b216904a9a 100644
--- a/arch/mips/include/asm/mach-loongson/gpio.h
+++ b/arch/mips/include/asm/mach-loongson/gpio.h
@@ -1,8 +1,9 @@
1/* 1/*
2 * STLS2F GPIO Support 2 * Loongson GPIO Support
3 * 3 *
4 * Copyright (c) 2008 Richard Liu, STMicroelectronics <richard.liu@st.com> 4 * Copyright (c) 2008 Richard Liu, STMicroelectronics <richard.liu@st.com>
5 * Copyright (c) 2008-2010 Arnaud Patard <apatard@mandriva.com> 5 * Copyright (c) 2008-2010 Arnaud Patard <apatard@mandriva.com>
6 * Copyright (c) 2014 Huacai Chen <chenhc@lemote.com>
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 * it under the terms of the GNU General Public License as published by
@@ -10,14 +11,14 @@
10 * (at your option) any later version. 11 * (at your option) any later version.
11 */ 12 */
12 13
13#ifndef __STLS2F_GPIO_H 14#ifndef __LOONGSON_GPIO_H
14#define __STLS2F_GPIO_H 15#define __LOONGSON_GPIO_H
15 16
16#include <asm-generic/gpio.h> 17#include <asm-generic/gpio.h>
17 18
18extern void gpio_set_value(unsigned gpio, int value); 19#define gpio_get_value __gpio_get_value
19extern int gpio_get_value(unsigned gpio); 20#define gpio_set_value __gpio_set_value
20extern int gpio_cansleep(unsigned gpio); 21#define gpio_cansleep __gpio_cansleep
21 22
22/* The chip can do interrupt 23/* The chip can do interrupt
23 * but it has not been tested and doc not clear 24 * but it has not been tested and doc not clear
@@ -32,4 +33,4 @@ static inline int irq_to_gpio(int gpio)
32 return -EINVAL; 33 return -EINVAL;
33} 34}
34 35
35#endif /* __STLS2F_GPIO_H */ 36#endif /* __LOONGSON_GPIO_H */
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
5obj-y += setup.o init.o cmdline.o env.o time.o reset.o irq.o \ 5obj-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
7obj-$(CONFIG_GPIOLIB) += gpio.o
8obj-$(CONFIG_PCI) += pci.o 7obj-$(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 29dbaa253061..000000000000
--- a/arch/mips/loongson/common/gpio.c
+++ /dev/null
@@ -1,139 +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
25static DEFINE_SPINLOCK(gpio_lock);
26
27int gpio_get_value(unsigned gpio)
28{
29 u32 val;
30 u32 mask;
31
32 if (gpio >= STLS2F_N_GPIO)
33 return __gpio_get_value(gpio);
34
35 mask = 1 << (gpio + STLS2F_GPIO_IN_OFFSET);
36 spin_lock(&gpio_lock);
37 val = LOONGSON_GPIODATA;
38 spin_unlock(&gpio_lock);
39
40 return (val & mask) != 0;
41}
42EXPORT_SYMBOL(gpio_get_value);
43
44void gpio_set_value(unsigned gpio, int state)
45{
46 u32 val;
47 u32 mask;
48
49 if (gpio >= STLS2F_N_GPIO) {
50 __gpio_set_value(gpio, state);
51 return ;
52 }
53
54 mask = 1 << gpio;
55
56 spin_lock(&gpio_lock);
57 val = LOONGSON_GPIODATA;
58 if (state)
59 val |= mask;
60 else
61 val &= (~mask);
62 LOONGSON_GPIODATA = val;
63 spin_unlock(&gpio_lock);
64}
65EXPORT_SYMBOL(gpio_set_value);
66
67int gpio_cansleep(unsigned gpio)
68{
69 if (gpio < STLS2F_N_GPIO)
70 return 0;
71 else
72 return __gpio_cansleep(gpio);
73}
74EXPORT_SYMBOL(gpio_cansleep);
75
76static int ls2f_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
77{
78 u32 temp;
79 u32 mask;
80
81 if (gpio >= STLS2F_N_GPIO)
82 return -EINVAL;
83
84 spin_lock(&gpio_lock);
85 mask = 1 << gpio;
86 temp = LOONGSON_GPIOIE;
87 temp |= mask;
88 LOONGSON_GPIOIE = temp;
89 spin_unlock(&gpio_lock);
90
91 return 0;
92}
93
94static int ls2f_gpio_direction_output(struct gpio_chip *chip,
95 unsigned gpio, int level)
96{
97 u32 temp;
98 u32 mask;
99
100 if (gpio >= STLS2F_N_GPIO)
101 return -EINVAL;
102
103 gpio_set_value(gpio, level);
104 spin_lock(&gpio_lock);
105 mask = 1 << gpio;
106 temp = LOONGSON_GPIOIE;
107 temp &= (~mask);
108 LOONGSON_GPIOIE = temp;
109 spin_unlock(&gpio_lock);
110
111 return 0;
112}
113
114static int ls2f_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
115{
116 return gpio_get_value(gpio);
117}
118
119static void ls2f_gpio_set_value(struct gpio_chip *chip,
120 unsigned gpio, int value)
121{
122 gpio_set_value(gpio, value);
123}
124
125static struct gpio_chip ls2f_chip = {
126 .label = "ls2f",
127 .direction_input = ls2f_gpio_direction_input,
128 .get = ls2f_gpio_get_value,
129 .direction_output = ls2f_gpio_direction_output,
130 .set = ls2f_gpio_set_value,
131 .base = 0,
132 .ngpio = STLS2F_N_GPIO,
133};
134
135static int __init ls2f_gpio_setup(void)
136{
137 return gpiochip_add(&ls2f_chip);
138}
139arch_initcall(ls2f_gpio_setup);