Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 1 | /* |
| 2 | * See file CREDITS for list of people who contributed to this |
| 3 | * project. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; either version 2 of |
| 8 | * the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 18 | * MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | * MPC8xx I/O port pin manipulation functions |
| 23 | * Roughly based on iopin_8260.h |
| 24 | */ |
| 25 | |
| 26 | #ifndef _ASM_IOPIN_8XX_H_ |
| 27 | #define _ASM_IOPIN_8XX_H_ |
| 28 | |
| 29 | #include <linux/types.h> |
| 30 | #include <asm/8xx_immap.h> |
| 31 | |
| 32 | #ifdef __KERNEL__ |
| 33 | |
| 34 | typedef struct { |
| 35 | u_char port:2; /* port number (A=0, B=1, C=2, D=3) */ |
| 36 | u_char pin:5; /* port pin (0-31) */ |
| 37 | u_char flag:1; /* for whatever */ |
| 38 | } iopin_t; |
| 39 | |
| 40 | #define IOPIN_PORTA 0 |
| 41 | #define IOPIN_PORTB 1 |
| 42 | #define IOPIN_PORTC 2 |
| 43 | #define IOPIN_PORTD 3 |
| 44 | |
| 45 | extern __inline__ void |
| 46 | iopin_set_high(iopin_t *iopin) |
| 47 | { |
| 48 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 49 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 50 | *datp |= (1 << (15 - iopin->pin)); |
| 51 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 53 | *datp |= (1 << (31 - iopin->pin)); |
| 54 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 55 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 56 | *datp |= (1 << (15 - iopin->pin)); |
| 57 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 58 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 59 | *datp |= (1 << (15 - iopin->pin)); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | extern __inline__ void |
| 64 | iopin_set_low(iopin_t *iopin) |
| 65 | { |
| 66 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 67 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 68 | *datp &= ~(1 << (15 - iopin->pin)); |
| 69 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 70 | volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 71 | *datp &= ~(1 << (31 - iopin->pin)); |
| 72 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 73 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 74 | *datp &= ~(1 << (15 - iopin->pin)); |
| 75 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 76 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 77 | *datp &= ~(1 << (15 - iopin->pin)); |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | extern __inline__ uint |
| 82 | iopin_is_high(iopin_t *iopin) |
| 83 | { |
| 84 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 85 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 86 | return (*datp >> (15 - iopin->pin)) & 1; |
| 87 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 89 | return (*datp >> (31 - iopin->pin)) & 1; |
| 90 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 91 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 92 | return (*datp >> (15 - iopin->pin)) & 1; |
| 93 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 94 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 95 | return (*datp >> (15 - iopin->pin)) & 1; |
| 96 | } |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | extern __inline__ uint |
| 101 | iopin_is_low(iopin_t *iopin) |
| 102 | { |
| 103 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 104 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 105 | return ((*datp >> (15 - iopin->pin)) & 1) ^ 1; |
| 106 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 107 | volatile uint *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 108 | return ((*datp >> (31 - iopin->pin)) & 1) ^ 1; |
| 109 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 110 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 111 | return ((*datp >> (15 - iopin->pin)) & 1) ^ 1; |
| 112 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 113 | volatile ushort *datp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddat; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 114 | return ((*datp >> (15 - iopin->pin)) & 1) ^ 1; |
| 115 | } |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | extern __inline__ void |
| 120 | iopin_set_out(iopin_t *iopin) |
| 121 | { |
| 122 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 123 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 124 | *dirp |= (1 << (15 - iopin->pin)); |
| 125 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 126 | volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 127 | *dirp |= (1 << (31 - iopin->pin)); |
| 128 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 129 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 130 | *dirp |= (1 << (15 - iopin->pin)); |
| 131 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 132 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 133 | *dirp |= (1 << (15 - iopin->pin)); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | extern __inline__ void |
| 138 | iopin_set_in(iopin_t *iopin) |
| 139 | { |
| 140 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 141 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 142 | *dirp &= ~(1 << (15 - iopin->pin)); |
| 143 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 144 | volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 145 | *dirp &= ~(1 << (31 - iopin->pin)); |
| 146 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 147 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 148 | *dirp &= ~(1 << (15 - iopin->pin)); |
| 149 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 150 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 151 | *dirp &= ~(1 << (15 - iopin->pin)); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | extern __inline__ uint |
| 156 | iopin_is_out(iopin_t *iopin) |
| 157 | { |
| 158 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 159 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 160 | return (*dirp >> (15 - iopin->pin)) & 1; |
| 161 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 162 | volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 163 | return (*dirp >> (31 - iopin->pin)) & 1; |
| 164 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 165 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 166 | return (*dirp >> (15 - iopin->pin)) & 1; |
| 167 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 168 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 169 | return (*dirp >> (15 - iopin->pin)) & 1; |
| 170 | } |
| 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | extern __inline__ uint |
| 175 | iopin_is_in(iopin_t *iopin) |
| 176 | { |
| 177 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 178 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_padir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 179 | return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1; |
| 180 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 181 | volatile uint *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbdir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 182 | return ((*dirp >> (31 - iopin->pin)) & 1) ^ 1; |
| 183 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 184 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcdir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 185 | return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1; |
| 186 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 187 | volatile ushort *dirp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pddir; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 188 | return ((*dirp >> (15 - iopin->pin)) & 1) ^ 1; |
| 189 | } |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | extern __inline__ void |
| 194 | iopin_set_odr(iopin_t *iopin) |
| 195 | { |
| 196 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 197 | volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 198 | *odrp |= (1 << (15 - iopin->pin)); |
| 199 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 200 | volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 201 | *odrp |= (1 << (31 - iopin->pin)); |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | extern __inline__ void |
| 206 | iopin_set_act(iopin_t *iopin) |
| 207 | { |
| 208 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 209 | volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 210 | *odrp &= ~(1 << (15 - iopin->pin)); |
| 211 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 212 | volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 213 | *odrp &= ~(1 << (31 - iopin->pin)); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | extern __inline__ uint |
| 218 | iopin_is_odr(iopin_t *iopin) |
| 219 | { |
| 220 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 221 | volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 222 | return (*odrp >> (15 - iopin->pin)) & 1; |
| 223 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 224 | volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 225 | return (*odrp >> (31 - iopin->pin)) & 1; |
| 226 | } |
| 227 | return 0; |
| 228 | } |
| 229 | |
| 230 | extern __inline__ uint |
| 231 | iopin_is_act(iopin_t *iopin) |
| 232 | { |
| 233 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 234 | volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_paodr; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 235 | return ((*odrp >> (15 - iopin->pin)) & 1) ^ 1; |
| 236 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 237 | volatile ushort *odrp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbodr; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 238 | return ((*odrp >> (31 - iopin->pin)) & 1) ^ 1; |
| 239 | } |
| 240 | return 0; |
| 241 | } |
| 242 | |
| 243 | extern __inline__ void |
| 244 | iopin_set_ded(iopin_t *iopin) |
| 245 | { |
| 246 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 247 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 248 | *parp |= (1 << (15 - iopin->pin)); |
| 249 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 250 | volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 251 | *parp |= (1 << (31 - iopin->pin)); |
| 252 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 253 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 254 | *parp |= (1 << (15 - iopin->pin)); |
| 255 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 256 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 257 | *parp |= (1 << (15 - iopin->pin)); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | extern __inline__ void |
| 262 | iopin_set_gen(iopin_t *iopin) |
| 263 | { |
| 264 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 265 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 266 | *parp &= ~(1 << (15 - iopin->pin)); |
| 267 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 268 | volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 269 | *parp &= ~(1 << (31 - iopin->pin)); |
| 270 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 271 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 272 | *parp &= ~(1 << (15 - iopin->pin)); |
| 273 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 274 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 275 | *parp &= ~(1 << (15 - iopin->pin)); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | extern __inline__ uint |
| 280 | iopin_is_ded(iopin_t *iopin) |
| 281 | { |
| 282 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 283 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 284 | return (*parp >> (15 - iopin->pin)) & 1; |
| 285 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 286 | volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 287 | return (*parp >> (31 - iopin->pin)) & 1; |
| 288 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 289 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 290 | return (*parp >> (15 - iopin->pin)) & 1; |
| 291 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 292 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 293 | return (*parp >> (15 - iopin->pin)) & 1; |
| 294 | } |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | extern __inline__ uint |
| 299 | iopin_is_gen(iopin_t *iopin) |
| 300 | { |
| 301 | if (iopin->port == IOPIN_PORTA) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 302 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_papar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 303 | return ((*parp >> (15 - iopin->pin)) & 1) ^ 1; |
| 304 | } else if (iopin->port == IOPIN_PORTB) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 305 | volatile uint *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_pbpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 306 | return ((*parp >> (31 - iopin->pin)) & 1) ^ 1; |
| 307 | } else if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 308 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 309 | return ((*parp >> (15 - iopin->pin)) & 1) ^ 1; |
| 310 | } else if (iopin->port == IOPIN_PORTD) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 311 | volatile ushort *parp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pdpar; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 312 | return ((*parp >> (15 - iopin->pin)) & 1) ^ 1; |
| 313 | } |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | extern __inline__ void |
| 318 | iopin_set_opt2(iopin_t *iopin) |
| 319 | { |
| 320 | if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 321 | volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 322 | *sorp |= (1 << (15 - iopin->pin)); |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | extern __inline__ void |
| 327 | iopin_set_opt1(iopin_t *iopin) |
| 328 | { |
| 329 | if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 330 | volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 331 | *sorp &= ~(1 << (15 - iopin->pin)); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | extern __inline__ uint |
| 336 | iopin_is_opt2(iopin_t *iopin) |
| 337 | { |
| 338 | if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 339 | volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 340 | return (*sorp >> (15 - iopin->pin)) & 1; |
| 341 | } |
| 342 | return 0; |
| 343 | } |
| 344 | |
| 345 | extern __inline__ uint |
| 346 | iopin_is_opt1(iopin_t *iopin) |
| 347 | { |
| 348 | if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 349 | volatile ushort *sorp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcso; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 350 | return ((*sorp >> (15 - iopin->pin)) & 1) ^ 1; |
| 351 | } |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | extern __inline__ void |
| 356 | iopin_set_falledge(iopin_t *iopin) |
| 357 | { |
| 358 | if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 359 | volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 360 | *intp |= (1 << (15 - iopin->pin)); |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | extern __inline__ void |
| 365 | iopin_set_anyedge(iopin_t *iopin) |
| 366 | { |
| 367 | if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 368 | volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 369 | *intp &= ~(1 << (15 - iopin->pin)); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | extern __inline__ uint |
| 374 | iopin_is_falledge(iopin_t *iopin) |
| 375 | { |
| 376 | if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 377 | volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 378 | return (*intp >> (15 - iopin->pin)) & 1; |
| 379 | } |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | extern __inline__ uint |
| 384 | iopin_is_anyedge(iopin_t *iopin) |
| 385 | { |
| 386 | if (iopin->port == IOPIN_PORTC) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 387 | volatile ushort *intp = &((immap_t *)CONFIG_SYS_IMMR)->im_ioport.iop_pcint; |
Wolfgang Denk | cba3feb | 2005-09-26 00:44:15 +0200 | [diff] [blame] | 388 | return ((*intp >> (15 - iopin->pin)) & 1) ^ 1; |
| 389 | } |
| 390 | return 0; |
| 391 | } |
| 392 | |
| 393 | #endif /* __KERNEL__ */ |
| 394 | |
| 395 | #endif /* _ASM_IOPIN_8XX_H_ */ |