blob: 619f3a8abea2b0af17f8bed1d9e0553683ab4042 [file] [log] [blame]
wdenk2dab3012001-08-05 15:35:05 +00001/*
2 * MPC8260 I/O port pin manipulation functions
3 */
4
5#ifndef _ASM_IOPIN_8260_H_
6#define _ASM_IOPIN_8260_H_
7
8#include <linux/types.h>
9#include <asm/immap_8260.h>
10
11#ifdef __KERNEL__
12
13typedef
14 struct {
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 */
18 }
19iopin_t;
20
21#define IOPIN_PORTA 0
22#define IOPIN_PORTB 1
23#define IOPIN_PORTC 2
24#define IOPIN_PORTD 3
25
26extern __inline__ void
27iopin_set_high(iopin_t *iopin)
28{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020029 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdata;
wdenk2dab3012001-08-05 15:35:05 +000030 datp[iopin->port * 8] |= (1 << (31 - iopin->pin));
31}
32
33extern __inline__ void
34iopin_set_low(iopin_t *iopin)
35{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020036 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdata;
wdenk2dab3012001-08-05 15:35:05 +000037 datp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
38}
39
40extern __inline__ uint
41iopin_is_high(iopin_t *iopin)
42{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020043 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdata;
wdenk2dab3012001-08-05 15:35:05 +000044 return (datp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
45}
46
47extern __inline__ uint
48iopin_is_low(iopin_t *iopin)
49{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020050 volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdata;
wdenk2dab3012001-08-05 15:35:05 +000051 return ((datp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
52}
53
54extern __inline__ void
55iopin_set_out(iopin_t *iopin)
56{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020057 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdira;
wdenk2dab3012001-08-05 15:35:05 +000058 dirp[iopin->port * 8] |= (1 << (31 - iopin->pin));
59}
60
61extern __inline__ void
62iopin_set_in(iopin_t *iopin)
63{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020064 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdira;
wdenk2dab3012001-08-05 15:35:05 +000065 dirp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
66}
67
68extern __inline__ uint
69iopin_is_out(iopin_t *iopin)
70{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020071 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdira;
wdenk2dab3012001-08-05 15:35:05 +000072 return (dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
73}
74
75extern __inline__ uint
76iopin_is_in(iopin_t *iopin)
77{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020078 volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdira;
wdenk2dab3012001-08-05 15:35:05 +000079 return ((dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
80}
81
82extern __inline__ void
83iopin_set_odr(iopin_t *iopin)
84{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020085 volatile uint *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_podra;
wdenk2dab3012001-08-05 15:35:05 +000086 odrp[iopin->port * 8] |= (1 << (31 - iopin->pin));
87}
88
89extern __inline__ void
90iopin_set_act(iopin_t *iopin)
91{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020092 volatile uint *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_podra;
wdenk2dab3012001-08-05 15:35:05 +000093 odrp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
94}
95
96extern __inline__ uint
97iopin_is_odr(iopin_t *iopin)
98{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020099 volatile uint *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_podra;
wdenk2dab3012001-08-05 15:35:05 +0000100 return (odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
101}
102
103extern __inline__ uint
104iopin_is_act(iopin_t *iopin)
105{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200106 volatile uint *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_podra;
wdenk2dab3012001-08-05 15:35:05 +0000107 return ((odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
108}
109
110extern __inline__ void
111iopin_set_ded(iopin_t *iopin)
112{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200113 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_ppara;
wdenk2dab3012001-08-05 15:35:05 +0000114 parp[iopin->port * 8] |= (1 << (31 - iopin->pin));
115}
116
117extern __inline__ void
118iopin_set_gen(iopin_t *iopin)
119{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200120 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_ppara;
wdenk2dab3012001-08-05 15:35:05 +0000121 parp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
122}
123
124extern __inline__ uint
125iopin_is_ded(iopin_t *iopin)
126{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200127 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_ppara;
wdenk2dab3012001-08-05 15:35:05 +0000128 return (parp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
129}
130
131extern __inline__ uint
132iopin_is_gen(iopin_t *iopin)
133{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200134 volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_ppara;
wdenk2dab3012001-08-05 15:35:05 +0000135 return ((parp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
136}
137
138extern __inline__ void
139iopin_set_opt2(iopin_t *iopin)
140{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200141 volatile uint *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_psora;
wdenk2dab3012001-08-05 15:35:05 +0000142 sorp[iopin->port * 8] |= (1 << (31 - iopin->pin));
143}
144
145extern __inline__ void
146iopin_set_opt1(iopin_t *iopin)
147{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200148 volatile uint *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_psora;
wdenk2dab3012001-08-05 15:35:05 +0000149 sorp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
150}
151
152extern __inline__ uint
153iopin_is_opt2(iopin_t *iopin)
154{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200155 volatile uint *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_psora;
wdenk2dab3012001-08-05 15:35:05 +0000156 return (sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
157}
158
159extern __inline__ uint
160iopin_is_opt1(iopin_t *iopin)
161{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200162 volatile uint *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_psora;
wdenk2dab3012001-08-05 15:35:05 +0000163 return ((sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
164}
165
166#endif /* __KERNEL__ */
167
168#endif /* _ASM_IOPIN_8260_H_ */