blob: daddb554d4923aceaf1d0a241db4bfcbab6708c2 [file] [log] [blame]
Wolfgang Denk8123eee2006-03-12 22:41:33 +01001/*
2 * MPC85xx I/O port pin manipulation functions
3 */
4
5#ifndef _ASM_IOPIN_85xx_H_
6#define _ASM_IOPIN_85xx_H_
7
8#include <linux/types.h>
9#include <asm/immap_85xx.h>
10
11#ifdef __KERNEL__
12
13typedef struct {
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 */
17} iopin_t;
18
19#define IOPIN_PORTA 0
20#define IOPIN_PORTB 1
21#define IOPIN_PORTC 2
22#define IOPIN_PORTD 3
23
24extern __inline__ void iopin_set_high (iopin_t * iopin)
25{
Kumar Galaaafeefb2007-11-28 00:36:33 -060026 volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010027 datp[iopin->port * 8] |= (1 << (31 - iopin->pin));
28}
29
30extern __inline__ void iopin_set_low (iopin_t * iopin)
31{
Kumar Galaaafeefb2007-11-28 00:36:33 -060032 volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010033 datp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
34}
35
36extern __inline__ uint iopin_is_high (iopin_t * iopin)
37{
Kumar Galaaafeefb2007-11-28 00:36:33 -060038 volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010039 return (datp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
40}
41
42extern __inline__ uint iopin_is_low (iopin_t * iopin)
43{
Kumar Galaaafeefb2007-11-28 00:36:33 -060044 volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010045 return ((datp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
46}
47
48extern __inline__ void iopin_set_out (iopin_t * iopin)
49{
Kumar Galaaafeefb2007-11-28 00:36:33 -060050 volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010051 dirp[iopin->port * 8] |= (1 << (31 - iopin->pin));
52}
53
54extern __inline__ void iopin_set_in (iopin_t * iopin)
55{
Kumar Galaaafeefb2007-11-28 00:36:33 -060056 volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010057 dirp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
58}
59
60extern __inline__ uint iopin_is_out (iopin_t * iopin)
61{
Kumar Galaaafeefb2007-11-28 00:36:33 -060062 volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010063 return (dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
64}
65
66extern __inline__ uint iopin_is_in (iopin_t * iopin)
67{
Kumar Galaaafeefb2007-11-28 00:36:33 -060068 volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010069 return ((dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
70}
71
72extern __inline__ void iopin_set_odr (iopin_t * iopin)
73{
Kumar Galaaafeefb2007-11-28 00:36:33 -060074 volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010075 odrp[iopin->port * 8] |= (1 << (31 - iopin->pin));
76}
77
78extern __inline__ void iopin_set_act (iopin_t * iopin)
79{
Kumar Galaaafeefb2007-11-28 00:36:33 -060080 volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010081 odrp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
82}
83
84extern __inline__ uint iopin_is_odr (iopin_t * iopin)
85{
Kumar Galaaafeefb2007-11-28 00:36:33 -060086 volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010087 return (odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
88}
89
90extern __inline__ uint iopin_is_act (iopin_t * iopin)
91{
Kumar Galaaafeefb2007-11-28 00:36:33 -060092 volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010093 return ((odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
94}
95
96extern __inline__ void iopin_set_ded (iopin_t * iopin)
97{
Kumar Galaaafeefb2007-11-28 00:36:33 -060098 volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara;
Wolfgang Denk8123eee2006-03-12 22:41:33 +010099 parp[iopin->port * 8] |= (1 << (31 - iopin->pin));
100}
101
102extern __inline__ void iopin_set_gen (iopin_t * iopin)
103{
Kumar Galaaafeefb2007-11-28 00:36:33 -0600104 volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara;
Wolfgang Denk8123eee2006-03-12 22:41:33 +0100105 parp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
106}
107
108extern __inline__ uint iopin_is_ded (iopin_t * iopin)
109{
Kumar Galaaafeefb2007-11-28 00:36:33 -0600110 volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara;
Wolfgang Denk8123eee2006-03-12 22:41:33 +0100111 return (parp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
112}
113
114extern __inline__ uint iopin_is_gen (iopin_t * iopin)
115{
Kumar Galaaafeefb2007-11-28 00:36:33 -0600116 volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara;
Wolfgang Denk8123eee2006-03-12 22:41:33 +0100117 return ((parp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
118}
119
120extern __inline__ void iopin_set_opt2 (iopin_t * iopin)
121{
Kumar Galaaafeefb2007-11-28 00:36:33 -0600122 volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora;
Wolfgang Denk8123eee2006-03-12 22:41:33 +0100123 sorp[iopin->port * 8] |= (1 << (31 - iopin->pin));
124}
125
126extern __inline__ void iopin_set_opt1 (iopin_t * iopin)
127{
Kumar Galaaafeefb2007-11-28 00:36:33 -0600128 volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora;
Wolfgang Denk8123eee2006-03-12 22:41:33 +0100129 sorp[iopin->port * 8] &= ~(1 << (31 - iopin->pin));
130}
131
132extern __inline__ uint iopin_is_opt2 (iopin_t * iopin)
133{
Kumar Galaaafeefb2007-11-28 00:36:33 -0600134 volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora;
Wolfgang Denk8123eee2006-03-12 22:41:33 +0100135 return (sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1;
136}
137
138extern __inline__ uint iopin_is_opt1 (iopin_t * iopin)
139{
Kumar Galaaafeefb2007-11-28 00:36:33 -0600140 volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora;
Wolfgang Denk8123eee2006-03-12 22:41:33 +0100141 return ((sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1;
142}
143
144#endif /* __KERNEL__ */
145
146#endif /* _ASM_IOPIN_85xx_H_ */