1.1 --- a/include/jz4740.h Tue Jul 11 18:45:08 2017 +0200
1.2 +++ b/include/jz4740.h Wed Jul 12 15:46:53 2017 +0200
1.3 @@ -742,60 +742,11 @@
1.4 /*************************************************************************
1.5 * GPIO (General-Purpose I/O Ports)
1.6 *************************************************************************/
1.7 +
1.8 +/* Register definitions with absolute positioning have been removed. */
1.9 +
1.10 #define MAX_GPIO_NUM 128
1.11
1.12 -/* = 0,1,2,3 */
1.13 -#define GPIO_PXPIN(n) (GPIO_BASE + (0x00 + (n)*0x100)) /* PIN Level Register */
1.14 -#define GPIO_PXDAT(n) (GPIO_BASE + (0x10 + (n)*0x100)) /* Port Data Register */
1.15 -#define GPIO_PXDATS(n) (GPIO_BASE + (0x14 + (n)*0x100)) /* Port Data Set Register */
1.16 -#define GPIO_PXDATC(n) (GPIO_BASE + (0x18 + (n)*0x100)) /* Port Data Clear Register */
1.17 -#define GPIO_PXIM(n) (GPIO_BASE + (0x20 + (n)*0x100)) /* Interrupt Mask Register */
1.18 -#define GPIO_PXIMS(n) (GPIO_BASE + (0x24 + (n)*0x100)) /* Interrupt Mask Set Reg */
1.19 -#define GPIO_PXIMC(n) (GPIO_BASE + (0x28 + (n)*0x100)) /* Interrupt Mask Clear Reg */
1.20 -#define GPIO_PXPE(n) (GPIO_BASE + (0x30 + (n)*0x100)) /* Pull Enable Register */
1.21 -#define GPIO_PXPES(n) (GPIO_BASE + (0x34 + (n)*0x100)) /* Pull Enable Set Reg. */
1.22 -#define GPIO_PXPEC(n) (GPIO_BASE + (0x38 + (n)*0x100)) /* Pull Enable Clear Reg. */
1.23 -#define GPIO_PXFUN(n) (GPIO_BASE + (0x40 + (n)*0x100)) /* Function Register */
1.24 -#define GPIO_PXFUNS(n) (GPIO_BASE + (0x44 + (n)*0x100)) /* Function Set Register */
1.25 -#define GPIO_PXFUNC(n) (GPIO_BASE + (0x48 + (n)*0x100)) /* Function Clear Register */
1.26 -#define GPIO_PXSEL(n) (GPIO_BASE + (0x50 + (n)*0x100)) /* Select Register */
1.27 -#define GPIO_PXSELS(n) (GPIO_BASE + (0x54 + (n)*0x100)) /* Select Set Register */
1.28 -#define GPIO_PXSELC(n) (GPIO_BASE + (0x58 + (n)*0x100)) /* Select Clear Register */
1.29 -#define GPIO_PXDIR(n) (GPIO_BASE + (0x60 + (n)*0x100)) /* Direction Register */
1.30 -#define GPIO_PXDIRS(n) (GPIO_BASE + (0x64 + (n)*0x100)) /* Direction Set Register */
1.31 -#define GPIO_PXDIRC(n) (GPIO_BASE + (0x68 + (n)*0x100)) /* Direction Clear Register */
1.32 -#define GPIO_PXTRG(n) (GPIO_BASE + (0x70 + (n)*0x100)) /* Trigger Register */
1.33 -#define GPIO_PXTRGS(n) (GPIO_BASE + (0x74 + (n)*0x100)) /* Trigger Set Register */
1.34 -#define GPIO_PXTRGC(n) (GPIO_BASE + (0x78 + (n)*0x100)) /* Trigger Set Register */
1.35 -#define GPIO_PXFLG(n) (GPIO_BASE + (0x80 + (n)*0x100)) /* Port Flag Register */
1.36 -#define GPIO_PXFLGC(n) (GPIO_BASE + (0x84 + (n)*0x100)) /* Port Flag clear Register */
1.37 -
1.38 -#define REG_GPIO_PXPIN(n) REG32(GPIO_PXPIN((n))) /* PIN level */
1.39 -#define REG_GPIO_PXDAT(n) REG32(GPIO_PXDAT((n))) /* 1: interrupt pending */
1.40 -#define REG_GPIO_PXDATS(n) REG32(GPIO_PXDATS((n)))
1.41 -#define REG_GPIO_PXDATC(n) REG32(GPIO_PXDATC((n)))
1.42 -#define REG_GPIO_PXIM(n) REG32(GPIO_PXIM((n))) /* 1: mask pin interrupt */
1.43 -#define REG_GPIO_PXIMS(n) REG32(GPIO_PXIMS((n)))
1.44 -#define REG_GPIO_PXIMC(n) REG32(GPIO_PXIMC((n)))
1.45 -#define REG_GPIO_PXPE(n) REG32(GPIO_PXPE((n))) /* 1: disable pull up/down */
1.46 -#define REG_GPIO_PXPES(n) REG32(GPIO_PXPES((n)))
1.47 -#define REG_GPIO_PXPEC(n) REG32(GPIO_PXPEC((n)))
1.48 -#define REG_GPIO_PXFUN(n) REG32(GPIO_PXFUN((n))) /* 0:GPIO or intr, 1:FUNC */
1.49 -#define REG_GPIO_PXFUNS(n) REG32(GPIO_PXFUNS((n)))
1.50 -#define REG_GPIO_PXFUNC(n) REG32(GPIO_PXFUNC((n)))
1.51 -#define REG_GPIO_PXSEL(n) REG32(GPIO_PXSEL((n))) /* 0:GPIO/Fun0,1:intr/fun1*/
1.52 -#define REG_GPIO_PXSELS(n) REG32(GPIO_PXSELS((n)))
1.53 -#define REG_GPIO_PXSELC(n) REG32(GPIO_PXSELC((n)))
1.54 -#define REG_GPIO_PXDIR(n) REG32(GPIO_PXDIR((n))) /* 0:input/low-level-trig/falling-edge-trig, 1:output/high-level-trig/rising-edge-trig */
1.55 -#define REG_GPIO_PXDIRS(n) REG32(GPIO_PXDIRS((n)))
1.56 -#define REG_GPIO_PXDIRC(n) REG32(GPIO_PXDIRC((n)))
1.57 -#define REG_GPIO_PXTRG(n) REG32(GPIO_PXTRG((n))) /* 0:level-trigger, 1:edge-trigger */
1.58 -#define REG_GPIO_PXTRGS(n) REG32(GPIO_PXTRGS((n)))
1.59 -#define REG_GPIO_PXTRGC(n) REG32(GPIO_PXTRGC((n)))
1.60 -#define REG_GPIO_PXFLG(n) REG32(GPIO_PXFLG((n))) /* interrupt flag */
1.61 -#define REG_GPIO_PXFLGC(n) REG32(GPIO_PXFLGC((n))) /* interrupt flag */
1.62 -
1.63 -
1.64 /*************************************************************************
1.65 * UART
1.66 *************************************************************************/
1.67 @@ -2317,701 +2268,10 @@
1.68
1.69
1.70 /* Module Operation Definitions */
1.71 +
1.72 #ifndef __ASSEMBLY__
1.73
1.74 -
1.75 -/* GPIO Pins Description */
1.76 -/* PORT 0: */
1.77 -/* PIN/BIT N FUNC0 FUNC1 */
1.78 -/* 0 D0 - */
1.79 -/* 1 D1 - */
1.80 -/* 2 D2 - */
1.81 -/* 3 D3 - */
1.82 -/* 4 D4 - */
1.83 -/* 5 D5 - */
1.84 -/* 6 D6 - */
1.85 -/* 7 D7 - */
1.86 -/* 8 D8 - */
1.87 -/* 9 D9 - */
1.88 -/* 10 D10 - */
1.89 -/* 11 D11 - */
1.90 -/* 12 D12 - */
1.91 -/* 13 D13 - */
1.92 -/* 14 D14 - */
1.93 -/* 15 D15 - */
1.94 -/* 16 D16 - */
1.95 -/* 17 D17 - */
1.96 -/* 18 D18 - */
1.97 -/* 19 D19 - */
1.98 -/* 20 D20 - */
1.99 -/* 21 D21 - */
1.100 -/* 22 D22 - */
1.101 -/* 23 D23 - */
1.102 -/* 24 D24 - */
1.103 -/* 25 D25 - */
1.104 -/* 26 D26 - */
1.105 -/* 27 D27 - */
1.106 -/* 28 D28 - */
1.107 -/* 29 D29 - */
1.108 -/* 30 D30 - */
1.109 -/* 31 D31 - */
1.110 -/*------------------------------------------------------ */
1.111 -/* PORT 1: */
1.112 -/* */
1.113 -/* PIN/BIT N FUNC0 FUNC1 */
1.114 -/* 0 A0 - */
1.115 -/* 1 A1 - */
1.116 -/* 2 A2 - */
1.117 -/* 3 A3 - */
1.118 -/* 4 A4 - */
1.119 -/* 5 A5 - */
1.120 -/* 6 A6 - */
1.121 -/* 7 A7 - */
1.122 -/* 8 A8 - */
1.123 -/* 9 A9 - */
1.124 -/* 10 A10 - */
1.125 -/* 11 A11 - */
1.126 -/* 12 A12 - */
1.127 -/* 13 A13 - */
1.128 -/* 14 A14 - */
1.129 -/* 15 A15/CL - */
1.130 -/* 16 A16/AL - */
1.131 -/* 17 LCD_CLS A21 */
1.132 -/* 18 LCD_SPL A22 */
1.133 -/* 19 DCS# - */
1.134 -/* 20 RAS# - */
1.135 -/* 21 CAS# - */
1.136 -/* 22 RDWE#/BUFD# - */
1.137 -/* 23 CKE - */
1.138 -/* 24 CKO - */
1.139 -/* 25 CS1# - */
1.140 -/* 26 CS2# - */
1.141 -/* 27 CS3# - */
1.142 -/* 28 CS4# - */
1.143 -/* 29 RD# - */
1.144 -/* 30 WR# - */
1.145 -/* 31 WE0# - */
1.146 -/* Note: PIN15&16 are CL&AL when connecting to NAND flash. */
1.147 -/*------------------------------------------------------ */
1.148 -/* PORT 2: */
1.149 -/* */
1.150 -/* PIN/BIT N FUNC0 FUNC1 */
1.151 -/* 0 LCD_D0 - */
1.152 -/* 1 LCD_D1 - */
1.153 -/* 2 LCD_D2 - */
1.154 -/* 3 LCD_D3 - */
1.155 -/* 4 LCD_D4 - */
1.156 -/* 5 LCD_D5 - */
1.157 -/* 6 LCD_D6 - */
1.158 -/* 7 LCD_D7 - */
1.159 -/* 8 LCD_D8 - */
1.160 -/* 9 LCD_D9 - */
1.161 -/* 10 LCD_D10 - */
1.162 -/* 11 LCD_D11 - */
1.163 -/* 12 LCD_D12 - */
1.164 -/* 13 LCD_D13 - */
1.165 -/* 14 LCD_D14 - */
1.166 -/* 15 LCD_D15 - */
1.167 -/* 16 LCD_D16 - */
1.168 -/* 17 LCD_D17 - */
1.169 -/* 18 LCD_PCLK - */
1.170 -/* 19 LCD_HSYNC - */
1.171 -/* 20 LCD_VSYNC - */
1.172 -/* 21 LCD_DE - */
1.173 -/* 22 LCD_PS A19 */
1.174 -/* 23 LCD_REV A20 */
1.175 -/* 24 WE1# - */
1.176 -/* 25 WE2# - */
1.177 -/* 26 WE3# - */
1.178 -/* 27 WAIT# - */
1.179 -/* 28 FRE# - */
1.180 -/* 29 FWE# - */
1.181 -/* 30(NOTE:FRB#) - - */
1.182 -/* 31 - - */
1.183 -/* NOTE(1): PIN30 is used for FRB# when connecting to NAND flash. */
1.184 -/*------------------------------------------------------ */
1.185 -/* PORT 3: */
1.186 -/* */
1.187 -/* PIN/BIT N FUNC0 FUNC1 */
1.188 -/* 0 CIM_D0 - */
1.189 -/* 1 CIM_D1 - */
1.190 -/* 2 CIM_D2 - */
1.191 -/* 3 CIM_D3 - */
1.192 -/* 4 CIM_D4 - */
1.193 -/* 5 CIM_D5 - */
1.194 -/* 6 CIM_D6 - */
1.195 -/* 7 CIM_D7 - */
1.196 -/* 8 MSC_CMD - */
1.197 -/* 9 MSC_CLK - */
1.198 -/* 10 MSC_D0 - */
1.199 -/* 11 MSC_D1 - */
1.200 -/* 12 MSC_D2 - */
1.201 -/* 13 MSC_D3 - */
1.202 -/* 14 CIM_MCLK - */
1.203 -/* 15 CIM_PCLK - */
1.204 -/* 16 CIM_VSYNC - */
1.205 -/* 17 CIM_HSYNC - */
1.206 -/* 18 SSI_CLK SCLK_RSTN */
1.207 -/* 19 SSI_CE0# BIT_CLK(AIC) */
1.208 -/* 20 SSI_DT SDATA_OUT(AIC) */
1.209 -/* 21 SSI_DR SDATA_IN(AIC) */
1.210 -/* 22 SSI_CE1#&GPC SYNC(AIC) */
1.211 -/* 23 PWM0 I2C_SDA */
1.212 -/* 24 PWM1 I2C_SCK */
1.213 -/* 25 PWM2 UART0_TxD */
1.214 -/* 26 PWM3 UART0_RxD */
1.215 -/* 27 PWM4 A17 */
1.216 -/* 28 PWM5 A18 */
1.217 -/* 29 - - */
1.218 -/* 30 PWM6 UART0_CTS/UART1_RxD */
1.219 -/* 31 PWM7 UART0_RTS/UART1_TxD */
1.220 -/*
1.221 - * p is the port number (0,1,2,3)
1.222 - * o is the pin offset (0-31) inside the port
1.223 - * n is the absolute number of a pin (0-127), regardless of the port
1.224 - */
1.225 -
1.226 -/* Function Pins Mode */
1.227 -
1.228 -#define __gpio_as_func0(n) \
1.229 -do { \
1.230 - unsigned int p, o; \
1.231 - p = (n) / 32; \
1.232 - o = (n) % 32; \
1.233 - REG_GPIO_PXFUNS(p) = (1 << o); \
1.234 - REG_GPIO_PXSELC(p) = (1 << o); \
1.235 -} while (0)
1.236 -
1.237 -#define __gpio_as_func1(n) \
1.238 -do { \
1.239 - unsigned int p, o; \
1.240 - p = (n) / 32; \
1.241 - o = (n) % 32; \
1.242 - REG_GPIO_PXFUNS(p) = (1 << o); \
1.243 - REG_GPIO_PXSELS(p) = (1 << o); \
1.244 -} while (0)
1.245 -
1.246 -/*
1.247 - * D0 ~ D31, A0 ~ A16, DCS#, RAS#, CAS#, CKE#,
1.248 - * RDWE#, CKO#, WE0#, WE1#, WE2#, WE3#
1.249 - */
1.250 -#define __gpio_as_sdram_32bit() \
1.251 -do { \
1.252 - REG_GPIO_PXFUNS(0) = 0xffffffff; \
1.253 - REG_GPIO_PXSELC(0) = 0xffffffff; \
1.254 - REG_GPIO_PXPES(0) = 0xffffffff; \
1.255 - REG_GPIO_PXFUNS(1) = 0x81f9ffff; \
1.256 - REG_GPIO_PXSELC(1) = 0x81f9ffff; \
1.257 - REG_GPIO_PXPES(1) = 0x81f9ffff; \
1.258 - REG_GPIO_PXFUNS(2) = 0x07000000; \
1.259 - REG_GPIO_PXSELC(2) = 0x07000000; \
1.260 - REG_GPIO_PXPES(2) = 0x07000000; \
1.261 -} while (0)
1.262 -
1.263 -/*
1.264 - * D0 ~ D15, A0 ~ A16, DCS#, RAS#, CAS#, CKE#,
1.265 - * RDWE#, CKO#, WE0#, WE1#
1.266 - */
1.267 -#define __gpio_as_sdram_16bit_4720() \
1.268 -do { \
1.269 - REG_GPIO_PXFUNS(0) = 0x5442bfaa; \
1.270 - REG_GPIO_PXSELC(0) = 0x5442bfaa; \
1.271 - REG_GPIO_PXPES(0) = 0x5442bfaa; \
1.272 - REG_GPIO_PXFUNS(1) = 0x81f9ffff; \
1.273 - REG_GPIO_PXSELC(1) = 0x81f9ffff; \
1.274 - REG_GPIO_PXPES(1) = 0x81f9ffff; \
1.275 - REG_GPIO_PXFUNS(2) = 0x01000000; \
1.276 - REG_GPIO_PXSELC(2) = 0x01000000; \
1.277 - REG_GPIO_PXPES(2) = 0x01000000; \
1.278 -} while (0)
1.279 -
1.280 -/*
1.281 - * D0 ~ D15, A0 ~ A16, DCS#, RAS#, CAS#, CKE#,
1.282 - * RDWE#, CKO#, WE0#, WE1#
1.283 - */
1.284 -#define __gpio_as_sdram_16bit_4725() \
1.285 -do { \
1.286 - REG_GPIO_PXFUNS(0) = 0x0000ffff; \
1.287 - REG_GPIO_PXSELC(0) = 0x0000ffff; \
1.288 - REG_GPIO_PXPES(0) = 0x0000ffff; \
1.289 - REG_GPIO_PXFUNS(1) = 0x81f9ffff; \
1.290 - REG_GPIO_PXSELC(1) = 0x81f9ffff; \
1.291 - REG_GPIO_PXPES(1) = 0x81f9ffff; \
1.292 - REG_GPIO_PXFUNS(2) = 0x01000000; \
1.293 - REG_GPIO_PXSELC(2) = 0x01000000; \
1.294 - REG_GPIO_PXPES(2) = 0x01000000; \
1.295 -} while (0)
1.296 -
1.297 -
1.298 -/*
1.299 - * CS1#, CLE, ALE, FRE#, FWE#, FRB#, RDWE#/BUFD#
1.300 - */
1.301 -#define __gpio_as_nand() \
1.302 -do { \
1.303 - REG_GPIO_PXFUNS(1) = 0x02018000; \
1.304 - REG_GPIO_PXSELC(1) = 0x02018000; \
1.305 - REG_GPIO_PXPES(1) = 0x02018000; \
1.306 - REG_GPIO_PXFUNS(2) = 0x30000000; \
1.307 - REG_GPIO_PXSELC(2) = 0x30000000; \
1.308 - REG_GPIO_PXPES(2) = 0x30000000; \
1.309 - REG_GPIO_PXFUNC(2) = 0x40000000; \
1.310 - REG_GPIO_PXSELC(2) = 0x40000000; \
1.311 - REG_GPIO_PXDIRC(2) = 0x40000000; \
1.312 - REG_GPIO_PXPES(2) = 0x40000000; \
1.313 - REG_GPIO_PXFUNS(1) = 0x00400000; \
1.314 - REG_GPIO_PXSELC(1) = 0x00400000; \
1.315 -} while (0)
1.316 -
1.317 -/*
1.318 - * CS4#, RD#, WR#, WAIT#, A0 ~ A22, D0 ~ D7
1.319 - */
1.320 -#define __gpio_as_nor_8bit() \
1.321 -do { \
1.322 - REG_GPIO_PXFUNS(0) = 0x000000ff; \
1.323 - REG_GPIO_PXSELC(0) = 0x000000ff; \
1.324 - REG_GPIO_PXPES(0) = 0x000000ff; \
1.325 - REG_GPIO_PXFUNS(1) = 0x7041ffff; \
1.326 - REG_GPIO_PXSELC(1) = 0x7041ffff; \
1.327 - REG_GPIO_PXPES(1) = 0x7041ffff; \
1.328 - REG_GPIO_PXFUNS(1) = 0x00060000; \
1.329 - REG_GPIO_PXSELS(1) = 0x00060000; \
1.330 - REG_GPIO_PXPES(1) = 0x00060000; \
1.331 - REG_GPIO_PXFUNS(2) = 0x08000000; \
1.332 - REG_GPIO_PXSELC(2) = 0x08000000; \
1.333 - REG_GPIO_PXPES(2) = 0x08000000; \
1.334 - REG_GPIO_PXFUNS(2) = 0x00c00000; \
1.335 - REG_GPIO_PXSELS(2) = 0x00c00000; \
1.336 - REG_GPIO_PXPES(2) = 0x00c00000; \
1.337 - REG_GPIO_PXFUNS(3) = 0x18000000; \
1.338 - REG_GPIO_PXSELS(3) = 0x18000000; \
1.339 - REG_GPIO_PXPES(3) = 0x18000000; \
1.340 -} while (0)
1.341 -
1.342 -/*
1.343 - * CS4#, RD#, WR#, WAIT#, A0 ~ A22, D0 ~ D15
1.344 - */
1.345 -#define __gpio_as_nor_16bit() \
1.346 -do { \
1.347 - REG_GPIO_PXFUNS(0) = 0x0000ffff; \
1.348 - REG_GPIO_PXSELC(0) = 0x0000ffff; \
1.349 - REG_GPIO_PXPES(0) = 0x0000ffff; \
1.350 - REG_GPIO_PXFUNS(1) = 0x7041ffff; \
1.351 - REG_GPIO_PXSELC(1) = 0x7041ffff; \
1.352 - REG_GPIO_PXPES(1) = 0x7041ffff; \
1.353 - REG_GPIO_PXFUNS(1) = 0x00060000; \
1.354 - REG_GPIO_PXSELS(1) = 0x00060000; \
1.355 - REG_GPIO_PXPES(1) = 0x00060000; \
1.356 - REG_GPIO_PXFUNS(2) = 0x08000000; \
1.357 - REG_GPIO_PXSELC(2) = 0x08000000; \
1.358 - REG_GPIO_PXPES(2) = 0x08000000; \
1.359 - REG_GPIO_PXFUNS(2) = 0x00c00000; \
1.360 - REG_GPIO_PXSELS(2) = 0x00c00000; \
1.361 - REG_GPIO_PXPES(2) = 0x00c00000; \
1.362 - REG_GPIO_PXFUNS(3) = 0x18000000; \
1.363 - REG_GPIO_PXSELS(3) = 0x18000000; \
1.364 - REG_GPIO_PXPES(3) = 0x18000000; \
1.365 -} while (0)
1.366 -
1.367 -/*
1.368 - * UART0_TxD, UART_RxD0
1.369 - */
1.370 -#define __gpio_as_uart0() \
1.371 -do { \
1.372 - REG_GPIO_PXFUNS(3) = 0x06000000; \
1.373 - REG_GPIO_PXSELS(3) = 0x06000000; \
1.374 - REG_GPIO_PXPES(3) = 0x06000000; \
1.375 -} while (0)
1.376 -
1.377 -#define __gpio_jtag_to_uart0() \
1.378 -do { \
1.379 - REG_GPIO_PXSELS(2) = 0x80000000; \
1.380 -} while (0)
1.381 -
1.382 -/*
1.383 - * UART0_CTS, UART0_RTS
1.384 - */
1.385 -#define __gpio_as_ctsrts() \
1.386 -do { \
1.387 - REG_GPIO_PXFUNS(3) = 0xc0000000; \
1.388 - REG_GPIO_PXSELS(3) = 0xc0000000; \
1.389 - REG_GPIO_PXTRGC(3) = 0xc0000000; \
1.390 - REG_GPIO_PXPES(3) = 0xc0000000; \
1.391 -} while (0)
1.392 -
1.393 -/*
1.394 - * UART1_TxD, UART1_RxD1
1.395 - */
1.396 -#define __gpio_as_uart1() \
1.397 -do { \
1.398 - REG_GPIO_PXFUNS(3) = 0xc0000000; \
1.399 - REG_GPIO_PXSELC(3) = 0xc0000000; \
1.400 - REG_GPIO_PXTRGS(3) = 0xc0000000; \
1.401 - REG_GPIO_PXPES(3) = 0xc0000000; \
1.402 -} while (0)
1.403 -
1.404 -/*
1.405 - * LCD_D0~LCD_D15, LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE
1.406 - */
1.407 -#define __gpio_as_lcd_16bit() \
1.408 -do { \
1.409 - REG_GPIO_PXFUNS(2) = 0x003cffff; \
1.410 - REG_GPIO_PXSELC(2) = 0x003cffff; \
1.411 - REG_GPIO_PXPES(2) = 0x003cffff; \
1.412 -} while (0)
1.413 -
1.414 -/*
1.415 - * LCD_D0~LCD_D17, LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE
1.416 - */
1.417 -#define __gpio_as_lcd_18bit() \
1.418 -do { \
1.419 - REG_GPIO_PXFUNS(2) = 0x003fffff; \
1.420 - REG_GPIO_PXSELC(2) = 0x003fffff; \
1.421 - REG_GPIO_PXPES(2) = 0x003fffff; \
1.422 -} while (0)
1.423 -
1.424 -
1.425 -/* LCD_D0~LCD_D7, SLCD_CLK, SLCD_RS, SLCD_CS, LCD_DE */
1.426 -#define __gpio_as_slcd_8bit() \
1.427 -do { \
1.428 - REG_GPIO_PXFUNS(2) = 0x003c00ff; \
1.429 - REG_GPIO_PXSELC(2) = 0x003c00ff; \
1.430 -} while (0)
1.431 -
1.432 -/* LCD_D0~LCD_D7, SLCD_RS, SLCD_CS */
1.433 -#define __gpio_as_slcd_9bit() \
1.434 -do { \
1.435 - REG_GPIO_PXFUNS(2) = 0x001801ff; \
1.436 - REG_GPIO_PXSELC(2) = 0x001801ff; \
1.437 -} while (0)
1.438 -
1.439 -/* LCD_D0~LCD_D15, SLCD_RS, SLCD_CS */
1.440 -#define __gpio_as_slcd_16bit() \
1.441 -do { \
1.442 - REG_GPIO_PXFUNS(2) = 0x0018ffff; \
1.443 - REG_GPIO_PXSELC(2) = 0x0018ffff; \
1.444 -} while (0)
1.445 -
1.446 -/* LCD_D0~LCD_D17, SLCD_RS, SLCD_CS */
1.447 -#define __gpio_as_slcd_18bit() \
1.448 -do { \
1.449 - REG_GPIO_PXFUNS(2) = 0x001bffff; \
1.450 - REG_GPIO_PXSELC(2) = 0x001bffff; \
1.451 -} while (0)
1.452 -/*
1.453 - * CIM_D0~CIM_D7, CIM_MCLK, CIM_PCLK, CIM_VSYNC, CIM_HSYNC
1.454 - */
1.455 -#define __gpio_as_cim() \
1.456 -do { \
1.457 - REG_GPIO_PXFUNS(3) = 0x0003c0ff; \
1.458 - REG_GPIO_PXSELC(3) = 0x0003c0ff; \
1.459 - REG_GPIO_PXPES(3) = 0x0003c0ff; \
1.460 -} while (0)
1.461 -
1.462 -/*
1.463 - * SDATA_OUT, SDATA_IN, BIT_CLK, SYNC, SCLK_RESET
1.464 - */
1.465 -#define __gpio_as_aic() \
1.466 -do { \
1.467 - REG_GPIO_PXFUNS(3) = 0x007c0000; \
1.468 - REG_GPIO_PXSELS(3) = 0x007c0000; \
1.469 - REG_GPIO_PXPES(3) = 0x007c0000; \
1.470 -} while (0)
1.471 -
1.472 -/*
1.473 - * MSC_CMD, MSC_CLK, MSC_D0 ~ MSC_D3
1.474 - */
1.475 -#define __gpio_as_msc() \
1.476 -do { \
1.477 - REG_GPIO_PXFUNS(3) = 0x00003f00; \
1.478 - REG_GPIO_PXSELC(3) = 0x00003f00; \
1.479 - REG_GPIO_PXPES(3) = 0x00003f00; \
1.480 -} while (0)
1.481 -
1.482 -/*
1.483 - * SSI_CS0, SSI_CLK, SSI_DT, SSI_DR
1.484 - */
1.485 -#define __gpio_as_ssi() \
1.486 -do { \
1.487 - REG_GPIO_PXFUNS(3) = 0x003c0000; \
1.488 - REG_GPIO_PXSELC(3) = 0x003c0000; \
1.489 - REG_GPIO_PXPES(3) = 0x003c0000; \
1.490 -} while (0)
1.491 -
1.492 -/*
1.493 - * I2C_SCK, I2C_SDA
1.494 - */
1.495 -#define __gpio_as_i2c() \
1.496 -do { \
1.497 - REG_GPIO_PXFUNS(3) = 0x01800000; \
1.498 - REG_GPIO_PXSELS(3) = 0x01800000; \
1.499 - REG_GPIO_PXPES(3) = 0x01800000; \
1.500 -} while (0)
1.501 -
1.502 -/*
1.503 - * PWM0
1.504 - */
1.505 -#define __gpio_as_pwm0() \
1.506 -do { \
1.507 - REG_GPIO_PXFUNS(3) = 0x00800000; \
1.508 - REG_GPIO_PXSELC(3) = 0x00800000; \
1.509 - REG_GPIO_PXPES(3) = 0x00800000; \
1.510 -} while (0)
1.511 -
1.512 -/*
1.513 - * PWM1
1.514 - */
1.515 -#define __gpio_as_pwm1() \
1.516 -do { \
1.517 - REG_GPIO_PXFUNS(3) = 0x01000000; \
1.518 - REG_GPIO_PXSELC(3) = 0x01000000; \
1.519 - REG_GPIO_PXPES(3) = 0x01000000; \
1.520 -} while (0)
1.521 -
1.522 -/*
1.523 - * PWM2
1.524 - */
1.525 -#define __gpio_as_pwm2() \
1.526 -do { \
1.527 - REG_GPIO_PXFUNS(3) = 0x02000000; \
1.528 - REG_GPIO_PXSELC(3) = 0x02000000; \
1.529 - REG_GPIO_PXPES(3) = 0x02000000; \
1.530 -} while (0)
1.531 -
1.532 -/*
1.533 - * PWM3
1.534 - */
1.535 -#define __gpio_as_pwm3() \
1.536 -do { \
1.537 - REG_GPIO_PXFUNS(3) = 0x04000000; \
1.538 - REG_GPIO_PXSELC(3) = 0x04000000; \
1.539 - REG_GPIO_PXPES(3) = 0x04000000; \
1.540 -} while (0)
1.541 -
1.542 -/*
1.543 - * PWM4
1.544 - */
1.545 -#define __gpio_as_pwm4() \
1.546 -do { \
1.547 - REG_GPIO_PXFUNS(3) = 0x08000000; \
1.548 - REG_GPIO_PXSELC(3) = 0x08000000; \
1.549 - REG_GPIO_PXPES(3) = 0x08000000; \
1.550 -} while (0)
1.551 -
1.552 -/*
1.553 - * PWM5
1.554 - */
1.555 -#define __gpio_as_pwm5() \
1.556 -do { \
1.557 - REG_GPIO_PXFUNS(3) = 0x10000000; \
1.558 - REG_GPIO_PXSELC(3) = 0x10000000; \
1.559 - REG_GPIO_PXPES(3) = 0x10000000; \
1.560 -} while (0)
1.561 -
1.562 -/*
1.563 - * PWM6
1.564 - */
1.565 -#define __gpio_as_pwm6() \
1.566 -do { \
1.567 - REG_GPIO_PXFUNS(3) = 0x40000000; \
1.568 - REG_GPIO_PXSELC(3) = 0x40000000; \
1.569 - REG_GPIO_PXPES(3) = 0x40000000; \
1.570 -} while (0)
1.571 -
1.572 -/*
1.573 - * PWM7
1.574 - */
1.575 -#define __gpio_as_pwm7() \
1.576 -do { \
1.577 - REG_GPIO_PXFUNS(3) = 0x80000000; \
1.578 - REG_GPIO_PXSELC(3) = 0x80000000; \
1.579 - REG_GPIO_PXPES(3) = 0x80000000; \
1.580 -} while (0)
1.581 -
1.582 -/*
1.583 - * n = 0 ~ 7
1.584 - */
1.585 -#define __gpio_as_pwm(n) __gpio_as_pwm##n()
1.586 -
1.587 -/* GPIO or Interrupt Mode */
1.588 -
1.589 -#define __gpio_get_port(p) (REG_GPIO_PXPIN(p))
1.590 -
1.591 -#define __gpio_port_as_output(p, o) \
1.592 -do { \
1.593 - REG_GPIO_PXFUNC(p) = (1 << (o)); \
1.594 - REG_GPIO_PXSELC(p) = (1 << (o)); \
1.595 - REG_GPIO_PXDIRS(p) = (1 << (o)); \
1.596 -} while (0)
1.597 -
1.598 -#define __gpio_port_as_input(p, o) \
1.599 -do { \
1.600 - REG_GPIO_PXFUNC(p) = (1 << (o)); \
1.601 - REG_GPIO_PXSELC(p) = (1 << (o)); \
1.602 - REG_GPIO_PXDIRC(p) = (1 << (o)); \
1.603 -} while (0)
1.604 -
1.605 -#define __gpio_as_output(n) \
1.606 -do { \
1.607 - unsigned int p, o; \
1.608 - p = (n) / 32; \
1.609 - o = (n) % 32; \
1.610 - __gpio_port_as_output(p, o); \
1.611 -} while (0)
1.612 -
1.613 -#define __gpio_as_input(n) \
1.614 -do { \
1.615 - unsigned int p, o; \
1.616 - p = (n) / 32; \
1.617 - o = (n) % 32; \
1.618 - __gpio_port_as_input(p, o); \
1.619 -} while (0)
1.620 -
1.621 -#define __gpio_set_pin(n) \
1.622 -do { \
1.623 - unsigned int p, o; \
1.624 - p = (n) / 32; \
1.625 - o = (n) % 32; \
1.626 - REG_GPIO_PXDATS(p) = (1 << o); \
1.627 -} while (0)
1.628 -
1.629 -#define __gpio_clear_pin(n) \
1.630 -do { \
1.631 - unsigned int p, o; \
1.632 - p = (n) / 32; \
1.633 - o = (n) % 32; \
1.634 - REG_GPIO_PXDATC(p) = (1 << o); \
1.635 -} while (0)
1.636 -
1.637 -#define __gpio_get_pin(n) \
1.638 -({ \
1.639 - unsigned int p, o, v; \
1.640 - p = (n) / 32; \
1.641 - o = (n) % 32; \
1.642 - if (__gpio_get_port(p) & (1 << o)) \
1.643 - v = 1; \
1.644 - else \
1.645 - v = 0; \
1.646 - v; \
1.647 -})
1.648 -
1.649 -#define __gpio_as_irq_high_level(n) \
1.650 -do { \
1.651 - unsigned int p, o; \
1.652 - p = (n) / 32; \
1.653 - o = (n) % 32; \
1.654 - REG_GPIO_PXIMS(p) = (1 << o); \
1.655 - REG_GPIO_PXTRGC(p) = (1 << o); \
1.656 - REG_GPIO_PXFUNC(p) = (1 << o); \
1.657 - REG_GPIO_PXSELS(p) = (1 << o); \
1.658 - REG_GPIO_PXDIRS(p) = (1 << o); \
1.659 - REG_GPIO_PXFLGC(p) = (1 << o); \
1.660 - REG_GPIO_PXIMC(p) = (1 << o); \
1.661 -} while (0)
1.662 -
1.663 -#define __gpio_as_irq_low_level(n) \
1.664 -do { \
1.665 - unsigned int p, o; \
1.666 - p = (n) / 32; \
1.667 - o = (n) % 32; \
1.668 - REG_GPIO_PXIMS(p) = (1 << o); \
1.669 - REG_GPIO_PXTRGC(p) = (1 << o); \
1.670 - REG_GPIO_PXFUNC(p) = (1 << o); \
1.671 - REG_GPIO_PXSELS(p) = (1 << o); \
1.672 - REG_GPIO_PXDIRC(p) = (1 << o); \
1.673 - REG_GPIO_PXFLGC(p) = (1 << o); \
1.674 - REG_GPIO_PXIMC(p) = (1 << o); \
1.675 -} while (0)
1.676 -
1.677 -#define __gpio_as_irq_rise_edge(n) \
1.678 -do { \
1.679 - unsigned int p, o; \
1.680 - p = (n) / 32; \
1.681 - o = (n) % 32; \
1.682 - REG_GPIO_PXIMS(p) = (1 << o); \
1.683 - REG_GPIO_PXTRGS(p) = (1 << o); \
1.684 - REG_GPIO_PXFUNC(p) = (1 << o); \
1.685 - REG_GPIO_PXSELS(p) = (1 << o); \
1.686 - REG_GPIO_PXDIRS(p) = (1 << o); \
1.687 - REG_GPIO_PXFLGC(p) = (1 << o); \
1.688 - REG_GPIO_PXIMC(p) = (1 << o); \
1.689 -} while (0)
1.690 -
1.691 -#define __gpio_as_irq_fall_edge(n) \
1.692 -do { \
1.693 - unsigned int p, o; \
1.694 - p = (n) / 32; \
1.695 - o = (n) % 32; \
1.696 - REG_GPIO_PXIMS(p) = (1 << o); \
1.697 - REG_GPIO_PXTRGS(p) = (1 << o); \
1.698 - REG_GPIO_PXFUNC(p) = (1 << o); \
1.699 - REG_GPIO_PXSELS(p) = (1 << o); \
1.700 - REG_GPIO_PXDIRC(p) = (1 << o); \
1.701 - REG_GPIO_PXFLGC(p) = (1 << o); \
1.702 - REG_GPIO_PXIMC(p) = (1 << o); \
1.703 -} while (0)
1.704 -
1.705 -#define __gpio_mask_irq(n) \
1.706 -do { \
1.707 - unsigned int p, o; \
1.708 - p = (n) / 32; \
1.709 - o = (n) % 32; \
1.710 - REG_GPIO_PXIMS(p) = (1 << o); \
1.711 -} while (0)
1.712 -
1.713 -#define __gpio_unmask_irq(n) \
1.714 -do { \
1.715 - unsigned int p, o; \
1.716 - p = (n) / 32; \
1.717 - o = (n) % 32; \
1.718 - REG_GPIO_PXIMC(p) = (1 << o); \
1.719 -} while (0)
1.720 -
1.721 -#define __gpio_ack_irq(n) \
1.722 -do { \
1.723 - unsigned int p, o; \
1.724 - p = (n) / 32; \
1.725 - o = (n) % 32; \
1.726 - REG_GPIO_PXFLGC(p) = (1 << o); \
1.727 -} while (0)
1.728 -
1.729 -#define __gpio_get_irq() \
1.730 -({ \
1.731 - unsigned int p, i, tmp, v = 0; \
1.732 - for (p = 3; p >= 0; p--) { \
1.733 - tmp = REG_GPIO_PXFLG(p); \
1.734 - for (i = 0; i < 32; i++) \
1.735 - if (tmp & (1 << i)) \
1.736 - v = (32*p + i); \
1.737 - } \
1.738 - v; \
1.739 -})
1.740 -
1.741 -#define __gpio_group_irq(n) \
1.742 -({ \
1.743 - register int tmp, i; \
1.744 - tmp = REG_GPIO_PXFLG((n)); \
1.745 - for (i=31;i>=0;i--) \
1.746 - if (tmp & (1 << i)) \
1.747 - break; \
1.748 - i; \
1.749 -})
1.750 -
1.751 -#define __gpio_enable_pull(n) \
1.752 -do { \
1.753 - unsigned int p, o; \
1.754 - p = (n) / 32; \
1.755 - o = (n) % 32; \
1.756 - REG_GPIO_PXPEC(p) = (1 << o); \
1.757 -} while (0)
1.758 -
1.759 -#define __gpio_disable_pull(n) \
1.760 -do { \
1.761 - unsigned int p, o; \
1.762 - p = (n) / 32; \
1.763 - o = (n) % 32; \
1.764 - REG_GPIO_PXPES(p) = (1 << o); \
1.765 -} while (0)
1.766 -
1.767 +/* Register operations using absolute positioning have been removed. */
1.768
1.769 /***************************************************************************
1.770 * CPM