NanoPayload

include/jz4740.h

19:d53c943a7f5d
2015-06-08 Paul Boddie Removed superfluous and confusing alternative definitions.
     1 /*     2  * Include file for Ingenic Semiconductor's JZ4740 CPU.     3  *     4  * Copyright 2009 (C) Qi Hardware Inc.,     5  * Author: Xiangfu Liu <xiangfu@sharism.cc>     6  *     7  * This program is free software; you can redistribute it and/or     8  * modify it under the terms of the GNU General Public License     9  * version 3 as published by the Free Software Foundation.    10  *    11  * This program is distributed in the hope that it will be useful,    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    14  * GNU General Public License for more details.    15  *    16  * You should have received a copy of the GNU General Public License    17  * along with this program; if not, write to the Free Software    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor,    19  * Boston, MA  02110-1301, USA    20  */    21 #ifndef __JZ4740_H__    22 #define __JZ4740_H__    23     24 #include "xburst_types.h"    25     26 /* Boot ROM Specification  */    27 /* NOR Boot config */    28 #define JZ4740_NORBOOT_8BIT	0x00000000	/* 8-bit data bus flash */    29 #define JZ4740_NORBOOT_16BIT	0x10101010	/* 16-bit data bus flash */    30 #define JZ4740_NORBOOT_32BIT	0x20202020	/* 32-bit data bus flash */    31     32 /* NAND Boot config */    33 #define JZ4740_NANDBOOT_B8R3	0xffffffff	/* 8-bit bus & 3 row cycles */    34 #define JZ4740_NANDBOOT_B8R2	0xf0f0f0f0	/* 8-bit bus & 2 row cycles */    35 #define JZ4740_NANDBOOT_B16R3	0x0f0f0f0f	/* 16-bit bus & 3 row cycles */    36 #define JZ4740_NANDBOOT_B16R2	0x00000000	/* 16-bit bus & 2 row cycles */    37     38     39 /* Register Definitions */    40 #define	CPM_BASE	0xB0000000    41 #define	INTC_BASE	0xB0001000    42 #define	TCU_BASE	0xB0002000    43 #define	WDT_BASE	0xB0002000    44 #define	RTC_BASE	0xB0003000    45 #define	GPIO_BASE	0xB0010000    46 #define	AIC_BASE	0xB0020000    47 #define	ICDC_BASE	0xB0020000    48 #define	MSC_BASE	0xB0021000    49 #define	UART0_BASE	0xB0030000    50 #define	I2C_BASE	0xB0042000    51 #define	SSI_BASE	0xB0043000    52 #define	SADC_BASE	0xB0070000    53 #define	EMC_BASE	0xB3010000    54 #define	DMAC_BASE	0xB3020000    55 #define	UHC_BASE	0xB3030000    56 #define	UDC_BASE	0xB3040000    57 #define	LCD_BASE	0xB3050000    58 #define	SLCD_BASE	0xB3050000    59 #define	CIM_BASE	0xB3060000    60 #define	ETH_BASE	0xB3100000    61     62     63 /*    64  * INTC (Interrupt Controller)    65  */    66 #define INTC_ISR	(INTC_BASE + 0x00)    67 #define INTC_IMR	(INTC_BASE + 0x04)    68 #define INTC_IMSR	(INTC_BASE + 0x08)    69 #define INTC_IMCR	(INTC_BASE + 0x0c)    70 #define INTC_IPR	(INTC_BASE + 0x10)    71     72 #define REG_INTC_ISR	REG32(INTC_ISR)    73 #define REG_INTC_IMR	REG32(INTC_IMR)    74 #define REG_INTC_IMSR	REG32(INTC_IMSR)    75 #define REG_INTC_IMCR	REG32(INTC_IMCR)    76 #define REG_INTC_IPR	REG32(INTC_IPR)    77     78 /* 1st-level interrupts */    79 #define IRQ_I2C		1    80 #define IRQ_UHC		3    81 #define IRQ_UART0	9    82 #define IRQ_SADC	12    83 #define IRQ_MSC		14    84 #define IRQ_RTC		15    85 #define IRQ_SSI		16    86 #define IRQ_CIM		17    87 #define IRQ_AIC		18    88 #define IRQ_ETH		19    89 #define IRQ_DMAC	20    90 #define IRQ_TCU2	21    91 #define IRQ_TCU1	22    92 #define IRQ_TCU0	23    93 #define IRQ_UDC 	24    94 #define IRQ_GPIO3	25    95 #define IRQ_GPIO2	26    96 #define IRQ_GPIO1	27    97 #define IRQ_GPIO0	28    98 #define IRQ_IPU		29    99 #define IRQ_LCD		30   100    101 /* 2nd-level interrupts */   102 #define IRQ_DMA_0	32  /* 32 to 37 for DMAC channel 0 to 5 */   103 #define IRQ_GPIO_0	48  /* 48 to 175 for GPIO pin 0 to 127 */   104    105    106 /*   107  * RTC   108  */   109 #define RTC_RCR		(RTC_BASE + 0x00) /* RTC Control Register */   110 #define RTC_RSR		(RTC_BASE + 0x04) /* RTC Second Register */   111 #define RTC_RSAR	(RTC_BASE + 0x08) /* RTC Second Alarm Register */   112 #define RTC_RGR		(RTC_BASE + 0x0c) /* RTC Regulator Register */   113    114 #define RTC_HCR		(RTC_BASE + 0x20) /* Hibernate Control Register */   115 #define RTC_HWFCR	(RTC_BASE + 0x24) /* Hibernate Wakeup Filter Counter Reg */   116 #define RTC_HRCR	(RTC_BASE + 0x28) /* Hibernate Reset Counter Register */   117 #define RTC_HWCR	(RTC_BASE + 0x2c) /* Hibernate Wakeup Control Register */   118 #define RTC_HWRSR	(RTC_BASE + 0x30) /* Hibernate Wakeup Status Register */   119 #define RTC_HSPR	(RTC_BASE + 0x34) /* Hibernate Scratch Pattern Register */   120    121 #define REG_RTC_RCR	REG32(RTC_RCR)   122 #define REG_RTC_RSR	REG32(RTC_RSR)   123 #define REG_RTC_RSAR	REG32(RTC_RSAR)   124 #define REG_RTC_RGR	REG32(RTC_RGR)   125 #define REG_RTC_HCR	REG32(RTC_HCR)   126 #define REG_RTC_HWFCR	REG32(RTC_HWFCR)   127 #define REG_RTC_HRCR	REG32(RTC_HRCR)   128 #define REG_RTC_HWCR	REG32(RTC_HWCR)   129 #define REG_RTC_HWRSR	REG32(RTC_HWRSR)   130 #define REG_RTC_HSPR	REG32(RTC_HSPR)   131    132 /* RTC Control Register */   133 #define RTC_RCR_WRDY	(1 << 7)  /* Write Ready Flag */   134 #define RTC_RCR_HZ	(1 << 6)  /* 1Hz Flag */   135 #define RTC_RCR_HZIE	(1 << 5)  /* 1Hz Interrupt Enable */   136 #define RTC_RCR_AF	(1 << 4)  /* Alarm Flag */   137 #define RTC_RCR_AIE	(1 << 3)  /* Alarm Interrupt Enable */   138 #define RTC_RCR_AE	(1 << 2)  /* Alarm Enable */   139 #define RTC_RCR_RTCE	(1 << 0)  /* RTC Enable */   140    141 /* RTC Regulator Register */   142 #define RTC_RGR_LOCK		(1 << 31) /* Lock Bit */   143 #define RTC_RGR_ADJC_BIT	16   144 #define RTC_RGR_ADJC_MASK	(0x3ff << RTC_RGR_ADJC_BIT)   145 #define RTC_RGR_NC1HZ_BIT	0   146 #define RTC_RGR_NC1HZ_MASK	(0xffff << RTC_RGR_NC1HZ_BIT)   147    148 /* Hibernate Control Register */   149 #define RTC_HCR_PD		(1 << 0)  /* Power Down */   150    151 /* Hibernate Wakeup Filter Counter Register */   152 #define RTC_HWFCR_BIT		5   153 #define RTC_HWFCR_MASK		(0x7ff << RTC_HWFCR_BIT)   154    155 /* Hibernate Reset Counter Register */   156 #define RTC_HRCR_BIT		5   157 #define RTC_HRCR_MASK		(0x7f << RTC_HRCR_BIT)   158    159 /* Hibernate Wakeup Control Register */   160 #define RTC_HWCR_EALM		(1 << 0)  /* RTC alarm wakeup enable */   161    162 /* Hibernate Wakeup Status Register */   163 #define RTC_HWRSR_HR		(1 << 5)  /* Hibernate reset */   164 #define RTC_HWRSR_PPR		(1 << 4)  /* PPR reset */   165 #define RTC_HWRSR_PIN		(1 << 1)  /* Wakeup pin status bit */   166 #define RTC_HWRSR_ALM		(1 << 0)  /* RTC alarm status bit */   167    168 /*************************************************************************   169  * CPM (Clock reset and Power control Management)   170  *************************************************************************/   171 #define CPM_CPCCR	(CPM_BASE+0x00)   172 #define CPM_CPPCR	(CPM_BASE+0x10)   173 #define CPM_I2SCDR	(CPM_BASE+0x60)   174 #define CPM_LPCDR	(CPM_BASE+0x64)   175 #define CPM_MSCCDR	(CPM_BASE+0x68)   176 #define CPM_UHCCDR	(CPM_BASE+0x6C)   177    178 #define CPM_LCR		(CPM_BASE+0x04)   179 #define CPM_CLKGR	(CPM_BASE+0x20)   180 #define CPM_SCR		(CPM_BASE+0x24)   181    182 #define CPM_HCR		(CPM_BASE+0x30)   183 #define CPM_HWFCR	(CPM_BASE+0x34)   184 #define CPM_HRCR	(CPM_BASE+0x38)   185 #define CPM_HWCR	(CPM_BASE+0x3c)   186 #define CPM_HWSR	(CPM_BASE+0x40)   187 #define CPM_HSPR	(CPM_BASE+0x44)   188    189 #define CPM_RSR		(CPM_BASE+0x08)   190    191    192 #define REG_CPM_CPCCR	REG32(CPM_CPCCR)   193 #define REG_CPM_CPPCR	REG32(CPM_CPPCR)   194 #define REG_CPM_I2SCDR	REG32(CPM_I2SCDR)   195 #define REG_CPM_LPCDR	REG32(CPM_LPCDR)   196 #define REG_CPM_MSCCDR	REG32(CPM_MSCCDR)   197 #define REG_CPM_UHCCDR	REG32(CPM_UHCCDR)   198    199 #define REG_CPM_LCR	REG32(CPM_LCR)   200 #define REG_CPM_CLKGR	REG32(CPM_CLKGR)   201 #define REG_CPM_SCR	REG32(CPM_SCR)   202 #define REG_CPM_HCR	REG32(CPM_HCR)   203 #define REG_CPM_HWFCR	REG32(CPM_HWFCR)   204 #define REG_CPM_HRCR	REG32(CPM_HRCR)   205 #define REG_CPM_HWCR	REG32(CPM_HWCR)   206 #define REG_CPM_HWSR	REG32(CPM_HWSR)   207 #define REG_CPM_HSPR	REG32(CPM_HSPR)   208    209 #define REG_CPM_RSR	REG32(CPM_RSR)   210    211    212 /* Clock Control Register */   213 #define CPM_CPCCR_I2CS		(1 << 31)   214 #define CPM_CPCCR_CLKOEN	(1 << 30)   215 #define CPM_CPCCR_UCS		(1 << 29)   216 #define CPM_CPCCR_UDIV_BIT	23   217 #define CPM_CPCCR_UDIV_MASK	(0x3f << CPM_CPCCR_UDIV_BIT)   218 #define CPM_CPCCR_CE		(1 << 22)   219 #define CPM_CPCCR_PCS		(1 << 21)   220 #define CPM_CPCCR_LDIV_BIT	16   221 #define CPM_CPCCR_LDIV_MASK	(0x1f << CPM_CPCCR_LDIV_BIT)   222 #define CPM_CPCCR_MDIV_BIT	12   223 #define CPM_CPCCR_MDIV_MASK	(0x0f << CPM_CPCCR_MDIV_BIT)   224 #define CPM_CPCCR_PDIV_BIT	8   225 #define CPM_CPCCR_PDIV_MASK	(0x0f << CPM_CPCCR_PDIV_BIT)   226 #define CPM_CPCCR_HDIV_BIT	4   227 #define CPM_CPCCR_HDIV_MASK	(0x0f << CPM_CPCCR_HDIV_BIT)   228 #define CPM_CPCCR_CDIV_BIT	0   229 #define CPM_CPCCR_CDIV_MASK	(0x0f << CPM_CPCCR_CDIV_BIT)   230    231 /* I2S Clock Divider Register */   232 #define CPM_I2SCDR_I2SDIV_BIT	0   233 #define CPM_I2SCDR_I2SDIV_MASK	(0x1ff << CPM_I2SCDR_I2SDIV_BIT)   234    235 /* LCD Pixel Clock Divider Register */   236 #define CPM_LPCDR_PIXDIV_BIT	0   237 #define CPM_LPCDR_PIXDIV_MASK	(0x1ff << CPM_LPCDR_PIXDIV_BIT)   238    239 /* MSC Clock Divider Register */   240 #define CPM_MSCCDR_MSCDIV_BIT	0   241 #define CPM_MSCCDR_MSCDIV_MASK	(0x1f << CPM_MSCCDR_MSCDIV_BIT)   242    243 /* PLL Control Register */   244 #define CPM_CPPCR_PLLM_BIT	23   245 #define CPM_CPPCR_PLLM_MASK	(0x1ff << CPM_CPPCR_PLLM_BIT)   246 #define CPM_CPPCR_PLLN_BIT	18   247 #define CPM_CPPCR_PLLN_MASK	(0x1f << CPM_CPPCR_PLLN_BIT)   248 #define CPM_CPPCR_PLLOD_BIT	16   249 #define CPM_CPPCR_PLLOD_MASK	(0x03 << CPM_CPPCR_PLLOD_BIT)   250 #define CPM_CPPCR_PLLS		(1 << 10)   251 #define CPM_CPPCR_PLLBP		(1 << 9)   252 #define CPM_CPPCR_PLLEN		(1 << 8)   253 #define CPM_CPPCR_PLLST_BIT	0   254 #define CPM_CPPCR_PLLST_MASK	(0xff << CPM_CPPCR_PLLST_BIT)   255    256 /* Low Power Control Register */   257 #define CPM_LCR_DOZE_DUTY_BIT 	3   258 #define CPM_LCR_DOZE_DUTY_MASK 	(0x1f << CPM_LCR_DOZE_DUTY_BIT)   259 #define CPM_LCR_DOZE_ON		(1 << 2)   260 #define CPM_LCR_LPM_BIT		0   261 #define CPM_LCR_LPM_MASK	(0x3 << CPM_LCR_LPM_BIT)   262   #define CPM_LCR_LPM_IDLE	(0x0 << CPM_LCR_LPM_BIT)   263   #define CPM_LCR_LPM_SLEEP	(0x1 << CPM_LCR_LPM_BIT)   264    265 /* Clock Gate Register */   266 #define CPM_CLKGR_UART1		(1 << 15)   267 #define CPM_CLKGR_UHC		(1 << 14)   268 #define CPM_CLKGR_IPU		(1 << 13)   269 #define CPM_CLKGR_DMAC		(1 << 12)   270 #define CPM_CLKGR_UDC		(1 << 11)   271 #define CPM_CLKGR_LCD		(1 << 10)   272 #define CPM_CLKGR_CIM		(1 << 9)   273 #define CPM_CLKGR_SADC		(1 << 8)   274 #define CPM_CLKGR_MSC		(1 << 7)   275 #define CPM_CLKGR_AIC1		(1 << 6)   276 #define CPM_CLKGR_AIC2		(1 << 5)   277 #define CPM_CLKGR_SSI		(1 << 4)   278 #define CPM_CLKGR_I2C		(1 << 3)   279 #define CPM_CLKGR_RTC		(1 << 2)   280 #define CPM_CLKGR_TCU		(1 << 1)   281 #define CPM_CLKGR_UART0		(1 << 0)   282    283 /* Sleep Control Register */   284 #define CPM_SCR_O1ST_BIT	8   285 #define CPM_SCR_O1ST_MASK	(0xff << CPM_SCR_O1ST_BIT)   286 #define CPM_SCR_UDCPHY_ENABLE	(1 << 6)   287 #define CPM_SCR_USBPHY_DISABLE	(1 << 7)   288 #define CPM_SCR_OSC_ENABLE	(1 << 4)   289    290 /* Hibernate Control Register */   291 #define CPM_HCR_PD		(1 << 0)   292    293 /* Wakeup Filter Counter Register in Hibernate Mode */   294 #define CPM_HWFCR_TIME_BIT	0   295 #define CPM_HWFCR_TIME_MASK	(0x3ff << CPM_HWFCR_TIME_BIT)   296    297 /* Reset Counter Register in Hibernate Mode */   298 #define CPM_HRCR_TIME_BIT	0   299 #define CPM_HRCR_TIME_MASK	(0x7f << CPM_HRCR_TIME_BIT)   300    301 /* Wakeup Control Register in Hibernate Mode */   302 #define CPM_HWCR_WLE_LOW	(0 << 2)   303 #define CPM_HWCR_WLE_HIGH	(1 << 2)   304 #define CPM_HWCR_PIN_WAKEUP	(1 << 1)   305 #define CPM_HWCR_RTC_WAKEUP	(1 << 0)   306    307 /* Wakeup Status Register in Hibernate Mode */   308 #define CPM_HWSR_WSR_PIN	(1 << 1)   309 #define CPM_HWSR_WSR_RTC	(1 << 0)   310    311 /* Reset Status Register */   312 #define CPM_RSR_HR		(1 << 2)   313 #define CPM_RSR_WR		(1 << 1)   314 #define CPM_RSR_PR		(1 << 0)   315    316    317 /*************************************************************************   318  * TCU (Timer Counter Unit)   319  *************************************************************************/   320 #define TCU_TSR		(TCU_BASE + 0x1C) /* Timer Stop Register */   321 #define TCU_TSSR	(TCU_BASE + 0x2C) /* Timer Stop Set Register */   322 #define TCU_TSCR	(TCU_BASE + 0x3C) /* Timer Stop Clear Register */   323 #define TCU_TER		(TCU_BASE + 0x10) /* Timer Counter Enable Register */   324 #define TCU_TESR	(TCU_BASE + 0x14) /* Timer Counter Enable Set Register */   325 #define TCU_TECR	(TCU_BASE + 0x18) /* Timer Counter Enable Clear Register */   326 #define TCU_TFR		(TCU_BASE + 0x20) /* Timer Flag Register */   327 #define TCU_TFSR	(TCU_BASE + 0x24) /* Timer Flag Set Register */   328 #define TCU_TFCR	(TCU_BASE + 0x28) /* Timer Flag Clear Register */   329 #define TCU_TMR		(TCU_BASE + 0x30) /* Timer Mask Register */   330 #define TCU_TMSR	(TCU_BASE + 0x34) /* Timer Mask Set Register */   331 #define TCU_TMCR	(TCU_BASE + 0x38) /* Timer Mask Clear Register */   332 #define TCU_TDFR0	(TCU_BASE + 0x40) /* Timer Data Full Register */   333 #define TCU_TDHR0	(TCU_BASE + 0x44) /* Timer Data Half Register */   334 #define TCU_TCNT0	(TCU_BASE + 0x48) /* Timer Counter Register */   335 #define TCU_TCSR0	(TCU_BASE + 0x4C) /* Timer Control Register */   336 #define TCU_TDFR1	(TCU_BASE + 0x50)   337 #define TCU_TDHR1	(TCU_BASE + 0x54)   338 #define TCU_TCNT1	(TCU_BASE + 0x58)   339 #define TCU_TCSR1	(TCU_BASE + 0x5C)   340 #define TCU_TDFR2	(TCU_BASE + 0x60)   341 #define TCU_TDHR2	(TCU_BASE + 0x64)   342 #define TCU_TCNT2	(TCU_BASE + 0x68)   343 #define TCU_TCSR2	(TCU_BASE + 0x6C)   344 #define TCU_TDFR3	(TCU_BASE + 0x70)   345 #define TCU_TDHR3	(TCU_BASE + 0x74)   346 #define TCU_TCNT3	(TCU_BASE + 0x78)   347 #define TCU_TCSR3	(TCU_BASE + 0x7C)   348 #define TCU_TDFR4	(TCU_BASE + 0x80)   349 #define TCU_TDHR4	(TCU_BASE + 0x84)   350 #define TCU_TCNT4	(TCU_BASE + 0x88)   351 #define TCU_TCSR4	(TCU_BASE + 0x8C)   352 #define TCU_TDFR5	(TCU_BASE + 0x90)   353 #define TCU_TDHR5	(TCU_BASE + 0x94)   354 #define TCU_TCNT5	(TCU_BASE + 0x98)   355 #define TCU_TCSR5	(TCU_BASE + 0x9C)   356    357 #define REG_TCU_TSR	REG32(TCU_TSR)   358 #define REG_TCU_TSSR	REG32(TCU_TSSR)   359 #define REG_TCU_TSCR	REG32(TCU_TSCR)   360 #define REG_TCU_TER	REG8(TCU_TER)   361 #define REG_TCU_TESR	REG8(TCU_TESR)   362 #define REG_TCU_TECR	REG8(TCU_TECR)   363 #define REG_TCU_TFR	REG32(TCU_TFR)   364 #define REG_TCU_TFSR	REG32(TCU_TFSR)   365 #define REG_TCU_TFCR	REG32(TCU_TFCR)   366 #define REG_TCU_TMR	REG32(TCU_TMR)   367 #define REG_TCU_TMSR	REG32(TCU_TMSR)   368 #define REG_TCU_TMCR	REG32(TCU_TMCR)   369 #define REG_TCU_TDFR0	REG16(TCU_TDFR0)   370 #define REG_TCU_TDHR0	REG16(TCU_TDHR0)   371 #define REG_TCU_TCNT0	REG16(TCU_TCNT0)   372 #define REG_TCU_TCSR0	REG16(TCU_TCSR0)   373 #define REG_TCU_TDFR1	REG16(TCU_TDFR1)   374 #define REG_TCU_TDHR1	REG16(TCU_TDHR1)   375 #define REG_TCU_TCNT1	REG16(TCU_TCNT1)   376 #define REG_TCU_TCSR1	REG16(TCU_TCSR1)   377 #define REG_TCU_TDFR2	REG16(TCU_TDFR2)   378 #define REG_TCU_TDHR2	REG16(TCU_TDHR2)   379 #define REG_TCU_TCNT2	REG16(TCU_TCNT2)   380 #define REG_TCU_TCSR2	REG16(TCU_TCSR2)   381 #define REG_TCU_TDFR3	REG16(TCU_TDFR3)   382 #define REG_TCU_TDHR3	REG16(TCU_TDHR3)   383 #define REG_TCU_TCNT3	REG16(TCU_TCNT3)   384 #define REG_TCU_TCSR3	REG16(TCU_TCSR3)   385 #define REG_TCU_TDFR4	REG16(TCU_TDFR4)   386 #define REG_TCU_TDHR4	REG16(TCU_TDHR4)   387 #define REG_TCU_TCNT4	REG16(TCU_TCNT4)   388 #define REG_TCU_TCSR4	REG16(TCU_TCSR4)   389    390 /* n = 0,1,2,3,4,5 */   391 #define TCU_TDFR(n)	(TCU_BASE + (0x40 + (n)*0x10)) /* Timer Data Full Reg */   392 #define TCU_TDHR(n)	(TCU_BASE + (0x44 + (n)*0x10)) /* Timer Data Half Reg */   393 #define TCU_TCNT(n)	(TCU_BASE + (0x48 + (n)*0x10)) /* Timer Counter Reg */   394 #define TCU_TCSR(n)	(TCU_BASE + (0x4C + (n)*0x10)) /* Timer Control Reg */   395    396 #define REG_TCU_TDFR(n)	REG16(TCU_TDFR((n)))   397 #define REG_TCU_TDHR(n)	REG16(TCU_TDHR((n)))   398 #define REG_TCU_TCNT(n)	REG16(TCU_TCNT((n)))   399 #define REG_TCU_TCSR(n)	REG16(TCU_TCSR((n)))   400    401 /* Register definitions */   402 #define TCU_TCSR_PWM_SD		(1 << 9)   403 #define TCU_TCSR_PWM_INITL_HIGH	(1 << 8)   404 #define TCU_TCSR_PWM_EN		(1 << 7)   405 #define TCU_TCSR_PRESCALE_BIT	3   406 #define TCU_TCSR_PRESCALE_MASK	(0x7 << TCU_TCSR_PRESCALE_BIT)   407 #define TCU_TCSR_PRESCALE1	(0x0 << TCU_TCSR_PRESCALE_BIT)   408 #define TCU_TCSR_PRESCALE4	(0x1 << TCU_TCSR_PRESCALE_BIT)   409 #define TCU_TCSR_PRESCALE16	(0x2 << TCU_TCSR_PRESCALE_BIT)   410 #define TCU_TCSR_PRESCALE64	(0x3 << TCU_TCSR_PRESCALE_BIT)   411 #define TCU_TCSR_PRESCALE256	(0x4 << TCU_TCSR_PRESCALE_BIT)   412 #define TCU_TCSR_PRESCALE1024	(0x5 << TCU_TCSR_PRESCALE_BIT)   413 #define TCU_TCSR_EXT_EN		(1 << 2)   414 #define TCU_TCSR_RTC_EN		(1 << 1)   415 #define TCU_TCSR_PCK_EN		(1 << 0)   416    417 #define TCU_TER_TCEN5		(1 << 5)   418 #define TCU_TER_TCEN4		(1 << 4)   419 #define TCU_TER_TCEN3		(1 << 3)   420 #define TCU_TER_TCEN2		(1 << 2)   421 #define TCU_TER_TCEN1		(1 << 1)   422 #define TCU_TER_TCEN0		(1 << 0)   423    424 #define TCU_TESR_TCST5		(1 << 5)   425 #define TCU_TESR_TCST4		(1 << 4)   426 #define TCU_TESR_TCST3		(1 << 3)   427 #define TCU_TESR_TCST2		(1 << 2)   428 #define TCU_TESR_TCST1		(1 << 1)   429 #define TCU_TESR_TCST0		(1 << 0)   430    431 #define TCU_TECR_TCCL5		(1 << 5)   432 #define TCU_TECR_TCCL4		(1 << 4)   433 #define TCU_TECR_TCCL3		(1 << 3)   434 #define TCU_TECR_TCCL2		(1 << 2)   435 #define TCU_TECR_TCCL1		(1 << 1)   436 #define TCU_TECR_TCCL0		(1 << 0)   437    438 #define TCU_TFR_HFLAG5		(1 << 21)   439 #define TCU_TFR_HFLAG4		(1 << 20)   440 #define TCU_TFR_HFLAG3		(1 << 19)   441 #define TCU_TFR_HFLAG2		(1 << 18)   442 #define TCU_TFR_HFLAG1		(1 << 17)   443 #define TCU_TFR_HFLAG0		(1 << 16)   444 #define TCU_TFR_FFLAG5		(1 << 5)   445 #define TCU_TFR_FFLAG4		(1 << 4)   446 #define TCU_TFR_FFLAG3		(1 << 3)   447 #define TCU_TFR_FFLAG2		(1 << 2)   448 #define TCU_TFR_FFLAG1		(1 << 1)   449 #define TCU_TFR_FFLAG0		(1 << 0)   450    451 #define TCU_TFSR_HFLAG5		(1 << 21)   452 #define TCU_TFSR_HFLAG4		(1 << 20)   453 #define TCU_TFSR_HFLAG3		(1 << 19)   454 #define TCU_TFSR_HFLAG2		(1 << 18)   455 #define TCU_TFSR_HFLAG1		(1 << 17)   456 #define TCU_TFSR_HFLAG0		(1 << 16)   457 #define TCU_TFSR_FFLAG5		(1 << 5)   458 #define TCU_TFSR_FFLAG4		(1 << 4)   459 #define TCU_TFSR_FFLAG3		(1 << 3)   460 #define TCU_TFSR_FFLAG2		(1 << 2)   461 #define TCU_TFSR_FFLAG1		(1 << 1)   462 #define TCU_TFSR_FFLAG0		(1 << 0)   463    464 #define TCU_TFCR_HFLAG5		(1 << 21)   465 #define TCU_TFCR_HFLAG4		(1 << 20)   466 #define TCU_TFCR_HFLAG3		(1 << 19)   467 #define TCU_TFCR_HFLAG2		(1 << 18)   468 #define TCU_TFCR_HFLAG1		(1 << 17)   469 #define TCU_TFCR_HFLAG0		(1 << 16)   470 #define TCU_TFCR_FFLAG5		(1 << 5)   471 #define TCU_TFCR_FFLAG4		(1 << 4)   472 #define TCU_TFCR_FFLAG3		(1 << 3)   473 #define TCU_TFCR_FFLAG2		(1 << 2)   474 #define TCU_TFCR_FFLAG1		(1 << 1)   475 #define TCU_TFCR_FFLAG0		(1 << 0)   476    477 #define TCU_TMR_HMASK5		(1 << 21)   478 #define TCU_TMR_HMASK4		(1 << 20)   479 #define TCU_TMR_HMASK3		(1 << 19)   480 #define TCU_TMR_HMASK2		(1 << 18)   481 #define TCU_TMR_HMASK1		(1 << 17)   482 #define TCU_TMR_HMASK0		(1 << 16)   483 #define TCU_TMR_FMASK5		(1 << 5)   484 #define TCU_TMR_FMASK4		(1 << 4)   485 #define TCU_TMR_FMASK3		(1 << 3)   486 #define TCU_TMR_FMASK2		(1 << 2)   487 #define TCU_TMR_FMASK1		(1 << 1)   488 #define TCU_TMR_FMASK0		(1 << 0)   489    490 #define TCU_TMSR_HMST5		(1 << 21)   491 #define TCU_TMSR_HMST4		(1 << 20)   492 #define TCU_TMSR_HMST3		(1 << 19)   493 #define TCU_TMSR_HMST2		(1 << 18)   494 #define TCU_TMSR_HMST1		(1 << 17)   495 #define TCU_TMSR_HMST0		(1 << 16)   496 #define TCU_TMSR_FMST5		(1 << 5)   497 #define TCU_TMSR_FMST4		(1 << 4)   498 #define TCU_TMSR_FMST3		(1 << 3)   499 #define TCU_TMSR_FMST2		(1 << 2)   500 #define TCU_TMSR_FMST1		(1 << 1)   501 #define TCU_TMSR_FMST0		(1 << 0)   502    503 #define TCU_TMCR_HMCL5		(1 << 21)   504 #define TCU_TMCR_HMCL4		(1 << 20)   505 #define TCU_TMCR_HMCL3		(1 << 19)   506 #define TCU_TMCR_HMCL2		(1 << 18)   507 #define TCU_TMCR_HMCL1		(1 << 17)   508 #define TCU_TMCR_HMCL0		(1 << 16)   509 #define TCU_TMCR_FMCL5		(1 << 5)   510 #define TCU_TMCR_FMCL4		(1 << 4)   511 #define TCU_TMCR_FMCL3		(1 << 3)   512 #define TCU_TMCR_FMCL2		(1 << 2)   513 #define TCU_TMCR_FMCL1		(1 << 1)   514 #define TCU_TMCR_FMCL0		(1 << 0)   515    516 #define TCU_TSR_WDTS		(1 << 16)   517 #define TCU_TSR_STOP5		(1 << 5)   518 #define TCU_TSR_STOP4		(1 << 4)   519 #define TCU_TSR_STOP3		(1 << 3)   520 #define TCU_TSR_STOP2		(1 << 2)   521 #define TCU_TSR_STOP1		(1 << 1)   522 #define TCU_TSR_STOP0		(1 << 0)   523    524 #define TCU_TSSR_WDTSS		(1 << 16)   525 #define TCU_TSSR_STPS5		(1 << 5)   526 #define TCU_TSSR_STPS4		(1 << 4)   527 #define TCU_TSSR_STPS3		(1 << 3)   528 #define TCU_TSSR_STPS2		(1 << 2)   529 #define TCU_TSSR_STPS1		(1 << 1)   530 #define TCU_TSSR_STPS0		(1 << 0)   531    532 #define TCU_TSSR_WDTSC		(1 << 16)   533 #define TCU_TSSR_STPC5		(1 << 5)   534 #define TCU_TSSR_STPC4		(1 << 4)   535 #define TCU_TSSR_STPC3		(1 << 3)   536 #define TCU_TSSR_STPC2		(1 << 2)   537 #define TCU_TSSR_STPC1		(1 << 1)   538 #define TCU_TSSR_STPC0		(1 << 0)   539    540    541 /*   542  * WDT (WatchDog Timer)   543  */   544 #define WDT_TDR		(WDT_BASE + 0x00)   545 #define WDT_TCER	(WDT_BASE + 0x04)   546 #define WDT_TCNT	(WDT_BASE + 0x08)   547 #define WDT_TCSR	(WDT_BASE + 0x0C)   548    549 #define REG_WDT_TDR	REG16(WDT_TDR)   550 #define REG_WDT_TCER	REG8(WDT_TCER)   551 #define REG_WDT_TCNT	REG16(WDT_TCNT)   552 #define REG_WDT_TCSR	REG16(WDT_TCSR)   553    554 /* Register definition */   555 #define WDT_TCSR_PRESCALE_BIT	3   556 #define WDT_TCSR_PRESCALE_MASK	(0x7 << WDT_TCSR_PRESCALE_BIT)   557   #define WDT_TCSR_PRESCALE1	(0x0 << WDT_TCSR_PRESCALE_BIT)   558   #define WDT_TCSR_PRESCALE4	(0x1 << WDT_TCSR_PRESCALE_BIT)   559   #define WDT_TCSR_PRESCALE16	(0x2 << WDT_TCSR_PRESCALE_BIT)   560   #define WDT_TCSR_PRESCALE64	(0x3 << WDT_TCSR_PRESCALE_BIT)   561   #define WDT_TCSR_PRESCALE256	(0x4 << WDT_TCSR_PRESCALE_BIT)   562   #define WDT_TCSR_PRESCALE1024	(0x5 << WDT_TCSR_PRESCALE_BIT)   563 #define WDT_TCSR_EXT_EN		(1 << 2)   564 #define WDT_TCSR_RTC_EN		(1 << 1)   565 #define WDT_TCSR_PCK_EN		(1 << 0)   566    567 #define WDT_TCER_TCEN		(1 << 0)   568    569    570 /*   571  * DMAC (DMA Controller)   572  */   573    574 #define MAX_DMA_NUM	6  /* max 6 channels */   575    576 #define DMAC_DSAR(n)	(DMAC_BASE + (0x00 + (n) * 0x20)) /* DMA source address */   577 #define DMAC_DTAR(n)	(DMAC_BASE + (0x04 + (n) * 0x20)) /* DMA target address */   578 #define DMAC_DTCR(n)	(DMAC_BASE + (0x08 + (n) * 0x20)) /* DMA transfer count */   579 #define DMAC_DRSR(n)	(DMAC_BASE + (0x0c + (n) * 0x20)) /* DMA request source */   580 #define DMAC_DCCSR(n)	(DMAC_BASE + (0x10 + (n) * 0x20)) /* DMA control/status */   581 #define DMAC_DCMD(n)	(DMAC_BASE + (0x14 + (n) * 0x20)) /* DMA command */   582 #define DMAC_DDA(n)	(DMAC_BASE + (0x18 + (n) * 0x20)) /* DMA descriptor address */   583 #define DMAC_DMACR	(DMAC_BASE + 0x0300)              /* DMA control register */   584 #define DMAC_DMAIPR	(DMAC_BASE + 0x0304)              /* DMA interrupt pending */   585 #define DMAC_DMADBR	(DMAC_BASE + 0x0308)              /* DMA doorbell */   586 #define DMAC_DMADBSR	(DMAC_BASE + 0x030C)              /* DMA doorbell set */   587    588 /* channel 0 */   589 #define DMAC_DSAR0      DMAC_DSAR(0)   590 #define DMAC_DTAR0      DMAC_DTAR(0)   591 #define DMAC_DTCR0      DMAC_DTCR(0)   592 #define DMAC_DRSR0      DMAC_DRSR(0)   593 #define DMAC_DCCSR0     DMAC_DCCSR(0)   594 #define DMAC_DCMD0	DMAC_DCMD(0)   595 #define DMAC_DDA0	DMAC_DDA(0)   596    597 /* channel 1 */   598 #define DMAC_DSAR1      DMAC_DSAR(1)   599 #define DMAC_DTAR1      DMAC_DTAR(1)   600 #define DMAC_DTCR1      DMAC_DTCR(1)   601 #define DMAC_DRSR1      DMAC_DRSR(1)   602 #define DMAC_DCCSR1     DMAC_DCCSR(1)   603 #define DMAC_DCMD1	DMAC_DCMD(1)   604 #define DMAC_DDA1	DMAC_DDA(1)   605    606 /* channel 2 */   607 #define DMAC_DSAR2      DMAC_DSAR(2)   608 #define DMAC_DTAR2      DMAC_DTAR(2)   609 #define DMAC_DTCR2      DMAC_DTCR(2)   610 #define DMAC_DRSR2      DMAC_DRSR(2)   611 #define DMAC_DCCSR2     DMAC_DCCSR(2)   612 #define DMAC_DCMD2	DMAC_DCMD(2)   613 #define DMAC_DDA2	DMAC_DDA(2)   614    615 /* channel 3 */   616 #define DMAC_DSAR3      DMAC_DSAR(3)   617 #define DMAC_DTAR3      DMAC_DTAR(3)   618 #define DMAC_DTCR3      DMAC_DTCR(3)   619 #define DMAC_DRSR3      DMAC_DRSR(3)   620 #define DMAC_DCCSR3     DMAC_DCCSR(3)   621 #define DMAC_DCMD3	DMAC_DCMD(3)   622 #define DMAC_DDA3	DMAC_DDA(3)   623    624 /* channel 4 */   625 #define DMAC_DSAR4      DMAC_DSAR(4)   626 #define DMAC_DTAR4      DMAC_DTAR(4)   627 #define DMAC_DTCR4      DMAC_DTCR(4)   628 #define DMAC_DRSR4      DMAC_DRSR(4)   629 #define DMAC_DCCSR4     DMAC_DCCSR(4)   630 #define DMAC_DCMD4	DMAC_DCMD(4)   631 #define DMAC_DDA4	DMAC_DDA(4)   632    633 /* channel 5 */   634 #define DMAC_DSAR5      DMAC_DSAR(5)   635 #define DMAC_DTAR5      DMAC_DTAR(5)   636 #define DMAC_DTCR5      DMAC_DTCR(5)   637 #define DMAC_DRSR5      DMAC_DRSR(5)   638 #define DMAC_DCCSR5     DMAC_DCCSR(5)   639 #define DMAC_DCMD5	DMAC_DCMD(5)   640 #define DMAC_DDA5	DMAC_DDA(5)   641    642 #define REG_DMAC_DSAR(n)	REG32(DMAC_DSAR((n)))   643 #define REG_DMAC_DTAR(n)	REG32(DMAC_DTAR((n)))   644 #define REG_DMAC_DTCR(n)	REG32(DMAC_DTCR((n)))   645 #define REG_DMAC_DRSR(n)	REG32(DMAC_DRSR((n)))   646 #define REG_DMAC_DCCSR(n)	REG32(DMAC_DCCSR((n)))   647 #define REG_DMAC_DCMD(n)	REG32(DMAC_DCMD((n)))   648 #define REG_DMAC_DDA(n)		REG32(DMAC_DDA((n)))   649 #define REG_DMAC_DMACR		REG32(DMAC_DMACR)   650 #define REG_DMAC_DMAIPR		REG32(DMAC_DMAIPR)   651 #define REG_DMAC_DMADBR		REG32(DMAC_DMADBR)   652 #define REG_DMAC_DMADBSR	REG32(DMAC_DMADBSR)   653    654 /* DMA request source register */   655 #define DMAC_DRSR_RS_BIT	0   656 #define DMAC_DRSR_RS_MASK	(0x1f << DMAC_DRSR_RS_BIT)   657 #define DMAC_DRSR_RS_AUTO	(8 << DMAC_DRSR_RS_BIT)   658 #define DMAC_DRSR_RS_UART0OUT	(20 << DMAC_DRSR_RS_BIT)   659 #define DMAC_DRSR_RS_UART0IN	(21 << DMAC_DRSR_RS_BIT)   660 #define DMAC_DRSR_RS_SSIOUT	(22 << DMAC_DRSR_RS_BIT)   661 #define DMAC_DRSR_RS_SSIIN	(23 << DMAC_DRSR_RS_BIT)   662 #define DMAC_DRSR_RS_AICOUT	(24 << DMAC_DRSR_RS_BIT)   663 #define DMAC_DRSR_RS_AICIN	(25 << DMAC_DRSR_RS_BIT)   664 #define DMAC_DRSR_RS_MSCOUT	(26 << DMAC_DRSR_RS_BIT)   665 #define DMAC_DRSR_RS_MSCIN	(27 << DMAC_DRSR_RS_BIT)   666 #define DMAC_DRSR_RS_TCU	(28 << DMAC_DRSR_RS_BIT)   667 #define DMAC_DRSR_RS_SADC	(29 << DMAC_DRSR_RS_BIT)   668 #define DMAC_DRSR_RS_SLCD	(30 << DMAC_DRSR_RS_BIT)   669    670 /* DMA channel control/status register */   671 #define DMAC_DCCSR_NDES		(1 << 31) /* descriptor (0) or not (1) ? */   672 #define DMAC_DCCSR_CDOA_BIT	16        /* copy of DMA offset address */   673 #define DMAC_DCCSR_CDOA_MASK	(0xff << DMAC_DCCSR_CDOA_BIT)   674 #define DMAC_DCCSR_INV		(1 << 6)  /* descriptor invalid */   675 #define DMAC_DCCSR_AR		(1 << 4)  /* address error */   676 #define DMAC_DCCSR_TT		(1 << 3)  /* transfer terminated */   677 #define DMAC_DCCSR_HLT		(1 << 2)  /* DMA halted */   678 #define DMAC_DCCSR_CT		(1 << 1)  /* count terminated */   679 #define DMAC_DCCSR_EN		(1 << 0)  /* channel enable bit */   680    681 /* DMA channel command register  */   682 #define DMAC_DCMD_SAI		(1 << 23) /* source address increment */   683 #define DMAC_DCMD_DAI		(1 << 22) /* dest address increment */   684 #define DMAC_DCMD_RDIL_BIT	16        /* request detection interval length */   685 #define DMAC_DCMD_RDIL_MASK	(0x0f << DMAC_DCMD_RDIL_BIT)   686   #define DMAC_DCMD_RDIL_IGN	(0 << DMAC_DCMD_RDIL_BIT)   687   #define DMAC_DCMD_RDIL_2	(1 << DMAC_DCMD_RDIL_BIT)   688   #define DMAC_DCMD_RDIL_4	(2 << DMAC_DCMD_RDIL_BIT)   689   #define DMAC_DCMD_RDIL_8	(3 << DMAC_DCMD_RDIL_BIT)   690   #define DMAC_DCMD_RDIL_12	(4 << DMAC_DCMD_RDIL_BIT)   691   #define DMAC_DCMD_RDIL_16	(5 << DMAC_DCMD_RDIL_BIT)   692   #define DMAC_DCMD_RDIL_20	(6 << DMAC_DCMD_RDIL_BIT)   693   #define DMAC_DCMD_RDIL_24	(7 << DMAC_DCMD_RDIL_BIT)   694   #define DMAC_DCMD_RDIL_28	(8 << DMAC_DCMD_RDIL_BIT)   695   #define DMAC_DCMD_RDIL_32	(9 << DMAC_DCMD_RDIL_BIT)   696   #define DMAC_DCMD_RDIL_48	(10 << DMAC_DCMD_RDIL_BIT)   697   #define DMAC_DCMD_RDIL_60	(11 << DMAC_DCMD_RDIL_BIT)   698   #define DMAC_DCMD_RDIL_64	(12 << DMAC_DCMD_RDIL_BIT)   699   #define DMAC_DCMD_RDIL_124	(13 << DMAC_DCMD_RDIL_BIT)   700   #define DMAC_DCMD_RDIL_128	(14 << DMAC_DCMD_RDIL_BIT)   701   #define DMAC_DCMD_RDIL_200	(15 << DMAC_DCMD_RDIL_BIT)   702 #define DMAC_DCMD_SWDH_BIT	14  /* source port width */   703 #define DMAC_DCMD_SWDH_MASK	(0x03 << DMAC_DCMD_SWDH_BIT)   704   #define DMAC_DCMD_SWDH_32	(0 << DMAC_DCMD_SWDH_BIT)   705   #define DMAC_DCMD_SWDH_8	(1 << DMAC_DCMD_SWDH_BIT)   706   #define DMAC_DCMD_SWDH_16	(2 << DMAC_DCMD_SWDH_BIT)   707 #define DMAC_DCMD_DWDH_BIT	12  /* dest port width */   708 #define DMAC_DCMD_DWDH_MASK	(0x03 << DMAC_DCMD_DWDH_BIT)   709   #define DMAC_DCMD_DWDH_32	(0 << DMAC_DCMD_DWDH_BIT)   710   #define DMAC_DCMD_DWDH_8	(1 << DMAC_DCMD_DWDH_BIT)   711   #define DMAC_DCMD_DWDH_16	(2 << DMAC_DCMD_DWDH_BIT)   712 #define DMAC_DCMD_DS_BIT	8  /* transfer data size of a data unit */   713 #define DMAC_DCMD_DS_MASK	(0x07 << DMAC_DCMD_DS_BIT)   714   #define DMAC_DCMD_DS_32BIT	(0 << DMAC_DCMD_DS_BIT)   715   #define DMAC_DCMD_DS_8BIT	(1 << DMAC_DCMD_DS_BIT)   716   #define DMAC_DCMD_DS_16BIT	(2 << DMAC_DCMD_DS_BIT)   717   #define DMAC_DCMD_DS_16BYTE	(3 << DMAC_DCMD_DS_BIT)   718   #define DMAC_DCMD_DS_32BYTE	(4 << DMAC_DCMD_DS_BIT)   719 #define DMAC_DCMD_TM		(1 << 7)  /* transfer mode: 0-single 1-block */   720 #define DMAC_DCMD_DES_V		(1 << 4)  /* descriptor valid flag */   721 #define DMAC_DCMD_DES_VM	(1 << 3)  /* descriptor valid mask: 1:support V-bit */   722 #define DMAC_DCMD_DES_VIE	(1 << 2)  /* DMA valid error interrupt enable */   723 #define DMAC_DCMD_TIE		(1 << 1)  /* DMA transfer interrupt enable */   724 #define DMAC_DCMD_LINK		(1 << 0)  /* descriptor link enable */   725    726 /* DMA descriptor address register */   727 #define DMAC_DDA_BASE_BIT	12  /* descriptor base address */   728 #define DMAC_DDA_BASE_MASK	(0x0fffff << DMAC_DDA_BASE_BIT)   729 #define DMAC_DDA_OFFSET_BIT	4  /* descriptor offset address */   730 #define DMAC_DDA_OFFSET_MASK	(0x0ff << DMAC_DDA_OFFSET_BIT)   731    732 /* DMA control register */   733 #define DMAC_DMACR_PR_BIT	8  /* channel priority mode */   734 #define DMAC_DMACR_PR_MASK	(0x03 << DMAC_DMACR_PR_BIT)   735   #define DMAC_DMACR_PR_012345	(0 << DMAC_DMACR_PR_BIT)   736   #define DMAC_DMACR_PR_023145	(1 << DMAC_DMACR_PR_BIT)   737   #define DMAC_DMACR_PR_201345	(2 << DMAC_DMACR_PR_BIT)   738   #define DMAC_DMACR_PR_RR	(3 << DMAC_DMACR_PR_BIT) /* round robin */   739 #define DMAC_DMACR_HLT		(1 << 3)  /* DMA halt flag */   740 #define DMAC_DMACR_AR		(1 << 2)  /* address error flag */   741 #define DMAC_DMACR_DMAE		(1 << 0)  /* DMA enable bit */   742    743 /* DMA doorbell register */   744 #define DMAC_DMADBR_DB5		(1 << 5)  /* doorbell for channel 5 */   745 #define DMAC_DMADBR_DB4		(1 << 5)  /* doorbell for channel 4 */   746 #define DMAC_DMADBR_DB3		(1 << 5)  /* doorbell for channel 3 */   747 #define DMAC_DMADBR_DB2		(1 << 5)  /* doorbell for channel 2 */   748 #define DMAC_DMADBR_DB1		(1 << 5)  /* doorbell for channel 1 */   749 #define DMAC_DMADBR_DB0		(1 << 5)  /* doorbell for channel 0 */   750    751 /* DMA doorbell set register */   752 #define DMAC_DMADBSR_DBS5	(1 << 5)  /* enable doorbell for channel 5 */   753 #define DMAC_DMADBSR_DBS4	(1 << 5)  /* enable doorbell for channel 4 */   754 #define DMAC_DMADBSR_DBS3	(1 << 5)  /* enable doorbell for channel 3 */   755 #define DMAC_DMADBSR_DBS2	(1 << 5)  /* enable doorbell for channel 2 */   756 #define DMAC_DMADBSR_DBS1	(1 << 5)  /* enable doorbell for channel 1 */   757 #define DMAC_DMADBSR_DBS0	(1 << 5)  /* enable doorbell for channel 0 */   758    759 /* DMA interrupt pending register */   760 #define DMAC_DMAIPR_CIRQ5	(1 << 5)  /* irq pending status for channel 5 */   761 #define DMAC_DMAIPR_CIRQ4	(1 << 4)  /* irq pending status for channel 4 */   762 #define DMAC_DMAIPR_CIRQ3	(1 << 3)  /* irq pending status for channel 3 */   763 #define DMAC_DMAIPR_CIRQ2	(1 << 2)  /* irq pending status for channel 2 */   764 #define DMAC_DMAIPR_CIRQ1	(1 << 1)  /* irq pending status for channel 1 */   765 #define DMAC_DMAIPR_CIRQ0	(1 << 0)  /* irq pending status for channel 0 */   766    767    768 /*************************************************************************   769  * GPIO (General-Purpose I/O Ports)   770  *************************************************************************/   771 #define MAX_GPIO_NUM	128   772    773 /*  = 0,1,2,3 */   774 #define GPIO_PXPIN(n)	(GPIO_BASE + (0x00 + (n)*0x100)) /* PIN Level Register */   775 #define GPIO_PXDAT(n)	(GPIO_BASE + (0x10 + (n)*0x100)) /* Port Data Register */   776 #define GPIO_PXDATS(n)	(GPIO_BASE + (0x14 + (n)*0x100)) /* Port Data Set Register */   777 #define GPIO_PXDATC(n)	(GPIO_BASE + (0x18 + (n)*0x100)) /* Port Data Clear Register */   778 #define GPIO_PXIM(n)	(GPIO_BASE + (0x20 + (n)*0x100)) /* Interrupt Mask Register */   779 #define GPIO_PXIMS(n)	(GPIO_BASE + (0x24 + (n)*0x100)) /* Interrupt Mask Set Reg */   780 #define GPIO_PXIMC(n)	(GPIO_BASE + (0x28 + (n)*0x100)) /* Interrupt Mask Clear Reg */   781 #define GPIO_PXPE(n)	(GPIO_BASE + (0x30 + (n)*0x100)) /* Pull Enable Register */   782 #define GPIO_PXPES(n)	(GPIO_BASE + (0x34 + (n)*0x100)) /* Pull Enable Set Reg. */   783 #define GPIO_PXPEC(n)	(GPIO_BASE + (0x38 + (n)*0x100)) /* Pull Enable Clear Reg. */   784 #define GPIO_PXFUN(n)	(GPIO_BASE + (0x40 + (n)*0x100)) /* Function Register */   785 #define GPIO_PXFUNS(n)	(GPIO_BASE + (0x44 + (n)*0x100)) /* Function Set Register */   786 #define GPIO_PXFUNC(n)	(GPIO_BASE + (0x48 + (n)*0x100)) /* Function Clear Register */   787 #define GPIO_PXSEL(n)	(GPIO_BASE + (0x50 + (n)*0x100)) /* Select Register */   788 #define GPIO_PXSELS(n)	(GPIO_BASE + (0x54 + (n)*0x100)) /* Select Set Register */   789 #define GPIO_PXSELC(n)	(GPIO_BASE + (0x58 + (n)*0x100)) /* Select Clear Register */   790 #define GPIO_PXDIR(n)	(GPIO_BASE + (0x60 + (n)*0x100)) /* Direction Register */   791 #define GPIO_PXDIRS(n)	(GPIO_BASE + (0x64 + (n)*0x100)) /* Direction Set Register */   792 #define GPIO_PXDIRC(n)	(GPIO_BASE + (0x68 + (n)*0x100)) /* Direction Clear Register */   793 #define GPIO_PXTRG(n)	(GPIO_BASE + (0x70 + (n)*0x100)) /* Trigger Register */   794 #define GPIO_PXTRGS(n)	(GPIO_BASE + (0x74 + (n)*0x100)) /* Trigger Set Register */   795 #define GPIO_PXTRGC(n)	(GPIO_BASE + (0x78 + (n)*0x100)) /* Trigger Set Register */   796 #define GPIO_PXFLG(n)	(GPIO_BASE + (0x80 + (n)*0x100)) /* Port Flag Register */   797 #define GPIO_PXFLGC(n)	(GPIO_BASE + (0x14 + (n)*0x100)) /* Port Flag clear Register */   798    799 #define REG_GPIO_PXPIN(n)	REG32(GPIO_PXPIN((n)))  /* PIN level */   800 #define REG_GPIO_PXDAT(n)	REG32(GPIO_PXDAT((n)))  /* 1: interrupt pending */   801 #define REG_GPIO_PXDATS(n)	REG32(GPIO_PXDATS((n)))   802 #define REG_GPIO_PXDATC(n)	REG32(GPIO_PXDATC((n)))   803 #define REG_GPIO_PXIM(n)	REG32(GPIO_PXIM((n)))   /* 1: mask pin interrupt */   804 #define REG_GPIO_PXIMS(n)	REG32(GPIO_PXIMS((n)))   805 #define REG_GPIO_PXIMC(n)	REG32(GPIO_PXIMC((n)))   806 #define REG_GPIO_PXPE(n)	REG32(GPIO_PXPE((n)))   /* 1: disable pull up/down */   807 #define REG_GPIO_PXPES(n)	REG32(GPIO_PXPES((n)))   808 #define REG_GPIO_PXPEC(n)	REG32(GPIO_PXPEC((n)))   809 #define REG_GPIO_PXFUN(n)	REG32(GPIO_PXFUN((n)))  /* 0:GPIO or intr, 1:FUNC */   810 #define REG_GPIO_PXFUNS(n)	REG32(GPIO_PXFUNS((n)))   811 #define REG_GPIO_PXFUNC(n)	REG32(GPIO_PXFUNC((n)))   812 #define REG_GPIO_PXSEL(n)	REG32(GPIO_PXSEL((n))) /* 0:GPIO/Fun0,1:intr/fun1*/   813 #define REG_GPIO_PXSELS(n)	REG32(GPIO_PXSELS((n)))   814 #define REG_GPIO_PXSELC(n)	REG32(GPIO_PXSELC((n)))   815 #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 */   816 #define REG_GPIO_PXDIRS(n)	REG32(GPIO_PXDIRS((n)))   817 #define REG_GPIO_PXDIRC(n)	REG32(GPIO_PXDIRC((n)))   818 #define REG_GPIO_PXTRG(n)	REG32(GPIO_PXTRG((n))) /* 0:level-trigger, 1:edge-trigger */   819 #define REG_GPIO_PXTRGS(n)	REG32(GPIO_PXTRGS((n)))   820 #define REG_GPIO_PXTRGC(n)	REG32(GPIO_PXTRGC((n)))   821 #define REG_GPIO_PXFLG(n)	REG32(GPIO_PXFLG((n))) /* interrupt flag */   822 #define REG_GPIO_PXFLGC(n)	REG32(GPIO_PXFLGC((n))) /* interrupt flag */   823    824    825 /*************************************************************************   826  * UART   827  *************************************************************************/   828    829 #define IRDA_BASE	UART0_BASE   830 /* #define UART_BASE	UART0_BASE */   831 #define UART_OFF	0x1000   832    833 /* Register Offset */   834 #define OFF_RDR		(0x00)	/* R  8b H'xx */   835 #define OFF_TDR		(0x00)	/* W  8b H'xx */   836 #define OFF_DLLR	(0x00)	/* RW 8b H'00 */   837 #define OFF_DLHR	(0x04)	/* RW 8b H'00 */   838 #define OFF_IER		(0x04)	/* RW 8b H'00 */   839 #define OFF_ISR		(0x08)	/* R  8b H'01 */   840 #define OFF_FCR		(0x08)	/* W  8b H'00 */   841 #define OFF_LCR		(0x0C)	/* RW 8b H'00 */   842 #define OFF_MCR		(0x10)	/* RW 8b H'00 */   843 #define OFF_LSR		(0x14)	/* R  8b H'00 */   844 #define OFF_MSR		(0x18)	/* R  8b H'00 */   845 #define OFF_SPR		(0x1C)	/* RW 8b H'00 */   846 #define OFF_SIRCR	(0x20)	/* RW 8b H'00, UART0 */   847 #define OFF_UMR		(0x24)	/* RW 8b H'00, UART M Register */   848 #define OFF_UACR	(0x28)	/* RW 8b H'00, UART Add Cycle Register */   849    850 /* Register Address */   851 #define UART0_RDR	(UART0_BASE + OFF_RDR)   852 #define UART0_TDR	(UART0_BASE + OFF_TDR)   853 #define UART0_DLLR	(UART0_BASE + OFF_DLLR)   854 #define UART0_DLHR	(UART0_BASE + OFF_DLHR)   855 #define UART0_IER	(UART0_BASE + OFF_IER)   856 #define UART0_ISR	(UART0_BASE + OFF_ISR)   857 #define UART0_FCR	(UART0_BASE + OFF_FCR)   858 #define UART0_LCR	(UART0_BASE + OFF_LCR)   859 #define UART0_MCR	(UART0_BASE + OFF_MCR)   860 #define UART0_LSR	(UART0_BASE + OFF_LSR)   861 #define UART0_MSR	(UART0_BASE + OFF_MSR)   862 #define UART0_SPR	(UART0_BASE + OFF_SPR)   863 #define UART0_SIRCR	(UART0_BASE + OFF_SIRCR)   864 #define UART0_UMR	(UART0_BASE + OFF_UMR)   865 #define UART0_UACR	(UART0_BASE + OFF_UACR)   866    867 /*   868  * Define macros for UART_IER   869  * UART Interrupt Enable Register   870  */   871 #define UART_IER_RIE	(1 << 0)	/* 0: receive fifo "full" interrupt disable */   872 #define UART_IER_TIE	(1 << 1)	/* 0: transmit fifo "empty" interrupt disable */   873 #define UART_IER_RLIE	(1 << 2)	/* 0: receive line status interrupt disable */   874 #define UART_IER_MIE	(1 << 3)	/* 0: modem status interrupt disable */   875 #define UART_IER_RTIE	(1 << 4)	/* 0: receive timeout interrupt disable */   876    877 /*   878  * Define macros for UART_ISR   879  * UART Interrupt Status Register   880  */   881 #define UART_ISR_IP	(1 << 0)	/* 0: interrupt is pending  1: no interrupt */   882 #define UART_ISR_IID	(7 << 1)	/* Source of Interrupt */   883 #define UART_ISR_IID_MSI		(0 << 1)	/* Modem status interrupt */   884 #define UART_ISR_IID_THRI	(1 << 1)	/* Transmitter holding register empty */   885 #define UART_ISR_IID_RDI		(2 << 1)	/* Receiver data interrupt */   886 #define UART_ISR_IID_RLSI	(3 << 1)	/* Receiver line status interrupt */   887 #define UART_ISR_FFMS	(3 << 6)	/* FIFO mode select, set when UART_FCR.FE is set to 1 */   888 #define UART_ISR_FFMS_NO_FIFO	(0 << 6)   889 #define UART_ISR_FFMS_FIFO_MODE	(3 << 6)   890    891 /*   892  * Define macros for UART_FCR   893  * UART FIFO Control Register   894  */   895 #define UART_FCR_FE	(1 << 0)	/* 0: non-FIFO mode  1: FIFO mode */   896 #define UART_FCR_RFLS	(1 << 1)	/* write 1 to flush receive FIFO */   897 #define UART_FCR_TFLS	(1 << 2)	/* write 1 to flush transmit FIFO */   898 #define UART_FCR_DMS	(1 << 3)	/* 0: disable DMA mode */   899 #define UART_FCR_UUE	(1 << 4)	/* 0: disable UART */   900 #define UART_FCR_RTRG	(3 << 6)	/* Receive FIFO Data Trigger */   901 #define UART_FCR_RTRG_1	(0 << 6)   902 #define UART_FCR_RTRG_4	(1 << 6)   903 #define UART_FCR_RTRG_8	(2 << 6)   904 #define UART_FCR_RTRG_15	(3 << 6)   905    906 /*   907  * Define macros for UART_LCR   908  * UART Line Control Register   909  */   910 #define UART_LCR_WLEN	(3 << 0)	/* word length */   911 #define UART_LCR_WLEN_5	(0 << 0)   912 #define UART_LCR_WLEN_6	(1 << 0)   913 #define UART_LCR_WLEN_7	(2 << 0)   914 #define UART_LCR_WLEN_8	(3 << 0)   915 #define UART_LCR_STOP	(1 << 2)	/* 0: 1 stop bit when word length is 5,6,7,8   916 					   1: 1.5 stop bits when 5; 2 stop bits when 6,7,8 */   917 #define UART_LCR_STOP_1	(0 << 2)	/* 0: 1 stop bit when word length is 5,6,7,8   918 					   1: 1.5 stop bits when 5; 2 stop bits when 6,7,8 */   919 #define UART_LCR_STOP_2	(1 << 2)	/* 0: 1 stop bit when word length is 5,6,7,8   920 					   1: 1.5 stop bits when 5; 2 stop bits when 6,7,8 */   921    922 #define UART_LCR_PE	(1 << 3)	/* 0: parity disable */   923 #define UART_LCR_PROE	(1 << 4)	/* 0: even parity  1: odd parity */   924 #define UART_LCR_SPAR	(1 << 5)	/* 0: sticky parity disable */   925 #define UART_LCR_SBRK	(1 << 6)	/* write 0 normal, write 1 send break */   926 #define UART_LCR_DLAB	(1 << 7)	/* 0: access UART_RDR/TDR/IER  1: access UART_DLLR/DLHR */   927    928 /*   929  * Define macros for UART_LSR   930  * UART Line Status Register   931  */   932 #define UART_LSR_DR	(1 << 0)	/* 0: receive FIFO is empty  1: receive data is ready */   933 #define UART_LSR_ORER	(1 << 1)	/* 0: no overrun error */   934 #define UART_LSR_PER	(1 << 2)	/* 0: no parity error */   935 #define UART_LSR_FER	(1 << 3)	/* 0; no framing error */   936 #define UART_LSR_BRK	(1 << 4)	/* 0: no break detected  1: receive a break signal */   937 #define UART_LSR_TDRQ	(1 << 5)	/* 1: transmit FIFO half "empty" */   938 #define UART_LSR_TEMT	(1 << 6)	/* 1: transmit FIFO and shift registers empty */   939 #define UART_LSR_RFER	(1 << 7)	/* 0: no receive error  1: receive error in FIFO mode */   940    941 /*   942  * Define macros for UART_MCR   943  * UART Modem Control Register   944  */   945 #define UART_MCR_DTR	(1 << 0)	/* 0: DTR_ ouput high */   946 #define UART_MCR_RTS	(1 << 1)	/* 0: RTS_ output high */   947 #define UART_MCR_OUT1	(1 << 2)	/* 0: UART_MSR.RI is set to 0 and RI_ input high */   948 #define UART_MCR_OUT2	(1 << 3)	/* 0: UART_MSR.DCD is set to 0 and DCD_ input high */   949 #define UART_MCR_LOOP	(1 << 4)	/* 0: normal  1: loopback mode */   950 #define UART_MCR_MCE	(1 << 7)	/* 0: modem function is disable */   951    952 /*   953  * Define macros for UART_MSR   954  * UART Modem Status Register   955  */   956 #define UART_MSR_DCTS	(1 << 0)	/* 0: no change on CTS_ pin since last read of UART_MSR */   957 #define UART_MSR_DDSR	(1 << 1)	/* 0: no change on DSR_ pin since last read of UART_MSR */   958 #define UART_MSR_DRI	(1 << 2)	/* 0: no change on RI_ pin since last read of UART_MSR */   959 #define UART_MSR_DDCD	(1 << 3)	/* 0: no change on DCD_ pin since last read of UART_MSR */   960 #define UART_MSR_CTS	(1 << 4)	/* 0: CTS_ pin is high */   961 #define UART_MSR_DSR	(1 << 5)	/* 0: DSR_ pin is high */   962 #define UART_MSR_RI	(1 << 6)	/* 0: RI_ pin is high */   963 #define UART_MSR_DCD	(1 << 7)	/* 0: DCD_ pin is high */   964    965 /*   966  * Define macros for SIRCR   967  * Slow IrDA Control Register   968  */   969 #define SIRCR_TSIRE	(1 << 0)	/* 0: transmitter is in UART mode  1: IrDA mode */   970 #define SIRCR_RSIRE	(1 << 1)	/* 0: receiver is in UART mode  1: IrDA mode */   971 #define SIRCR_TPWS	(1 << 2)	/* 0: transmit 0 pulse width is 3/16 of bit length   972 					   1: 0 pulse width is 1.6us for 115.2Kbps */   973 #define SIRCR_TXPL	(1 << 3)	/* 0: encoder generates a positive pulse for 0 */   974 #define SIRCR_RXPL	(1 << 4)	/* 0: decoder interprets positive pulse as 0 */   975    976    977 /*************************************************************************   978  * AIC (AC97/I2S Controller)   979  *************************************************************************/   980 #define	AIC_FR			(AIC_BASE + 0x000)   981 #define	AIC_CR			(AIC_BASE + 0x004)   982 #define	AIC_ACCR1		(AIC_BASE + 0x008)   983 #define	AIC_ACCR2		(AIC_BASE + 0x00C)   984 #define	AIC_I2SCR		(AIC_BASE + 0x010)   985 #define	AIC_SR			(AIC_BASE + 0x014)   986 #define	AIC_ACSR		(AIC_BASE + 0x018)   987 #define	AIC_I2SSR		(AIC_BASE + 0x01C)   988 #define	AIC_ACCAR		(AIC_BASE + 0x020)   989 #define	AIC_ACCDR		(AIC_BASE + 0x024)   990 #define	AIC_ACSAR		(AIC_BASE + 0x028)   991 #define	AIC_ACSDR		(AIC_BASE + 0x02C)   992 #define	AIC_I2SDIV		(AIC_BASE + 0x030)   993 #define	AIC_DR			(AIC_BASE + 0x034)   994    995 #define	REG_AIC_FR		REG32(AIC_FR)   996 #define	REG_AIC_CR		REG32(AIC_CR)   997 #define	REG_AIC_ACCR1		REG32(AIC_ACCR1)   998 #define	REG_AIC_ACCR2		REG32(AIC_ACCR2)   999 #define	REG_AIC_I2SCR		REG32(AIC_I2SCR)  1000 #define	REG_AIC_SR		REG32(AIC_SR)  1001 #define	REG_AIC_ACSR		REG32(AIC_ACSR)  1002 #define	REG_AIC_I2SSR		REG32(AIC_I2SSR)  1003 #define	REG_AIC_ACCAR		REG32(AIC_ACCAR)  1004 #define	REG_AIC_ACCDR		REG32(AIC_ACCDR)  1005 #define	REG_AIC_ACSAR		REG32(AIC_ACSAR)  1006 #define	REG_AIC_ACSDR		REG32(AIC_ACSDR)  1007 #define	REG_AIC_I2SDIV		REG32(AIC_I2SDIV)  1008 #define	REG_AIC_DR		REG32(AIC_DR)  1009   1010 /* AIC Controller Configuration Register (AIC_FR) */  1011   1012 #define	AIC_FR_RFTH_BIT		12        /* Receive FIFO Threshold */  1013 #define	AIC_FR_RFTH_MASK	(0xf << AIC_FR_RFTH_BIT)  1014 #define	AIC_FR_TFTH_BIT		8         /* Transmit FIFO Threshold */  1015 #define	AIC_FR_TFTH_MASK	(0xf << AIC_FR_TFTH_BIT)  1016 #define	AIC_FR_ICDC		(1 << 5)  /* External(0) or Internal CODEC(1) */  1017 #define	AIC_FR_AUSEL		(1 << 4)  /* AC97(0) or I2S/MSB-justified(1) */  1018 #define	AIC_FR_RST		(1 << 3)  /* AIC registers reset */  1019 #define	AIC_FR_BCKD		(1 << 2)  /* I2S BIT_CLK direction, 0:input,1:output */  1020 #define	AIC_FR_SYNCD		(1 << 1)  /* I2S SYNC direction, 0:input,1:output */  1021 #define	AIC_FR_ENB		(1 << 0)  /* AIC enable bit */  1022   1023 /* AIC Controller Common Control Register (AIC_CR) */  1024   1025 #define	AIC_CR_OSS_BIT		19  /* Output Sample Size from memory (AIC V2 only) */  1026 #define	AIC_CR_OSS_MASK		(0x7 << AIC_CR_OSS_BIT)  1027   #define AIC_CR_OSS_8BIT	(0x0 << AIC_CR_OSS_BIT)  1028   #define AIC_CR_OSS_16BIT	(0x1 << AIC_CR_OSS_BIT)  1029   #define AIC_CR_OSS_18BIT	(0x2 << AIC_CR_OSS_BIT)  1030   #define AIC_CR_OSS_20BIT	(0x3 << AIC_CR_OSS_BIT)  1031   #define AIC_CR_OSS_24BIT	(0x4 << AIC_CR_OSS_BIT)  1032 #define	AIC_CR_ISS_BIT		16  /* Input Sample Size from memory (AIC V2 only) */  1033 #define	AIC_CR_ISS_MASK		(0x7 << AIC_CR_ISS_BIT)  1034   #define AIC_CR_ISS_8BIT	(0x0 << AIC_CR_ISS_BIT)  1035   #define AIC_CR_ISS_16BIT	(0x1 << AIC_CR_ISS_BIT)  1036   #define AIC_CR_ISS_18BIT	(0x2 << AIC_CR_ISS_BIT)  1037   #define AIC_CR_ISS_20BIT	(0x3 << AIC_CR_ISS_BIT)  1038   #define AIC_CR_ISS_24BIT	(0x4 << AIC_CR_ISS_BIT)  1039 #define	AIC_CR_RDMS		(1 << 15)  /* Receive DMA enable */  1040 #define	AIC_CR_TDMS		(1 << 14)  /* Transmit DMA enable */  1041 #define	AIC_CR_M2S		(1 << 11)  /* Mono to Stereo enable */  1042 #define	AIC_CR_ENDSW		(1 << 10)  /* Endian switch enable */  1043 #define	AIC_CR_AVSTSU		(1 << 9)   /* Signed <-> Unsigned toggle enable */  1044 #define	AIC_CR_FLUSH		(1 << 8)   /* Flush FIFO */  1045 #define	AIC_CR_EROR		(1 << 6)   /* Enable ROR interrupt */  1046 #define	AIC_CR_ETUR		(1 << 5)   /* Enable TUR interrupt */  1047 #define	AIC_CR_ERFS		(1 << 4)   /* Enable RFS interrupt */  1048 #define	AIC_CR_ETFS		(1 << 3)   /* Enable TFS interrupt */  1049 #define	AIC_CR_ENLBF		(1 << 2)   /* Enable Loopback Function */  1050 #define	AIC_CR_ERPL		(1 << 1)   /* Enable Playback Function */  1051 #define	AIC_CR_EREC		(1 << 0)   /* Enable Record Function */  1052   1053 /* AIC Controller AC-link Control Register 1 (AIC_ACCR1) */  1054   1055 #define	AIC_ACCR1_RS_BIT	16          /* Receive Valid Slots */  1056 #define	AIC_ACCR1_RS_MASK	(0x3ff << AIC_ACCR1_RS_BIT)  1057   #define AIC_ACCR1_RS_SLOT12	  (1 << 25) /* Slot 12 valid bit */  1058   #define AIC_ACCR1_RS_SLOT11	  (1 << 24) /* Slot 11 valid bit */  1059   #define AIC_ACCR1_RS_SLOT10	  (1 << 23) /* Slot 10 valid bit */  1060   #define AIC_ACCR1_RS_SLOT9	  (1 << 22) /* Slot 9 valid bit, LFE */  1061   #define AIC_ACCR1_RS_SLOT8	  (1 << 21) /* Slot 8 valid bit, Surround Right */  1062   #define AIC_ACCR1_RS_SLOT7	  (1 << 20) /* Slot 7 valid bit, Surround Left */  1063   #define AIC_ACCR1_RS_SLOT6	  (1 << 19) /* Slot 6 valid bit, PCM Center */  1064   #define AIC_ACCR1_RS_SLOT5	  (1 << 18) /* Slot 5 valid bit */  1065   #define AIC_ACCR1_RS_SLOT4	  (1 << 17) /* Slot 4 valid bit, PCM Right */  1066   #define AIC_ACCR1_RS_SLOT3	  (1 << 16) /* Slot 3 valid bit, PCM Left */  1067 #define	AIC_ACCR1_XS_BIT	0          /* Transmit Valid Slots */  1068 #define	AIC_ACCR1_XS_MASK	(0x3ff << AIC_ACCR1_XS_BIT)  1069   #define AIC_ACCR1_XS_SLOT12	  (1 << 9) /* Slot 12 valid bit */  1070   #define AIC_ACCR1_XS_SLOT11	  (1 << 8) /* Slot 11 valid bit */  1071   #define AIC_ACCR1_XS_SLOT10	  (1 << 7) /* Slot 10 valid bit */  1072   #define AIC_ACCR1_XS_SLOT9	  (1 << 6) /* Slot 9 valid bit, LFE */  1073   #define AIC_ACCR1_XS_SLOT8	  (1 << 5) /* Slot 8 valid bit, Surround Right */  1074   #define AIC_ACCR1_XS_SLOT7	  (1 << 4) /* Slot 7 valid bit, Surround Left */  1075   #define AIC_ACCR1_XS_SLOT6	  (1 << 3) /* Slot 6 valid bit, PCM Center */  1076   #define AIC_ACCR1_XS_SLOT5	  (1 << 2) /* Slot 5 valid bit */  1077   #define AIC_ACCR1_XS_SLOT4	  (1 << 1) /* Slot 4 valid bit, PCM Right */  1078   #define AIC_ACCR1_XS_SLOT3	  (1 << 0) /* Slot 3 valid bit, PCM Left */  1079   1080 /* AIC Controller AC-link Control Register 2 (AIC_ACCR2) */  1081   1082 #define	AIC_ACCR2_ERSTO		(1 << 18) /* Enable RSTO interrupt */  1083 #define	AIC_ACCR2_ESADR		(1 << 17) /* Enable SADR interrupt */  1084 #define	AIC_ACCR2_ECADT		(1 << 16) /* Enable CADT interrupt */  1085 #define	AIC_ACCR2_OASS_BIT	8  /* Output Sample Size for AC-link */  1086 #define	AIC_ACCR2_OASS_MASK	(0x3 << AIC_ACCR2_OASS_BIT)  1087   #define AIC_ACCR2_OASS_20BIT	  (0 << AIC_ACCR2_OASS_BIT) /* Output Audio Sample Size is 20-bit */  1088   #define AIC_ACCR2_OASS_18BIT	  (1 << AIC_ACCR2_OASS_BIT) /* Output Audio Sample Size is 18-bit */  1089   #define AIC_ACCR2_OASS_16BIT	  (2 << AIC_ACCR2_OASS_BIT) /* Output Audio Sample Size is 16-bit */  1090   #define AIC_ACCR2_OASS_8BIT	  (3 << AIC_ACCR2_OASS_BIT) /* Output Audio Sample Size is 8-bit */  1091 #define	AIC_ACCR2_IASS_BIT	6  /* Output Sample Size for AC-link */  1092 #define	AIC_ACCR2_IASS_MASK	(0x3 << AIC_ACCR2_IASS_BIT)  1093   #define AIC_ACCR2_IASS_20BIT	  (0 << AIC_ACCR2_IASS_BIT) /* Input Audio Sample Size is 20-bit */  1094   #define AIC_ACCR2_IASS_18BIT	  (1 << AIC_ACCR2_IASS_BIT) /* Input Audio Sample Size is 18-bit */  1095   #define AIC_ACCR2_IASS_16BIT	  (2 << AIC_ACCR2_IASS_BIT) /* Input Audio Sample Size is 16-bit */  1096   #define AIC_ACCR2_IASS_8BIT	  (3 << AIC_ACCR2_IASS_BIT) /* Input Audio Sample Size is 8-bit */  1097 #define	AIC_ACCR2_SO		(1 << 3)  /* SDATA_OUT output value */  1098 #define	AIC_ACCR2_SR		(1 << 2)  /* RESET# pin level */  1099 #define	AIC_ACCR2_SS		(1 << 1)  /* SYNC pin level */  1100 #define	AIC_ACCR2_SA		(1 << 0)  /* SYNC and SDATA_OUT alternation */  1101   1102 /* AIC Controller I2S/MSB-justified Control Register (AIC_I2SCR) */  1103   1104 #define	AIC_I2SCR_STPBK		(1 << 12) /* Stop BIT_CLK for I2S/MSB-justified */  1105 #define	AIC_I2SCR_WL_BIT	1  /* Input/Output Sample Size for I2S/MSB-justified */  1106 #define	AIC_I2SCR_WL_MASK	(0x7 << AIC_I2SCR_WL_BIT)  1107   #define AIC_I2SCR_WL_24BIT	  (0 << AIC_I2SCR_WL_BIT) /* Word Length is 24 bit */  1108   #define AIC_I2SCR_WL_20BIT	  (1 << AIC_I2SCR_WL_BIT) /* Word Length is 20 bit */  1109   #define AIC_I2SCR_WL_18BIT	  (2 << AIC_I2SCR_WL_BIT) /* Word Length is 18 bit */  1110   #define AIC_I2SCR_WL_16BIT	  (3 << AIC_I2SCR_WL_BIT) /* Word Length is 16 bit */  1111   #define AIC_I2SCR_WL_8BIT	  (4 << AIC_I2SCR_WL_BIT) /* Word Length is 8 bit */  1112 #define	AIC_I2SCR_AMSL		(1 << 0) /* 0:I2S, 1:MSB-justified */  1113   1114 /* AIC Controller FIFO Status Register (AIC_SR) */  1115   1116 #define	AIC_SR_RFL_BIT		24  /* Receive FIFO Level */  1117 #define	AIC_SR_RFL_MASK		(0x3f << AIC_SR_RFL_BIT)  1118 #define	AIC_SR_TFL_BIT		8   /* Transmit FIFO level */  1119 #define	AIC_SR_TFL_MASK		(0x3f << AIC_SR_TFL_BIT)  1120 #define	AIC_SR_ROR		(1 << 6) /* Receive FIFO Overrun */  1121 #define	AIC_SR_TUR		(1 << 5) /* Transmit FIFO Underrun */  1122 #define	AIC_SR_RFS		(1 << 4) /* Receive FIFO Service Request */  1123 #define	AIC_SR_TFS		(1 << 3) /* Transmit FIFO Service Request */  1124   1125 /* AIC Controller AC-link Status Register (AIC_ACSR) */  1126   1127 #define	AIC_ACSR_SLTERR		(1 << 21) /* Slot Error Flag */  1128 #define	AIC_ACSR_CRDY		(1 << 20) /* External CODEC Ready Flag */  1129 #define	AIC_ACSR_CLPM		(1 << 19) /* External CODEC low power mode flag */  1130 #define	AIC_ACSR_RSTO		(1 << 18) /* External CODEC regs read status timeout */  1131 #define	AIC_ACSR_SADR		(1 << 17) /* External CODEC regs status addr and data received */  1132 #define	AIC_ACSR_CADT		(1 << 16) /* Command Address and Data Transmitted */  1133   1134 /* AIC Controller I2S/MSB-justified Status Register (AIC_I2SSR) */  1135   1136 #define	AIC_I2SSR_BSY		(1 << 2)  /* AIC Busy in I2S/MSB-justified format */  1137   1138 /* AIC Controller AC97 codec Command Address Register (AIC_ACCAR) */  1139   1140 #define	AIC_ACCAR_CAR_BIT	0  1141 #define	AIC_ACCAR_CAR_MASK	(0xfffff << AIC_ACCAR_CAR_BIT)  1142   1143 /* AIC Controller AC97 codec Command Data Register (AIC_ACCDR) */  1144   1145 #define	AIC_ACCDR_CDR_BIT	0  1146 #define	AIC_ACCDR_CDR_MASK	(0xfffff << AIC_ACCDR_CDR_BIT)  1147   1148 /* AIC Controller AC97 codec Status Address Register (AIC_ACSAR) */  1149   1150 #define	AIC_ACSAR_SAR_BIT	0  1151 #define	AIC_ACSAR_SAR_MASK	(0xfffff << AIC_ACSAR_SAR_BIT)  1152   1153 /* AIC Controller AC97 codec Status Data Register (AIC_ACSDR) */  1154   1155 #define	AIC_ACSDR_SDR_BIT	0  1156 #define	AIC_ACSDR_SDR_MASK	(0xfffff << AIC_ACSDR_SDR_BIT)  1157   1158 /* AIC Controller I2S/MSB-justified Clock Divider Register (AIC_I2SDIV) */  1159   1160 #define	AIC_I2SDIV_DIV_BIT	0  1161 #define	AIC_I2SDIV_DIV_MASK	(0x7f << AIC_I2SDIV_DIV_BIT)  1162   #define AIC_I2SDIV_BITCLK_3072KHZ	(0x0C << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 3.072MHz */  1163   #define AIC_I2SDIV_BITCLK_2836KHZ	(0x0D << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 2.836MHz */  1164   #define AIC_I2SDIV_BITCLK_1418KHZ	(0x1A << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 1.418MHz */  1165   #define AIC_I2SDIV_BITCLK_1024KHZ	(0x24 << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 1.024MHz */  1166   #define AIC_I2SDIV_BITCLK_7089KHZ	(0x34 << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 708.92KHz */  1167   #define AIC_I2SDIV_BITCLK_512KHZ	(0x48 << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 512.00KHz */  1168   1169   1170 /*************************************************************************  1171  * ICDC (Internal CODEC)  1172  *************************************************************************/  1173 #define	ICDC_CR			(ICDC_BASE + 0x0400)  /* ICDC Control Register */  1174 #define	ICDC_APWAIT		(ICDC_BASE + 0x0404)  /* Anti-Pop WAIT Stage Timing Control Register */  1175 #define	ICDC_APPRE		(ICDC_BASE + 0x0408)  /* Anti-Pop HPEN-PRE Stage Timing Control Register */  1176 #define	ICDC_APHPEN		(ICDC_BASE + 0x040C)  /* Anti-Pop HPEN Stage Timing Control Register */  1177 #define	ICDC_APSR		(ICDC_BASE + 0x0410)  /* Anti-Pop Status Register */  1178 #define ICDC_CDCCR1             (ICDC_BASE + 0x0080)  1179 #define ICDC_CDCCR2             (ICDC_BASE + 0x0084)  1180   1181 #define	REG_ICDC_CR		REG32(ICDC_CR)  1182 #define	REG_ICDC_APWAIT		REG32(ICDC_APWAIT)  1183 #define	REG_ICDC_APPRE		REG32(ICDC_APPRE)  1184 #define	REG_ICDC_APHPEN		REG32(ICDC_APHPEN)  1185 #define	REG_ICDC_APSR		REG32(ICDC_APSR)  1186 #define REG_ICDC_CDCCR1         REG32(ICDC_CDCCR1)  1187 #define REG_ICDC_CDCCR2         REG32(ICDC_CDCCR2)  1188   1189 /* ICDC Control Register */  1190 #define	ICDC_CR_LINVOL_BIT	24 /* LINE Input Volume Gain: GAIN=LINVOL*1.5-34.5 */  1191 #define	ICDC_CR_LINVOL_MASK	(0x1f << ICDC_CR_LINVOL_BIT)  1192 #define	ICDC_CR_ASRATE_BIT	20 /* Audio Sample Rate */  1193 #define	ICDC_CR_ASRATE_MASK	(0x0f << ICDC_CR_ASRATE_BIT)  1194   #define ICDC_CR_ASRATE_8000	(0x0 << ICDC_CR_ASRATE_BIT)  1195   #define ICDC_CR_ASRATE_11025	(0x1 << ICDC_CR_ASRATE_BIT)  1196   #define ICDC_CR_ASRATE_12000	(0x2 << ICDC_CR_ASRATE_BIT)  1197   #define ICDC_CR_ASRATE_16000	(0x3 << ICDC_CR_ASRATE_BIT)  1198   #define ICDC_CR_ASRATE_22050	(0x4 << ICDC_CR_ASRATE_BIT)  1199   #define ICDC_CR_ASRATE_24000	(0x5 << ICDC_CR_ASRATE_BIT)  1200   #define ICDC_CR_ASRATE_32000	(0x6 << ICDC_CR_ASRATE_BIT)  1201   #define ICDC_CR_ASRATE_44100	(0x7 << ICDC_CR_ASRATE_BIT)  1202   #define ICDC_CR_ASRATE_48000	(0x8 << ICDC_CR_ASRATE_BIT)  1203 #define	ICDC_CR_MICBG_BIT	18 /* MIC Boost Gain */  1204 #define	ICDC_CR_MICBG_MASK	(0x3 << ICDC_CR_MICBG_BIT)  1205   #define ICDC_CR_MICBG_0DB	(0x0 << ICDC_CR_MICBG_BIT)  1206   #define ICDC_CR_MICBG_6DB	(0x1 << ICDC_CR_MICBG_BIT)  1207   #define ICDC_CR_MICBG_12DB	(0x2 << ICDC_CR_MICBG_BIT)  1208   #define ICDC_CR_MICBG_20DB	(0x3 << ICDC_CR_MICBG_BIT)  1209 #define	ICDC_CR_HPVOL_BIT	16 /* Headphone Volume Gain */  1210 #define	ICDC_CR_HPVOL_MASK	(0x3 << ICDC_CR_HPVOL_BIT)  1211   #define ICDC_CR_HPVOL_0DB	(0x0 << ICDC_CR_HPVOL_BIT)  1212   #define ICDC_CR_HPVOL_2DB	(0x1 << ICDC_CR_HPVOL_BIT)  1213   #define ICDC_CR_HPVOL_4DB	(0x2 << ICDC_CR_HPVOL_BIT)  1214   #define ICDC_CR_HPVOL_6DB	(0x3 << ICDC_CR_HPVOL_BIT)  1215 #define ICDC_CR_ELINEIN		(1 << 13) /* Enable LINE Input */  1216 #define ICDC_CR_EMIC		(1 << 12) /* Enable MIC Input */  1217 #define ICDC_CR_SW1ON		(1 << 11) /* Switch 1 in CODEC is on */  1218 #define ICDC_CR_EADC		(1 << 10) /* Enable ADC */  1219 #define ICDC_CR_SW2ON		(1 << 9)  /* Switch 2 in CODEC is on */  1220 #define ICDC_CR_EDAC		(1 << 8)  /* Enable DAC */  1221 #define ICDC_CR_HPMUTE		(1 << 5)  /* Headphone Mute */  1222 #define ICDC_CR_HPTON		(1 << 4)  /* Headphone Amplifier Trun On */  1223 #define ICDC_CR_HPTOFF		(1 << 3)  /* Headphone Amplifier Trun Off */  1224 #define ICDC_CR_TAAP		(1 << 2)  /* Turn Around of the Anti-Pop Procedure */  1225 #define ICDC_CR_EAP		(1 << 1)  /* Enable Anti-Pop Procedure */  1226 #define ICDC_CR_SUSPD		(1 << 0)  /* CODEC Suspend */  1227   1228 /* Anti-Pop WAIT Stage Timing Control Register */  1229 #define	ICDC_APWAIT_WAITSN_BIT	0  1230 #define	ICDC_APWAIT_WAITSN_MASK	(0x7ff << ICDC_APWAIT_WAITSN_BIT)  1231   1232 /* Anti-Pop HPEN-PRE Stage Timing Control Register */  1233 #define	ICDC_APPRE_PRESN_BIT	0  1234 #define	ICDC_APPRE_PRESN_MASK	(0x1ff << ICDC_APPRE_PRESN_BIT)  1235   1236 /* Anti-Pop HPEN Stage Timing Control Register */  1237 #define	ICDC_APHPEN_HPENSN_BIT	0  1238 #define	ICDC_APHPEN_HPENSN_MASK	(0x3fff << ICDC_APHPEN_HPENSN_BIT)  1239   1240 /* Anti-Pop Status Register */  1241 #define	ICDC_SR_HPST_BIT	14  /* Headphone Amplifier State */  1242 #define	ICDC_SR_HPST_MASK	(0x7 << ICDC_SR_HPST_BIT)  1243 #define ICDC_SR_HPST_HP_OFF	 (0x0 << ICDC_SR_HPST_BIT) /* HP amplifier is off */  1244 #define ICDC_SR_HPST_TON_WAIT	 (0x1 << ICDC_SR_HPST_BIT) /* wait state in turn-on */  1245   #define ICDC_SR_HPST_TON_PRE	 (0x2 << ICDC_SR_HPST_BIT) /* pre-enable state in turn-on */  1246 #define ICDC_SR_HPST_TON_HPEN	 (0x3 << ICDC_SR_HPST_BIT) /* HP enable state in turn-on */  1247   #define ICDC_SR_HPST_TOFF_HPEN (0x4 << ICDC_SR_HPST_BIT) /* HP enable state in turn-off */  1248   #define ICDC_SR_HPST_TOFF_PRE  (0x5 << ICDC_SR_HPST_BIT) /* pre-enable state in turn-off */  1249   #define ICDC_SR_HPST_TOFF_WAIT (0x6 << ICDC_SR_HPST_BIT) /* wait state in turn-off */  1250   #define ICDC_SR_HPST_HP_ON	 (0x7 << ICDC_SR_HPST_BIT) /* HP amplifier is on */  1251 #define	ICDC_SR_SNCNT_BIT	0  /* Sample Number Counter */  1252 #define	ICDC_SR_SNCNT_MASK	(0x3fff << ICDC_SR_SNCNT_BIT)  1253   1254   1255 /*************************************************************************  1256  * I2C  1257  *************************************************************************/  1258 #define	I2C_DR			(I2C_BASE + 0x000)  1259 #define	I2C_CR			(I2C_BASE + 0x004)  1260 #define	I2C_SR			(I2C_BASE + 0x008)  1261 #define	I2C_GR			(I2C_BASE + 0x00C)  1262   1263 #define	REG_I2C_DR		REG8(I2C_DR)  1264 #define	REG_I2C_CR		REG8(I2C_CR)  1265 #define REG_I2C_SR		REG8(I2C_SR)  1266 #define REG_I2C_GR		REG16(I2C_GR)  1267   1268 /* I2C Control Register (I2C_CR) */  1269   1270 #define I2C_CR_IEN		(1 << 4)  1271 #define I2C_CR_STA		(1 << 3)  1272 #define I2C_CR_STO		(1 << 2)  1273 #define I2C_CR_AC		(1 << 1)  1274 #define I2C_CR_I2CE		(1 << 0)  1275   1276 /* I2C Status Register (I2C_SR) */  1277   1278 #define I2C_SR_STX		(1 << 4)  1279 #define I2C_SR_BUSY		(1 << 3)  1280 #define I2C_SR_TEND		(1 << 2)  1281 #define I2C_SR_DRF		(1 << 1)  1282 #define I2C_SR_ACKF		(1 << 0)  1283   1284   1285 /*************************************************************************  1286  * SSI  1287  *************************************************************************/  1288 #define	SSI_DR			(SSI_BASE + 0x000)  1289 #define	SSI_CR0			(SSI_BASE + 0x004)  1290 #define	SSI_CR1			(SSI_BASE + 0x008)  1291 #define	SSI_SR			(SSI_BASE + 0x00C)  1292 #define	SSI_ITR			(SSI_BASE + 0x010)  1293 #define	SSI_ICR			(SSI_BASE + 0x014)  1294 #define	SSI_GR			(SSI_BASE + 0x018)  1295   1296 #define	REG_SSI_DR		REG32(SSI_DR)  1297 #define	REG_SSI_CR0		REG16(SSI_CR0)  1298 #define	REG_SSI_CR1		REG32(SSI_CR1)  1299 #define	REG_SSI_SR		REG32(SSI_SR)  1300 #define	REG_SSI_ITR		REG16(SSI_ITR)  1301 #define	REG_SSI_ICR		REG8(SSI_ICR)  1302 #define	REG_SSI_GR		REG16(SSI_GR)  1303   1304 /* SSI Data Register (SSI_DR) */  1305   1306 #define	SSI_DR_GPC_BIT		0  1307 #define	SSI_DR_GPC_MASK		(0x1ff << SSI_DR_GPC_BIT)  1308   1309 /* SSI Control Register 0 (SSI_CR0) */  1310   1311 #define SSI_CR0_SSIE		(1 << 15)  1312 #define SSI_CR0_TIE		(1 << 14)  1313 #define SSI_CR0_RIE		(1 << 13)  1314 #define SSI_CR0_TEIE		(1 << 12)  1315 #define SSI_CR0_REIE		(1 << 11)  1316 #define SSI_CR0_LOOP		(1 << 10)  1317 #define SSI_CR0_RFINE		(1 << 9)  1318 #define SSI_CR0_RFINC		(1 << 8)  1319 #define SSI_CR0_FSEL		(1 << 6)  1320 #define SSI_CR0_TFLUSH		(1 << 2)  1321 #define SSI_CR0_RFLUSH		(1 << 1)  1322 #define SSI_CR0_DISREV		(1 << 0)  1323   1324 /* SSI Control Register 1 (SSI_CR1) */  1325   1326 #define SSI_CR1_FRMHL_BIT	30  1327 #define SSI_CR1_FRMHL_MASK	(0x3 << SSI_CR1_FRMHL_BIT)  1328   #define SSI_CR1_FRMHL_CELOW_CE2LOW	(0 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is low valid and SSI_CE2_ is low valid */  1329   #define SSI_CR1_FRMHL_CEHIGH_CE2LOW	(1 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is high valid and SSI_CE2_ is low valid */  1330   #define SSI_CR1_FRMHL_CELOW_CE2HIGH	(2 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is low valid  and SSI_CE2_ is high valid */  1331   #define SSI_CR1_FRMHL_CEHIGH_CE2HIGH	(3 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is high valid and SSI_CE2_ is high valid */  1332 #define SSI_CR1_TFVCK_BIT	28  1333 #define SSI_CR1_TFVCK_MASK	(0x3 << SSI_CR1_TFVCK_BIT)  1334   #define SSI_CR1_TFVCK_0	  (0 << SSI_CR1_TFVCK_BIT)  1335   #define SSI_CR1_TFVCK_1	  (1 << SSI_CR1_TFVCK_BIT)  1336   #define SSI_CR1_TFVCK_2	  (2 << SSI_CR1_TFVCK_BIT)  1337   #define SSI_CR1_TFVCK_3	  (3 << SSI_CR1_TFVCK_BIT)  1338 #define SSI_CR1_TCKFI_BIT	26  1339 #define SSI_CR1_TCKFI_MASK	(0x3 << SSI_CR1_TCKFI_BIT)  1340   #define SSI_CR1_TCKFI_0	  (0 << SSI_CR1_TCKFI_BIT)  1341   #define SSI_CR1_TCKFI_1	  (1 << SSI_CR1_TCKFI_BIT)  1342   #define SSI_CR1_TCKFI_2	  (2 << SSI_CR1_TCKFI_BIT)  1343   #define SSI_CR1_TCKFI_3	  (3 << SSI_CR1_TCKFI_BIT)  1344 #define SSI_CR1_LFST		(1 << 25)  1345 #define SSI_CR1_ITFRM		(1 << 24)  1346 #define SSI_CR1_UNFIN		(1 << 23)  1347 #define SSI_CR1_MULTS		(1 << 22)  1348 #define SSI_CR1_FMAT_BIT	20  1349 #define SSI_CR1_FMAT_MASK	(0x3 << SSI_CR1_FMAT_BIT)  1350   #define SSI_CR1_FMAT_SPI	  (0 << SSI_CR1_FMAT_BIT) /* Motorola????s SPI format */  1351   #define SSI_CR1_FMAT_SSP	  (1 << SSI_CR1_FMAT_BIT) /* TI's SSP format */  1352   #define SSI_CR1_FMAT_MW1	  (2 << SSI_CR1_FMAT_BIT) /* National Microwire 1 format */  1353   #define SSI_CR1_FMAT_MW2	  (3 << SSI_CR1_FMAT_BIT) /* National Microwire 2 format */  1354 #define SSI_CR1_TTRG_BIT	16  1355 #define SSI_CR1_TTRG_MASK	(0xf << SSI_CR1_TTRG_BIT)  1356   #define SSI_CR1_TTRG_1	  (0 << SSI_CR1_TTRG_BIT)  1357   #define SSI_CR1_TTRG_8	  (1 << SSI_CR1_TTRG_BIT)  1358   #define SSI_CR1_TTRG_16	  (2 << SSI_CR1_TTRG_BIT)  1359   #define SSI_CR1_TTRG_24	  (3 << SSI_CR1_TTRG_BIT)  1360   #define SSI_CR1_TTRG_32	  (4 << SSI_CR1_TTRG_BIT)  1361   #define SSI_CR1_TTRG_40	  (5 << SSI_CR1_TTRG_BIT)  1362   #define SSI_CR1_TTRG_48	  (6 << SSI_CR1_TTRG_BIT)  1363   #define SSI_CR1_TTRG_56	  (7 << SSI_CR1_TTRG_BIT)  1364   #define SSI_CR1_TTRG_64	  (8 << SSI_CR1_TTRG_BIT)  1365   #define SSI_CR1_TTRG_72	  (9 << SSI_CR1_TTRG_BIT)  1366   #define SSI_CR1_TTRG_80	  (10<< SSI_CR1_TTRG_BIT)  1367   #define SSI_CR1_TTRG_88	  (11<< SSI_CR1_TTRG_BIT)  1368   #define SSI_CR1_TTRG_96	  (12<< SSI_CR1_TTRG_BIT)  1369   #define SSI_CR1_TTRG_104	  (13<< SSI_CR1_TTRG_BIT)  1370   #define SSI_CR1_TTRG_112	  (14<< SSI_CR1_TTRG_BIT)  1371   #define SSI_CR1_TTRG_120	  (15<< SSI_CR1_TTRG_BIT)  1372 #define SSI_CR1_MCOM_BIT	12  1373 #define SSI_CR1_MCOM_MASK	(0xf << SSI_CR1_MCOM_BIT)  1374   #define SSI_CR1_MCOM_1BIT	  (0x0 << SSI_CR1_MCOM_BIT) /* 1-bit command selected */  1375   #define SSI_CR1_MCOM_2BIT	  (0x1 << SSI_CR1_MCOM_BIT) /* 2-bit command selected */  1376   #define SSI_CR1_MCOM_3BIT	  (0x2 << SSI_CR1_MCOM_BIT) /* 3-bit command selected */  1377   #define SSI_CR1_MCOM_4BIT	  (0x3 << SSI_CR1_MCOM_BIT) /* 4-bit command selected */  1378   #define SSI_CR1_MCOM_5BIT	  (0x4 << SSI_CR1_MCOM_BIT) /* 5-bit command selected */  1379   #define SSI_CR1_MCOM_6BIT	  (0x5 << SSI_CR1_MCOM_BIT) /* 6-bit command selected */  1380   #define SSI_CR1_MCOM_7BIT	  (0x6 << SSI_CR1_MCOM_BIT) /* 7-bit command selected */  1381   #define SSI_CR1_MCOM_8BIT	  (0x7 << SSI_CR1_MCOM_BIT) /* 8-bit command selected */  1382   #define SSI_CR1_MCOM_9BIT	  (0x8 << SSI_CR1_MCOM_BIT) /* 9-bit command selected */  1383   #define SSI_CR1_MCOM_10BIT	  (0x9 << SSI_CR1_MCOM_BIT) /* 10-bit command selected */  1384   #define SSI_CR1_MCOM_11BIT	  (0xA << SSI_CR1_MCOM_BIT) /* 11-bit command selected */  1385   #define SSI_CR1_MCOM_12BIT	  (0xB << SSI_CR1_MCOM_BIT) /* 12-bit command selected */  1386   #define SSI_CR1_MCOM_13BIT	  (0xC << SSI_CR1_MCOM_BIT) /* 13-bit command selected */  1387   #define SSI_CR1_MCOM_14BIT	  (0xD << SSI_CR1_MCOM_BIT) /* 14-bit command selected */  1388   #define SSI_CR1_MCOM_15BIT	  (0xE << SSI_CR1_MCOM_BIT) /* 15-bit command selected */  1389   #define SSI_CR1_MCOM_16BIT	  (0xF << SSI_CR1_MCOM_BIT) /* 16-bit command selected */  1390 #define SSI_CR1_RTRG_BIT	8  1391 #define SSI_CR1_RTRG_MASK	(0xf << SSI_CR1_RTRG_BIT)  1392   #define SSI_CR1_RTRG_1	  (0 << SSI_CR1_RTRG_BIT)  1393   #define SSI_CR1_RTRG_8	  (1 << SSI_CR1_RTRG_BIT)  1394   #define SSI_CR1_RTRG_16	  (2 << SSI_CR1_RTRG_BIT)  1395   #define SSI_CR1_RTRG_24	  (3 << SSI_CR1_RTRG_BIT)  1396   #define SSI_CR1_RTRG_32	  (4 << SSI_CR1_RTRG_BIT)  1397   #define SSI_CR1_RTRG_40	  (5 << SSI_CR1_RTRG_BIT)  1398   #define SSI_CR1_RTRG_48	  (6 << SSI_CR1_RTRG_BIT)  1399   #define SSI_CR1_RTRG_56	  (7 << SSI_CR1_RTRG_BIT)  1400   #define SSI_CR1_RTRG_64	  (8 << SSI_CR1_RTRG_BIT)  1401   #define SSI_CR1_RTRG_72	  (9 << SSI_CR1_RTRG_BIT)  1402   #define SSI_CR1_RTRG_80	  (10<< SSI_CR1_RTRG_BIT)  1403   #define SSI_CR1_RTRG_88	  (11<< SSI_CR1_RTRG_BIT)  1404   #define SSI_CR1_RTRG_96	  (12<< SSI_CR1_RTRG_BIT)  1405   #define SSI_CR1_RTRG_104	  (13<< SSI_CR1_RTRG_BIT)  1406   #define SSI_CR1_RTRG_112	  (14<< SSI_CR1_RTRG_BIT)  1407   #define SSI_CR1_RTRG_120	  (15<< SSI_CR1_RTRG_BIT)  1408 #define SSI_CR1_FLEN_BIT	4  1409 #define SSI_CR1_FLEN_MASK	(0xf << SSI_CR1_FLEN_BIT)  1410   #define SSI_CR1_FLEN_2BIT	  (0x0 << SSI_CR1_FLEN_BIT)  1411   #define SSI_CR1_FLEN_3BIT	  (0x1 << SSI_CR1_FLEN_BIT)  1412   #define SSI_CR1_FLEN_4BIT	  (0x2 << SSI_CR1_FLEN_BIT)  1413   #define SSI_CR1_FLEN_5BIT	  (0x3 << SSI_CR1_FLEN_BIT)  1414   #define SSI_CR1_FLEN_6BIT	  (0x4 << SSI_CR1_FLEN_BIT)  1415   #define SSI_CR1_FLEN_7BIT	  (0x5 << SSI_CR1_FLEN_BIT)  1416   #define SSI_CR1_FLEN_8BIT	  (0x6 << SSI_CR1_FLEN_BIT)  1417   #define SSI_CR1_FLEN_9BIT	  (0x7 << SSI_CR1_FLEN_BIT)  1418   #define SSI_CR1_FLEN_10BIT	  (0x8 << SSI_CR1_FLEN_BIT)  1419   #define SSI_CR1_FLEN_11BIT	  (0x9 << SSI_CR1_FLEN_BIT)  1420   #define SSI_CR1_FLEN_12BIT	  (0xA << SSI_CR1_FLEN_BIT)  1421   #define SSI_CR1_FLEN_13BIT	  (0xB << SSI_CR1_FLEN_BIT)  1422   #define SSI_CR1_FLEN_14BIT	  (0xC << SSI_CR1_FLEN_BIT)  1423   #define SSI_CR1_FLEN_15BIT	  (0xD << SSI_CR1_FLEN_BIT)  1424   #define SSI_CR1_FLEN_16BIT	  (0xE << SSI_CR1_FLEN_BIT)  1425   #define SSI_CR1_FLEN_17BIT	  (0xF << SSI_CR1_FLEN_BIT)  1426 #define SSI_CR1_PHA		(1 << 1)  1427 #define SSI_CR1_POL		(1 << 0)  1428   1429 /* SSI Status Register (SSI_SR) */  1430   1431 #define SSI_SR_TFIFONUM_BIT	16  1432 #define SSI_SR_TFIFONUM_MASK	(0xff << SSI_SR_TFIFONUM_BIT)  1433 #define SSI_SR_RFIFONUM_BIT	8  1434 #define SSI_SR_RFIFONUM_MASK	(0xff << SSI_SR_RFIFONUM_BIT)  1435 #define SSI_SR_END		(1 << 7)  1436 #define SSI_SR_BUSY		(1 << 6)  1437 #define SSI_SR_TFF		(1 << 5)  1438 #define SSI_SR_RFE		(1 << 4)  1439 #define SSI_SR_TFHE		(1 << 3)  1440 #define SSI_SR_RFHF		(1 << 2)  1441 #define SSI_SR_UNDR		(1 << 1)  1442 #define SSI_SR_OVER		(1 << 0)  1443   1444 /* SSI Interval Time Control Register (SSI_ITR) */  1445   1446 #define	SSI_ITR_CNTCLK		(1 << 15)  1447 #define SSI_ITR_IVLTM_BIT	0  1448 #define SSI_ITR_IVLTM_MASK	(0x7fff << SSI_ITR_IVLTM_BIT)  1449   1450   1451 /*************************************************************************  1452  * MSC  1453  *************************************************************************/  1454 #define	MSC_STRPCL		(MSC_BASE + 0x000)  1455 #define	MSC_STAT		(MSC_BASE + 0x004)  1456 #define	MSC_CLKRT		(MSC_BASE + 0x008)  1457 #define	MSC_CMDAT		(MSC_BASE + 0x00C)  1458 #define	MSC_RESTO		(MSC_BASE + 0x010)  1459 #define	MSC_RDTO		(MSC_BASE + 0x014)  1460 #define	MSC_BLKLEN		(MSC_BASE + 0x018)  1461 #define	MSC_NOB			(MSC_BASE + 0x01C)  1462 #define	MSC_SNOB		(MSC_BASE + 0x020)  1463 #define	MSC_IMASK		(MSC_BASE + 0x024)  1464 #define	MSC_IREG		(MSC_BASE + 0x028)  1465 #define	MSC_CMD			(MSC_BASE + 0x02C)  1466 #define	MSC_ARG			(MSC_BASE + 0x030)  1467 #define	MSC_RES			(MSC_BASE + 0x034)  1468 #define	MSC_RXFIFO		(MSC_BASE + 0x038)  1469 #define	MSC_TXFIFO		(MSC_BASE + 0x03C)  1470   1471 #define	REG_MSC_STRPCL		REG16(MSC_STRPCL)  1472 #define	REG_MSC_STAT		REG32(MSC_STAT)  1473 #define	REG_MSC_CLKRT		REG16(MSC_CLKRT)  1474 #define	REG_MSC_CMDAT		REG32(MSC_CMDAT)  1475 #define	REG_MSC_RESTO		REG16(MSC_RESTO)  1476 #define	REG_MSC_RDTO		REG16(MSC_RDTO)  1477 #define	REG_MSC_BLKLEN		REG16(MSC_BLKLEN)  1478 #define	REG_MSC_NOB		REG16(MSC_NOB)  1479 #define	REG_MSC_SNOB		REG16(MSC_SNOB)  1480 #define	REG_MSC_IMASK		REG16(MSC_IMASK)  1481 #define	REG_MSC_IREG		REG16(MSC_IREG)  1482 #define	REG_MSC_CMD		REG8(MSC_CMD)  1483 #define	REG_MSC_ARG		REG32(MSC_ARG)  1484 #define	REG_MSC_RES		REG16(MSC_RES)  1485 #define	REG_MSC_RXFIFO		REG32(MSC_RXFIFO)  1486 #define	REG_MSC_TXFIFO		REG32(MSC_TXFIFO)  1487   1488 /* MSC Clock and Control Register (MSC_STRPCL) */  1489   1490 #define MSC_STRPCL_EXIT_MULTIPLE	(1 << 7)  1491 #define MSC_STRPCL_EXIT_TRANSFER	(1 << 6)  1492 #define MSC_STRPCL_START_READWAIT	(1 << 5)  1493 #define MSC_STRPCL_STOP_READWAIT	(1 << 4)  1494 #define MSC_STRPCL_RESET		(1 << 3)  1495 #define MSC_STRPCL_START_OP		(1 << 2)  1496 #define MSC_STRPCL_CLOCK_CONTROL_BIT	0  1497 #define MSC_STRPCL_CLOCK_CONTROL_MASK	(0x3 << MSC_STRPCL_CLOCK_CONTROL_BIT)  1498   #define MSC_STRPCL_CLOCK_CONTROL_STOP	  (0x1 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Stop MMC/SD clock */  1499   #define MSC_STRPCL_CLOCK_CONTROL_START  (0x2 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Start MMC/SD clock */  1500   1501 /* MSC Status Register (MSC_STAT) */  1502   1503 #define MSC_STAT_IS_RESETTING		(1 << 15)  1504 #define MSC_STAT_SDIO_INT_ACTIVE	(1 << 14)  1505 #define MSC_STAT_PRG_DONE		(1 << 13)  1506 #define MSC_STAT_DATA_TRAN_DONE		(1 << 12)  1507 #define MSC_STAT_END_CMD_RES		(1 << 11)  1508 #define MSC_STAT_DATA_FIFO_AFULL	(1 << 10)  1509 #define MSC_STAT_IS_READWAIT		(1 << 9)  1510 #define MSC_STAT_CLK_EN			(1 << 8)  1511 #define MSC_STAT_DATA_FIFO_FULL		(1 << 7)  1512 #define MSC_STAT_DATA_FIFO_EMPTY	(1 << 6)  1513 #define MSC_STAT_CRC_RES_ERR		(1 << 5)  1514 #define MSC_STAT_CRC_READ_ERROR		(1 << 4)  1515 #define MSC_STAT_CRC_WRITE_ERROR_BIT	2  1516 #define MSC_STAT_CRC_WRITE_ERROR_MASK	(0x3 << MSC_STAT_CRC_WRITE_ERROR_BIT)  1517   #define MSC_STAT_CRC_WRITE_ERROR_NO		(0 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No error on transmission of data */  1518   #define MSC_STAT_CRC_WRITE_ERROR		(1 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* Card observed erroneous transmission of data */  1519   #define MSC_STAT_CRC_WRITE_ERROR_NOSTS	(2 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No CRC status is sent back */  1520 #define MSC_STAT_TIME_OUT_RES		(1 << 1)  1521 #define MSC_STAT_TIME_OUT_READ		(1 << 0)  1522   1523 /* MSC Bus Clock Control Register (MSC_CLKRT) */  1524   1525 #define	MSC_CLKRT_CLK_RATE_BIT		0  1526 #define	MSC_CLKRT_CLK_RATE_MASK		(0x7 << MSC_CLKRT_CLK_RATE_BIT)  1527   #define MSC_CLKRT_CLK_RATE_DIV_1	  (0x0 << MSC_CLKRT_CLK_RATE_BIT) /* CLK_SRC */  1528   #define MSC_CLKRT_CLK_RATE_DIV_2	  (0x1 << MSC_CLKRT_CLK_RATE_BIT) /* 1/2 of CLK_SRC */  1529   #define MSC_CLKRT_CLK_RATE_DIV_4	  (0x2 << MSC_CLKRT_CLK_RATE_BIT) /* 1/4 of CLK_SRC */  1530   #define MSC_CLKRT_CLK_RATE_DIV_8	  (0x3 << MSC_CLKRT_CLK_RATE_BIT) /* 1/8 of CLK_SRC */  1531   #define MSC_CLKRT_CLK_RATE_DIV_16	  (0x4 << MSC_CLKRT_CLK_RATE_BIT) /* 1/16 of CLK_SRC */  1532   #define MSC_CLKRT_CLK_RATE_DIV_32	  (0x5 << MSC_CLKRT_CLK_RATE_BIT) /* 1/32 of CLK_SRC */  1533   #define MSC_CLKRT_CLK_RATE_DIV_64	  (0x6 << MSC_CLKRT_CLK_RATE_BIT) /* 1/64 of CLK_SRC */  1534   #define MSC_CLKRT_CLK_RATE_DIV_128	  (0x7 << MSC_CLKRT_CLK_RATE_BIT) /* 1/128 of CLK_SRC */  1535   1536 /* MSC Command Sequence Control Register (MSC_CMDAT) */  1537   1538 #define	MSC_CMDAT_IO_ABORT	(1 << 11)  1539 #define	MSC_CMDAT_BUS_WIDTH_BIT	9  1540 #define	MSC_CMDAT_BUS_WIDTH_MASK (0x3 << MSC_CMDAT_BUS_WIDTH_BIT)  1541 #define MSC_CMDAT_BUS_WIDTH_1BIT (0x0 << MSC_CMDAT_BUS_WIDTH_BIT)  1542 #define MSC_CMDAT_BUS_WIDTH_4BIT (0x2 << MSC_CMDAT_BUS_WIDTH_BIT)  1543 #define	MSC_CMDAT_DMA_EN	(1 << 8)  1544 #define	MSC_CMDAT_INIT		(1 << 7)  1545 #define	MSC_CMDAT_BUSY		(1 << 6)  1546 #define	MSC_CMDAT_STREAM_BLOCK	(1 << 5)  1547 #define	MSC_CMDAT_WRITE		(1 << 4)  1548 #define	MSC_CMDAT_READ		(0 << 4)  1549 #define	MSC_CMDAT_DATA_EN	(1 << 3)  1550 #define	MSC_CMDAT_RESPONSE_BIT	0  1551 #define	MSC_CMDAT_RESPONSE_MASK	(0x7 << MSC_CMDAT_RESPONSE_BIT)  1552 #define MSC_CMDAT_RESPONSE_NONE	(0x0 << MSC_CMDAT_RESPONSE_BIT)  1553 #define MSC_CMDAT_RESPONSE_R1	(0x1 << MSC_CMDAT_RESPONSE_BIT)  1554 #define MSC_CMDAT_RESPONSE_R2	(0x2 << MSC_CMDAT_RESPONSE_BIT)  1555 #define MSC_CMDAT_RESPONSE_R3	(0x3 << MSC_CMDAT_RESPONSE_BIT)  1556 #define MSC_CMDAT_RESPONSE_R4	(0x4 << MSC_CMDAT_RESPONSE_BIT)  1557 #define MSC_CMDAT_RESPONSE_R5	(0x5 << MSC_CMDAT_RESPONSE_BIT)  1558 #define MSC_CMDAT_RESPONSE_R6	(0x6 << MSC_CMDAT_RESPONSE_BIT)  1559   1560 /* MSC Interrupts Mask Register (MSC_IMASK) */  1561 #define	MSC_IMASK_SDIO			(1 << 7)  1562 #define	MSC_IMASK_TXFIFO_WR_REQ		(1 << 6)  1563 #define	MSC_IMASK_RXFIFO_RD_REQ		(1 << 5)  1564 #define	MSC_IMASK_END_CMD_RES		(1 << 2)  1565 #define	MSC_IMASK_PRG_DONE		(1 << 1)  1566 #define	MSC_IMASK_DATA_TRAN_DONE	(1 << 0)  1567   1568   1569 /* MSC Interrupts Status Register (MSC_IREG) */  1570 #define	MSC_IREG_SDIO			(1 << 7)  1571 #define	MSC_IREG_TXFIFO_WR_REQ		(1 << 6)  1572 #define	MSC_IREG_RXFIFO_RD_REQ		(1 << 5)  1573 #define	MSC_IREG_END_CMD_RES		(1 << 2)  1574 #define	MSC_IREG_PRG_DONE		(1 << 1)  1575 #define	MSC_IREG_DATA_TRAN_DONE		(1 << 0)  1576   1577   1578 /*  1579  * EMC (External Memory Controller)  1580  */  1581 #define EMC_BCR		(EMC_BASE + 0x0)  /* BCR */  1582   1583 #define EMC_SMCR0	(EMC_BASE + 0x10)  /* Static Memory Control Register 0 */  1584 #define EMC_SMCR1	(EMC_BASE + 0x14)  /* Static Memory Control Register 1 */  1585 #define EMC_SMCR2	(EMC_BASE + 0x18)  /* Static Memory Control Register 2 */  1586 #define EMC_SMCR3	(EMC_BASE + 0x1c)  /* Static Memory Control Register 3 */  1587 #define EMC_SMCR4	(EMC_BASE + 0x20)  /* Static Memory Control Register 4 */  1588 #define EMC_SACR0	(EMC_BASE + 0x30)  /* Static Memory Bank 0 Addr Config Reg */  1589 #define EMC_SACR1	(EMC_BASE + 0x34)  /* Static Memory Bank 1 Addr Config Reg */  1590 #define EMC_SACR2	(EMC_BASE + 0x38)  /* Static Memory Bank 2 Addr Config Reg */  1591 #define EMC_SACR3	(EMC_BASE + 0x3c)  /* Static Memory Bank 3 Addr Config Reg */  1592 #define EMC_SACR4	(EMC_BASE + 0x40)  /* Static Memory Bank 4 Addr Config Reg */  1593   1594 #define EMC_NFCSR	(EMC_BASE + 0x050) /* NAND Flash Control/Status Register */  1595 #define EMC_NFECR	(EMC_BASE + 0x100) /* NAND Flash ECC Control Register */  1596 #define EMC_NFECC	(EMC_BASE + 0x104) /* NAND Flash ECC Data Register */  1597 #define EMC_NFPAR0	(EMC_BASE + 0x108) /* NAND Flash RS Parity 0 Register */  1598 #define EMC_NFPAR1	(EMC_BASE + 0x10c) /* NAND Flash RS Parity 1 Register */  1599 #define EMC_NFPAR2	(EMC_BASE + 0x110) /* NAND Flash RS Parity 2 Register */  1600 #define EMC_NFINTS	(EMC_BASE + 0x114) /* NAND Flash Interrupt Status Register */  1601 #define EMC_NFINTE	(EMC_BASE + 0x118) /* NAND Flash Interrupt Enable Register */  1602 #define EMC_NFERR0	(EMC_BASE + 0x11c) /* NAND Flash RS Error Report 0 Register */  1603 #define EMC_NFERR1	(EMC_BASE + 0x120) /* NAND Flash RS Error Report 1 Register */  1604 #define EMC_NFERR2	(EMC_BASE + 0x124) /* NAND Flash RS Error Report 2 Register */  1605 #define EMC_NFERR3	(EMC_BASE + 0x128) /* NAND Flash RS Error Report 3 Register */  1606   1607 #define EMC_DMCR	(EMC_BASE + 0x80)  /* DRAM Control Register */  1608 #define EMC_RTCSR	(EMC_BASE + 0x84)  /* Refresh Time Control/Status Register */  1609 #define EMC_RTCNT	(EMC_BASE + 0x88)  /* Refresh Timer Counter */  1610 #define EMC_RTCOR	(EMC_BASE + 0x8c)  /* Refresh Time Constant Register */  1611 #define EMC_DMAR0	(EMC_BASE + 0x90)  /* SDRAM Bank 0 Addr Config Register */  1612 #define EMC_SDMR0	(EMC_BASE + 0xa000) /* Mode Register of SDRAM bank 0 */  1613   1614 #define REG_EMC_BCR	REG32(EMC_BCR)  1615   1616 #define REG_EMC_SMCR0	REG32(EMC_SMCR0)  1617 #define REG_EMC_SMCR1	REG32(EMC_SMCR1)  1618 #define REG_EMC_SMCR2	REG32(EMC_SMCR2)  1619 #define REG_EMC_SMCR3	REG32(EMC_SMCR3)  1620 #define REG_EMC_SMCR4	REG32(EMC_SMCR4)  1621 #define REG_EMC_SACR0	REG32(EMC_SACR0)  1622 #define REG_EMC_SACR1	REG32(EMC_SACR1)  1623 #define REG_EMC_SACR2	REG32(EMC_SACR2)  1624 #define REG_EMC_SACR3	REG32(EMC_SACR3)  1625 #define REG_EMC_SACR4	REG32(EMC_SACR4)  1626   1627 #define REG_EMC_NFCSR	REG32(EMC_NFCSR)  1628 #define REG_EMC_NFECR	REG32(EMC_NFECR)  1629 #define REG_EMC_NFECC	REG32(EMC_NFECC)  1630 #define REG_EMC_NFPAR0	REG32(EMC_NFPAR0)  1631 #define REG_EMC_NFPAR1	REG32(EMC_NFPAR1)  1632 #define REG_EMC_NFPAR2	REG32(EMC_NFPAR2)  1633 #define REG_EMC_NFINTS	REG32(EMC_NFINTS)  1634 #define REG_EMC_NFINTE	REG32(EMC_NFINTE)  1635 #define REG_EMC_NFERR0	REG32(EMC_NFERR0)  1636 #define REG_EMC_NFERR1	REG32(EMC_NFERR1)  1637 #define REG_EMC_NFERR2	REG32(EMC_NFERR2)  1638 #define REG_EMC_NFERR3	REG32(EMC_NFERR3)  1639   1640 #define REG_EMC_DMCR	REG32(EMC_DMCR)  1641 #define REG_EMC_RTCSR	REG16(EMC_RTCSR)  1642 #define REG_EMC_RTCNT	REG16(EMC_RTCNT)  1643 #define REG_EMC_RTCOR	REG16(EMC_RTCOR)  1644 #define REG_EMC_DMAR0	REG32(EMC_DMAR0)  1645   1646 /* Static Memory Control Register */  1647 #define EMC_SMCR_STRV_BIT	24  1648 #define EMC_SMCR_STRV_MASK	(0x0f << EMC_SMCR_STRV_BIT)  1649 #define EMC_SMCR_TAW_BIT	20  1650 #define EMC_SMCR_TAW_MASK	(0x0f << EMC_SMCR_TAW_BIT)  1651 #define EMC_SMCR_TBP_BIT	16  1652 #define EMC_SMCR_TBP_MASK	(0x0f << EMC_SMCR_TBP_BIT)  1653 #define EMC_SMCR_TAH_BIT	12  1654 #define EMC_SMCR_TAH_MASK	(0x07 << EMC_SMCR_TAH_BIT)  1655 #define EMC_SMCR_TAS_BIT	8  1656 #define EMC_SMCR_TAS_MASK	(0x07 << EMC_SMCR_TAS_BIT)  1657 #define EMC_SMCR_BW_BIT		6  1658 #define EMC_SMCR_BW_MASK	(0x03 << EMC_SMCR_BW_BIT)  1659   #define EMC_SMCR_BW_8BIT	(0 << EMC_SMCR_BW_BIT)  1660   #define EMC_SMCR_BW_16BIT	(1 << EMC_SMCR_BW_BIT)  1661   #define EMC_SMCR_BW_32BIT	(2 << EMC_SMCR_BW_BIT)  1662 #define EMC_SMCR_BCM		(1 << 3)  1663 #define EMC_SMCR_BL_BIT		1  1664 #define EMC_SMCR_BL_MASK	(0x03 << EMC_SMCR_BL_BIT)  1665   #define EMC_SMCR_BL_4		(0 << EMC_SMCR_BL_BIT)  1666   #define EMC_SMCR_BL_8		(1 << EMC_SMCR_BL_BIT)  1667   #define EMC_SMCR_BL_16	(2 << EMC_SMCR_BL_BIT)  1668   #define EMC_SMCR_BL_32	(3 << EMC_SMCR_BL_BIT)  1669 #define EMC_SMCR_SMT		(1 << 0)  1670   1671 /* Static Memory Bank Addr Config Reg */  1672 #define EMC_SACR_BASE_BIT	8  1673 #define EMC_SACR_BASE_MASK	(0xff << EMC_SACR_BASE_BIT)  1674 #define EMC_SACR_MASK_BIT	0  1675 #define EMC_SACR_MASK_MASK	(0xff << EMC_SACR_MASK_BIT)  1676   1677 /* NAND Flash Control/Status Register */  1678 #define EMC_NFCSR_NFCE4		(1 << 7) /* NAND Flash Enable */  1679 #define EMC_NFCSR_NFE4		(1 << 6) /* NAND Flash FCE# Assertion Enable */  1680 #define EMC_NFCSR_NFCE3		(1 << 5)  1681 #define EMC_NFCSR_NFE3		(1 << 4)  1682 #define EMC_NFCSR_NFCE2		(1 << 3)  1683 #define EMC_NFCSR_NFE2		(1 << 2)  1684 #define EMC_NFCSR_NFCE1		(1 << 1)  1685 #define EMC_NFCSR_NFE1		(1 << 0)  1686   1687 /* NAND Flash ECC Control Register */  1688 #define EMC_NFECR_PRDY		(1 << 4) /* Parity Ready */  1689 #define EMC_NFECR_RS_DECODING	(0 << 3) /* RS is in decoding phase */  1690 #define EMC_NFECR_RS_ENCODING	(1 << 3) /* RS is in encoding phase */  1691 #define EMC_NFECR_HAMMING	(0 << 2) /* Select HAMMING Correction Algorithm */  1692 #define EMC_NFECR_RS		(1 << 2) /* Select RS Correction Algorithm */  1693 #define EMC_NFECR_ERST		(1 << 1) /* ECC Reset */  1694 #define EMC_NFECR_ECCE		(1 << 0) /* ECC Enable */  1695   1696 /* NAND Flash ECC Data Register */  1697 #define EMC_NFECC_ECC2_BIT	16  1698 #define EMC_NFECC_ECC2_MASK	(0xff << EMC_NFECC_ECC2_BIT)  1699 #define EMC_NFECC_ECC1_BIT	8  1700 #define EMC_NFECC_ECC1_MASK	(0xff << EMC_NFECC_ECC1_BIT)  1701 #define EMC_NFECC_ECC0_BIT	0  1702 #define EMC_NFECC_ECC0_MASK	(0xff << EMC_NFECC_ECC0_BIT)  1703   1704 /* NAND Flash Interrupt Status Register */  1705 #define EMC_NFINTS_ERRCNT_BIT	29       /* Error Count */  1706 #define EMC_NFINTS_ERRCNT_MASK	(0x7 << EMC_NFINTS_ERRCNT_BIT)  1707 #define EMC_NFINTS_PADF		(1 << 4) /* Padding Finished */  1708 #define EMC_NFINTS_DECF		(1 << 3) /* Decoding Finished */  1709 #define EMC_NFINTS_ENCF		(1 << 2) /* Encoding Finished */  1710 #define EMC_NFINTS_UNCOR	(1 << 1) /* Uncorrectable Error Occurred */  1711 #define EMC_NFINTS_ERR		(1 << 0) /* Error Occurred */  1712   1713 /* NAND Flash Interrupt Enable Register */  1714 #define EMC_NFINTE_PADFE	(1 << 4) /* Padding Finished Interrupt Enable */  1715 #define EMC_NFINTE_DECFE	(1 << 3) /* Decoding Finished Interrupt Enable */  1716 #define EMC_NFINTE_ENCFE	(1 << 2) /* Encoding Finished Interrupt Enable */  1717 #define EMC_NFINTE_UNCORE	(1 << 1) /* Uncorrectable Error Occurred Intr Enable */  1718 #define EMC_NFINTE_ERRE		(1 << 0) /* Error Occurred Interrupt */  1719   1720 /* NAND Flash RS Error Report Register */  1721 #define EMC_NFERR_INDEX_BIT	16       /* Error Symbol Index */  1722 #define EMC_NFERR_INDEX_MASK	(0x1ff << EMC_NFERR_INDEX_BIT)  1723 #define EMC_NFERR_MASK_BIT	0        /* Error Symbol Value */  1724 #define EMC_NFERR_MASK_MASK	(0x1ff << EMC_NFERR_MASK_BIT)  1725   1726   1727 /* DRAM Control Register */  1728 #define EMC_DMCR_BW_BIT		31  1729 #define EMC_DMCR_BW		(1 << EMC_DMCR_BW_BIT)  1730 #define EMC_DMCR_CA_BIT		26  1731 #define EMC_DMCR_CA_MASK	(0x07 << EMC_DMCR_CA_BIT)  1732   #define EMC_DMCR_CA_8		(0 << EMC_DMCR_CA_BIT)  1733   #define EMC_DMCR_CA_9		(1 << EMC_DMCR_CA_BIT)  1734   #define EMC_DMCR_CA_10	(2 << EMC_DMCR_CA_BIT)  1735   #define EMC_DMCR_CA_11	(3 << EMC_DMCR_CA_BIT)  1736   #define EMC_DMCR_CA_12	(4 << EMC_DMCR_CA_BIT)  1737 #define EMC_DMCR_RMODE		(1 << 25)  1738 #define EMC_DMCR_RFSH		(1 << 24)  1739 #define EMC_DMCR_MRSET		(1 << 23)  1740 #define EMC_DMCR_RA_BIT		20  1741 #define EMC_DMCR_RA_MASK	(0x03 << EMC_DMCR_RA_BIT)  1742   #define EMC_DMCR_RA_11	(0 << EMC_DMCR_RA_BIT)  1743   #define EMC_DMCR_RA_12	(1 << EMC_DMCR_RA_BIT)  1744   #define EMC_DMCR_RA_13	(2 << EMC_DMCR_RA_BIT)  1745 #define EMC_DMCR_BA_BIT		19  1746 #define EMC_DMCR_BA		(1 << EMC_DMCR_BA_BIT)  1747 #define EMC_DMCR_PDM		(1 << 18)  1748 #define EMC_DMCR_EPIN		(1 << 17)  1749 #define EMC_DMCR_TRAS_BIT	13  1750 #define EMC_DMCR_TRAS_MASK	(0x07 << EMC_DMCR_TRAS_BIT)  1751 #define EMC_DMCR_RCD_BIT	11  1752 #define EMC_DMCR_RCD_MASK	(0x03 << EMC_DMCR_RCD_BIT)  1753 #define EMC_DMCR_TPC_BIT	8  1754 #define EMC_DMCR_TPC_MASK	(0x07 << EMC_DMCR_TPC_BIT)  1755 #define EMC_DMCR_TRWL_BIT	5  1756 #define EMC_DMCR_TRWL_MASK	(0x03 << EMC_DMCR_TRWL_BIT)  1757 #define EMC_DMCR_TRC_BIT	2  1758 #define EMC_DMCR_TRC_MASK	(0x07 << EMC_DMCR_TRC_BIT)  1759 #define EMC_DMCR_TCL_BIT	0  1760 #define EMC_DMCR_TCL_MASK	(0x03 << EMC_DMCR_TCL_BIT)  1761   1762 /* Refresh Time Control/Status Register */  1763 #define EMC_RTCSR_CMF		(1 << 7)  1764 #define EMC_RTCSR_CKS_BIT	0  1765 #define EMC_RTCSR_CKS_MASK	(0x07 << EMC_RTCSR_CKS_BIT)  1766   #define EMC_RTCSR_CKS_DISABLE	(0 << EMC_RTCSR_CKS_BIT)  1767   #define EMC_RTCSR_CKS_4	(1 << EMC_RTCSR_CKS_BIT)  1768   #define EMC_RTCSR_CKS_16	(2 << EMC_RTCSR_CKS_BIT)  1769   #define EMC_RTCSR_CKS_64	(3 << EMC_RTCSR_CKS_BIT)  1770   #define EMC_RTCSR_CKS_256	(4 << EMC_RTCSR_CKS_BIT)  1771   #define EMC_RTCSR_CKS_1024	(5 << EMC_RTCSR_CKS_BIT)  1772   #define EMC_RTCSR_CKS_2048	(6 << EMC_RTCSR_CKS_BIT)  1773   #define EMC_RTCSR_CKS_4096	(7 << EMC_RTCSR_CKS_BIT)  1774   1775 /* SDRAM Bank Address Configuration Register */  1776 #define EMC_DMAR_BASE_BIT	8  1777 #define EMC_DMAR_BASE_MASK	(0xff << EMC_DMAR_BASE_BIT)  1778 #define EMC_DMAR_MASK_BIT	0  1779 #define EMC_DMAR_MASK_MASK	(0xff << EMC_DMAR_MASK_BIT)  1780   1781 /* Mode Register of SDRAM bank 0 */  1782 #define EMC_SDMR_BM		(1 << 9) /* Write Burst Mode */  1783 #define EMC_SDMR_OM_BIT		7        /* Operating Mode */  1784 #define EMC_SDMR_OM_MASK	(3 << EMC_SDMR_OM_BIT)  1785   #define EMC_SDMR_OM_NORMAL	(0 << EMC_SDMR_OM_BIT)  1786 #define EMC_SDMR_CAS_BIT	4        /* CAS Latency */  1787 #define EMC_SDMR_CAS_MASK	(7 << EMC_SDMR_CAS_BIT)  1788   #define EMC_SDMR_CAS_1	(1 << EMC_SDMR_CAS_BIT)  1789   #define EMC_SDMR_CAS_2	(2 << EMC_SDMR_CAS_BIT)  1790   #define EMC_SDMR_CAS_3	(3 << EMC_SDMR_CAS_BIT)  1791 #define EMC_SDMR_BT_BIT		3        /* Burst Type */  1792 #define EMC_SDMR_BT_MASK	(1 << EMC_SDMR_BT_BIT)  1793   #define EMC_SDMR_BT_SEQ	(0 << EMC_SDMR_BT_BIT) /* Sequential */  1794   #define EMC_SDMR_BT_INT	(1 << EMC_SDMR_BT_BIT) /* Interleave */  1795 #define EMC_SDMR_BL_BIT		0        /* Burst Length */  1796 #define EMC_SDMR_BL_MASK	(7 << EMC_SDMR_BL_BIT)  1797   #define EMC_SDMR_BL_1		(0 << EMC_SDMR_BL_BIT)  1798   #define EMC_SDMR_BL_2		(1 << EMC_SDMR_BL_BIT)  1799   #define EMC_SDMR_BL_4		(2 << EMC_SDMR_BL_BIT)  1800   #define EMC_SDMR_BL_8		(3 << EMC_SDMR_BL_BIT)  1801   1802 #define EMC_SDMR_CAS2_16BIT \  1803   (EMC_SDMR_CAS_2 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_2)  1804 #define EMC_SDMR_CAS2_32BIT \  1805   (EMC_SDMR_CAS_2 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_4)  1806 #define EMC_SDMR_CAS3_16BIT \  1807   (EMC_SDMR_CAS_3 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_2)  1808 #define EMC_SDMR_CAS3_32BIT \  1809   (EMC_SDMR_CAS_3 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_4)  1810   1811 /*************************************************************************  1812  * CIM  1813  *************************************************************************/  1814 #define	CIM_CFG			(CIM_BASE + 0x0000)  1815 #define	CIM_CTRL		(CIM_BASE + 0x0004)  1816 #define	CIM_STATE		(CIM_BASE + 0x0008)  1817 #define	CIM_IID			(CIM_BASE + 0x000C)  1818 #define	CIM_RXFIFO		(CIM_BASE + 0x0010)  1819 #define	CIM_DA			(CIM_BASE + 0x0020)  1820 #define	CIM_FA			(CIM_BASE + 0x0024)  1821 #define	CIM_FID			(CIM_BASE + 0x0028)  1822 #define	CIM_CMD			(CIM_BASE + 0x002C)  1823   1824 #define	REG_CIM_CFG		REG32(CIM_CFG)  1825 #define	REG_CIM_CTRL		REG32(CIM_CTRL)  1826 #define	REG_CIM_STATE		REG32(CIM_STATE)  1827 #define	REG_CIM_IID		REG32(CIM_IID)  1828 #define	REG_CIM_RXFIFO		REG32(CIM_RXFIFO)  1829 #define	REG_CIM_DA		REG32(CIM_DA)  1830 #define	REG_CIM_FA		REG32(CIM_FA)  1831 #define	REG_CIM_FID		REG32(CIM_FID)  1832 #define	REG_CIM_CMD		REG32(CIM_CMD)  1833   1834 /* CIM Configuration Register  (CIM_CFG) */  1835   1836 #define	CIM_CFG_INV_DAT		(1 << 15)  1837 #define	CIM_CFG_VSP		(1 << 14)  1838 #define	CIM_CFG_HSP		(1 << 13)  1839 #define	CIM_CFG_PCP		(1 << 12)  1840 #define	CIM_CFG_DUMMY_ZERO	(1 << 9)  1841 #define	CIM_CFG_EXT_VSYNC	(1 << 8)  1842 #define	CIM_CFG_PACK_BIT	4  1843 #define	CIM_CFG_PACK_MASK	(0x7 << CIM_CFG_PACK_BIT)  1844   #define CIM_CFG_PACK_0	  (0 << CIM_CFG_PACK_BIT)  1845   #define CIM_CFG_PACK_1	  (1 << CIM_CFG_PACK_BIT)  1846   #define CIM_CFG_PACK_2	  (2 << CIM_CFG_PACK_BIT)  1847   #define CIM_CFG_PACK_3	  (3 << CIM_CFG_PACK_BIT)  1848   #define CIM_CFG_PACK_4	  (4 << CIM_CFG_PACK_BIT)  1849   #define CIM_CFG_PACK_5	  (5 << CIM_CFG_PACK_BIT)  1850   #define CIM_CFG_PACK_6	  (6 << CIM_CFG_PACK_BIT)  1851   #define CIM_CFG_PACK_7	  (7 << CIM_CFG_PACK_BIT)  1852 #define	CIM_CFG_DSM_BIT		0  1853 #define	CIM_CFG_DSM_MASK	(0x3 << CIM_CFG_DSM_BIT)  1854   #define CIM_CFG_DSM_CPM	  (0 << CIM_CFG_DSM_BIT) /* CCIR656 Progressive Mode */  1855   #define CIM_CFG_DSM_CIM	  (1 << CIM_CFG_DSM_BIT) /* CCIR656 Interlace Mode */  1856   #define CIM_CFG_DSM_GCM	  (2 << CIM_CFG_DSM_BIT) /* Gated Clock Mode */  1857   #define CIM_CFG_DSM_NGCM	  (3 << CIM_CFG_DSM_BIT) /* Non-Gated Clock Mode */  1858   1859 /* CIM Control Register  (CIM_CTRL) */  1860   1861 #define	CIM_CTRL_MCLKDIV_BIT	24  1862 #define	CIM_CTRL_MCLKDIV_MASK	(0xff << CIM_CTRL_MCLKDIV_BIT)  1863 #define	CIM_CTRL_FRC_BIT	16  1864 #define	CIM_CTRL_FRC_MASK	(0xf << CIM_CTRL_FRC_BIT)  1865   #define CIM_CTRL_FRC_1	  (0x0 << CIM_CTRL_FRC_BIT) /* Sample every frame */  1866   #define CIM_CTRL_FRC_2	  (0x1 << CIM_CTRL_FRC_BIT) /* Sample 1/2 frame */  1867   #define CIM_CTRL_FRC_3	  (0x2 << CIM_CTRL_FRC_BIT) /* Sample 1/3 frame */  1868   #define CIM_CTRL_FRC_4	  (0x3 << CIM_CTRL_FRC_BIT) /* Sample 1/4 frame */  1869   #define CIM_CTRL_FRC_5	  (0x4 << CIM_CTRL_FRC_BIT) /* Sample 1/5 frame */  1870   #define CIM_CTRL_FRC_6	  (0x5 << CIM_CTRL_FRC_BIT) /* Sample 1/6 frame */  1871   #define CIM_CTRL_FRC_7	  (0x6 << CIM_CTRL_FRC_BIT) /* Sample 1/7 frame */  1872   #define CIM_CTRL_FRC_8	  (0x7 << CIM_CTRL_FRC_BIT) /* Sample 1/8 frame */  1873   #define CIM_CTRL_FRC_9	  (0x8 << CIM_CTRL_FRC_BIT) /* Sample 1/9 frame */  1874   #define CIM_CTRL_FRC_10	  (0x9 << CIM_CTRL_FRC_BIT) /* Sample 1/10 frame */  1875   #define CIM_CTRL_FRC_11	  (0xA << CIM_CTRL_FRC_BIT) /* Sample 1/11 frame */  1876   #define CIM_CTRL_FRC_12	  (0xB << CIM_CTRL_FRC_BIT) /* Sample 1/12 frame */  1877   #define CIM_CTRL_FRC_13	  (0xC << CIM_CTRL_FRC_BIT) /* Sample 1/13 frame */  1878   #define CIM_CTRL_FRC_14	  (0xD << CIM_CTRL_FRC_BIT) /* Sample 1/14 frame */  1879   #define CIM_CTRL_FRC_15	  (0xE << CIM_CTRL_FRC_BIT) /* Sample 1/15 frame */  1880   #define CIM_CTRL_FRC_16	  (0xF << CIM_CTRL_FRC_BIT) /* Sample 1/16 frame */  1881 #define	CIM_CTRL_VDDM		(1 << 13)  1882 #define	CIM_CTRL_DMA_SOFM	(1 << 12)  1883 #define	CIM_CTRL_DMA_EOFM	(1 << 11)  1884 #define	CIM_CTRL_DMA_STOPM	(1 << 10)  1885 #define	CIM_CTRL_RXF_TRIGM	(1 << 9)  1886 #define	CIM_CTRL_RXF_OFM	(1 << 8)  1887 #define	CIM_CTRL_RXF_TRIG_BIT	4  1888 #define	CIM_CTRL_RXF_TRIG_MASK	(0x7 << CIM_CTRL_RXF_TRIG_BIT)  1889   #define CIM_CTRL_RXF_TRIG_4	  (0 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 4 */  1890   #define CIM_CTRL_RXF_TRIG_8	  (1 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 8 */  1891   #define CIM_CTRL_RXF_TRIG_12	  (2 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 12 */  1892   #define CIM_CTRL_RXF_TRIG_16	  (3 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 16 */  1893   #define CIM_CTRL_RXF_TRIG_20	  (4 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 20 */  1894   #define CIM_CTRL_RXF_TRIG_24	  (5 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 24 */  1895   #define CIM_CTRL_RXF_TRIG_28	  (6 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 28 */  1896   #define CIM_CTRL_RXF_TRIG_32	  (7 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 32 */  1897 #define	CIM_CTRL_DMA_EN		(1 << 2)  1898 #define	CIM_CTRL_RXF_RST	(1 << 1)  1899 #define	CIM_CTRL_ENA		(1 << 0)  1900   1901 /* CIM State Register  (CIM_STATE) */  1902   1903 #define	CIM_STATE_DMA_SOF	(1 << 6)  1904 #define	CIM_STATE_DMA_EOF	(1 << 5)  1905 #define	CIM_STATE_DMA_STOP	(1 << 4)  1906 #define	CIM_STATE_RXF_OF	(1 << 3)  1907 #define	CIM_STATE_RXF_TRIG	(1 << 2)  1908 #define	CIM_STATE_RXF_EMPTY	(1 << 1)  1909 #define	CIM_STATE_VDD		(1 << 0)  1910   1911 /* CIM DMA Command Register (CIM_CMD) */  1912   1913 #define	CIM_CMD_SOFINT		(1 << 31)  1914 #define	CIM_CMD_EOFINT		(1 << 30)  1915 #define	CIM_CMD_STOP		(1 << 28)  1916 #define	CIM_CMD_LEN_BIT		0  1917 #define	CIM_CMD_LEN_MASK	(0xffffff << CIM_CMD_LEN_BIT)  1918   1919   1920 /*************************************************************************  1921  * SADC (Smart A/D Controller)  1922  *************************************************************************/  1923   1924 #define SADC_ENA	(SADC_BASE + 0x00)  /* ADC Enable Register */  1925 #define SADC_CFG	(SADC_BASE + 0x04)  /* ADC Configure Register */  1926 #define SADC_CTRL	(SADC_BASE + 0x08)  /* ADC Control Register */  1927 #define SADC_STATE	(SADC_BASE + 0x0C)  /* ADC Status Register*/  1928 #define SADC_SAMETIME	(SADC_BASE + 0x10)  /* ADC Same Point Time Register */  1929 #define SADC_WAITTIME	(SADC_BASE + 0x14)  /* ADC Wait Time Register */  1930 #define SADC_TSDAT	(SADC_BASE + 0x18)  /* ADC Touch Screen Data Register */  1931 #define SADC_BATDAT	(SADC_BASE + 0x1C)  /* ADC PBAT Data Register */  1932 #define SADC_SADDAT	(SADC_BASE + 0x20)  /* ADC SADCIN Data Register */  1933   1934 #define REG_SADC_ENA		REG8(SADC_ENA)  1935 #define REG_SADC_CFG		REG32(SADC_CFG)  1936 #define REG_SADC_CTRL		REG8(SADC_CTRL)  1937 #define REG_SADC_STATE		REG8(SADC_STATE)  1938 #define REG_SADC_SAMETIME	REG16(SADC_SAMETIME)  1939 #define REG_SADC_WAITTIME	REG16(SADC_WAITTIME)  1940 #define REG_SADC_TSDAT		REG32(SADC_TSDAT)  1941 #define REG_SADC_BATDAT		REG16(SADC_BATDAT)  1942 #define REG_SADC_SADDAT		REG16(SADC_SADDAT)  1943   1944 /* ADC Enable Register */  1945 #define SADC_ENA_ADEN		(1 << 7)  /* Touch Screen Enable */  1946 #define SADC_ENA_TSEN		(1 << 2)  /* Touch Screen Enable */  1947 #define SADC_ENA_PBATEN		(1 << 1)  /* PBAT Enable */  1948 #define SADC_ENA_SADCINEN	(1 << 0)  /* SADCIN Enable */  1949   1950 /* ADC Configure Register */  1951 #define SADC_CFG_CLKOUT_NUM_BIT	16  1952 #define SADC_CFG_CLKOUT_NUM_MASK (0x7 << SADC_CFG_CLKOUT_NUM_BIT)  1953 #define SADC_CFG_TS_DMA		(1 << 15)  /* Touch Screen DMA Enable */  1954 #define SADC_CFG_XYZ_BIT	13  /* XYZ selection */  1955 #define SADC_CFG_XYZ_MASK	(0x3 << SADC_CFG_XYZ_BIT)  1956   #define SADC_CFG_XY		(0 << SADC_CFG_XYZ_BIT)  1957   #define SADC_CFG_XYZ		(1 << SADC_CFG_XYZ_BIT)  1958   #define SADC_CFG_XYZ1Z2	(2 << SADC_CFG_XYZ_BIT)  1959 #define SADC_CFG_SNUM_BIT	10  /* Sample Number */  1960 #define SADC_CFG_SNUM_MASK	(0x7 << SADC_CFG_SNUM_BIT)  1961   #define SADC_CFG_SNUM_1	(0x0 << SADC_CFG_SNUM_BIT)  1962   #define SADC_CFG_SNUM_2	(0x1 << SADC_CFG_SNUM_BIT)  1963   #define SADC_CFG_SNUM_3	(0x2 << SADC_CFG_SNUM_BIT)  1964   #define SADC_CFG_SNUM_4	(0x3 << SADC_CFG_SNUM_BIT)  1965   #define SADC_CFG_SNUM_5	(0x4 << SADC_CFG_SNUM_BIT)  1966   #define SADC_CFG_SNUM_6	(0x5 << SADC_CFG_SNUM_BIT)  1967   #define SADC_CFG_SNUM_8	(0x6 << SADC_CFG_SNUM_BIT)  1968   #define SADC_CFG_SNUM_9	(0x7 << SADC_CFG_SNUM_BIT)  1969 #define SADC_CFG_CLKDIV_BIT	5  /* AD Converter frequency clock divider */  1970 #define SADC_CFG_CLKDIV_MASK	(0x1f << SADC_CFG_CLKDIV_BIT)  1971 #define SADC_CFG_PBAT_HIGH	(0 << 4)  /* PBAT >= 2.5V */  1972 #define SADC_CFG_PBAT_LOW	(1 << 4)  /* PBAT < 2.5V */  1973 #define SADC_CFG_CMD_BIT	0  /* ADC Command */  1974 #define SADC_CFG_CMD_MASK	(0xf << SADC_CFG_CMD_BIT)  1975   #define SADC_CFG_CMD_X_SE	(0x0 << SADC_CFG_CMD_BIT) /* X Single-End */  1976   #define SADC_CFG_CMD_Y_SE	(0x1 << SADC_CFG_CMD_BIT) /* Y Single-End */  1977   #define SADC_CFG_CMD_X_DIFF	(0x2 << SADC_CFG_CMD_BIT) /* X Differential */  1978   #define SADC_CFG_CMD_Y_DIFF	(0x3 << SADC_CFG_CMD_BIT) /* Y Differential */  1979   #define SADC_CFG_CMD_Z1_DIFF	(0x4 << SADC_CFG_CMD_BIT) /* Z1 Differential */  1980   #define SADC_CFG_CMD_Z2_DIFF	(0x5 << SADC_CFG_CMD_BIT) /* Z2 Differential */  1981   #define SADC_CFG_CMD_Z3_DIFF	(0x6 << SADC_CFG_CMD_BIT) /* Z3 Differential */  1982   #define SADC_CFG_CMD_Z4_DIFF	(0x7 << SADC_CFG_CMD_BIT) /* Z4 Differential */  1983   #define SADC_CFG_CMD_TP_SE	(0x8 << SADC_CFG_CMD_BIT) /* Touch Pressure */  1984   #define SADC_CFG_CMD_PBATH_SE	(0x9 << SADC_CFG_CMD_BIT) /* PBAT >= 2.5V */  1985   #define SADC_CFG_CMD_PBATL_SE	(0xa << SADC_CFG_CMD_BIT) /* PBAT < 2.5V */  1986   #define SADC_CFG_CMD_SADCIN_SE (0xb << SADC_CFG_CMD_BIT) /* Measure SADCIN */  1987   #define SADC_CFG_CMD_INT_PEN	(0xc << SADC_CFG_CMD_BIT) /* INT_PEN Enable */  1988   1989 /* ADC Control Register */  1990 #define SADC_CTRL_PENDM		(1 << 4)  /* Pen Down Interrupt Mask */  1991 #define SADC_CTRL_PENUM		(1 << 3)  /* Pen Up Interrupt Mask */  1992 #define SADC_CTRL_TSRDYM	(1 << 2)  /* Touch Screen Data Ready Interrupt Mask */  1993 #define SADC_CTRL_PBATRDYM	(1 << 1)  /* PBAT Data Ready Interrupt Mask */  1994 #define SADC_CTRL_SRDYM		(1 << 0)  /* SADCIN Data Ready Interrupt Mask */  1995   1996 /* ADC Status Register */  1997 #define SADC_STATE_TSBUSY	(1 << 7)  /* TS A/D is working */  1998 #define SADC_STATE_PBATBUSY	(1 << 6)  /* PBAT A/D is working */  1999 #define SADC_STATE_SBUSY	(1 << 5)  /* SADCIN A/D is working */  2000 #define SADC_STATE_PEND		(1 << 4)  /* Pen Down Interrupt Flag */  2001 #define SADC_STATE_PENU		(1 << 3)  /* Pen Up Interrupt Flag */  2002 #define SADC_STATE_TSRDY	(1 << 2)  /* Touch Screen Data Ready Interrupt Flag */  2003 #define SADC_STATE_PBATRDY	(1 << 1)  /* PBAT Data Ready Interrupt Flag */  2004 #define SADC_STATE_SRDY		(1 << 0)  /* SADCIN Data Ready Interrupt Flag */  2005   2006 /* ADC Touch Screen Data Register */  2007 #define SADC_TSDAT_DATA0_BIT	0  2008 #define SADC_TSDAT_DATA0_MASK	(0xfff << SADC_TSDAT_DATA0_BIT)  2009 #define SADC_TSDAT_TYPE0	(1 << 15)  2010 #define SADC_TSDAT_DATA1_BIT	16  2011 #define SADC_TSDAT_DATA1_MASK	(0xfff << SADC_TSDAT_DATA1_BIT)  2012 #define SADC_TSDAT_TYPE1	(1 << 31)  2013   2014   2015 /*************************************************************************  2016  * SLCD (Smart LCD Controller)  2017  *************************************************************************/  2018   2019 #define SLCD_CFG	(SLCD_BASE + 0xA0)  /* SLCD Configure Register */  2020 #define SLCD_CTRL	(SLCD_BASE + 0xA4)  /* SLCD Control Register */  2021 #define SLCD_STATE	(SLCD_BASE + 0xA8)  /* SLCD Status Register */  2022 #define SLCD_DATA	(SLCD_BASE + 0xAC)  /* SLCD Data Register */  2023 #define SLCD_FIFO	(SLCD_BASE + 0xB0)  /* SLCD FIFO Register */  2024   2025 #define REG_SLCD_CFG	REG32(SLCD_CFG)  2026 #define REG_SLCD_CTRL	REG8(SLCD_CTRL)  2027 #define REG_SLCD_STATE	REG8(SLCD_STATE)  2028 #define REG_SLCD_DATA	REG32(SLCD_DATA)  2029 #define REG_SLCD_FIFO	REG32(SLCD_FIFO)  2030   2031 /* SLCD Configure Register */  2032 #define SLCD_CFG_BURST_BIT	14  2033 #define SLCD_CFG_BURST_MASK	(0x3 << SLCD_CFG_BURST_BIT)  2034   #define SLCD_CFG_BURST_4_WORD	(0 << SLCD_CFG_BURST_BIT)  2035   #define SLCD_CFG_BURST_8_WORD	(1 << SLCD_CFG_BURST_BIT)  2036 #define SLCD_CFG_DWIDTH_BIT	10  2037 #define SLCD_CFG_DWIDTH_MASK	(0x7 << SLCD_CFG_DWIDTH_BIT)  2038   #define SLCD_CFG_DWIDTH_18	(0 << SLCD_CFG_DWIDTH_BIT)  2039   #define SLCD_CFG_DWIDTH_16	(1 << SLCD_CFG_DWIDTH_BIT)  2040   #define SLCD_CFG_DWIDTH_8_x3	(2 << SLCD_CFG_DWIDTH_BIT)  2041   #define SLCD_CFG_DWIDTH_8_x2	(3 << SLCD_CFG_DWIDTH_BIT)  2042   #define SLCD_CFG_DWIDTH_8_x1	(4 << SLCD_CFG_DWIDTH_BIT)  2043   #define SLCD_CFG_DWIDTH_9_x2	(4 << SLCD_CFG_DWIDTH_BIT)  2044 #define SLCD_CFG_CWIDTH_16BIT	(0 << 8)  2045 #define SLCD_CFG_CWIDTH_8BIT	(1 << 8)  2046 #define SLCD_CFG_CWIDTH_18BIT	(2 << 8)  2047 #define SLCD_CFG_CS_ACTIVE_LOW	(0 << 4)  2048 #define SLCD_CFG_CS_ACTIVE_HIGH	(1 << 4)  2049 #define SLCD_CFG_RS_CMD_LOW	(0 << 3)  2050 #define SLCD_CFG_RS_CMD_HIGH	(1 << 3)  2051 #define SLCD_CFG_CLK_ACTIVE_FALLING	(0 << 1)  2052 #define SLCD_CFG_CLK_ACTIVE_RISING	(1 << 1)  2053 #define SLCD_CFG_TYPE_PARALLEL	(0 << 0)  2054 #define SLCD_CFG_TYPE_SERIAL	(1 << 0)  2055   2056 /* SLCD Control Register */  2057 #define SLCD_CTRL_DMA_EN	(1 << 0)  2058   2059 /* SLCD Status Register */  2060 #define SLCD_STATE_BUSY		(1 << 0)  2061   2062 /* SLCD Data Register */  2063 #define SLCD_DATA_RS_DATA	(0 << 31)  2064 #define SLCD_DATA_RS_COMMAND	(1 << 31)  2065   2066 /* SLCD FIFO Register */  2067 #define SLCD_FIFO_RS_DATA	(0 << 31)  2068 #define SLCD_FIFO_RS_COMMAND	(1 << 31)  2069   2070   2071 /*************************************************************************  2072  * LCD (LCD Controller)  2073  *************************************************************************/  2074 #define LCD_CFG		(LCD_BASE + 0x00) /* LCD Configure Register */  2075 #define LCD_VSYNC	(LCD_BASE + 0x04) /* Vertical Synchronize Register */  2076 #define LCD_HSYNC	(LCD_BASE + 0x08) /* Horizontal Synchronize Register */  2077 #define LCD_VAT		(LCD_BASE + 0x0c) /* Virtual Area Setting Register */  2078 #define LCD_DAH		(LCD_BASE + 0x10) /* Display Area Horizontal Start/End Point */  2079 #define LCD_DAV		(LCD_BASE + 0x14) /* Display Area Vertical Start/End Point */  2080 #define LCD_PS		(LCD_BASE + 0x18) /* PS Signal Setting */  2081 #define LCD_CLS		(LCD_BASE + 0x1c) /* CLS Signal Setting */  2082 #define LCD_SPL		(LCD_BASE + 0x20) /* SPL Signal Setting */  2083 #define LCD_REV		(LCD_BASE + 0x24) /* REV Signal Setting */  2084 #define LCD_CTRL	(LCD_BASE + 0x30) /* LCD Control Register */  2085 #define LCD_STATE	(LCD_BASE + 0x34) /* LCD Status Register */  2086 #define LCD_IID		(LCD_BASE + 0x38) /* Interrupt ID Register */  2087 #define LCD_DA0		(LCD_BASE + 0x40) /* Descriptor Address Register 0 */  2088 #define LCD_SA0		(LCD_BASE + 0x44) /* Source Address Register 0 */  2089 #define LCD_FID0	(LCD_BASE + 0x48) /* Frame ID Register 0 */  2090 #define LCD_CMD0	(LCD_BASE + 0x4c) /* DMA Command Register 0 */  2091 #define LCD_DA1		(LCD_BASE + 0x50) /* Descriptor Address Register 1 */  2092 #define LCD_SA1		(LCD_BASE + 0x54) /* Source Address Register 1 */  2093 #define LCD_FID1	(LCD_BASE + 0x58) /* Frame ID Register 1 */  2094 #define LCD_CMD1	(LCD_BASE + 0x5c) /* DMA Command Register 1 */  2095   2096 #define REG_LCD_CFG	REG32(LCD_CFG)  2097 #define REG_LCD_VSYNC	REG32(LCD_VSYNC)  2098 #define REG_LCD_HSYNC	REG32(LCD_HSYNC)  2099 #define REG_LCD_VAT	REG32(LCD_VAT)  2100 #define REG_LCD_DAH	REG32(LCD_DAH)  2101 #define REG_LCD_DAV	REG32(LCD_DAV)  2102 #define REG_LCD_PS	REG32(LCD_PS)  2103 #define REG_LCD_CLS	REG32(LCD_CLS)  2104 #define REG_LCD_SPL	REG32(LCD_SPL)  2105 #define REG_LCD_REV	REG32(LCD_REV)  2106 #define REG_LCD_CTRL	REG32(LCD_CTRL)  2107 #define REG_LCD_STATE	REG32(LCD_STATE)  2108 #define REG_LCD_IID	REG32(LCD_IID)  2109 #define REG_LCD_DA0	REG32(LCD_DA0)  2110 #define REG_LCD_SA0	REG32(LCD_SA0)  2111 #define REG_LCD_FID0	REG32(LCD_FID0)  2112 #define REG_LCD_CMD0	REG32(LCD_CMD0)  2113 #define REG_LCD_DA1	REG32(LCD_DA1)  2114 #define REG_LCD_SA1	REG32(LCD_SA1)  2115 #define REG_LCD_FID1	REG32(LCD_FID1)  2116 #define REG_LCD_CMD1	REG32(LCD_CMD1)  2117   2118 /* LCD Configure Register */  2119 #define LCD_CFG_LCDPIN_BIT	31  /* LCD pins selection */  2120 #define LCD_CFG_LCDPIN_MASK	(0x1 << LCD_CFG_LCDPIN_BIT)  2121   #define LCD_CFG_LCDPIN_LCD	(0x0 << LCD_CFG_LCDPIN_BIT)  2122   #define LCD_CFG_LCDPIN_SLCD	(0x1 << LCD_CFG_LCDPIN_BIT)  2123 #define LCD_CFG_PSM		(1 << 23) /* PS signal mode */  2124 #define LCD_CFG_CLSM		(1 << 22) /* CLS signal mode */  2125 #define LCD_CFG_SPLM		(1 << 21) /* SPL signal mode */  2126 #define LCD_CFG_REVM		(1 << 20) /* REV signal mode */  2127 #define LCD_CFG_HSYNM		(1 << 19) /* HSYNC signal mode */  2128 #define LCD_CFG_PCLKM		(1 << 18) /* PCLK signal mode */  2129 #define LCD_CFG_INVDAT		(1 << 17) /* Inverse output data */  2130 #define LCD_CFG_SYNDIR_IN	(1 << 16) /* VSYNC&HSYNC direction */  2131 #define LCD_CFG_PSP		(1 << 15) /* PS pin reset state */  2132 #define LCD_CFG_CLSP		(1 << 14) /* CLS pin reset state */  2133 #define LCD_CFG_SPLP		(1 << 13) /* SPL pin reset state */  2134 #define LCD_CFG_REVP		(1 << 12) /* REV pin reset state */  2135 #define LCD_CFG_HSP		(1 << 11) /* HSYNC pority:0-active high,1-active low */  2136 #define LCD_CFG_PCP		(1 << 10) /* PCLK pority:0-rising,1-falling */  2137 #define LCD_CFG_DEP		(1 << 9)  /* DE pority:0-active high,1-active low */  2138 #define LCD_CFG_VSP		(1 << 8)  /* VSYNC pority:0-rising,1-falling */  2139 #define LCD_CFG_PDW_BIT		4  /* STN pins utilization */  2140 #define LCD_CFG_PDW_MASK	(0x3 << LCD_DEV_PDW_BIT)  2141 #define LCD_CFG_PDW_1		(0 << LCD_CFG_PDW_BIT) /* LCD_D[0] */  2142   #define LCD_CFG_PDW_2		(1 << LCD_CFG_PDW_BIT) /* LCD_D[0:1] */  2143   #define LCD_CFG_PDW_4		(2 << LCD_CFG_PDW_BIT) /* LCD_D[0:3]/LCD_D[8:11] */  2144   #define LCD_CFG_PDW_8		(3 << LCD_CFG_PDW_BIT) /* LCD_D[0:7]/LCD_D[8:15] */  2145 #define LCD_CFG_MODE_BIT	0  /* Display Device Mode Select */  2146 #define LCD_CFG_MODE_MASK	(0x0f << LCD_CFG_MODE_BIT)  2147   #define LCD_CFG_MODE_GENERIC_TFT	(0 << LCD_CFG_MODE_BIT) /* 16,18 bit TFT */  2148   #define LCD_CFG_MODE_SPECIAL_TFT_1	(1 << LCD_CFG_MODE_BIT)  2149   #define LCD_CFG_MODE_SPECIAL_TFT_2	(2 << LCD_CFG_MODE_BIT)  2150   #define LCD_CFG_MODE_SPECIAL_TFT_3	(3 << LCD_CFG_MODE_BIT)  2151   #define LCD_CFG_MODE_NONINTER_CCIR656	(4 << LCD_CFG_MODE_BIT)  2152   #define LCD_CFG_MODE_INTER_CCIR656	(5 << LCD_CFG_MODE_BIT)  2153   #define LCD_CFG_MODE_SINGLE_CSTN	(8 << LCD_CFG_MODE_BIT)  2154   #define LCD_CFG_MODE_SINGLE_MSTN	(9 << LCD_CFG_MODE_BIT)  2155   #define LCD_CFG_MODE_DUAL_CSTN	(10 << LCD_CFG_MODE_BIT)  2156   #define LCD_CFG_MODE_DUAL_MSTN	(11 << LCD_CFG_MODE_BIT)  2157   #define LCD_CFG_MODE_SERIAL_TFT	(12 << LCD_CFG_MODE_BIT)  2158   #define LCD_CFG_MODE_GENERIC_18BIT_TFT  (13 << LCD_CFG_MODE_BIT)  2159   /* JZ47XX defines */  2160   #define LCD_CFG_MODE_SHARP_HR		(1 << LCD_CFG_MODE_BIT)  2161   #define LCD_CFG_MODE_CASIO_TFT	(2 << LCD_CFG_MODE_BIT)  2162   #define LCD_CFG_MODE_SAMSUNG_ALPHA	(3 << LCD_CFG_MODE_BIT)  2163   2164   2165   2166 /* Vertical Synchronize Register */  2167 #define LCD_VSYNC_VPS_BIT	16  /* VSYNC pulse start in line clock, fixed to 0 */  2168 #define LCD_VSYNC_VPS_MASK	(0xffff << LCD_VSYNC_VPS_BIT)  2169 #define LCD_VSYNC_VPE_BIT	0   /* VSYNC pulse end in line clock */  2170 #define LCD_VSYNC_VPE_MASK	(0xffff << LCD_VSYNC_VPS_BIT)  2171   2172 /* Horizontal Synchronize Register */  2173 #define LCD_HSYNC_HPS_BIT	16  /* HSYNC pulse start position in dot clock */  2174 #define LCD_HSYNC_HPS_MASK	(0xffff << LCD_HSYNC_HPS_BIT)  2175 #define LCD_HSYNC_HPE_BIT	0   /* HSYNC pulse end position in dot clock */  2176 #define LCD_HSYNC_HPE_MASK	(0xffff << LCD_HSYNC_HPE_BIT)  2177   2178 /* Virtual Area Setting Register */  2179 #define LCD_VAT_HT_BIT		16  /* Horizontal Total size in dot clock */  2180 #define LCD_VAT_HT_MASK		(0xffff << LCD_VAT_HT_BIT)  2181 #define LCD_VAT_VT_BIT		0   /* Vertical Total size in dot clock */  2182 #define LCD_VAT_VT_MASK		(0xffff << LCD_VAT_VT_BIT)  2183   2184 /* Display Area Horizontal Start/End Point Register */  2185 #define LCD_DAH_HDS_BIT		16  /* Horizontal display area start in dot clock */  2186 #define LCD_DAH_HDS_MASK	(0xffff << LCD_DAH_HDS_BIT)  2187 #define LCD_DAH_HDE_BIT		0   /* Horizontal display area end in dot clock */  2188 #define LCD_DAH_HDE_MASK	(0xffff << LCD_DAH_HDE_BIT)  2189   2190 /* Display Area Vertical Start/End Point Register */  2191 #define LCD_DAV_VDS_BIT		16  /* Vertical display area start in line clock */  2192 #define LCD_DAV_VDS_MASK	(0xffff << LCD_DAV_VDS_BIT)  2193 #define LCD_DAV_VDE_BIT		0   /* Vertical display area end in line clock */  2194 #define LCD_DAV_VDE_MASK	(0xffff << LCD_DAV_VDE_BIT)  2195   2196 /* PS Signal Setting */  2197 #define LCD_PS_PSS_BIT		16  /* PS signal start position in dot clock */  2198 #define LCD_PS_PSS_MASK		(0xffff << LCD_PS_PSS_BIT)  2199 #define LCD_PS_PSE_BIT		0   /* PS signal end position in dot clock */  2200 #define LCD_PS_PSE_MASK		(0xffff << LCD_PS_PSE_BIT)  2201   2202 /* CLS Signal Setting */  2203 #define LCD_CLS_CLSS_BIT	16  /* CLS signal start position in dot clock */  2204 #define LCD_CLS_CLSS_MASK	(0xffff << LCD_CLS_CLSS_BIT)  2205 #define LCD_CLS_CLSE_BIT	0   /* CLS signal end position in dot clock */  2206 #define LCD_CLS_CLSE_MASK	(0xffff << LCD_CLS_CLSE_BIT)  2207   2208 /* SPL Signal Setting */  2209 #define LCD_SPL_SPLS_BIT	16  /* SPL signal start position in dot clock */  2210 #define LCD_SPL_SPLS_MASK	(0xffff << LCD_SPL_SPLS_BIT)  2211 #define LCD_SPL_SPLE_BIT	0   /* SPL signal end position in dot clock */  2212 #define LCD_SPL_SPLE_MASK	(0xffff << LCD_SPL_SPLE_BIT)  2213   2214 /* REV Signal Setting */  2215 #define LCD_REV_REVS_BIT	16  /* REV signal start position in dot clock */  2216 #define LCD_REV_REVS_MASK	(0xffff << LCD_REV_REVS_BIT)  2217   2218 /* LCD Control Register */  2219 #define LCD_CTRL_BST_BIT	28  /* Burst Length Selection */  2220 #define LCD_CTRL_BST_MASK	(0x03 << LCD_CTRL_BST_BIT)  2221   #define LCD_CTRL_BST_4	(0 << LCD_CTRL_BST_BIT) /* 4-word */  2222   #define LCD_CTRL_BST_8	(1 << LCD_CTRL_BST_BIT) /* 8-word */  2223   #define LCD_CTRL_BST_16	(2 << LCD_CTRL_BST_BIT) /* 16-word */  2224 #define LCD_CTRL_RGB565		(0 << 27) /* RGB565 mode */  2225 #define LCD_CTRL_RGB555		(1 << 27) /* RGB555 mode */  2226 #define LCD_CTRL_OFUP		(1 << 26) /* Output FIFO underrun protection enable */  2227 #define LCD_CTRL_FRC_BIT	24  /* STN FRC Algorithm Selection */  2228 #define LCD_CTRL_FRC_MASK	(0x03 << LCD_CTRL_FRC_BIT)  2229   #define LCD_CTRL_FRC_16	(0 << LCD_CTRL_FRC_BIT) /* 16 grayscale */  2230   #define LCD_CTRL_FRC_4	(1 << LCD_CTRL_FRC_BIT) /* 4 grayscale */  2231   #define LCD_CTRL_FRC_2	(2 << LCD_CTRL_FRC_BIT) /* 2 grayscale */  2232 #define LCD_CTRL_PDD_BIT	16  /* Load Palette Delay Counter */  2233 #define LCD_CTRL_PDD_MASK	(0xff << LCD_CTRL_PDD_BIT)  2234 #define LCD_CTRL_EOFM		(1 << 13) /* EOF interrupt mask */  2235 #define LCD_CTRL_SOFM		(1 << 12) /* SOF interrupt mask */  2236 #define LCD_CTRL_OFUM		(1 << 11) /* Output FIFO underrun interrupt mask */  2237 #define LCD_CTRL_IFUM0		(1 << 10) /* Input FIFO 0 underrun interrupt mask */  2238 #define LCD_CTRL_IFUM1		(1 << 9)  /* Input FIFO 1 underrun interrupt mask */  2239 #define LCD_CTRL_LDDM		(1 << 8)  /* LCD disable done interrupt mask */  2240 #define LCD_CTRL_QDM		(1 << 7)  /* LCD quick disable done interrupt mask */  2241 #define LCD_CTRL_BEDN		(1 << 6)  /* Endian selection */  2242 #define LCD_CTRL_PEDN		(1 << 5)  /* Endian in byte:0-msb first, 1-lsb first */  2243 #define LCD_CTRL_DIS		(1 << 4)  /* Disable indicate bit */  2244 #define LCD_CTRL_ENA		(1 << 3)  /* LCD enable bit */  2245 #define LCD_CTRL_BPP_BIT	0  /* Bits Per Pixel */  2246 #define LCD_CTRL_BPP_MASK	(0x07 << LCD_CTRL_BPP_BIT)  2247   #define LCD_CTRL_BPP_1	(0 << LCD_CTRL_BPP_BIT) /* 1 bpp */  2248   #define LCD_CTRL_BPP_2	(1 << LCD_CTRL_BPP_BIT) /* 2 bpp */  2249   #define LCD_CTRL_BPP_4	(2 << LCD_CTRL_BPP_BIT) /* 4 bpp */  2250   #define LCD_CTRL_BPP_8	(3 << LCD_CTRL_BPP_BIT) /* 8 bpp */  2251   #define LCD_CTRL_BPP_16	(4 << LCD_CTRL_BPP_BIT) /* 15/16 bpp */  2252   #define LCD_CTRL_BPP_18_24	(5 << LCD_CTRL_BPP_BIT) /* 18/24/32 bpp */  2253   2254 /* LCD Status Register */  2255 #define LCD_STATE_QD		(1 << 7) /* Quick Disable Done */  2256 #define LCD_STATE_EOF		(1 << 5) /* EOF Flag */  2257 #define LCD_STATE_SOF		(1 << 4) /* SOF Flag */  2258 #define LCD_STATE_OFU		(1 << 3) /* Output FIFO Underrun */  2259 #define LCD_STATE_IFU0		(1 << 2) /* Input FIFO 0 Underrun */  2260 #define LCD_STATE_IFU1		(1 << 1) /* Input FIFO 1 Underrun */  2261 #define LCD_STATE_LDD		(1 << 0) /* LCD Disabled */  2262   2263 /* DMA Command Register */  2264 #define LCD_CMD_SOFINT		(1 << 31)  2265 #define LCD_CMD_EOFINT		(1 << 30)  2266 #define LCD_CMD_PAL		(1 << 28)  2267 #define LCD_CMD_LEN_BIT		0  2268 #define LCD_CMD_LEN_MASK	(0xffffff << LCD_CMD_LEN_BIT)  2269   2270   2271 /*************************************************************************  2272  * USB Device  2273  *************************************************************************/  2274 #define USB_BASE  UDC_BASE  2275   2276 #define USB_REG_FADDR		(USB_BASE + 0x00) /* Function Address 8-bit */  2277 #define USB_REG_POWER		(USB_BASE + 0x01) /* Power Managemetn 8-bit */  2278 #define USB_REG_INTRIN		(USB_BASE + 0x02) /* Interrupt IN 16-bit */  2279 #define USB_REG_INTROUT		(USB_BASE + 0x04) /* Interrupt OUT 16-bit */  2280 #define USB_REG_INTRINE		(USB_BASE + 0x06) /* Intr IN enable 16-bit */  2281 #define USB_REG_INTROUTE	(USB_BASE + 0x08) /* Intr OUT enable 16-bit */  2282 #define USB_REG_INTRUSB		(USB_BASE + 0x0a) /* Interrupt USB 8-bit */  2283 #define USB_REG_INTRUSBE	(USB_BASE + 0x0b) /* Interrupt USB Enable 8-bit */  2284 #define USB_REG_FRAME		(USB_BASE + 0x0c) /* Frame number 16-bit */  2285 #define USB_REG_INDEX		(USB_BASE + 0x0e) /* Index register 8-bit */  2286 #define USB_REG_TESTMODE	(USB_BASE + 0x0f) /* USB test mode 8-bit */  2287   2288 #define USB_REG_CSR0		(USB_BASE + 0x12) /* EP0 CSR 8-bit */  2289 #define USB_REG_INMAXP		(USB_BASE + 0x10) /* EP1-2 IN Max Pkt Size 16-bit */  2290 #define USB_REG_INCSR		(USB_BASE + 0x12) /* EP1-2 IN CSR LSB 8/16bit */  2291 #define USB_REG_INCSRH		(USB_BASE + 0x13) /* EP1-2 IN CSR MSB 8-bit */  2292 #define USB_REG_OUTMAXP		(USB_BASE + 0x14) /* EP1 OUT Max Pkt Size 16-bit */  2293 #define USB_REG_OUTCSR		(USB_BASE + 0x16) /* EP1 OUT CSR LSB 8/16bit */  2294 #define USB_REG_OUTCSRH		(USB_BASE + 0x17) /* EP1 OUT CSR MSB 8-bit */  2295 #define USB_REG_OUTCOUNT	(USB_BASE + 0x18) /* bytes in EP0/1 OUT FIFO 16-bit */  2296   2297 #define USB_FIFO_EP0		(USB_BASE + 0x20)  2298 #define USB_FIFO_EP1		(USB_BASE + 0x24)  2299 #define USB_FIFO_EP2		(USB_BASE + 0x28)  2300   2301 #define USB_REG_EPINFO		(USB_BASE + 0x78) /* Endpoint information */  2302 #define USB_REG_RAMINFO		(USB_BASE + 0x79) /* RAM information */  2303   2304 #define USB_REG_INTR		(USB_BASE + 0x200) /* DMA pending interrupts */  2305 #define USB_REG_CNTL1		(USB_BASE + 0x204) /* DMA channel 1 control */  2306 #define USB_REG_ADDR1		(USB_BASE + 0x208) /* DMA channel 1 AHB memory addr */  2307 #define USB_REG_COUNT1		(USB_BASE + 0x20c) /* DMA channel 1 byte count */  2308 #define USB_REG_CNTL2		(USB_BASE + 0x214) /* DMA channel 2 control */  2309 #define USB_REG_ADDR2		(USB_BASE + 0x218) /* DMA channel 2 AHB memory addr */  2310 #define USB_REG_COUNT2		(USB_BASE + 0x21c) /* DMA channel 2 byte count */  2311   2312   2313 /* Power register bit masks */  2314 #define USB_POWER_SUSPENDM	0x01  2315 #define USB_POWER_RESUME	0x04  2316 #define USB_POWER_HSMODE	0x10  2317 #define USB_POWER_HSENAB	0x20  2318 #define USB_POWER_SOFTCONN	0x40  2319   2320 /* Interrupt register bit masks */  2321 #define USB_INTR_SUSPEND	0x01  2322 #define USB_INTR_RESUME		0x02  2323 #define USB_INTR_RESET		0x04  2324   2325 #define USB_INTR_EP0		0x0001  2326 #define USB_INTR_INEP1		0x0002  2327 #define USB_INTR_INEP2		0x0004  2328 #define USB_INTR_OUTEP1		0x0002  2329   2330 /* CSR0 bit masks */  2331 #define USB_CSR0_OUTPKTRDY	0x01  2332 #define USB_CSR0_INPKTRDY	0x02  2333 #define USB_CSR0_SENTSTALL	0x04  2334 #define USB_CSR0_DATAEND	0x08  2335 #define USB_CSR0_SETUPEND	0x10  2336 #define USB_CSR0_SENDSTALL	0x20  2337 #define USB_CSR0_SVDOUTPKTRDY	0x40  2338 #define USB_CSR0_SVDSETUPEND	0x80  2339   2340 /* Endpoint CSR register bits */  2341 #define USB_INCSRH_AUTOSET	0x80  2342 #define USB_INCSRH_ISO		0x40  2343 #define USB_INCSRH_MODE		0x20  2344 #define USB_INCSRH_DMAREQENAB	0x10  2345 #define USB_INCSRH_DMAREQMODE	0x04  2346 #define USB_INCSR_CDT		0x40  2347 #define USB_INCSR_SENTSTALL	0x20  2348 #define USB_INCSR_SENDSTALL	0x10  2349 #define USB_INCSR_FF		0x08  2350 #define USB_INCSR_UNDERRUN	0x04  2351 #define USB_INCSR_FFNOTEMPT	0x02  2352 #define USB_INCSR_INPKTRDY	0x01  2353 #define USB_OUTCSRH_AUTOCLR	0x80  2354 #define USB_OUTCSRH_ISO		0x40  2355 #define USB_OUTCSRH_DMAREQENAB	0x20  2356 #define USB_OUTCSRH_DNYT	0x10  2357 #define USB_OUTCSRH_DMAREQMODE	0x08  2358 #define USB_OUTCSR_CDT		0x80  2359 #define USB_OUTCSR_SENTSTALL	0x40  2360 #define USB_OUTCSR_SENDSTALL	0x20  2361 #define USB_OUTCSR_FF		0x10  2362 #define USB_OUTCSR_DATAERR	0x08  2363 #define USB_OUTCSR_OVERRUN	0x04  2364 #define USB_OUTCSR_FFFULL	0x02  2365 #define USB_OUTCSR_OUTPKTRDY	0x01  2366   2367 /* Testmode register bits */  2368 #define USB_TEST_SE0NAK		0x01  2369 #define USB_TEST_J		0x02  2370 #define USB_TEST_K		0x04  2371 #define USB_TEST_PACKET		0x08  2372   2373 /* DMA control bits */  2374 #define USB_CNTL_ENA		0x01  2375 #define USB_CNTL_DIR_IN		0x02  2376 #define USB_CNTL_MODE_1		0x04  2377 #define USB_CNTL_INTR_EN	0x08  2378 #define USB_CNTL_EP(n)		((n) << 4)  2379 #define USB_CNTL_BURST_0	(0 << 9)  2380 #define USB_CNTL_BURST_4	(1 << 9)  2381 #define USB_CNTL_BURST_8	(2 << 9)  2382 #define USB_CNTL_BURST_16	(3 << 9)  2383   2384   2385   2386 /* Module Operation Definitions */  2387 #ifndef __ASSEMBLY__  2388   2389   2390 /* GPIO Pins Description */  2391 /* PORT 0: */  2392 /* PIN/BIT N		FUNC0		FUNC1 */  2393 /*	0		D0		- */  2394 /*	1		D1		- */  2395 /*	2		D2		- */  2396 /*	3		D3		- */  2397 /*	4		D4		- */  2398 /*	5		D5		- */  2399 /*	6		D6		- */  2400 /*	7		D7		- */  2401 /*	8		D8		- */  2402 /*	9		D9		- */  2403 /*	10		D10		- */  2404 /*	11		D11		- */  2405 /*	12		D12		- */  2406 /*	13		D13		- */  2407 /*	14		D14		- */  2408 /*	15		D15		- */  2409 /*	16		D16		- */  2410 /*	17		D17		- */  2411 /*	18		D18		- */  2412 /*	19		D19		- */  2413 /*	20		D20		- */  2414 /*	21		D21		- */  2415 /*	22		D22		- */  2416 /*	23		D23		- */  2417 /*	24		D24		- */  2418 /*	25		D25		- */  2419 /*	26		D26		- */  2420 /*	27		D27		- */  2421 /*	28		D28		- */  2422 /*	29		D29		- */  2423 /*	30		D30		- */  2424 /*	31		D31		- */  2425 /*------------------------------------------------------ */  2426 /* PORT 1: */  2427 /* */  2428 /* PIN/BIT N		FUNC0		FUNC1 */  2429 /*	0		A0		- */  2430 /*	1		A1		- */  2431 /*	2		A2		- */  2432 /*	3		A3		- */  2433 /*	4		A4		- */  2434 /*	5		A5		- */  2435 /*	6		A6		- */  2436 /*	7		A7		- */  2437 /*	8		A8		- */  2438 /*	9		A9		- */  2439 /*	10		A10		- */  2440 /*	11		A11		- */  2441 /*	12		A12		- */  2442 /*	13		A13		- */  2443 /*	14		A14		- */  2444 /*	15		A15/CL		- */  2445 /*	16		A16/AL		- */  2446 /*	17		LCD_CLS		A21 */  2447 /*	18		LCD_SPL		A22 */  2448 /*	19		DCS#		- */  2449 /*	20		RAS#		- */  2450 /*	21		CAS#		- */  2451 /*	22		RDWE#/BUFD#	- */  2452 /*	23		CKE		- */  2453 /*	24		CKO		- */  2454 /*	25		CS1#		- */  2455 /*	26		CS2#		- */  2456 /*	27		CS3#		- */  2457 /*	28		CS4#		- */  2458 /*	29		RD#		- */  2459 /*	30		WR#		- */  2460 /*	31		WE0#		- */  2461 /* Note: PIN15&16 are CL&AL when connecting to NAND flash. */  2462 /*------------------------------------------------------ */  2463 /* PORT 2: */  2464 /* */  2465 /* PIN/BIT N		FUNC0		FUNC1 */  2466 /*	0		LCD_D0		- */  2467 /*	1		LCD_D1		- */  2468 /*	2		LCD_D2		- */  2469 /*	3		LCD_D3		- */  2470 /*	4		LCD_D4		- */  2471 /*	5		LCD_D5		- */  2472 /*	6		LCD_D6		- */  2473 /*	7		LCD_D7		- */  2474 /*	8		LCD_D8		- */  2475 /*	9		LCD_D9		- */  2476 /*	10		LCD_D10		- */  2477 /*	11		LCD_D11		- */  2478 /*	12		LCD_D12		- */  2479 /*	13		LCD_D13		- */  2480 /*	14		LCD_D14		- */  2481 /*	15		LCD_D15		- */  2482 /*	16		LCD_D16		- */  2483 /*	17		LCD_D17		- */  2484 /*	18		LCD_PCLK	- */  2485 /*	19		LCD_HSYNC	- */  2486 /*	20		LCD_VSYNC	- */  2487 /*	21		LCD_DE		- */  2488 /*	22		LCD_PS		A19 */  2489 /*	23		LCD_REV		A20 */  2490 /*	24		WE1#		- */  2491 /*	25		WE2#		- */  2492 /*	26		WE3#		- */  2493 /*	27		WAIT#		- */  2494 /*	28		FRE#		- */  2495 /*	29		FWE#		- */  2496 /*	30(NOTE:FRB#)	-		- */  2497 /*	31		-		- */  2498 /* NOTE(1): PIN30 is used for FRB# when connecting to NAND flash. */  2499 /*------------------------------------------------------ */  2500 /* PORT 3: */  2501 /* */  2502 /* PIN/BIT N		FUNC0		FUNC1 */  2503 /*	0		CIM_D0		- */  2504 /*	1		CIM_D1		- */  2505 /*	2		CIM_D2		- */  2506 /*	3		CIM_D3		- */  2507 /*	4		CIM_D4		- */  2508 /*	5		CIM_D5		- */  2509 /*	6		CIM_D6		- */  2510 /*	7		CIM_D7		- */  2511 /*	8		MSC_CMD		- */  2512 /*	9		MSC_CLK		- */  2513 /*	10		MSC_D0		- */  2514 /*	11		MSC_D1		- */  2515 /*	12		MSC_D2		- */  2516 /*	13		MSC_D3		- */  2517 /*	14		CIM_MCLK	- */  2518 /*	15		CIM_PCLK	- */  2519 /*	16		CIM_VSYNC	- */  2520 /*	17		CIM_HSYNC	- */  2521 /*	18		SSI_CLK		SCLK_RSTN */  2522 /*	19		SSI_CE0#	BIT_CLK(AIC) */  2523 /*	20		SSI_DT		SDATA_OUT(AIC) */  2524 /*	21		SSI_DR		SDATA_IN(AIC) */  2525 /*	22		SSI_CE1#&GPC	SYNC(AIC) */  2526 /*	23		PWM0		I2C_SDA */  2527 /*	24		PWM1		I2C_SCK */  2528 /*	25		PWM2		UART0_TxD */  2529 /*	26		PWM3		UART0_RxD */  2530 /*	27		PWM4		A17 */  2531 /*	28		PWM5		A18 */  2532 /*	29		-		- */  2533 /*	30		PWM6		UART0_CTS/UART1_RxD */  2534 /*	31		PWM7		UART0_RTS/UART1_TxD */  2535 /*   2536  * p is the port number (0,1,2,3)  2537  * o is the pin offset (0-31) inside the port  2538  * n is the absolute number of a pin (0-127), regardless of the port  2539  */  2540   2541 /* Function Pins Mode */  2542   2543 #define __gpio_as_func0(n)			\  2544 do {						\  2545 	unsigned int p, o;			\  2546 	p = (n) / 32;				\  2547 	o = (n) % 32;				\  2548 	REG_GPIO_PXFUNS(p) = (1 << o);		\  2549 	REG_GPIO_PXSELC(p) = (1 << o);		\  2550 } while (0)  2551   2552 #define __gpio_as_func1(n)			\  2553 do {						\  2554 	unsigned int p, o;			\  2555 	p = (n) / 32;				\  2556 	o = (n) % 32;				\  2557 	REG_GPIO_PXFUNS(p) = (1 << o);		\  2558 	REG_GPIO_PXSELS(p) = (1 << o);		\  2559 } while (0)  2560   2561 /*  2562  * D0 ~ D31, A0 ~ A16, DCS#, RAS#, CAS#, CKE#,   2563  * RDWE#, CKO#, WE0#, WE1#, WE2#, WE3#  2564  */  2565 #define __gpio_as_sdram_32bit()			\  2566 do {						\  2567 	REG_GPIO_PXFUNS(0) = 0xffffffff;	\  2568 	REG_GPIO_PXSELC(0) = 0xffffffff;	\  2569 	REG_GPIO_PXPES(0) = 0xffffffff;		\  2570 	REG_GPIO_PXFUNS(1) = 0x81f9ffff;	\  2571 	REG_GPIO_PXSELC(1) = 0x81f9ffff;	\  2572 	REG_GPIO_PXPES(1) = 0x81f9ffff;		\  2573 	REG_GPIO_PXFUNS(2) = 0x07000000;	\  2574 	REG_GPIO_PXSELC(2) = 0x07000000;	\  2575 	REG_GPIO_PXPES(2) = 0x07000000;		\  2576 } while (0)  2577   2578 /*  2579  * D0 ~ D15, A0 ~ A16, DCS#, RAS#, CAS#, CKE#,   2580  * RDWE#, CKO#, WE0#, WE1#  2581  */  2582 #define __gpio_as_sdram_16bit_4720()		\  2583 do {						\  2584 	REG_GPIO_PXFUNS(0) = 0x5442bfaa;	\  2585 	REG_GPIO_PXSELC(0) = 0x5442bfaa;	\  2586 	REG_GPIO_PXPES(0) = 0x5442bfaa;		\  2587 	REG_GPIO_PXFUNS(1) = 0x81f9ffff;	\  2588 	REG_GPIO_PXSELC(1) = 0x81f9ffff;	\  2589 	REG_GPIO_PXPES(1) = 0x81f9ffff;		\  2590 	REG_GPIO_PXFUNS(2) = 0x01000000;	\  2591 	REG_GPIO_PXSELC(2) = 0x01000000;	\  2592 	REG_GPIO_PXPES(2) = 0x01000000;		\  2593 } while (0)  2594   2595 /*  2596  * D0 ~ D15, A0 ~ A16, DCS#, RAS#, CAS#, CKE#,   2597  * RDWE#, CKO#, WE0#, WE1#  2598  */  2599 #define __gpio_as_sdram_16bit_4725()		\  2600 do {						\  2601 	REG_GPIO_PXFUNS(0) = 0x0000ffff;	\  2602 	REG_GPIO_PXSELC(0) = 0x0000ffff;	\  2603 	REG_GPIO_PXPES(0) = 0x0000ffff;		\  2604 	REG_GPIO_PXFUNS(1) = 0x81f9ffff;	\  2605 	REG_GPIO_PXSELC(1) = 0x81f9ffff;	\  2606 	REG_GPIO_PXPES(1) = 0x81f9ffff;		\  2607 	REG_GPIO_PXFUNS(2) = 0x01000000;	\  2608 	REG_GPIO_PXSELC(2) = 0x01000000;	\  2609 	REG_GPIO_PXPES(2) = 0x01000000;		\  2610 } while (0)  2611   2612   2613 /*  2614  * CS1#, CLE, ALE, FRE#, FWE#, FRB#, RDWE#/BUFD#  2615  */  2616 #define __gpio_as_nand()			\  2617 do {						\  2618 	REG_GPIO_PXFUNS(1) = 0x02018000;	\  2619 	REG_GPIO_PXSELC(1) = 0x02018000;	\  2620 	REG_GPIO_PXPES(1) = 0x02018000;		\  2621 	REG_GPIO_PXFUNS(2) = 0x30000000;	\  2622 	REG_GPIO_PXSELC(2) = 0x30000000;	\  2623 	REG_GPIO_PXPES(2) = 0x30000000;		\  2624 	REG_GPIO_PXFUNC(2) = 0x40000000;	\  2625 	REG_GPIO_PXSELC(2) = 0x40000000;	\  2626 	REG_GPIO_PXDIRC(2) = 0x40000000;	\  2627 	REG_GPIO_PXPES(2) = 0x40000000;		\  2628 	REG_GPIO_PXFUNS(1) = 0x00400000;	\  2629 	REG_GPIO_PXSELC(1) = 0x00400000;	\  2630 } while (0)  2631   2632 /*  2633  * CS4#, RD#, WR#, WAIT#, A0 ~ A22, D0 ~ D7  2634  */  2635 #define __gpio_as_nor_8bit()			\  2636 do {						\  2637 	REG_GPIO_PXFUNS(0) = 0x000000ff;	\  2638 	REG_GPIO_PXSELC(0) = 0x000000ff;	\  2639 	REG_GPIO_PXPES(0) = 0x000000ff;		\  2640 	REG_GPIO_PXFUNS(1) = 0x7041ffff;	\  2641 	REG_GPIO_PXSELC(1) = 0x7041ffff;	\  2642 	REG_GPIO_PXPES(1) = 0x7041ffff;		\  2643 	REG_GPIO_PXFUNS(1) = 0x00060000;	\  2644 	REG_GPIO_PXSELS(1) = 0x00060000;	\  2645 	REG_GPIO_PXPES(1) = 0x00060000;		\  2646 	REG_GPIO_PXFUNS(2) = 0x08000000;	\  2647 	REG_GPIO_PXSELC(2) = 0x08000000;	\  2648 	REG_GPIO_PXPES(2) = 0x08000000;		\  2649 	REG_GPIO_PXFUNS(2) = 0x00c00000;	\  2650 	REG_GPIO_PXSELS(2) = 0x00c00000;	\  2651 	REG_GPIO_PXPES(2) = 0x00c00000;		\  2652 	REG_GPIO_PXFUNS(3) = 0x18000000;	\  2653 	REG_GPIO_PXSELS(3) = 0x18000000;	\  2654 	REG_GPIO_PXPES(3) = 0x18000000;		\  2655 } while (0)  2656   2657 /*  2658  * CS4#, RD#, WR#, WAIT#, A0 ~ A22, D0 ~ D15  2659  */  2660 #define __gpio_as_nor_16bit()			\  2661 do {						\  2662 	REG_GPIO_PXFUNS(0) = 0x0000ffff;	\  2663 	REG_GPIO_PXSELC(0) = 0x0000ffff;	\  2664 	REG_GPIO_PXPES(0) = 0x0000ffff;		\  2665 	REG_GPIO_PXFUNS(1) = 0x7041ffff;	\  2666 	REG_GPIO_PXSELC(1) = 0x7041ffff;	\  2667 	REG_GPIO_PXPES(1) = 0x7041ffff;		\  2668 	REG_GPIO_PXFUNS(1) = 0x00060000;	\  2669 	REG_GPIO_PXSELS(1) = 0x00060000;	\  2670 	REG_GPIO_PXPES(1) = 0x00060000;		\  2671 	REG_GPIO_PXFUNS(2) = 0x08000000;	\  2672 	REG_GPIO_PXSELC(2) = 0x08000000;	\  2673 	REG_GPIO_PXPES(2) = 0x08000000;		\  2674 	REG_GPIO_PXFUNS(2) = 0x00c00000;	\  2675 	REG_GPIO_PXSELS(2) = 0x00c00000;	\  2676 	REG_GPIO_PXPES(2) = 0x00c00000;		\  2677 	REG_GPIO_PXFUNS(3) = 0x18000000;	\  2678 	REG_GPIO_PXSELS(3) = 0x18000000;	\  2679 	REG_GPIO_PXPES(3) = 0x18000000;		\  2680 } while (0)  2681   2682 /*  2683  * UART0_TxD, UART_RxD0  2684  */  2685 #define __gpio_as_uart0()			\  2686 do {						\  2687 	REG_GPIO_PXFUNS(3) = 0x06000000;	\  2688 	REG_GPIO_PXSELS(3) = 0x06000000;	\  2689 	REG_GPIO_PXPES(3) = 0x06000000;		\  2690 } while (0)  2691   2692 #define __gpio_jtag_to_uart0()			\  2693 do {						\  2694 	REG_GPIO_PXSELS(2) = 0x80000000;	\  2695 } while (0)  2696   2697 /*  2698  * UART0_CTS, UART0_RTS  2699  */  2700 #define __gpio_as_ctsrts()			\  2701 do {						\  2702 	REG_GPIO_PXFUNS(3) = 0xc0000000;	\  2703 	REG_GPIO_PXSELS(3) = 0xc0000000;	\  2704 	REG_GPIO_PXTRGC(3) = 0xc0000000;	\  2705 	REG_GPIO_PXPES(3) = 0xc0000000;		\  2706 } while (0)  2707   2708 /*  2709  * UART1_TxD, UART1_RxD1  2710  */  2711 #define __gpio_as_uart1()			\  2712 do {						\  2713 	REG_GPIO_PXFUNS(3) = 0xc0000000;	\  2714 	REG_GPIO_PXSELC(3) = 0xc0000000;	\  2715 	REG_GPIO_PXTRGS(3) = 0xc0000000;	\  2716 	REG_GPIO_PXPES(3) = 0xc0000000;		\  2717 } while (0)  2718   2719 /*  2720  * LCD_D0~LCD_D15, LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE  2721  */  2722 #define __gpio_as_lcd_16bit()			\  2723 do {						\  2724 	REG_GPIO_PXFUNS(2) = 0x003cffff;	\  2725 	REG_GPIO_PXSELC(2) = 0x003cffff;	\  2726 	REG_GPIO_PXPES(2) = 0x003cffff;		\  2727 } while (0)  2728   2729 /*  2730  * LCD_D0~LCD_D17, LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE  2731  */  2732 #define __gpio_as_lcd_18bit()			\  2733 do {						\  2734 	REG_GPIO_PXFUNS(2) = 0x003fffff;	\  2735 	REG_GPIO_PXSELC(2) = 0x003fffff;	\  2736 	REG_GPIO_PXPES(2) = 0x003fffff;		\  2737 } while (0)  2738   2739   2740 /* LCD_D0~LCD_D7, SLCD_RS, SLCD_CS */  2741 #define __gpio_as_slcd_8bit()			\  2742 do {						\  2743 	REG_GPIO_PXFUNS(2) = 0x001800ff;	\  2744 	REG_GPIO_PXSELC(2) = 0x001800ff;	\  2745 } while (0)  2746   2747 /* LCD_D0~LCD_D7, SLCD_RS, SLCD_CS */  2748 #define __gpio_as_slcd_9bit()			\  2749 do {						\  2750 	REG_GPIO_PXFUNS(2) = 0x001801ff;	\  2751 	REG_GPIO_PXSELC(2) = 0x001801ff;	\  2752 } while (0)  2753   2754 /* LCD_D0~LCD_D15, SLCD_RS, SLCD_CS */  2755 #define __gpio_as_slcd_16bit()			\  2756 do {						\  2757 	REG_GPIO_PXFUNS(2) = 0x0018ffff;	\  2758 	REG_GPIO_PXSELC(2) = 0x0018ffff;	\  2759 } while (0)  2760   2761 /* LCD_D0~LCD_D17, SLCD_RS, SLCD_CS */  2762 #define __gpio_as_slcd_18bit()			\  2763 do {						\  2764 	REG_GPIO_PXFUNS(2) = 0x001bffff;	\  2765 	REG_GPIO_PXSELC(2) = 0x001bffff;	\  2766 } while (0)  2767 /*  2768  * CIM_D0~CIM_D7, CIM_MCLK, CIM_PCLK, CIM_VSYNC, CIM_HSYNC  2769  */  2770 #define __gpio_as_cim()				\  2771 do {						\  2772 	REG_GPIO_PXFUNS(3) = 0x0003c0ff;	\  2773 	REG_GPIO_PXSELC(3) = 0x0003c0ff;	\  2774 	REG_GPIO_PXPES(3) = 0x0003c0ff;		\  2775 } while (0)  2776   2777 /*  2778  * SDATA_OUT, SDATA_IN, BIT_CLK, SYNC, SCLK_RESET  2779  */  2780 #define __gpio_as_aic()				\  2781 do {						\  2782 	REG_GPIO_PXFUNS(3) = 0x007c0000;	\  2783 	REG_GPIO_PXSELS(3) = 0x007c0000;	\  2784 	REG_GPIO_PXPES(3) = 0x007c0000;		\  2785 } while (0)  2786   2787 /*  2788  * MSC_CMD, MSC_CLK, MSC_D0 ~ MSC_D3  2789  */  2790 #define __gpio_as_msc()				\  2791 do {						\  2792 	REG_GPIO_PXFUNS(3) = 0x00003f00;	\  2793 	REG_GPIO_PXSELC(3) = 0x00003f00;	\  2794 	REG_GPIO_PXPES(3) = 0x00003f00;		\  2795 } while (0)  2796   2797 /*  2798  * SSI_CS0, SSI_CLK, SSI_DT, SSI_DR  2799  */  2800 #define __gpio_as_ssi()				\  2801 do {						\  2802 	REG_GPIO_PXFUNS(3) = 0x003c0000;	\  2803 	REG_GPIO_PXSELC(3) = 0x003c0000;	\  2804 	REG_GPIO_PXPES(3) = 0x003c0000;		\  2805 } while (0)  2806   2807 /*  2808  * I2C_SCK, I2C_SDA  2809  */  2810 #define __gpio_as_i2c()				\  2811 do {						\  2812 	REG_GPIO_PXFUNS(3) = 0x01800000;	\  2813 	REG_GPIO_PXSELS(3) = 0x01800000;	\  2814 	REG_GPIO_PXPES(3) = 0x01800000;		\  2815 } while (0)  2816   2817 /*  2818  * PWM0  2819  */  2820 #define __gpio_as_pwm0()			\  2821 do {						\  2822 	REG_GPIO_PXFUNS(3) = 0x00800000;	\  2823 	REG_GPIO_PXSELC(3) = 0x00800000;	\  2824 	REG_GPIO_PXPES(3) = 0x00800000;		\  2825 } while (0)  2826   2827 /*  2828  * PWM1  2829  */  2830 #define __gpio_as_pwm1()			\  2831 do {						\  2832 	REG_GPIO_PXFUNS(3) = 0x01000000;	\  2833 	REG_GPIO_PXSELC(3) = 0x01000000;	\  2834 	REG_GPIO_PXPES(3) = 0x01000000;		\  2835 } while (0)  2836   2837 /*  2838  * PWM2  2839  */  2840 #define __gpio_as_pwm2()			\  2841 do {						\  2842 	REG_GPIO_PXFUNS(3) = 0x02000000;	\  2843 	REG_GPIO_PXSELC(3) = 0x02000000;	\  2844 	REG_GPIO_PXPES(3) = 0x02000000;		\  2845 } while (0)  2846   2847 /*  2848  * PWM3  2849  */  2850 #define __gpio_as_pwm3()			\  2851 do {						\  2852 	REG_GPIO_PXFUNS(3) = 0x04000000;	\  2853 	REG_GPIO_PXSELC(3) = 0x04000000;	\  2854 	REG_GPIO_PXPES(3) = 0x04000000;		\  2855 } while (0)  2856   2857 /*  2858  * PWM4  2859  */  2860 #define __gpio_as_pwm4()			\  2861 do {						\  2862 	REG_GPIO_PXFUNS(3) = 0x08000000;	\  2863 	REG_GPIO_PXSELC(3) = 0x08000000;	\  2864 	REG_GPIO_PXPES(3) = 0x08000000;		\  2865 } while (0)  2866   2867 /*  2868  * PWM5  2869  */  2870 #define __gpio_as_pwm5()			\  2871 do {						\  2872 	REG_GPIO_PXFUNS(3) = 0x10000000;	\  2873 	REG_GPIO_PXSELC(3) = 0x10000000;	\  2874 	REG_GPIO_PXPES(3) = 0x10000000;		\  2875 } while (0)  2876   2877 /*  2878  * PWM6  2879  */  2880 #define __gpio_as_pwm6()			\  2881 do {						\  2882 	REG_GPIO_PXFUNS(3) = 0x40000000;	\  2883 	REG_GPIO_PXSELC(3) = 0x40000000;	\  2884 	REG_GPIO_PXPES(3) = 0x40000000;		\  2885 } while (0)  2886   2887 /*  2888  * PWM7  2889  */  2890 #define __gpio_as_pwm7()			\  2891 do {						\  2892 	REG_GPIO_PXFUNS(3) = 0x80000000;	\  2893 	REG_GPIO_PXSELC(3) = 0x80000000;	\  2894 	REG_GPIO_PXPES(3) = 0x80000000;		\  2895 } while (0)  2896   2897 /*  2898  * n = 0 ~ 7  2899  */  2900 #define __gpio_as_pwm(n)	__gpio_as_pwm##n()  2901   2902 /* GPIO or Interrupt Mode */  2903   2904 #define __gpio_get_port(p)	(REG_GPIO_PXPIN(p))  2905   2906 #define __gpio_port_as_output(p, o)		\  2907 do {						\  2908     REG_GPIO_PXFUNC(p) = (1 << (o));		\  2909     REG_GPIO_PXSELC(p) = (1 << (o));		\  2910     REG_GPIO_PXDIRS(p) = (1 << (o));		\  2911 } while (0)  2912   2913 #define __gpio_port_as_input(p, o)		\  2914 do {						\  2915     REG_GPIO_PXFUNC(p) = (1 << (o));		\  2916     REG_GPIO_PXSELC(p) = (1 << (o));		\  2917     REG_GPIO_PXDIRC(p) = (1 << (o));		\  2918 } while (0)  2919   2920 #define __gpio_as_output(n)			\  2921 do {						\  2922 	unsigned int p, o;			\  2923 	p = (n) / 32;				\  2924 	o = (n) % 32;				\  2925 	__gpio_port_as_output(p, o);		\  2926 } while (0)  2927   2928 #define __gpio_as_input(n)			\  2929 do {						\  2930 	unsigned int p, o;			\  2931 	p = (n) / 32;				\  2932 	o = (n) % 32;				\  2933 	__gpio_port_as_input(p, o);		\  2934 } while (0)  2935   2936 #define __gpio_set_pin(n)			\  2937 do {						\  2938 	unsigned int p, o;			\  2939 	p = (n) / 32;				\  2940 	o = (n) % 32;				\  2941 	REG_GPIO_PXDATS(p) = (1 << o);		\  2942 } while (0)  2943   2944 #define __gpio_clear_pin(n)			\  2945 do {						\  2946 	unsigned int p, o;			\  2947 	p = (n) / 32;				\  2948 	o = (n) % 32;				\  2949 	REG_GPIO_PXDATC(p) = (1 << o);		\  2950 } while (0)  2951   2952 #define __gpio_get_pin(n)			\  2953 ({						\  2954 	unsigned int p, o, v;			\  2955 	p = (n) / 32;				\  2956 	o = (n) % 32;				\  2957 	if (__gpio_get_port(p) & (1 << o))	\  2958 		v = 1;				\  2959 	else					\  2960 		v = 0;				\  2961 	v;					\  2962 })  2963   2964 #define __gpio_as_irq_high_level(n)		\  2965 do {						\  2966 	unsigned int p, o;			\  2967 	p = (n) / 32;				\  2968 	o = (n) % 32;				\  2969 	REG_GPIO_PXIMS(p) = (1 << o);		\  2970 	REG_GPIO_PXTRGC(p) = (1 << o);		\  2971 	REG_GPIO_PXFUNC(p) = (1 << o);		\  2972 	REG_GPIO_PXSELS(p) = (1 << o);		\  2973 	REG_GPIO_PXDIRS(p) = (1 << o);		\  2974 	REG_GPIO_PXFLGC(p) = (1 << o);		\  2975 	REG_GPIO_PXIMC(p) = (1 << o);		\  2976 } while (0)  2977   2978 #define __gpio_as_irq_low_level(n)		\  2979 do {						\  2980 	unsigned int p, o;			\  2981 	p = (n) / 32;				\  2982 	o = (n) % 32;				\  2983 	REG_GPIO_PXIMS(p) = (1 << o);		\  2984 	REG_GPIO_PXTRGC(p) = (1 << o);		\  2985 	REG_GPIO_PXFUNC(p) = (1 << o);		\  2986 	REG_GPIO_PXSELS(p) = (1 << o);		\  2987 	REG_GPIO_PXDIRC(p) = (1 << o);		\  2988 	REG_GPIO_PXFLGC(p) = (1 << o);		\  2989 	REG_GPIO_PXIMC(p) = (1 << o);		\  2990 } while (0)  2991   2992 #define __gpio_as_irq_rise_edge(n)		\  2993 do {						\  2994 	unsigned int p, o;			\  2995 	p = (n) / 32;				\  2996 	o = (n) % 32;				\  2997 	REG_GPIO_PXIMS(p) = (1 << o);		\  2998 	REG_GPIO_PXTRGS(p) = (1 << o);		\  2999 	REG_GPIO_PXFUNC(p) = (1 << o);		\  3000 	REG_GPIO_PXSELS(p) = (1 << o);		\  3001 	REG_GPIO_PXDIRS(p) = (1 << o);		\  3002 	REG_GPIO_PXFLGC(p) = (1 << o);		\  3003 	REG_GPIO_PXIMC(p) = (1 << o);		\  3004 } while (0)  3005   3006 #define __gpio_as_irq_fall_edge(n)		\  3007 do {						\  3008 	unsigned int p, o;			\  3009 	p = (n) / 32;				\  3010 	o = (n) % 32;				\  3011 	REG_GPIO_PXIMS(p) = (1 << o);		\  3012 	REG_GPIO_PXTRGS(p) = (1 << o);		\  3013 	REG_GPIO_PXFUNC(p) = (1 << o);		\  3014 	REG_GPIO_PXSELS(p) = (1 << o);		\  3015 	REG_GPIO_PXDIRC(p) = (1 << o);		\  3016 	REG_GPIO_PXFLGC(p) = (1 << o);		\  3017 	REG_GPIO_PXIMC(p) = (1 << o);		\  3018 } while (0)  3019   3020 #define __gpio_mask_irq(n)			\  3021 do {						\  3022 	unsigned int p, o;			\  3023 	p = (n) / 32;				\  3024 	o = (n) % 32;				\  3025 	REG_GPIO_PXIMS(p) = (1 << o);		\  3026 } while (0)  3027   3028 #define __gpio_unmask_irq(n)			\  3029 do {						\  3030 	unsigned int p, o;			\  3031 	p = (n) / 32;				\  3032 	o = (n) % 32;				\  3033 	REG_GPIO_PXIMC(p) = (1 << o);		\  3034 } while (0)  3035   3036 #define __gpio_ack_irq(n)			\  3037 do {						\  3038 	unsigned int p, o;			\  3039 	p = (n) / 32;				\  3040 	o = (n) % 32;				\  3041 	REG_GPIO_PXFLGC(p) = (1 << o);		\  3042 } while (0)  3043   3044 #define __gpio_get_irq()			\  3045 ({						\  3046 	unsigned int p, i, tmp, v = 0;		\  3047 	for (p = 3; p >= 0; p--) {		\  3048 		tmp = REG_GPIO_PXFLG(p);	\  3049 		for (i = 0; i < 32; i++)	\  3050 			if (tmp & (1 << i))	\  3051 				v = (32*p + i);	\  3052 	}					\  3053 	v;					\  3054 })  3055   3056 #define __gpio_group_irq(n)			\  3057 ({						\  3058 	register int tmp, i;			\  3059 	tmp = REG_GPIO_PXFLG((n));		\  3060 	for (i=31;i>=0;i--)			\  3061 		if (tmp & (1 << i))		\  3062 			break;			\  3063 	i;					\  3064 })  3065   3066 #define __gpio_enable_pull(n)			\  3067 do {						\  3068 	unsigned int p, o;			\  3069 	p = (n) / 32;				\  3070 	o = (n) % 32;				\  3071 	REG_GPIO_PXPEC(p) = (1 << o);		\  3072 } while (0)  3073   3074 #define __gpio_disable_pull(n)			\  3075 do {						\  3076 	unsigned int p, o;			\  3077 	p = (n) / 32;				\  3078 	o = (n) % 32;				\  3079 	REG_GPIO_PXPES(p) = (1 << o);		\  3080 } while (0)  3081   3082   3083 /***************************************************************************  3084  * CPM  3085  ***************************************************************************/  3086 #define __cpm_get_pllm() \  3087 	((REG_CPM_CPPCR & CPM_CPPCR_PLLM_MASK) >> CPM_CPPCR_PLLM_BIT)  3088 #define __cpm_get_plln() \  3089 	((REG_CPM_CPPCR & CPM_CPPCR_PLLN_MASK) >> CPM_CPPCR_PLLN_BIT)  3090 #define __cpm_get_pllod() \  3091 	((REG_CPM_CPPCR & CPM_CPPCR_PLLOD_MASK) >> CPM_CPPCR_PLLOD_BIT)  3092   3093 #define __cpm_get_cdiv() \  3094 	((REG_CPM_CPCCR & CPM_CPCCR_CDIV_MASK) >> CPM_CPCCR_CDIV_BIT)  3095 #define __cpm_get_hdiv() \  3096 	((REG_CPM_CPCCR & CPM_CPCCR_HDIV_MASK) >> CPM_CPCCR_HDIV_BIT)  3097 #define __cpm_get_pdiv() \  3098 	((REG_CPM_CPCCR & CPM_CPCCR_PDIV_MASK) >> CPM_CPCCR_PDIV_BIT)  3099 #define __cpm_get_mdiv() \  3100 	((REG_CPM_CPCCR & CPM_CPCCR_MDIV_MASK) >> CPM_CPCCR_MDIV_BIT)  3101 #define __cpm_get_ldiv() \  3102 	((REG_CPM_CPCCR & CPM_CPCCR_LDIV_MASK) >> CPM_CPCCR_LDIV_BIT)  3103 #define __cpm_get_udiv() \  3104 	((REG_CPM_CPCCR & CPM_CPCCR_UDIV_MASK) >> CPM_CPCCR_UDIV_BIT)  3105 #define __cpm_get_i2sdiv() \  3106 	((REG_CPM_I2SCDR & CPM_I2SCDR_I2SDIV_MASK) >> CPM_I2SCDR_I2SDIV_BIT)  3107 #define __cpm_get_pixdiv() \  3108 	((REG_CPM_LPCDR & CPM_LPCDR_PIXDIV_MASK) >> CPM_LPCDR_PIXDIV_BIT)  3109 #define __cpm_get_mscdiv() \  3110 	((REG_CPM_MSCCDR & CPM_MSCCDR_MSCDIV_MASK) >> CPM_MSCCDR_MSCDIV_BIT)  3111   3112 #define __cpm_set_cdiv(v) \  3113 	(REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_CDIV_MASK) | ((v) << (CPM_CPCCR_CDIV_BIT)))  3114 #define __cpm_set_hdiv(v) \  3115 	(REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_HDIV_MASK) | ((v) << (CPM_CPCCR_HDIV_BIT)))  3116 #define __cpm_set_pdiv(v) \  3117 	(REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_PDIV_MASK) | ((v) << (CPM_CPCCR_PDIV_BIT)))  3118 #define __cpm_set_mdiv(v) \  3119 	(REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_MDIV_MASK) | ((v) << (CPM_CPCCR_MDIV_BIT)))  3120 #define __cpm_set_ldiv(v) \  3121 	(REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_LDIV_MASK) | ((v) << (CPM_CPCCR_LDIV_BIT)))  3122 #define __cpm_set_udiv(v) \  3123 	(REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_UDIV_MASK) | ((v) << (CPM_CPCCR_UDIV_BIT)))  3124 #define __cpm_set_i2sdiv(v) \  3125 	(REG_CPM_I2SCDR = (REG_CPM_I2SCDR & ~CPM_I2SCDR_I2SDIV_MASK) | ((v) << (CPM_I2SCDR_I2SDIV_BIT)))  3126 #define __cpm_set_pixdiv(v) \  3127 	(REG_CPM_LPCDR = (REG_CPM_LPCDR & ~CPM_LPCDR_PIXDIV_MASK) | ((v) << (CPM_LPCDR_PIXDIV_BIT)))  3128 #define __cpm_set_mscdiv(v) \  3129 	(REG_CPM_MSCCDR = (REG_CPM_MSCCDR & ~CPM_MSCCDR_MSCDIV_MASK) | ((v) << (CPM_MSCCDR_MSCDIV_BIT)))  3130   3131 #define __cpm_select_i2sclk_exclk()	(REG_CPM_CPCCR &= ~CPM_CPCCR_I2CS)  3132 #define __cpm_select_i2sclk_pll()	(REG_CPM_CPCCR |= CPM_CPCCR_I2CS)  3133 #define __cpm_enable_cko()		(REG_CPM_CPCCR |= CPM_CPCCR_CLKOEN)  3134 #define __cpm_select_usbclk_exclk()	(REG_CPM_CPCCR &= ~CPM_CPCCR_UCS)  3135 #define __cpm_select_usbclk_pll()	(REG_CPM_CPCCR |= CPM_CPCCR_UCS)  3136 #define __cpm_enable_pll_change()	(REG_CPM_CPCCR |= CPM_CPCCR_CE)  3137 #define __cpm_pllout_direct()		(REG_CPM_CPCCR |= CPM_CPCCR_PCS)  3138 #define __cpm_pllout_div2()		(REG_CPM_CPCCR &= ~CPM_CPCCR_PCS)  3139   3140 #define __cpm_pll_is_on()		(REG_CPM_CPPCR & CPM_CPPCR_PLLS)  3141 #define __cpm_pll_bypass()		(REG_CPM_CPPCR |= CPM_CPPCR_PLLBP)  3142 #define __cpm_pll_enable()		(REG_CPM_CPPCR |= CPM_CPPCR_PLLEN)  3143   3144 #define __cpm_get_cclk_doze_duty() \  3145 	((REG_CPM_LCR & CPM_LCR_DOZE_DUTY_MASK) >> CPM_LCR_DOZE_DUTY_BIT)  3146 #define __cpm_set_cclk_doze_duty(v) \  3147 	(REG_CPM_LCR = (REG_CPM_LCR & ~CPM_LCR_DOZE_DUTY_MASK) | ((v) << (CPM_LCR_DOZE_DUTY_BIT)))  3148   3149 #define __cpm_doze_mode()		(REG_CPM_LCR |= CPM_LCR_DOZE_ON)  3150 #define __cpm_idle_mode() \  3151 	(REG_CPM_LCR = (REG_CPM_LCR & ~CPM_LCR_LPM_MASK) | CPM_LCR_LPM_IDLE)  3152 #define __cpm_sleep_mode() \  3153 	(REG_CPM_LCR = (REG_CPM_LCR & ~CPM_LCR_LPM_MASK) | CPM_LCR_LPM_SLEEP)  3154   3155 #define __cpm_stop_all() 	(REG_CPM_CLKGR = 0x7fff)  3156 #define __cpm_stop_uart1()	(REG_CPM_CLKGR |= CPM_CLKGR_UART1)  3157 #define __cpm_stop_uhc()	(REG_CPM_CLKGR |= CPM_CLKGR_UHC)  3158 #define __cpm_stop_ipu()	(REG_CPM_CLKGR |= CPM_CLKGR_IPU)  3159 #define __cpm_stop_dmac()	(REG_CPM_CLKGR |= CPM_CLKGR_DMAC)  3160 #define __cpm_stop_udc()	(REG_CPM_CLKGR |= CPM_CLKGR_UDC)  3161 #define __cpm_stop_lcd()	(REG_CPM_CLKGR |= CPM_CLKGR_LCD)  3162 #define __cpm_stop_cim()	(REG_CPM_CLKGR |= CPM_CLKGR_CIM)  3163 #define __cpm_stop_sadc()	(REG_CPM_CLKGR |= CPM_CLKGR_SADC)  3164 #define __cpm_stop_msc()	(REG_CPM_CLKGR |= CPM_CLKGR_MSC)  3165 #define __cpm_stop_aic1()	(REG_CPM_CLKGR |= CPM_CLKGR_AIC1)  3166 #define __cpm_stop_aic2()	(REG_CPM_CLKGR |= CPM_CLKGR_AIC2)  3167 #define __cpm_stop_ssi()	(REG_CPM_CLKGR |= CPM_CLKGR_SSI)  3168 #define __cpm_stop_i2c()	(REG_CPM_CLKGR |= CPM_CLKGR_I2C)  3169 #define __cpm_stop_rtc()	(REG_CPM_CLKGR |= CPM_CLKGR_RTC)  3170 #define __cpm_stop_tcu()	(REG_CPM_CLKGR |= CPM_CLKGR_TCU)  3171 #define __cpm_stop_uart0()	(REG_CPM_CLKGR |= CPM_CLKGR_UART0)  3172   3173 #define __cpm_start_all() 	(REG_CPM_CLKGR = 0x0)  3174 #define __cpm_start_uart1()	(REG_CPM_CLKGR &= ~CPM_CLKGR_UART1)  3175 #define __cpm_start_uhc()	(REG_CPM_CLKGR &= ~CPM_CLKGR_UHC)  3176 #define __cpm_start_ipu()	(REG_CPM_CLKGR &= ~CPM_CLKGR_IPU)  3177 #define __cpm_start_dmac()	(REG_CPM_CLKGR &= ~CPM_CLKGR_DMAC)  3178 #define __cpm_start_udc()	(REG_CPM_CLKGR &= ~CPM_CLKGR_UDC)  3179 #define __cpm_start_lcd()	(REG_CPM_CLKGR &= ~CPM_CLKGR_LCD)  3180 #define __cpm_start_cim()	(REG_CPM_CLKGR &= ~CPM_CLKGR_CIM)  3181 #define __cpm_start_sadc()	(REG_CPM_CLKGR &= ~CPM_CLKGR_SADC)  3182 #define __cpm_start_msc()	(REG_CPM_CLKGR &= ~CPM_CLKGR_MSC)  3183 #define __cpm_start_aic1()	(REG_CPM_CLKGR &= ~CPM_CLKGR_AIC1)  3184 #define __cpm_start_aic2()	(REG_CPM_CLKGR &= ~CPM_CLKGR_AIC2)  3185 #define __cpm_start_ssi()	(REG_CPM_CLKGR &= ~CPM_CLKGR_SSI)  3186 #define __cpm_start_i2c()	(REG_CPM_CLKGR &= ~CPM_CLKGR_I2C)  3187 #define __cpm_start_rtc()	(REG_CPM_CLKGR &= ~CPM_CLKGR_RTC)  3188 #define __cpm_start_tcu()	(REG_CPM_CLKGR &= ~CPM_CLKGR_TCU)  3189 #define __cpm_start_uart0()	(REG_CPM_CLKGR &= ~CPM_CLKGR_UART0)  3190   3191 #define __cpm_get_o1st() \  3192 	((REG_CPM_SCR & CPM_SCR_O1ST_MASK) >> CPM_SCR_O1ST_BIT)  3193 #define __cpm_set_o1st(v) \  3194 	(REG_CPM_SCR = (REG_CPM_SCR & ~CPM_SCR_O1ST_MASK) | ((v) << (CPM_SCR_O1ST_BIT)))  3195 #define __cpm_suspend_udcphy()		(REG_CPM_SCR &= ~CPM_SCR_UDCPHY_ENABLE)  3196 #define __cpm_suspend_usbphy()		(REG_CPM_SCR |= CPM_SCR_USBPHY_DISABLE)  3197 #define __cpm_enable_osc_in_sleep()	(REG_CPM_SCR |= CPM_SCR_OSC_ENABLE)  3198   3199 /* NOTE: Independent of usbboot parameters. */  3200   3201 #define CONFIG_SYS_CPU_SPEED    336000000       /* CPU clock: 336 MHz */  3202 #define CONFIG_SYS_EXTAL        12000000        /* EXTAL freq: 12 MHz */  3203 #define CONFIG_SYS_HZ           (CONFIG_SYS_EXTAL / 256) /* incrementer freq */  3204 #define JZ_EXTAL		CONFIG_SYS_EXTAL  3205 #define JZ_EXTAL2		32768 /* RTC clock */  3206   3207 /* PLL output frequency */  3208 static __inline__ unsigned int __cpm_get_pllout(void)  3209 {  3210 	unsigned long m, n, no, pllout;  3211 	unsigned long cppcr = REG_CPM_CPPCR;  3212 	unsigned long od[4] = {1, 2, 2, 4};  3213 	if ((cppcr & CPM_CPPCR_PLLEN) && !(cppcr & CPM_CPPCR_PLLBP)) {  3214 		m = __cpm_get_pllm() + 2;  3215 		n = __cpm_get_plln() + 2;  3216 		no = od[__cpm_get_pllod()];  3217 		pllout = ((JZ_EXTAL) / (n * no)) * m;  3218 	} else  3219 		pllout = JZ_EXTAL;  3220 	return pllout;  3221 }  3222   3223 /* PLL output frequency for MSC/I2S/LCD/USB */  3224 static __inline__ unsigned int __cpm_get_pllout2(void)  3225 {  3226 	if (REG_CPM_CPCCR & CPM_CPCCR_PCS)  3227 		return __cpm_get_pllout();  3228 	else  3229 		return __cpm_get_pllout()/2;  3230 }  3231   3232 /* CPU core clock */  3233 static __inline__ unsigned int __cpm_get_cclk(void)  3234 {  3235 	int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};  3236   3237 	return __cpm_get_pllout() / div[__cpm_get_cdiv()];  3238 }  3239   3240 /* AHB system bus clock */  3241 static __inline__ unsigned int __cpm_get_hclk(void)  3242 {  3243 	int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};  3244   3245 	return __cpm_get_pllout() / div[__cpm_get_hdiv()];  3246 }  3247   3248 /* Memory bus clock */  3249 static __inline__ unsigned int __cpm_get_mclk(void)  3250 {  3251 	int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};  3252   3253 	return __cpm_get_pllout() / div[__cpm_get_mdiv()];  3254 }  3255   3256 /* APB peripheral bus clock */  3257 static __inline__ unsigned int __cpm_get_pclk(void)  3258 {  3259 	int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};  3260   3261 	return __cpm_get_pllout() / div[__cpm_get_pdiv()];  3262 }  3263   3264 /* LCDC module clock */  3265 static __inline__ unsigned int __cpm_get_lcdclk(void)  3266 {  3267 	return __cpm_get_pllout2() / (__cpm_get_ldiv() + 1);  3268 }  3269   3270 /* LCD pixel clock */  3271 static __inline__ unsigned int __cpm_get_pixclk(void)  3272 {  3273 	return __cpm_get_pllout2() / (__cpm_get_pixdiv() + 1);  3274 }  3275   3276 /* I2S clock */  3277 static __inline__ unsigned int __cpm_get_i2sclk(void)  3278 {  3279 	if (REG_CPM_CPCCR & CPM_CPCCR_I2CS) {  3280 		return __cpm_get_pllout2() / (__cpm_get_i2sdiv() + 1);  3281 	}  3282 	else {  3283 		return JZ_EXTAL;  3284 	}  3285 }  3286   3287 /* USB clock */  3288 static __inline__ unsigned int __cpm_get_usbclk(void)  3289 {  3290 	if (REG_CPM_CPCCR & CPM_CPCCR_UCS) {  3291 		return __cpm_get_pllout2() / (__cpm_get_udiv() + 1);  3292 	}  3293 	else {  3294 		return JZ_EXTAL;  3295 	}  3296 }  3297   3298 /* MSC clock */  3299 static __inline__ unsigned int __cpm_get_mscclk(void)  3300 {  3301 	return __cpm_get_pllout2() / (__cpm_get_mscdiv() + 1);  3302 }  3303   3304 /* EXTAL clock for UART,I2C,SSI,TCU,USB-PHY */  3305 static __inline__ unsigned int __cpm_get_extalclk(void)  3306 {  3307 	return JZ_EXTAL;  3308 }  3309   3310 /* RTC clock for CPM,INTC,RTC,TCU,WDT */  3311 static __inline__ unsigned int __cpm_get_rtcclk(void)  3312 {  3313 	return JZ_EXTAL2;  3314 }  3315   3316 /*  3317  * Output 24MHz for SD and 16MHz for MMC.  3318  */  3319 static inline void __cpm_select_msc_clk(int sd)  3320 {  3321 	unsigned int pllout2 = __cpm_get_pllout2();  3322 	unsigned int div = 0;  3323   3324 	if (sd) {  3325 		div = pllout2 / 24000000;  3326 	}  3327 	else {  3328 		div = pllout2 / 16000000;  3329 	}  3330   3331 	REG_CPM_MSCCDR = div - 1;  3332 }  3333   3334 /*  3335  * TCU  3336  */  3337 /* where 'n' is the TCU channel */  3338 #define __tcu_select_extalclk(n) \  3339 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCU_TCSR_EXT_EN | TCU_TCSR_RTC_EN | TCU_TCSR_PCK_EN)) | TCU_TCSR_EXT_EN)  3340 #define __tcu_select_rtcclk(n) \  3341 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCU_TCSR_EXT_EN | TCU_TCSR_RTC_EN | TCU_TCSR_PCK_EN)) | TCU_TCSR_RTC_EN)  3342 #define __tcu_select_pclk(n) \  3343 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCU_TCSR_EXT_EN | TCU_TCSR_RTC_EN | TCU_TCSR_PCK_EN)) | TCU_TCSR_PCK_EN)  3344   3345 #define __tcu_select_clk_div1(n) \  3346 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE1)  3347 #define __tcu_select_clk_div4(n) \  3348 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE4)  3349 #define __tcu_select_clk_div16(n) \  3350 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE16)  3351 #define __tcu_select_clk_div64(n) \  3352 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE64)  3353 #define __tcu_select_clk_div256(n) \  3354 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE256)  3355 #define __tcu_select_clk_div1024(n) \  3356 	(REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE1024)  3357   3358 #define __tcu_enable_pwm_output(n)	( REG_TCU_TCSR((n)) |= TCU_TCSR_PWM_EN )  3359 #define __tcu_disable_pwm_output(n)	( REG_TCU_TCSR((n)) &= ~TCU_TCSR_PWM_EN )  3360   3361 #define __tcu_init_pwm_output_high(n)	( REG_TCU_TCSR((n)) |= TCU_TCSR_PWM_INITL_HIGH )  3362 #define __tcu_init_pwm_output_low(n)	( REG_TCU_TCSR((n)) &= ~TCU_TCSR_PWM_INITL_HIGH )  3363   3364 #define __tcu_set_pwm_output_shutdown_graceful(n)	( REG_TCU_TCSR((n)) &= ~TCU_TCSR_PWM_SD )  3365 #define __tcu_set_pwm_output_shutdown_abrupt(n)		( REG_TCU_TCSR((n)) |= TCU_TCSR_PWM_SD )  3366   3367 #define __tcu_start_counter(n)		( REG_TCU_TESR |= (1 << (n)) )  3368 #define __tcu_stop_counter(n)		( REG_TCU_TECR |= (1 << (n)) )  3369   3370 #define __tcu_half_match_flag(n)	( REG_TCU_TFR & (1 << ((n) + 16)) )  3371 #define __tcu_full_match_flag(n)	( REG_TCU_TFR & (1 << (n)) )  3372 #define __tcu_set_half_match_flag(n)	( REG_TCU_TFSR = (1 << ((n) + 16)) )  3373 #define __tcu_set_full_match_flag(n)	( REG_TCU_TFSR = (1 << (n)) )  3374 #define __tcu_clear_half_match_flag(n)	( REG_TCU_TFCR = (1 << ((n) + 16)) )  3375 #define __tcu_clear_full_match_flag(n)	( REG_TCU_TFCR = (1 << (n)) )  3376 #define __tcu_mask_half_match_irq(n)	( REG_TCU_TMSR = (1 << ((n) + 16)) )  3377 #define __tcu_mask_full_match_irq(n)	( REG_TCU_TMSR = (1 << (n)) )  3378 #define __tcu_unmask_half_match_irq(n)	( REG_TCU_TMCR = (1 << ((n) + 16)) )  3379 #define __tcu_unmask_full_match_irq(n)	( REG_TCU_TMCR = (1 << (n)) )  3380   3381 #define __tcu_wdt_clock_stopped()	( REG_TCU_TSR & TCU_TSSR_WDTSC )  3382 #define __tcu_timer_clock_stopped(n)	( REG_TCU_TSR & (1 << (n)) )  3383   3384 #define __tcu_start_wdt_clock()		( REG_TCU_TSCR = TCU_TSSR_WDTSC )  3385 #define __tcu_start_timer_clock(n)	( REG_TCU_TSCR = (1 << (n)) )  3386   3387 #define __tcu_stop_wdt_clock()		( REG_TCU_TSSR = TCU_TSSR_WDTSC )  3388 #define __tcu_stop_timer_clock(n)	( REG_TCU_TSSR = (1 << (n)) )  3389   3390 #define __tcu_get_count(n)		( REG_TCU_TCNT((n)) )  3391 #define __tcu_set_count(n,v)		( REG_TCU_TCNT((n)) = (v) )  3392 #define __tcu_set_full_data(n,v)	( REG_TCU_TDFR((n)) = (v) )  3393 #define __tcu_set_half_data(n,v)	( REG_TCU_TDHR((n)) = (v) )  3394   3395   3396 /***************************************************************************  3397  * WDT  3398  ***************************************************************************/  3399 #define __wdt_start()			( REG_WDT_TCER |= WDT_TCER_TCEN )  3400 #define __wdt_stop()			( REG_WDT_TCER &= ~WDT_TCER_TCEN )  3401 #define __wdt_set_count(v)		( REG_WDT_TCNT = (v) )  3402 #define __wdt_set_data(v)		( REG_WDT_TDR = (v) )  3403   3404 #define __wdt_select_extalclk() \  3405 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~(WDT_TCSR_EXT_EN | WDT_TCSR_RTC_EN | WDT_TCSR_PCK_EN)) | WDT_TCSR_EXT_EN)  3406 #define __wdt_select_rtcclk() \  3407 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~(WDT_TCSR_EXT_EN | WDT_TCSR_RTC_EN | WDT_TCSR_PCK_EN)) | WDT_TCSR_RTC_EN)  3408 #define __wdt_select_pclk() \  3409 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~(WDT_TCSR_EXT_EN | WDT_TCSR_RTC_EN | WDT_TCSR_PCK_EN)) | WDT_TCSR_PCK_EN)  3410   3411 #define __wdt_select_clk_div1() \  3412 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE1)  3413 #define __wdt_select_clk_div4() \  3414 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE4)  3415 #define __wdt_select_clk_div16() \  3416 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE16)  3417 #define __wdt_select_clk_div64() \  3418 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE64)  3419 #define __wdt_select_clk_div256() \  3420 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE256)  3421 #define __wdt_select_clk_div1024() \  3422 	(REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE1024)  3423   3424   3425 /***************************************************************************  3426  * UART  3427  ***************************************************************************/  3428   3429 #define __uart_enable()			( REG8(UART0_FCR) |= UARTFCR_UUE | UARTFCR_FE )  3430 #define __uart_disable()		( REG8(UART0_FCR) = ~UARTFCR_UUE )  3431   3432 #define __uart_enable_transmit_irq()	( REG8(UART0_IER) |= UARTIER_TIE )  3433 #define __uart_disable_transmit_irq()	( REG8(UART0_IER) &= ~UARTIER_TIE )  3434   3435 #define __uart_enable_receive_irq() \  3436   ( REG8(UART0_IER) |= UARTIER_RIE | UARTIER_RLIE | UARTIER_RTIE )  3437 #define __uart_disable_receive_irq() \  3438   ( REG8(UART0_IER) &= ~(UARTIER_RIE | UARTIER_RLIE | UARTIER_RTIE) )  3439   3440 #define __uart_enable_loopback()  	( REG8(UART0_MCR) |= UARTMCR_LOOP )  3441 #define __uart_disable_loopback() 	( REG8(UART0_MCR) &= ~UARTMCR_LOOP )  3442   3443 #define __uart_set_8n1()		( REG8(UART0_LCR) = UARTLCR_WLEN_8 )  3444   3445 #define __uart_set_baud(devclk, baud)				\  3446   do {								\  3447 	REG8(UART0_LCR) |= UARTLCR_DLAB;			\  3448 	REG8(UART0_DLLR) = (devclk / 16 / baud) & 0xff;		\  3449 	REG8(UART0_DLHR) = ((devclk / 16 / baud) >> 8) & 0xff;	\  3450 	REG8(UART0_LCR) &= ~UARTLCR_DLAB;			\  3451   } while (0)  3452   3453 #define __uart_parity_error()		( (REG8(UART0_LSR) & UARTLSR_PER) != 0 )  3454 #define __uart_clear_errors() \  3455   ( REG8(UART0_LSR) &= ~(UARTLSR_ORER | UARTLSR_BRK | UARTLSR_FER | UARTLSR_PER | UARTLSR_RFER) )  3456   3457 #define __uart_transmit_fifo_empty()	( (REG8(UART0_LSR) & UARTLSR_TDRQ) != 0 )  3458 #define __uart_transmit_end()		( (REG8(UART0_LSR) & UARTLSR_TEMT) != 0 )  3459 #define __uart_transmit_char(ch)	( REG8(UART0_TDR) = (ch) )  3460 #define __uart_receive_fifo_full()	( (REG8(UART0_LSR) & UARTLSR_DR) != 0 )  3461 #define __uart_receive_ready()		( (REG8(UART0_LSR) & UARTLSR_DR) != 0 )  3462 #define __uart_receive_char()		REG8(UART0_RDR)  3463 #define __uart_disable_irda()		( REG8(UART0_SIRCR) &= ~(SIRCR_TSIRE | SIRCR_RSIRE) )  3464 #define __uart_enable_irda() \  3465   /* Tx high pulse as 0, Rx low pulse as 0 */ \  3466   ( REG8(UART0_SIRCR) = SIRCR_TSIRE | SIRCR_RSIRE | SIRCR_RXPL | SIRCR_TPWS )  3467   3468   3469 /***************************************************************************  3470  * DMAC  3471  ***************************************************************************/  3472   3473 /* n is the DMA channel (0 - 5) */  3474   3475 #define __dmac_enable_module() \  3476   ( REG_DMAC_DMACR |= DMAC_DMACR_DMAE | DMAC_DMACR_PR_RR )  3477 #define __dmac_disable_module() \  3478   ( REG_DMAC_DMACR &= ~DMAC_DMACR_DMAE )  3479   3480 /* p=0,1,2,3 */  3481 #define __dmac_set_priority(p) 				\  3482 do {							\  3483 	REG_DMAC_DMACR &= ~DMAC_DMACR_PR_MASK;		\  3484 	REG_DMAC_DMACR |= ((p) << DMAC_DMACR_PR_BIT);	\  3485 } while (0)  3486   3487 #define __dmac_test_halt_error() ( REG_DMAC_DMACR & DMAC_DMACR_HLT )  3488 #define __dmac_test_addr_error() ( REG_DMAC_DMACR & DMAC_DMACR_AR )  3489   3490 #define __dmac_enable_descriptor(n) \  3491   ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_NDES )  3492 #define __dmac_disable_descriptor(n) \  3493   ( REG_DMAC_DCCSR((n)) |= DMAC_DCCSR_NDES )  3494   3495 #define __dmac_enable_channel(n) \  3496   ( REG_DMAC_DCCSR((n)) |= DMAC_DCCSR_EN )  3497 #define __dmac_disable_channel(n) \  3498   ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_EN )  3499 #define __dmac_channel_enabled(n) \  3500   ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_EN )  3501   3502 #define __dmac_channel_enable_irq(n) \  3503   ( REG_DMAC_DCMD((n)) |= DMAC_DCMD_TIE )  3504 #define __dmac_channel_disable_irq(n) \  3505   ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_TIE )  3506   3507 #define __dmac_channel_transmit_halt_detected(n) \  3508   (  REG_DMAC_DCCSR((n)) & DMAC_DCCSR_HLT )  3509 #define __dmac_channel_transmit_end_detected(n) \  3510   (  REG_DMAC_DCCSR((n)) & DMAC_DCCSR_TT )  3511 #define __dmac_channel_address_error_detected(n) \  3512   (  REG_DMAC_DCCSR((n)) & DMAC_DCCSR_AR )  3513 #define __dmac_channel_count_terminated_detected(n) \  3514   (  REG_DMAC_DCCSR((n)) & DMAC_DCCSR_CT )  3515 #define __dmac_channel_descriptor_invalid_detected(n) \  3516   (  REG_DMAC_DCCSR((n)) & DMAC_DCCSR_INV )  3517   3518 #define __dmac_channel_clear_transmit_halt(n) \  3519   (  REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_HLT )  3520 #define __dmac_channel_clear_transmit_end(n) \  3521   (  REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_TT )  3522 #define __dmac_channel_clear_address_error(n) \  3523   (  REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_AR )  3524 #define __dmac_channel_clear_count_terminated(n) \  3525   (  REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_CT )  3526 #define __dmac_channel_clear_descriptor_invalid(n) \  3527   (  REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_INV )  3528   3529 #define __dmac_channel_set_single_mode(n) \  3530   (  REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_TM )  3531 #define __dmac_channel_set_block_mode(n) \  3532   (  REG_DMAC_DCMD((n)) |= DMAC_DCMD_TM )  3533   3534 #define __dmac_channel_set_transfer_unit_32bit(n)	\  3535 do {							\  3536 	REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK;	\  3537 	REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_32BIT;	\  3538 } while (0)  3539   3540 #define __dmac_channel_set_transfer_unit_16bit(n)	\  3541 do {							\  3542 	REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK;	\  3543 	REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_16BIT;	\  3544 } while (0)  3545   3546 #define __dmac_channel_set_transfer_unit_8bit(n)	\  3547 do {							\  3548 	REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK;	\  3549 	REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_8BIT;	\  3550 } while (0)  3551   3552 #define __dmac_channel_set_transfer_unit_16byte(n)	\  3553 do {							\  3554 	REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK;	\  3555 	REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_16BYTE;	\  3556 } while (0)  3557   3558 #define __dmac_channel_set_transfer_unit_32byte(n)	\  3559 do {							\  3560 	REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK;	\  3561 	REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_32BYTE;	\  3562 } while (0)  3563   3564 /* w=8,16,32 */  3565 #define __dmac_channel_set_dest_port_width(n,w)		\  3566 do {							\  3567 	REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DWDH_MASK;	\  3568 	REG_DMAC_DCMD((n)) |= DMAC_DCMD_DWDH_##w;	\  3569 } while (0)  3570   3571 /* w=8,16,32 */  3572 #define __dmac_channel_set_src_port_width(n,w)		\  3573 do {							\  3574 	REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_SWDH_MASK;	\  3575 	REG_DMAC_DCMD((n)) |= DMAC_DCMD_SWDH_##w;	\  3576 } while (0)  3577   3578 /* v=0-15 */  3579 #define __dmac_channel_set_rdil(n,v)				\  3580 do {								\  3581 	REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_RDIL_MASK;		\  3582 	REG_DMAC_DCMD((n) |= ((v) << DMAC_DCMD_RDIL_BIT);	\  3583 } while (0)  3584   3585 #define __dmac_channel_dest_addr_fixed(n) \  3586   (  REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DAI )  3587 #define __dmac_channel_dest_addr_increment(n) \  3588   (  REG_DMAC_DCMD((n)) |= DMAC_DCMD_DAI )  3589   3590 #define __dmac_channel_src_addr_fixed(n) \  3591   (  REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_SAI )  3592 #define __dmac_channel_src_addr_increment(n) \  3593   (  REG_DMAC_DCMD((n)) |= DMAC_DCMD_SAI )  3594   3595 #define __dmac_channel_set_doorbell(n) \  3596   (  REG_DMAC_DMADBSR = (1 << (n)) )  3597   3598 #define __dmac_channel_irq_detected(n)  ( REG_DMAC_DMAIPR & (1 << (n)) )  3599 #define __dmac_channel_ack_irq(n)       ( REG_DMAC_DMAIPR &= ~(1 << (n)) )  3600   3601 static __inline__ int __dmac_get_irq(void)  3602 {  3603 	int i;  3604 	for (i = 0; i < MAX_DMA_NUM; i++)  3605 		if (__dmac_channel_irq_detected(i))  3606 			return i;  3607 	return -1;  3608 }  3609   3610   3611 /***************************************************************************  3612  * AIC (AC'97 & I2S Controller)  3613  ***************************************************************************/  3614   3615 #define __aic_enable()		( REG_AIC_FR |= AIC_FR_ENB )  3616 #define __aic_disable()		( REG_AIC_FR &= ~AIC_FR_ENB )  3617   3618 #define __aic_select_ac97()	( REG_AIC_FR &= ~AIC_FR_AUSEL )  3619 #define __aic_select_i2s()	( REG_AIC_FR |= AIC_FR_AUSEL )  3620   3621 #define __i2s_as_master()	( REG_AIC_FR |= AIC_FR_BCKD | AIC_FR_SYNCD )  3622 #define __i2s_as_slave()	( REG_AIC_FR &= ~(AIC_FR_BCKD | AIC_FR_SYNCD) )  3623 #define __aic_reset_status()          ( REG_AIC_FR & AIC_FR_RST )  3624   3625 #define __aic_reset()                                   \  3626 do {                                                    \  3627         REG_AIC_FR |= AIC_FR_RST;                       \  3628 } while(0)  3629   3630   3631 #define __aic_set_transmit_trigger(n) 			\  3632 do {							\  3633 	REG_AIC_FR &= ~AIC_FR_TFTH_MASK;		\  3634 	REG_AIC_FR |= ((n) << AIC_FR_TFTH_BIT);		\  3635 } while(0)  3636   3637 #define __aic_set_receive_trigger(n) 			\  3638 do {							\  3639 	REG_AIC_FR &= ~AIC_FR_RFTH_MASK;		\  3640 	REG_AIC_FR |= ((n) << AIC_FR_RFTH_BIT);		\  3641 } while(0)  3642   3643 #define __aic_enable_record()	( REG_AIC_CR |= AIC_CR_EREC )  3644 #define __aic_disable_record()	( REG_AIC_CR &= ~AIC_CR_EREC )  3645 #define __aic_enable_replay()	( REG_AIC_CR |= AIC_CR_ERPL )  3646 #define __aic_disable_replay()	( REG_AIC_CR &= ~AIC_CR_ERPL )  3647 #define __aic_enable_loopback()	( REG_AIC_CR |= AIC_CR_ENLBF )  3648 #define __aic_disable_loopback() ( REG_AIC_CR &= ~AIC_CR_ENLBF )  3649   3650 #define __aic_flush_fifo()	( REG_AIC_CR |= AIC_CR_FLUSH )  3651 #define __aic_unflush_fifo()	( REG_AIC_CR &= ~AIC_CR_FLUSH )  3652   3653 #define __aic_enable_transmit_intr() \  3654   ( REG_AIC_CR |= (AIC_CR_ETFS | AIC_CR_ETUR) )  3655 #define __aic_disable_transmit_intr() \  3656   ( REG_AIC_CR &= ~(AIC_CR_ETFS | AIC_CR_ETUR) )  3657 #define __aic_enable_receive_intr() \  3658   ( REG_AIC_CR |= (AIC_CR_ERFS | AIC_CR_EROR) )  3659 #define __aic_disable_receive_intr() \  3660   ( REG_AIC_CR &= ~(AIC_CR_ERFS | AIC_CR_EROR) )  3661   3662 #define __aic_enable_transmit_dma()  ( REG_AIC_CR |= AIC_CR_TDMS )  3663 #define __aic_disable_transmit_dma() ( REG_AIC_CR &= ~AIC_CR_TDMS )  3664 #define __aic_enable_receive_dma()   ( REG_AIC_CR |= AIC_CR_RDMS )  3665 #define __aic_disable_receive_dma()  ( REG_AIC_CR &= ~AIC_CR_RDMS )  3666   3667 #define __aic_enable_mono2stereo()   ( REG_AIC_CR |= AIC_CR_M2S )  3668 #define __aic_disable_mono2stereo()  ( REG_AIC_CR &= ~AIC_CR_M2S )  3669 #define __aic_enable_byteswap()      ( REG_AIC_CR |= AIC_CR_ENDSW )  3670 #define __aic_disable_byteswap()     ( REG_AIC_CR &= ~AIC_CR_ENDSW )  3671 #define __aic_enable_unsignadj()     ( REG_AIC_CR |= AIC_CR_AVSTSU )  3672 #define __aic_disable_unsignadj()    ( REG_AIC_CR &= ~AIC_CR_AVSTSU )  3673   3674 #define AC97_PCM_XS_L_FRONT   	AIC_ACCR1_XS_SLOT3  3675 #define AC97_PCM_XS_R_FRONT   	AIC_ACCR1_XS_SLOT4  3676 #define AC97_PCM_XS_CENTER    	AIC_ACCR1_XS_SLOT6  3677 #define AC97_PCM_XS_L_SURR    	AIC_ACCR1_XS_SLOT7  3678 #define AC97_PCM_XS_R_SURR    	AIC_ACCR1_XS_SLOT8  3679 #define AC97_PCM_XS_LFE       	AIC_ACCR1_XS_SLOT9  3680   3681 #define AC97_PCM_RS_L_FRONT   	AIC_ACCR1_RS_SLOT3  3682 #define AC97_PCM_RS_R_FRONT   	AIC_ACCR1_RS_SLOT4  3683 #define AC97_PCM_RS_CENTER    	AIC_ACCR1_RS_SLOT6  3684 #define AC97_PCM_RS_L_SURR    	AIC_ACCR1_RS_SLOT7  3685 #define AC97_PCM_RS_R_SURR    	AIC_ACCR1_RS_SLOT8  3686 #define AC97_PCM_RS_LFE       	AIC_ACCR1_RS_SLOT9  3687   3688 #define __ac97_set_xs_none()	( REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK )  3689 #define __ac97_set_xs_mono() 						\  3690 do {									\  3691 	REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK;				\  3692 	REG_AIC_ACCR1 |= AC97_PCM_XS_R_FRONT;				\  3693 } while(0)  3694 #define __ac97_set_xs_stereo() 						\  3695 do {									\  3696 	REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK;				\  3697 	REG_AIC_ACCR1 |= AC97_PCM_XS_L_FRONT | AC97_PCM_XS_R_FRONT;	\  3698 } while(0)  3699   3700 /* In fact, only stereo is support now. */   3701 #define __ac97_set_rs_none()	( REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK )  3702 #define __ac97_set_rs_mono() 						\  3703 do {									\  3704 	REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK;				\  3705 	REG_AIC_ACCR1 |= AC97_PCM_RS_R_FRONT;				\  3706 } while(0)  3707 #define __ac97_set_rs_stereo() 						\  3708 do {									\  3709 	REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK;				\  3710 	REG_AIC_ACCR1 |= AC97_PCM_RS_L_FRONT | AC97_PCM_RS_R_FRONT;	\  3711 } while(0)  3712   3713 #define __ac97_warm_reset_codec()		\  3714  do {						\  3715 	REG_AIC_ACCR2 |= AIC_ACCR2_SA;		\  3716 	REG_AIC_ACCR2 |= AIC_ACCR2_SS;		\  3717 	udelay(2);				\  3718 	REG_AIC_ACCR2 &= ~AIC_ACCR2_SS;		\  3719 	REG_AIC_ACCR2 &= ~AIC_ACCR2_SA;		\  3720  } while (0)  3721   3722 #define __ac97_cold_reset_codec()		\  3723  do {						\  3724 	REG_AIC_ACCR2 |=  AIC_ACCR2_SR;		\  3725 	udelay(2);				\  3726 	REG_AIC_ACCR2 &= ~AIC_ACCR2_SR;		\  3727  } while (0)  3728   3729 /* n=8,16,18,20 */  3730 #define __ac97_set_iass(n) \  3731  ( REG_AIC_ACCR2 = (REG_AIC_ACCR2 & ~AIC_ACCR2_IASS_MASK) | AIC_ACCR2_IASS_##n##BIT )  3732 #define __ac97_set_oass(n) \  3733  ( REG_AIC_ACCR2 = (REG_AIC_ACCR2 & ~AIC_ACCR2_OASS_MASK) | AIC_ACCR2_OASS_##n##BIT )  3734   3735 #define __i2s_select_i2s()            ( REG_AIC_I2SCR &= ~AIC_I2SCR_AMSL )  3736 #define __i2s_select_msbjustified()   ( REG_AIC_I2SCR |= AIC_I2SCR_AMSL )  3737   3738 /* n=8,16,18,20,24 */  3739 /*#define __i2s_set_sample_size(n) \  3740  ( REG_AIC_I2SCR |= (REG_AIC_I2SCR & ~AIC_I2SCR_WL_MASK) | AIC_I2SCR_WL_##n##BIT )*/  3741   3742 #define __i2s_set_oss_sample_size(n) \  3743  ( REG_AIC_CR = (REG_AIC_CR & ~AIC_CR_OSS_MASK) | AIC_CR_OSS_##n##BIT )  3744 #define __i2s_set_iss_sample_size(n) \  3745  ( REG_AIC_CR = (REG_AIC_CR & ~AIC_CR_ISS_MASK) | AIC_CR_ISS_##n##BIT )  3746   3747 #define __i2s_stop_bitclk()   ( REG_AIC_I2SCR |= AIC_I2SCR_STPBK )  3748 #define __i2s_start_bitclk()  ( REG_AIC_I2SCR &= ~AIC_I2SCR_STPBK )  3749   3750 #define __aic_transmit_request()  ( REG_AIC_SR & AIC_SR_TFS )  3751 #define __aic_receive_request()   ( REG_AIC_SR & AIC_SR_RFS )  3752 #define __aic_transmit_underrun() ( REG_AIC_SR & AIC_SR_TUR )  3753 #define __aic_receive_overrun()   ( REG_AIC_SR & AIC_SR_ROR )  3754   3755 #define __aic_clear_errors()      ( REG_AIC_SR &= ~(AIC_SR_TUR | AIC_SR_ROR) )  3756   3757 #define __aic_get_transmit_resident() \  3758   ( (REG_AIC_SR & AIC_SR_TFL_MASK) >> AIC_SR_TFL_BIT )  3759 #define __aic_get_receive_count() \  3760   ( (REG_AIC_SR & AIC_SR_RFL_MASK) >> AIC_SR_RFL_BIT )  3761   3762 #define __ac97_command_transmitted()     ( REG_AIC_ACSR & AIC_ACSR_CADT )  3763 #define __ac97_status_received()         ( REG_AIC_ACSR & AIC_ACSR_SADR )  3764 #define __ac97_status_receive_timeout()  ( REG_AIC_ACSR & AIC_ACSR_RSTO )  3765 #define __ac97_codec_is_low_power_mode() ( REG_AIC_ACSR & AIC_ACSR_CLPM )  3766 #define __ac97_codec_is_ready()          ( REG_AIC_ACSR & AIC_ACSR_CRDY )  3767 #define __ac97_slot_error_detected()     ( REG_AIC_ACSR & AIC_ACSR_SLTERR )  3768 #define __ac97_clear_slot_error()        ( REG_AIC_ACSR &= ~AIC_ACSR_SLTERR )  3769   3770 #define __i2s_is_busy()         ( REG_AIC_I2SSR & AIC_I2SSR_BSY )  3771   3772 #define CODEC_READ_CMD	        (1 << 19)  3773 #define CODEC_WRITE_CMD	        (0 << 19)  3774 #define CODEC_REG_INDEX_BIT     12  3775 #define CODEC_REG_INDEX_MASK	(0x7f << CODEC_REG_INDEX_BIT)	/* 18:12 */  3776 #define CODEC_REG_DATA_BIT      4  3777 #define CODEC_REG_DATA_MASK	(0x0ffff << 4)	/* 19:4 */  3778   3779 #define __ac97_out_rcmd_addr(reg) 					\  3780 do { 									\  3781     REG_AIC_ACCAR = CODEC_READ_CMD | ((reg) << CODEC_REG_INDEX_BIT); 	\  3782 } while (0)  3783   3784 #define __ac97_out_wcmd_addr(reg) 					\  3785 do { 									\  3786     REG_AIC_ACCAR = CODEC_WRITE_CMD | ((reg) << CODEC_REG_INDEX_BIT); 	\  3787 } while (0)  3788   3789 #define __ac97_out_data(value) 						\  3790 do { 									\  3791     REG_AIC_ACCDR = ((value) << CODEC_REG_DATA_BIT); 			\  3792 } while (0)  3793   3794 #define __ac97_in_data() \  3795  ( (REG_AIC_ACSDR & CODEC_REG_DATA_MASK) >> CODEC_REG_DATA_BIT )  3796   3797 #define __ac97_in_status_addr() \  3798  ( (REG_AIC_ACSAR & CODEC_REG_INDEX_MASK) >> CODEC_REG_INDEX_BIT )  3799   3800 #define __i2s_set_sample_rate(i2sclk, sync) \  3801   ( REG_AIC_I2SDIV = ((i2sclk) / (4*64)) / (sync) )  3802   3803 #define __aic_write_tfifo(v)  ( REG_AIC_DR = (v) )  3804 #define __aic_read_rfifo()    ( REG_AIC_DR )  3805   3806 #define __aic_internal_codec()  ( REG_AIC_FR |= AIC_FR_ICDC )   3807 #define __aic_external_codec()  ( REG_AIC_FR &= ~AIC_FR_ICDC )  3808   3809 /* Define next ops for AC97 compatible */  3810   3811 #define AC97_ACSR	AIC_ACSR  3812   3813 #define __ac97_enable()		__aic_enable(); __aic_select_ac97()  3814 #define __ac97_disable()	__aic_disable()  3815 #define __ac97_reset()		__aic_reset()  3816   3817 #define __ac97_set_transmit_trigger(n)	__aic_set_transmit_trigger(n)  3818 #define __ac97_set_receive_trigger(n)	__aic_set_receive_trigger(n)  3819   3820 #define __ac97_enable_record()		__aic_enable_record()  3821 #define __ac97_disable_record()		__aic_disable_record()  3822 #define __ac97_enable_replay()		__aic_enable_replay()  3823 #define __ac97_disable_replay()		__aic_disable_replay()  3824 #define __ac97_enable_loopback()	__aic_enable_loopback()  3825 #define __ac97_disable_loopback()	__aic_disable_loopback()  3826   3827 #define __ac97_enable_transmit_dma()	__aic_enable_transmit_dma()  3828 #define __ac97_disable_transmit_dma()	__aic_disable_transmit_dma()  3829 #define __ac97_enable_receive_dma()	__aic_enable_receive_dma()  3830 #define __ac97_disable_receive_dma()	__aic_disable_receive_dma()  3831   3832 #define __ac97_transmit_request()	__aic_transmit_request()  3833 #define __ac97_receive_request()	__aic_receive_request()  3834 #define __ac97_transmit_underrun()	__aic_transmit_underrun()  3835 #define __ac97_receive_overrun()	__aic_receive_overrun()  3836   3837 #define __ac97_clear_errors()		__aic_clear_errors()  3838   3839 #define __ac97_get_transmit_resident()	__aic_get_transmit_resident()  3840 #define __ac97_get_receive_count()	__aic_get_receive_count()  3841   3842 #define __ac97_enable_transmit_intr()	__aic_enable_transmit_intr()  3843 #define __ac97_disable_transmit_intr()	__aic_disable_transmit_intr()  3844 #define __ac97_enable_receive_intr()	__aic_enable_receive_intr()  3845 #define __ac97_disable_receive_intr()	__aic_disable_receive_intr()  3846   3847 #define __ac97_write_tfifo(v)		__aic_write_tfifo(v)  3848 #define __ac97_read_rfifo()		__aic_read_rfifo()  3849   3850 /* Define next ops for I2S compatible */  3851   3852 #define I2S_ACSR	AIC_I2SSR  3853   3854 #define __i2s_enable()		 __aic_enable(); __aic_select_i2s()  3855 #define __i2s_disable()		__aic_disable()  3856 #define __i2s_reset()		__aic_reset()  3857   3858 #define __i2s_set_transmit_trigger(n)	__aic_set_transmit_trigger(n)  3859 #define __i2s_set_receive_trigger(n)	__aic_set_receive_trigger(n)  3860   3861 #define __i2s_enable_record()		__aic_enable_record()  3862 #define __i2s_disable_record()		__aic_disable_record()  3863 #define __i2s_enable_replay()		__aic_enable_replay()  3864 #define __i2s_disable_replay()		__aic_disable_replay()  3865 #define __i2s_enable_loopback()		__aic_enable_loopback()  3866 #define __i2s_disable_loopback()	__aic_disable_loopback()  3867   3868 #define __i2s_enable_transmit_dma()	__aic_enable_transmit_dma()  3869 #define __i2s_disable_transmit_dma()	__aic_disable_transmit_dma()  3870 #define __i2s_enable_receive_dma()	__aic_enable_receive_dma()  3871 #define __i2s_disable_receive_dma()	__aic_disable_receive_dma()  3872   3873 #define __i2s_transmit_request()	__aic_transmit_request()  3874 #define __i2s_receive_request()		__aic_receive_request()  3875 #define __i2s_transmit_underrun()	__aic_transmit_underrun()  3876 #define __i2s_receive_overrun()		__aic_receive_overrun()  3877   3878 #define __i2s_clear_errors()		__aic_clear_errors()  3879   3880 #define __i2s_get_transmit_resident()	__aic_get_transmit_resident()  3881 #define __i2s_get_receive_count()	__aic_get_receive_count()  3882   3883 #define __i2s_enable_transmit_intr()	__aic_enable_transmit_intr()  3884 #define __i2s_disable_transmit_intr()	__aic_disable_transmit_intr()  3885 #define __i2s_enable_receive_intr()	__aic_enable_receive_intr()  3886 #define __i2s_disable_receive_intr()	__aic_disable_receive_intr()  3887   3888 #define __i2s_write_tfifo(v)		__aic_write_tfifo(v)  3889 #define __i2s_read_rfifo()		__aic_read_rfifo()  3890   3891 #define __i2s_reset_codec()			\  3892  do {						\  3893  } while (0)  3894   3895   3896 /***************************************************************************  3897  * ICDC  3898  ***************************************************************************/  3899 #define __i2s_internal_codec()         __aic_internal_codec()  3900 #define __i2s_external_codec()         __aic_external_codec()  3901   3902 /***************************************************************************  3903  * INTC  3904  ***************************************************************************/  3905 #define __intc_unmask_irq(n)	( REG_INTC_IMCR = (1 << (n)) )  3906 #define __intc_mask_irq(n)	( REG_INTC_IMSR = (1 << (n)) )  3907 #define __intc_ack_irq(n)	( REG_INTC_IPR = (1 << (n)) )  3908   3909   3910 /***************************************************************************  3911  * I2C  3912  ***************************************************************************/  3913   3914 #define __i2c_enable()		( REG_I2C_CR |= I2C_CR_I2CE )  3915 #define __i2c_disable()		( REG_I2C_CR &= ~I2C_CR_I2CE )  3916   3917 #define __i2c_send_start()	( REG_I2C_CR |= I2C_CR_STA )  3918 #define __i2c_send_stop()	( REG_I2C_CR |= I2C_CR_STO )  3919 #define __i2c_send_ack()	( REG_I2C_CR &= ~I2C_CR_AC )  3920 #define __i2c_send_nack()	( REG_I2C_CR |= I2C_CR_AC )  3921   3922 #define __i2c_set_drf()		( REG_I2C_SR |= I2C_SR_DRF )  3923 #define __i2c_clear_drf()	( REG_I2C_SR &= ~I2C_SR_DRF )  3924 #define __i2c_check_drf()	( REG_I2C_SR & I2C_SR_DRF )  3925   3926 #define __i2c_received_ack()	( !(REG_I2C_SR & I2C_SR_ACKF) )  3927 #define __i2c_is_busy()		( REG_I2C_SR & I2C_SR_BUSY )  3928 #define __i2c_transmit_ended()	( REG_I2C_SR & I2C_SR_TEND )  3929   3930 #define __i2c_set_clk(dev_clk, i2c_clk) \  3931   ( REG_I2C_GR = (dev_clk) / (16*(i2c_clk)) - 1 )  3932   3933 #define __i2c_read()		( REG_I2C_DR )  3934 #define __i2c_write(val)	( REG_I2C_DR = (val) )  3935   3936   3937 /***************************************************************************  3938  * MSC  3939  ***************************************************************************/  3940   3941 #define __msc_start_op() \  3942   ( REG_MSC_STRPCL = MSC_STRPCL_START_OP | MSC_STRPCL_CLOCK_CONTROL_START )  3943   3944 #define __msc_set_resto(to) 	( REG_MSC_RESTO = to )  3945 #define __msc_set_rdto(to) 	( REG_MSC_RDTO = to )  3946 #define __msc_set_cmd(cmd) 	( REG_MSC_CMD = cmd )  3947 #define __msc_set_arg(arg) 	( REG_MSC_ARG = arg )  3948 #define __msc_set_nob(nob) 	( REG_MSC_NOB = nob )  3949 #define __msc_get_nob() 	( REG_MSC_NOB )  3950 #define __msc_set_blklen(len) 	( REG_MSC_BLKLEN = len )  3951 #define __msc_set_cmdat(cmdat) 	( REG_MSC_CMDAT = cmdat )  3952 #define __msc_set_cmdat_ioabort() 	( REG_MSC_CMDAT |= MSC_CMDAT_IO_ABORT )  3953 #define __msc_clear_cmdat_ioabort() 	( REG_MSC_CMDAT &= ~MSC_CMDAT_IO_ABORT )  3954   3955 #define __msc_set_cmdat_bus_width1() 			\  3956 do { 							\  3957 	REG_MSC_CMDAT &= ~MSC_CMDAT_BUS_WIDTH_MASK; 	\  3958 	REG_MSC_CMDAT |= MSC_CMDAT_BUS_WIDTH_1BIT; 	\  3959 } while(0)  3960   3961 #define __msc_set_cmdat_bus_width4() 			\  3962 do { 							\  3963 	REG_MSC_CMDAT &= ~MSC_CMDAT_BUS_WIDTH_MASK; 	\  3964 	REG_MSC_CMDAT |= MSC_CMDAT_BUS_WIDTH_4BIT; 	\  3965 } while(0)  3966   3967 #define __msc_set_cmdat_dma_en() ( REG_MSC_CMDAT |= MSC_CMDAT_DMA_EN )  3968 #define __msc_set_cmdat_init() 	( REG_MSC_CMDAT |= MSC_CMDAT_INIT )  3969 #define __msc_set_cmdat_busy() 	( REG_MSC_CMDAT |= MSC_CMDAT_BUSY )  3970 #define __msc_set_cmdat_stream() ( REG_MSC_CMDAT |= MSC_CMDAT_STREAM_BLOCK )  3971 #define __msc_set_cmdat_block() ( REG_MSC_CMDAT &= ~MSC_CMDAT_STREAM_BLOCK )  3972 #define __msc_set_cmdat_read() 	( REG_MSC_CMDAT &= ~MSC_CMDAT_WRITE_READ )  3973 #define __msc_set_cmdat_write() ( REG_MSC_CMDAT |= MSC_CMDAT_WRITE_READ )  3974 #define __msc_set_cmdat_data_en() ( REG_MSC_CMDAT |= MSC_CMDAT_DATA_EN )  3975   3976 /* r is MSC_CMDAT_RESPONSE_FORMAT_Rx or MSC_CMDAT_RESPONSE_FORMAT_NONE */  3977 #define __msc_set_cmdat_res_format(r) 				\  3978 do { 								\  3979 	REG_MSC_CMDAT &= ~MSC_CMDAT_RESPONSE_FORMAT_MASK; 	\  3980 	REG_MSC_CMDAT |= (r); 					\  3981 } while(0)  3982   3983 #define __msc_clear_cmdat() \  3984   REG_MSC_CMDAT &= ~( MSC_CMDAT_IO_ABORT | MSC_CMDAT_DMA_EN | MSC_CMDAT_INIT| \  3985   MSC_CMDAT_BUSY | MSC_CMDAT_STREAM_BLOCK | MSC_CMDAT_WRITE_READ | \  3986   MSC_CMDAT_DATA_EN | MSC_CMDAT_RESPONSE_FORMAT_MASK )  3987   3988 #define __msc_get_imask() 		( REG_MSC_IMASK )  3989 #define __msc_mask_all_intrs() 		( REG_MSC_IMASK = 0xff )  3990 #define __msc_unmask_all_intrs() 	( REG_MSC_IMASK = 0x00 )  3991 #define __msc_mask_rd() 		( REG_MSC_IMASK |= MSC_IMASK_RXFIFO_RD_REQ )  3992 #define __msc_unmask_rd() 		( REG_MSC_IMASK &= ~MSC_IMASK_RXFIFO_RD_REQ )  3993 #define __msc_mask_wr() 		( REG_MSC_IMASK |= MSC_IMASK_TXFIFO_WR_REQ )  3994 #define __msc_unmask_wr() 		( REG_MSC_IMASK &= ~MSC_IMASK_TXFIFO_WR_REQ )  3995 #define __msc_mask_endcmdres() 		( REG_MSC_IMASK |= MSC_IMASK_END_CMD_RES )  3996 #define __msc_unmask_endcmdres() 	( REG_MSC_IMASK &= ~MSC_IMASK_END_CMD_RES )  3997 #define __msc_mask_datatrandone() 	( REG_MSC_IMASK |= MSC_IMASK_DATA_TRAN_DONE )  3998 #define __msc_unmask_datatrandone() 	( REG_MSC_IMASK &= ~MSC_IMASK_DATA_TRAN_DONE )  3999 #define __msc_mask_prgdone() 		( REG_MSC_IMASK |= MSC_IMASK_PRG_DONE )  4000 #define __msc_unmask_prgdone() 		( REG_MSC_IMASK &= ~MSC_IMASK_PRG_DONE )  4001   4002 /* n=0,1,2,3,4,5,6,7 */  4003 #define __msc_set_clkrt(n) 	\  4004 do { 				\  4005 	REG_MSC_CLKRT = n;	\  4006 } while(0)  4007   4008 #define __msc_get_ireg() 		( REG_MSC_IREG )  4009 #define __msc_ireg_rd() 		( REG_MSC_IREG & MSC_IREG_RXFIFO_RD_REQ )  4010 #define __msc_ireg_wr() 		( REG_MSC_IREG & MSC_IREG_TXFIFO_WR_REQ )  4011 #define __msc_ireg_end_cmd_res() 	( REG_MSC_IREG & MSC_IREG_END_CMD_RES )  4012 #define __msc_ireg_data_tran_done() 	( REG_MSC_IREG & MSC_IREG_DATA_TRAN_DONE )  4013 #define __msc_ireg_prg_done() 		( REG_MSC_IREG & MSC_IREG_PRG_DONE )  4014 #define __msc_ireg_clear_end_cmd_res() 	( REG_MSC_IREG = MSC_IREG_END_CMD_RES )  4015 #define __msc_ireg_clear_data_tran_done() ( REG_MSC_IREG = MSC_IREG_DATA_TRAN_DONE )  4016 #define __msc_ireg_clear_prg_done() 	( REG_MSC_IREG = MSC_IREG_PRG_DONE )  4017   4018 #define __msc_get_stat() 		( REG_MSC_STAT )  4019 #define __msc_stat_not_end_cmd_res() 	( (REG_MSC_STAT & MSC_STAT_END_CMD_RES) == 0)  4020 #define __msc_stat_crc_err() \  4021   ( REG_MSC_STAT & (MSC_STAT_CRC_RES_ERR | MSC_STAT_CRC_READ_ERROR | MSC_STAT_CRC_WRITE_ERROR_YES) )  4022 #define __msc_stat_res_crc_err() 	( REG_MSC_STAT & MSC_STAT_CRC_RES_ERR )  4023 #define __msc_stat_rd_crc_err() 	( REG_MSC_STAT & MSC_STAT_CRC_READ_ERROR )  4024 #define __msc_stat_wr_crc_err() 	( REG_MSC_STAT & MSC_STAT_CRC_WRITE_ERROR_YES )  4025 #define __msc_stat_resto_err() 		( REG_MSC_STAT & MSC_STAT_TIME_OUT_RES )  4026 #define __msc_stat_rdto_err() 		( REG_MSC_STAT & MSC_STAT_TIME_OUT_READ )  4027   4028 #define __msc_rd_resfifo() 		( REG_MSC_RES )  4029 #define __msc_rd_rxfifo()  		( REG_MSC_RXFIFO )  4030 #define __msc_wr_txfifo(v)  		( REG_MSC_TXFIFO = v )  4031   4032 #define __msc_reset() 						\  4033 do { 								\  4034 	REG_MSC_STRPCL = MSC_STRPCL_RESET;			\  4035  	while (REG_MSC_STAT & MSC_STAT_IS_RESETTING);		\  4036 } while (0)  4037   4038 #define __msc_start_clk() 					\  4039 do { 								\  4040 	REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_START;	\  4041 } while (0)  4042   4043 #define __msc_stop_clk() 					\  4044 do { 								\  4045 	REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_STOP;	\  4046 } while (0)  4047   4048 #define MMC_CLK 19169200  4049 #define SD_CLK  24576000  4050   4051 /* msc_clk should little than pclk and little than clk retrieve from card */  4052 #define __msc_calc_clk_divisor(type,dev_clk,msc_clk,lv)		\  4053 do {								\  4054 	unsigned int rate, pclk, i;				\  4055 	pclk = dev_clk;						\  4056 	rate = type?SD_CLK:MMC_CLK;				\  4057   	if (msc_clk && msc_clk < pclk)				\  4058     		pclk = msc_clk;					\  4059 	i = 0;							\  4060   	while (pclk < rate)					\  4061     	{							\  4062       		i ++;						\  4063       		rate >>= 1;					\  4064     	}							\  4065   	lv = i;							\  4066 } while(0)  4067   4068 /* divide rate to little than or equal to 400kHz */  4069 #define __msc_calc_slow_clk_divisor(type, lv)			\  4070 do {								\  4071 	unsigned int rate, i;					\  4072 	rate = (type?SD_CLK:MMC_CLK)/1000/400;			\  4073 	i = 0;							\  4074 	while (rate > 0)					\  4075     	{							\  4076       		rate >>= 1;					\  4077       		i ++;						\  4078     	}							\  4079   	lv = i;							\  4080 } while(0)  4081   4082   4083 /***************************************************************************  4084  * SSI  4085  ***************************************************************************/  4086   4087 #define __ssi_enable()    ( REG_SSI_CR0 |= SSI_CR0_SSIE )  4088 #define __ssi_disable()   ( REG_SSI_CR0 &= ~SSI_CR0_SSIE )  4089 #define __ssi_select_ce() ( REG_SSI_CR0 &= ~SSI_CR0_FSEL )  4090   4091 #define __ssi_normal_mode() ( REG_SSI_ITR &= ~SSI_ITR_IVLTM_MASK )  4092   4093 #define __ssi_select_ce2() 		\  4094 do { 					\  4095 	REG_SSI_CR0 |= SSI_CR0_FSEL; 	\  4096 	REG_SSI_CR1 &= ~SSI_CR1_MULTS; 	\  4097 } while (0)  4098   4099 #define __ssi_select_gpc() 		\  4100 do { 					\  4101 	REG_SSI_CR0 &= ~SSI_CR0_FSEL; 	\  4102 	REG_SSI_CR1 |= SSI_CR1_MULTS; 	\  4103 } while (0)  4104   4105 #define __ssi_enable_tx_intr() 	\  4106   ( REG_SSI_CR0 |= SSI_CR0_TIE | SSI_CR0_TEIE )  4107   4108 #define __ssi_disable_tx_intr() \  4109   ( REG_SSI_CR0 &= ~(SSI_CR0_TIE | SSI_CR0_TEIE) )  4110   4111 #define __ssi_enable_rx_intr() 	\  4112   ( REG_SSI_CR0 |= SSI_CR0_RIE | SSI_CR0_REIE )  4113   4114 #define __ssi_disable_rx_intr() \  4115   ( REG_SSI_CR0 &= ~(SSI_CR0_RIE | SSI_CR0_REIE) )  4116   4117 #define __ssi_enable_loopback()  ( REG_SSI_CR0 |= SSI_CR0_LOOP )  4118 #define __ssi_disable_loopback() ( REG_SSI_CR0 &= ~SSI_CR0_LOOP )  4119   4120 #define __ssi_enable_receive()   ( REG_SSI_CR0 &= ~SSI_CR0_DISREV )  4121 #define __ssi_disable_receive()  ( REG_SSI_CR0 |= SSI_CR0_DISREV )  4122   4123 #define __ssi_finish_receive() 	\  4124   ( REG_SSI_CR0 |= (SSI_CR0_RFINE | SSI_CR0_RFINC) )  4125   4126 #define __ssi_disable_recvfinish() \  4127   ( REG_SSI_CR0 &= ~(SSI_CR0_RFINE | SSI_CR0_RFINC) )  4128   4129 #define __ssi_flush_txfifo()   ( REG_SSI_CR0 |= SSI_CR0_TFLUSH )  4130 #define __ssi_flush_rxfifo()   ( REG_SSI_CR0 |= SSI_CR0_RFLUSH )  4131   4132 #define __ssi_flush_fifo() \  4133   ( REG_SSI_CR0 |= SSI_CR0_TFLUSH | SSI_CR0_RFLUSH )  4134   4135 #define __ssi_finish_transmit() ( REG_SSI_CR1 &= ~SSI_CR1_UNFIN )  4136   4137 #define __ssi_spi_format() 					\  4138 do { 								\  4139 	REG_SSI_CR1 &= ~SSI_CR1_FMAT_MASK; 			\  4140 	REG_SSI_CR1 |= SSI_CR1_FMAT_SPI; 			\  4141 	REG_SSI_CR1 &= ~(SSI_CR1_TFVCK_MASK|SSI_CR1_TCKFI_MASK);\  4142 	REG_SSI_CR1 |= (SSI_CR1_TFVCK_1 | SSI_CR1_TCKFI_1);	\  4143 } while (0)  4144   4145 /* TI's SSP format, must clear SSI_CR1.UNFIN */  4146 #define __ssi_ssp_format() 					\  4147 do { 								\  4148 	REG_SSI_CR1 &= ~(SSI_CR1_FMAT_MASK | SSI_CR1_UNFIN); 	\  4149 	REG_SSI_CR1 |= SSI_CR1_FMAT_SSP; 			\  4150 } while (0)  4151   4152 /* National's Microwire format, must clear SSI_CR0.RFINE, and set max delay */  4153 #define __ssi_microwire_format() 				\  4154 do { 								\  4155 	REG_SSI_CR1 &= ~SSI_CR1_FMAT_MASK; 			\  4156 	REG_SSI_CR1 |= SSI_CR1_FMAT_MW1; 			\  4157 	REG_SSI_CR1 &= ~(SSI_CR1_TFVCK_MASK|SSI_CR1_TCKFI_MASK);\  4158 	REG_SSI_CR1 |= (SSI_CR1_TFVCK_3 | SSI_CR1_TCKFI_3);	\  4159 	REG_SSI_CR0 &= ~SSI_CR0_RFINE; 				\  4160 } while (0)  4161   4162 /* CE# level (FRMHL), CE# in interval time (ITFRM),  4163    clock phase and polarity (PHA POL),  4164    interval time (SSIITR), interval characters/frame (SSIICR) */  4165   4166  /* frmhl,endian,mcom,flen,pha,pol MASK */  4167 #define SSICR1_MISC_MASK 					\  4168 	( SSI_CR1_FRMHL_MASK | SSI_CR1_LFST | SSI_CR1_MCOM_MASK	\  4169 	| SSI_CR1_FLEN_MASK | SSI_CR1_PHA | SSI_CR1_POL )	\  4170   4171 #define __ssi_spi_set_misc(frmhl,endian,flen,mcom,pha,pol)	\  4172 do { 								\  4173 	REG_SSI_CR1 &= ~SSICR1_MISC_MASK; 			\  4174 	REG_SSI_CR1 |= ((frmhl) << 30) | ((endian) << 25) | 	\  4175 		 (((mcom) - 1) << 12) | (((flen) - 2) << 4) | 	\  4176 	         ((pha) << 1) | (pol); 				\  4177 } while(0)  4178   4179 /* Transfer with MSB or LSB first */  4180 #define __ssi_set_msb() ( REG_SSI_CR1 &= ~SSI_CR1_LFST )  4181 #define __ssi_set_lsb() ( REG_SSI_CR1 |= SSI_CR1_LFST )  4182   4183 #define __ssi_set_frame_length(n) \  4184     REG_SSI_CR1 = (REG_SSI_CR1 & ~SSI_CR1_FLEN_MASK) | (((n) - 2) << 4)   4185   4186 /* n = 1 - 16 */  4187 #define __ssi_set_microwire_command_length(n) \  4188     ( REG_SSI_CR1 = ((REG_SSI_CR1 & ~SSI_CR1_MCOM_MASK) | SSI_CR1_MCOM_##n##BIT) )  4189   4190 /* Set the clock phase for SPI */  4191 #define __ssi_set_spi_clock_phase(n) \  4192     ( REG_SSI_CR1 = ((REG_SSI_CR1 & ~SSI_CR1_PHA) | (n&0x1)) )  4193   4194 /* Set the clock polarity for SPI */  4195 #define __ssi_set_spi_clock_polarity(n) \  4196     ( REG_SSI_CR1 = ((REG_SSI_CR1 & ~SSI_CR1_POL) | (n&0x1)) )  4197   4198 /* n = ix8 */  4199 #define __ssi_set_tx_trigger(n) 		\  4200 do { 						\  4201 	REG_SSI_CR1 &= ~SSI_CR1_TTRG_MASK; 	\  4202 	REG_SSI_CR1 |= SSI_CR1_TTRG_##n; 	\  4203 } while (0)  4204   4205 /* n = ix8 */  4206 #define __ssi_set_rx_trigger(n) 		\  4207 do { 						\  4208 	REG_SSI_CR1 &= ~SSI_CR1_RTRG_MASK; 	\  4209 	REG_SSI_CR1 |= SSI_CR1_RTRG_##n; 	\  4210 } while (0)  4211   4212 #define __ssi_get_txfifo_count() \  4213     ( (REG_SSI_SR & SSI_SR_TFIFONUM_MASK) >> SSI_SR_TFIFONUM_BIT )  4214   4215 #define __ssi_get_rxfifo_count() \  4216     ( (REG_SSI_SR & SSI_SR_RFIFONUM_MASK) >> SSI_SR_RFIFONUM_BIT )  4217   4218 #define __ssi_clear_errors() \  4219     ( REG_SSI_SR &= ~(SSI_SR_UNDR | SSI_SR_OVER) )  4220   4221 #define __ssi_transfer_end()	( REG_SSI_SR & SSI_SR_END )  4222 #define __ssi_is_busy()		( REG_SSI_SR & SSI_SR_BUSY )  4223   4224 #define __ssi_txfifo_full()	( REG_SSI_SR & SSI_SR_TFF )  4225 #define __ssi_rxfifo_empty()	( REG_SSI_SR & SSI_SR_RFE )  4226 #define __ssi_rxfifo_noempty()	( REG_SSI_SR & SSI_SR_RFHF )  4227   4228 #define __ssi_set_clk(dev_clk, ssi_clk) \  4229   ( REG_SSI_GR = (dev_clk) / (2*(ssi_clk)) - 1 )  4230   4231 #define __ssi_receive_data()    REG_SSI_DR  4232 #define __ssi_transmit_data(v)  ( REG_SSI_DR = (v) )  4233   4234   4235 /***************************************************************************  4236  * CIM  4237  ***************************************************************************/  4238   4239 #define __cim_enable()	( REG_CIM_CTRL |= CIM_CTRL_ENA )  4240 #define __cim_disable()	( REG_CIM_CTRL &= ~CIM_CTRL_ENA )  4241   4242 #define __cim_input_data_inverse()	( REG_CIM_CFG |= CIM_CFG_INV_DAT )  4243 #define __cim_input_data_normal()	( REG_CIM_CFG &= ~CIM_CFG_INV_DAT )  4244   4245 #define __cim_vsync_active_low()	( REG_CIM_CFG |= CIM_CFG_VSP )  4246 #define __cim_vsync_active_high()	( REG_CIM_CFG &= ~CIM_CFG_VSP )  4247   4248 #define __cim_hsync_active_low()	( REG_CIM_CFG |= CIM_CFG_HSP )  4249 #define __cim_hsync_active_high()	( REG_CIM_CFG &= ~CIM_CFG_HSP )  4250   4251 #define __cim_sample_data_at_pclk_falling_edge() \  4252   ( REG_CIM_CFG |= CIM_CFG_PCP )  4253 #define __cim_sample_data_at_pclk_rising_edge() \  4254   ( REG_CIM_CFG &= ~CIM_CFG_PCP )  4255   4256 #define __cim_enable_dummy_zero()	( REG_CIM_CFG |= CIM_CFG_DUMMY_ZERO )  4257 #define __cim_disable_dummy_zero()	( REG_CIM_CFG &= ~CIM_CFG_DUMMY_ZERO )  4258   4259 #define __cim_select_external_vsync()	( REG_CIM_CFG |= CIM_CFG_EXT_VSYNC )  4260 #define __cim_select_internal_vsync()	( REG_CIM_CFG &= ~CIM_CFG_EXT_VSYNC )  4261   4262 /* n=0-7 */  4263 #define __cim_set_data_packing_mode(n) 		\  4264 do {						\  4265     REG_CIM_CFG &= ~CIM_CFG_PACK_MASK; 		\  4266     REG_CIM_CFG |= (CIM_CFG_PACK_##n); 		\  4267 } while (0)  4268   4269 #define __cim_enable_ccir656_progressive_mode()	\  4270 do {						\  4271     REG_CIM_CFG &= ~CIM_CFG_DSM_MASK; 		\  4272     REG_CIM_CFG |= CIM_CFG_DSM_CPM; 		\  4273 } while (0)  4274   4275 #define __cim_enable_ccir656_interlace_mode()	\  4276 do {						\  4277     REG_CIM_CFG &= ~CIM_CFG_DSM_MASK; 		\  4278     REG_CIM_CFG |= CIM_CFG_DSM_CIM; 		\  4279 } while (0)  4280   4281 #define __cim_enable_gated_clock_mode()		\  4282 do {						\  4283     REG_CIM_CFG &= ~CIM_CFG_DSM_MASK; 		\  4284     REG_CIM_CFG |= CIM_CFG_DSM_GCM; 		\  4285 } while (0)  4286   4287 #define __cim_enable_nongated_clock_mode()	\  4288 do {						\  4289     REG_CIM_CFG &= ~CIM_CFG_DSM_MASK; 		\  4290     REG_CIM_CFG |= CIM_CFG_DSM_NGCM; 		\  4291 } while (0)  4292   4293 /* sclk:system bus clock  4294  * mclk: CIM master clock  4295  */  4296 #define __cim_set_master_clk(sclk, mclk)			\  4297 do {								\  4298     REG_CIM_CTRL &= ~CIM_CTRL_MCLKDIV_MASK;			\  4299     REG_CIM_CTRL |= (((sclk)/(mclk) - 1) << CIM_CTRL_MCLKDIV_BIT);	\  4300 } while (0)  4301   4302 #define __cim_enable_sof_intr() \  4303   ( REG_CIM_CTRL |= CIM_CTRL_DMA_SOFM )  4304 #define __cim_disable_sof_intr() \  4305   ( REG_CIM_CTRL &= ~CIM_CTRL_DMA_SOFM )  4306   4307 #define __cim_enable_eof_intr() \  4308   ( REG_CIM_CTRL |= CIM_CTRL_DMA_EOFM )  4309 #define __cim_disable_eof_intr() \  4310   ( REG_CIM_CTRL &= ~CIM_CTRL_DMA_EOFM )  4311   4312 #define __cim_enable_stop_intr() \  4313   ( REG_CIM_CTRL |= CIM_CTRL_DMA_STOPM )  4314 #define __cim_disable_stop_intr() \  4315   ( REG_CIM_CTRL &= ~CIM_CTRL_DMA_STOPM )  4316   4317 #define __cim_enable_trig_intr() \  4318   ( REG_CIM_CTRL |= CIM_CTRL_RXF_TRIGM )  4319 #define __cim_disable_trig_intr() \  4320   ( REG_CIM_CTRL &= ~CIM_CTRL_RXF_TRIGM )  4321   4322 #define __cim_enable_rxfifo_overflow_intr() \  4323   ( REG_CIM_CTRL |= CIM_CTRL_RXF_OFM )  4324 #define __cim_disable_rxfifo_overflow_intr() \  4325   ( REG_CIM_CTRL &= ~CIM_CTRL_RXF_OFM )  4326   4327 /* n=1-16 */  4328 #define __cim_set_frame_rate(n) 		\  4329 do {						\  4330     REG_CIM_CTRL &= ~CIM_CTRL_FRC_MASK; 	\  4331     REG_CIM_CTRL |= CIM_CTRL_FRC_##n; 		\  4332 } while (0)  4333   4334 #define __cim_enable_dma()   ( REG_CIM_CTRL |= CIM_CTRL_DMA_EN )  4335 #define __cim_disable_dma()  ( REG_CIM_CTRL &= ~CIM_CTRL_DMA_EN )  4336   4337 #define __cim_reset_rxfifo() ( REG_CIM_CTRL |= CIM_CTRL_RXF_RST )  4338 #define __cim_unreset_rxfifo() ( REG_CIM_CTRL &= ~CIM_CTRL_RXF_RST )  4339   4340 /* n=4,8,12,16,20,24,28,32 */  4341 #define __cim_set_rxfifo_trigger(n) 		\  4342 do {						\  4343     REG_CIM_CTRL &= ~CIM_CTRL_RXF_TRIG_MASK; 	\  4344     REG_CIM_CTRL |= CIM_CTRL_RXF_TRIG_##n; 	\  4345 } while (0)  4346   4347 #define __cim_clear_state()   	     ( REG_CIM_STATE = 0 )  4348   4349 #define __cim_disable_done()   	     ( REG_CIM_STATE & CIM_STATE_VDD )  4350 #define __cim_rxfifo_empty()   	     ( REG_CIM_STATE & CIM_STATE_RXF_EMPTY )  4351 #define __cim_rxfifo_reach_trigger() ( REG_CIM_STATE & CIM_STATE_RXF_TRIG )  4352 #define __cim_rxfifo_overflow()      ( REG_CIM_STATE & CIM_STATE_RXF_OF )  4353 #define __cim_clear_rxfifo_overflow() ( REG_CIM_STATE &= ~CIM_STATE_RXF_OF )  4354 #define __cim_dma_stop()   	     ( REG_CIM_STATE & CIM_STATE_DMA_STOP )  4355 #define __cim_dma_eof()   	     ( REG_CIM_STATE & CIM_STATE_DMA_EOF )  4356 #define __cim_dma_sof()   	     ( REG_CIM_STATE & CIM_STATE_DMA_SOF )  4357   4358 #define __cim_get_iid()   	     ( REG_CIM_IID )  4359 #define __cim_get_image_data()       ( REG_CIM_RXFIFO )  4360 #define __cim_get_dam_cmd()          ( REG_CIM_CMD )  4361   4362 #define __cim_set_da(a)              ( REG_CIM_DA = (a) )  4363   4364 /***************************************************************************  4365  * LCD  4366  ***************************************************************************/  4367 #define __lcd_as_smart_lcd() 		( REG_LCD_CFG |= (1<<LCD_CFG_LCDPIN_BIT) )  4368 #define __lcd_as_general_lcd() 		( REG_LCD_CFG &= ~(1<<LCD_CFG_LCDPIN_BIT) )  4369   4370 #define __lcd_set_dis()			( REG_LCD_CTRL |= LCD_CTRL_DIS )  4371 #define __lcd_clr_dis()			( REG_LCD_CTRL &= ~LCD_CTRL_DIS )  4372   4373 #define __lcd_set_ena()			( REG_LCD_CTRL |= LCD_CTRL_ENA )  4374 #define __lcd_clr_ena()			( REG_LCD_CTRL &= ~LCD_CTRL_ENA )  4375   4376 /* n=1,2,4,8,16 */  4377 #define __lcd_set_bpp(n) \  4378   ( REG_LCD_CTRL = (REG_LCD_CTRL & ~LCD_CTRL_BPP_MASK) | LCD_CTRL_BPP_##n )  4379   4380 /* n=4,8,16 */  4381 #define __lcd_set_burst_length(n) 		\  4382 do {						\  4383 	REG_LCD_CTRL &= ~LCD_CTRL_BST_MASK;	\  4384 	REG_LCD_CTRL |= LCD_CTRL_BST_n##;	\  4385 } while (0)  4386   4387 #define __lcd_select_rgb565()		( REG_LCD_CTRL &= ~LCD_CTRL_RGB555 )  4388 #define __lcd_select_rgb555()		( REG_LCD_CTRL |= LCD_CTRL_RGB555 )  4389   4390 #define __lcd_set_ofup()		( REG_LCD_CTRL |= LCD_CTRL_OFUP )  4391 #define __lcd_clr_ofup()		( REG_LCD_CTRL &= ~LCD_CTRL_OFUP )  4392   4393 /* n=2,4,16 */  4394 #define __lcd_set_stn_frc(n) 			\  4395 do {						\  4396 	REG_LCD_CTRL &= ~LCD_CTRL_FRC_MASK;	\  4397 	REG_LCD_CTRL |= LCD_CTRL_FRC_n##;	\  4398 } while (0)  4399   4400   4401 #define __lcd_pixel_endian_little()	( REG_LCD_CTRL |= LCD_CTRL_PEDN )  4402 #define __lcd_pixel_endian_big()	( REG_LCD_CTRL &= ~LCD_CTRL_PEDN )  4403   4404 #define __lcd_reverse_byte_endian()	( REG_LCD_CTRL |= LCD_CTRL_BEDN )  4405 #define __lcd_normal_byte_endian()	( REG_LCD_CTRL &= ~LCD_CTRL_BEDN )  4406   4407 #define __lcd_enable_eof_intr()		( REG_LCD_CTRL |= LCD_CTRL_EOFM )  4408 #define __lcd_disable_eof_intr()	( REG_LCD_CTRL &= ~LCD_CTRL_EOFM )  4409   4410 #define __lcd_enable_sof_intr()		( REG_LCD_CTRL |= LCD_CTRL_SOFM )  4411 #define __lcd_disable_sof_intr()	( REG_LCD_CTRL &= ~LCD_CTRL_SOFM )  4412   4413 #define __lcd_enable_ofu_intr()		( REG_LCD_CTRL |= LCD_CTRL_OFUM )  4414 #define __lcd_disable_ofu_intr()	( REG_LCD_CTRL &= ~LCD_CTRL_OFUM )  4415   4416 #define __lcd_enable_ifu0_intr()	( REG_LCD_CTRL |= LCD_CTRL_IFUM0 )  4417 #define __lcd_disable_ifu0_intr()	( REG_LCD_CTRL &= ~LCD_CTRL_IFUM0 )  4418   4419 #define __lcd_enable_ifu1_intr()	( REG_LCD_CTRL |= LCD_CTRL_IFUM1 )  4420 #define __lcd_disable_ifu1_intr()	( REG_LCD_CTRL &= ~LCD_CTRL_IFUM1 )  4421   4422 #define __lcd_enable_ldd_intr()		( REG_LCD_CTRL |= LCD_CTRL_LDDM )  4423 #define __lcd_disable_ldd_intr()	( REG_LCD_CTRL &= ~LCD_CTRL_LDDM )  4424   4425 #define __lcd_enable_qd_intr()		( REG_LCD_CTRL |= LCD_CTRL_QDM )  4426 #define __lcd_disable_qd_intr()		( REG_LCD_CTRL &= ~LCD_CTRL_QDM )  4427   4428   4429 /* LCD status register indication */  4430   4431 #define __lcd_quick_disable_done()	( REG_LCD_STATE & LCD_STATE_QD )  4432 #define __lcd_disable_done()		( REG_LCD_STATE & LCD_STATE_LDD )  4433 #define __lcd_infifo0_underrun()	( REG_LCD_STATE & LCD_STATE_IFU0 )  4434 #define __lcd_infifo1_underrun()	( REG_LCD_STATE & LCD_STATE_IFU1 )  4435 #define __lcd_outfifo_underrun()	( REG_LCD_STATE & LCD_STATE_OFU )  4436 #define __lcd_start_of_frame()		( REG_LCD_STATE & LCD_STATE_SOF )  4437 #define __lcd_end_of_frame()		( REG_LCD_STATE & LCD_STATE_EOF )  4438   4439 #define __lcd_clr_outfifounderrun()	( REG_LCD_STATE &= ~LCD_STATE_OFU )  4440 #define __lcd_clr_sof()			( REG_LCD_STATE &= ~LCD_STATE_SOF )  4441 #define __lcd_clr_eof()			( REG_LCD_STATE &= ~LCD_STATE_EOF )  4442   4443 #define __lcd_panel_white()		( REG_LCD_CFG |= LCD_CFG_WHITE )  4444 #define __lcd_panel_black()		( REG_LCD_CFG &= ~LCD_CFG_WHITE )  4445   4446 /* n=1,2,4,8 for single mono-STN   4447  * n=4,8 for dual mono-STN  4448  */  4449 #define __lcd_set_panel_datawidth(n) 		\  4450 do { 						\  4451 	REG_LCD_CFG &= ~LCD_CFG_PDW_MASK; 	\  4452 	REG_LCD_CFG |= LCD_CFG_PDW_n##;		\  4453 } while (0)  4454   4455 /* m=LCD_CFG_MODE_GENERUIC_TFT_xxx */  4456 #define __lcd_set_panel_mode(m) 		\  4457 do {						\  4458 	REG_LCD_CFG &= ~LCD_CFG_MODE_MASK;	\  4459 	REG_LCD_CFG |= (m);			\  4460 } while(0)  4461   4462 /* n = 0-255 */  4463 #define __lcd_disable_ac_bias()		( REG_LCD_IO = 0xff )  4464 #define __lcd_set_ac_bias(n) 			\  4465 do {						\  4466 	REG_LCD_IO &= ~LCD_IO_ACB_MASK;		\  4467 	REG_LCD_IO |= ((n) << LCD_IO_ACB_BIT);	\  4468 } while(0)  4469   4470 #define __lcd_io_set_dir()		( REG_LCD_IO |= LCD_IO_DIR )  4471 #define __lcd_io_clr_dir()		( REG_LCD_IO &= ~LCD_IO_DIR )  4472   4473 #define __lcd_io_set_dep()		( REG_LCD_IO |= LCD_IO_DEP )  4474 #define __lcd_io_clr_dep()		( REG_LCD_IO &= ~LCD_IO_DEP )  4475   4476 #define __lcd_io_set_vsp()		( REG_LCD_IO |= LCD_IO_VSP )  4477 #define __lcd_io_clr_vsp()		( REG_LCD_IO &= ~LCD_IO_VSP )  4478   4479 #define __lcd_io_set_hsp()		( REG_LCD_IO |= LCD_IO_HSP )  4480 #define __lcd_io_clr_hsp()		( REG_LCD_IO &= ~LCD_IO_HSP )  4481   4482 #define __lcd_io_set_pcp()		( REG_LCD_IO |= LCD_IO_PCP )  4483 #define __lcd_io_clr_pcp()		( REG_LCD_IO &= ~LCD_IO_PCP )  4484   4485 #define __lcd_vsync_get_vps() \  4486   ( (REG_LCD_VSYNC & LCD_VSYNC_VPS_MASK) >> LCD_VSYNC_VPS_BIT )  4487   4488 #define __lcd_vsync_get_vpe() \  4489   ( (REG_LCD_VSYNC & LCD_VSYNC_VPE_MASK) >> LCD_VSYNC_VPE_BIT )  4490 #define __lcd_vsync_set_vpe(n) 				\  4491 do {							\  4492 	REG_LCD_VSYNC &= ~LCD_VSYNC_VPE_MASK;		\  4493 	REG_LCD_VSYNC |= (n) << LCD_VSYNC_VPE_BIT;	\  4494 } while (0)  4495   4496 #define __lcd_hsync_get_hps() \  4497   ( (REG_LCD_HSYNC & LCD_HSYNC_HPS_MASK) >> LCD_HSYNC_HPS_BIT )  4498 #define __lcd_hsync_set_hps(n) 				\  4499 do {							\  4500 	REG_LCD_HSYNC &= ~LCD_HSYNC_HPS_MASK;		\  4501 	REG_LCD_HSYNC |= (n) << LCD_HSYNC_HPS_BIT;	\  4502 } while (0)  4503   4504 #define __lcd_hsync_get_hpe() \  4505   ( (REG_LCD_HSYNC & LCD_HSYNC_HPE_MASK) >> LCD_VSYNC_HPE_BIT )  4506 #define __lcd_hsync_set_hpe(n) 				\  4507 do {							\  4508 	REG_LCD_HSYNC &= ~LCD_HSYNC_HPE_MASK;		\  4509 	REG_LCD_HSYNC |= (n) << LCD_HSYNC_HPE_BIT;	\  4510 } while (0)  4511   4512 #define __lcd_vat_get_ht() \  4513   ( (REG_LCD_VAT & LCD_VAT_HT_MASK) >> LCD_VAT_HT_BIT )  4514 #define __lcd_vat_set_ht(n) 				\  4515 do {							\  4516 	REG_LCD_VAT &= ~LCD_VAT_HT_MASK;		\  4517 	REG_LCD_VAT |= (n) << LCD_VAT_HT_BIT;		\  4518 } while (0)  4519   4520 #define __lcd_vat_get_vt() \  4521   ( (REG_LCD_VAT & LCD_VAT_VT_MASK) >> LCD_VAT_VT_BIT )  4522 #define __lcd_vat_set_vt(n) 				\  4523 do {							\  4524 	REG_LCD_VAT &= ~LCD_VAT_VT_MASK;		\  4525 	REG_LCD_VAT |= (n) << LCD_VAT_VT_BIT;		\  4526 } while (0)  4527   4528 #define __lcd_dah_get_hds() \  4529   ( (REG_LCD_DAH & LCD_DAH_HDS_MASK) >> LCD_DAH_HDS_BIT )  4530 #define __lcd_dah_set_hds(n) 				\  4531 do {							\  4532 	REG_LCD_DAH &= ~LCD_DAH_HDS_MASK;		\  4533 	REG_LCD_DAH |= (n) << LCD_DAH_HDS_BIT;		\  4534 } while (0)  4535   4536 #define __lcd_dah_get_hde() \  4537   ( (REG_LCD_DAH & LCD_DAH_HDE_MASK) >> LCD_DAH_HDE_BIT )  4538 #define __lcd_dah_set_hde(n) 				\  4539 do {							\  4540 	REG_LCD_DAH &= ~LCD_DAH_HDE_MASK;		\  4541 	REG_LCD_DAH |= (n) << LCD_DAH_HDE_BIT;		\  4542 } while (0)  4543   4544 #define __lcd_dav_get_vds() \  4545   ( (REG_LCD_DAV & LCD_DAV_VDS_MASK) >> LCD_DAV_VDS_BIT )  4546 #define __lcd_dav_set_vds(n) 				\  4547 do {							\  4548 	REG_LCD_DAV &= ~LCD_DAV_VDS_MASK;		\  4549 	REG_LCD_DAV |= (n) << LCD_DAV_VDS_BIT;		\  4550 } while (0)  4551   4552 #define __lcd_dav_get_vde() \  4553   ( (REG_LCD_DAV & LCD_DAV_VDE_MASK) >> LCD_DAV_VDE_BIT )  4554 #define __lcd_dav_set_vde(n) 				\  4555 do {							\  4556 	REG_LCD_DAV &= ~LCD_DAV_VDE_MASK;		\  4557 	REG_LCD_DAV |= (n) << LCD_DAV_VDE_BIT;		\  4558 } while (0)  4559   4560 #define __lcd_cmd0_set_sofint()		( REG_LCD_CMD0 |= LCD_CMD_SOFINT )  4561 #define __lcd_cmd0_clr_sofint()		( REG_LCD_CMD0 &= ~LCD_CMD_SOFINT )  4562 #define __lcd_cmd1_set_sofint()		( REG_LCD_CMD1 |= LCD_CMD_SOFINT )  4563 #define __lcd_cmd1_clr_sofint()		( REG_LCD_CMD1 &= ~LCD_CMD_SOFINT )  4564   4565 #define __lcd_cmd0_set_eofint()		( REG_LCD_CMD0 |= LCD_CMD_EOFINT )  4566 #define __lcd_cmd0_clr_eofint()		( REG_LCD_CMD0 &= ~LCD_CMD_EOFINT )  4567 #define __lcd_cmd1_set_eofint()		( REG_LCD_CMD1 |= LCD_CMD_EOFINT )  4568 #define __lcd_cmd1_clr_eofint()		( REG_LCD_CMD1 &= ~LCD_CMD_EOFINT )  4569   4570 #define __lcd_cmd0_set_pal()		( REG_LCD_CMD0 |= LCD_CMD_PAL )  4571 #define __lcd_cmd0_clr_pal()		( REG_LCD_CMD0 &= ~LCD_CMD_PAL )  4572   4573 #define __lcd_cmd0_get_len() \  4574   ( (REG_LCD_CMD0 & LCD_CMD_LEN_MASK) >> LCD_CMD_LEN_BIT )  4575 #define __lcd_cmd1_get_len() \  4576   ( (REG_LCD_CMD1 & LCD_CMD_LEN_MASK) >> LCD_CMD_LEN_BIT )  4577   4578 /***************************************************************************  4579  * RTC ops  4580  ***************************************************************************/  4581   4582 #define __rtc_write_ready()  ( REG_RTC_RCR & RTC_RCR_WRDY )  4583 #define __rtc_enabled()      \  4584 do{                          \  4585       while(!__rtc_write_ready());  \  4586       REG_RTC_RCR |= RTC_RCR_RTCE ; \  4587 }while(0)                           \  4588   4589 #define __rtc_disabled()         \  4590 do{                          \  4591       while(!__rtc_write_ready());  \  4592       REG_RTC_RCR &= ~RTC_RCR_RTCE; \  4593 }while(0)  4594 #define __rtc_enable_alarm()       \  4595 do{                          \  4596       while(!__rtc_write_ready());  \  4597       REG_RTC_RCR |= RTC_RCR_AE; \  4598 }while(0)  4599   4600 #define __rtc_disable_alarm()    \  4601 do{                          \  4602       while(!__rtc_write_ready());  \  4603       REG_RTC_RCR &= ~RTC_RCR_AE; \  4604 }while(0)  4605   4606 #define __rtc_enable_alarm_irq()  \  4607 do{                          \  4608       while(!__rtc_write_ready());  \  4609       REG_RTC_RCR |= RTC_RCR_AIE; \  4610 }while(0)  4611   4612 #define __rtc_disable_alarm_irq() \  4613 do{                          \  4614       while(!__rtc_write_ready());  \  4615       REG_RTC_RCR &= ~RTC_RCR_AIE; \  4616 }while(0)  4617 #define __rtc_enable_Hz_irq()      \  4618 do{                          \  4619       while(!__rtc_write_ready());  \  4620       REG_RTC_RCR |= RTC_RCR_HZIE;  \  4621 }while(0)  4622   4623 #define __rtc_disable_Hz_irq()     \  4624 do{                          \  4625       while(!__rtc_write_ready());  \  4626       REG_RTC_RCR &= ~RTC_RCR_HZIE; \  4627 }while(0)  4628 #define __rtc_get_1Hz_flag()     \  4629 do{                                 \  4630       while(!__rtc_write_ready());  \  4631       ((REG_RTC_RCR >> RTC_RCR_HZ) & 0x1); \  4632 }while(0)  4633 #define __rtc_clear_1Hz_flag()      \  4634 do{                                 \  4635       while(!__rtc_write_ready());  \  4636       REG_RTC_RCR &= ~RTC_RCR_HZ;   \  4637 }while(0)  4638 #define __rtc_get_alarm_flag()       \  4639 do{                                  \  4640        while(!__rtc_write_ready());  \  4641       ((REG_RTC_RCR >> RTC_RCR_AF) & 0x1) \  4642 while(0)  4643 #define __rtc_clear_alarm_flag()    \  4644 do{                                 \  4645       while(!__rtc_write_ready());  \  4646       REG_RTC_RCR &= ~RTC_RCR_AF;   \  4647 }while(0)  4648 #define  __rtc_get_second()        \  4649 do{                                \  4650        while(!__rtc_write_ready());\  4651 	   REG_RTC_RSR;                \  4652 }while(0)  4653    4654 #define __rtc_set_second(v)         \  4655 do{                                 \  4656       while(!__rtc_write_ready());  \  4657       REG_RTC_RSR = v;              \  4658 }while(0)  4659   4660 #define  __rtc_get_alarm_second()  \  4661 do{                                \  4662       while(!__rtc_write_ready()); \  4663 	  REG_RTC_RSAR;                \  4664 }while(0)  4665   4666   4667 #define __rtc_set_alarm_second(v)   \  4668 do{                                 \  4669       while(!__rtc_write_ready());  \  4670       REG_RTC_RSAR = v;             \  4671 }while(0)  4672   4673 #define __rtc_RGR_is_locked()       \  4674 do{                                 \  4675       while(!__rtc_write_ready());  \  4676       REG_RTC_RGR >> RTC_RGR_LOCK;  \  4677 }while(0)  4678 #define __rtc_lock_RGR()            \  4679 do{                                 \  4680       while(!__rtc_write_ready());  \  4681       REG_RTC_RGR |= RTC_RGR_LOCK;  \  4682 }while(0)  4683   4684 #define __rtc_unlock_RGR()       \  4685 do{                                 \  4686       while(!__rtc_write_ready());  \  4687       REG_RTC_RGR &= ~RTC_RGR_LOCK; \  4688 }while(0)  4689   4690 #define __rtc_get_adjc_val()       \  4691 do{                                \  4692       while(!__rtc_write_ready());  \  4693       ( (REG_RTC_RGR & RTC_RGR_ADJC_MASK) >> RTC_RGR_ADJC_BIT ); \  4694 }while(0)  4695 #define __rtc_set_adjc_val(v)      \  4696 do{                                 \  4697       while(!__rtc_write_ready());  \  4698       ( REG_RTC_RGR = ( (REG_RTC_RGR & ~RTC_RGR_ADJC_MASK) | (v << RTC_RGR_ADJC_BIT) )) \  4699 }while(0)  4700   4701 #define __rtc_get_nc1Hz_val()       \  4702       while(!__rtc_write_ready());  \  4703       ( (REG_RTC_RGR & RTC_RGR_NC1HZ_MASK) >> RTC_RGR_NC1HZ_BIT )  4704   4705 #define __rtc_set_nc1Hz_val(v)      \  4706 do{                                 \  4707       while(!__rtc_write_ready());  \  4708       ( REG_RTC_RGR = ( (REG_RTC_RGR & ~RTC_RGR_NC1HZ_MASK) | (v << RTC_RGR_NC1HZ_BIT) )) \  4709 }while(0)  4710 #define __rtc_power_down()          \  4711 do{                                 \  4712       while(!__rtc_write_ready());  \  4713       REG_RTC_HCR |= RTC_HCR_PD;    \  4714 }while(0)  4715   4716 #define __rtc_get_hwfcr_val()       \  4717 do{                                 \  4718       while(!__rtc_write_ready());  \  4719       REG_RTC_HWFCR & RTC_HWFCR_MASK;  \  4720 }while(0)  4721 #define __rtc_set_hwfcr_val(v)      \  4722 do{                                 \  4723       while(!__rtc_write_ready());  \  4724       REG_RTC_HWFCR = (v) & RTC_HWFCR_MASK;  \  4725 }while(0)  4726   4727 #define __rtc_get_hrcr_val()      \  4728 do{                               \  4729       while(!__rtc_write_ready());  \  4730       ( REG_RTC_HRCR & RTC_HRCR_MASK ); \  4731 }while(0)  4732 #define __rtc_set_hrcr_val(v)        \  4733 do{                                 \  4734       while(!__rtc_write_ready());  \  4735       ( REG_RTC_HRCR = (v) & RTC_HRCR_MASK );  \  4736 }while(0)  4737   4738 #define __rtc_enable_alarm_wakeup()      \  4739 do{                                 \  4740       while(!__rtc_write_ready());  \  4741       ( REG_RTC_HWCR |= RTC_HWCR_EALM );  \  4742 }while(0)  4743   4744 #define __rtc_disable_alarm_wakeup()     \  4745 do{                                 \  4746       while(!__rtc_write_ready());  \  4747       ( REG_RTC_HWCR &= ~RTC_HWCR_EALM );  \  4748 }while(0)  4749   4750 #define __rtc_status_hib_reset_occur()    \  4751 do{                                       \  4752       while(!__rtc_write_ready());        \  4753     ( (REG_RTC_HWRSR >> RTC_HWRSR_HR) & 0x1 ); \  4754 }while(0)  4755 #define __rtc_status_ppr_reset_occur()     \  4756 do{                                        \  4757       while(!__rtc_write_ready());        \  4758    ( (REG_RTC_HWRSR >> RTC_HWRSR_PPR) & 0x1 ); \  4759 }while(0)  4760 #define __rtc_status_wakeup_pin_waken_up() \  4761 do{                                        \  4762       while(!__rtc_write_ready());        \  4763    ( (REG_RTC_HWRSR >> RTC_HWRSR_PIN) & 0x1 ); \  4764 }while(0)  4765 #define __rtc_status_alarm_waken_up()      \  4766 do{                                       \  4767       while(!__rtc_write_ready());        \  4768   ( (REG_RTC_HWRSR >> RTC_HWRSR_ALM) & 0x1 ); \  4769 }while(0)  4770 #define __rtc_clear_hib_stat_all()  \  4771 do{                                 \  4772       while(!__rtc_write_ready());  \  4773       ( REG_RTC_HWRSR = 0 );        \  4774 }while(0)  4775   4776 #define __rtc_get_scratch_pattern() \  4777       while(!__rtc_write_ready());  \  4778 		  (REG_RTC_HSPR)  4779 #define __rtc_set_scratch_pattern(n) 		\  4780 do{                                 \  4781       while(!__rtc_write_ready());  \  4782       (REG_RTC_HSPR = n );        \  4783 }while(0)  4784   4785   4786 #endif /* !__ASSEMBLY__ */  4787   4788 #endif /* __JZ4740_H__ */