]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - arch/ppc/include/asm/iopin_8260.h
2 * MPC8260 I/O port pin manipulation functions
5 #ifndef _ASM_IOPIN_8260_H_
6 #define _ASM_IOPIN_8260_H_
8 #include <linux/types.h>
9 #include <asm/immap_8260.h>
15 u_char port
:2; /* port number (A=0, B=1, C=2, D=3) */
16 u_char pin
:5; /* port pin (0-31) */
17 u_char flag
:1; /* for whatever */
26 extern __inline__
void
27 iopin_set_high(iopin_t
*iopin
)
29 volatile uint
*datp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_pdata
;
30 datp
[iopin
->port
* 8] |= (1 << (31 - iopin
->pin
));
33 extern __inline__
void
34 iopin_set_low(iopin_t
*iopin
)
36 volatile uint
*datp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_pdata
;
37 datp
[iopin
->port
* 8] &= ~(1 << (31 - iopin
->pin
));
40 extern __inline__ uint
41 iopin_is_high(iopin_t
*iopin
)
43 volatile uint
*datp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_pdata
;
44 return (datp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1;
47 extern __inline__ uint
48 iopin_is_low(iopin_t
*iopin
)
50 volatile uint
*datp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_pdata
;
51 return ((datp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1) ^ 1;
54 extern __inline__
void
55 iopin_set_out(iopin_t
*iopin
)
57 volatile uint
*dirp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_pdira
;
58 dirp
[iopin
->port
* 8] |= (1 << (31 - iopin
->pin
));
61 extern __inline__
void
62 iopin_set_in(iopin_t
*iopin
)
64 volatile uint
*dirp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_pdira
;
65 dirp
[iopin
->port
* 8] &= ~(1 << (31 - iopin
->pin
));
68 extern __inline__ uint
69 iopin_is_out(iopin_t
*iopin
)
71 volatile uint
*dirp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_pdira
;
72 return (dirp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1;
75 extern __inline__ uint
76 iopin_is_in(iopin_t
*iopin
)
78 volatile uint
*dirp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_pdira
;
79 return ((dirp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1) ^ 1;
82 extern __inline__
void
83 iopin_set_odr(iopin_t
*iopin
)
85 volatile uint
*odrp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_podra
;
86 odrp
[iopin
->port
* 8] |= (1 << (31 - iopin
->pin
));
89 extern __inline__
void
90 iopin_set_act(iopin_t
*iopin
)
92 volatile uint
*odrp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_podra
;
93 odrp
[iopin
->port
* 8] &= ~(1 << (31 - iopin
->pin
));
96 extern __inline__ uint
97 iopin_is_odr(iopin_t
*iopin
)
99 volatile uint
*odrp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_podra
;
100 return (odrp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1;
103 extern __inline__ uint
104 iopin_is_act(iopin_t
*iopin
)
106 volatile uint
*odrp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_podra
;
107 return ((odrp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1) ^ 1;
110 extern __inline__
void
111 iopin_set_ded(iopin_t
*iopin
)
113 volatile uint
*parp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_ppara
;
114 parp
[iopin
->port
* 8] |= (1 << (31 - iopin
->pin
));
117 extern __inline__
void
118 iopin_set_gen(iopin_t
*iopin
)
120 volatile uint
*parp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_ppara
;
121 parp
[iopin
->port
* 8] &= ~(1 << (31 - iopin
->pin
));
124 extern __inline__ uint
125 iopin_is_ded(iopin_t
*iopin
)
127 volatile uint
*parp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_ppara
;
128 return (parp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1;
131 extern __inline__ uint
132 iopin_is_gen(iopin_t
*iopin
)
134 volatile uint
*parp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_ppara
;
135 return ((parp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1) ^ 1;
138 extern __inline__
void
139 iopin_set_opt2(iopin_t
*iopin
)
141 volatile uint
*sorp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_psora
;
142 sorp
[iopin
->port
* 8] |= (1 << (31 - iopin
->pin
));
145 extern __inline__
void
146 iopin_set_opt1(iopin_t
*iopin
)
148 volatile uint
*sorp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_psora
;
149 sorp
[iopin
->port
* 8] &= ~(1 << (31 - iopin
->pin
));
152 extern __inline__ uint
153 iopin_is_opt2(iopin_t
*iopin
)
155 volatile uint
*sorp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_psora
;
156 return (sorp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1;
159 extern __inline__ uint
160 iopin_is_opt1(iopin_t
*iopin
)
162 volatile uint
*sorp
= &((immap_t
*)CONFIG_SYS_IMMR
)->im_ioport
.iop_psora
;
163 return ((sorp
[iopin
->port
* 8] >> (31 - iopin
->pin
)) & 1) ^ 1;
166 #endif /* __KERNEL__ */
168 #endif /* _ASM_IOPIN_8260_H_ */