wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 13 | typedef |
| 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 | } |
| 19 | iopin_t; |
| 20 | |
| 21 | #define IOPIN_PORTA 0 |
| 22 | #define IOPIN_PORTB 1 |
| 23 | #define IOPIN_PORTC 2 |
| 24 | #define IOPIN_PORTD 3 |
| 25 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 26 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 27 | iopin_set_high(iopin_t *iopin) |
| 28 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 29 | volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdata; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 30 | datp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 31 | } |
| 32 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 33 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 34 | iopin_set_low(iopin_t *iopin) |
| 35 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 36 | volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdata; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 37 | datp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 38 | } |
| 39 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 40 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 41 | iopin_is_high(iopin_t *iopin) |
| 42 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 43 | volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdata; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 44 | return (datp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 45 | } |
| 46 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 47 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 48 | iopin_is_low(iopin_t *iopin) |
| 49 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 50 | volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdata; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 51 | return ((datp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 52 | } |
| 53 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 54 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 55 | iopin_set_out(iopin_t *iopin) |
| 56 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 57 | volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdira; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 58 | dirp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 59 | } |
| 60 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 61 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 62 | iopin_set_in(iopin_t *iopin) |
| 63 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 64 | volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdira; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 65 | dirp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 66 | } |
| 67 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 68 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 69 | iopin_is_out(iopin_t *iopin) |
| 70 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 71 | volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdira; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 72 | return (dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 73 | } |
| 74 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 75 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 76 | iopin_is_in(iopin_t *iopin) |
| 77 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 78 | volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdira; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 79 | return ((dirp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 80 | } |
| 81 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 82 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 83 | iopin_set_odr(iopin_t *iopin) |
| 84 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 85 | volatile uint *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_podra; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 86 | odrp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 87 | } |
| 88 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 89 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 90 | iopin_set_act(iopin_t *iopin) |
| 91 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 92 | volatile uint *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_podra; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 93 | odrp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 94 | } |
| 95 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 96 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 97 | iopin_is_odr(iopin_t *iopin) |
| 98 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 99 | volatile uint *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_podra; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 100 | return (odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 101 | } |
| 102 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 103 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 104 | iopin_is_act(iopin_t *iopin) |
| 105 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 106 | volatile uint *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_podra; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 107 | return ((odrp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 108 | } |
| 109 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 110 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 111 | iopin_set_ded(iopin_t *iopin) |
| 112 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 113 | volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_ppara; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 114 | parp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 115 | } |
| 116 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 117 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 118 | iopin_set_gen(iopin_t *iopin) |
| 119 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 120 | volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_ppara; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 121 | parp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 122 | } |
| 123 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 124 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 125 | iopin_is_ded(iopin_t *iopin) |
| 126 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 127 | volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_ppara; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 128 | return (parp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 129 | } |
| 130 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 131 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 132 | iopin_is_gen(iopin_t *iopin) |
| 133 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 134 | volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_ppara; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 135 | return ((parp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 136 | } |
| 137 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 138 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 139 | iopin_set_opt2(iopin_t *iopin) |
| 140 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 141 | volatile uint *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_psora; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 142 | sorp[iopin->port * 8] |= (1 << (31 - iopin->pin)); |
| 143 | } |
| 144 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 145 | static __inline__ void |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 146 | iopin_set_opt1(iopin_t *iopin) |
| 147 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 148 | volatile uint *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_psora; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 149 | sorp[iopin->port * 8] &= ~(1 << (31 - iopin->pin)); |
| 150 | } |
| 151 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 152 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 153 | iopin_is_opt2(iopin_t *iopin) |
| 154 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 155 | volatile uint *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_psora; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 156 | return (sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1; |
| 157 | } |
| 158 | |
Måns Rullgård | 4dc3970 | 2015-11-06 12:44:01 +0000 | [diff] [blame] | 159 | static __inline__ uint |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 160 | iopin_is_opt1(iopin_t *iopin) |
| 161 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 162 | volatile uint *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_psora; |
wdenk | 2dab301 | 2001-08-05 15:35:05 +0000 | [diff] [blame] | 163 | return ((sorp[iopin->port * 8] >> (31 - iopin->pin)) & 1) ^ 1; |
| 164 | } |
| 165 | |
| 166 | #endif /* __KERNEL__ */ |
| 167 | |
| 168 | #endif /* _ASM_IOPIN_8260_H_ */ |