1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef AT91_PIO_H
14#define AT91_PIO_H
15
16
17#define AT91_ASM_PIO_RANGE 0x200
18#define AT91_ASM_PIOC_ASR \
19 (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x70)
20#define AT91_ASM_PIOC_BSR \
21 (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x74)
22#define AT91_ASM_PIOC_PDR \
23 (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x04)
24#define AT91_ASM_PIOC_PUDR \
25 (ATMEL_BASE_PIO + AT91_PIO_PORTC * AT91_ASM_PIO_RANGE + 0x60)
26
27#define AT91_ASM_PIOD_PDR \
28 (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x04)
29#define AT91_ASM_PIOD_PUDR \
30 (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x60)
31#define AT91_ASM_PIOD_ASR \
32 (ATMEL_BASE_PIO + AT91_PIO_PORTD * AT91_ASM_PIO_RANGE + 0x70)
33
34#define PIO_SCDR_DIV 0x3fff
35
36#ifndef __ASSEMBLY__
37
38typedef struct at91_port {
39 u32 per;
40 u32 pdr;
41 u32 psr;
42 u32 reserved0;
43 u32 oer;
44 u32 odr;
45 u32 osr;
46 u32 reserved1;
47 u32 ifer;
48 u32 ifdr;
49 u32 ifsr;
50 u32 reserved2;
51 u32 sodr;
52 u32 codr;
53 u32 odsr;
54 u32 pdsr;
55 u32 ier;
56 u32 idr;
57 u32 imr;
58 u32 isr;
59 u32 mder;
60 u32 mddr;
61 u32 mdsr;
62 u32 reserved3;
63 u32 pudr;
64 u32 puer;
65 u32 pusr;
66 u32 reserved4;
67 union {
68 struct {
69 u32 abcdsr1;
70 u32 abcdsr2;
71 u32 reserved5[2];
72 u32 ifscdr;
73 u32 ifscer;
74 u32 ifscsr;
75 u32 scdr;
76 u32 ppddr;
77 u32 ppder;
78 u32 ppdsr;
79 u32 reserved6;
80 } pio3;
81
82 struct {
83 u32 asr;
84 u32 bsr;
85 u32 absr;
86 u32 reserved5[9];
87 } pio2;
88 } mux;
89
90 u32 ower;
91 u32 owdr;
92 u32 owsr;
93 u32 reserved7;
94 u32 aimer;
95 u32 aimdr;
96 u32 aimmr;
97 u32 reserved8;
98 u32 esr;
99 u32 lsr;
100 u32 elsr;
101 u32 reserved9;
102 u32 fellsr;
103 u32 rehlsr;
104 u32 frlhsr;
105 u32 reserved10;
106 u32 locksr;
107 u32 wpmr;
108 u32 wpsr;
109 u32 reserved11[5];
110 u32 schmitt;
111 u32 reserved12[4];
112 u32 driver1;
113 u32 driver12;
114 u32 driver2;
115 u32 reserved13[12];
116} at91_port_t;
117
118typedef union at91_pio {
119 struct {
120 at91_port_t pioa;
121 at91_port_t piob;
122 at91_port_t pioc;
123 at91_port_t piod;
124 at91_port_t pioe;
125 };
126 at91_port_t port[5];
127} at91_pio_t;
128
129#ifdef CONFIG_AT91_GPIO
130int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup);
131int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup);
132int at91_set_pio_input(unsigned port, unsigned pin, int use_pullup);
133int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on);
134int at91_set_pio_output(unsigned port, unsigned pin, int value);
135int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup);
136int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup);
137int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on);
138int at91_set_pio_value(unsigned port, unsigned pin, int value);
139int at91_get_pio_value(unsigned port, unsigned pin);
140
141int at91_pio3_set_a_periph(unsigned port, unsigned pin, int use_pullup);
142int at91_pio3_set_b_periph(unsigned port, unsigned pin, int use_pullup);
143int at91_pio3_set_c_periph(unsigned port, unsigned pin, int use_pullup);
144int at91_pio3_set_d_periph(unsigned port, unsigned pin, int use_pullup);
145int at91_pio3_set_pio_debounce(unsigned port, unsigned pin, int is_on, int div);
146int at91_pio3_set_pio_pullup(unsigned port, unsigned pin, int use_pullup);
147int at91_pio3_set_pio_pulldown(unsigned port, unsigned pin, int is_on);
148int at91_pio3_set_pio_disable_schmitt_trig(unsigned port, unsigned pin);
149#endif
150#endif
151
152#define AT91_PIO_PORTA 0x0
153#define AT91_PIO_PORTB 0x1
154#define AT91_PIO_PORTC 0x2
155#define AT91_PIO_PORTD 0x3
156#define AT91_PIO_PORTE 0x4
157
158#endif
159