blob: 0123bafcaddb84e050cbd1493eba9cba51fa2a8c [file] [log] [blame]
Wolfgang Denke6f22282005-09-26 00:44:15 +02001/*
Wolfgang Denk1a459662013-07-08 09:37:19 +02002 * SPDX-License-Identifier: GPL-2.0+
Wolfgang Denke6f22282005-09-26 00:44:15 +02003 */
4
5/*
6 * MPC8xx I/O port pin manipulation functions
7 * Roughly based on iopin_8260.h
8 */
9
10#ifndef _ASM_IOPIN_8XX_H_
11#define _ASM_IOPIN_8XX_H_
12
13#include <linux/types.h>
14#include <asm/8xx_immap.h>
15
16#ifdef __KERNEL__
17
18typedef struct {
19 u_char port:2; /* port number (A=0, B=1, C=2, D=3) */
20 u_char pin:5; /* port pin (0-31) */
21 u_char flag:1; /* for whatever */
22} iopin_t;
23
24#define IOPIN_PORTA 0
25#define IOPIN_PORTB 1
26#define IOPIN_PORTC 2
27#define IOPIN_PORTD 3
28
29extern __inline__ void
30iopin_set_high(iopin_t *iopin)
31{
32 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020033 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020034 *datp |= (1 << (15 - iopin->pin));
35 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020036 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020037 *datp |= (1 << (31 - iopin->pin));
38 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020039 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020040 *datp |= (1 << (15 - iopin->pin));
41 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020042 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020043 *datp |= (1 << (15 - iopin->pin));
44 }
45}
46
47extern __inline__ void
48iopin_set_low(iopin_t *iopin)
49{
50 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020051 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020052 *datp &= ~(1 << (15 - iopin->pin));
53 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020054 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020055 *datp &= ~(1 << (31 - iopin->pin));
56 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020057 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020058 *datp &= ~(1 << (15 - iopin->pin));
59 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020060 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020061 *datp &= ~(1 << (15 - iopin->pin));
62 }
63}
64
65extern __inline__ uint
66iopin_is_high(iopin_t *iopin)
67{
68 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020069 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020070 return (*datp >> (15 - iopin->pin)) & 1;
71 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020072 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020073 return (*datp >> (31 - iopin->pin)) & 1;
74 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020075 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020076 return (*datp >> (15 - iopin->pin)) & 1;
77 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020078 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020079 return (*datp >> (15 - iopin->pin)) & 1;
80 }
81 return 0;
82}
83
84extern __inline__ uint
85iopin_is_low(iopin_t *iopin)
86{
87 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020088 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020089 return ((*datp >> (15 - iopin->pin)) & 1) ^ 1;
90 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020091 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020092 return ((*datp >> (31 - iopin->pin)) & 1) ^ 1;
93 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020094 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020095 return ((*datp >> (15 - iopin->pin)) & 1) ^ 1;
96 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020097 volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat;
Wolfgang Denke6f22282005-09-26 00:44:15 +020098 return ((*datp >> (15 - iopin->pin)) & 1) ^ 1;
99 }
100 return 0;
101}
102
103extern __inline__ void
104iopin_set_out(iopin_t *iopin)
105{
106 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200107 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200108 *dirp |= (1 << (15 - iopin->pin));
109 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200110 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200111 *dirp |= (1 << (31 - iopin->pin));
112 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200113 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200114 *dirp |= (1 << (15 - iopin->pin));
115 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200116 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200117 *dirp |= (1 << (15 - iopin->pin));
118 }
119}
120
121extern __inline__ void
122iopin_set_in(iopin_t *iopin)
123{
124 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200125 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200126 *dirp &= ~(1 << (15 - iopin->pin));
127 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200128 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200129 *dirp &= ~(1 << (31 - iopin->pin));
130 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200131 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200132 *dirp &= ~(1 << (15 - iopin->pin));
133 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200134 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200135 *dirp &= ~(1 << (15 - iopin->pin));
136 }
137}
138
139extern __inline__ uint
140iopin_is_out(iopin_t *iopin)
141{
142 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200143 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200144 return (*dirp >> (15 - iopin->pin)) & 1;
145 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200146 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200147 return (*dirp >> (31 - iopin->pin)) & 1;
148 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200149 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200150 return (*dirp >> (15 - iopin->pin)) & 1;
151 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200152 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200153 return (*dirp >> (15 - iopin->pin)) & 1;
154 }
155 return 0;
156}
157
158extern __inline__ uint
159iopin_is_in(iopin_t *iopin)
160{
161 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200162 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200163 return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1;
164 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200165 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200166 return ((*dirp >> (31 - iopin->pin)) & 1) ^ 1;
167 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200168 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200169 return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1;
170 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200171 volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200172 return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1;
173 }
174 return 0;
175}
176
177extern __inline__ void
178iopin_set_odr(iopin_t *iopin)
179{
180 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200181 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200182 *odrp |= (1 << (15 - iopin->pin));
183 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200184 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200185 *odrp |= (1 << (31 - iopin->pin));
186 }
187}
188
189extern __inline__ void
190iopin_set_act(iopin_t *iopin)
191{
192 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200193 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200194 *odrp &= ~(1 << (15 - iopin->pin));
195 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200196 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200197 *odrp &= ~(1 << (31 - iopin->pin));
198 }
199}
200
201extern __inline__ uint
202iopin_is_odr(iopin_t *iopin)
203{
204 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200205 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200206 return (*odrp >> (15 - iopin->pin)) & 1;
207 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200208 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200209 return (*odrp >> (31 - iopin->pin)) & 1;
210 }
211 return 0;
212}
213
214extern __inline__ uint
215iopin_is_act(iopin_t *iopin)
216{
217 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200218 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200219 return ((*odrp >> (15 - iopin->pin)) & 1) ^ 1;
220 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200221 volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200222 return ((*odrp >> (31 - iopin->pin)) & 1) ^ 1;
223 }
224 return 0;
225}
226
227extern __inline__ void
228iopin_set_ded(iopin_t *iopin)
229{
230 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200231 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200232 *parp |= (1 << (15 - iopin->pin));
233 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200234 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200235 *parp |= (1 << (31 - iopin->pin));
236 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200237 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200238 *parp |= (1 << (15 - iopin->pin));
239 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200240 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200241 *parp |= (1 << (15 - iopin->pin));
242 }
243}
244
245extern __inline__ void
246iopin_set_gen(iopin_t *iopin)
247{
248 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200249 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200250 *parp &= ~(1 << (15 - iopin->pin));
251 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200252 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200253 *parp &= ~(1 << (31 - iopin->pin));
254 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200255 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200256 *parp &= ~(1 << (15 - iopin->pin));
257 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200258 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200259 *parp &= ~(1 << (15 - iopin->pin));
260 }
261}
262
263extern __inline__ uint
264iopin_is_ded(iopin_t *iopin)
265{
266 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200267 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200268 return (*parp >> (15 - iopin->pin)) & 1;
269 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200270 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200271 return (*parp >> (31 - iopin->pin)) & 1;
272 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200273 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200274 return (*parp >> (15 - iopin->pin)) & 1;
275 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200276 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200277 return (*parp >> (15 - iopin->pin)) & 1;
278 }
279 return 0;
280}
281
282extern __inline__ uint
283iopin_is_gen(iopin_t *iopin)
284{
285 if (iopin->port == IOPIN_PORTA) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200286 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200287 return ((*parp >> (15 - iopin->pin)) & 1) ^ 1;
288 } else if (iopin->port == IOPIN_PORTB) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200289 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200290 return ((*parp >> (31 - iopin->pin)) & 1) ^ 1;
291 } else if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200292 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200293 return ((*parp >> (15 - iopin->pin)) & 1) ^ 1;
294 } else if (iopin->port == IOPIN_PORTD) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200295 volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200296 return ((*parp >> (15 - iopin->pin)) & 1) ^ 1;
297 }
298 return 0;
299}
300
301extern __inline__ void
302iopin_set_opt2(iopin_t *iopin)
303{
304 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200305 volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200306 *sorp |= (1 << (15 - iopin->pin));
307 }
308}
309
310extern __inline__ void
311iopin_set_opt1(iopin_t *iopin)
312{
313 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200314 volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200315 *sorp &= ~(1 << (15 - iopin->pin));
316 }
317}
318
319extern __inline__ uint
320iopin_is_opt2(iopin_t *iopin)
321{
322 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200323 volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200324 return (*sorp >> (15 - iopin->pin)) & 1;
325 }
326 return 0;
327}
328
329extern __inline__ uint
330iopin_is_opt1(iopin_t *iopin)
331{
332 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200333 volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200334 return ((*sorp >> (15 - iopin->pin)) & 1) ^ 1;
335 }
336 return 0;
337}
338
339extern __inline__ void
340iopin_set_falledge(iopin_t *iopin)
341{
342 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200343 volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200344 *intp |= (1 << (15 - iopin->pin));
345 }
346}
347
348extern __inline__ void
349iopin_set_anyedge(iopin_t *iopin)
350{
351 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200352 volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200353 *intp &= ~(1 << (15 - iopin->pin));
354 }
355}
356
357extern __inline__ uint
358iopin_is_falledge(iopin_t *iopin)
359{
360 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200361 volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200362 return (*intp >> (15 - iopin->pin)) & 1;
363 }
364 return 0;
365}
366
367extern __inline__ uint
368iopin_is_anyedge(iopin_t *iopin)
369{
370 if (iopin->port == IOPIN_PORTC) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200371 volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint;
Wolfgang Denke6f22282005-09-26 00:44:15 +0200372 return ((*intp >> (15 - iopin->pin)) & 1) ^ 1;
373 }
374 return 0;
375}
376
377#endif /* __KERNEL__ */
378
379#endif /* _ASM_IOPIN_8XX_H_ */