summaryrefslogtreecommitdiff
path: root/target/linux/cns21xx/patches-2.6.37/102-cns21xx-gpiolib-support.patch
blob: d54a7132cd154ca743efec9dfe240334c0e0accd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -296,6 +296,8 @@ config ARCH_CNS21XX
 	select CPU_FA526
 	select PLAT_FA
 	select PLAT_FA_TIME
+	select PLAT_FA_GPIO
+	select ARCH_REQUIRE_GPIOLIB
 	select ARM_L1_CACHE_SHIFT_4
 	help
 	  Support for Cavium Networks CNS21xx family.
--- a/arch/arm/mach-cns21xx/common.h
+++ b/arch/arm/mach-cns21xx/common.h
@@ -12,6 +12,7 @@
 
 void __init cns21xx_map_io(void);
 void __init cns21xx_init_irq(void);
+void __init cns21xx_gpio_init(void);
 
 extern struct sys_timer cns21xx_timer;
 
--- /dev/null
+++ b/arch/arm/mach-cns21xx/gpio.c
@@ -0,0 +1,45 @@
+/*
+ *  Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License, Version 2, as
+ *  published by the Free Software Foundation.
+ */
+
+#include <plat/gpio.h>
+
+#include <mach/cns21xx.h>
+#include <mach/irqs.h>
+
+static struct fa_gpio_chip cns21xx_gpio_chips[] = {
+	{
+		.gpio_chip = {
+			.label	= "GPIOA",
+			.base	= 0,
+			.ngpio	= 32,
+		},
+
+		.map_base	= CNS21XX_GPIOA_BASE,
+		.irq_base	= CNS21XX_GPIO_IRQ_BASE,
+	}, {
+		.gpio_chip = {
+			.label	= "GPIOB",
+			.base	= 32,
+			.ngpio	= 32,
+		},
+
+		.map_base	= CNS21XX_GPIOB_BASE,
+		.irq_base	= CNS21XX_GPIO_IRQ_BASE + 32,
+	}
+};
+
+static struct fa_gpio_data cns21xx_gpio_data = {
+	.chips	= cns21xx_gpio_chips,
+	.nchips = ARRAY_SIZE(cns21xx_gpio_chips),
+	.irq	= CNS21XX_IRQ_GPIO,
+};
+
+void __init cns21xx_gpio_init(void)
+{
+	fa_gpio_init(&cns21xx_gpio_data);
+}
--- /dev/null
+++ b/arch/arm/mach-cns21xx/include/mach/gpio.h
@@ -0,0 +1,30 @@
+/*
+ *  Copyright (c) 2008 Cavium Networks
+ *  Copyright (c) 2010 Gabor Juhos <juhosg@openwrt.org>
+ *
+ *  This file is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License, Version 2, as
+ *  published by the Free Software Foundation.
+ */
+
+#ifndef _CNS21XX_GPIO_H
+#define _CNS21XX_GPIO_H
+
+#include <asm-generic/gpio.h>
+#include <mach/irqs.h>
+
+#define gpio_get_value	__gpio_get_value
+#define gpio_set_value	__gpio_set_value
+#define gpio_cansleep	__gpio_cansleep
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+	return (CNS21XX_GPIO_IRQ_BASE + gpio);
+}
+
+static inline int irq_to_gpio(int irq)
+{
+	return (irq - CNS21XX_GPIO_IRQ_BASE);
+}
+
+#endif /* _CNS21XX_GPIO_H */
--- a/arch/arm/mach-cns21xx/Makefile
+++ b/arch/arm/mach-cns21xx/Makefile
@@ -4,7 +4,7 @@
 
 # Object file lists.
 
-obj-y		:= core.o devices.o irq.o mm.o time.o
+obj-y		:= core.o devices.o gpio.o irq.o mm.o time.o
 
 # machine specific files