blob: 1fa1a8e6ecf79dc045660ba6d242e4b8bff43404 [file] [log] [blame]
Mike Frysinger4638b212010-06-02 04:17:26 -04001/*
2 * Copyright 2006-2009 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 */
6
7#ifndef __ARCH_BLACKFIN_GPIO_H__
8#define __ARCH_BLACKFIN_GPIO_H__
9
Sonic Zhangda34aae2013-05-02 13:46:21 +080010#include <asm-generic/gpio.h>
Steven Miaocae4d042013-10-23 14:44:09 +080011#include <asm/portmux.h>
Sonic Zhangda34aae2013-05-02 13:46:21 +080012
Mike Frysinger4638b212010-06-02 04:17:26 -040013#define gpio_bank(x) ((x) >> 4)
14#define gpio_bit(x) (1<<((x) & 0xF))
15#define gpio_sub_n(x) ((x) & 0xF)
16
17#define GPIO_BANKSIZE 16
18#define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE)
19
20#define GPIO_0 0
21#define GPIO_1 1
22#define GPIO_2 2
23#define GPIO_3 3
24#define GPIO_4 4
25#define GPIO_5 5
26#define GPIO_6 6
27#define GPIO_7 7
28#define GPIO_8 8
29#define GPIO_9 9
30#define GPIO_10 10
31#define GPIO_11 11
32#define GPIO_12 12
33#define GPIO_13 13
34#define GPIO_14 14
35#define GPIO_15 15
36#define GPIO_16 16
37#define GPIO_17 17
38#define GPIO_18 18
39#define GPIO_19 19
40#define GPIO_20 20
41#define GPIO_21 21
42#define GPIO_22 22
43#define GPIO_23 23
44#define GPIO_24 24
45#define GPIO_25 25
46#define GPIO_26 26
47#define GPIO_27 27
48#define GPIO_28 28
49#define GPIO_29 29
50#define GPIO_30 30
51#define GPIO_31 31
52#define GPIO_32 32
53#define GPIO_33 33
54#define GPIO_34 34
55#define GPIO_35 35
56#define GPIO_36 36
57#define GPIO_37 37
58#define GPIO_38 38
59#define GPIO_39 39
60#define GPIO_40 40
61#define GPIO_41 41
62#define GPIO_42 42
63#define GPIO_43 43
64#define GPIO_44 44
65#define GPIO_45 45
66#define GPIO_46 46
67#define GPIO_47 47
68
69#define PERIPHERAL_USAGE 1
70#define GPIO_USAGE 0
Sonic Zhangda34aae2013-05-02 13:46:21 +080071#define MAX_GPIOS MAX_BLACKFIN_GPIOS
Mike Frysinger4638b212010-06-02 04:17:26 -040072
73#ifndef __ASSEMBLY__
74
Sonic Zhang76db0fde2013-11-18 14:12:39 +080075#ifndef CONFIG_ADI_GPIO2
Mike Frysinger4638b212010-06-02 04:17:26 -040076void set_gpio_dir(unsigned, unsigned short);
77void set_gpio_inen(unsigned, unsigned short);
78void set_gpio_polar(unsigned, unsigned short);
79void set_gpio_edge(unsigned, unsigned short);
80void set_gpio_both(unsigned, unsigned short);
81void set_gpio_data(unsigned, unsigned short);
82void set_gpio_maska(unsigned, unsigned short);
83void set_gpio_maskb(unsigned, unsigned short);
84void set_gpio_toggle(unsigned);
85void set_gpiop_dir(unsigned, unsigned short);
86void set_gpiop_inen(unsigned, unsigned short);
87void set_gpiop_polar(unsigned, unsigned short);
88void set_gpiop_edge(unsigned, unsigned short);
89void set_gpiop_both(unsigned, unsigned short);
90void set_gpiop_data(unsigned, unsigned short);
91void set_gpiop_maska(unsigned, unsigned short);
92void set_gpiop_maskb(unsigned, unsigned short);
93unsigned short get_gpio_dir(unsigned);
94unsigned short get_gpio_inen(unsigned);
95unsigned short get_gpio_polar(unsigned);
96unsigned short get_gpio_edge(unsigned);
97unsigned short get_gpio_both(unsigned);
98unsigned short get_gpio_maska(unsigned);
99unsigned short get_gpio_maskb(unsigned);
100unsigned short get_gpio_data(unsigned);
101unsigned short get_gpiop_dir(unsigned);
102unsigned short get_gpiop_inen(unsigned);
103unsigned short get_gpiop_polar(unsigned);
104unsigned short get_gpiop_edge(unsigned);
105unsigned short get_gpiop_both(unsigned);
106unsigned short get_gpiop_maska(unsigned);
107unsigned short get_gpiop_maskb(unsigned);
108unsigned short get_gpiop_data(unsigned);
109
110struct gpio_port_t {
111 unsigned short data;
112 unsigned short dummy1;
113 unsigned short data_clear;
114 unsigned short dummy2;
115 unsigned short data_set;
116 unsigned short dummy3;
117 unsigned short toggle;
118 unsigned short dummy4;
119 unsigned short maska;
120 unsigned short dummy5;
121 unsigned short maska_clear;
122 unsigned short dummy6;
123 unsigned short maska_set;
124 unsigned short dummy7;
125 unsigned short maska_toggle;
126 unsigned short dummy8;
127 unsigned short maskb;
128 unsigned short dummy9;
129 unsigned short maskb_clear;
130 unsigned short dummy10;
131 unsigned short maskb_set;
132 unsigned short dummy11;
133 unsigned short maskb_toggle;
134 unsigned short dummy12;
135 unsigned short dir;
136 unsigned short dummy13;
137 unsigned short polar;
138 unsigned short dummy14;
139 unsigned short edge;
140 unsigned short dummy15;
141 unsigned short both;
142 unsigned short dummy16;
143 unsigned short inen;
144};
Steven Miaocae4d042013-10-23 14:44:09 +0800145#else
146extern struct gpio_port_t * const gpio_array[];
Mike Frysinger4638b212010-06-02 04:17:26 -0400147#endif
148
Sonic Zhangda34aae2013-05-02 13:46:21 +0800149#ifdef ADI_SPECIAL_GPIO_BANKS
150void special_gpio_free(unsigned gpio);
151int special_gpio_request(unsigned gpio, const char *label);
Mike Frysinger4638b212010-06-02 04:17:26 -0400152#endif
153
Sonic Zhangda34aae2013-05-02 13:46:21 +0800154void gpio_labels(void);
Mike Frysinger4638b212010-06-02 04:17:26 -0400155
156static inline int gpio_is_valid(int number)
157{
Sonic Zhangda34aae2013-05-02 13:46:21 +0800158 return number >= 0 && number < MAX_GPIOS;
Mike Frysinger4638b212010-06-02 04:17:26 -0400159}
160
Mike Frysingera972b8d2011-04-03 04:40:46 -0400161#include <linux/ctype.h>
162
Sonic Zhangda34aae2013-05-02 13:46:21 +0800163#define gpio_status() gpio_labels()
Mike Frysingera972b8d2011-04-03 04:40:46 -0400164
Mike Frysinger4638b212010-06-02 04:17:26 -0400165#endif /* __ASSEMBLY__ */
166
167#endif /* __ARCH_BLACKFIN_GPIO_H__ */