blob: 0f07ba355e9c0f64b5ecf5d4f802fc1d4e2f9e02 [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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020026 volatile uint *datp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020032 volatile uint *datp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020038 volatile uint *datp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020044 volatile uint *datp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020050 volatile uint *dirp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020056 volatile uint *dirp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020062 volatile uint *dirp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020068 volatile uint *dirp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020074 volatile uint *odrp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020080 volatile uint *odrp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020086 volatile uint *odrp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020092 volatile uint *odrp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020098 volatile uint *parp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200104 volatile uint *parp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200110 volatile uint *parp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200116 volatile uint *parp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200122 volatile uint *sorp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200128 volatile uint *sorp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200134 volatile uint *sorp = &((ccsr_cpm_t *) CONFIG_SYS_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{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200140 volatile uint *sorp = &((ccsr_cpm_t *) CONFIG_SYS_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_ */