Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 13 | typedef 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 | |
| 24 | extern __inline__ void iopin_set_high (iopin_t * iopin) |
| 25 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 26 | volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 27 | datp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 28 | } |
| 29 | |
| 30 | extern __inline__ void iopin_set_low (iopin_t * iopin) |
| 31 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 32 | volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 33 | datp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 34 | } |
| 35 | |
| 36 | extern __inline__ uint iopin_is_high (iopin_t * iopin) |
| 37 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 38 | volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 39 | return (datp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 40 | } |
| 41 | |
| 42 | extern __inline__ uint iopin_is_low (iopin_t * iopin) |
| 43 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 44 | volatile uint *datp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdata; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 45 | return ((datp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 46 | } |
| 47 | |
| 48 | extern __inline__ void iopin_set_out (iopin_t * iopin) |
| 49 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 50 | volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 51 | dirp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 52 | } |
| 53 | |
| 54 | extern __inline__ void iopin_set_in (iopin_t * iopin) |
| 55 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 56 | volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 57 | dirp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 58 | } |
| 59 | |
| 60 | extern __inline__ uint iopin_is_out (iopin_t * iopin) |
| 61 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 62 | volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 63 | return (dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 64 | } |
| 65 | |
| 66 | extern __inline__ uint iopin_is_in (iopin_t * iopin) |
| 67 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 68 | volatile uint *dirp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.pdira; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 69 | return ((dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 70 | } |
| 71 | |
| 72 | extern __inline__ void iopin_set_odr (iopin_t * iopin) |
| 73 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 74 | volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 75 | odrp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 76 | } |
| 77 | |
| 78 | extern __inline__ void iopin_set_act (iopin_t * iopin) |
| 79 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 80 | volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 81 | odrp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 82 | } |
| 83 | |
| 84 | extern __inline__ uint iopin_is_odr (iopin_t * iopin) |
| 85 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 86 | volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 87 | return (odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 88 | } |
| 89 | |
| 90 | extern __inline__ uint iopin_is_act (iopin_t * iopin) |
| 91 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 92 | volatile uint *odrp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.podra; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 93 | return ((odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 94 | } |
| 95 | |
| 96 | extern __inline__ void iopin_set_ded (iopin_t * iopin) |
| 97 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 98 | volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 99 | parp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 100 | } |
| 101 | |
| 102 | extern __inline__ void iopin_set_gen (iopin_t * iopin) |
| 103 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 104 | volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 105 | parp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 106 | } |
| 107 | |
| 108 | extern __inline__ uint iopin_is_ded (iopin_t * iopin) |
| 109 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 110 | volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 111 | return (parp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 112 | } |
| 113 | |
| 114 | extern __inline__ uint iopin_is_gen (iopin_t * iopin) |
| 115 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 116 | volatile uint *parp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.ppara; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 117 | return ((parp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 118 | } |
| 119 | |
| 120 | extern __inline__ void iopin_set_opt2 (iopin_t * iopin) |
| 121 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 122 | volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 123 | sorp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 124 | } |
| 125 | |
| 126 | extern __inline__ void iopin_set_opt1 (iopin_t * iopin) |
| 127 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 128 | volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 129 | sorp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 130 | } |
| 131 | |
| 132 | extern __inline__ uint iopin_is_opt2 (iopin_t * iopin) |
| 133 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 134 | volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 135 | return (sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 136 | } |
| 137 | |
| 138 | extern __inline__ uint iopin_is_opt1 (iopin_t * iopin) |
| 139 | { |
Kumar Gala | cd113a0 | 2007-11-28 00:36:33 -0600 | [diff] [blame] | 140 | volatile uint *sorp = &((ccsr_cpm_t *) CFG_MPC85xx_CPM_ADDR)->im_cpm_iop.psora; |
Wolfgang Denk | b32a921 | 2006-03-12 22:41:33 +0100 | [diff] [blame] | 141 | return ((sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 142 | } |
| 143 | |
| 144 | #endif /* __KERNEL__ */ |
| 145 | |
| 146 | #endif /* _ASM_IOPIN_85xx_H_ */ |