blob: 3a2a682f66ce949800ad6bef58307d60f87f7b52 [file] [log] [blame]
Wolfgang Denke6f22282005-09-26 00:44:15 +02001/*
2 * See file CREDITS for list of people who contributed to this
3 * project.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
19 */
20
21/*
22 * MPC8xx I/O port pin manipulation functions
23 * Roughly based on iopin_8260.h
24 */
25
26#ifndef _ASM_IOPIN_8XX_H_
27#define _ASM_IOPIN_8XX_H_
28
29#include <linux/types.h>
30#include <asm/8xx_immap.h>
31
32#ifdef __KERNEL__
33
34typedef struct {
35 u_char port:2; /* port number (A=0, B=1, C=2, D=3) */
36 u_char pin:5; /* port pin (0-31) */
37 u_char flag:1; /* for whatever */
38} iopin_t;
39
40#define IOPIN_PORTA 0
41#define IOPIN_PORTB 1
42#define IOPIN_PORTC 2
43#define IOPIN_PORTD 3
44
45extern __inline__ void
46iopin_set_high(iopin_t *iopin)
47{
48 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020049 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020050 *datp |= (1 << (15 - iopin->pin));
51 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020052 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020053 *datp |= (1 << (31 - iopin->pin));
54 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020055 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020056 *datp |= (1 << (15 - iopin->pin));
57 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020058 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020059 *datp |= (1 << (15 - iopin->pin));
60 }
61}
62
63extern __inline__ void
64iopin_set_low(iopin_t *iopin)
65{
66 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020067 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020068 *datp &= ~(1 << (15 - iopin->pin));
69 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020070 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020071 *datp &= ~(1 << (31 - iopin->pin));
72 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020073 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020074 *datp &= ~(1 << (15 - iopin->pin));
75 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020076 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020077 *datp &= ~(1 << (15 - iopin->pin));
78 }
79}
80
81extern __inline__ uint
82iopin_is_high(iopin_t *iopin)
83{
84 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020085 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020086 return (*datp >> (15 - iopin->pin)) & 1;
87 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020088 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020089 return (*datp >> (31 - iopin->pin)) & 1;
90 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020091 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020092 return (*datp >> (15 - iopin->pin)) & 1;
93 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020094 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020095 return (*datp >> (15 - iopin->pin)) & 1;
96 }
97 return 0;
98}
99
100extern __inline__ uint
101iopin_is_low(iopin_t *iopin)
102{
103 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200104 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200105 return ((*datp >> (15 - iopin->pin)) & 1) ^ 1;
106 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200107 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200108 return ((*datp >> (31 - iopin->pin)) & 1) ^ 1;
109 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200110 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200111 return ((*datp >> (15 - iopin->pin)) & 1) ^ 1;
112 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200113 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200114 return ((*datp >> (15 - iopin->pin)) & 1) ^ 1;
115 }
116 return 0;
117}
118
119extern __inline__ void
120iopin_set_out(iopin_t *iopin)
121{
122 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200123 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200124 *dirp |= (1 << (15 - iopin->pin));
125 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200126 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200127 *dirp |= (1 << (31 - iopin->pin));
128 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200129 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200130 *dirp |= (1 << (15 - iopin->pin));
131 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200132 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200133 *dirp |= (1 << (15 - iopin->pin));
134 }
135}
136
137extern __inline__ void
138iopin_set_in(iopin_t *iopin)
139{
140 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200141 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200142 *dirp &= ~(1 << (15 - iopin->pin));
143 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200144 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200145 *dirp &= ~(1 << (31 - iopin->pin));
146 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200147 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200148 *dirp &= ~(1 << (15 - iopin->pin));
149 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200150 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200151 *dirp &= ~(1 << (15 - iopin->pin));
152 }
153}
154
155extern __inline__ uint
156iopin_is_out(iopin_t *iopin)
157{
158 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200159 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200160 return (*dirp >> (15 - iopin->pin)) & 1;
161 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200162 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200163 return (*dirp >> (31 - iopin->pin)) & 1;
164 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200165 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200166 return (*dirp >> (15 - iopin->pin)) & 1;
167 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200168 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200169 return (*dirp >> (15 - iopin->pin)) & 1;
170 }
171 return 0;
172}
173
174extern __inline__ uint
175iopin_is_in(iopin_t *iopin)
176{
177 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200178 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200179 return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1;
180 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200181 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200182 return ((*dirp >> (31 - iopin->pin)) & 1) ^ 1;
183 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200184 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200185 return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1;
186 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200187 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200188 return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1;
189 }
190 return 0;
191}
192
193extern __inline__ void
194iopin_set_odr(iopin_t *iopin)
195{
196 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200197 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200198 *odrp |= (1 << (15 - iopin->pin));
199 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200200 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200201 *odrp |= (1 << (31 - iopin->pin));
202 }
203}
204
205extern __inline__ void
206iopin_set_act(iopin_t *iopin)
207{
208 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200209 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200210 *odrp &= ~(1 << (15 - iopin->pin));
211 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200212 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200213 *odrp &= ~(1 << (31 - iopin->pin));
214 }
215}
216
217extern __inline__ uint
218iopin_is_odr(iopin_t *iopin)
219{
220 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200221 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200222 return (*odrp >> (15 - iopin->pin)) & 1;
223 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200224 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200225 return (*odrp >> (31 - iopin->pin)) & 1;
226 }
227 return 0;
228}
229
230extern __inline__ uint
231iopin_is_act(iopin_t *iopin)
232{
233 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200234 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200235 return ((*odrp >> (15 - iopin->pin)) & 1) ^ 1;
236 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200237 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200238 return ((*odrp >> (31 - iopin->pin)) & 1) ^ 1;
239 }
240 return 0;
241}
242
243extern __inline__ void
244iopin_set_ded(iopin_t *iopin)
245{
246 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200247 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200248 *parp |= (1 << (15 - iopin->pin));
249 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200250 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200251 *parp |= (1 << (31 - iopin->pin));
252 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200253 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200254 *parp |= (1 << (15 - iopin->pin));
255 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200256 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200257 *parp |= (1 << (15 - iopin->pin));
258 }
259}
260
261extern __inline__ void
262iopin_set_gen(iopin_t *iopin)
263{
264 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200265 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200266 *parp &= ~(1 << (15 - iopin->pin));
267 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200268 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200269 *parp &= ~(1 << (31 - iopin->pin));
270 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200271 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200272 *parp &= ~(1 << (15 - iopin->pin));
273 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200274 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200275 *parp &= ~(1 << (15 - iopin->pin));
276 }
277}
278
279extern __inline__ uint
280iopin_is_ded(iopin_t *iopin)
281{
282 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200283 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200284 return (*parp >> (15 - iopin->pin)) & 1;
285 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200286 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200287 return (*parp >> (31 - iopin->pin)) & 1;
288 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200289 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200290 return (*parp >> (15 - iopin->pin)) & 1;
291 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200292 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200293 return (*parp >> (15 - iopin->pin)) & 1;
294 }
295 return 0;
296}
297
298extern __inline__ uint
299iopin_is_gen(iopin_t *iopin)
300{
301 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200302 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200303 return ((*parp >> (15 - iopin->pin)) & 1) ^ 1;
304 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200305 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200306 return ((*parp >> (31 - iopin->pin)) & 1) ^ 1;
307 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200308 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200309 return ((*parp >> (15 - iopin->pin)) & 1) ^ 1;
310 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200311 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200312 return ((*parp >> (15 - iopin->pin)) & 1) ^ 1;
313 }
314 return 0;
315}
316
317extern __inline__ void
318iopin_set_opt2(iopin_t *iopin)
319{
320 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200321 volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200322 *sorp |= (1 << (15 - iopin->pin));
323 }
324}
325
326extern __inline__ void
327iopin_set_opt1(iopin_t *iopin)
328{
329 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200330 volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200331 *sorp &= ~(1 << (15 - iopin->pin));
332 }
333}
334
335extern __inline__ uint
336iopin_is_opt2(iopin_t *iopin)
337{
338 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200339 volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200340 return (*sorp >> (15 - iopin->pin)) & 1;
341 }
342 return 0;
343}
344
345extern __inline__ uint
346iopin_is_opt1(iopin_t *iopin)
347{
348 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200349 volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200350 return ((*sorp >> (15 - iopin->pin)) & 1) ^ 1;
351 }
352 return 0;
353}
354
355extern __inline__ void
356iopin_set_falledge(iopin_t *iopin)
357{
358 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200359 volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200360 *intp |= (1 << (15 - iopin->pin));
361 }
362}
363
364extern __inline__ void
365iopin_set_anyedge(iopin_t *iopin)
366{
367 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200368 volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200369 *intp &= ~(1 << (15 - iopin->pin));
370 }
371}
372
373extern __inline__ uint
374iopin_is_falledge(iopin_t *iopin)
375{
376 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200377 volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200378 return (*intp >> (15 - iopin->pin)) & 1;
379 }
380 return 0;
381}
382
383extern __inline__ uint
384iopin_is_anyedge(iopin_t *iopin)
385{
386 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200387 volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200388 return ((*intp >> (15 - iopin->pin)) & 1) ^ 1;
389 }
390 return 0;
391}
392
393#endif /* __KERNEL__ */
394
395#endif /* _ASM_IOPIN_8XX_H_ */