2 * MPC85xx I/O port pin manipulation functions
5 #ifndef _ASM_IOPIN_85xx_H_
6 #define _ASM_IOPIN_85xx_H_
8 #include <linux/types.h>
9 #include <asm/immap_85xx.h>
14 u_char port:2; /* port number (A=0, B=1, C=2, D=3) */
15 u_char pin:5; /* port pin (0-31) */
16 u_char flag:1; /* for whatever */
24 extern __inline__ void iopin_set_high (iopin_t * iopin)
26 volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata;
27 datp[iopin->port * 8] |= (1 << (31 - iopin->pin));
30 extern __inline__ void iopin_set_low (iopin_t * iopin)
32 volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata;
33 datp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
36 extern __inline__ uint iopin_is_high (iopin_t * iopin)
38 volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata;
39 return (datp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
42 extern __inline__ uint iopin_is_low (iopin_t * iopin)
44 volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata;
45 return ((datp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
48 extern __inline__ void iopin_set_out (iopin_t * iopin)
50 volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira;
51 dirp[iopin->port * 8] |= (1 << (31 - iopin->pin));
54 extern __inline__ void iopin_set_in (iopin_t * iopin)
56 volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira;
57 dirp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
60 extern __inline__ uint iopin_is_out (iopin_t * iopin)
62 volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira;
63 return (dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
66 extern __inline__ uint iopin_is_in (iopin_t * iopin)
68 volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira;
69 return ((dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
72 extern __inline__ void iopin_set_odr (iopin_t * iopin)
74 volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra;
75 odrp[iopin->port * 8] |= (1 << (31 - iopin->pin));
78 extern __inline__ void iopin_set_act (iopin_t * iopin)
80 volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra;
81 odrp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
84 extern __inline__ uint iopin_is_odr (iopin_t * iopin)
86 volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra;
87 return (odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
90 extern __inline__ uint iopin_is_act (iopin_t * iopin)
92 volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra;
93 return ((odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
96 extern __inline__ void iopin_set_ded (iopin_t * iopin)
98 volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara;
99 parp[iopin->port * 8] |= (1 << (31 - iopin->pin));
102 extern __inline__ void iopin_set_gen (iopin_t * iopin)
104 volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara;
105 parp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
108 extern __inline__ uint iopin_is_ded (iopin_t * iopin)
110 volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara;
111 return (parp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
114 extern __inline__ uint iopin_is_gen (iopin_t * iopin)
116 volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara;
117 return ((parp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
120 extern __inline__ void iopin_set_opt2 (iopin_t * iopin)
122 volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora;
123 sorp[iopin->port * 8] |= (1 << (31 - iopin->pin));
126 extern __inline__ void iopin_set_opt1 (iopin_t * iopin)
128 volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora;
129 sorp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
132 extern __inline__ uint iopin_is_opt2 (iopin_t * iopin)
134 volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora;
135 return (sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
138 extern __inline__ uint iopin_is_opt1 (iopin_t * iopin)
140 volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora;
141 return ((sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
144 #endif /* __KERNEL__ */
146 #endif /* _ASM_IOPIN_85xx_H_ */