1.1 --- a/include/jz4730.h Tue Jul 11 18:45:08 2017 +0200
1.2 +++ b/include/jz4730.h Wed Jul 12 15:46:53 2017 +0200
1.3 @@ -1343,83 +1343,11 @@
1.4 /*************************************************************************
1.5 * GPIO
1.6 *************************************************************************/
1.7 -#define GPIO_GPDR(n) (GPIO_BASE + (0x00 + (n)*0x30))
1.8 -#define GPIO_GPDIR(n) (GPIO_BASE + (0x04 + (n)*0x30))
1.9 -#define GPIO_GPODR(n) (GPIO_BASE + (0x08 + (n)*0x30))
1.10 -#define GPIO_GPPUR(n) (GPIO_BASE + (0x0c + (n)*0x30))
1.11 -#define GPIO_GPALR(n) (GPIO_BASE + (0x10 + (n)*0x30))
1.12 -#define GPIO_GPAUR(n) (GPIO_BASE + (0x14 + (n)*0x30))
1.13 -#define GPIO_GPIDLR(n) (GPIO_BASE + (0x18 + (n)*0x30))
1.14 -#define GPIO_GPIDUR(n) (GPIO_BASE + (0x1c + (n)*0x30))
1.15 -#define GPIO_GPIER(n) (GPIO_BASE + (0x20 + (n)*0x30))
1.16 -#define GPIO_GPIMR(n) (GPIO_BASE + (0x24 + (n)*0x30))
1.17 -#define GPIO_GPFR(n) (GPIO_BASE + (0x28 + (n)*0x30))
1.18 -
1.19 -#define REG_GPIO_GPDR(n) REG32(GPIO_GPDR((n)))
1.20 -#define REG_GPIO_GPDIR(n) REG32(GPIO_GPDIR((n)))
1.21 -#define REG_GPIO_GPODR(n) REG32(GPIO_GPODR((n)))
1.22 -#define REG_GPIO_GPPUR(n) REG32(GPIO_GPPUR((n)))
1.23 -#define REG_GPIO_GPALR(n) REG32(GPIO_GPALR((n)))
1.24 -#define REG_GPIO_GPAUR(n) REG32(GPIO_GPAUR((n)))
1.25 -#define REG_GPIO_GPIDLR(n) REG32(GPIO_GPIDLR((n)))
1.26 -#define REG_GPIO_GPIDUR(n) REG32(GPIO_GPIDUR((n)))
1.27 -#define REG_GPIO_GPIER(n) REG32(GPIO_GPIER((n)))
1.28 -#define REG_GPIO_GPIMR(n) REG32(GPIO_GPIMR((n)))
1.29 -#define REG_GPIO_GPFR(n) REG32(GPIO_GPFR((n)))
1.30 -
1.31 -#define GPIO_IRQ_LOLEVEL 0
1.32 -#define GPIO_IRQ_HILEVEL 1
1.33 -#define GPIO_IRQ_FALLEDG 2
1.34 -#define GPIO_IRQ_RAISEDG 3
1.35
1.36 #define IRQ_GPIO_0 48
1.37 #define NUM_GPIO 100
1.38
1.39 -#define GPIO_GPDR0 GPIO_GPDR(0)
1.40 -#define GPIO_GPDR1 GPIO_GPDR(1)
1.41 -#define GPIO_GPDR2 GPIO_GPDR(2)
1.42 -#define GPIO_GPDR3 GPIO_GPDR(3)
1.43 -#define GPIO_GPDIR0 GPIO_GPDIR(0)
1.44 -#define GPIO_GPDIR1 GPIO_GPDIR(1)
1.45 -#define GPIO_GPDIR2 GPIO_GPDIR(2)
1.46 -#define GPIO_GPDIR3 GPIO_GPDIR(3)
1.47 -#define GPIO_GPODR0 GPIO_GPODR(0)
1.48 -#define GPIO_GPODR1 GPIO_GPODR(1)
1.49 -#define GPIO_GPODR2 GPIO_GPODR(2)
1.50 -#define GPIO_GPODR3 GPIO_GPODR(3)
1.51 -#define GPIO_GPPUR0 GPIO_GPPUR(0)
1.52 -#define GPIO_GPPUR1 GPIO_GPPUR(1)
1.53 -#define GPIO_GPPUR2 GPIO_GPPUR(2)
1.54 -#define GPIO_GPPUR3 GPIO_GPPUR(3)
1.55 -#define GPIO_GPALR0 GPIO_GPALR(0)
1.56 -#define GPIO_GPALR1 GPIO_GPALR(1)
1.57 -#define GPIO_GPALR2 GPIO_GPALR(2)
1.58 -#define GPIO_GPALR3 GPIO_GPALR(3)
1.59 -#define GPIO_GPAUR0 GPIO_GPAUR(0)
1.60 -#define GPIO_GPAUR1 GPIO_GPAUR(1)
1.61 -#define GPIO_GPAUR2 GPIO_GPAUR(2)
1.62 -#define GPIO_GPAUR3 GPIO_GPAUR(3)
1.63 -#define GPIO_GPIDLR0 GPIO_GPIDLR(0)
1.64 -#define GPIO_GPIDLR1 GPIO_GPIDLR(1)
1.65 -#define GPIO_GPIDLR2 GPIO_GPIDLR(2)
1.66 -#define GPIO_GPIDLR3 GPIO_GPIDLR(3)
1.67 -#define GPIO_GPIDUR0 GPIO_GPIDUR(0)
1.68 -#define GPIO_GPIDUR1 GPIO_GPIDUR(1)
1.69 -#define GPIO_GPIDUR2 GPIO_GPIDUR(2)
1.70 -#define GPIO_GPIDUR3 GPIO_GPIDUR(3)
1.71 -#define GPIO_GPIER0 GPIO_GPIER(0)
1.72 -#define GPIO_GPIER1 GPIO_GPIER(1)
1.73 -#define GPIO_GPIER2 GPIO_GPIER(2)
1.74 -#define GPIO_GPIER3 GPIO_GPIER(3)
1.75 -#define GPIO_GPIMR0 GPIO_GPIMR(0)
1.76 -#define GPIO_GPIMR1 GPIO_GPIMR(1)
1.77 -#define GPIO_GPIMR2 GPIO_GPIMR(2)
1.78 -#define GPIO_GPIMR3 GPIO_GPIMR(3)
1.79 -#define GPIO_GPFR0 GPIO_GPFR(0)
1.80 -#define GPIO_GPFR1 GPIO_GPFR(1)
1.81 -#define GPIO_GPFR2 GPIO_GPFR(2)
1.82 -#define GPIO_GPFR3 GPIO_GPFR(3)
1.83 -
1.84 +/* Register definitions with absolute positioning have been removed. */
1.85
1.86 /*************************************************************************
1.87 * HARB
1.88 @@ -3160,356 +3088,7 @@
1.89 * GPIO
1.90 ***************************************************************************/
1.91
1.92 -/* p is the port number (0,1,2,3)
1.93 - * o is the pin offset (0-31) inside the port
1.94 - * n is the absolute number of a pin (0-124), regardless of the port
1.95 - * m is the interrupt manner (low/high/falling/rising)
1.96 - */
1.97 -
1.98 -#define __gpio_port_data(p) ( REG_GPIO_GPDR(p) )
1.99 -
1.100 -#define __gpio_port_as_output(p, o) \
1.101 -do { \
1.102 - unsigned int tmp; \
1.103 - REG_GPIO_GPIER(p) &= ~(1 << (o)); \
1.104 - REG_GPIO_GPDIR(p) |= (1 << (o)); \
1.105 - if (o < 16) { \
1.106 - tmp = REG_GPIO_GPALR(p); \
1.107 - tmp &= ~(3 << ((o) << 1)); \
1.108 - REG_GPIO_GPALR(p) = tmp; \
1.109 - } else { \
1.110 - tmp = REG_GPIO_GPAUR(p); \
1.111 - tmp &= ~(3 << (((o) - 16)<< 1)); \
1.112 - REG_GPIO_GPAUR(p) = tmp; \
1.113 - } \
1.114 -} while (0)
1.115 -
1.116 -#define __gpio_port_as_input(p, o) \
1.117 -do { \
1.118 - unsigned int tmp; \
1.119 - REG_GPIO_GPIER(p) &= ~(1 << (o)); \
1.120 - REG_GPIO_GPDIR(p) &= ~(1 << (o)); \
1.121 - if (o < 16) { \
1.122 - tmp = REG_GPIO_GPALR(p); \
1.123 - tmp &= ~(3 << ((o) << 1)); \
1.124 - REG_GPIO_GPALR(p) = tmp; \
1.125 - } else { \
1.126 - tmp = REG_GPIO_GPAUR(p); \
1.127 - tmp &= ~(3 << (((o) - 16)<< 1)); \
1.128 - REG_GPIO_GPAUR(p) = tmp; \
1.129 - } \
1.130 -} while (0)
1.131 -
1.132 -#define __gpio_as_output(n) \
1.133 -do { \
1.134 - unsigned int p, o; \
1.135 - p = (n) / 32; \
1.136 - o = (n) % 32; \
1.137 - __gpio_port_as_output(p, o); \
1.138 -} while (0)
1.139 -
1.140 -#define __gpio_as_input(n) \
1.141 -do { \
1.142 - unsigned int p, o; \
1.143 - p = (n) / 32; \
1.144 - o = (n) % 32; \
1.145 - __gpio_port_as_input(p, o); \
1.146 -} while (0)
1.147 -
1.148 -#define __gpio_set_pin(n) \
1.149 -do { \
1.150 - unsigned int p, o; \
1.151 - p = (n) / 32; \
1.152 - o = (n) % 32; \
1.153 - __gpio_port_data(p) |= (1 << o); \
1.154 -} while (0)
1.155 -
1.156 -#define __gpio_clear_pin(n) \
1.157 -do { \
1.158 - unsigned int p, o; \
1.159 - p = (n) / 32; \
1.160 - o = (n) % 32; \
1.161 - __gpio_port_data(p) &= ~(1 << o); \
1.162 -} while (0)
1.163 -
1.164 -static __inline__ unsigned int __gpio_get_pin(unsigned int n)
1.165 -{
1.166 - unsigned int p, o;
1.167 - p = (n) / 32;
1.168 - o = (n) % 32;
1.169 - if (__gpio_port_data(p) & (1 << o))
1.170 - return 1;
1.171 - else
1.172 - return 0;
1.173 -}
1.174 -
1.175 -
1.176 -#define __gpio_set_irq_detect_manner(p, o, m) \
1.177 -do { \
1.178 - unsigned int tmp; \
1.179 - if (o < 16) { \
1.180 - tmp = REG_GPIO_GPIDLR(p); \
1.181 - tmp &= ~(3 << ((o) << 1)); \
1.182 - tmp |= ((m) << ((o) << 1)); \
1.183 - REG_GPIO_GPIDLR(p) = tmp; \
1.184 - } else { \
1.185 - o -= 16; \
1.186 - tmp = REG_GPIO_GPIDUR(p); \
1.187 - tmp &= ~(3 << ((o) << 1)); \
1.188 - tmp |= ((m) << ((o) << 1)); \
1.189 - REG_GPIO_GPIDUR(p) = tmp; \
1.190 - } \
1.191 -} while (0)
1.192 -
1.193 -#define __gpio_port_as_irq(p, o, m) \
1.194 -do { \
1.195 - __gpio_set_irq_detect_manner(p, o, m); \
1.196 - __gpio_port_as_input(p, o); \
1.197 - REG_GPIO_GPIER(p) |= (1 << o); \
1.198 -} while (0)
1.199 -
1.200 -#define __gpio_as_irq(n, m) \
1.201 -do { \
1.202 - unsigned int p, o; \
1.203 - p = (n) / 32; \
1.204 - o = (n) % 32; \
1.205 - __gpio_port_as_irq(p, o, m); \
1.206 -} while (0)
1.207 -
1.208 -
1.209 -#define __gpio_as_irq_high_level(n) __gpio_as_irq(n, GPIO_IRQ_HILEVEL)
1.210 -#define __gpio_as_irq_low_level(n) __gpio_as_irq(n, GPIO_IRQ_LOLEVEL)
1.211 -#define __gpio_as_irq_fall_edge(n) __gpio_as_irq(n, GPIO_IRQ_FALLEDG)
1.212 -#define __gpio_as_irq_rise_edge(n) __gpio_as_irq(n, GPIO_IRQ_RAISEDG)
1.213 -
1.214 -
1.215 -#define __gpio_mask_irq(n) \
1.216 -do { \
1.217 - unsigned int p, o; \
1.218 - p = (n) / 32; \
1.219 - o = (n) % 32; \
1.220 - REG_GPIO_GPIER(p) &= ~(1 << o); \
1.221 -} while (0)
1.222 -
1.223 -#define __gpio_unmask_irq(n) \
1.224 -do { \
1.225 - unsigned int p, o; \
1.226 - p = (n) / 32; \
1.227 - o = (n) % 32; \
1.228 - REG_GPIO_GPIER(n) |= (1 << o); \
1.229 -} while (0)
1.230 -
1.231 -#define __gpio_ack_irq(n) \
1.232 -do { \
1.233 - unsigned int p, o; \
1.234 - p = (n) / 32; \
1.235 - o = (n) % 32; \
1.236 - REG_GPIO_GPFR(p) |= (1 << o); \
1.237 -} while (0)
1.238 -
1.239 -
1.240 -static __inline__ unsigned int __gpio_get_irq(void)
1.241 -{
1.242 - unsigned int tmp, i;
1.243 -
1.244 - tmp = REG_GPIO_GPFR(3);
1.245 - for (i=0; i<32; i++)
1.246 - if (tmp & (1 << i))
1.247 - return 0x60 + i;
1.248 - tmp = REG_GPIO_GPFR(2);
1.249 - for (i=0; i<32; i++)
1.250 - if (tmp & (1 << i))
1.251 - return 0x40 + i;
1.252 - tmp = REG_GPIO_GPFR(1);
1.253 - for (i=0; i<32; i++)
1.254 - if (tmp & (1 << i))
1.255 - return 0x20 + i;
1.256 - tmp = REG_GPIO_GPFR(0);
1.257 - for (i=0; i<32; i++)
1.258 - if (tmp & (1 << i))
1.259 - return i;
1.260 - return 0;
1.261 -}
1.262 -
1.263 -#define __gpio_group_irq(n) \
1.264 -({ \
1.265 - register int tmp, i; \
1.266 - tmp = REG_GPIO_GPFR((n)); \
1.267 - for (i=31;i>=0;i--) \
1.268 - if (tmp & (1 << i)) \
1.269 - break; \
1.270 - i; \
1.271 -})
1.272 -
1.273 -#define __gpio_enable_pull(n) \
1.274 -do { \
1.275 - unsigned int p, o; \
1.276 - p = (n) / 32; \
1.277 - o = (n) % 32; \
1.278 - REG_GPIO_GPPUR(p) |= (1 << o); \
1.279 -} while (0)
1.280 -
1.281 -#define __gpio_disable_pull(n) \
1.282 -do { \
1.283 - unsigned int p, o; \
1.284 - p = (n) / 32; \
1.285 - o = (n) % 32; \
1.286 - REG_GPIO_GPPUR(p) &= ~(1 << o); \
1.287 -} while (0)
1.288 -
1.289 -/* Init the alternate function pins */
1.290 -
1.291 -
1.292 -#define __gpio_as_ssi() \
1.293 -do { \
1.294 - REG_GPIO_GPALR(2) &= 0xFC00FFFF; \
1.295 - REG_GPIO_GPALR(2) |= 0x01550000; \
1.296 -} while (0)
1.297 -
1.298 -#define __gpio_as_uart3() \
1.299 -do { \
1.300 - REG_GPIO_GPAUR(0) &= 0xFFFF0000; \
1.301 - REG_GPIO_GPAUR(0) |= 0x00005555; \
1.302 -} while (0)
1.303 -
1.304 -#define __gpio_as_uart2() \
1.305 -do { \
1.306 - REG_GPIO_GPALR(3) &= 0x3FFFFFFF; \
1.307 - REG_GPIO_GPALR(3) |= 0x40000000; \
1.308 - REG_GPIO_GPAUR(3) &= 0xF3FFFFFF; \
1.309 - REG_GPIO_GPAUR(3) |= 0x04000000; \
1.310 -} while (0)
1.311 -
1.312 -#define __gpio_as_uart1() \
1.313 -do { \
1.314 - REG_GPIO_GPAUR(0) &= 0xFFF0FFFF; \
1.315 - REG_GPIO_GPAUR(0) |= 0x00050000; \
1.316 -} while (0)
1.317 -
1.318 -#define __gpio_as_uart0() \
1.319 -do { \
1.320 - REG_GPIO_GPAUR(3) &= 0x0FFFFFFF; \
1.321 - REG_GPIO_GPAUR(3) |= 0x50000000; \
1.322 -} while (0)
1.323 -
1.324 -
1.325 -#define __gpio_as_scc0() \
1.326 -do { \
1.327 - REG_GPIO_GPALR(2) &= 0xFFFFFFCC; \
1.328 - REG_GPIO_GPALR(2) |= 0x00000011; \
1.329 -} while (0)
1.330 -
1.331 -#define __gpio_as_scc1() \
1.332 -do { \
1.333 - REG_GPIO_GPALR(2) &= 0xFFFFFF33; \
1.334 - REG_GPIO_GPALR(2) |= 0x00000044; \
1.335 -} while (0)
1.336 -
1.337 -#define __gpio_as_scc() \
1.338 -do { \
1.339 - __gpio_as_scc0(); \
1.340 - __gpio_as_scc1(); \
1.341 -} while (0)
1.342 -
1.343 -#define __gpio_as_dma() \
1.344 -do { \
1.345 - REG_GPIO_GPALR(0) &= 0x00FFFFFF; \
1.346 - REG_GPIO_GPALR(0) |= 0x55000000; \
1.347 - REG_GPIO_GPAUR(0) &= 0xFF0FFFFF; \
1.348 - REG_GPIO_GPAUR(0) |= 0x00500000; \
1.349 -} while (0)
1.350 -
1.351 -#define __gpio_as_msc() \
1.352 -do { \
1.353 - REG_GPIO_GPALR(1) &= 0xFFFF000F; \
1.354 - REG_GPIO_GPALR(1) |= 0x00005550; \
1.355 -} while (0)
1.356 -
1.357 -#define __gpio_as_pcmcia() \
1.358 -do { \
1.359 - REG_GPIO_GPAUR(2) &= 0xF000FFFF; \
1.360 - REG_GPIO_GPAUR(2) |= 0x05550000; \
1.361 -} while (0)
1.362 -
1.363 -#define __gpio_as_emc() \
1.364 -do { \
1.365 - REG_GPIO_GPALR(2) &= 0x3FFFFFFF; \
1.366 - REG_GPIO_GPALR(2) |= 0x40000000; \
1.367 - REG_GPIO_GPAUR(2) &= 0xFFFF0000; \
1.368 - REG_GPIO_GPAUR(2) |= 0x00005555; \
1.369 -} while (0)
1.370 -
1.371 -#define __gpio_as_lcd_slave() \
1.372 -do { \
1.373 - REG_GPIO_GPALR(1) &= 0x0000FFFF; \
1.374 - REG_GPIO_GPALR(1) |= 0x55550000; \
1.375 - REG_GPIO_GPAUR(1) &= 0x00000000; \
1.376 - REG_GPIO_GPAUR(1) |= 0x55555555; \
1.377 -} while (0)
1.378 -
1.379 -#define __gpio_as_lcd_master() \
1.380 -do { \
1.381 - REG_GPIO_GPALR(1) &= 0x0000FFFF; \
1.382 - REG_GPIO_GPALR(1) |= 0x55550000; \
1.383 - REG_GPIO_GPAUR(1) &= 0x00000000; \
1.384 - REG_GPIO_GPAUR(1) |= 0x556A5555; \
1.385 -} while (0)
1.386 -
1.387 -#define __gpio_as_usb() \
1.388 -do { \
1.389 - REG_GPIO_GPAUR(0) &= 0x00FFFFFF; \
1.390 - REG_GPIO_GPAUR(0) |= 0x55000000; \
1.391 -} while (0)
1.392 -
1.393 -#define __gpio_as_ac97() \
1.394 -do { \
1.395 - REG_GPIO_GPALR(2) &= 0xC3FF03FF; \
1.396 - REG_GPIO_GPALR(2) |= 0x24005400; \
1.397 -} while (0)
1.398 -
1.399 -#define __gpio_as_i2s_slave() \
1.400 -do { \
1.401 - REG_GPIO_GPALR(2) &= 0xC3FF0CFF; \
1.402 - REG_GPIO_GPALR(2) |= 0x14005100; \
1.403 -} while (0)
1.404 -
1.405 -#define __gpio_as_i2s_master() \
1.406 -do { \
1.407 - REG_GPIO_GPALR(2) &= 0xC3FF0CFF; \
1.408 - REG_GPIO_GPALR(2) |= 0x28005100; \
1.409 -} while (0)
1.410 -
1.411 -#define __gpio_as_eth() \
1.412 -do { \
1.413 - REG_GPIO_GPAUR(3) &= 0xFC000000; \
1.414 - REG_GPIO_GPAUR(3) |= 0x01555555; \
1.415 -} while (0)
1.416 -
1.417 -#define __gpio_as_pwm() \
1.418 -do { \
1.419 - REG_GPIO_GPAUR(2) &= 0x0FFFFFFF; \
1.420 - REG_GPIO_GPAUR(2) |= 0x50000000; \
1.421 -} while (0)
1.422 -
1.423 -#define __gpio_as_ps2() \
1.424 -do { \
1.425 - REG_GPIO_GPALR(1) &= 0xFFFFFFF0; \
1.426 - REG_GPIO_GPALR(1) |= 0x00000005; \
1.427 -} while (0)
1.428 -
1.429 -#define __gpio_as_uprt() \
1.430 -do { \
1.431 - REG_GPIO_GPALR(1) &= 0x0000000F; \
1.432 - REG_GPIO_GPALR(1) |= 0x55555550; \
1.433 - REG_GPIO_GPALR(3) &= 0xC0000000; \
1.434 - REG_GPIO_GPALR(3) |= 0x15555555; \
1.435 -} while (0)
1.436 -
1.437 -#define __gpio_as_cim() \
1.438 -do { \
1.439 - REG_GPIO_GPALR(0) &= 0xFF000000; \
1.440 - REG_GPIO_GPALR(0) |= 0x00555555; \
1.441 -} while (0)
1.442 +/* Register operations using absolute positioning have been removed. */
1.443
1.444 /***************************************************************************
1.445 * HARB