2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/board-nanonote.c Fri May 22 18:37:44 2015 +0200
2.3 @@ -0,0 +1,232 @@
2.4 +/*
2.5 + * Ben NanoNote board initialisation, based on uboot-xburst and xburst-tools.
2.6 + *
2.7 + * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
2.8 + * Copyright (C) Xiangfu Liu <xiangfu.z@gmail.com>
2.9 + * Copyright (c) 2006 Ingenic Semiconductor, <jlwei@ingenic.cn>
2.10 + *
2.11 + * This program is free software; you can redistribute it and/or modify it under
2.12 + * the terms of the GNU General Public License as published by the Free Software
2.13 + * Foundation; either version 3 of the License, or (at your option) any later
2.14 + * version.
2.15 + *
2.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
2.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2.18 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2.19 + * details.
2.20 + *
2.21 + * You should have received a copy of the GNU General Public License along with
2.22 + * this program. If not, see <http://www.gnu.org/licenses/>.
2.23 + */
2.24 +
2.25 +#include "jz4740.h"
2.26 +#include "configs.h"
2.27 +
2.28 +void gpio_init(void)
2.29 +{
2.30 + /*
2.31 + * Initialize NAND Flash Pins
2.32 + */
2.33 + __gpio_as_nand();
2.34 +
2.35 + /*
2.36 + * Initialize SDRAM pins
2.37 + */
2.38 + __gpio_as_sdram_32bit();
2.39 +
2.40 + /*
2.41 + * Initialize LCD pins
2.42 + */
2.43 + __gpio_as_lcd_8bit();
2.44 +
2.45 + /*
2.46 + * Initialize MSC pins
2.47 + */
2.48 + __gpio_as_msc();
2.49 +
2.50 + /*
2.51 + * Initialize Other pins
2.52 + */
2.53 + unsigned int i;
2.54 + for (i = 0; i < 7; i++){
2.55 + __gpio_as_input(GPIO_KEYIN_BASE + i);
2.56 + __gpio_enable_pull(GPIO_KEYIN_BASE + i);
2.57 + }
2.58 +
2.59 + for (i = 0; i < 8; i++) {
2.60 + __gpio_as_output(GPIO_KEYOUT_BASE + i);
2.61 + __gpio_clear_pin(GPIO_KEYOUT_BASE + i);
2.62 + }
2.63 +
2.64 + /* enable the TP4, TP5 as UART0 */
2.65 + __gpio_jtag_to_uart0();
2.66 +
2.67 + __gpio_as_input(GPIO_KEYIN_8);
2.68 + __gpio_enable_pull(GPIO_KEYIN_8);
2.69 +
2.70 + __gpio_as_output(GPIO_AUDIO_POP);
2.71 + __gpio_set_pin(GPIO_AUDIO_POP);
2.72 +
2.73 + __gpio_as_output(GPIO_LCD_CS);
2.74 + __gpio_clear_pin(GPIO_LCD_CS);
2.75 +
2.76 + __gpio_as_output(GPIO_AMP_EN);
2.77 + __gpio_clear_pin(GPIO_AMP_EN);
2.78 +
2.79 + __gpio_as_output(GPIO_SDPW_EN);
2.80 + __gpio_disable_pull(GPIO_SDPW_EN);
2.81 + __gpio_clear_pin(GPIO_SDPW_EN);
2.82 +
2.83 + __gpio_as_input(GPIO_SD_DETECT);
2.84 + __gpio_disable_pull(GPIO_SD_DETECT);
2.85 +
2.86 + __gpio_as_input(GPIO_USB_DETECT);
2.87 + __gpio_enable_pull(GPIO_USB_DETECT);
2.88 +}
2.89 +
2.90 +void cpm_init(void)
2.91 +{
2.92 + __cpm_stop_ipu();
2.93 + __cpm_stop_cim();
2.94 + __cpm_stop_i2c();
2.95 + __cpm_stop_ssi();
2.96 + __cpm_stop_uart1();
2.97 + __cpm_stop_sadc();
2.98 + __cpm_stop_uhc();
2.99 + __cpm_stop_udc();
2.100 + __cpm_stop_aic1();
2.101 +/* __cpm_stop_aic2();*/
2.102 +}
2.103 +
2.104 +void pll_init(void)
2.105 +{
2.106 + register unsigned int cfcr, plcr1;
2.107 + int n2FR[33] = {
2.108 + 0, 0, 1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 0, 0,
2.109 + 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0,
2.110 + 9
2.111 + };
2.112 + int nf, pllout2;
2.113 +
2.114 + cfcr = CPM_CPCCR_CLKOEN |
2.115 + (n2FR[PHM_DIV] << CPM_CPCCR_CDIV_BIT) |
2.116 + (n2FR[PHM_DIV] << CPM_CPCCR_HDIV_BIT) |
2.117 + (n2FR[PHM_DIV] << CPM_CPCCR_PDIV_BIT) |
2.118 + (n2FR[PHM_DIV] << CPM_CPCCR_MDIV_BIT) |
2.119 + (n2FR[PHM_DIV] << CPM_CPCCR_LDIV_BIT);
2.120 +
2.121 + pllout2 = (cfcr & CPM_CPCCR_PCS) ? CFG_CPU_SPEED : (CFG_CPU_SPEED / 2);
2.122 +
2.123 + /* Init USB Host clock, pllout2 must be n*48MHz */
2.124 + REG_CPM_UHCCDR = pllout2 / 48000000 - 1;
2.125 +
2.126 + nf = CFG_CPU_SPEED * 2 / CFG_EXTAL;
2.127 + plcr1 = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | /* FD */
2.128 + (0 << CPM_CPPCR_PLLN_BIT) | /* RD=0, NR=2 */
2.129 + (0 << CPM_CPPCR_PLLOD_BIT) | /* OD=0, NO=1 */
2.130 + (0x20 << CPM_CPPCR_PLLST_BIT) | /* PLL stable time */
2.131 + CPM_CPPCR_PLLEN; /* enable PLL */
2.132 +
2.133 + /* init PLL */
2.134 + REG_CPM_CPCCR = cfcr;
2.135 + REG_CPM_CPPCR = plcr1;
2.136 +}
2.137 +
2.138 +void sdram_init(void)
2.139 +{
2.140 + register unsigned int dmcr0, dmcr, sdmode, tmp, cpu_clk, mem_clk, ns;
2.141 +
2.142 + unsigned int cas_latency_sdmr[2] = {
2.143 + EMC_SDMR_CAS_2,
2.144 + EMC_SDMR_CAS_3,
2.145 + };
2.146 +
2.147 + unsigned int cas_latency_dmcr[2] = {
2.148 + 1 << EMC_DMCR_TCL_BIT, /* CAS latency is 2 */
2.149 + 2 << EMC_DMCR_TCL_BIT /* CAS latency is 3 */
2.150 + };
2.151 +
2.152 + int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
2.153 +
2.154 + cpu_clk = CFG_CPU_SPEED;
2.155 + mem_clk = cpu_clk * div[__cpm_get_cdiv()] / div[__cpm_get_mdiv()];
2.156 +
2.157 + REG_EMC_BCR = 0; /* Disable bus release */
2.158 + REG_EMC_RTCSR = 0; /* Disable clock for counting */
2.159 +
2.160 + /* Fault DMCR value for mode register setting*/
2.161 +#define SDRAM_ROW0 11
2.162 +#define SDRAM_COL0 8
2.163 +#define SDRAM_BANK40 0
2.164 +
2.165 + dmcr0 = ((SDRAM_ROW0-11)<<EMC_DMCR_RA_BIT) |
2.166 + ((SDRAM_COL0-8)<<EMC_DMCR_CA_BIT) |
2.167 + (SDRAM_BANK40<<EMC_DMCR_BA_BIT) |
2.168 + (SDRAM_BW16<<EMC_DMCR_BW_BIT) |
2.169 + EMC_DMCR_EPIN |
2.170 + cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
2.171 +
2.172 + /* Basic DMCR value */
2.173 + dmcr = ((SDRAM_ROW-11)<<EMC_DMCR_RA_BIT) |
2.174 + ((SDRAM_COL-8)<<EMC_DMCR_CA_BIT) |
2.175 + (SDRAM_BANK4<<EMC_DMCR_BA_BIT) |
2.176 + (SDRAM_BW16<<EMC_DMCR_BW_BIT) |
2.177 + EMC_DMCR_EPIN |
2.178 + cas_latency_dmcr[((SDRAM_CASL == 3) ? 1 : 0)];
2.179 +
2.180 + /* SDRAM timimg */
2.181 + ns = 1000000000 / mem_clk;
2.182 + tmp = SDRAM_TRAS/ns;
2.183 + if (tmp < 4) tmp = 4;
2.184 + if (tmp > 11) tmp = 11;
2.185 + dmcr |= ((tmp-4) << EMC_DMCR_TRAS_BIT);
2.186 + tmp = SDRAM_RCD/ns;
2.187 + if (tmp > 3) tmp = 3;
2.188 + dmcr |= (tmp << EMC_DMCR_RCD_BIT);
2.189 + tmp = SDRAM_TPC/ns;
2.190 + if (tmp > 7) tmp = 7;
2.191 + dmcr |= (tmp << EMC_DMCR_TPC_BIT);
2.192 + tmp = SDRAM_TRWL/ns;
2.193 + if (tmp > 3) tmp = 3;
2.194 + dmcr |= (tmp << EMC_DMCR_TRWL_BIT);
2.195 + tmp = (SDRAM_TRAS + SDRAM_TPC)/ns;
2.196 + if (tmp > 14) tmp = 14;
2.197 + dmcr |= (((tmp + 1) >> 1) << EMC_DMCR_TRC_BIT);
2.198 +
2.199 + /* SDRAM mode value */
2.200 + sdmode = EMC_SDMR_BT_SEQ |
2.201 + EMC_SDMR_OM_NORMAL |
2.202 + EMC_SDMR_BL_4 |
2.203 + cas_latency_sdmr[((SDRAM_CASL == 3) ? 1 : 0)];
2.204 +
2.205 + /* Stage 1. Precharge all banks by writing SDMR with DMCR.MRSET=0 */
2.206 + REG_EMC_DMCR = dmcr;
2.207 + REG8(EMC_SDMR0|sdmode) = 0;
2.208 +
2.209 + /* Wait for precharge, > 200us */
2.210 + tmp = (cpu_clk / 1000000) * 1000;
2.211 + while (tmp--);
2.212 +
2.213 + /* Stage 2. Enable auto-refresh */
2.214 + REG_EMC_DMCR = dmcr | EMC_DMCR_RFSH;
2.215 +
2.216 + tmp = SDRAM_TREF/ns;
2.217 + tmp = tmp/64 + 1;
2.218 + if (tmp > 0xff) tmp = 0xff;
2.219 + REG_EMC_RTCOR = tmp;
2.220 + REG_EMC_RTCNT = 0;
2.221 + REG_EMC_RTCSR = EMC_RTCSR_CKS_64; /* Divisor is 64, CKO/64 */
2.222 +
2.223 + /* Wait for number of auto-refresh cycles */
2.224 + tmp = (cpu_clk / 1000000) * 1000;
2.225 + while (tmp--);
2.226 +
2.227 + /* Stage 3. Mode Register Set */
2.228 + REG_EMC_DMCR = dmcr0 | EMC_DMCR_RFSH | EMC_DMCR_MRSET;
2.229 + REG8(EMC_SDMR0|sdmode) = 0;
2.230 +
2.231 + /* Set back to basic DMCR value */
2.232 + REG_EMC_DMCR = dmcr | EMC_DMCR_RFSH | EMC_DMCR_MRSET;
2.233 +
2.234 + /* everything is ok now */
2.235 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/include/jz4740.h Fri May 22 18:37:44 2015 +0200
7.3 @@ -0,0 +1,4837 @@
7.4 +/*
7.5 + * Include file for Ingenic Semiconductor's JZ4740 CPU.
7.6 + *
7.7 + * Copyright 2009 (C) Qi Hardware Inc.,
7.8 + * Author: Xiangfu Liu <xiangfu@sharism.cc>
7.9 + *
7.10 + * This program is free software; you can redistribute it and/or
7.11 + * modify it under the terms of the GNU General Public License
7.12 + * version 3 as published by the Free Software Foundation.
7.13 + *
7.14 + * This program is distributed in the hope that it will be useful,
7.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.17 + * GNU General Public License for more details.
7.18 + *
7.19 + * You should have received a copy of the GNU General Public License
7.20 + * along with this program; if not, write to the Free Software
7.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
7.22 + * Boston, MA 02110-1301, USA
7.23 + */
7.24 +#ifndef __JZ4740_H__
7.25 +#define __JZ4740_H__
7.26 +
7.27 +#include "xburst_types.h"
7.28 +
7.29 +#if 0
7.30 +static inline void jz_flush_dcache(void)
7.31 +{
7.32 + unsigned long start;
7.33 + unsigned long end;
7.34 +
7.35 + start = KSEG0;
7.36 + end = start + CFG_DCACHE_SIZE;
7.37 + while (start < end) {
7.38 + cache_unroll(start,Index_Writeback_Inv_D);
7.39 + start += CFG_CACHELINE_SIZE;
7.40 + }
7.41 +}
7.42 +
7.43 +static inline void jz_flush_icache(void)
7.44 +{
7.45 + unsigned long start;
7.46 + unsigned long end;
7.47 +
7.48 + start = KSEG0;
7.49 + end = start + CFG_ICACHE_SIZE;
7.50 + while(start < end) {
7.51 + cache_unroll(start,Index_Invalidate_I);
7.52 + start += CFG_CACHELINE_SIZE;
7.53 + }
7.54 +}
7.55 +
7.56 +#endif
7.57 +#define cache_unroll(base,op) \
7.58 + __asm__ __volatile__(" \
7.59 + .set noreorder; \
7.60 + .set mips3; \
7.61 + cache %1, (%0); \
7.62 + .set mips0; \
7.63 + .set reorder" \
7.64 + : \
7.65 + : "r" (base), \
7.66 + "i" (op));
7.67 +/* cpu pipeline flush */
7.68 +static inline void jz_sync(void)
7.69 +{
7.70 + __asm__ volatile ("sync");
7.71 +}
7.72 +
7.73 +static inline void jz_writeb(u32 address, u8 value)
7.74 +{
7.75 + *((volatile u8 *)address) = value;
7.76 +}
7.77 +
7.78 +static inline void jz_writew(u32 address, u16 value)
7.79 +{
7.80 + *((volatile u16 *)address) = value;
7.81 +}
7.82 +
7.83 +static inline void jz_writel(u32 address, u32 value)
7.84 +{
7.85 + *((volatile u32 *)address) = value;
7.86 +}
7.87 +
7.88 +static inline u8 jz_readb(u32 address)
7.89 +{
7.90 + return *((volatile u8 *)address);
7.91 +}
7.92 +
7.93 +static inline u16 jz_readw(u32 address)
7.94 +{
7.95 + return *((volatile u16 *)address);
7.96 +}
7.97 +
7.98 +static inline u32 jz_readl(u32 address)
7.99 +{
7.100 + return *((volatile u32 *)address);
7.101 +}
7.102 +
7.103 +/* Boot ROM Specification */
7.104 +
7.105 +/* NOR Boot config */
7.106 +#define JZ4740_NORBOOT_8BIT 0x00000000 /* 8-bit data bus flash */
7.107 +#define JZ4740_NORBOOT_16BIT 0x10101010 /* 16-bit data bus flash */
7.108 +#define JZ4740_NORBOOT_32BIT 0x20202020 /* 32-bit data bus flash */
7.109 +
7.110 +/* NAND Boot config */
7.111 +#define JZ4740_NANDBOOT_B8R3 0xffffffff /* 8-bit bus & 3 row cycles */
7.112 +#define JZ4740_NANDBOOT_B8R2 0xf0f0f0f0 /* 8-bit bus & 2 row cycles */
7.113 +#define JZ4740_NANDBOOT_B16R3 0x0f0f0f0f /* 16-bit bus & 3 row cycles */
7.114 +#define JZ4740_NANDBOOT_B16R2 0x00000000 /* 16-bit bus & 2 row cycles */
7.115 +
7.116 +
7.117 +/* Register Definitions */
7.118 +#define CPM_BASE 0xB0000000
7.119 +#define INTC_BASE 0xB0001000
7.120 +#define TCU_BASE 0xB0002000
7.121 +#define WDT_BASE 0xB0002000
7.122 +#define RTC_BASE 0xB0003000
7.123 +#define GPIO_BASE 0xB0010000
7.124 +#define AIC_BASE 0xB0020000
7.125 +#define ICDC_BASE 0xB0020000
7.126 +#define MSC_BASE 0xB0021000
7.127 +#define UART0_BASE 0xB0030000
7.128 +#define I2C_BASE 0xB0042000
7.129 +#define SSI_BASE 0xB0043000
7.130 +#define SADC_BASE 0xB0070000
7.131 +#define EMC_BASE 0xB3010000
7.132 +#define DMAC_BASE 0xB3020000
7.133 +#define UHC_BASE 0xB3030000
7.134 +#define UDC_BASE 0xB3040000
7.135 +#define LCD_BASE 0xB3050000
7.136 +#define SLCD_BASE 0xB3050000
7.137 +#define CIM_BASE 0xB3060000
7.138 +#define ETH_BASE 0xB3100000
7.139 +
7.140 +
7.141 +/*************************************************************************
7.142 + * INTC (Interrupt Controller)
7.143 + *************************************************************************/
7.144 +#define INTC_ISR (INTC_BASE + 0x00)
7.145 +#define INTC_IMR (INTC_BASE + 0x04)
7.146 +#define INTC_IMSR (INTC_BASE + 0x08)
7.147 +#define INTC_IMCR (INTC_BASE + 0x0c)
7.148 +#define INTC_IPR (INTC_BASE + 0x10)
7.149 +
7.150 +#define REG_INTC_ISR REG32(INTC_ISR)
7.151 +#define REG_INTC_IMR REG32(INTC_IMR)
7.152 +#define REG_INTC_IMSR REG32(INTC_IMSR)
7.153 +#define REG_INTC_IMCR REG32(INTC_IMCR)
7.154 +#define REG_INTC_IPR REG32(INTC_IPR)
7.155 +
7.156 +/* 1st-level interrupts */
7.157 +#define IRQ_I2C 1
7.158 +#define IRQ_UHC 3
7.159 +#define IRQ_UART0 9
7.160 +#define IRQ_SADC 12
7.161 +#define IRQ_MSC 14
7.162 +#define IRQ_RTC 15
7.163 +#define IRQ_SSI 16
7.164 +#define IRQ_CIM 17
7.165 +#define IRQ_AIC 18
7.166 +#define IRQ_ETH 19
7.167 +#define IRQ_DMAC 20
7.168 +#define IRQ_TCU2 21
7.169 +#define IRQ_TCU1 22
7.170 +#define IRQ_TCU0 23
7.171 +#define IRQ_UDC 24
7.172 +#define IRQ_GPIO3 25
7.173 +#define IRQ_GPIO2 26
7.174 +#define IRQ_GPIO1 27
7.175 +#define IRQ_GPIO0 28
7.176 +#define IRQ_IPU 29
7.177 +#define IRQ_LCD 30
7.178 +
7.179 +/* 2nd-level interrupts */
7.180 +#define IRQ_DMA_0 32 /* 32 to 37 for DMAC channel 0 to 5 */
7.181 +#define IRQ_GPIO_0 48 /* 48 to 175 for GPIO pin 0 to 127 */
7.182 +
7.183 +
7.184 +/*************************************************************************
7.185 + * RTC
7.186 + *************************************************************************/
7.187 +#define RTC_RCR (RTC_BASE + 0x00) /* RTC Control Register */
7.188 +#define RTC_RSR (RTC_BASE + 0x04) /* RTC Second Register */
7.189 +#define RTC_RSAR (RTC_BASE + 0x08) /* RTC Second Alarm Register */
7.190 +#define RTC_RGR (RTC_BASE + 0x0c) /* RTC Regulator Register */
7.191 +
7.192 +#define RTC_HCR (RTC_BASE + 0x20) /* Hibernate Control Register */
7.193 +#define RTC_HWFCR (RTC_BASE + 0x24) /* Hibernate Wakeup Filter Counter Reg */
7.194 +#define RTC_HRCR (RTC_BASE + 0x28) /* Hibernate Reset Counter Register */
7.195 +#define RTC_HWCR (RTC_BASE + 0x2c) /* Hibernate Wakeup Control Register */
7.196 +#define RTC_HWRSR (RTC_BASE + 0x30) /* Hibernate Wakeup Status Register */
7.197 +#define RTC_HSPR (RTC_BASE + 0x34) /* Hibernate Scratch Pattern Register */
7.198 +
7.199 +#define REG_RTC_RCR REG32(RTC_RCR)
7.200 +#define REG_RTC_RSR REG32(RTC_RSR)
7.201 +#define REG_RTC_RSAR REG32(RTC_RSAR)
7.202 +#define REG_RTC_RGR REG32(RTC_RGR)
7.203 +#define REG_RTC_HCR REG32(RTC_HCR)
7.204 +#define REG_RTC_HWFCR REG32(RTC_HWFCR)
7.205 +#define REG_RTC_HRCR REG32(RTC_HRCR)
7.206 +#define REG_RTC_HWCR REG32(RTC_HWCR)
7.207 +#define REG_RTC_HWRSR REG32(RTC_HWRSR)
7.208 +#define REG_RTC_HSPR REG32(RTC_HSPR)
7.209 +
7.210 +/* RTC Control Register */
7.211 +#define RTC_RCR_WRDY (1 << 7) /* Write Ready Flag */
7.212 +#define RTC_RCR_HZ (1 << 6) /* 1Hz Flag */
7.213 +#define RTC_RCR_HZIE (1 << 5) /* 1Hz Interrupt Enable */
7.214 +#define RTC_RCR_AF (1 << 4) /* Alarm Flag */
7.215 +#define RTC_RCR_AIE (1 << 3) /* Alarm Interrupt Enable */
7.216 +#define RTC_RCR_AE (1 << 2) /* Alarm Enable */
7.217 +#define RTC_RCR_RTCE (1 << 0) /* RTC Enable */
7.218 +
7.219 +/* RTC Regulator Register */
7.220 +#define RTC_RGR_LOCK (1 << 31) /* Lock Bit */
7.221 +#define RTC_RGR_ADJC_BIT 16
7.222 +#define RTC_RGR_ADJC_MASK (0x3ff << RTC_RGR_ADJC_BIT)
7.223 +#define RTC_RGR_NC1HZ_BIT 0
7.224 +#define RTC_RGR_NC1HZ_MASK (0xffff << RTC_RGR_NC1HZ_BIT)
7.225 +
7.226 +/* Hibernate Control Register */
7.227 +#define RTC_HCR_PD (1 << 0) /* Power Down */
7.228 +
7.229 +/* Hibernate Wakeup Filter Counter Register */
7.230 +#define RTC_HWFCR_BIT 5
7.231 +#define RTC_HWFCR_MASK (0x7ff << RTC_HWFCR_BIT)
7.232 +
7.233 +/* Hibernate Reset Counter Register */
7.234 +#define RTC_HRCR_BIT 5
7.235 +#define RTC_HRCR_MASK (0x7f << RTC_HRCR_BIT)
7.236 +
7.237 +/* Hibernate Wakeup Control Register */
7.238 +#define RTC_HWCR_EALM (1 << 0) /* RTC alarm wakeup enable */
7.239 +
7.240 +/* Hibernate Wakeup Status Register */
7.241 +#define RTC_HWRSR_HR (1 << 5) /* Hibernate reset */
7.242 +#define RTC_HWRSR_PPR (1 << 4) /* PPR reset */
7.243 +#define RTC_HWRSR_PIN (1 << 1) /* Wakeup pin status bit */
7.244 +#define RTC_HWRSR_ALM (1 << 0) /* RTC alarm status bit */
7.245 +
7.246 +
7.247 +/*************************************************************************
7.248 + * CPM (Clock reset and Power control Management)
7.249 + *************************************************************************/
7.250 +#define CPM_CPCCR (CPM_BASE+0x00)
7.251 +#define CPM_CPPCR (CPM_BASE+0x10)
7.252 +#define CPM_I2SCDR (CPM_BASE+0x60)
7.253 +#define CPM_LPCDR (CPM_BASE+0x64)
7.254 +#define CPM_MSCCDR (CPM_BASE+0x68)
7.255 +#define CPM_UHCCDR (CPM_BASE+0x6C)
7.256 +
7.257 +#define CPM_LCR (CPM_BASE+0x04)
7.258 +#define CPM_CLKGR (CPM_BASE+0x20)
7.259 +#define CPM_SCR (CPM_BASE+0x24)
7.260 +
7.261 +#define CPM_HCR (CPM_BASE+0x30)
7.262 +#define CPM_HWFCR (CPM_BASE+0x34)
7.263 +#define CPM_HRCR (CPM_BASE+0x38)
7.264 +#define CPM_HWCR (CPM_BASE+0x3c)
7.265 +#define CPM_HWSR (CPM_BASE+0x40)
7.266 +#define CPM_HSPR (CPM_BASE+0x44)
7.267 +
7.268 +#define CPM_RSR (CPM_BASE+0x08)
7.269 +
7.270 +
7.271 +#define REG_CPM_CPCCR REG32(CPM_CPCCR)
7.272 +#define REG_CPM_CPPCR REG32(CPM_CPPCR)
7.273 +#define REG_CPM_I2SCDR REG32(CPM_I2SCDR)
7.274 +#define REG_CPM_LPCDR REG32(CPM_LPCDR)
7.275 +#define REG_CPM_MSCCDR REG32(CPM_MSCCDR)
7.276 +#define REG_CPM_UHCCDR REG32(CPM_UHCCDR)
7.277 +
7.278 +#define REG_CPM_LCR REG32(CPM_LCR)
7.279 +#define REG_CPM_CLKGR REG32(CPM_CLKGR)
7.280 +#define REG_CPM_SCR REG32(CPM_SCR)
7.281 +#define REG_CPM_HCR REG32(CPM_HCR)
7.282 +#define REG_CPM_HWFCR REG32(CPM_HWFCR)
7.283 +#define REG_CPM_HRCR REG32(CPM_HRCR)
7.284 +#define REG_CPM_HWCR REG32(CPM_HWCR)
7.285 +#define REG_CPM_HWSR REG32(CPM_HWSR)
7.286 +#define REG_CPM_HSPR REG32(CPM_HSPR)
7.287 +
7.288 +#define REG_CPM_RSR REG32(CPM_RSR)
7.289 +
7.290 +
7.291 +/* Clock Control Register */
7.292 +#define CPM_CPCCR_I2CS (1 << 31)
7.293 +#define CPM_CPCCR_CLKOEN (1 << 30)
7.294 +#define CPM_CPCCR_UCS (1 << 29)
7.295 +#define CPM_CPCCR_UDIV_BIT 23
7.296 +#define CPM_CPCCR_UDIV_MASK (0x3f << CPM_CPCCR_UDIV_BIT)
7.297 +#define CPM_CPCCR_CE (1 << 22)
7.298 +#define CPM_CPCCR_PCS (1 << 21)
7.299 +#define CPM_CPCCR_LDIV_BIT 16
7.300 +#define CPM_CPCCR_LDIV_MASK (0x1f << CPM_CPCCR_LDIV_BIT)
7.301 +#define CPM_CPCCR_MDIV_BIT 12
7.302 +#define CPM_CPCCR_MDIV_MASK (0x0f << CPM_CPCCR_MDIV_BIT)
7.303 +#define CPM_CPCCR_PDIV_BIT 8
7.304 +#define CPM_CPCCR_PDIV_MASK (0x0f << CPM_CPCCR_PDIV_BIT)
7.305 +#define CPM_CPCCR_HDIV_BIT 4
7.306 +#define CPM_CPCCR_HDIV_MASK (0x0f << CPM_CPCCR_HDIV_BIT)
7.307 +#define CPM_CPCCR_CDIV_BIT 0
7.308 +#define CPM_CPCCR_CDIV_MASK (0x0f << CPM_CPCCR_CDIV_BIT)
7.309 +
7.310 +/* I2S Clock Divider Register */
7.311 +#define CPM_I2SCDR_I2SDIV_BIT 0
7.312 +#define CPM_I2SCDR_I2SDIV_MASK (0x1ff << CPM_I2SCDR_I2SDIV_BIT)
7.313 +
7.314 +/* LCD Pixel Clock Divider Register */
7.315 +#define CPM_LPCDR_PIXDIV_BIT 0
7.316 +#define CPM_LPCDR_PIXDIV_MASK (0x1ff << CPM_LPCDR_PIXDIV_BIT)
7.317 +
7.318 +/* MSC Clock Divider Register */
7.319 +#define CPM_MSCCDR_MSCDIV_BIT 0
7.320 +#define CPM_MSCCDR_MSCDIV_MASK (0x1f << CPM_MSCCDR_MSCDIV_BIT)
7.321 +
7.322 +/* PLL Control Register */
7.323 +#define CPM_CPPCR_PLLM_BIT 23
7.324 +#define CPM_CPPCR_PLLM_MASK (0x1ff << CPM_CPPCR_PLLM_BIT)
7.325 +#define CPM_CPPCR_PLLN_BIT 18
7.326 +#define CPM_CPPCR_PLLN_MASK (0x1f << CPM_CPPCR_PLLN_BIT)
7.327 +#define CPM_CPPCR_PLLOD_BIT 16
7.328 +#define CPM_CPPCR_PLLOD_MASK (0x03 << CPM_CPPCR_PLLOD_BIT)
7.329 +#define CPM_CPPCR_PLLS (1 << 10)
7.330 +#define CPM_CPPCR_PLLBP (1 << 9)
7.331 +#define CPM_CPPCR_PLLEN (1 << 8)
7.332 +#define CPM_CPPCR_PLLST_BIT 0
7.333 +#define CPM_CPPCR_PLLST_MASK (0xff << CPM_CPPCR_PLLST_BIT)
7.334 +
7.335 +/* Low Power Control Register */
7.336 +#define CPM_LCR_DOZE_DUTY_BIT 3
7.337 +#define CPM_LCR_DOZE_DUTY_MASK (0x1f << CPM_LCR_DOZE_DUTY_BIT)
7.338 +#define CPM_LCR_DOZE_ON (1 << 2)
7.339 +#define CPM_LCR_LPM_BIT 0
7.340 +#define CPM_LCR_LPM_MASK (0x3 << CPM_LCR_LPM_BIT)
7.341 + #define CPM_LCR_LPM_IDLE (0x0 << CPM_LCR_LPM_BIT)
7.342 + #define CPM_LCR_LPM_SLEEP (0x1 << CPM_LCR_LPM_BIT)
7.343 +
7.344 +/* Clock Gate Register */
7.345 +#define CPM_CLKGR_UART1 (1 << 15)
7.346 +#define CPM_CLKGR_UHC (1 << 14)
7.347 +#define CPM_CLKGR_IPU (1 << 13)
7.348 +#define CPM_CLKGR_DMAC (1 << 12)
7.349 +#define CPM_CLKGR_UDC (1 << 11)
7.350 +#define CPM_CLKGR_LCD (1 << 10)
7.351 +#define CPM_CLKGR_CIM (1 << 9)
7.352 +#define CPM_CLKGR_SADC (1 << 8)
7.353 +#define CPM_CLKGR_MSC (1 << 7)
7.354 +#define CPM_CLKGR_AIC1 (1 << 6)
7.355 +#define CPM_CLKGR_AIC2 (1 << 5)
7.356 +#define CPM_CLKGR_SSI (1 << 4)
7.357 +#define CPM_CLKGR_I2C (1 << 3)
7.358 +#define CPM_CLKGR_RTC (1 << 2)
7.359 +#define CPM_CLKGR_TCU (1 << 1)
7.360 +#define CPM_CLKGR_UART0 (1 << 0)
7.361 +
7.362 +/* Sleep Control Register */
7.363 +#define CPM_SCR_O1ST_BIT 8
7.364 +#define CPM_SCR_O1ST_MASK (0xff << CPM_SCR_O1ST_BIT)
7.365 +#define CPM_SCR_USBPHY_ENABLE (1 << 6)
7.366 +#define CPM_SCR_OSC_ENABLE (1 << 4)
7.367 +
7.368 +/* Hibernate Control Register */
7.369 +#define CPM_HCR_PD (1 << 0)
7.370 +
7.371 +/* Wakeup Filter Counter Register in Hibernate Mode */
7.372 +#define CPM_HWFCR_TIME_BIT 0
7.373 +#define CPM_HWFCR_TIME_MASK (0x3ff << CPM_HWFCR_TIME_BIT)
7.374 +
7.375 +/* Reset Counter Register in Hibernate Mode */
7.376 +#define CPM_HRCR_TIME_BIT 0
7.377 +#define CPM_HRCR_TIME_MASK (0x7f << CPM_HRCR_TIME_BIT)
7.378 +
7.379 +/* Wakeup Control Register in Hibernate Mode */
7.380 +#define CPM_HWCR_WLE_LOW (0 << 2)
7.381 +#define CPM_HWCR_WLE_HIGH (1 << 2)
7.382 +#define CPM_HWCR_PIN_WAKEUP (1 << 1)
7.383 +#define CPM_HWCR_RTC_WAKEUP (1 << 0)
7.384 +
7.385 +/* Wakeup Status Register in Hibernate Mode */
7.386 +#define CPM_HWSR_WSR_PIN (1 << 1)
7.387 +#define CPM_HWSR_WSR_RTC (1 << 0)
7.388 +
7.389 +/* Reset Status Register */
7.390 +#define CPM_RSR_HR (1 << 2)
7.391 +#define CPM_RSR_WR (1 << 1)
7.392 +#define CPM_RSR_PR (1 << 0)
7.393 +
7.394 +
7.395 +/*************************************************************************
7.396 + * TCU (Timer Counter Unit)
7.397 + *************************************************************************/
7.398 +#define TCU_TSR (TCU_BASE + 0x1C) /* Timer Stop Register */
7.399 +#define TCU_TSSR (TCU_BASE + 0x2C) /* Timer Stop Set Register */
7.400 +#define TCU_TSCR (TCU_BASE + 0x3C) /* Timer Stop Clear Register */
7.401 +#define TCU_TER (TCU_BASE + 0x10) /* Timer Counter Enable Register */
7.402 +#define TCU_TESR (TCU_BASE + 0x14) /* Timer Counter Enable Set Register */
7.403 +#define TCU_TECR (TCU_BASE + 0x18) /* Timer Counter Enable Clear Register */
7.404 +#define TCU_TFR (TCU_BASE + 0x20) /* Timer Flag Register */
7.405 +#define TCU_TFSR (TCU_BASE + 0x24) /* Timer Flag Set Register */
7.406 +#define TCU_TFCR (TCU_BASE + 0x28) /* Timer Flag Clear Register */
7.407 +#define TCU_TMR (TCU_BASE + 0x30) /* Timer Mask Register */
7.408 +#define TCU_TMSR (TCU_BASE + 0x34) /* Timer Mask Set Register */
7.409 +#define TCU_TMCR (TCU_BASE + 0x38) /* Timer Mask Clear Register */
7.410 +#define TCU_TDFR0 (TCU_BASE + 0x40) /* Timer Data Full Register */
7.411 +#define TCU_TDHR0 (TCU_BASE + 0x44) /* Timer Data Half Register */
7.412 +#define TCU_TCNT0 (TCU_BASE + 0x48) /* Timer Counter Register */
7.413 +#define TCU_TCSR0 (TCU_BASE + 0x4C) /* Timer Control Register */
7.414 +#define TCU_TDFR1 (TCU_BASE + 0x50)
7.415 +#define TCU_TDHR1 (TCU_BASE + 0x54)
7.416 +#define TCU_TCNT1 (TCU_BASE + 0x58)
7.417 +#define TCU_TCSR1 (TCU_BASE + 0x5C)
7.418 +#define TCU_TDFR2 (TCU_BASE + 0x60)
7.419 +#define TCU_TDHR2 (TCU_BASE + 0x64)
7.420 +#define TCU_TCNT2 (TCU_BASE + 0x68)
7.421 +#define TCU_TCSR2 (TCU_BASE + 0x6C)
7.422 +#define TCU_TDFR3 (TCU_BASE + 0x70)
7.423 +#define TCU_TDHR3 (TCU_BASE + 0x74)
7.424 +#define TCU_TCNT3 (TCU_BASE + 0x78)
7.425 +#define TCU_TCSR3 (TCU_BASE + 0x7C)
7.426 +#define TCU_TDFR4 (TCU_BASE + 0x80)
7.427 +#define TCU_TDHR4 (TCU_BASE + 0x84)
7.428 +#define TCU_TCNT4 (TCU_BASE + 0x88)
7.429 +#define TCU_TCSR4 (TCU_BASE + 0x8C)
7.430 +#define TCU_TDFR5 (TCU_BASE + 0x90)
7.431 +#define TCU_TDHR5 (TCU_BASE + 0x94)
7.432 +#define TCU_TCNT5 (TCU_BASE + 0x98)
7.433 +#define TCU_TCSR5 (TCU_BASE + 0x9C)
7.434 +
7.435 +#define REG_TCU_TSR REG32(TCU_TSR)
7.436 +#define REG_TCU_TSSR REG32(TCU_TSSR)
7.437 +#define REG_TCU_TSCR REG32(TCU_TSCR)
7.438 +#define REG_TCU_TER REG8(TCU_TER)
7.439 +#define REG_TCU_TESR REG8(TCU_TESR)
7.440 +#define REG_TCU_TECR REG8(TCU_TECR)
7.441 +#define REG_TCU_TFR REG32(TCU_TFR)
7.442 +#define REG_TCU_TFSR REG32(TCU_TFSR)
7.443 +#define REG_TCU_TFCR REG32(TCU_TFCR)
7.444 +#define REG_TCU_TMR REG32(TCU_TMR)
7.445 +#define REG_TCU_TMSR REG32(TCU_TMSR)
7.446 +#define REG_TCU_TMCR REG32(TCU_TMCR)
7.447 +#define REG_TCU_TDFR0 REG16(TCU_TDFR0)
7.448 +#define REG_TCU_TDHR0 REG16(TCU_TDHR0)
7.449 +#define REG_TCU_TCNT0 REG16(TCU_TCNT0)
7.450 +#define REG_TCU_TCSR0 REG16(TCU_TCSR0)
7.451 +#define REG_TCU_TDFR1 REG16(TCU_TDFR1)
7.452 +#define REG_TCU_TDHR1 REG16(TCU_TDHR1)
7.453 +#define REG_TCU_TCNT1 REG16(TCU_TCNT1)
7.454 +#define REG_TCU_TCSR1 REG16(TCU_TCSR1)
7.455 +#define REG_TCU_TDFR2 REG16(TCU_TDFR2)
7.456 +#define REG_TCU_TDHR2 REG16(TCU_TDHR2)
7.457 +#define REG_TCU_TCNT2 REG16(TCU_TCNT2)
7.458 +#define REG_TCU_TCSR2 REG16(TCU_TCSR2)
7.459 +#define REG_TCU_TDFR3 REG16(TCU_TDFR3)
7.460 +#define REG_TCU_TDHR3 REG16(TCU_TDHR3)
7.461 +#define REG_TCU_TCNT3 REG16(TCU_TCNT3)
7.462 +#define REG_TCU_TCSR3 REG16(TCU_TCSR3)
7.463 +#define REG_TCU_TDFR4 REG16(TCU_TDFR4)
7.464 +#define REG_TCU_TDHR4 REG16(TCU_TDHR4)
7.465 +#define REG_TCU_TCNT4 REG16(TCU_TCNT4)
7.466 +#define REG_TCU_TCSR4 REG16(TCU_TCSR4)
7.467 +
7.468 +/* n = 0,1,2,3,4,5 */
7.469 +#define TCU_TDFR(n) (TCU_BASE + (0x40 + (n)*0x10)) /* Timer Data Full Reg */
7.470 +#define TCU_TDHR(n) (TCU_BASE + (0x44 + (n)*0x10)) /* Timer Data Half Reg */
7.471 +#define TCU_TCNT(n) (TCU_BASE + (0x48 + (n)*0x10)) /* Timer Counter Reg */
7.472 +#define TCU_TCSR(n) (TCU_BASE + (0x4C + (n)*0x10)) /* Timer Control Reg */
7.473 +
7.474 +#define REG_TCU_TDFR(n) REG16(TCU_TDFR((n)))
7.475 +#define REG_TCU_TDHR(n) REG16(TCU_TDHR((n)))
7.476 +#define REG_TCU_TCNT(n) REG16(TCU_TCNT((n)))
7.477 +#define REG_TCU_TCSR(n) REG16(TCU_TCSR((n)))
7.478 +
7.479 +/* Register definitions */
7.480 +#define TCU_TCSR_PWM_SD (1 << 9)
7.481 +#define TCU_TCSR_PWM_INITL_HIGH (1 << 8)
7.482 +#define TCU_TCSR_PWM_EN (1 << 7)
7.483 +#define TCU_TCSR_PRESCALE_BIT 3
7.484 +#define TCU_TCSR_PRESCALE_MASK (0x7 << TCU_TCSR_PRESCALE_BIT)
7.485 + #define TCU_TCSR_PRESCALE1 (0x0 << TCU_TCSR_PRESCALE_BIT)
7.486 + #define TCU_TCSR_PRESCALE4 (0x1 << TCU_TCSR_PRESCALE_BIT)
7.487 + #define TCU_TCSR_PRESCALE16 (0x2 << TCU_TCSR_PRESCALE_BIT)
7.488 + #define TCU_TCSR_PRESCALE64 (0x3 << TCU_TCSR_PRESCALE_BIT)
7.489 + #define TCU_TCSR_PRESCALE256 (0x4 << TCU_TCSR_PRESCALE_BIT)
7.490 + #define TCU_TCSR_PRESCALE1024 (0x5 << TCU_TCSR_PRESCALE_BIT)
7.491 +#define TCU_TCSR_EXT_EN (1 << 2)
7.492 +#define TCU_TCSR_RTC_EN (1 << 1)
7.493 +#define TCU_TCSR_PCK_EN (1 << 0)
7.494 +
7.495 +#define TCU_TER_TCEN5 (1 << 5)
7.496 +#define TCU_TER_TCEN4 (1 << 4)
7.497 +#define TCU_TER_TCEN3 (1 << 3)
7.498 +#define TCU_TER_TCEN2 (1 << 2)
7.499 +#define TCU_TER_TCEN1 (1 << 1)
7.500 +#define TCU_TER_TCEN0 (1 << 0)
7.501 +
7.502 +#define TCU_TESR_TCST5 (1 << 5)
7.503 +#define TCU_TESR_TCST4 (1 << 4)
7.504 +#define TCU_TESR_TCST3 (1 << 3)
7.505 +#define TCU_TESR_TCST2 (1 << 2)
7.506 +#define TCU_TESR_TCST1 (1 << 1)
7.507 +#define TCU_TESR_TCST0 (1 << 0)
7.508 +
7.509 +#define TCU_TECR_TCCL5 (1 << 5)
7.510 +#define TCU_TECR_TCCL4 (1 << 4)
7.511 +#define TCU_TECR_TCCL3 (1 << 3)
7.512 +#define TCU_TECR_TCCL2 (1 << 2)
7.513 +#define TCU_TECR_TCCL1 (1 << 1)
7.514 +#define TCU_TECR_TCCL0 (1 << 0)
7.515 +
7.516 +#define TCU_TFR_HFLAG5 (1 << 21)
7.517 +#define TCU_TFR_HFLAG4 (1 << 20)
7.518 +#define TCU_TFR_HFLAG3 (1 << 19)
7.519 +#define TCU_TFR_HFLAG2 (1 << 18)
7.520 +#define TCU_TFR_HFLAG1 (1 << 17)
7.521 +#define TCU_TFR_HFLAG0 (1 << 16)
7.522 +#define TCU_TFR_FFLAG5 (1 << 5)
7.523 +#define TCU_TFR_FFLAG4 (1 << 4)
7.524 +#define TCU_TFR_FFLAG3 (1 << 3)
7.525 +#define TCU_TFR_FFLAG2 (1 << 2)
7.526 +#define TCU_TFR_FFLAG1 (1 << 1)
7.527 +#define TCU_TFR_FFLAG0 (1 << 0)
7.528 +
7.529 +#define TCU_TFSR_HFLAG5 (1 << 21)
7.530 +#define TCU_TFSR_HFLAG4 (1 << 20)
7.531 +#define TCU_TFSR_HFLAG3 (1 << 19)
7.532 +#define TCU_TFSR_HFLAG2 (1 << 18)
7.533 +#define TCU_TFSR_HFLAG1 (1 << 17)
7.534 +#define TCU_TFSR_HFLAG0 (1 << 16)
7.535 +#define TCU_TFSR_FFLAG5 (1 << 5)
7.536 +#define TCU_TFSR_FFLAG4 (1 << 4)
7.537 +#define TCU_TFSR_FFLAG3 (1 << 3)
7.538 +#define TCU_TFSR_FFLAG2 (1 << 2)
7.539 +#define TCU_TFSR_FFLAG1 (1 << 1)
7.540 +#define TCU_TFSR_FFLAG0 (1 << 0)
7.541 +
7.542 +#define TCU_TFCR_HFLAG5 (1 << 21)
7.543 +#define TCU_TFCR_HFLAG4 (1 << 20)
7.544 +#define TCU_TFCR_HFLAG3 (1 << 19)
7.545 +#define TCU_TFCR_HFLAG2 (1 << 18)
7.546 +#define TCU_TFCR_HFLAG1 (1 << 17)
7.547 +#define TCU_TFCR_HFLAG0 (1 << 16)
7.548 +#define TCU_TFCR_FFLAG5 (1 << 5)
7.549 +#define TCU_TFCR_FFLAG4 (1 << 4)
7.550 +#define TCU_TFCR_FFLAG3 (1 << 3)
7.551 +#define TCU_TFCR_FFLAG2 (1 << 2)
7.552 +#define TCU_TFCR_FFLAG1 (1 << 1)
7.553 +#define TCU_TFCR_FFLAG0 (1 << 0)
7.554 +
7.555 +#define TCU_TMR_HMASK5 (1 << 21)
7.556 +#define TCU_TMR_HMASK4 (1 << 20)
7.557 +#define TCU_TMR_HMASK3 (1 << 19)
7.558 +#define TCU_TMR_HMASK2 (1 << 18)
7.559 +#define TCU_TMR_HMASK1 (1 << 17)
7.560 +#define TCU_TMR_HMASK0 (1 << 16)
7.561 +#define TCU_TMR_FMASK5 (1 << 5)
7.562 +#define TCU_TMR_FMASK4 (1 << 4)
7.563 +#define TCU_TMR_FMASK3 (1 << 3)
7.564 +#define TCU_TMR_FMASK2 (1 << 2)
7.565 +#define TCU_TMR_FMASK1 (1 << 1)
7.566 +#define TCU_TMR_FMASK0 (1 << 0)
7.567 +
7.568 +#define TCU_TMSR_HMST5 (1 << 21)
7.569 +#define TCU_TMSR_HMST4 (1 << 20)
7.570 +#define TCU_TMSR_HMST3 (1 << 19)
7.571 +#define TCU_TMSR_HMST2 (1 << 18)
7.572 +#define TCU_TMSR_HMST1 (1 << 17)
7.573 +#define TCU_TMSR_HMST0 (1 << 16)
7.574 +#define TCU_TMSR_FMST5 (1 << 5)
7.575 +#define TCU_TMSR_FMST4 (1 << 4)
7.576 +#define TCU_TMSR_FMST3 (1 << 3)
7.577 +#define TCU_TMSR_FMST2 (1 << 2)
7.578 +#define TCU_TMSR_FMST1 (1 << 1)
7.579 +#define TCU_TMSR_FMST0 (1 << 0)
7.580 +
7.581 +#define TCU_TMCR_HMCL5 (1 << 21)
7.582 +#define TCU_TMCR_HMCL4 (1 << 20)
7.583 +#define TCU_TMCR_HMCL3 (1 << 19)
7.584 +#define TCU_TMCR_HMCL2 (1 << 18)
7.585 +#define TCU_TMCR_HMCL1 (1 << 17)
7.586 +#define TCU_TMCR_HMCL0 (1 << 16)
7.587 +#define TCU_TMCR_FMCL5 (1 << 5)
7.588 +#define TCU_TMCR_FMCL4 (1 << 4)
7.589 +#define TCU_TMCR_FMCL3 (1 << 3)
7.590 +#define TCU_TMCR_FMCL2 (1 << 2)
7.591 +#define TCU_TMCR_FMCL1 (1 << 1)
7.592 +#define TCU_TMCR_FMCL0 (1 << 0)
7.593 +
7.594 +#define TCU_TSR_WDTS (1 << 16)
7.595 +#define TCU_TSR_STOP5 (1 << 5)
7.596 +#define TCU_TSR_STOP4 (1 << 4)
7.597 +#define TCU_TSR_STOP3 (1 << 3)
7.598 +#define TCU_TSR_STOP2 (1 << 2)
7.599 +#define TCU_TSR_STOP1 (1 << 1)
7.600 +#define TCU_TSR_STOP0 (1 << 0)
7.601 +
7.602 +#define TCU_TSSR_WDTSS (1 << 16)
7.603 +#define TCU_TSSR_STPS5 (1 << 5)
7.604 +#define TCU_TSSR_STPS4 (1 << 4)
7.605 +#define TCU_TSSR_STPS3 (1 << 3)
7.606 +#define TCU_TSSR_STPS2 (1 << 2)
7.607 +#define TCU_TSSR_STPS1 (1 << 1)
7.608 +#define TCU_TSSR_STPS0 (1 << 0)
7.609 +
7.610 +#define TCU_TSSR_WDTSC (1 << 16)
7.611 +#define TCU_TSSR_STPC5 (1 << 5)
7.612 +#define TCU_TSSR_STPC4 (1 << 4)
7.613 +#define TCU_TSSR_STPC3 (1 << 3)
7.614 +#define TCU_TSSR_STPC2 (1 << 2)
7.615 +#define TCU_TSSR_STPC1 (1 << 1)
7.616 +#define TCU_TSSR_STPC0 (1 << 0)
7.617 +
7.618 +
7.619 +/*************************************************************************
7.620 + * WDT (WatchDog Timer)
7.621 + *************************************************************************/
7.622 +#define WDT_TDR (WDT_BASE + 0x00)
7.623 +#define WDT_TCER (WDT_BASE + 0x04)
7.624 +#define WDT_TCNT (WDT_BASE + 0x08)
7.625 +#define WDT_TCSR (WDT_BASE + 0x0C)
7.626 +
7.627 +#define REG_WDT_TDR REG16(WDT_TDR)
7.628 +#define REG_WDT_TCER REG8(WDT_TCER)
7.629 +#define REG_WDT_TCNT REG16(WDT_TCNT)
7.630 +#define REG_WDT_TCSR REG16(WDT_TCSR)
7.631 +
7.632 +/* Register definition */
7.633 +#define WDT_TCSR_PRESCALE_BIT 3
7.634 +#define WDT_TCSR_PRESCALE_MASK (0x7 << WDT_TCSR_PRESCALE_BIT)
7.635 + #define WDT_TCSR_PRESCALE1 (0x0 << WDT_TCSR_PRESCALE_BIT)
7.636 + #define WDT_TCSR_PRESCALE4 (0x1 << WDT_TCSR_PRESCALE_BIT)
7.637 + #define WDT_TCSR_PRESCALE16 (0x2 << WDT_TCSR_PRESCALE_BIT)
7.638 + #define WDT_TCSR_PRESCALE64 (0x3 << WDT_TCSR_PRESCALE_BIT)
7.639 + #define WDT_TCSR_PRESCALE256 (0x4 << WDT_TCSR_PRESCALE_BIT)
7.640 + #define WDT_TCSR_PRESCALE1024 (0x5 << WDT_TCSR_PRESCALE_BIT)
7.641 +#define WDT_TCSR_EXT_EN (1 << 2)
7.642 +#define WDT_TCSR_RTC_EN (1 << 1)
7.643 +#define WDT_TCSR_PCK_EN (1 << 0)
7.644 +
7.645 +#define WDT_TCER_TCEN (1 << 0)
7.646 +
7.647 +
7.648 +/*************************************************************************
7.649 + * DMAC (DMA Controller)
7.650 + *************************************************************************/
7.651 +
7.652 +#define MAX_DMA_NUM 6 /* max 6 channels */
7.653 +
7.654 +#define DMAC_DSAR(n) (DMAC_BASE + (0x00 + (n) * 0x20)) /* DMA source address */
7.655 +#define DMAC_DTAR(n) (DMAC_BASE + (0x04 + (n) * 0x20)) /* DMA target address */
7.656 +#define DMAC_DTCR(n) (DMAC_BASE + (0x08 + (n) * 0x20)) /* DMA transfer count */
7.657 +#define DMAC_DRSR(n) (DMAC_BASE + (0x0c + (n) * 0x20)) /* DMA request source */
7.658 +#define DMAC_DCCSR(n) (DMAC_BASE + (0x10 + (n) * 0x20)) /* DMA control/status */
7.659 +#define DMAC_DCMD(n) (DMAC_BASE + (0x14 + (n) * 0x20)) /* DMA command */
7.660 +#define DMAC_DDA(n) (DMAC_BASE + (0x18 + (n) * 0x20)) /* DMA descriptor address */
7.661 +#define DMAC_DMACR (DMAC_BASE + 0x0300) /* DMA control register */
7.662 +#define DMAC_DMAIPR (DMAC_BASE + 0x0304) /* DMA interrupt pending */
7.663 +#define DMAC_DMADBR (DMAC_BASE + 0x0308) /* DMA doorbell */
7.664 +#define DMAC_DMADBSR (DMAC_BASE + 0x030C) /* DMA doorbell set */
7.665 +
7.666 +/* channel 0 */
7.667 +#define DMAC_DSAR0 DMAC_DSAR(0)
7.668 +#define DMAC_DTAR0 DMAC_DTAR(0)
7.669 +#define DMAC_DTCR0 DMAC_DTCR(0)
7.670 +#define DMAC_DRSR0 DMAC_DRSR(0)
7.671 +#define DMAC_DCCSR0 DMAC_DCCSR(0)
7.672 +#define DMAC_DCMD0 DMAC_DCMD(0)
7.673 +#define DMAC_DDA0 DMAC_DDA(0)
7.674 +
7.675 +/* channel 1 */
7.676 +#define DMAC_DSAR1 DMAC_DSAR(1)
7.677 +#define DMAC_DTAR1 DMAC_DTAR(1)
7.678 +#define DMAC_DTCR1 DMAC_DTCR(1)
7.679 +#define DMAC_DRSR1 DMAC_DRSR(1)
7.680 +#define DMAC_DCCSR1 DMAC_DCCSR(1)
7.681 +#define DMAC_DCMD1 DMAC_DCMD(1)
7.682 +#define DMAC_DDA1 DMAC_DDA(1)
7.683 +
7.684 +/* channel 2 */
7.685 +#define DMAC_DSAR2 DMAC_DSAR(2)
7.686 +#define DMAC_DTAR2 DMAC_DTAR(2)
7.687 +#define DMAC_DTCR2 DMAC_DTCR(2)
7.688 +#define DMAC_DRSR2 DMAC_DRSR(2)
7.689 +#define DMAC_DCCSR2 DMAC_DCCSR(2)
7.690 +#define DMAC_DCMD2 DMAC_DCMD(2)
7.691 +#define DMAC_DDA2 DMAC_DDA(2)
7.692 +
7.693 +/* channel 3 */
7.694 +#define DMAC_DSAR3 DMAC_DSAR(3)
7.695 +#define DMAC_DTAR3 DMAC_DTAR(3)
7.696 +#define DMAC_DTCR3 DMAC_DTCR(3)
7.697 +#define DMAC_DRSR3 DMAC_DRSR(3)
7.698 +#define DMAC_DCCSR3 DMAC_DCCSR(3)
7.699 +#define DMAC_DCMD3 DMAC_DCMD(3)
7.700 +#define DMAC_DDA3 DMAC_DDA(3)
7.701 +
7.702 +/* channel 4 */
7.703 +#define DMAC_DSAR4 DMAC_DSAR(4)
7.704 +#define DMAC_DTAR4 DMAC_DTAR(4)
7.705 +#define DMAC_DTCR4 DMAC_DTCR(4)
7.706 +#define DMAC_DRSR4 DMAC_DRSR(4)
7.707 +#define DMAC_DCCSR4 DMAC_DCCSR(4)
7.708 +#define DMAC_DCMD4 DMAC_DCMD(4)
7.709 +#define DMAC_DDA4 DMAC_DDA(4)
7.710 +
7.711 +/* channel 5 */
7.712 +#define DMAC_DSAR5 DMAC_DSAR(5)
7.713 +#define DMAC_DTAR5 DMAC_DTAR(5)
7.714 +#define DMAC_DTCR5 DMAC_DTCR(5)
7.715 +#define DMAC_DRSR5 DMAC_DRSR(5)
7.716 +#define DMAC_DCCSR5 DMAC_DCCSR(5)
7.717 +#define DMAC_DCMD5 DMAC_DCMD(5)
7.718 +#define DMAC_DDA5 DMAC_DDA(5)
7.719 +
7.720 +#define REG_DMAC_DSAR(n) REG32(DMAC_DSAR((n)))
7.721 +#define REG_DMAC_DTAR(n) REG32(DMAC_DTAR((n)))
7.722 +#define REG_DMAC_DTCR(n) REG32(DMAC_DTCR((n)))
7.723 +#define REG_DMAC_DRSR(n) REG32(DMAC_DRSR((n)))
7.724 +#define REG_DMAC_DCCSR(n) REG32(DMAC_DCCSR((n)))
7.725 +#define REG_DMAC_DCMD(n) REG32(DMAC_DCMD((n)))
7.726 +#define REG_DMAC_DDA(n) REG32(DMAC_DDA((n)))
7.727 +#define REG_DMAC_DMACR REG32(DMAC_DMACR)
7.728 +#define REG_DMAC_DMAIPR REG32(DMAC_DMAIPR)
7.729 +#define REG_DMAC_DMADBR REG32(DMAC_DMADBR)
7.730 +#define REG_DMAC_DMADBSR REG32(DMAC_DMADBSR)
7.731 +
7.732 +/* DMA request source register */
7.733 +#define DMAC_DRSR_RS_BIT 0
7.734 +#define DMAC_DRSR_RS_MASK (0x1f << DMAC_DRSR_RS_BIT)
7.735 + #define DMAC_DRSR_RS_AUTO (8 << DMAC_DRSR_RS_BIT)
7.736 + #define DMAC_DRSR_RS_UART0OUT (20 << DMAC_DRSR_RS_BIT)
7.737 + #define DMAC_DRSR_RS_UART0IN (21 << DMAC_DRSR_RS_BIT)
7.738 + #define DMAC_DRSR_RS_SSIOUT (22 << DMAC_DRSR_RS_BIT)
7.739 + #define DMAC_DRSR_RS_SSIIN (23 << DMAC_DRSR_RS_BIT)
7.740 + #define DMAC_DRSR_RS_AICOUT (24 << DMAC_DRSR_RS_BIT)
7.741 + #define DMAC_DRSR_RS_AICIN (25 << DMAC_DRSR_RS_BIT)
7.742 + #define DMAC_DRSR_RS_MSCOUT (26 << DMAC_DRSR_RS_BIT)
7.743 + #define DMAC_DRSR_RS_MSCIN (27 << DMAC_DRSR_RS_BIT)
7.744 + #define DMAC_DRSR_RS_TCU (28 << DMAC_DRSR_RS_BIT)
7.745 + #define DMAC_DRSR_RS_SADC (29 << DMAC_DRSR_RS_BIT)
7.746 + #define DMAC_DRSR_RS_SLCD (30 << DMAC_DRSR_RS_BIT)
7.747 +
7.748 +/* DMA channel control/status register */
7.749 +#define DMAC_DCCSR_NDES (1 << 31) /* descriptor (0) or not (1) ? */
7.750 +#define DMAC_DCCSR_CDOA_BIT 16 /* copy of DMA offset address */
7.751 +#define DMAC_DCCSR_CDOA_MASK (0xff << DMAC_DCCSR_CDOA_BIT)
7.752 +#define DMAC_DCCSR_INV (1 << 6) /* descriptor invalid */
7.753 +#define DMAC_DCCSR_AR (1 << 4) /* address error */
7.754 +#define DMAC_DCCSR_TT (1 << 3) /* transfer terminated */
7.755 +#define DMAC_DCCSR_HLT (1 << 2) /* DMA halted */
7.756 +#define DMAC_DCCSR_CT (1 << 1) /* count terminated */
7.757 +#define DMAC_DCCSR_EN (1 << 0) /* channel enable bit */
7.758 +
7.759 +/* DMA channel command register */
7.760 +#define DMAC_DCMD_SAI (1 << 23) /* source address increment */
7.761 +#define DMAC_DCMD_DAI (1 << 22) /* dest address increment */
7.762 +#define DMAC_DCMD_RDIL_BIT 16 /* request detection interval length */
7.763 +#define DMAC_DCMD_RDIL_MASK (0x0f << DMAC_DCMD_RDIL_BIT)
7.764 + #define DMAC_DCMD_RDIL_IGN (0 << DMAC_DCMD_RDIL_BIT)
7.765 + #define DMAC_DCMD_RDIL_2 (1 << DMAC_DCMD_RDIL_BIT)
7.766 + #define DMAC_DCMD_RDIL_4 (2 << DMAC_DCMD_RDIL_BIT)
7.767 + #define DMAC_DCMD_RDIL_8 (3 << DMAC_DCMD_RDIL_BIT)
7.768 + #define DMAC_DCMD_RDIL_12 (4 << DMAC_DCMD_RDIL_BIT)
7.769 + #define DMAC_DCMD_RDIL_16 (5 << DMAC_DCMD_RDIL_BIT)
7.770 + #define DMAC_DCMD_RDIL_20 (6 << DMAC_DCMD_RDIL_BIT)
7.771 + #define DMAC_DCMD_RDIL_24 (7 << DMAC_DCMD_RDIL_BIT)
7.772 + #define DMAC_DCMD_RDIL_28 (8 << DMAC_DCMD_RDIL_BIT)
7.773 + #define DMAC_DCMD_RDIL_32 (9 << DMAC_DCMD_RDIL_BIT)
7.774 + #define DMAC_DCMD_RDIL_48 (10 << DMAC_DCMD_RDIL_BIT)
7.775 + #define DMAC_DCMD_RDIL_60 (11 << DMAC_DCMD_RDIL_BIT)
7.776 + #define DMAC_DCMD_RDIL_64 (12 << DMAC_DCMD_RDIL_BIT)
7.777 + #define DMAC_DCMD_RDIL_124 (13 << DMAC_DCMD_RDIL_BIT)
7.778 + #define DMAC_DCMD_RDIL_128 (14 << DMAC_DCMD_RDIL_BIT)
7.779 + #define DMAC_DCMD_RDIL_200 (15 << DMAC_DCMD_RDIL_BIT)
7.780 +#define DMAC_DCMD_SWDH_BIT 14 /* source port width */
7.781 +#define DMAC_DCMD_SWDH_MASK (0x03 << DMAC_DCMD_SWDH_BIT)
7.782 + #define DMAC_DCMD_SWDH_32 (0 << DMAC_DCMD_SWDH_BIT)
7.783 + #define DMAC_DCMD_SWDH_8 (1 << DMAC_DCMD_SWDH_BIT)
7.784 + #define DMAC_DCMD_SWDH_16 (2 << DMAC_DCMD_SWDH_BIT)
7.785 +#define DMAC_DCMD_DWDH_BIT 12 /* dest port width */
7.786 +#define DMAC_DCMD_DWDH_MASK (0x03 << DMAC_DCMD_DWDH_BIT)
7.787 + #define DMAC_DCMD_DWDH_32 (0 << DMAC_DCMD_DWDH_BIT)
7.788 + #define DMAC_DCMD_DWDH_8 (1 << DMAC_DCMD_DWDH_BIT)
7.789 + #define DMAC_DCMD_DWDH_16 (2 << DMAC_DCMD_DWDH_BIT)
7.790 +#define DMAC_DCMD_DS_BIT 8 /* transfer data size of a data unit */
7.791 +#define DMAC_DCMD_DS_MASK (0x07 << DMAC_DCMD_DS_BIT)
7.792 + #define DMAC_DCMD_DS_32BIT (0 << DMAC_DCMD_DS_BIT)
7.793 + #define DMAC_DCMD_DS_8BIT (1 << DMAC_DCMD_DS_BIT)
7.794 + #define DMAC_DCMD_DS_16BIT (2 << DMAC_DCMD_DS_BIT)
7.795 + #define DMAC_DCMD_DS_16BYTE (3 << DMAC_DCMD_DS_BIT)
7.796 + #define DMAC_DCMD_DS_32BYTE (4 << DMAC_DCMD_DS_BIT)
7.797 +#define DMAC_DCMD_TM (1 << 7) /* transfer mode: 0-single 1-block */
7.798 +#define DMAC_DCMD_DES_V (1 << 4) /* descriptor valid flag */
7.799 +#define DMAC_DCMD_DES_VM (1 << 3) /* descriptor valid mask: 1:support V-bit */
7.800 +#define DMAC_DCMD_DES_VIE (1 << 2) /* DMA valid error interrupt enable */
7.801 +#define DMAC_DCMD_TIE (1 << 1) /* DMA transfer interrupt enable */
7.802 +#define DMAC_DCMD_LINK (1 << 0) /* descriptor link enable */
7.803 +
7.804 +/* DMA descriptor address register */
7.805 +#define DMAC_DDA_BASE_BIT 12 /* descriptor base address */
7.806 +#define DMAC_DDA_BASE_MASK (0x0fffff << DMAC_DDA_BASE_BIT)
7.807 +#define DMAC_DDA_OFFSET_BIT 4 /* descriptor offset address */
7.808 +#define DMAC_DDA_OFFSET_MASK (0x0ff << DMAC_DDA_OFFSET_BIT)
7.809 +
7.810 +/* DMA control register */
7.811 +#define DMAC_DMACR_PR_BIT 8 /* channel priority mode */
7.812 +#define DMAC_DMACR_PR_MASK (0x03 << DMAC_DMACR_PR_BIT)
7.813 + #define DMAC_DMACR_PR_012345 (0 << DMAC_DMACR_PR_BIT)
7.814 + #define DMAC_DMACR_PR_023145 (1 << DMAC_DMACR_PR_BIT)
7.815 + #define DMAC_DMACR_PR_201345 (2 << DMAC_DMACR_PR_BIT)
7.816 + #define DMAC_DMACR_PR_RR (3 << DMAC_DMACR_PR_BIT) /* round robin */
7.817 +#define DMAC_DMACR_HLT (1 << 3) /* DMA halt flag */
7.818 +#define DMAC_DMACR_AR (1 << 2) /* address error flag */
7.819 +#define DMAC_DMACR_DMAE (1 << 0) /* DMA enable bit */
7.820 +
7.821 +/* DMA doorbell register */
7.822 +#define DMAC_DMADBR_DB5 (1 << 5) /* doorbell for channel 5 */
7.823 +#define DMAC_DMADBR_DB4 (1 << 5) /* doorbell for channel 4 */
7.824 +#define DMAC_DMADBR_DB3 (1 << 5) /* doorbell for channel 3 */
7.825 +#define DMAC_DMADBR_DB2 (1 << 5) /* doorbell for channel 2 */
7.826 +#define DMAC_DMADBR_DB1 (1 << 5) /* doorbell for channel 1 */
7.827 +#define DMAC_DMADBR_DB0 (1 << 5) /* doorbell for channel 0 */
7.828 +
7.829 +/* DMA doorbell set register */
7.830 +#define DMAC_DMADBSR_DBS5 (1 << 5) /* enable doorbell for channel 5 */
7.831 +#define DMAC_DMADBSR_DBS4 (1 << 5) /* enable doorbell for channel 4 */
7.832 +#define DMAC_DMADBSR_DBS3 (1 << 5) /* enable doorbell for channel 3 */
7.833 +#define DMAC_DMADBSR_DBS2 (1 << 5) /* enable doorbell for channel 2 */
7.834 +#define DMAC_DMADBSR_DBS1 (1 << 5) /* enable doorbell for channel 1 */
7.835 +#define DMAC_DMADBSR_DBS0 (1 << 5) /* enable doorbell for channel 0 */
7.836 +
7.837 +/* DMA interrupt pending register */
7.838 +#define DMAC_DMAIPR_CIRQ5 (1 << 5) /* irq pending status for channel 5 */
7.839 +#define DMAC_DMAIPR_CIRQ4 (1 << 4) /* irq pending status for channel 4 */
7.840 +#define DMAC_DMAIPR_CIRQ3 (1 << 3) /* irq pending status for channel 3 */
7.841 +#define DMAC_DMAIPR_CIRQ2 (1 << 2) /* irq pending status for channel 2 */
7.842 +#define DMAC_DMAIPR_CIRQ1 (1 << 1) /* irq pending status for channel 1 */
7.843 +#define DMAC_DMAIPR_CIRQ0 (1 << 0) /* irq pending status for channel 0 */
7.844 +
7.845 +
7.846 +/*************************************************************************
7.847 + * GPIO (General-Purpose I/O Ports)
7.848 + *************************************************************************/
7.849 +#define MAX_GPIO_NUM 128
7.850 +
7.851 +/*n = 0,1,2,3 */
7.852 +#define GPIO_PXPIN(n) (GPIO_BASE + (0x00 + (n)*0x100)) /* PIN Level Register */
7.853 +#define GPIO_PXDAT(n) (GPIO_BASE + (0x10 + (n)*0x100)) /* Port Data Register */
7.854 +#define GPIO_PXDATS(n) (GPIO_BASE + (0x14 + (n)*0x100)) /* Port Data Set Register */
7.855 +#define GPIO_PXDATC(n) (GPIO_BASE + (0x18 + (n)*0x100)) /* Port Data Clear Register */
7.856 +#define GPIO_PXIM(n) (GPIO_BASE + (0x20 + (n)*0x100)) /* Interrupt Mask Register */
7.857 +#define GPIO_PXIMS(n) (GPIO_BASE + (0x24 + (n)*0x100)) /* Interrupt Mask Set Reg */
7.858 +#define GPIO_PXIMC(n) (GPIO_BASE + (0x28 + (n)*0x100)) /* Interrupt Mask Clear Reg */
7.859 +#define GPIO_PXPE(n) (GPIO_BASE + (0x30 + (n)*0x100)) /* Pull Enable Register */
7.860 +#define GPIO_PXPES(n) (GPIO_BASE + (0x34 + (n)*0x100)) /* Pull Enable Set Reg. */
7.861 +#define GPIO_PXPEC(n) (GPIO_BASE + (0x38 + (n)*0x100)) /* Pull Enable Clear Reg. */
7.862 +#define GPIO_PXFUN(n) (GPIO_BASE + (0x40 + (n)*0x100)) /* Function Register */
7.863 +#define GPIO_PXFUNS(n) (GPIO_BASE + (0x44 + (n)*0x100)) /* Function Set Register */
7.864 +#define GPIO_PXFUNC(n) (GPIO_BASE + (0x48 + (n)*0x100)) /* Function Clear Register */
7.865 +#define GPIO_PXSEL(n) (GPIO_BASE + (0x50 + (n)*0x100)) /* Select Register */
7.866 +#define GPIO_PXSELS(n) (GPIO_BASE + (0x54 + (n)*0x100)) /* Select Set Register */
7.867 +#define GPIO_PXSELC(n) (GPIO_BASE + (0x58 + (n)*0x100)) /* Select Clear Register */
7.868 +#define GPIO_PXDIR(n) (GPIO_BASE + (0x60 + (n)*0x100)) /* Direction Register */
7.869 +#define GPIO_PXDIRS(n) (GPIO_BASE + (0x64 + (n)*0x100)) /* Direction Set Register */
7.870 +#define GPIO_PXDIRC(n) (GPIO_BASE + (0x68 + (n)*0x100)) /* Direction Clear Register */
7.871 +#define GPIO_PXTRG(n) (GPIO_BASE + (0x70 + (n)*0x100)) /* Trigger Register */
7.872 +#define GPIO_PXTRGS(n) (GPIO_BASE + (0x74 + (n)*0x100)) /* Trigger Set Register */
7.873 +#define GPIO_PXTRGC(n) (GPIO_BASE + (0x78 + (n)*0x100)) /* Trigger Set Register */
7.874 +#define GPIO_PXFLG(n) (GPIO_BASE + (0x80 + (n)*0x100)) /* Port Flag Register */
7.875 +#define GPIO_PXFLGC(n) (GPIO_BASE + (0x14 + (n)*0x100)) /* Port Flag clear Register */
7.876 +
7.877 +#define REG_GPIO_PXPIN(n) REG32(GPIO_PXPIN((n))) /* PIN level */
7.878 +#define REG_GPIO_PXDAT(n) REG32(GPIO_PXDAT((n))) /* 1: interrupt pending */
7.879 +#define REG_GPIO_PXDATS(n) REG32(GPIO_PXDATS((n)))
7.880 +#define REG_GPIO_PXDATC(n) REG32(GPIO_PXDATC((n)))
7.881 +#define REG_GPIO_PXIM(n) REG32(GPIO_PXIM((n))) /* 1: mask pin interrupt */
7.882 +#define REG_GPIO_PXIMS(n) REG32(GPIO_PXIMS((n)))
7.883 +#define REG_GPIO_PXIMC(n) REG32(GPIO_PXIMC((n)))
7.884 +#define REG_GPIO_PXPE(n) REG32(GPIO_PXPE((n))) /* 1: disable pull up/down */
7.885 +#define REG_GPIO_PXPES(n) REG32(GPIO_PXPES((n)))
7.886 +#define REG_GPIO_PXPEC(n) REG32(GPIO_PXPEC((n)))
7.887 +#define REG_GPIO_PXFUN(n) REG32(GPIO_PXFUN((n))) /* 0:GPIO or intr, 1:FUNC */
7.888 +#define REG_GPIO_PXFUNS(n) REG32(GPIO_PXFUNS((n)))
7.889 +#define REG_GPIO_PXFUNC(n) REG32(GPIO_PXFUNC((n)))
7.890 +#define REG_GPIO_PXSEL(n) REG32(GPIO_PXSEL((n))) /* 0:GPIO/Fun0,1:intr/fun1*/
7.891 +#define REG_GPIO_PXSELS(n) REG32(GPIO_PXSELS((n)))
7.892 +#define REG_GPIO_PXSELC(n) REG32(GPIO_PXSELC((n)))
7.893 +#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 */
7.894 +#define REG_GPIO_PXDIRS(n) REG32(GPIO_PXDIRS((n)))
7.895 +#define REG_GPIO_PXDIRC(n) REG32(GPIO_PXDIRC((n)))
7.896 +#define REG_GPIO_PXTRG(n) REG32(GPIO_PXTRG((n))) /* 0:level-trigger, 1:edge-trigger */
7.897 +#define REG_GPIO_PXTRGS(n) REG32(GPIO_PXTRGS((n)))
7.898 +#define REG_GPIO_PXTRGC(n) REG32(GPIO_PXTRGC((n)))
7.899 +#define REG_GPIO_PXFLG(n) REG32(GPIO_PXFLG((n))) /* interrupt flag */
7.900 +#define REG_GPIO_PXFLGC(n) REG32(GPIO_PXFLGC((n))) /* interrupt flag */
7.901 +
7.902 +
7.903 +/*************************************************************************
7.904 + * UART
7.905 + *************************************************************************/
7.906 +
7.907 +#define IRDA_BASE UART0_BASE
7.908 +/*#define UART_BASE UART0_BASE */
7.909 +#define UART_OFF 0x1000
7.910 +
7.911 +/* Register Offset */
7.912 +#define OFF_RDR (0x00) /* R 8b H'xx */
7.913 +#define OFF_TDR (0x00) /* W 8b H'xx */
7.914 +#define OFF_DLLR (0x00) /* RW 8b H'00 */
7.915 +#define OFF_DLHR (0x04) /* RW 8b H'00 */
7.916 +#define OFF_IER (0x04) /* RW 8b H'00 */
7.917 +#define OFF_ISR (0x08) /* R 8b H'01 */
7.918 +#define OFF_FCR (0x08) /* W 8b H'00 */
7.919 +#define OFF_LCR (0x0C) /* RW 8b H'00 */
7.920 +#define OFF_MCR (0x10) /* RW 8b H'00 */
7.921 +#define OFF_LSR (0x14) /* R 8b H'00 */
7.922 +#define OFF_MSR (0x18) /* R 8b H'00 */
7.923 +#define OFF_SPR (0x1C) /* RW 8b H'00 */
7.924 +#define OFF_SIRCR (0x20) /* RW 8b H'00, UART0 */
7.925 +#define OFF_UMR (0x24) /* RW 8b H'00, UART M Register */
7.926 +#define OFF_UACR (0x28) /* RW 8b H'00, UART Add Cycle Register */
7.927 +
7.928 +/* Register Address */
7.929 +#define UART0_RDR (UART0_BASE + OFF_RDR)
7.930 +#define UART0_TDR (UART0_BASE + OFF_TDR)
7.931 +#define UART0_DLLR (UART0_BASE + OFF_DLLR)
7.932 +#define UART0_DLHR (UART0_BASE + OFF_DLHR)
7.933 +#define UART0_IER (UART0_BASE + OFF_IER)
7.934 +#define UART0_ISR (UART0_BASE + OFF_ISR)
7.935 +#define UART0_FCR (UART0_BASE + OFF_FCR)
7.936 +#define UART0_LCR (UART0_BASE + OFF_LCR)
7.937 +#define UART0_MCR (UART0_BASE + OFF_MCR)
7.938 +#define UART0_LSR (UART0_BASE + OFF_LSR)
7.939 +#define UART0_MSR (UART0_BASE + OFF_MSR)
7.940 +#define UART0_SPR (UART0_BASE + OFF_SPR)
7.941 +#define UART0_SIRCR (UART0_BASE + OFF_SIRCR)
7.942 +#define UART0_UMR (UART0_BASE + OFF_UMR)
7.943 +#define UART0_UACR (UART0_BASE + OFF_UACR)
7.944 +
7.945 +/*
7.946 + * Define macros for UART_IER
7.947 + * UART Interrupt Enable Register
7.948 + */
7.949 +#define UART_IER_RIE (1 << 0) /* 0: receive fifo "full" interrupt disable */
7.950 +#define UART_IER_TIE (1 << 1) /* 0: transmit fifo "empty" interrupt disable */
7.951 +#define UART_IER_RLIE (1 << 2) /* 0: receive line status interrupt disable */
7.952 +#define UART_IER_MIE (1 << 3) /* 0: modem status interrupt disable */
7.953 +#define UART_IER_RTIE (1 << 4) /* 0: receive timeout interrupt disable */
7.954 +
7.955 +/*
7.956 + * Define macros for UART_ISR
7.957 + * UART Interrupt Status Register
7.958 + */
7.959 +#define UART_ISR_IP (1 << 0) /* 0: interrupt is pending 1: no interrupt */
7.960 +#define UART_ISR_IID (7 << 1) /* Source of Interrupt */
7.961 +#define UART_ISR_IID_MSI (0 << 1) /* Modem status interrupt */
7.962 +#define UART_ISR_IID_THRI (1 << 1) /* Transmitter holding register empty */
7.963 +#define UART_ISR_IID_RDI (2 << 1) /* Receiver data interrupt */
7.964 +#define UART_ISR_IID_RLSI (3 << 1) /* Receiver line status interrupt */
7.965 +#define UART_ISR_FFMS (3 << 6) /* FIFO mode select, set when UART_FCR.FE is set to 1 */
7.966 +#define UART_ISR_FFMS_NO_FIFO (0 << 6)
7.967 +#define UART_ISR_FFMS_FIFO_MODE (3 << 6)
7.968 +
7.969 +/*
7.970 + * Define macros for UART_FCR
7.971 + * UART FIFO Control Register
7.972 + */
7.973 +#define UART_FCR_FE (1 << 0) /* 0: non-FIFO mode 1: FIFO mode */
7.974 +#define UART_FCR_RFLS (1 << 1) /* write 1 to flush receive FIFO */
7.975 +#define UART_FCR_TFLS (1 << 2) /* write 1 to flush transmit FIFO */
7.976 +#define UART_FCR_DMS (1 << 3) /* 0: disable DMA mode */
7.977 +#define UART_FCR_UUE (1 << 4) /* 0: disable UART */
7.978 +#define UART_FCR_RTRG (3 << 6) /* Receive FIFO Data Trigger */
7.979 +#define UART_FCR_RTRG_1 (0 << 6)
7.980 +#define UART_FCR_RTRG_4 (1 << 6)
7.981 +#define UART_FCR_RTRG_8 (2 << 6)
7.982 +#define UART_FCR_RTRG_15 (3 << 6)
7.983 +
7.984 +/*
7.985 + * Define macros for UART_LCR
7.986 + * UART Line Control Register
7.987 + */
7.988 +#define UART_LCR_WLEN (3 << 0) /* word length */
7.989 +#define UART_LCR_WLEN_5 (0 << 0)
7.990 +#define UART_LCR_WLEN_6 (1 << 0)
7.991 +#define UART_LCR_WLEN_7 (2 << 0)
7.992 +#define UART_LCR_WLEN_8 (3 << 0)
7.993 +#define UART_LCR_STOP (1 << 2) /* 0: 1 stop bit when word length is 5,6,7,8
7.994 + 1: 1.5 stop bits when 5; 2 stop bits when 6,7,8 */
7.995 +#define UART_LCR_STOP_1 (0 << 2) /* 0: 1 stop bit when word length is 5,6,7,8
7.996 + 1: 1.5 stop bits when 5; 2 stop bits when 6,7,8 */
7.997 +#define UART_LCR_STOP_2 (1 << 2) /* 0: 1 stop bit when word length is 5,6,7,8
7.998 + 1: 1.5 stop bits when 5; 2 stop bits when 6,7,8 */
7.999 +
7.1000 +#define UART_LCR_PE (1 << 3) /* 0: parity disable */
7.1001 +#define UART_LCR_PROE (1 << 4) /* 0: even parity 1: odd parity */
7.1002 +#define UART_LCR_SPAR (1 << 5) /* 0: sticky parity disable */
7.1003 +#define UART_LCR_SBRK (1 << 6) /* write 0 normal, write 1 send break */
7.1004 +#define UART_LCR_DLAB (1 << 7) /* 0: access UART_RDR/TDR/IER 1: access UART_DLLR/DLHR */
7.1005 +
7.1006 +/*
7.1007 + * Define macros for UART_LSR
7.1008 + * UART Line Status Register
7.1009 + */
7.1010 +#define UART_LSR_DR (1 << 0) /* 0: receive FIFO is empty 1: receive data is ready */
7.1011 +#define UART_LSR_ORER (1 << 1) /* 0: no overrun error */
7.1012 +#define UART_LSR_PER (1 << 2) /* 0: no parity error */
7.1013 +#define UART_LSR_FER (1 << 3) /* 0; no framing error */
7.1014 +#define UART_LSR_BRK (1 << 4) /* 0: no break detected 1: receive a break signal */
7.1015 +#define UART_LSR_TDRQ (1 << 5) /* 1: transmit FIFO half "empty" */
7.1016 +#define UART_LSR_TEMT (1 << 6) /* 1: transmit FIFO and shift registers empty */
7.1017 +#define UART_LSR_RFER (1 << 7) /* 0: no receive error 1: receive error in FIFO mode */
7.1018 +
7.1019 +/*
7.1020 + * Define macros for UART_MCR
7.1021 + * UART Modem Control Register
7.1022 + */
7.1023 +#define UART_MCR_DTR (1 << 0) /* 0: DTR_ ouput high */
7.1024 +#define UART_MCR_RTS (1 << 1) /* 0: RTS_ output high */
7.1025 +#define UART_MCR_OUT1 (1 << 2) /* 0: UART_MSR.RI is set to 0 and RI_ input high */
7.1026 +#define UART_MCR_OUT2 (1 << 3) /* 0: UART_MSR.DCD is set to 0 and DCD_ input high */
7.1027 +#define UART_MCR_LOOP (1 << 4) /* 0: normal 1: loopback mode */
7.1028 +#define UART_MCR_MCE (1 << 7) /* 0: modem function is disable */
7.1029 +
7.1030 +/*
7.1031 + * Define macros for UART_MSR
7.1032 + * UART Modem Status Register
7.1033 + */
7.1034 +#define UART_MSR_DCTS (1 << 0) /* 0: no change on CTS_ pin since last read of UART_MSR */
7.1035 +#define UART_MSR_DDSR (1 << 1) /* 0: no change on DSR_ pin since last read of UART_MSR */
7.1036 +#define UART_MSR_DRI (1 << 2) /* 0: no change on RI_ pin since last read of UART_MSR */
7.1037 +#define UART_MSR_DDCD (1 << 3) /* 0: no change on DCD_ pin since last read of UART_MSR */
7.1038 +#define UART_MSR_CTS (1 << 4) /* 0: CTS_ pin is high */
7.1039 +#define UART_MSR_DSR (1 << 5) /* 0: DSR_ pin is high */
7.1040 +#define UART_MSR_RI (1 << 6) /* 0: RI_ pin is high */
7.1041 +#define UART_MSR_DCD (1 << 7) /* 0: DCD_ pin is high */
7.1042 +
7.1043 +/*
7.1044 + * Define macros for SIRCR
7.1045 + * Slow IrDA Control Register
7.1046 + */
7.1047 +#define SIRCR_TSIRE (1 << 0) /* 0: transmitter is in UART mode 1: IrDA mode */
7.1048 +#define SIRCR_RSIRE (1 << 1) /* 0: receiver is in UART mode 1: IrDA mode */
7.1049 +#define SIRCR_TPWS (1 << 2) /* 0: transmit 0 pulse width is 3/16 of bit length
7.1050 + 1: 0 pulse width is 1.6us for 115.2Kbps */
7.1051 +#define SIRCR_TXPL (1 << 3) /* 0: encoder generates a positive pulse for 0 */
7.1052 +#define SIRCR_RXPL (1 << 4) /* 0: decoder interprets positive pulse as 0 */
7.1053 +
7.1054 +
7.1055 +/*************************************************************************
7.1056 + * AIC (AC97/I2S Controller)
7.1057 + *************************************************************************/
7.1058 +#define AIC_FR (AIC_BASE + 0x000)
7.1059 +#define AIC_CR (AIC_BASE + 0x004)
7.1060 +#define AIC_ACCR1 (AIC_BASE + 0x008)
7.1061 +#define AIC_ACCR2 (AIC_BASE + 0x00C)
7.1062 +#define AIC_I2SCR (AIC_BASE + 0x010)
7.1063 +#define AIC_SR (AIC_BASE + 0x014)
7.1064 +#define AIC_ACSR (AIC_BASE + 0x018)
7.1065 +#define AIC_I2SSR (AIC_BASE + 0x01C)
7.1066 +#define AIC_ACCAR (AIC_BASE + 0x020)
7.1067 +#define AIC_ACCDR (AIC_BASE + 0x024)
7.1068 +#define AIC_ACSAR (AIC_BASE + 0x028)
7.1069 +#define AIC_ACSDR (AIC_BASE + 0x02C)
7.1070 +#define AIC_I2SDIV (AIC_BASE + 0x030)
7.1071 +#define AIC_DR (AIC_BASE + 0x034)
7.1072 +
7.1073 +#define REG_AIC_FR REG32(AIC_FR)
7.1074 +#define REG_AIC_CR REG32(AIC_CR)
7.1075 +#define REG_AIC_ACCR1 REG32(AIC_ACCR1)
7.1076 +#define REG_AIC_ACCR2 REG32(AIC_ACCR2)
7.1077 +#define REG_AIC_I2SCR REG32(AIC_I2SCR)
7.1078 +#define REG_AIC_SR REG32(AIC_SR)
7.1079 +#define REG_AIC_ACSR REG32(AIC_ACSR)
7.1080 +#define REG_AIC_I2SSR REG32(AIC_I2SSR)
7.1081 +#define REG_AIC_ACCAR REG32(AIC_ACCAR)
7.1082 +#define REG_AIC_ACCDR REG32(AIC_ACCDR)
7.1083 +#define REG_AIC_ACSAR REG32(AIC_ACSAR)
7.1084 +#define REG_AIC_ACSDR REG32(AIC_ACSDR)
7.1085 +#define REG_AIC_I2SDIV REG32(AIC_I2SDIV)
7.1086 +#define REG_AIC_DR REG32(AIC_DR)
7.1087 +
7.1088 +/* AIC Controller Configuration Register (AIC_FR) */
7.1089 +
7.1090 +#define AIC_FR_RFTH_BIT 12 /* Receive FIFO Threshold */
7.1091 +#define AIC_FR_RFTH_MASK (0xf << AIC_FR_RFTH_BIT)
7.1092 +#define AIC_FR_TFTH_BIT 8 /* Transmit FIFO Threshold */
7.1093 +#define AIC_FR_TFTH_MASK (0xf << AIC_FR_TFTH_BIT)
7.1094 +#define AIC_FR_ICDC (1 << 5) /* External(0) or Internal CODEC(1) */
7.1095 +#define AIC_FR_AUSEL (1 << 4) /* AC97(0) or I2S/MSB-justified(1) */
7.1096 +#define AIC_FR_RST (1 << 3) /* AIC registers reset */
7.1097 +#define AIC_FR_BCKD (1 << 2) /* I2S BIT_CLK direction, 0:input,1:output */
7.1098 +#define AIC_FR_SYNCD (1 << 1) /* I2S SYNC direction, 0:input,1:output */
7.1099 +#define AIC_FR_ENB (1 << 0) /* AIC enable bit */
7.1100 +
7.1101 +/* AIC Controller Common Control Register (AIC_CR) */
7.1102 +
7.1103 +#define AIC_CR_OSS_BIT 19 /* Output Sample Size from memory (AIC V2 only) */
7.1104 +#define AIC_CR_OSS_MASK (0x7 << AIC_CR_OSS_BIT)
7.1105 + #define AIC_CR_OSS_8BIT (0x0 << AIC_CR_OSS_BIT)
7.1106 + #define AIC_CR_OSS_16BIT (0x1 << AIC_CR_OSS_BIT)
7.1107 + #define AIC_CR_OSS_18BIT (0x2 << AIC_CR_OSS_BIT)
7.1108 + #define AIC_CR_OSS_20BIT (0x3 << AIC_CR_OSS_BIT)
7.1109 + #define AIC_CR_OSS_24BIT (0x4 << AIC_CR_OSS_BIT)
7.1110 +#define AIC_CR_ISS_BIT 16 /* Input Sample Size from memory (AIC V2 only) */
7.1111 +#define AIC_CR_ISS_MASK (0x7 << AIC_CR_ISS_BIT)
7.1112 + #define AIC_CR_ISS_8BIT (0x0 << AIC_CR_ISS_BIT)
7.1113 + #define AIC_CR_ISS_16BIT (0x1 << AIC_CR_ISS_BIT)
7.1114 + #define AIC_CR_ISS_18BIT (0x2 << AIC_CR_ISS_BIT)
7.1115 + #define AIC_CR_ISS_20BIT (0x3 << AIC_CR_ISS_BIT)
7.1116 + #define AIC_CR_ISS_24BIT (0x4 << AIC_CR_ISS_BIT)
7.1117 +#define AIC_CR_RDMS (1 << 15) /* Receive DMA enable */
7.1118 +#define AIC_CR_TDMS (1 << 14) /* Transmit DMA enable */
7.1119 +#define AIC_CR_M2S (1 << 11) /* Mono to Stereo enable */
7.1120 +#define AIC_CR_ENDSW (1 << 10) /* Endian switch enable */
7.1121 +#define AIC_CR_AVSTSU (1 << 9) /* Signed <-> Unsigned toggle enable */
7.1122 +#define AIC_CR_FLUSH (1 << 8) /* Flush FIFO */
7.1123 +#define AIC_CR_EROR (1 << 6) /* Enable ROR interrupt */
7.1124 +#define AIC_CR_ETUR (1 << 5) /* Enable TUR interrupt */
7.1125 +#define AIC_CR_ERFS (1 << 4) /* Enable RFS interrupt */
7.1126 +#define AIC_CR_ETFS (1 << 3) /* Enable TFS interrupt */
7.1127 +#define AIC_CR_ENLBF (1 << 2) /* Enable Loopback Function */
7.1128 +#define AIC_CR_ERPL (1 << 1) /* Enable Playback Function */
7.1129 +#define AIC_CR_EREC (1 << 0) /* Enable Record Function */
7.1130 +
7.1131 +/* AIC Controller AC-link Control Register 1 (AIC_ACCR1) */
7.1132 +
7.1133 +#define AIC_ACCR1_RS_BIT 16 /* Receive Valid Slots */
7.1134 +#define AIC_ACCR1_RS_MASK (0x3ff << AIC_ACCR1_RS_BIT)
7.1135 + #define AIC_ACCR1_RS_SLOT12 (1 << 25) /* Slot 12 valid bit */
7.1136 + #define AIC_ACCR1_RS_SLOT11 (1 << 24) /* Slot 11 valid bit */
7.1137 + #define AIC_ACCR1_RS_SLOT10 (1 << 23) /* Slot 10 valid bit */
7.1138 + #define AIC_ACCR1_RS_SLOT9 (1 << 22) /* Slot 9 valid bit, LFE */
7.1139 + #define AIC_ACCR1_RS_SLOT8 (1 << 21) /* Slot 8 valid bit, Surround Right */
7.1140 + #define AIC_ACCR1_RS_SLOT7 (1 << 20) /* Slot 7 valid bit, Surround Left */
7.1141 + #define AIC_ACCR1_RS_SLOT6 (1 << 19) /* Slot 6 valid bit, PCM Center */
7.1142 + #define AIC_ACCR1_RS_SLOT5 (1 << 18) /* Slot 5 valid bit */
7.1143 + #define AIC_ACCR1_RS_SLOT4 (1 << 17) /* Slot 4 valid bit, PCM Right */
7.1144 + #define AIC_ACCR1_RS_SLOT3 (1 << 16) /* Slot 3 valid bit, PCM Left */
7.1145 +#define AIC_ACCR1_XS_BIT 0 /* Transmit Valid Slots */
7.1146 +#define AIC_ACCR1_XS_MASK (0x3ff << AIC_ACCR1_XS_BIT)
7.1147 + #define AIC_ACCR1_XS_SLOT12 (1 << 9) /* Slot 12 valid bit */
7.1148 + #define AIC_ACCR1_XS_SLOT11 (1 << 8) /* Slot 11 valid bit */
7.1149 + #define AIC_ACCR1_XS_SLOT10 (1 << 7) /* Slot 10 valid bit */
7.1150 + #define AIC_ACCR1_XS_SLOT9 (1 << 6) /* Slot 9 valid bit, LFE */
7.1151 + #define AIC_ACCR1_XS_SLOT8 (1 << 5) /* Slot 8 valid bit, Surround Right */
7.1152 + #define AIC_ACCR1_XS_SLOT7 (1 << 4) /* Slot 7 valid bit, Surround Left */
7.1153 + #define AIC_ACCR1_XS_SLOT6 (1 << 3) /* Slot 6 valid bit, PCM Center */
7.1154 + #define AIC_ACCR1_XS_SLOT5 (1 << 2) /* Slot 5 valid bit */
7.1155 + #define AIC_ACCR1_XS_SLOT4 (1 << 1) /* Slot 4 valid bit, PCM Right */
7.1156 + #define AIC_ACCR1_XS_SLOT3 (1 << 0) /* Slot 3 valid bit, PCM Left */
7.1157 +
7.1158 +/* AIC Controller AC-link Control Register 2 (AIC_ACCR2) */
7.1159 +
7.1160 +#define AIC_ACCR2_ERSTO (1 << 18) /* Enable RSTO interrupt */
7.1161 +#define AIC_ACCR2_ESADR (1 << 17) /* Enable SADR interrupt */
7.1162 +#define AIC_ACCR2_ECADT (1 << 16) /* Enable CADT interrupt */
7.1163 +#define AIC_ACCR2_OASS_BIT 8 /* Output Sample Size for AC-link */
7.1164 +#define AIC_ACCR2_OASS_MASK (0x3 << AIC_ACCR2_OASS_BIT)
7.1165 + #define AIC_ACCR2_OASS_20BIT (0 << AIC_ACCR2_OASS_BIT) /* Output Audio Sample Size is 20-bit */
7.1166 + #define AIC_ACCR2_OASS_18BIT (1 << AIC_ACCR2_OASS_BIT) /* Output Audio Sample Size is 18-bit */
7.1167 + #define AIC_ACCR2_OASS_16BIT (2 << AIC_ACCR2_OASS_BIT) /* Output Audio Sample Size is 16-bit */
7.1168 + #define AIC_ACCR2_OASS_8BIT (3 << AIC_ACCR2_OASS_BIT) /* Output Audio Sample Size is 8-bit */
7.1169 +#define AIC_ACCR2_IASS_BIT 6 /* Output Sample Size for AC-link */
7.1170 +#define AIC_ACCR2_IASS_MASK (0x3 << AIC_ACCR2_IASS_BIT)
7.1171 + #define AIC_ACCR2_IASS_20BIT (0 << AIC_ACCR2_IASS_BIT) /* Input Audio Sample Size is 20-bit */
7.1172 + #define AIC_ACCR2_IASS_18BIT (1 << AIC_ACCR2_IASS_BIT) /* Input Audio Sample Size is 18-bit */
7.1173 + #define AIC_ACCR2_IASS_16BIT (2 << AIC_ACCR2_IASS_BIT) /* Input Audio Sample Size is 16-bit */
7.1174 + #define AIC_ACCR2_IASS_8BIT (3 << AIC_ACCR2_IASS_BIT) /* Input Audio Sample Size is 8-bit */
7.1175 +#define AIC_ACCR2_SO (1 << 3) /* SDATA_OUT output value */
7.1176 +#define AIC_ACCR2_SR (1 << 2) /* RESET# pin level */
7.1177 +#define AIC_ACCR2_SS (1 << 1) /* SYNC pin level */
7.1178 +#define AIC_ACCR2_SA (1 << 0) /* SYNC and SDATA_OUT alternation */
7.1179 +
7.1180 +/* AIC Controller I2S/MSB-justified Control Register (AIC_I2SCR) */
7.1181 +
7.1182 +#define AIC_I2SCR_STPBK (1 << 12) /* Stop BIT_CLK for I2S/MSB-justified */
7.1183 +#define AIC_I2SCR_WL_BIT 1 /* Input/Output Sample Size for I2S/MSB-justified */
7.1184 +#define AIC_I2SCR_WL_MASK (0x7 << AIC_I2SCR_WL_BIT)
7.1185 + #define AIC_I2SCR_WL_24BIT (0 << AIC_I2SCR_WL_BIT) /* Word Length is 24 bit */
7.1186 + #define AIC_I2SCR_WL_20BIT (1 << AIC_I2SCR_WL_BIT) /* Word Length is 20 bit */
7.1187 + #define AIC_I2SCR_WL_18BIT (2 << AIC_I2SCR_WL_BIT) /* Word Length is 18 bit */
7.1188 + #define AIC_I2SCR_WL_16BIT (3 << AIC_I2SCR_WL_BIT) /* Word Length is 16 bit */
7.1189 + #define AIC_I2SCR_WL_8BIT (4 << AIC_I2SCR_WL_BIT) /* Word Length is 8 bit */
7.1190 +#define AIC_I2SCR_AMSL (1 << 0) /* 0:I2S, 1:MSB-justified */
7.1191 +
7.1192 +/* AIC Controller FIFO Status Register (AIC_SR) */
7.1193 +
7.1194 +#define AIC_SR_RFL_BIT 24 /* Receive FIFO Level */
7.1195 +#define AIC_SR_RFL_MASK (0x3f << AIC_SR_RFL_BIT)
7.1196 +#define AIC_SR_TFL_BIT 8 /* Transmit FIFO level */
7.1197 +#define AIC_SR_TFL_MASK (0x3f << AIC_SR_TFL_BIT)
7.1198 +#define AIC_SR_ROR (1 << 6) /* Receive FIFO Overrun */
7.1199 +#define AIC_SR_TUR (1 << 5) /* Transmit FIFO Underrun */
7.1200 +#define AIC_SR_RFS (1 << 4) /* Receive FIFO Service Request */
7.1201 +#define AIC_SR_TFS (1 << 3) /* Transmit FIFO Service Request */
7.1202 +
7.1203 +/* AIC Controller AC-link Status Register (AIC_ACSR) */
7.1204 +
7.1205 +#define AIC_ACSR_SLTERR (1 << 21) /* Slot Error Flag */
7.1206 +#define AIC_ACSR_CRDY (1 << 20) /* External CODEC Ready Flag */
7.1207 +#define AIC_ACSR_CLPM (1 << 19) /* External CODEC low power mode flag */
7.1208 +#define AIC_ACSR_RSTO (1 << 18) /* External CODEC regs read status timeout */
7.1209 +#define AIC_ACSR_SADR (1 << 17) /* External CODEC regs status addr and data received */
7.1210 +#define AIC_ACSR_CADT (1 << 16) /* Command Address and Data Transmitted */
7.1211 +
7.1212 +/* AIC Controller I2S/MSB-justified Status Register (AIC_I2SSR) */
7.1213 +
7.1214 +#define AIC_I2SSR_BSY (1 << 2) /* AIC Busy in I2S/MSB-justified format */
7.1215 +
7.1216 +/* AIC Controller AC97 codec Command Address Register (AIC_ACCAR) */
7.1217 +
7.1218 +#define AIC_ACCAR_CAR_BIT 0
7.1219 +#define AIC_ACCAR_CAR_MASK (0xfffff << AIC_ACCAR_CAR_BIT)
7.1220 +
7.1221 +/* AIC Controller AC97 codec Command Data Register (AIC_ACCDR) */
7.1222 +
7.1223 +#define AIC_ACCDR_CDR_BIT 0
7.1224 +#define AIC_ACCDR_CDR_MASK (0xfffff << AIC_ACCDR_CDR_BIT)
7.1225 +
7.1226 +/* AIC Controller AC97 codec Status Address Register (AIC_ACSAR) */
7.1227 +
7.1228 +#define AIC_ACSAR_SAR_BIT 0
7.1229 +#define AIC_ACSAR_SAR_MASK (0xfffff << AIC_ACSAR_SAR_BIT)
7.1230 +
7.1231 +/* AIC Controller AC97 codec Status Data Register (AIC_ACSDR) */
7.1232 +
7.1233 +#define AIC_ACSDR_SDR_BIT 0
7.1234 +#define AIC_ACSDR_SDR_MASK (0xfffff << AIC_ACSDR_SDR_BIT)
7.1235 +
7.1236 +/* AIC Controller I2S/MSB-justified Clock Divider Register (AIC_I2SDIV) */
7.1237 +
7.1238 +#define AIC_I2SDIV_DIV_BIT 0
7.1239 +#define AIC_I2SDIV_DIV_MASK (0x7f << AIC_I2SDIV_DIV_BIT)
7.1240 + #define AIC_I2SDIV_BITCLK_3072KHZ (0x0C << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 3.072MHz */
7.1241 + #define AIC_I2SDIV_BITCLK_2836KHZ (0x0D << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 2.836MHz */
7.1242 + #define AIC_I2SDIV_BITCLK_1418KHZ (0x1A << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 1.418MHz */
7.1243 + #define AIC_I2SDIV_BITCLK_1024KHZ (0x24 << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 1.024MHz */
7.1244 + #define AIC_I2SDIV_BITCLK_7089KHZ (0x34 << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 708.92KHz */
7.1245 + #define AIC_I2SDIV_BITCLK_512KHZ (0x48 << AIC_I2SDIV_DIV_BIT) /* BIT_CLK of 512.00KHz */
7.1246 +
7.1247 +
7.1248 +/*************************************************************************
7.1249 + * ICDC (Internal CODEC)
7.1250 + *************************************************************************/
7.1251 +#define ICDC_CR (ICDC_BASE + 0x0400) /* ICDC Control Register */
7.1252 +#define ICDC_APWAIT (ICDC_BASE + 0x0404) /* Anti-Pop WAIT Stage Timing Control Register */
7.1253 +#define ICDC_APPRE (ICDC_BASE + 0x0408) /* Anti-Pop HPEN-PRE Stage Timing Control Register */
7.1254 +#define ICDC_APHPEN (ICDC_BASE + 0x040C) /* Anti-Pop HPEN Stage Timing Control Register */
7.1255 +#define ICDC_APSR (ICDC_BASE + 0x0410) /* Anti-Pop Status Register */
7.1256 +#define ICDC_CDCCR1 (ICDC_BASE + 0x0080)
7.1257 +#define ICDC_CDCCR2 (ICDC_BASE + 0x0084)
7.1258 +
7.1259 +#define REG_ICDC_CR REG32(ICDC_CR)
7.1260 +#define REG_ICDC_APWAIT REG32(ICDC_APWAIT)
7.1261 +#define REG_ICDC_APPRE REG32(ICDC_APPRE)
7.1262 +#define REG_ICDC_APHPEN REG32(ICDC_APHPEN)
7.1263 +#define REG_ICDC_APSR REG32(ICDC_APSR)
7.1264 +#define REG_ICDC_CDCCR1 REG32(ICDC_CDCCR1)
7.1265 +#define REG_ICDC_CDCCR2 REG32(ICDC_CDCCR2)
7.1266 +
7.1267 +/* ICDC Control Register */
7.1268 +#define ICDC_CR_LINVOL_BIT 24 /* LINE Input Volume Gain: GAIN=LINVOL*1.5-34.5 */
7.1269 +#define ICDC_CR_LINVOL_MASK (0x1f << ICDC_CR_LINVOL_BIT)
7.1270 +#define ICDC_CR_ASRATE_BIT 20 /* Audio Sample Rate */
7.1271 +#define ICDC_CR_ASRATE_MASK (0x0f << ICDC_CR_ASRATE_BIT)
7.1272 + #define ICDC_CR_ASRATE_8000 (0x0 << ICDC_CR_ASRATE_BIT)
7.1273 + #define ICDC_CR_ASRATE_11025 (0x1 << ICDC_CR_ASRATE_BIT)
7.1274 + #define ICDC_CR_ASRATE_12000 (0x2 << ICDC_CR_ASRATE_BIT)
7.1275 + #define ICDC_CR_ASRATE_16000 (0x3 << ICDC_CR_ASRATE_BIT)
7.1276 + #define ICDC_CR_ASRATE_22050 (0x4 << ICDC_CR_ASRATE_BIT)
7.1277 + #define ICDC_CR_ASRATE_24000 (0x5 << ICDC_CR_ASRATE_BIT)
7.1278 + #define ICDC_CR_ASRATE_32000 (0x6 << ICDC_CR_ASRATE_BIT)
7.1279 + #define ICDC_CR_ASRATE_44100 (0x7 << ICDC_CR_ASRATE_BIT)
7.1280 + #define ICDC_CR_ASRATE_48000 (0x8 << ICDC_CR_ASRATE_BIT)
7.1281 +#define ICDC_CR_MICBG_BIT 18 /* MIC Boost Gain */
7.1282 +#define ICDC_CR_MICBG_MASK (0x3 << ICDC_CR_MICBG_BIT)
7.1283 + #define ICDC_CR_MICBG_0DB (0x0 << ICDC_CR_MICBG_BIT)
7.1284 + #define ICDC_CR_MICBG_6DB (0x1 << ICDC_CR_MICBG_BIT)
7.1285 + #define ICDC_CR_MICBG_12DB (0x2 << ICDC_CR_MICBG_BIT)
7.1286 + #define ICDC_CR_MICBG_20DB (0x3 << ICDC_CR_MICBG_BIT)
7.1287 +#define ICDC_CR_HPVOL_BIT 16 /* Headphone Volume Gain */
7.1288 +#define ICDC_CR_HPVOL_MASK (0x3 << ICDC_CR_HPVOL_BIT)
7.1289 + #define ICDC_CR_HPVOL_0DB (0x0 << ICDC_CR_HPVOL_BIT)
7.1290 + #define ICDC_CR_HPVOL_2DB (0x1 << ICDC_CR_HPVOL_BIT)
7.1291 + #define ICDC_CR_HPVOL_4DB (0x2 << ICDC_CR_HPVOL_BIT)
7.1292 + #define ICDC_CR_HPVOL_6DB (0x3 << ICDC_CR_HPVOL_BIT)
7.1293 +#define ICDC_CR_ELINEIN (1 << 13) /* Enable LINE Input */
7.1294 +#define ICDC_CR_EMIC (1 << 12) /* Enable MIC Input */
7.1295 +#define ICDC_CR_SW1ON (1 << 11) /* Switch 1 in CODEC is on */
7.1296 +#define ICDC_CR_EADC (1 << 10) /* Enable ADC */
7.1297 +#define ICDC_CR_SW2ON (1 << 9) /* Switch 2 in CODEC is on */
7.1298 +#define ICDC_CR_EDAC (1 << 8) /* Enable DAC */
7.1299 +#define ICDC_CR_HPMUTE (1 << 5) /* Headphone Mute */
7.1300 +#define ICDC_CR_HPTON (1 << 4) /* Headphone Amplifier Trun On */
7.1301 +#define ICDC_CR_HPTOFF (1 << 3) /* Headphone Amplifier Trun Off */
7.1302 +#define ICDC_CR_TAAP (1 << 2) /* Turn Around of the Anti-Pop Procedure */
7.1303 +#define ICDC_CR_EAP (1 << 1) /* Enable Anti-Pop Procedure */
7.1304 +#define ICDC_CR_SUSPD (1 << 0) /* CODEC Suspend */
7.1305 +
7.1306 +/* Anti-Pop WAIT Stage Timing Control Register */
7.1307 +#define ICDC_APWAIT_WAITSN_BIT 0
7.1308 +#define ICDC_APWAIT_WAITSN_MASK (0x7ff << ICDC_APWAIT_WAITSN_BIT)
7.1309 +
7.1310 +/* Anti-Pop HPEN-PRE Stage Timing Control Register */
7.1311 +#define ICDC_APPRE_PRESN_BIT 0
7.1312 +#define ICDC_APPRE_PRESN_MASK (0x1ff << ICDC_APPRE_PRESN_BIT)
7.1313 +
7.1314 +/* Anti-Pop HPEN Stage Timing Control Register */
7.1315 +#define ICDC_APHPEN_HPENSN_BIT 0
7.1316 +#define ICDC_APHPEN_HPENSN_MASK (0x3fff << ICDC_APHPEN_HPENSN_BIT)
7.1317 +
7.1318 +/* Anti-Pop Status Register */
7.1319 +#define ICDC_SR_HPST_BIT 14 /* Headphone Amplifier State */
7.1320 +#define ICDC_SR_HPST_MASK (0x7 << ICDC_SR_HPST_BIT)
7.1321 +#define ICDC_SR_HPST_HP_OFF (0x0 << ICDC_SR_HPST_BIT) /* HP amplifier is off */
7.1322 +#define ICDC_SR_HPST_TON_WAIT (0x1 << ICDC_SR_HPST_BIT) /* wait state in turn-on */
7.1323 + #define ICDC_SR_HPST_TON_PRE (0x2 << ICDC_SR_HPST_BIT) /* pre-enable state in turn-on */
7.1324 +#define ICDC_SR_HPST_TON_HPEN (0x3 << ICDC_SR_HPST_BIT) /* HP enable state in turn-on */
7.1325 + #define ICDC_SR_HPST_TOFF_HPEN (0x4 << ICDC_SR_HPST_BIT) /* HP enable state in turn-off */
7.1326 + #define ICDC_SR_HPST_TOFF_PRE (0x5 << ICDC_SR_HPST_BIT) /* pre-enable state in turn-off */
7.1327 + #define ICDC_SR_HPST_TOFF_WAIT (0x6 << ICDC_SR_HPST_BIT) /* wait state in turn-off */
7.1328 + #define ICDC_SR_HPST_HP_ON (0x7 << ICDC_SR_HPST_BIT) /* HP amplifier is on */
7.1329 +#define ICDC_SR_SNCNT_BIT 0 /* Sample Number Counter */
7.1330 +#define ICDC_SR_SNCNT_MASK (0x3fff << ICDC_SR_SNCNT_BIT)
7.1331 +
7.1332 +
7.1333 +/*************************************************************************
7.1334 + * I2C
7.1335 + *************************************************************************/
7.1336 +#define I2C_DR (I2C_BASE + 0x000)
7.1337 +#define I2C_CR (I2C_BASE + 0x004)
7.1338 +#define I2C_SR (I2C_BASE + 0x008)
7.1339 +#define I2C_GR (I2C_BASE + 0x00C)
7.1340 +
7.1341 +#define REG_I2C_DR REG8(I2C_DR)
7.1342 +#define REG_I2C_CR REG8(I2C_CR)
7.1343 +#define REG_I2C_SR REG8(I2C_SR)
7.1344 +#define REG_I2C_GR REG16(I2C_GR)
7.1345 +
7.1346 +/* I2C Control Register (I2C_CR) */
7.1347 +
7.1348 +#define I2C_CR_IEN (1 << 4)
7.1349 +#define I2C_CR_STA (1 << 3)
7.1350 +#define I2C_CR_STO (1 << 2)
7.1351 +#define I2C_CR_AC (1 << 1)
7.1352 +#define I2C_CR_I2CE (1 << 0)
7.1353 +
7.1354 +/* I2C Status Register (I2C_SR) */
7.1355 +
7.1356 +#define I2C_SR_STX (1 << 4)
7.1357 +#define I2C_SR_BUSY (1 << 3)
7.1358 +#define I2C_SR_TEND (1 << 2)
7.1359 +#define I2C_SR_DRF (1 << 1)
7.1360 +#define I2C_SR_ACKF (1 << 0)
7.1361 +
7.1362 +
7.1363 +/*************************************************************************
7.1364 + * SSI
7.1365 + *************************************************************************/
7.1366 +#define SSI_DR (SSI_BASE + 0x000)
7.1367 +#define SSI_CR0 (SSI_BASE + 0x004)
7.1368 +#define SSI_CR1 (SSI_BASE + 0x008)
7.1369 +#define SSI_SR (SSI_BASE + 0x00C)
7.1370 +#define SSI_ITR (SSI_BASE + 0x010)
7.1371 +#define SSI_ICR (SSI_BASE + 0x014)
7.1372 +#define SSI_GR (SSI_BASE + 0x018)
7.1373 +
7.1374 +#define REG_SSI_DR REG32(SSI_DR)
7.1375 +#define REG_SSI_CR0 REG16(SSI_CR0)
7.1376 +#define REG_SSI_CR1 REG32(SSI_CR1)
7.1377 +#define REG_SSI_SR REG32(SSI_SR)
7.1378 +#define REG_SSI_ITR REG16(SSI_ITR)
7.1379 +#define REG_SSI_ICR REG8(SSI_ICR)
7.1380 +#define REG_SSI_GR REG16(SSI_GR)
7.1381 +
7.1382 +/* SSI Data Register (SSI_DR) */
7.1383 +
7.1384 +#define SSI_DR_GPC_BIT 0
7.1385 +#define SSI_DR_GPC_MASK (0x1ff << SSI_DR_GPC_BIT)
7.1386 +
7.1387 +/* SSI Control Register 0 (SSI_CR0) */
7.1388 +
7.1389 +#define SSI_CR0_SSIE (1 << 15)
7.1390 +#define SSI_CR0_TIE (1 << 14)
7.1391 +#define SSI_CR0_RIE (1 << 13)
7.1392 +#define SSI_CR0_TEIE (1 << 12)
7.1393 +#define SSI_CR0_REIE (1 << 11)
7.1394 +#define SSI_CR0_LOOP (1 << 10)
7.1395 +#define SSI_CR0_RFINE (1 << 9)
7.1396 +#define SSI_CR0_RFINC (1 << 8)
7.1397 +#define SSI_CR0_FSEL (1 << 6)
7.1398 +#define SSI_CR0_TFLUSH (1 << 2)
7.1399 +#define SSI_CR0_RFLUSH (1 << 1)
7.1400 +#define SSI_CR0_DISREV (1 << 0)
7.1401 +
7.1402 +/* SSI Control Register 1 (SSI_CR1) */
7.1403 +
7.1404 +#define SSI_CR1_FRMHL_BIT 30
7.1405 +#define SSI_CR1_FRMHL_MASK (0x3 << SSI_CR1_FRMHL_BIT)
7.1406 + #define SSI_CR1_FRMHL_CELOW_CE2LOW (0 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is low valid and SSI_CE2_ is low valid */
7.1407 + #define SSI_CR1_FRMHL_CEHIGH_CE2LOW (1 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is high valid and SSI_CE2_ is low valid */
7.1408 + #define SSI_CR1_FRMHL_CELOW_CE2HIGH (2 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is low valid and SSI_CE2_ is high valid */
7.1409 + #define SSI_CR1_FRMHL_CEHIGH_CE2HIGH (3 << SSI_CR1_FRMHL_BIT) /* SSI_CE_ is high valid and SSI_CE2_ is high valid */
7.1410 +#define SSI_CR1_TFVCK_BIT 28
7.1411 +#define SSI_CR1_TFVCK_MASK (0x3 << SSI_CR1_TFVCK_BIT)
7.1412 + #define SSI_CR1_TFVCK_0 (0 << SSI_CR1_TFVCK_BIT)
7.1413 + #define SSI_CR1_TFVCK_1 (1 << SSI_CR1_TFVCK_BIT)
7.1414 + #define SSI_CR1_TFVCK_2 (2 << SSI_CR1_TFVCK_BIT)
7.1415 + #define SSI_CR1_TFVCK_3 (3 << SSI_CR1_TFVCK_BIT)
7.1416 +#define SSI_CR1_TCKFI_BIT 26
7.1417 +#define SSI_CR1_TCKFI_MASK (0x3 << SSI_CR1_TCKFI_BIT)
7.1418 + #define SSI_CR1_TCKFI_0 (0 << SSI_CR1_TCKFI_BIT)
7.1419 + #define SSI_CR1_TCKFI_1 (1 << SSI_CR1_TCKFI_BIT)
7.1420 + #define SSI_CR1_TCKFI_2 (2 << SSI_CR1_TCKFI_BIT)
7.1421 + #define SSI_CR1_TCKFI_3 (3 << SSI_CR1_TCKFI_BIT)
7.1422 +#define SSI_CR1_LFST (1 << 25)
7.1423 +#define SSI_CR1_ITFRM (1 << 24)
7.1424 +#define SSI_CR1_UNFIN (1 << 23)
7.1425 +#define SSI_CR1_MULTS (1 << 22)
7.1426 +#define SSI_CR1_FMAT_BIT 20
7.1427 +#define SSI_CR1_FMAT_MASK (0x3 << SSI_CR1_FMAT_BIT)
7.1428 + #define SSI_CR1_FMAT_SPI (0 << SSI_CR1_FMAT_BIT) /* Motorola¡¯s SPI format */
7.1429 + #define SSI_CR1_FMAT_SSP (1 << SSI_CR1_FMAT_BIT) /* TI's SSP format */
7.1430 + #define SSI_CR1_FMAT_MW1 (2 << SSI_CR1_FMAT_BIT) /* National Microwire 1 format */
7.1431 + #define SSI_CR1_FMAT_MW2 (3 << SSI_CR1_FMAT_BIT) /* National Microwire 2 format */
7.1432 +#define SSI_CR1_TTRG_BIT 16
7.1433 +#define SSI_CR1_TTRG_MASK (0xf << SSI_CR1_TTRG_BIT)
7.1434 + #define SSI_CR1_TTRG_1 (0 << SSI_CR1_TTRG_BIT)
7.1435 + #define SSI_CR1_TTRG_8 (1 << SSI_CR1_TTRG_BIT)
7.1436 + #define SSI_CR1_TTRG_16 (2 << SSI_CR1_TTRG_BIT)
7.1437 + #define SSI_CR1_TTRG_24 (3 << SSI_CR1_TTRG_BIT)
7.1438 + #define SSI_CR1_TTRG_32 (4 << SSI_CR1_TTRG_BIT)
7.1439 + #define SSI_CR1_TTRG_40 (5 << SSI_CR1_TTRG_BIT)
7.1440 + #define SSI_CR1_TTRG_48 (6 << SSI_CR1_TTRG_BIT)
7.1441 + #define SSI_CR1_TTRG_56 (7 << SSI_CR1_TTRG_BIT)
7.1442 + #define SSI_CR1_TTRG_64 (8 << SSI_CR1_TTRG_BIT)
7.1443 + #define SSI_CR1_TTRG_72 (9 << SSI_CR1_TTRG_BIT)
7.1444 + #define SSI_CR1_TTRG_80 (10<< SSI_CR1_TTRG_BIT)
7.1445 + #define SSI_CR1_TTRG_88 (11<< SSI_CR1_TTRG_BIT)
7.1446 + #define SSI_CR1_TTRG_96 (12<< SSI_CR1_TTRG_BIT)
7.1447 + #define SSI_CR1_TTRG_104 (13<< SSI_CR1_TTRG_BIT)
7.1448 + #define SSI_CR1_TTRG_112 (14<< SSI_CR1_TTRG_BIT)
7.1449 + #define SSI_CR1_TTRG_120 (15<< SSI_CR1_TTRG_BIT)
7.1450 +#define SSI_CR1_MCOM_BIT 12
7.1451 +#define SSI_CR1_MCOM_MASK (0xf << SSI_CR1_MCOM_BIT)
7.1452 + #define SSI_CR1_MCOM_1BIT (0x0 << SSI_CR1_MCOM_BIT) /* 1-bit command selected */
7.1453 + #define SSI_CR1_MCOM_2BIT (0x1 << SSI_CR1_MCOM_BIT) /* 2-bit command selected */
7.1454 + #define SSI_CR1_MCOM_3BIT (0x2 << SSI_CR1_MCOM_BIT) /* 3-bit command selected */
7.1455 + #define SSI_CR1_MCOM_4BIT (0x3 << SSI_CR1_MCOM_BIT) /* 4-bit command selected */
7.1456 + #define SSI_CR1_MCOM_5BIT (0x4 << SSI_CR1_MCOM_BIT) /* 5-bit command selected */
7.1457 + #define SSI_CR1_MCOM_6BIT (0x5 << SSI_CR1_MCOM_BIT) /* 6-bit command selected */
7.1458 + #define SSI_CR1_MCOM_7BIT (0x6 << SSI_CR1_MCOM_BIT) /* 7-bit command selected */
7.1459 + #define SSI_CR1_MCOM_8BIT (0x7 << SSI_CR1_MCOM_BIT) /* 8-bit command selected */
7.1460 + #define SSI_CR1_MCOM_9BIT (0x8 << SSI_CR1_MCOM_BIT) /* 9-bit command selected */
7.1461 + #define SSI_CR1_MCOM_10BIT (0x9 << SSI_CR1_MCOM_BIT) /* 10-bit command selected */
7.1462 + #define SSI_CR1_MCOM_11BIT (0xA << SSI_CR1_MCOM_BIT) /* 11-bit command selected */
7.1463 + #define SSI_CR1_MCOM_12BIT (0xB << SSI_CR1_MCOM_BIT) /* 12-bit command selected */
7.1464 + #define SSI_CR1_MCOM_13BIT (0xC << SSI_CR1_MCOM_BIT) /* 13-bit command selected */
7.1465 + #define SSI_CR1_MCOM_14BIT (0xD << SSI_CR1_MCOM_BIT) /* 14-bit command selected */
7.1466 + #define SSI_CR1_MCOM_15BIT (0xE << SSI_CR1_MCOM_BIT) /* 15-bit command selected */
7.1467 + #define SSI_CR1_MCOM_16BIT (0xF << SSI_CR1_MCOM_BIT) /* 16-bit command selected */
7.1468 +#define SSI_CR1_RTRG_BIT 8
7.1469 +#define SSI_CR1_RTRG_MASK (0xf << SSI_CR1_RTRG_BIT)
7.1470 + #define SSI_CR1_RTRG_1 (0 << SSI_CR1_RTRG_BIT)
7.1471 + #define SSI_CR1_RTRG_8 (1 << SSI_CR1_RTRG_BIT)
7.1472 + #define SSI_CR1_RTRG_16 (2 << SSI_CR1_RTRG_BIT)
7.1473 + #define SSI_CR1_RTRG_24 (3 << SSI_CR1_RTRG_BIT)
7.1474 + #define SSI_CR1_RTRG_32 (4 << SSI_CR1_RTRG_BIT)
7.1475 + #define SSI_CR1_RTRG_40 (5 << SSI_CR1_RTRG_BIT)
7.1476 + #define SSI_CR1_RTRG_48 (6 << SSI_CR1_RTRG_BIT)
7.1477 + #define SSI_CR1_RTRG_56 (7 << SSI_CR1_RTRG_BIT)
7.1478 + #define SSI_CR1_RTRG_64 (8 << SSI_CR1_RTRG_BIT)
7.1479 + #define SSI_CR1_RTRG_72 (9 << SSI_CR1_RTRG_BIT)
7.1480 + #define SSI_CR1_RTRG_80 (10<< SSI_CR1_RTRG_BIT)
7.1481 + #define SSI_CR1_RTRG_88 (11<< SSI_CR1_RTRG_BIT)
7.1482 + #define SSI_CR1_RTRG_96 (12<< SSI_CR1_RTRG_BIT)
7.1483 + #define SSI_CR1_RTRG_104 (13<< SSI_CR1_RTRG_BIT)
7.1484 + #define SSI_CR1_RTRG_112 (14<< SSI_CR1_RTRG_BIT)
7.1485 + #define SSI_CR1_RTRG_120 (15<< SSI_CR1_RTRG_BIT)
7.1486 +#define SSI_CR1_FLEN_BIT 4
7.1487 +#define SSI_CR1_FLEN_MASK (0xf << SSI_CR1_FLEN_BIT)
7.1488 + #define SSI_CR1_FLEN_2BIT (0x0 << SSI_CR1_FLEN_BIT)
7.1489 + #define SSI_CR1_FLEN_3BIT (0x1 << SSI_CR1_FLEN_BIT)
7.1490 + #define SSI_CR1_FLEN_4BIT (0x2 << SSI_CR1_FLEN_BIT)
7.1491 + #define SSI_CR1_FLEN_5BIT (0x3 << SSI_CR1_FLEN_BIT)
7.1492 + #define SSI_CR1_FLEN_6BIT (0x4 << SSI_CR1_FLEN_BIT)
7.1493 + #define SSI_CR1_FLEN_7BIT (0x5 << SSI_CR1_FLEN_BIT)
7.1494 + #define SSI_CR1_FLEN_8BIT (0x6 << SSI_CR1_FLEN_BIT)
7.1495 + #define SSI_CR1_FLEN_9BIT (0x7 << SSI_CR1_FLEN_BIT)
7.1496 + #define SSI_CR1_FLEN_10BIT (0x8 << SSI_CR1_FLEN_BIT)
7.1497 + #define SSI_CR1_FLEN_11BIT (0x9 << SSI_CR1_FLEN_BIT)
7.1498 + #define SSI_CR1_FLEN_12BIT (0xA << SSI_CR1_FLEN_BIT)
7.1499 + #define SSI_CR1_FLEN_13BIT (0xB << SSI_CR1_FLEN_BIT)
7.1500 + #define SSI_CR1_FLEN_14BIT (0xC << SSI_CR1_FLEN_BIT)
7.1501 + #define SSI_CR1_FLEN_15BIT (0xD << SSI_CR1_FLEN_BIT)
7.1502 + #define SSI_CR1_FLEN_16BIT (0xE << SSI_CR1_FLEN_BIT)
7.1503 + #define SSI_CR1_FLEN_17BIT (0xF << SSI_CR1_FLEN_BIT)
7.1504 +#define SSI_CR1_PHA (1 << 1)
7.1505 +#define SSI_CR1_POL (1 << 0)
7.1506 +
7.1507 +/* SSI Status Register (SSI_SR) */
7.1508 +
7.1509 +#define SSI_SR_TFIFONUM_BIT 16
7.1510 +#define SSI_SR_TFIFONUM_MASK (0xff << SSI_SR_TFIFONUM_BIT)
7.1511 +#define SSI_SR_RFIFONUM_BIT 8
7.1512 +#define SSI_SR_RFIFONUM_MASK (0xff << SSI_SR_RFIFONUM_BIT)
7.1513 +#define SSI_SR_END (1 << 7)
7.1514 +#define SSI_SR_BUSY (1 << 6)
7.1515 +#define SSI_SR_TFF (1 << 5)
7.1516 +#define SSI_SR_RFE (1 << 4)
7.1517 +#define SSI_SR_TFHE (1 << 3)
7.1518 +#define SSI_SR_RFHF (1 << 2)
7.1519 +#define SSI_SR_UNDR (1 << 1)
7.1520 +#define SSI_SR_OVER (1 << 0)
7.1521 +
7.1522 +/* SSI Interval Time Control Register (SSI_ITR) */
7.1523 +
7.1524 +#define SSI_ITR_CNTCLK (1 << 15)
7.1525 +#define SSI_ITR_IVLTM_BIT 0
7.1526 +#define SSI_ITR_IVLTM_MASK (0x7fff << SSI_ITR_IVLTM_BIT)
7.1527 +
7.1528 +
7.1529 +/*************************************************************************
7.1530 + * MSC
7.1531 + *************************************************************************/
7.1532 +#define MSC_STRPCL (MSC_BASE + 0x000)
7.1533 +#define MSC_STAT (MSC_BASE + 0x004)
7.1534 +#define MSC_CLKRT (MSC_BASE + 0x008)
7.1535 +#define MSC_CMDAT (MSC_BASE + 0x00C)
7.1536 +#define MSC_RESTO (MSC_BASE + 0x010)
7.1537 +#define MSC_RDTO (MSC_BASE + 0x014)
7.1538 +#define MSC_BLKLEN (MSC_BASE + 0x018)
7.1539 +#define MSC_NOB (MSC_BASE + 0x01C)
7.1540 +#define MSC_SNOB (MSC_BASE + 0x020)
7.1541 +#define MSC_IMASK (MSC_BASE + 0x024)
7.1542 +#define MSC_IREG (MSC_BASE + 0x028)
7.1543 +#define MSC_CMD (MSC_BASE + 0x02C)
7.1544 +#define MSC_ARG (MSC_BASE + 0x030)
7.1545 +#define MSC_RES (MSC_BASE + 0x034)
7.1546 +#define MSC_RXFIFO (MSC_BASE + 0x038)
7.1547 +#define MSC_TXFIFO (MSC_BASE + 0x03C)
7.1548 +
7.1549 +#define REG_MSC_STRPCL REG16(MSC_STRPCL)
7.1550 +#define REG_MSC_STAT REG32(MSC_STAT)
7.1551 +#define REG_MSC_CLKRT REG16(MSC_CLKRT)
7.1552 +#define REG_MSC_CMDAT REG32(MSC_CMDAT)
7.1553 +#define REG_MSC_RESTO REG16(MSC_RESTO)
7.1554 +#define REG_MSC_RDTO REG16(MSC_RDTO)
7.1555 +#define REG_MSC_BLKLEN REG16(MSC_BLKLEN)
7.1556 +#define REG_MSC_NOB REG16(MSC_NOB)
7.1557 +#define REG_MSC_SNOB REG16(MSC_SNOB)
7.1558 +#define REG_MSC_IMASK REG16(MSC_IMASK)
7.1559 +#define REG_MSC_IREG REG16(MSC_IREG)
7.1560 +#define REG_MSC_CMD REG8(MSC_CMD)
7.1561 +#define REG_MSC_ARG REG32(MSC_ARG)
7.1562 +#define REG_MSC_RES REG16(MSC_RES)
7.1563 +#define REG_MSC_RXFIFO REG32(MSC_RXFIFO)
7.1564 +#define REG_MSC_TXFIFO REG32(MSC_TXFIFO)
7.1565 +
7.1566 +/* MSC Clock and Control Register (MSC_STRPCL) */
7.1567 +
7.1568 +#define MSC_STRPCL_EXIT_MULTIPLE (1 << 7)
7.1569 +#define MSC_STRPCL_EXIT_TRANSFER (1 << 6)
7.1570 +#define MSC_STRPCL_START_READWAIT (1 << 5)
7.1571 +#define MSC_STRPCL_STOP_READWAIT (1 << 4)
7.1572 +#define MSC_STRPCL_RESET (1 << 3)
7.1573 +#define MSC_STRPCL_START_OP (1 << 2)
7.1574 +#define MSC_STRPCL_CLOCK_CONTROL_BIT 0
7.1575 +#define MSC_STRPCL_CLOCK_CONTROL_MASK (0x3 << MSC_STRPCL_CLOCK_CONTROL_BIT)
7.1576 + #define MSC_STRPCL_CLOCK_CONTROL_STOP (0x1 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Stop MMC/SD clock */
7.1577 + #define MSC_STRPCL_CLOCK_CONTROL_START (0x2 << MSC_STRPCL_CLOCK_CONTROL_BIT) /* Start MMC/SD clock */
7.1578 +
7.1579 +/* MSC Status Register (MSC_STAT) */
7.1580 +
7.1581 +#define MSC_STAT_IS_RESETTING (1 << 15)
7.1582 +#define MSC_STAT_SDIO_INT_ACTIVE (1 << 14)
7.1583 +#define MSC_STAT_PRG_DONE (1 << 13)
7.1584 +#define MSC_STAT_DATA_TRAN_DONE (1 << 12)
7.1585 +#define MSC_STAT_END_CMD_RES (1 << 11)
7.1586 +#define MSC_STAT_DATA_FIFO_AFULL (1 << 10)
7.1587 +#define MSC_STAT_IS_READWAIT (1 << 9)
7.1588 +#define MSC_STAT_CLK_EN (1 << 8)
7.1589 +#define MSC_STAT_DATA_FIFO_FULL (1 << 7)
7.1590 +#define MSC_STAT_DATA_FIFO_EMPTY (1 << 6)
7.1591 +#define MSC_STAT_CRC_RES_ERR (1 << 5)
7.1592 +#define MSC_STAT_CRC_READ_ERROR (1 << 4)
7.1593 +#define MSC_STAT_CRC_WRITE_ERROR_BIT 2
7.1594 +#define MSC_STAT_CRC_WRITE_ERROR_MASK (0x3 << MSC_STAT_CRC_WRITE_ERROR_BIT)
7.1595 + #define MSC_STAT_CRC_WRITE_ERROR_NO (0 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No error on transmission of data */
7.1596 + #define MSC_STAT_CRC_WRITE_ERROR (1 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* Card observed erroneous transmission of data */
7.1597 + #define MSC_STAT_CRC_WRITE_ERROR_NOSTS (2 << MSC_STAT_CRC_WRITE_ERROR_BIT) /* No CRC status is sent back */
7.1598 +#define MSC_STAT_TIME_OUT_RES (1 << 1)
7.1599 +#define MSC_STAT_TIME_OUT_READ (1 << 0)
7.1600 +
7.1601 +/* MSC Bus Clock Control Register (MSC_CLKRT) */
7.1602 +
7.1603 +#define MSC_CLKRT_CLK_RATE_BIT 0
7.1604 +#define MSC_CLKRT_CLK_RATE_MASK (0x7 << MSC_CLKRT_CLK_RATE_BIT)
7.1605 + #define MSC_CLKRT_CLK_RATE_DIV_1 (0x0 << MSC_CLKRT_CLK_RATE_BIT) /* CLK_SRC */
7.1606 + #define MSC_CLKRT_CLK_RATE_DIV_2 (0x1 << MSC_CLKRT_CLK_RATE_BIT) /* 1/2 of CLK_SRC */
7.1607 + #define MSC_CLKRT_CLK_RATE_DIV_4 (0x2 << MSC_CLKRT_CLK_RATE_BIT) /* 1/4 of CLK_SRC */
7.1608 + #define MSC_CLKRT_CLK_RATE_DIV_8 (0x3 << MSC_CLKRT_CLK_RATE_BIT) /* 1/8 of CLK_SRC */
7.1609 + #define MSC_CLKRT_CLK_RATE_DIV_16 (0x4 << MSC_CLKRT_CLK_RATE_BIT) /* 1/16 of CLK_SRC */
7.1610 + #define MSC_CLKRT_CLK_RATE_DIV_32 (0x5 << MSC_CLKRT_CLK_RATE_BIT) /* 1/32 of CLK_SRC */
7.1611 + #define MSC_CLKRT_CLK_RATE_DIV_64 (0x6 << MSC_CLKRT_CLK_RATE_BIT) /* 1/64 of CLK_SRC */
7.1612 + #define MSC_CLKRT_CLK_RATE_DIV_128 (0x7 << MSC_CLKRT_CLK_RATE_BIT) /* 1/128 of CLK_SRC */
7.1613 +
7.1614 +/* MSC Command Sequence Control Register (MSC_CMDAT) */
7.1615 +
7.1616 +#define MSC_CMDAT_IO_ABORT (1 << 11)
7.1617 +#define MSC_CMDAT_BUS_WIDTH_BIT 9
7.1618 +#define MSC_CMDAT_BUS_WIDTH_MASK (0x3 << MSC_CMDAT_BUS_WIDTH_BIT)
7.1619 + #define MSC_CMDAT_BUS_WIDTH_1BIT (0x0 << MSC_CMDAT_BUS_WIDTH_BIT) /* 1-bit data bus */
7.1620 + #define MSC_CMDAT_BUS_WIDTH_4BIT (0x2 << MSC_CMDAT_BUS_WIDTH_BIT) /* 4-bit data bus */
7.1621 + #define CMDAT_BUS_WIDTH1 (0x0 << MSC_CMDAT_BUS_WIDTH_BIT)
7.1622 + #define CMDAT_BUS_WIDTH4 (0x2 << MSC_CMDAT_BUS_WIDTH_BIT)
7.1623 +#define MSC_CMDAT_DMA_EN (1 << 8)
7.1624 +#define MSC_CMDAT_INIT (1 << 7)
7.1625 +#define MSC_CMDAT_BUSY (1 << 6)
7.1626 +#define MSC_CMDAT_STREAM_BLOCK (1 << 5)
7.1627 +#define MSC_CMDAT_WRITE (1 << 4)
7.1628 +#define MSC_CMDAT_READ (0 << 4)
7.1629 +#define MSC_CMDAT_DATA_EN (1 << 3)
7.1630 +#define MSC_CMDAT_RESPONSE_BIT 0
7.1631 +#define MSC_CMDAT_RESPONSE_MASK (0x7 << MSC_CMDAT_RESPONSE_BIT)
7.1632 + #define MSC_CMDAT_RESPONSE_NONE (0x0 << MSC_CMDAT_RESPONSE_BIT) /* No response */
7.1633 + #define MSC_CMDAT_RESPONSE_R1 (0x1 << MSC_CMDAT_RESPONSE_BIT) /* Format R1 and R1b */
7.1634 + #define MSC_CMDAT_RESPONSE_R2 (0x2 << MSC_CMDAT_RESPONSE_BIT) /* Format R2 */
7.1635 + #define MSC_CMDAT_RESPONSE_R3 (0x3 << MSC_CMDAT_RESPONSE_BIT) /* Format R3 */
7.1636 + #define MSC_CMDAT_RESPONSE_R4 (0x4 << MSC_CMDAT_RESPONSE_BIT) /* Format R4 */
7.1637 + #define MSC_CMDAT_RESPONSE_R5 (0x5 << MSC_CMDAT_RESPONSE_BIT) /* Format R5 */
7.1638 + #define MSC_CMDAT_RESPONSE_R6 (0x6 << MSC_CMDAT_RESPONSE_BIT) /* Format R6 */
7.1639 +
7.1640 +#define CMDAT_DMA_EN (1 << 8)
7.1641 +#define CMDAT_INIT (1 << 7)
7.1642 +#define CMDAT_BUSY (1 << 6)
7.1643 +#define CMDAT_STREAM (1 << 5)
7.1644 +#define CMDAT_WRITE (1 << 4)
7.1645 +#define CMDAT_DATA_EN (1 << 3)
7.1646 +
7.1647 +/* MSC Interrupts Mask Register (MSC_IMASK) */
7.1648 +
7.1649 +#define MSC_IMASK_SDIO (1 << 7)
7.1650 +#define MSC_IMASK_TXFIFO_WR_REQ (1 << 6)
7.1651 +#define MSC_IMASK_RXFIFO_RD_REQ (1 << 5)
7.1652 +#define MSC_IMASK_END_CMD_RES (1 << 2)
7.1653 +#define MSC_IMASK_PRG_DONE (1 << 1)
7.1654 +#define MSC_IMASK_DATA_TRAN_DONE (1 << 0)
7.1655 +
7.1656 +
7.1657 +/* MSC Interrupts Status Register (MSC_IREG) */
7.1658 +
7.1659 +#define MSC_IREG_SDIO (1 << 7)
7.1660 +#define MSC_IREG_TXFIFO_WR_REQ (1 << 6)
7.1661 +#define MSC_IREG_RXFIFO_RD_REQ (1 << 5)
7.1662 +#define MSC_IREG_END_CMD_RES (1 << 2)
7.1663 +#define MSC_IREG_PRG_DONE (1 << 1)
7.1664 +#define MSC_IREG_DATA_TRAN_DONE (1 << 0)
7.1665 +
7.1666 +
7.1667 +/*************************************************************************
7.1668 + * EMC (External Memory Controller)
7.1669 + *************************************************************************/
7.1670 +#define EMC_BCR (EMC_BASE + 0x0) /* BCR */
7.1671 +
7.1672 +#define EMC_SMCR0 (EMC_BASE + 0x10) /* Static Memory Control Register 0 */
7.1673 +#define EMC_SMCR1 (EMC_BASE + 0x14) /* Static Memory Control Register 1 */
7.1674 +#define EMC_SMCR2 (EMC_BASE + 0x18) /* Static Memory Control Register 2 */
7.1675 +#define EMC_SMCR3 (EMC_BASE + 0x1c) /* Static Memory Control Register 3 */
7.1676 +#define EMC_SMCR4 (EMC_BASE + 0x20) /* Static Memory Control Register 4 */
7.1677 +#define EMC_SACR0 (EMC_BASE + 0x30) /* Static Memory Bank 0 Addr Config Reg */
7.1678 +#define EMC_SACR1 (EMC_BASE + 0x34) /* Static Memory Bank 1 Addr Config Reg */
7.1679 +#define EMC_SACR2 (EMC_BASE + 0x38) /* Static Memory Bank 2 Addr Config Reg */
7.1680 +#define EMC_SACR3 (EMC_BASE + 0x3c) /* Static Memory Bank 3 Addr Config Reg */
7.1681 +#define EMC_SACR4 (EMC_BASE + 0x40) /* Static Memory Bank 4 Addr Config Reg */
7.1682 +
7.1683 +#define EMC_NFCSR (EMC_BASE + 0x050) /* NAND Flash Control/Status Register */
7.1684 +#define EMC_NFECR (EMC_BASE + 0x100) /* NAND Flash ECC Control Register */
7.1685 +#define EMC_NFECC (EMC_BASE + 0x104) /* NAND Flash ECC Data Register */
7.1686 +#define EMC_NFPAR0 (EMC_BASE + 0x108) /* NAND Flash RS Parity 0 Register */
7.1687 +#define EMC_NFPAR1 (EMC_BASE + 0x10c) /* NAND Flash RS Parity 1 Register */
7.1688 +#define EMC_NFPAR2 (EMC_BASE + 0x110) /* NAND Flash RS Parity 2 Register */
7.1689 +#define EMC_NFINTS (EMC_BASE + 0x114) /* NAND Flash Interrupt Status Register */
7.1690 +#define EMC_NFINTE (EMC_BASE + 0x118) /* NAND Flash Interrupt Enable Register */
7.1691 +#define EMC_NFERR0 (EMC_BASE + 0x11c) /* NAND Flash RS Error Report 0 Register */
7.1692 +#define EMC_NFERR1 (EMC_BASE + 0x120) /* NAND Flash RS Error Report 1 Register */
7.1693 +#define EMC_NFERR2 (EMC_BASE + 0x124) /* NAND Flash RS Error Report 2 Register */
7.1694 +#define EMC_NFERR3 (EMC_BASE + 0x128) /* NAND Flash RS Error Report 3 Register */
7.1695 +
7.1696 +#define EMC_DMCR (EMC_BASE + 0x80) /* DRAM Control Register */
7.1697 +#define EMC_RTCSR (EMC_BASE + 0x84) /* Refresh Time Control/Status Register */
7.1698 +#define EMC_RTCNT (EMC_BASE + 0x88) /* Refresh Timer Counter */
7.1699 +#define EMC_RTCOR (EMC_BASE + 0x8c) /* Refresh Time Constant Register */
7.1700 +#define EMC_DMAR0 (EMC_BASE + 0x90) /* SDRAM Bank 0 Addr Config Register */
7.1701 +#define EMC_SDMR0 (EMC_BASE + 0xa000) /* Mode Register of SDRAM bank 0 */
7.1702 +
7.1703 +#define REG_EMC_BCR REG32(EMC_BCR)
7.1704 +
7.1705 +#define REG_EMC_SMCR0 REG32(EMC_SMCR0)
7.1706 +#define REG_EMC_SMCR1 REG32(EMC_SMCR1)
7.1707 +#define REG_EMC_SMCR2 REG32(EMC_SMCR2)
7.1708 +#define REG_EMC_SMCR3 REG32(EMC_SMCR3)
7.1709 +#define REG_EMC_SMCR4 REG32(EMC_SMCR4)
7.1710 +#define REG_EMC_SACR0 REG32(EMC_SACR0)
7.1711 +#define REG_EMC_SACR1 REG32(EMC_SACR1)
7.1712 +#define REG_EMC_SACR2 REG32(EMC_SACR2)
7.1713 +#define REG_EMC_SACR3 REG32(EMC_SACR3)
7.1714 +#define REG_EMC_SACR4 REG32(EMC_SACR4)
7.1715 +
7.1716 +#define REG_EMC_NFCSR REG32(EMC_NFCSR)
7.1717 +#define REG_EMC_NFECR REG32(EMC_NFECR)
7.1718 +#define REG_EMC_NFECC REG32(EMC_NFECC)
7.1719 +#define REG_EMC_NFPAR0 REG32(EMC_NFPAR0)
7.1720 +#define REG_EMC_NFPAR1 REG32(EMC_NFPAR1)
7.1721 +#define REG_EMC_NFPAR2 REG32(EMC_NFPAR2)
7.1722 +#define REG_EMC_NFINTS REG32(EMC_NFINTS)
7.1723 +#define REG_EMC_NFINTE REG32(EMC_NFINTE)
7.1724 +#define REG_EMC_NFERR0 REG32(EMC_NFERR0)
7.1725 +#define REG_EMC_NFERR1 REG32(EMC_NFERR1)
7.1726 +#define REG_EMC_NFERR2 REG32(EMC_NFERR2)
7.1727 +#define REG_EMC_NFERR3 REG32(EMC_NFERR3)
7.1728 +
7.1729 +#define REG_EMC_DMCR REG32(EMC_DMCR)
7.1730 +#define REG_EMC_RTCSR REG16(EMC_RTCSR)
7.1731 +#define REG_EMC_RTCNT REG16(EMC_RTCNT)
7.1732 +#define REG_EMC_RTCOR REG16(EMC_RTCOR)
7.1733 +#define REG_EMC_DMAR0 REG32(EMC_DMAR0)
7.1734 +
7.1735 +/* Static Memory Control Register */
7.1736 +#define EMC_SMCR_STRV_BIT 24
7.1737 +#define EMC_SMCR_STRV_MASK (0x0f << EMC_SMCR_STRV_BIT)
7.1738 +#define EMC_SMCR_TAW_BIT 20
7.1739 +#define EMC_SMCR_TAW_MASK (0x0f << EMC_SMCR_TAW_BIT)
7.1740 +#define EMC_SMCR_TBP_BIT 16
7.1741 +#define EMC_SMCR_TBP_MASK (0x0f << EMC_SMCR_TBP_BIT)
7.1742 +#define EMC_SMCR_TAH_BIT 12
7.1743 +#define EMC_SMCR_TAH_MASK (0x07 << EMC_SMCR_TAH_BIT)
7.1744 +#define EMC_SMCR_TAS_BIT 8
7.1745 +#define EMC_SMCR_TAS_MASK (0x07 << EMC_SMCR_TAS_BIT)
7.1746 +#define EMC_SMCR_BW_BIT 6
7.1747 +#define EMC_SMCR_BW_MASK (0x03 << EMC_SMCR_BW_BIT)
7.1748 + #define EMC_SMCR_BW_8BIT (0 << EMC_SMCR_BW_BIT)
7.1749 + #define EMC_SMCR_BW_16BIT (1 << EMC_SMCR_BW_BIT)
7.1750 + #define EMC_SMCR_BW_32BIT (2 << EMC_SMCR_BW_BIT)
7.1751 +#define EMC_SMCR_BCM (1 << 3)
7.1752 +#define EMC_SMCR_BL_BIT 1
7.1753 +#define EMC_SMCR_BL_MASK (0x03 << EMC_SMCR_BL_BIT)
7.1754 + #define EMC_SMCR_BL_4 (0 << EMC_SMCR_BL_BIT)
7.1755 + #define EMC_SMCR_BL_8 (1 << EMC_SMCR_BL_BIT)
7.1756 + #define EMC_SMCR_BL_16 (2 << EMC_SMCR_BL_BIT)
7.1757 + #define EMC_SMCR_BL_32 (3 << EMC_SMCR_BL_BIT)
7.1758 +#define EMC_SMCR_SMT (1 << 0)
7.1759 +
7.1760 +/* Static Memory Bank Addr Config Reg */
7.1761 +#define EMC_SACR_BASE_BIT 8
7.1762 +#define EMC_SACR_BASE_MASK (0xff << EMC_SACR_BASE_BIT)
7.1763 +#define EMC_SACR_MASK_BIT 0
7.1764 +#define EMC_SACR_MASK_MASK (0xff << EMC_SACR_MASK_BIT)
7.1765 +
7.1766 +/* NAND Flash Control/Status Register */
7.1767 +#define EMC_NFCSR_NFCE4 (1 << 7) /* NAND Flash Enable */
7.1768 +#define EMC_NFCSR_NFE4 (1 << 6) /* NAND Flash FCE# Assertion Enable */
7.1769 +#define EMC_NFCSR_NFCE3 (1 << 5)
7.1770 +#define EMC_NFCSR_NFE3 (1 << 4)
7.1771 +#define EMC_NFCSR_NFCE2 (1 << 3)
7.1772 +#define EMC_NFCSR_NFE2 (1 << 2)
7.1773 +#define EMC_NFCSR_NFCE1 (1 << 1)
7.1774 +#define EMC_NFCSR_NFE1 (1 << 0)
7.1775 +
7.1776 +/* NAND Flash ECC Control Register */
7.1777 +#define EMC_NFECR_PRDY (1 << 4) /* Parity Ready */
7.1778 +#define EMC_NFECR_RS_DECODING (0 << 3) /* RS is in decoding phase */
7.1779 +#define EMC_NFECR_RS_ENCODING (1 << 3) /* RS is in encoding phase */
7.1780 +#define EMC_NFECR_HAMMING (0 << 2) /* Select HAMMING Correction Algorithm */
7.1781 +#define EMC_NFECR_RS (1 << 2) /* Select RS Correction Algorithm */
7.1782 +#define EMC_NFECR_ERST (1 << 1) /* ECC Reset */
7.1783 +#define EMC_NFECR_ECCE (1 << 0) /* ECC Enable */
7.1784 +
7.1785 +/* NAND Flash ECC Data Register */
7.1786 +#define EMC_NFECC_ECC2_BIT 16
7.1787 +#define EMC_NFECC_ECC2_MASK (0xff << EMC_NFECC_ECC2_BIT)
7.1788 +#define EMC_NFECC_ECC1_BIT 8
7.1789 +#define EMC_NFECC_ECC1_MASK (0xff << EMC_NFECC_ECC1_BIT)
7.1790 +#define EMC_NFECC_ECC0_BIT 0
7.1791 +#define EMC_NFECC_ECC0_MASK (0xff << EMC_NFECC_ECC0_BIT)
7.1792 +
7.1793 +/* NAND Flash Interrupt Status Register */
7.1794 +#define EMC_NFINTS_ERRCNT_BIT 29 /* Error Count */
7.1795 +#define EMC_NFINTS_ERRCNT_MASK (0x7 << EMC_NFINTS_ERRCNT_BIT)
7.1796 +#define EMC_NFINTS_PADF (1 << 4) /* Padding Finished */
7.1797 +#define EMC_NFINTS_DECF (1 << 3) /* Decoding Finished */
7.1798 +#define EMC_NFINTS_ENCF (1 << 2) /* Encoding Finished */
7.1799 +#define EMC_NFINTS_UNCOR (1 << 1) /* Uncorrectable Error Occurred */
7.1800 +#define EMC_NFINTS_ERR (1 << 0) /* Error Occurred */
7.1801 +
7.1802 +/* NAND Flash Interrupt Enable Register */
7.1803 +#define EMC_NFINTE_PADFE (1 << 4) /* Padding Finished Interrupt Enable */
7.1804 +#define EMC_NFINTE_DECFE (1 << 3) /* Decoding Finished Interrupt Enable */
7.1805 +#define EMC_NFINTE_ENCFE (1 << 2) /* Encoding Finished Interrupt Enable */
7.1806 +#define EMC_NFINTE_UNCORE (1 << 1) /* Uncorrectable Error Occurred Intr Enable */
7.1807 +#define EMC_NFINTE_ERRE (1 << 0) /* Error Occurred Interrupt */
7.1808 +
7.1809 +/* NAND Flash RS Error Report Register */
7.1810 +#define EMC_NFERR_INDEX_BIT 16 /* Error Symbol Index */
7.1811 +#define EMC_NFERR_INDEX_MASK (0x1ff << EMC_NFERR_INDEX_BIT)
7.1812 +#define EMC_NFERR_MASK_BIT 0 /* Error Symbol Value */
7.1813 +#define EMC_NFERR_MASK_MASK (0x1ff << EMC_NFERR_MASK_BIT)
7.1814 +
7.1815 +
7.1816 +/* DRAM Control Register */
7.1817 +#define EMC_DMCR_BW_BIT 31
7.1818 +#define EMC_DMCR_BW (1 << EMC_DMCR_BW_BIT)
7.1819 +#define EMC_DMCR_CA_BIT 26
7.1820 +#define EMC_DMCR_CA_MASK (0x07 << EMC_DMCR_CA_BIT)
7.1821 + #define EMC_DMCR_CA_8 (0 << EMC_DMCR_CA_BIT)
7.1822 + #define EMC_DMCR_CA_9 (1 << EMC_DMCR_CA_BIT)
7.1823 + #define EMC_DMCR_CA_10 (2 << EMC_DMCR_CA_BIT)
7.1824 + #define EMC_DMCR_CA_11 (3 << EMC_DMCR_CA_BIT)
7.1825 + #define EMC_DMCR_CA_12 (4 << EMC_DMCR_CA_BIT)
7.1826 +#define EMC_DMCR_RMODE (1 << 25)
7.1827 +#define EMC_DMCR_RFSH (1 << 24)
7.1828 +#define EMC_DMCR_MRSET (1 << 23)
7.1829 +#define EMC_DMCR_RA_BIT 20
7.1830 +#define EMC_DMCR_RA_MASK (0x03 << EMC_DMCR_RA_BIT)
7.1831 + #define EMC_DMCR_RA_11 (0 << EMC_DMCR_RA_BIT)
7.1832 + #define EMC_DMCR_RA_12 (1 << EMC_DMCR_RA_BIT)
7.1833 + #define EMC_DMCR_RA_13 (2 << EMC_DMCR_RA_BIT)
7.1834 +#define EMC_DMCR_BA_BIT 19
7.1835 +#define EMC_DMCR_BA (1 << EMC_DMCR_BA_BIT)
7.1836 +#define EMC_DMCR_PDM (1 << 18)
7.1837 +#define EMC_DMCR_EPIN (1 << 17)
7.1838 +#define EMC_DMCR_TRAS_BIT 13
7.1839 +#define EMC_DMCR_TRAS_MASK (0x07 << EMC_DMCR_TRAS_BIT)
7.1840 +#define EMC_DMCR_RCD_BIT 11
7.1841 +#define EMC_DMCR_RCD_MASK (0x03 << EMC_DMCR_RCD_BIT)
7.1842 +#define EMC_DMCR_TPC_BIT 8
7.1843 +#define EMC_DMCR_TPC_MASK (0x07 << EMC_DMCR_TPC_BIT)
7.1844 +#define EMC_DMCR_TRWL_BIT 5
7.1845 +#define EMC_DMCR_TRWL_MASK (0x03 << EMC_DMCR_TRWL_BIT)
7.1846 +#define EMC_DMCR_TRC_BIT 2
7.1847 +#define EMC_DMCR_TRC_MASK (0x07 << EMC_DMCR_TRC_BIT)
7.1848 +#define EMC_DMCR_TCL_BIT 0
7.1849 +#define EMC_DMCR_TCL_MASK (0x03 << EMC_DMCR_TCL_BIT)
7.1850 +
7.1851 +/* Refresh Time Control/Status Register */
7.1852 +#define EMC_RTCSR_CMF (1 << 7)
7.1853 +#define EMC_RTCSR_CKS_BIT 0
7.1854 +#define EMC_RTCSR_CKS_MASK (0x07 << EMC_RTCSR_CKS_BIT)
7.1855 + #define EMC_RTCSR_CKS_DISABLE (0 << EMC_RTCSR_CKS_BIT)
7.1856 + #define EMC_RTCSR_CKS_4 (1 << EMC_RTCSR_CKS_BIT)
7.1857 + #define EMC_RTCSR_CKS_16 (2 << EMC_RTCSR_CKS_BIT)
7.1858 + #define EMC_RTCSR_CKS_64 (3 << EMC_RTCSR_CKS_BIT)
7.1859 + #define EMC_RTCSR_CKS_256 (4 << EMC_RTCSR_CKS_BIT)
7.1860 + #define EMC_RTCSR_CKS_1024 (5 << EMC_RTCSR_CKS_BIT)
7.1861 + #define EMC_RTCSR_CKS_2048 (6 << EMC_RTCSR_CKS_BIT)
7.1862 + #define EMC_RTCSR_CKS_4096 (7 << EMC_RTCSR_CKS_BIT)
7.1863 +
7.1864 +/* SDRAM Bank Address Configuration Register */
7.1865 +#define EMC_DMAR_BASE_BIT 8
7.1866 +#define EMC_DMAR_BASE_MASK (0xff << EMC_DMAR_BASE_BIT)
7.1867 +#define EMC_DMAR_MASK_BIT 0
7.1868 +#define EMC_DMAR_MASK_MASK (0xff << EMC_DMAR_MASK_BIT)
7.1869 +
7.1870 +/* Mode Register of SDRAM bank 0 */
7.1871 +#define EMC_SDMR_BM (1 << 9) /* Write Burst Mode */
7.1872 +#define EMC_SDMR_OM_BIT 7 /* Operating Mode */
7.1873 +#define EMC_SDMR_OM_MASK (3 << EMC_SDMR_OM_BIT)
7.1874 + #define EMC_SDMR_OM_NORMAL (0 << EMC_SDMR_OM_BIT)
7.1875 +#define EMC_SDMR_CAS_BIT 4 /* CAS Latency */
7.1876 +#define EMC_SDMR_CAS_MASK (7 << EMC_SDMR_CAS_BIT)
7.1877 + #define EMC_SDMR_CAS_1 (1 << EMC_SDMR_CAS_BIT)
7.1878 + #define EMC_SDMR_CAS_2 (2 << EMC_SDMR_CAS_BIT)
7.1879 + #define EMC_SDMR_CAS_3 (3 << EMC_SDMR_CAS_BIT)
7.1880 +#define EMC_SDMR_BT_BIT 3 /* Burst Type */
7.1881 +#define EMC_SDMR_BT_MASK (1 << EMC_SDMR_BT_BIT)
7.1882 + #define EMC_SDMR_BT_SEQ (0 << EMC_SDMR_BT_BIT) /* Sequential */
7.1883 + #define EMC_SDMR_BT_INT (1 << EMC_SDMR_BT_BIT) /* Interleave */
7.1884 +#define EMC_SDMR_BL_BIT 0 /* Burst Length */
7.1885 +#define EMC_SDMR_BL_MASK (7 << EMC_SDMR_BL_BIT)
7.1886 + #define EMC_SDMR_BL_1 (0 << EMC_SDMR_BL_BIT)
7.1887 + #define EMC_SDMR_BL_2 (1 << EMC_SDMR_BL_BIT)
7.1888 + #define EMC_SDMR_BL_4 (2 << EMC_SDMR_BL_BIT)
7.1889 + #define EMC_SDMR_BL_8 (3 << EMC_SDMR_BL_BIT)
7.1890 +
7.1891 +#define EMC_SDMR_CAS2_16BIT \
7.1892 + (EMC_SDMR_CAS_2 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_2)
7.1893 +#define EMC_SDMR_CAS2_32BIT \
7.1894 + (EMC_SDMR_CAS_2 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_4)
7.1895 +#define EMC_SDMR_CAS3_16BIT \
7.1896 + (EMC_SDMR_CAS_3 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_2)
7.1897 +#define EMC_SDMR_CAS3_32BIT \
7.1898 + (EMC_SDMR_CAS_3 | EMC_SDMR_BT_SEQ | EMC_SDMR_BL_4)
7.1899 +
7.1900 +
7.1901 +/*************************************************************************
7.1902 + * CIM
7.1903 + *************************************************************************/
7.1904 +#define CIM_CFG (CIM_BASE + 0x0000)
7.1905 +#define CIM_CTRL (CIM_BASE + 0x0004)
7.1906 +#define CIM_STATE (CIM_BASE + 0x0008)
7.1907 +#define CIM_IID (CIM_BASE + 0x000C)
7.1908 +#define CIM_RXFIFO (CIM_BASE + 0x0010)
7.1909 +#define CIM_DA (CIM_BASE + 0x0020)
7.1910 +#define CIM_FA (CIM_BASE + 0x0024)
7.1911 +#define CIM_FID (CIM_BASE + 0x0028)
7.1912 +#define CIM_CMD (CIM_BASE + 0x002C)
7.1913 +
7.1914 +#define REG_CIM_CFG REG32(CIM_CFG)
7.1915 +#define REG_CIM_CTRL REG32(CIM_CTRL)
7.1916 +#define REG_CIM_STATE REG32(CIM_STATE)
7.1917 +#define REG_CIM_IID REG32(CIM_IID)
7.1918 +#define REG_CIM_RXFIFO REG32(CIM_RXFIFO)
7.1919 +#define REG_CIM_DA REG32(CIM_DA)
7.1920 +#define REG_CIM_FA REG32(CIM_FA)
7.1921 +#define REG_CIM_FID REG32(CIM_FID)
7.1922 +#define REG_CIM_CMD REG32(CIM_CMD)
7.1923 +
7.1924 +/* CIM Configuration Register (CIM_CFG) */
7.1925 +
7.1926 +#define CIM_CFG_INV_DAT (1 << 15)
7.1927 +#define CIM_CFG_VSP (1 << 14)
7.1928 +#define CIM_CFG_HSP (1 << 13)
7.1929 +#define CIM_CFG_PCP (1 << 12)
7.1930 +#define CIM_CFG_DUMMY_ZERO (1 << 9)
7.1931 +#define CIM_CFG_EXT_VSYNC (1 << 8)
7.1932 +#define CIM_CFG_PACK_BIT 4
7.1933 +#define CIM_CFG_PACK_MASK (0x7 << CIM_CFG_PACK_BIT)
7.1934 + #define CIM_CFG_PACK_0 (0 << CIM_CFG_PACK_BIT)
7.1935 + #define CIM_CFG_PACK_1 (1 << CIM_CFG_PACK_BIT)
7.1936 + #define CIM_CFG_PACK_2 (2 << CIM_CFG_PACK_BIT)
7.1937 + #define CIM_CFG_PACK_3 (3 << CIM_CFG_PACK_BIT)
7.1938 + #define CIM_CFG_PACK_4 (4 << CIM_CFG_PACK_BIT)
7.1939 + #define CIM_CFG_PACK_5 (5 << CIM_CFG_PACK_BIT)
7.1940 + #define CIM_CFG_PACK_6 (6 << CIM_CFG_PACK_BIT)
7.1941 + #define CIM_CFG_PACK_7 (7 << CIM_CFG_PACK_BIT)
7.1942 +#define CIM_CFG_DSM_BIT 0
7.1943 +#define CIM_CFG_DSM_MASK (0x3 << CIM_CFG_DSM_BIT)
7.1944 + #define CIM_CFG_DSM_CPM (0 << CIM_CFG_DSM_BIT) /* CCIR656 Progressive Mode */
7.1945 + #define CIM_CFG_DSM_CIM (1 << CIM_CFG_DSM_BIT) /* CCIR656 Interlace Mode */
7.1946 + #define CIM_CFG_DSM_GCM (2 << CIM_CFG_DSM_BIT) /* Gated Clock Mode */
7.1947 + #define CIM_CFG_DSM_NGCM (3 << CIM_CFG_DSM_BIT) /* Non-Gated Clock Mode */
7.1948 +
7.1949 +/* CIM Control Register (CIM_CTRL) */
7.1950 +
7.1951 +#define CIM_CTRL_MCLKDIV_BIT 24
7.1952 +#define CIM_CTRL_MCLKDIV_MASK (0xff << CIM_CTRL_MCLKDIV_BIT)
7.1953 +#define CIM_CTRL_FRC_BIT 16
7.1954 +#define CIM_CTRL_FRC_MASK (0xf << CIM_CTRL_FRC_BIT)
7.1955 + #define CIM_CTRL_FRC_1 (0x0 << CIM_CTRL_FRC_BIT) /* Sample every frame */
7.1956 + #define CIM_CTRL_FRC_2 (0x1 << CIM_CTRL_FRC_BIT) /* Sample 1/2 frame */
7.1957 + #define CIM_CTRL_FRC_3 (0x2 << CIM_CTRL_FRC_BIT) /* Sample 1/3 frame */
7.1958 + #define CIM_CTRL_FRC_4 (0x3 << CIM_CTRL_FRC_BIT) /* Sample 1/4 frame */
7.1959 + #define CIM_CTRL_FRC_5 (0x4 << CIM_CTRL_FRC_BIT) /* Sample 1/5 frame */
7.1960 + #define CIM_CTRL_FRC_6 (0x5 << CIM_CTRL_FRC_BIT) /* Sample 1/6 frame */
7.1961 + #define CIM_CTRL_FRC_7 (0x6 << CIM_CTRL_FRC_BIT) /* Sample 1/7 frame */
7.1962 + #define CIM_CTRL_FRC_8 (0x7 << CIM_CTRL_FRC_BIT) /* Sample 1/8 frame */
7.1963 + #define CIM_CTRL_FRC_9 (0x8 << CIM_CTRL_FRC_BIT) /* Sample 1/9 frame */
7.1964 + #define CIM_CTRL_FRC_10 (0x9 << CIM_CTRL_FRC_BIT) /* Sample 1/10 frame */
7.1965 + #define CIM_CTRL_FRC_11 (0xA << CIM_CTRL_FRC_BIT) /* Sample 1/11 frame */
7.1966 + #define CIM_CTRL_FRC_12 (0xB << CIM_CTRL_FRC_BIT) /* Sample 1/12 frame */
7.1967 + #define CIM_CTRL_FRC_13 (0xC << CIM_CTRL_FRC_BIT) /* Sample 1/13 frame */
7.1968 + #define CIM_CTRL_FRC_14 (0xD << CIM_CTRL_FRC_BIT) /* Sample 1/14 frame */
7.1969 + #define CIM_CTRL_FRC_15 (0xE << CIM_CTRL_FRC_BIT) /* Sample 1/15 frame */
7.1970 + #define CIM_CTRL_FRC_16 (0xF << CIM_CTRL_FRC_BIT) /* Sample 1/16 frame */
7.1971 +#define CIM_CTRL_VDDM (1 << 13)
7.1972 +#define CIM_CTRL_DMA_SOFM (1 << 12)
7.1973 +#define CIM_CTRL_DMA_EOFM (1 << 11)
7.1974 +#define CIM_CTRL_DMA_STOPM (1 << 10)
7.1975 +#define CIM_CTRL_RXF_TRIGM (1 << 9)
7.1976 +#define CIM_CTRL_RXF_OFM (1 << 8)
7.1977 +#define CIM_CTRL_RXF_TRIG_BIT 4
7.1978 +#define CIM_CTRL_RXF_TRIG_MASK (0x7 << CIM_CTRL_RXF_TRIG_BIT)
7.1979 + #define CIM_CTRL_RXF_TRIG_4 (0 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 4 */
7.1980 + #define CIM_CTRL_RXF_TRIG_8 (1 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 8 */
7.1981 + #define CIM_CTRL_RXF_TRIG_12 (2 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 12 */
7.1982 + #define CIM_CTRL_RXF_TRIG_16 (3 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 16 */
7.1983 + #define CIM_CTRL_RXF_TRIG_20 (4 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 20 */
7.1984 + #define CIM_CTRL_RXF_TRIG_24 (5 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 24 */
7.1985 + #define CIM_CTRL_RXF_TRIG_28 (6 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 28 */
7.1986 + #define CIM_CTRL_RXF_TRIG_32 (7 << CIM_CTRL_RXF_TRIG_BIT) /* RXFIFO Trigger Value is 32 */
7.1987 +#define CIM_CTRL_DMA_EN (1 << 2)
7.1988 +#define CIM_CTRL_RXF_RST (1 << 1)
7.1989 +#define CIM_CTRL_ENA (1 << 0)
7.1990 +
7.1991 +/* CIM State Register (CIM_STATE) */
7.1992 +
7.1993 +#define CIM_STATE_DMA_SOF (1 << 6)
7.1994 +#define CIM_STATE_DMA_EOF (1 << 5)
7.1995 +#define CIM_STATE_DMA_STOP (1 << 4)
7.1996 +#define CIM_STATE_RXF_OF (1 << 3)
7.1997 +#define CIM_STATE_RXF_TRIG (1 << 2)
7.1998 +#define CIM_STATE_RXF_EMPTY (1 << 1)
7.1999 +#define CIM_STATE_VDD (1 << 0)
7.2000 +
7.2001 +/* CIM DMA Command Register (CIM_CMD) */
7.2002 +
7.2003 +#define CIM_CMD_SOFINT (1 << 31)
7.2004 +#define CIM_CMD_EOFINT (1 << 30)
7.2005 +#define CIM_CMD_STOP (1 << 28)
7.2006 +#define CIM_CMD_LEN_BIT 0
7.2007 +#define CIM_CMD_LEN_MASK (0xffffff << CIM_CMD_LEN_BIT)
7.2008 +
7.2009 +
7.2010 +/*************************************************************************
7.2011 + * SADC (Smart A/D Controller)
7.2012 + *************************************************************************/
7.2013 +
7.2014 +#define SADC_ENA (SADC_BASE + 0x00) /* ADC Enable Register */
7.2015 +#define SADC_CFG (SADC_BASE + 0x04) /* ADC Configure Register */
7.2016 +#define SADC_CTRL (SADC_BASE + 0x08) /* ADC Control Register */
7.2017 +#define SADC_STATE (SADC_BASE + 0x0C) /* ADC Status Register*/
7.2018 +#define SADC_SAMETIME (SADC_BASE + 0x10) /* ADC Same Point Time Register */
7.2019 +#define SADC_WAITTIME (SADC_BASE + 0x14) /* ADC Wait Time Register */
7.2020 +#define SADC_TSDAT (SADC_BASE + 0x18) /* ADC Touch Screen Data Register */
7.2021 +#define SADC_BATDAT (SADC_BASE + 0x1C) /* ADC PBAT Data Register */
7.2022 +#define SADC_SADDAT (SADC_BASE + 0x20) /* ADC SADCIN Data Register */
7.2023 +
7.2024 +#define REG_SADC_ENA REG8(SADC_ENA)
7.2025 +#define REG_SADC_CFG REG32(SADC_CFG)
7.2026 +#define REG_SADC_CTRL REG8(SADC_CTRL)
7.2027 +#define REG_SADC_STATE REG8(SADC_STATE)
7.2028 +#define REG_SADC_SAMETIME REG16(SADC_SAMETIME)
7.2029 +#define REG_SADC_WAITTIME REG16(SADC_WAITTIME)
7.2030 +#define REG_SADC_TSDAT REG32(SADC_TSDAT)
7.2031 +#define REG_SADC_BATDAT REG16(SADC_BATDAT)
7.2032 +#define REG_SADC_SADDAT REG16(SADC_SADDAT)
7.2033 +
7.2034 +/* ADC Enable Register */
7.2035 +#define SADC_ENA_ADEN (1 << 7) /* Touch Screen Enable */
7.2036 +#define SADC_ENA_TSEN (1 << 2) /* Touch Screen Enable */
7.2037 +#define SADC_ENA_PBATEN (1 << 1) /* PBAT Enable */
7.2038 +#define SADC_ENA_SADCINEN (1 << 0) /* SADCIN Enable */
7.2039 +
7.2040 +/* ADC Configure Register */
7.2041 +#define SADC_CFG_CLKOUT_NUM_BIT 16
7.2042 +#define SADC_CFG_CLKOUT_NUM_MASK (0x7 << SADC_CFG_CLKOUT_NUM_BIT)
7.2043 +#define SADC_CFG_TS_DMA (1 << 15) /* Touch Screen DMA Enable */
7.2044 +#define SADC_CFG_XYZ_BIT 13 /* XYZ selection */
7.2045 +#define SADC_CFG_XYZ_MASK (0x3 << SADC_CFG_XYZ_BIT)
7.2046 + #define SADC_CFG_XY (0 << SADC_CFG_XYZ_BIT)
7.2047 + #define SADC_CFG_XYZ (1 << SADC_CFG_XYZ_BIT)
7.2048 + #define SADC_CFG_XYZ1Z2 (2 << SADC_CFG_XYZ_BIT)
7.2049 +#define SADC_CFG_SNUM_BIT 10 /* Sample Number */
7.2050 +#define SADC_CFG_SNUM_MASK (0x7 << SADC_CFG_SNUM_BIT)
7.2051 + #define SADC_CFG_SNUM_1 (0x0 << SADC_CFG_SNUM_BIT)
7.2052 + #define SADC_CFG_SNUM_2 (0x1 << SADC_CFG_SNUM_BIT)
7.2053 + #define SADC_CFG_SNUM_3 (0x2 << SADC_CFG_SNUM_BIT)
7.2054 + #define SADC_CFG_SNUM_4 (0x3 << SADC_CFG_SNUM_BIT)
7.2055 + #define SADC_CFG_SNUM_5 (0x4 << SADC_CFG_SNUM_BIT)
7.2056 + #define SADC_CFG_SNUM_6 (0x5 << SADC_CFG_SNUM_BIT)
7.2057 + #define SADC_CFG_SNUM_8 (0x6 << SADC_CFG_SNUM_BIT)
7.2058 + #define SADC_CFG_SNUM_9 (0x7 << SADC_CFG_SNUM_BIT)
7.2059 +#define SADC_CFG_CLKDIV_BIT 5 /* AD Converter frequency clock divider */
7.2060 +#define SADC_CFG_CLKDIV_MASK (0x1f << SADC_CFG_CLKDIV_BIT)
7.2061 +#define SADC_CFG_PBAT_HIGH (0 << 4) /* PBAT >= 2.5V */
7.2062 +#define SADC_CFG_PBAT_LOW (1 << 4) /* PBAT < 2.5V */
7.2063 +#define SADC_CFG_CMD_BIT 0 /* ADC Command */
7.2064 +#define SADC_CFG_CMD_MASK (0xf << SADC_CFG_CMD_BIT)
7.2065 + #define SADC_CFG_CMD_X_SE (0x0 << SADC_CFG_CMD_BIT) /* X Single-End */
7.2066 + #define SADC_CFG_CMD_Y_SE (0x1 << SADC_CFG_CMD_BIT) /* Y Single-End */
7.2067 + #define SADC_CFG_CMD_X_DIFF (0x2 << SADC_CFG_CMD_BIT) /* X Differential */
7.2068 + #define SADC_CFG_CMD_Y_DIFF (0x3 << SADC_CFG_CMD_BIT) /* Y Differential */
7.2069 + #define SADC_CFG_CMD_Z1_DIFF (0x4 << SADC_CFG_CMD_BIT) /* Z1 Differential */
7.2070 + #define SADC_CFG_CMD_Z2_DIFF (0x5 << SADC_CFG_CMD_BIT) /* Z2 Differential */
7.2071 + #define SADC_CFG_CMD_Z3_DIFF (0x6 << SADC_CFG_CMD_BIT) /* Z3 Differential */
7.2072 + #define SADC_CFG_CMD_Z4_DIFF (0x7 << SADC_CFG_CMD_BIT) /* Z4 Differential */
7.2073 + #define SADC_CFG_CMD_TP_SE (0x8 << SADC_CFG_CMD_BIT) /* Touch Pressure */
7.2074 + #define SADC_CFG_CMD_PBATH_SE (0x9 << SADC_CFG_CMD_BIT) /* PBAT >= 2.5V */
7.2075 + #define SADC_CFG_CMD_PBATL_SE (0xa << SADC_CFG_CMD_BIT) /* PBAT < 2.5V */
7.2076 + #define SADC_CFG_CMD_SADCIN_SE (0xb << SADC_CFG_CMD_BIT) /* Measure SADCIN */
7.2077 + #define SADC_CFG_CMD_INT_PEN (0xc << SADC_CFG_CMD_BIT) /* INT_PEN Enable */
7.2078 +
7.2079 +/* ADC Control Register */
7.2080 +#define SADC_CTRL_PENDM (1 << 4) /* Pen Down Interrupt Mask */
7.2081 +#define SADC_CTRL_PENUM (1 << 3) /* Pen Up Interrupt Mask */
7.2082 +#define SADC_CTRL_TSRDYM (1 << 2) /* Touch Screen Data Ready Interrupt Mask */
7.2083 +#define SADC_CTRL_PBATRDYM (1 << 1) /* PBAT Data Ready Interrupt Mask */
7.2084 +#define SADC_CTRL_SRDYM (1 << 0) /* SADCIN Data Ready Interrupt Mask */
7.2085 +
7.2086 +/* ADC Status Register */
7.2087 +#define SADC_STATE_TSBUSY (1 << 7) /* TS A/D is working */
7.2088 +#define SADC_STATE_PBATBUSY (1 << 6) /* PBAT A/D is working */
7.2089 +#define SADC_STATE_SBUSY (1 << 5) /* SADCIN A/D is working */
7.2090 +#define SADC_STATE_PEND (1 << 4) /* Pen Down Interrupt Flag */
7.2091 +#define SADC_STATE_PENU (1 << 3) /* Pen Up Interrupt Flag */
7.2092 +#define SADC_STATE_TSRDY (1 << 2) /* Touch Screen Data Ready Interrupt Flag */
7.2093 +#define SADC_STATE_PBATRDY (1 << 1) /* PBAT Data Ready Interrupt Flag */
7.2094 +#define SADC_STATE_SRDY (1 << 0) /* SADCIN Data Ready Interrupt Flag */
7.2095 +
7.2096 +/* ADC Touch Screen Data Register */
7.2097 +#define SADC_TSDAT_DATA0_BIT 0
7.2098 +#define SADC_TSDAT_DATA0_MASK (0xfff << SADC_TSDAT_DATA0_BIT)
7.2099 +#define SADC_TSDAT_TYPE0 (1 << 15)
7.2100 +#define SADC_TSDAT_DATA1_BIT 16
7.2101 +#define SADC_TSDAT_DATA1_MASK (0xfff << SADC_TSDAT_DATA1_BIT)
7.2102 +#define SADC_TSDAT_TYPE1 (1 << 31)
7.2103 +
7.2104 +
7.2105 +/*************************************************************************
7.2106 + * SLCD (Smart LCD Controller)
7.2107 + *************************************************************************/
7.2108 +
7.2109 +#define SLCD_CFG (SLCD_BASE + 0xA0) /* SLCD Configure Register */
7.2110 +#define SLCD_CTRL (SLCD_BASE + 0xA4) /* SLCD Control Register */
7.2111 +#define SLCD_STATE (SLCD_BASE + 0xA8) /* SLCD Status Register */
7.2112 +#define SLCD_DATA (SLCD_BASE + 0xAC) /* SLCD Data Register */
7.2113 +#define SLCD_FIFO (SLCD_BASE + 0xB0) /* SLCD FIFO Register */
7.2114 +
7.2115 +#define REG_SLCD_CFG REG32(SLCD_CFG)
7.2116 +#define REG_SLCD_CTRL REG8(SLCD_CTRL)
7.2117 +#define REG_SLCD_STATE REG8(SLCD_STATE)
7.2118 +#define REG_SLCD_DATA REG32(SLCD_DATA)
7.2119 +#define REG_SLCD_FIFO REG32(SLCD_FIFO)
7.2120 +
7.2121 +/* SLCD Configure Register */
7.2122 +#define SLCD_CFG_BURST_BIT 14
7.2123 +#define SLCD_CFG_BURST_MASK (0x3 << SLCD_CFG_BURST_BIT)
7.2124 + #define SLCD_CFG_BURST_4_WORD (0 << SLCD_CFG_BURST_BIT)
7.2125 + #define SLCD_CFG_BURST_8_WORD (1 << SLCD_CFG_BURST_BIT)
7.2126 +#define SLCD_CFG_DWIDTH_BIT 10
7.2127 +#define SLCD_CFG_DWIDTH_MASK (0x7 << SLCD_CFG_DWIDTH_BIT)
7.2128 + #define SLCD_CFG_DWIDTH_18 (0 << SLCD_CFG_DWIDTH_BIT)
7.2129 + #define SLCD_CFG_DWIDTH_16 (1 << SLCD_CFG_DWIDTH_BIT)
7.2130 + #define SLCD_CFG_DWIDTH_8_x3 (2 << SLCD_CFG_DWIDTH_BIT)
7.2131 + #define SLCD_CFG_DWIDTH_8_x2 (3 << SLCD_CFG_DWIDTH_BIT)
7.2132 + #define SLCD_CFG_DWIDTH_9_x2 (4 << SLCD_CFG_DWIDTH_BIT)
7.2133 +#define SLCD_CFG_CWIDTH_16BIT (0 << 8)
7.2134 +#define SLCD_CFG_CWIDTH_8BIT (1 << 8)
7.2135 +#define SLCD_CFG_CS_ACTIVE_LOW (0 << 4)
7.2136 +#define SLCD_CFG_CS_ACTIVE_HIGH (1 << 4)
7.2137 +#define SLCD_CFG_RS_CMD_LOW (0 << 3)
7.2138 +#define SLCD_CFG_RS_CMD_HIGH (1 << 3)
7.2139 +#define SLCD_CFG_CLK_ACTIVE_FALLING (0 << 1)
7.2140 +#define SLCD_CFG_CLK_ACTIVE_RISING (1 << 1)
7.2141 +#define SLCD_CFG_TYPE_PARALLEL (0 << 0)
7.2142 +#define SLCD_CFG_TYPE_SERIAL (1 << 0)
7.2143 +
7.2144 +/* SLCD Control Register */
7.2145 +#define SLCD_CTRL_DMA_EN (1 << 0)
7.2146 +
7.2147 +/* SLCD Status Register */
7.2148 +#define SLCD_STATE_BUSY (1 << 0)
7.2149 +
7.2150 +/* SLCD Data Register */
7.2151 +#define SLCD_DATA_RS_DATA (0 << 31)
7.2152 +#define SLCD_DATA_RS_COMMAND (1 << 31)
7.2153 +
7.2154 +/* SLCD FIFO Register */
7.2155 +#define SLCD_FIFO_RS_DATA (0 << 31)
7.2156 +#define SLCD_FIFO_RS_COMMAND (1 << 31)
7.2157 +
7.2158 +
7.2159 +/*************************************************************************
7.2160 + * LCD (LCD Controller)
7.2161 + *************************************************************************/
7.2162 +#define LCD_CFG (LCD_BASE + 0x00) /* LCD Configure Register */
7.2163 +#define LCD_VSYNC (LCD_BASE + 0x04) /* Vertical Synchronize Register */
7.2164 +#define LCD_HSYNC (LCD_BASE + 0x08) /* Horizontal Synchronize Register */
7.2165 +#define LCD_VAT (LCD_BASE + 0x0c) /* Virtual Area Setting Register */
7.2166 +#define LCD_DAH (LCD_BASE + 0x10) /* Display Area Horizontal Start/End Point */
7.2167 +#define LCD_DAV (LCD_BASE + 0x14) /* Display Area Vertical Start/End Point */
7.2168 +#define LCD_PS (LCD_BASE + 0x18) /* PS Signal Setting */
7.2169 +#define LCD_CLS (LCD_BASE + 0x1c) /* CLS Signal Setting */
7.2170 +#define LCD_SPL (LCD_BASE + 0x20) /* SPL Signal Setting */
7.2171 +#define LCD_REV (LCD_BASE + 0x24) /* REV Signal Setting */
7.2172 +#define LCD_CTRL (LCD_BASE + 0x30) /* LCD Control Register */
7.2173 +#define LCD_STATE (LCD_BASE + 0x34) /* LCD Status Register */
7.2174 +#define LCD_IID (LCD_BASE + 0x38) /* Interrupt ID Register */
7.2175 +#define LCD_DA0 (LCD_BASE + 0x40) /* Descriptor Address Register 0 */
7.2176 +#define LCD_SA0 (LCD_BASE + 0x44) /* Source Address Register 0 */
7.2177 +#define LCD_FID0 (LCD_BASE + 0x48) /* Frame ID Register 0 */
7.2178 +#define LCD_CMD0 (LCD_BASE + 0x4c) /* DMA Command Register 0 */
7.2179 +#define LCD_DA1 (LCD_BASE + 0x50) /* Descriptor Address Register 1 */
7.2180 +#define LCD_SA1 (LCD_BASE + 0x54) /* Source Address Register 1 */
7.2181 +#define LCD_FID1 (LCD_BASE + 0x58) /* Frame ID Register 1 */
7.2182 +#define LCD_CMD1 (LCD_BASE + 0x5c) /* DMA Command Register 1 */
7.2183 +
7.2184 +#define REG_LCD_CFG REG32(LCD_CFG)
7.2185 +#define REG_LCD_VSYNC REG32(LCD_VSYNC)
7.2186 +#define REG_LCD_HSYNC REG32(LCD_HSYNC)
7.2187 +#define REG_LCD_VAT REG32(LCD_VAT)
7.2188 +#define REG_LCD_DAH REG32(LCD_DAH)
7.2189 +#define REG_LCD_DAV REG32(LCD_DAV)
7.2190 +#define REG_LCD_PS REG32(LCD_PS)
7.2191 +#define REG_LCD_CLS REG32(LCD_CLS)
7.2192 +#define REG_LCD_SPL REG32(LCD_SPL)
7.2193 +#define REG_LCD_REV REG32(LCD_REV)
7.2194 +#define REG_LCD_CTRL REG32(LCD_CTRL)
7.2195 +#define REG_LCD_STATE REG32(LCD_STATE)
7.2196 +#define REG_LCD_IID REG32(LCD_IID)
7.2197 +#define REG_LCD_DA0 REG32(LCD_DA0)
7.2198 +#define REG_LCD_SA0 REG32(LCD_SA0)
7.2199 +#define REG_LCD_FID0 REG32(LCD_FID0)
7.2200 +#define REG_LCD_CMD0 REG32(LCD_CMD0)
7.2201 +#define REG_LCD_DA1 REG32(LCD_DA1)
7.2202 +#define REG_LCD_SA1 REG32(LCD_SA1)
7.2203 +#define REG_LCD_FID1 REG32(LCD_FID1)
7.2204 +#define REG_LCD_CMD1 REG32(LCD_CMD1)
7.2205 +
7.2206 +/* LCD Configure Register */
7.2207 +#define LCD_CFG_LCDPIN_BIT 31 /* LCD pins selection */
7.2208 +#define LCD_CFG_LCDPIN_MASK (0x1 << LCD_CFG_LCDPIN_BIT)
7.2209 + #define LCD_CFG_LCDPIN_LCD (0x0 << LCD_CFG_LCDPIN_BIT)
7.2210 + #define LCD_CFG_LCDPIN_SLCD (0x1 << LCD_CFG_LCDPIN_BIT)
7.2211 +#define LCD_CFG_PSM (1 << 23) /* PS signal mode */
7.2212 +#define LCD_CFG_CLSM (1 << 22) /* CLS signal mode */
7.2213 +#define LCD_CFG_SPLM (1 << 21) /* SPL signal mode */
7.2214 +#define LCD_CFG_REVM (1 << 20) /* REV signal mode */
7.2215 +#define LCD_CFG_HSYNM (1 << 19) /* HSYNC signal mode */
7.2216 +#define LCD_CFG_PCLKM (1 << 18) /* PCLK signal mode */
7.2217 +#define LCD_CFG_INVDAT (1 << 17) /* Inverse output data */
7.2218 +#define LCD_CFG_SYNDIR_IN (1 << 16) /* VSYNC&HSYNC direction */
7.2219 +#define LCD_CFG_PSP (1 << 15) /* PS pin reset state */
7.2220 +#define LCD_CFG_CLSP (1 << 14) /* CLS pin reset state */
7.2221 +#define LCD_CFG_SPLP (1 << 13) /* SPL pin reset state */
7.2222 +#define LCD_CFG_REVP (1 << 12) /* REV pin reset state */
7.2223 +#define LCD_CFG_HSP (1 << 11) /* HSYNC pority:0-active high,1-active low */
7.2224 +#define LCD_CFG_PCP (1 << 10) /* PCLK pority:0-rising,1-falling */
7.2225 +#define LCD_CFG_DEP (1 << 9) /* DE pority:0-active high,1-active low */
7.2226 +#define LCD_CFG_VSP (1 << 8) /* VSYNC pority:0-rising,1-falling */
7.2227 +#define LCD_CFG_PDW_BIT 4 /* STN pins utilization */
7.2228 +#define LCD_CFG_PDW_MASK (0x3 << LCD_DEV_PDW_BIT)
7.2229 +#define LCD_CFG_PDW_1 (0 << LCD_CFG_PDW_BIT) /* LCD_D[0] */
7.2230 + #define LCD_CFG_PDW_2 (1 << LCD_CFG_PDW_BIT) /* LCD_D[0:1] */
7.2231 + #define LCD_CFG_PDW_4 (2 << LCD_CFG_PDW_BIT) /* LCD_D[0:3]/LCD_D[8:11] */
7.2232 + #define LCD_CFG_PDW_8 (3 << LCD_CFG_PDW_BIT) /* LCD_D[0:7]/LCD_D[8:15] */
7.2233 +#define LCD_CFG_MODE_BIT 0 /* Display Device Mode Select */
7.2234 +#define LCD_CFG_MODE_MASK (0x0f << LCD_CFG_MODE_BIT)
7.2235 + #define LCD_CFG_MODE_GENERIC_TFT (0 << LCD_CFG_MODE_BIT) /* 16,18 bit TFT */
7.2236 + #define LCD_CFG_MODE_SPECIAL_TFT_1 (1 << LCD_CFG_MODE_BIT)
7.2237 + #define LCD_CFG_MODE_SPECIAL_TFT_2 (2 << LCD_CFG_MODE_BIT)
7.2238 + #define LCD_CFG_MODE_SPECIAL_TFT_3 (3 << LCD_CFG_MODE_BIT)
7.2239 + #define LCD_CFG_MODE_NONINTER_CCIR656 (4 << LCD_CFG_MODE_BIT)
7.2240 + #define LCD_CFG_MODE_INTER_CCIR656 (5 << LCD_CFG_MODE_BIT)
7.2241 + #define LCD_CFG_MODE_SINGLE_CSTN (8 << LCD_CFG_MODE_BIT)
7.2242 + #define LCD_CFG_MODE_SINGLE_MSTN (9 << LCD_CFG_MODE_BIT)
7.2243 + #define LCD_CFG_MODE_DUAL_CSTN (10 << LCD_CFG_MODE_BIT)
7.2244 + #define LCD_CFG_MODE_DUAL_MSTN (11 << LCD_CFG_MODE_BIT)
7.2245 + #define LCD_CFG_MODE_SERIAL_TFT (12 << LCD_CFG_MODE_BIT)
7.2246 + #define LCD_CFG_MODE_GENERIC_18BIT_TFT (13 << LCD_CFG_MODE_BIT)
7.2247 + /* JZ47XX defines */
7.2248 + #define LCD_CFG_MODE_SHARP_HR (1 << LCD_CFG_MODE_BIT)
7.2249 + #define LCD_CFG_MODE_CASIO_TFT (2 << LCD_CFG_MODE_BIT)
7.2250 + #define LCD_CFG_MODE_SAMSUNG_ALPHA (3 << LCD_CFG_MODE_BIT)
7.2251 +
7.2252 +
7.2253 +
7.2254 +/* Vertical Synchronize Register */
7.2255 +#define LCD_VSYNC_VPS_BIT 16 /* VSYNC pulse start in line clock, fixed to 0 */
7.2256 +#define LCD_VSYNC_VPS_MASK (0xffff << LCD_VSYNC_VPS_BIT)
7.2257 +#define LCD_VSYNC_VPE_BIT 0 /* VSYNC pulse end in line clock */
7.2258 +#define LCD_VSYNC_VPE_MASK (0xffff << LCD_VSYNC_VPS_BIT)
7.2259 +
7.2260 +/* Horizontal Synchronize Register */
7.2261 +#define LCD_HSYNC_HPS_BIT 16 /* HSYNC pulse start position in dot clock */
7.2262 +#define LCD_HSYNC_HPS_MASK (0xffff << LCD_HSYNC_HPS_BIT)
7.2263 +#define LCD_HSYNC_HPE_BIT 0 /* HSYNC pulse end position in dot clock */
7.2264 +#define LCD_HSYNC_HPE_MASK (0xffff << LCD_HSYNC_HPE_BIT)
7.2265 +
7.2266 +/* Virtual Area Setting Register */
7.2267 +#define LCD_VAT_HT_BIT 16 /* Horizontal Total size in dot clock */
7.2268 +#define LCD_VAT_HT_MASK (0xffff << LCD_VAT_HT_BIT)
7.2269 +#define LCD_VAT_VT_BIT 0 /* Vertical Total size in dot clock */
7.2270 +#define LCD_VAT_VT_MASK (0xffff << LCD_VAT_VT_BIT)
7.2271 +
7.2272 +/* Display Area Horizontal Start/End Point Register */
7.2273 +#define LCD_DAH_HDS_BIT 16 /* Horizontal display area start in dot clock */
7.2274 +#define LCD_DAH_HDS_MASK (0xffff << LCD_DAH_HDS_BIT)
7.2275 +#define LCD_DAH_HDE_BIT 0 /* Horizontal display area end in dot clock */
7.2276 +#define LCD_DAH_HDE_MASK (0xffff << LCD_DAH_HDE_BIT)
7.2277 +
7.2278 +/* Display Area Vertical Start/End Point Register */
7.2279 +#define LCD_DAV_VDS_BIT 16 /* Vertical display area start in line clock */
7.2280 +#define LCD_DAV_VDS_MASK (0xffff << LCD_DAV_VDS_BIT)
7.2281 +#define LCD_DAV_VDE_BIT 0 /* Vertical display area end in line clock */
7.2282 +#define LCD_DAV_VDE_MASK (0xffff << LCD_DAV_VDE_BIT)
7.2283 +
7.2284 +/* PS Signal Setting */
7.2285 +#define LCD_PS_PSS_BIT 16 /* PS signal start position in dot clock */
7.2286 +#define LCD_PS_PSS_MASK (0xffff << LCD_PS_PSS_BIT)
7.2287 +#define LCD_PS_PSE_BIT 0 /* PS signal end position in dot clock */
7.2288 +#define LCD_PS_PSE_MASK (0xffff << LCD_PS_PSE_BIT)
7.2289 +
7.2290 +/* CLS Signal Setting */
7.2291 +#define LCD_CLS_CLSS_BIT 16 /* CLS signal start position in dot clock */
7.2292 +#define LCD_CLS_CLSS_MASK (0xffff << LCD_CLS_CLSS_BIT)
7.2293 +#define LCD_CLS_CLSE_BIT 0 /* CLS signal end position in dot clock */
7.2294 +#define LCD_CLS_CLSE_MASK (0xffff << LCD_CLS_CLSE_BIT)
7.2295 +
7.2296 +/* SPL Signal Setting */
7.2297 +#define LCD_SPL_SPLS_BIT 16 /* SPL signal start position in dot clock */
7.2298 +#define LCD_SPL_SPLS_MASK (0xffff << LCD_SPL_SPLS_BIT)
7.2299 +#define LCD_SPL_SPLE_BIT 0 /* SPL signal end position in dot clock */
7.2300 +#define LCD_SPL_SPLE_MASK (0xffff << LCD_SPL_SPLE_BIT)
7.2301 +
7.2302 +/* REV Signal Setting */
7.2303 +#define LCD_REV_REVS_BIT 16 /* REV signal start position in dot clock */
7.2304 +#define LCD_REV_REVS_MASK (0xffff << LCD_REV_REVS_BIT)
7.2305 +
7.2306 +/* LCD Control Register */
7.2307 +#define LCD_CTRL_BST_BIT 28 /* Burst Length Selection */
7.2308 +#define LCD_CTRL_BST_MASK (0x03 << LCD_CTRL_BST_BIT)
7.2309 + #define LCD_CTRL_BST_4 (0 << LCD_CTRL_BST_BIT) /* 4-word */
7.2310 + #define LCD_CTRL_BST_8 (1 << LCD_CTRL_BST_BIT) /* 8-word */
7.2311 + #define LCD_CTRL_BST_16 (2 << LCD_CTRL_BST_BIT) /* 16-word */
7.2312 +#define LCD_CTRL_RGB565 (0 << 27) /* RGB565 mode */
7.2313 +#define LCD_CTRL_RGB555 (1 << 27) /* RGB555 mode */
7.2314 +#define LCD_CTRL_OFUP (1 << 26) /* Output FIFO underrun protection enable */
7.2315 +#define LCD_CTRL_FRC_BIT 24 /* STN FRC Algorithm Selection */
7.2316 +#define LCD_CTRL_FRC_MASK (0x03 << LCD_CTRL_FRC_BIT)
7.2317 + #define LCD_CTRL_FRC_16 (0 << LCD_CTRL_FRC_BIT) /* 16 grayscale */
7.2318 + #define LCD_CTRL_FRC_4 (1 << LCD_CTRL_FRC_BIT) /* 4 grayscale */
7.2319 + #define LCD_CTRL_FRC_2 (2 << LCD_CTRL_FRC_BIT) /* 2 grayscale */
7.2320 +#define LCD_CTRL_PDD_BIT 16 /* Load Palette Delay Counter */
7.2321 +#define LCD_CTRL_PDD_MASK (0xff << LCD_CTRL_PDD_BIT)
7.2322 +#define LCD_CTRL_EOFM (1 << 13) /* EOF interrupt mask */
7.2323 +#define LCD_CTRL_SOFM (1 << 12) /* SOF interrupt mask */
7.2324 +#define LCD_CTRL_OFUM (1 << 11) /* Output FIFO underrun interrupt mask */
7.2325 +#define LCD_CTRL_IFUM0 (1 << 10) /* Input FIFO 0 underrun interrupt mask */
7.2326 +#define LCD_CTRL_IFUM1 (1 << 9) /* Input FIFO 1 underrun interrupt mask */
7.2327 +#define LCD_CTRL_LDDM (1 << 8) /* LCD disable done interrupt mask */
7.2328 +#define LCD_CTRL_QDM (1 << 7) /* LCD quick disable done interrupt mask */
7.2329 +#define LCD_CTRL_BEDN (1 << 6) /* Endian selection */
7.2330 +#define LCD_CTRL_PEDN (1 << 5) /* Endian in byte:0-msb first, 1-lsb first */
7.2331 +#define LCD_CTRL_DIS (1 << 4) /* Disable indicate bit */
7.2332 +#define LCD_CTRL_ENA (1 << 3) /* LCD enable bit */
7.2333 +#define LCD_CTRL_BPP_BIT 0 /* Bits Per Pixel */
7.2334 +#define LCD_CTRL_BPP_MASK (0x07 << LCD_CTRL_BPP_BIT)
7.2335 + #define LCD_CTRL_BPP_1 (0 << LCD_CTRL_BPP_BIT) /* 1 bpp */
7.2336 + #define LCD_CTRL_BPP_2 (1 << LCD_CTRL_BPP_BIT) /* 2 bpp */
7.2337 + #define LCD_CTRL_BPP_4 (2 << LCD_CTRL_BPP_BIT) /* 4 bpp */
7.2338 + #define LCD_CTRL_BPP_8 (3 << LCD_CTRL_BPP_BIT) /* 8 bpp */
7.2339 + #define LCD_CTRL_BPP_16 (4 << LCD_CTRL_BPP_BIT) /* 15/16 bpp */
7.2340 + #define LCD_CTRL_BPP_18_24 (5 << LCD_CTRL_BPP_BIT) /* 18/24/32 bpp */
7.2341 +
7.2342 +/* LCD Status Register */
7.2343 +#define LCD_STATE_QD (1 << 7) /* Quick Disable Done */
7.2344 +#define LCD_STATE_EOF (1 << 5) /* EOF Flag */
7.2345 +#define LCD_STATE_SOF (1 << 4) /* SOF Flag */
7.2346 +#define LCD_STATE_OFU (1 << 3) /* Output FIFO Underrun */
7.2347 +#define LCD_STATE_IFU0 (1 << 2) /* Input FIFO 0 Underrun */
7.2348 +#define LCD_STATE_IFU1 (1 << 1) /* Input FIFO 1 Underrun */
7.2349 +#define LCD_STATE_LDD (1 << 0) /* LCD Disabled */
7.2350 +
7.2351 +/* DMA Command Register */
7.2352 +#define LCD_CMD_SOFINT (1 << 31)
7.2353 +#define LCD_CMD_EOFINT (1 << 30)
7.2354 +#define LCD_CMD_PAL (1 << 28)
7.2355 +#define LCD_CMD_LEN_BIT 0
7.2356 +#define LCD_CMD_LEN_MASK (0xffffff << LCD_CMD_LEN_BIT)
7.2357 +
7.2358 +
7.2359 +/*************************************************************************
7.2360 + * USB Device
7.2361 + *************************************************************************/
7.2362 +#define USB_BASE UDC_BASE
7.2363 +
7.2364 +#define USB_REG_FADDR (USB_BASE + 0x00) /* Function Address 8-bit */
7.2365 +#define USB_REG_POWER (USB_BASE + 0x01) /* Power Managemetn 8-bit */
7.2366 +#define USB_REG_INTRIN (USB_BASE + 0x02) /* Interrupt IN 16-bit */
7.2367 +#define USB_REG_INTROUT (USB_BASE + 0x04) /* Interrupt OUT 16-bit */
7.2368 +#define USB_REG_INTRINE (USB_BASE + 0x06) /* Intr IN enable 16-bit */
7.2369 +#define USB_REG_INTROUTE (USB_BASE + 0x08) /* Intr OUT enable 16-bit */
7.2370 +#define USB_REG_INTRUSB (USB_BASE + 0x0a) /* Interrupt USB 8-bit */
7.2371 +#define USB_REG_INTRUSBE (USB_BASE + 0x0b) /* Interrupt USB Enable 8-bit */
7.2372 +#define USB_REG_FRAME (USB_BASE + 0x0c) /* Frame number 16-bit */
7.2373 +#define USB_REG_INDEX (USB_BASE + 0x0e) /* Index register 8-bit */
7.2374 +#define USB_REG_TESTMODE (USB_BASE + 0x0f) /* USB test mode 8-bit */
7.2375 +
7.2376 +#define USB_REG_CSR0 (USB_BASE + 0x12) /* EP0 CSR 8-bit */
7.2377 +#define USB_REG_INMAXP (USB_BASE + 0x10) /* EP1-2 IN Max Pkt Size 16-bit */
7.2378 +#define USB_REG_INCSR (USB_BASE + 0x12) /* EP1-2 IN CSR LSB 8/16bit */
7.2379 +#define USB_REG_INCSRH (USB_BASE + 0x13) /* EP1-2 IN CSR MSB 8-bit */
7.2380 +#define USB_REG_OUTMAXP (USB_BASE + 0x14) /* EP1 OUT Max Pkt Size 16-bit */
7.2381 +#define USB_REG_OUTCSR (USB_BASE + 0x16) /* EP1 OUT CSR LSB 8/16bit */
7.2382 +#define USB_REG_OUTCSRH (USB_BASE + 0x17) /* EP1 OUT CSR MSB 8-bit */
7.2383 +#define USB_REG_OUTCOUNT (USB_BASE + 0x18) /* bytes in EP0/1 OUT FIFO 16-bit */
7.2384 +
7.2385 +#define USB_FIFO_EP0 (USB_BASE + 0x20)
7.2386 +#define USB_FIFO_EP1 (USB_BASE + 0x24)
7.2387 +#define USB_FIFO_EP2 (USB_BASE + 0x28)
7.2388 +
7.2389 +#define USB_REG_EPINFO (USB_BASE + 0x78) /* Endpoint information */
7.2390 +#define USB_REG_RAMINFO (USB_BASE + 0x79) /* RAM information */
7.2391 +
7.2392 +#define USB_REG_INTR (USB_BASE + 0x200) /* DMA pending interrupts */
7.2393 +#define USB_REG_CNTL1 (USB_BASE + 0x204) /* DMA channel 1 control */
7.2394 +#define USB_REG_ADDR1 (USB_BASE + 0x208) /* DMA channel 1 AHB memory addr */
7.2395 +#define USB_REG_COUNT1 (USB_BASE + 0x20c) /* DMA channel 1 byte count */
7.2396 +#define USB_REG_CNTL2 (USB_BASE + 0x214) /* DMA channel 2 control */
7.2397 +#define USB_REG_ADDR2 (USB_BASE + 0x218) /* DMA channel 2 AHB memory addr */
7.2398 +#define USB_REG_COUNT2 (USB_BASE + 0x21c) /* DMA channel 2 byte count */
7.2399 +
7.2400 +
7.2401 +/* Power register bit masks */
7.2402 +#define USB_POWER_SUSPENDM 0x01
7.2403 +#define USB_POWER_RESUME 0x04
7.2404 +#define USB_POWER_HSMODE 0x10
7.2405 +#define USB_POWER_HSENAB 0x20
7.2406 +#define USB_POWER_SOFTCONN 0x40
7.2407 +
7.2408 +/* Interrupt register bit masks */
7.2409 +#define USB_INTR_SUSPEND 0x01
7.2410 +#define USB_INTR_RESUME 0x02
7.2411 +#define USB_INTR_RESET 0x04
7.2412 +
7.2413 +#define USB_INTR_EP0 0x0001
7.2414 +#define USB_INTR_INEP1 0x0002
7.2415 +#define USB_INTR_INEP2 0x0004
7.2416 +#define USB_INTR_OUTEP1 0x0002
7.2417 +
7.2418 +/* CSR0 bit masks */
7.2419 +#define USB_CSR0_OUTPKTRDY 0x01
7.2420 +#define USB_CSR0_INPKTRDY 0x02
7.2421 +#define USB_CSR0_SENTSTALL 0x04
7.2422 +#define USB_CSR0_DATAEND 0x08
7.2423 +#define USB_CSR0_SETUPEND 0x10
7.2424 +#define USB_CSR0_SENDSTALL 0x20
7.2425 +#define USB_CSR0_SVDOUTPKTRDY 0x40
7.2426 +#define USB_CSR0_SVDSETUPEND 0x80
7.2427 +
7.2428 +/* Endpoint CSR register bits */
7.2429 +#define USB_INCSRH_AUTOSET 0x80
7.2430 +#define USB_INCSRH_ISO 0x40
7.2431 +#define USB_INCSRH_MODE 0x20
7.2432 +#define USB_INCSRH_DMAREQENAB 0x10
7.2433 +#define USB_INCSRH_DMAREQMODE 0x04
7.2434 +#define USB_INCSR_CDT 0x40
7.2435 +#define USB_INCSR_SENTSTALL 0x20
7.2436 +#define USB_INCSR_SENDSTALL 0x10
7.2437 +#define USB_INCSR_FF 0x08
7.2438 +#define USB_INCSR_UNDERRUN 0x04
7.2439 +#define USB_INCSR_FFNOTEMPT 0x02
7.2440 +#define USB_INCSR_INPKTRDY 0x01
7.2441 +#define USB_OUTCSRH_AUTOCLR 0x80
7.2442 +#define USB_OUTCSRH_ISO 0x40
7.2443 +#define USB_OUTCSRH_DMAREQENAB 0x20
7.2444 +#define USB_OUTCSRH_DNYT 0x10
7.2445 +#define USB_OUTCSRH_DMAREQMODE 0x08
7.2446 +#define USB_OUTCSR_CDT 0x80
7.2447 +#define USB_OUTCSR_SENTSTALL 0x40
7.2448 +#define USB_OUTCSR_SENDSTALL 0x20
7.2449 +#define USB_OUTCSR_FF 0x10
7.2450 +#define USB_OUTCSR_DATAERR 0x08
7.2451 +#define USB_OUTCSR_OVERRUN 0x04
7.2452 +#define USB_OUTCSR_FFFULL 0x02
7.2453 +#define USB_OUTCSR_OUTPKTRDY 0x01
7.2454 +
7.2455 +/* Testmode register bits */
7.2456 +#define USB_TEST_SE0NAK 0x01
7.2457 +#define USB_TEST_J 0x02
7.2458 +#define USB_TEST_K 0x04
7.2459 +#define USB_TEST_PACKET 0x08
7.2460 +
7.2461 +/* DMA control bits */
7.2462 +#define USB_CNTL_ENA 0x01
7.2463 +#define USB_CNTL_DIR_IN 0x02
7.2464 +#define USB_CNTL_MODE_1 0x04
7.2465 +#define USB_CNTL_INTR_EN 0x08
7.2466 +#define USB_CNTL_EP(n) ((n) << 4)
7.2467 +#define USB_CNTL_BURST_0 (0 << 9)
7.2468 +#define USB_CNTL_BURST_4 (1 << 9)
7.2469 +#define USB_CNTL_BURST_8 (2 << 9)
7.2470 +#define USB_CNTL_BURST_16 (3 << 9)
7.2471 +
7.2472 +
7.2473 +/* Module Operation Definitions */
7.2474 +#ifndef __ASSEMBLY__
7.2475 +
7.2476 +/***************************************************************************
7.2477 + * GPIO
7.2478 + ***************************************************************************/
7.2479 +
7.2480 +//------------------------------------------------------
7.2481 +// GPIO Pins Description
7.2482 +//
7.2483 +// PORT 0:
7.2484 +//
7.2485 +// PIN/BIT N FUNC0 FUNC1
7.2486 +// 0 D0 -
7.2487 +// 1 D1 -
7.2488 +// 2 D2 -
7.2489 +// 3 D3 -
7.2490 +// 4 D4 -
7.2491 +// 5 D5 -
7.2492 +// 6 D6 -
7.2493 +// 7 D7 -
7.2494 +// 8 D8 -
7.2495 +// 9 D9 -
7.2496 +// 10 D10 -
7.2497 +// 11 D11 -
7.2498 +// 12 D12 -
7.2499 +// 13 D13 -
7.2500 +// 14 D14 -
7.2501 +// 15 D15 -
7.2502 +// 16 D16 -
7.2503 +// 17 D17 -
7.2504 +// 18 D18 -
7.2505 +// 19 D19 -
7.2506 +// 20 D20 -
7.2507 +// 21 D21 -
7.2508 +// 22 D22 -
7.2509 +// 23 D23 -
7.2510 +// 24 D24 -
7.2511 +// 25 D25 -
7.2512 +// 26 D26 -
7.2513 +// 27 D27 -
7.2514 +// 28 D28 -
7.2515 +// 29 D29 -
7.2516 +// 30 D30 -
7.2517 +// 31 D31 -
7.2518 +//
7.2519 +//------------------------------------------------------
7.2520 +// PORT 1:
7.2521 +//
7.2522 +// PIN/BIT N FUNC0 FUNC1
7.2523 +// 0 A0 -
7.2524 +// 1 A1 -
7.2525 +// 2 A2 -
7.2526 +// 3 A3 -
7.2527 +// 4 A4 -
7.2528 +// 5 A5 -
7.2529 +// 6 A6 -
7.2530 +// 7 A7 -
7.2531 +// 8 A8 -
7.2532 +// 9 A9 -
7.2533 +// 10 A10 -
7.2534 +// 11 A11 -
7.2535 +// 12 A12 -
7.2536 +// 13 A13 -
7.2537 +// 14 A14 -
7.2538 +// 15 A15/CL -
7.2539 +// 16 A16/AL -
7.2540 +// 17 LCD_CLS A21
7.2541 +// 18 LCD_SPL A22
7.2542 +// 19 DCS# -
7.2543 +// 20 RAS# -
7.2544 +// 21 CAS# -
7.2545 +// 22 RDWE#/BUFD# -
7.2546 +// 23 CKE -
7.2547 +// 24 CKO -
7.2548 +// 25 CS1# -
7.2549 +// 26 CS2# -
7.2550 +// 27 CS3# -
7.2551 +// 28 CS4# -
7.2552 +// 29 RD# -
7.2553 +// 30 WR# -
7.2554 +// 31 WE0# -
7.2555 +//
7.2556 +// Note: PIN15&16 are CL&AL when connecting to NAND flash.
7.2557 +//------------------------------------------------------
7.2558 +// PORT 2:
7.2559 +//
7.2560 +// PIN/BIT N FUNC0 FUNC1
7.2561 +// 0 LCD_D0 -
7.2562 +// 1 LCD_D1 -
7.2563 +// 2 LCD_D2 -
7.2564 +// 3 LCD_D3 -
7.2565 +// 4 LCD_D4 -
7.2566 +// 5 LCD_D5 -
7.2567 +// 6 LCD_D6 -
7.2568 +// 7 LCD_D7 -
7.2569 +// 8 LCD_D8 -
7.2570 +// 9 LCD_D9 -
7.2571 +// 10 LCD_D10 -
7.2572 +// 11 LCD_D11 -
7.2573 +// 12 LCD_D12 -
7.2574 +// 13 LCD_D13 -
7.2575 +// 14 LCD_D14 -
7.2576 +// 15 LCD_D15 -
7.2577 +// 16 LCD_D16 -
7.2578 +// 17 LCD_D17 -
7.2579 +// 18 LCD_PCLK -
7.2580 +// 19 LCD_HSYNC -
7.2581 +// 20 LCD_VSYNC -
7.2582 +// 21 LCD_DE -
7.2583 +// 22 LCD_PS A19
7.2584 +// 23 LCD_REV A20
7.2585 +// 24 WE1# -
7.2586 +// 25 WE2# -
7.2587 +// 26 WE3# -
7.2588 +// 27 WAIT# -
7.2589 +// 28 FRE# -
7.2590 +// 29 FWE# -
7.2591 +// 30(NOTE:FRB#) - -
7.2592 +// 31 - -
7.2593 +//
7.2594 +// NOTE(1): PIN30 is used for FRB# when connecting to NAND flash.
7.2595 +//------------------------------------------------------
7.2596 +// PORT 3:
7.2597 +//
7.2598 +// PIN/BIT N FUNC0 FUNC1
7.2599 +// 0 CIM_D0 -
7.2600 +// 1 CIM_D1 -
7.2601 +// 2 CIM_D2 -
7.2602 +// 3 CIM_D3 -
7.2603 +// 4 CIM_D4 -
7.2604 +// 5 CIM_D5 -
7.2605 +// 6 CIM_D6 -
7.2606 +// 7 CIM_D7 -
7.2607 +// 8 MSC_CMD -
7.2608 +// 9 MSC_CLK -
7.2609 +// 10 MSC_D0 -
7.2610 +// 11 MSC_D1 -
7.2611 +// 12 MSC_D2 -
7.2612 +// 13 MSC_D3 -
7.2613 +// 14 CIM_MCLK -
7.2614 +// 15 CIM_PCLK -
7.2615 +// 16 CIM_VSYNC -
7.2616 +// 17 CIM_HSYNC -
7.2617 +// 18 SSI_CLK SCLK_RSTN
7.2618 +// 19 SSI_CE0# BIT_CLK(AIC)
7.2619 +// 20 SSI_DT SDATA_OUT(AIC)
7.2620 +// 21 SSI_DR SDATA_IN(AIC)
7.2621 +// 22 SSI_CE1#&GPC SYNC(AIC)
7.2622 +// 23 PWM0 I2C_SDA
7.2623 +// 24 PWM1 I2C_SCK
7.2624 +// 25 PWM2 UART0_TxD
7.2625 +// 26 PWM3 UART0_RxD
7.2626 +// 27 PWM4 A17
7.2627 +// 28 PWM5 A18
7.2628 +// 29 - -
7.2629 +// 30 PWM6 UART0_CTS/UART1_RxD
7.2630 +// 31 PWM7 UART0_RTS/UART1_TxD
7.2631 +//
7.2632 +//////////////////////////////////////////////////////////
7.2633 +
7.2634 +/*
7.2635 + * p is the port number (0,1,2,3)
7.2636 + * o is the pin offset (0-31) inside the port
7.2637 + * n is the absolute number of a pin (0-127), regardless of the port
7.2638 + */
7.2639 +
7.2640 +//-------------------------------------------
7.2641 +// Function Pins Mode
7.2642 +
7.2643 +#define __gpio_as_func0(n) \
7.2644 +do { \
7.2645 + unsigned int p, o; \
7.2646 + p = (n) / 32; \
7.2647 + o = (n) % 32; \
7.2648 + REG_GPIO_PXFUNS(p) = (1 << o); \
7.2649 + REG_GPIO_PXSELC(p) = (1 << o); \
7.2650 +} while (0)
7.2651 +
7.2652 +#define __gpio_as_func1(n) \
7.2653 +do { \
7.2654 + unsigned int p, o; \
7.2655 + p = (n) / 32; \
7.2656 + o = (n) % 32; \
7.2657 + REG_GPIO_PXFUNS(p) = (1 << o); \
7.2658 + REG_GPIO_PXSELS(p) = (1 << o); \
7.2659 +} while (0)
7.2660 +
7.2661 +/*
7.2662 + * D0 ~ D31, A0 ~ A16, DCS#, RAS#, CAS#, CKE#,
7.2663 + * RDWE#, CKO#, WE0#, WE1#, WE2#, WE3#
7.2664 + */
7.2665 +#define __gpio_as_sdram_32bit() \
7.2666 +do { \
7.2667 + REG_GPIO_PXFUNS(0) = 0xffffffff; \
7.2668 + REG_GPIO_PXSELC(0) = 0xffffffff; \
7.2669 + REG_GPIO_PXPES(0) = 0xffffffff; \
7.2670 + REG_GPIO_PXFUNS(1) = 0x81f9ffff; \
7.2671 + REG_GPIO_PXSELC(1) = 0x81f9ffff; \
7.2672 + REG_GPIO_PXPES(1) = 0x81f9ffff; \
7.2673 + REG_GPIO_PXFUNS(2) = 0x07000000; \
7.2674 + REG_GPIO_PXSELC(2) = 0x07000000; \
7.2675 + REG_GPIO_PXPES(2) = 0x07000000; \
7.2676 +} while (0)
7.2677 +
7.2678 +/*
7.2679 + * D0 ~ D15, A0 ~ A16, DCS#, RAS#, CAS#, CKE#,
7.2680 + * RDWE#, CKO#, WE0#, WE1#, WE2#, WE3#
7.2681 + */
7.2682 +#define __gpio_as_sdram_16bit() \
7.2683 +do { \
7.2684 + REG_GPIO_PXFUNS(0) = 0x5442bfaa; \
7.2685 + REG_GPIO_PXSELC(0) = 0x5442bfaa; \
7.2686 + REG_GPIO_PXPES(0) = 0x5442bfaa; \
7.2687 + REG_GPIO_PXFUNS(1) = 0x81f9ffff; \
7.2688 + REG_GPIO_PXSELC(1) = 0x81f9ffff; \
7.2689 + REG_GPIO_PXPES(1) = 0x81f9ffff; \
7.2690 + REG_GPIO_PXFUNS(2) = 0x01000000; \
7.2691 + REG_GPIO_PXSELC(2) = 0x01000000; \
7.2692 + REG_GPIO_PXPES(2) = 0x01000000; \
7.2693 +} while (0)
7.2694 +
7.2695 +/*
7.2696 + * CS1#, CLE, ALE, FRE#, FWE#, FRB#, RDWE#/BUFD#
7.2697 + */
7.2698 +#define __gpio_as_nand() \
7.2699 +do { \
7.2700 + REG_GPIO_PXFUNS(1) = 0x02018000; \
7.2701 + REG_GPIO_PXSELC(1) = 0x02018000; \
7.2702 + REG_GPIO_PXPES(1) = 0x02018000; \
7.2703 + REG_GPIO_PXFUNS(2) = 0x30000000; \
7.2704 + REG_GPIO_PXSELC(2) = 0x30000000; \
7.2705 + REG_GPIO_PXPES(2) = 0x30000000; \
7.2706 + REG_GPIO_PXFUNC(2) = 0x40000000; \
7.2707 + REG_GPIO_PXSELC(2) = 0x40000000; \
7.2708 + REG_GPIO_PXDIRC(2) = 0x40000000; \
7.2709 + REG_GPIO_PXPES(2) = 0x40000000; \
7.2710 + REG_GPIO_PXFUNS(1) = 0x00400000; \
7.2711 + REG_GPIO_PXSELC(1) = 0x00400000; \
7.2712 +} while (0)
7.2713 +
7.2714 +/*
7.2715 + * CS4#, RD#, WR#, WAIT#, A0 ~ A22, D0 ~ D7
7.2716 + */
7.2717 +#define __gpio_as_nor_8bit() \
7.2718 +do { \
7.2719 + REG_GPIO_PXFUNS(0) = 0x000000ff; \
7.2720 + REG_GPIO_PXSELC(0) = 0x000000ff; \
7.2721 + REG_GPIO_PXPES(0) = 0x000000ff; \
7.2722 + REG_GPIO_PXFUNS(1) = 0x7041ffff; \
7.2723 + REG_GPIO_PXSELC(1) = 0x7041ffff; \
7.2724 + REG_GPIO_PXPES(1) = 0x7041ffff; \
7.2725 + REG_GPIO_PXFUNS(1) = 0x00060000; \
7.2726 + REG_GPIO_PXSELS(1) = 0x00060000; \
7.2727 + REG_GPIO_PXPES(1) = 0x00060000; \
7.2728 + REG_GPIO_PXFUNS(2) = 0x08000000; \
7.2729 + REG_GPIO_PXSELC(2) = 0x08000000; \
7.2730 + REG_GPIO_PXPES(2) = 0x08000000; \
7.2731 + REG_GPIO_PXFUNS(2) = 0x00c00000; \
7.2732 + REG_GPIO_PXSELS(2) = 0x00c00000; \
7.2733 + REG_GPIO_PXPES(2) = 0x00c00000; \
7.2734 + REG_GPIO_PXFUNS(3) = 0x18000000; \
7.2735 + REG_GPIO_PXSELS(3) = 0x18000000; \
7.2736 + REG_GPIO_PXPES(3) = 0x18000000; \
7.2737 +} while (0)
7.2738 +
7.2739 +/*
7.2740 + * CS4#, RD#, WR#, WAIT#, A0 ~ A22, D0 ~ D15
7.2741 + */
7.2742 +#define __gpio_as_nor_16bit() \
7.2743 +do { \
7.2744 + REG_GPIO_PXFUNS(0) = 0x0000ffff; \
7.2745 + REG_GPIO_PXSELC(0) = 0x0000ffff; \
7.2746 + REG_GPIO_PXPES(0) = 0x0000ffff; \
7.2747 + REG_GPIO_PXFUNS(1) = 0x7041ffff; \
7.2748 + REG_GPIO_PXSELC(1) = 0x7041ffff; \
7.2749 + REG_GPIO_PXPES(1) = 0x7041ffff; \
7.2750 + REG_GPIO_PXFUNS(1) = 0x00060000; \
7.2751 + REG_GPIO_PXSELS(1) = 0x00060000; \
7.2752 + REG_GPIO_PXPES(1) = 0x00060000; \
7.2753 + REG_GPIO_PXFUNS(2) = 0x08000000; \
7.2754 + REG_GPIO_PXSELC(2) = 0x08000000; \
7.2755 + REG_GPIO_PXPES(2) = 0x08000000; \
7.2756 + REG_GPIO_PXFUNS(2) = 0x00c00000; \
7.2757 + REG_GPIO_PXSELS(2) = 0x00c00000; \
7.2758 + REG_GPIO_PXPES(2) = 0x00c00000; \
7.2759 + REG_GPIO_PXFUNS(3) = 0x18000000; \
7.2760 + REG_GPIO_PXSELS(3) = 0x18000000; \
7.2761 + REG_GPIO_PXPES(3) = 0x18000000; \
7.2762 +} while (0)
7.2763 +
7.2764 +/*
7.2765 + * UART0_TxD, UART_RxD0
7.2766 + */
7.2767 +#define __gpio_as_uart0() \
7.2768 +do { \
7.2769 + REG_GPIO_PXFUNS(3) = 0x06000000; \
7.2770 + REG_GPIO_PXSELS(3) = 0x06000000; \
7.2771 + REG_GPIO_PXPES(3) = 0x06000000; \
7.2772 +} while (0)
7.2773 +
7.2774 +/*
7.2775 + * UART0_CTS, UART0_RTS
7.2776 + */
7.2777 +#define __gpio_as_ctsrts() \
7.2778 +do { \
7.2779 + REG_GPIO_PXFUNS(3) = 0xc0000000; \
7.2780 + REG_GPIO_PXSELS(3) = 0xc0000000; \
7.2781 + REG_GPIO_PXTRGC(3) = 0xc0000000; \
7.2782 + REG_GPIO_PXPES(3) = 0xc0000000; \
7.2783 +} while (0)
7.2784 +
7.2785 +/*
7.2786 + * UART1_TxD, UART1_RxD1
7.2787 + */
7.2788 +#define __gpio_as_uart1() \
7.2789 +do { \
7.2790 + REG_GPIO_PXFUNS(3) = 0xc0000000; \
7.2791 + REG_GPIO_PXSELC(3) = 0xc0000000; \
7.2792 + REG_GPIO_PXTRGS(3) = 0xc0000000; \
7.2793 + REG_GPIO_PXPES(3) = 0xc0000000; \
7.2794 +} while (0)
7.2795 +
7.2796 +/*
7.2797 + * LCD_D0~LCD_D15, LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE
7.2798 + */
7.2799 +#define __gpio_as_lcd_16bit() \
7.2800 +do { \
7.2801 + REG_GPIO_PXFUNS(2) = 0x003cffff; \
7.2802 + REG_GPIO_PXSELC(2) = 0x003cffff; \
7.2803 + REG_GPIO_PXPES(2) = 0x003cffff; \
7.2804 +} while (0)
7.2805 +
7.2806 +/*
7.2807 + * LCD_D0~LCD_D17, LCD_PCLK, LCD_HSYNC, LCD_VSYNC, LCD_DE
7.2808 + */
7.2809 +#define __gpio_as_lcd_18bit() \
7.2810 +do { \
7.2811 + REG_GPIO_PXFUNS(2) = 0x003fffff; \
7.2812 + REG_GPIO_PXSELC(2) = 0x003fffff; \
7.2813 + REG_GPIO_PXPES(2) = 0x003fffff; \
7.2814 +} while (0)
7.2815 +
7.2816 +/*
7.2817 + * CIM_D0~CIM_D7, CIM_MCLK, CIM_PCLK, CIM_VSYNC, CIM_HSYNC
7.2818 + */
7.2819 +#define __gpio_as_cim() \
7.2820 +do { \
7.2821 + REG_GPIO_PXFUNS(3) = 0x0003c0ff; \
7.2822 + REG_GPIO_PXSELC(3) = 0x0003c0ff; \
7.2823 + REG_GPIO_PXPES(3) = 0x0003c0ff; \
7.2824 +} while (0)
7.2825 +
7.2826 +/*
7.2827 + * SDATA_OUT, SDATA_IN, BIT_CLK, SYNC, SCLK_RESET
7.2828 + */
7.2829 +#define __gpio_as_aic() \
7.2830 +do { \
7.2831 + REG_GPIO_PXFUNS(3) = 0x007c0000; \
7.2832 + REG_GPIO_PXSELS(3) = 0x007c0000; \
7.2833 + REG_GPIO_PXPES(3) = 0x007c0000; \
7.2834 +} while (0)
7.2835 +
7.2836 +/*
7.2837 + * MSC_CMD, MSC_CLK, MSC_D0 ~ MSC_D3
7.2838 + */
7.2839 +#define __gpio_as_msc() \
7.2840 +do { \
7.2841 + REG_GPIO_PXFUNS(3) = 0x00003f00; \
7.2842 + REG_GPIO_PXSELC(3) = 0x00003f00; \
7.2843 + REG_GPIO_PXPES(3) = 0x00003f00; \
7.2844 +} while (0)
7.2845 +
7.2846 +/*
7.2847 + * SSI_CS0, SSI_CLK, SSI_DT, SSI_DR
7.2848 + */
7.2849 +#define __gpio_as_ssi() \
7.2850 +do { \
7.2851 + REG_GPIO_PXFUNS(3) = 0x003c0000; \
7.2852 + REG_GPIO_PXSELC(3) = 0x003c0000; \
7.2853 + REG_GPIO_PXPES(3) = 0x003c0000; \
7.2854 +} while (0)
7.2855 +
7.2856 +/*
7.2857 + * I2C_SCK, I2C_SDA
7.2858 + */
7.2859 +#define __gpio_as_i2c() \
7.2860 +do { \
7.2861 + REG_GPIO_PXFUNS(3) = 0x01800000; \
7.2862 + REG_GPIO_PXSELS(3) = 0x01800000; \
7.2863 + REG_GPIO_PXPES(3) = 0x01800000; \
7.2864 +} while (0)
7.2865 +
7.2866 +/*
7.2867 + * PWM0
7.2868 + */
7.2869 +#define __gpio_as_pwm0() \
7.2870 +do { \
7.2871 + REG_GPIO_PXFUNS(3) = 0x00800000; \
7.2872 + REG_GPIO_PXSELC(3) = 0x00800000; \
7.2873 + REG_GPIO_PXPES(3) = 0x00800000; \
7.2874 +} while (0)
7.2875 +
7.2876 +/*
7.2877 + * PWM1
7.2878 + */
7.2879 +#define __gpio_as_pwm1() \
7.2880 +do { \
7.2881 + REG_GPIO_PXFUNS(3) = 0x01000000; \
7.2882 + REG_GPIO_PXSELC(3) = 0x01000000; \
7.2883 + REG_GPIO_PXPES(3) = 0x01000000; \
7.2884 +} while (0)
7.2885 +
7.2886 +/*
7.2887 + * PWM2
7.2888 + */
7.2889 +#define __gpio_as_pwm2() \
7.2890 +do { \
7.2891 + REG_GPIO_PXFUNS(3) = 0x02000000; \
7.2892 + REG_GPIO_PXSELC(3) = 0x02000000; \
7.2893 + REG_GPIO_PXPES(3) = 0x02000000; \
7.2894 +} while (0)
7.2895 +
7.2896 +/*
7.2897 + * PWM3
7.2898 + */
7.2899 +#define __gpio_as_pwm3() \
7.2900 +do { \
7.2901 + REG_GPIO_PXFUNS(3) = 0x04000000; \
7.2902 + REG_GPIO_PXSELC(3) = 0x04000000; \
7.2903 + REG_GPIO_PXPES(3) = 0x04000000; \
7.2904 +} while (0)
7.2905 +
7.2906 +/*
7.2907 + * PWM4
7.2908 + */
7.2909 +#define __gpio_as_pwm4() \
7.2910 +do { \
7.2911 + REG_GPIO_PXFUNS(3) = 0x08000000; \
7.2912 + REG_GPIO_PXSELC(3) = 0x08000000; \
7.2913 + REG_GPIO_PXPES(3) = 0x08000000; \
7.2914 +} while (0)
7.2915 +
7.2916 +/*
7.2917 + * PWM5
7.2918 + */
7.2919 +#define __gpio_as_pwm5() \
7.2920 +do { \
7.2921 + REG_GPIO_PXFUNS(3) = 0x10000000; \
7.2922 + REG_GPIO_PXSELC(3) = 0x10000000; \
7.2923 + REG_GPIO_PXPES(3) = 0x10000000; \
7.2924 +} while (0)
7.2925 +
7.2926 +/*
7.2927 + * PWM6
7.2928 + */
7.2929 +#define __gpio_as_pwm6() \
7.2930 +do { \
7.2931 + REG_GPIO_PXFUNS(3) = 0x40000000; \
7.2932 + REG_GPIO_PXSELC(3) = 0x40000000; \
7.2933 + REG_GPIO_PXPES(3) = 0x40000000; \
7.2934 +} while (0)
7.2935 +
7.2936 +/*
7.2937 + * PWM7
7.2938 + */
7.2939 +#define __gpio_as_pwm7() \
7.2940 +do { \
7.2941 + REG_GPIO_PXFUNS(3) = 0x80000000; \
7.2942 + REG_GPIO_PXSELC(3) = 0x80000000; \
7.2943 + REG_GPIO_PXPES(3) = 0x80000000; \
7.2944 +} while (0)
7.2945 +
7.2946 +/*
7.2947 + * n = 0 ~ 7
7.2948 + */
7.2949 +#define __gpio_as_pwm(n) __gpio_as_pwm##n()
7.2950 +
7.2951 +//-------------------------------------------
7.2952 +// GPIO or Interrupt Mode
7.2953 +
7.2954 +#define __gpio_get_port(p) (REG_GPIO_PXPIN(p))
7.2955 +
7.2956 +#define __gpio_port_as_output(p, o) \
7.2957 +do { \
7.2958 + REG_GPIO_PXFUNC(p) = (1 << (o)); \
7.2959 + REG_GPIO_PXSELC(p) = (1 << (o)); \
7.2960 + REG_GPIO_PXDIRS(p) = (1 << (o)); \
7.2961 +} while (0)
7.2962 +
7.2963 +#define __gpio_port_as_input(p, o) \
7.2964 +do { \
7.2965 + REG_GPIO_PXFUNC(p) = (1 << (o)); \
7.2966 + REG_GPIO_PXSELC(p) = (1 << (o)); \
7.2967 + REG_GPIO_PXDIRC(p) = (1 << (o)); \
7.2968 +} while (0)
7.2969 +
7.2970 +#define __gpio_as_output(n) \
7.2971 +do { \
7.2972 + unsigned int p, o; \
7.2973 + p = (n) / 32; \
7.2974 + o = (n) % 32; \
7.2975 + __gpio_port_as_output(p, o); \
7.2976 +} while (0)
7.2977 +
7.2978 +#define __gpio_as_input(n) \
7.2979 +do { \
7.2980 + unsigned int p, o; \
7.2981 + p = (n) / 32; \
7.2982 + o = (n) % 32; \
7.2983 + __gpio_port_as_input(p, o); \
7.2984 +} while (0)
7.2985 +
7.2986 +#define __gpio_set_pin(n) \
7.2987 +do { \
7.2988 + unsigned int p, o; \
7.2989 + p = (n) / 32; \
7.2990 + o = (n) % 32; \
7.2991 + REG_GPIO_PXDATS(p) = (1 << o); \
7.2992 +} while (0)
7.2993 +
7.2994 +#define __gpio_clear_pin(n) \
7.2995 +do { \
7.2996 + unsigned int p, o; \
7.2997 + p = (n) / 32; \
7.2998 + o = (n) % 32; \
7.2999 + REG_GPIO_PXDATC(p) = (1 << o); \
7.3000 +} while (0)
7.3001 +
7.3002 +#define __gpio_get_pin(n) \
7.3003 +({ \
7.3004 + unsigned int p, o, v; \
7.3005 + p = (n) / 32; \
7.3006 + o = (n) % 32; \
7.3007 + if (__gpio_get_port(p) & (1 << o)) \
7.3008 + v = 1; \
7.3009 + else \
7.3010 + v = 0; \
7.3011 + v; \
7.3012 +})
7.3013 +
7.3014 +#define __gpio_as_irq_high_level(n) \
7.3015 +do { \
7.3016 + unsigned int p, o; \
7.3017 + p = (n) / 32; \
7.3018 + o = (n) % 32; \
7.3019 + REG_GPIO_PXIMS(p) = (1 << o); \
7.3020 + REG_GPIO_PXTRGC(p) = (1 << o); \
7.3021 + REG_GPIO_PXFUNC(p) = (1 << o); \
7.3022 + REG_GPIO_PXSELS(p) = (1 << o); \
7.3023 + REG_GPIO_PXDIRS(p) = (1 << o); \
7.3024 + REG_GPIO_PXFLGC(p) = (1 << o); \
7.3025 + REG_GPIO_PXIMC(p) = (1 << o); \
7.3026 +} while (0)
7.3027 +
7.3028 +#define __gpio_as_irq_low_level(n) \
7.3029 +do { \
7.3030 + unsigned int p, o; \
7.3031 + p = (n) / 32; \
7.3032 + o = (n) % 32; \
7.3033 + REG_GPIO_PXIMS(p) = (1 << o); \
7.3034 + REG_GPIO_PXTRGC(p) = (1 << o); \
7.3035 + REG_GPIO_PXFUNC(p) = (1 << o); \
7.3036 + REG_GPIO_PXSELS(p) = (1 << o); \
7.3037 + REG_GPIO_PXDIRC(p) = (1 << o); \
7.3038 + REG_GPIO_PXFLGC(p) = (1 << o); \
7.3039 + REG_GPIO_PXIMC(p) = (1 << o); \
7.3040 +} while (0)
7.3041 +
7.3042 +#define __gpio_as_irq_rise_edge(n) \
7.3043 +do { \
7.3044 + unsigned int p, o; \
7.3045 + p = (n) / 32; \
7.3046 + o = (n) % 32; \
7.3047 + REG_GPIO_PXIMS(p) = (1 << o); \
7.3048 + REG_GPIO_PXTRGS(p) = (1 << o); \
7.3049 + REG_GPIO_PXFUNC(p) = (1 << o); \
7.3050 + REG_GPIO_PXSELS(p) = (1 << o); \
7.3051 + REG_GPIO_PXDIRS(p) = (1 << o); \
7.3052 + REG_GPIO_PXFLGC(p) = (1 << o); \
7.3053 + REG_GPIO_PXIMC(p) = (1 << o); \
7.3054 +} while (0)
7.3055 +
7.3056 +#define __gpio_as_irq_fall_edge(n) \
7.3057 +do { \
7.3058 + unsigned int p, o; \
7.3059 + p = (n) / 32; \
7.3060 + o = (n) % 32; \
7.3061 + REG_GPIO_PXIMS(p) = (1 << o); \
7.3062 + REG_GPIO_PXTRGS(p) = (1 << o); \
7.3063 + REG_GPIO_PXFUNC(p) = (1 << o); \
7.3064 + REG_GPIO_PXSELS(p) = (1 << o); \
7.3065 + REG_GPIO_PXDIRC(p) = (1 << o); \
7.3066 + REG_GPIO_PXFLGC(p) = (1 << o); \
7.3067 + REG_GPIO_PXIMC(p) = (1 << o); \
7.3068 +} while (0)
7.3069 +
7.3070 +#define __gpio_mask_irq(n) \
7.3071 +do { \
7.3072 + unsigned int p, o; \
7.3073 + p = (n) / 32; \
7.3074 + o = (n) % 32; \
7.3075 + REG_GPIO_PXIMS(p) = (1 << o); \
7.3076 +} while (0)
7.3077 +
7.3078 +#define __gpio_unmask_irq(n) \
7.3079 +do { \
7.3080 + unsigned int p, o; \
7.3081 + p = (n) / 32; \
7.3082 + o = (n) % 32; \
7.3083 + REG_GPIO_PXIMC(p) = (1 << o); \
7.3084 +} while (0)
7.3085 +
7.3086 +#define __gpio_ack_irq(n) \
7.3087 +do { \
7.3088 + unsigned int p, o; \
7.3089 + p = (n) / 32; \
7.3090 + o = (n) % 32; \
7.3091 + REG_GPIO_PXFLGC(p) = (1 << o); \
7.3092 +} while (0)
7.3093 +
7.3094 +#define __gpio_get_irq() \
7.3095 +({ \
7.3096 + unsigned int p, i, tmp, v = 0; \
7.3097 + for (p = 3; p >= 0; p--) { \
7.3098 + tmp = REG_GPIO_PXFLG(p); \
7.3099 + for (i = 0; i < 32; i++) \
7.3100 + if (tmp & (1 << i)) \
7.3101 + v = (32*p + i); \
7.3102 + } \
7.3103 + v; \
7.3104 +})
7.3105 +
7.3106 +#define __gpio_group_irq(n) \
7.3107 +({ \
7.3108 + register int tmp, i; \
7.3109 + tmp = REG_GPIO_PXFLG((n)); \
7.3110 + for (i=31;i>=0;i--) \
7.3111 + if (tmp & (1 << i)) \
7.3112 + break; \
7.3113 + i; \
7.3114 +})
7.3115 +
7.3116 +#define __gpio_enable_pull(n) \
7.3117 +do { \
7.3118 + unsigned int p, o; \
7.3119 + p = (n) / 32; \
7.3120 + o = (n) % 32; \
7.3121 + REG_GPIO_PXPEC(p) = (1 << o); \
7.3122 +} while (0)
7.3123 +
7.3124 +#define __gpio_disable_pull(n) \
7.3125 +do { \
7.3126 + unsigned int p, o; \
7.3127 + p = (n) / 32; \
7.3128 + o = (n) % 32; \
7.3129 + REG_GPIO_PXPES(p) = (1 << o); \
7.3130 +} while (0)
7.3131 +
7.3132 +
7.3133 +/***************************************************************************
7.3134 + * CPM
7.3135 + ***************************************************************************/
7.3136 +#define __cpm_get_pllm() \
7.3137 + ((REG_CPM_CPPCR & CPM_CPPCR_PLLM_MASK) >> CPM_CPPCR_PLLM_BIT)
7.3138 +#define __cpm_get_plln() \
7.3139 + ((REG_CPM_CPPCR & CPM_CPPCR_PLLN_MASK) >> CPM_CPPCR_PLLN_BIT)
7.3140 +#define __cpm_get_pllod() \
7.3141 + ((REG_CPM_CPPCR & CPM_CPPCR_PLLOD_MASK) >> CPM_CPPCR_PLLOD_BIT)
7.3142 +
7.3143 +#define __cpm_get_cdiv() \
7.3144 + ((REG_CPM_CPCCR & CPM_CPCCR_CDIV_MASK) >> CPM_CPCCR_CDIV_BIT)
7.3145 +#define __cpm_get_hdiv() \
7.3146 + ((REG_CPM_CPCCR & CPM_CPCCR_HDIV_MASK) >> CPM_CPCCR_HDIV_BIT)
7.3147 +#define __cpm_get_pdiv() \
7.3148 + ((REG_CPM_CPCCR & CPM_CPCCR_PDIV_MASK) >> CPM_CPCCR_PDIV_BIT)
7.3149 +#define __cpm_get_mdiv() \
7.3150 + ((REG_CPM_CPCCR & CPM_CPCCR_MDIV_MASK) >> CPM_CPCCR_MDIV_BIT)
7.3151 +#define __cpm_get_ldiv() \
7.3152 + ((REG_CPM_CPCCR & CPM_CPCCR_LDIV_MASK) >> CPM_CPCCR_LDIV_BIT)
7.3153 +#define __cpm_get_udiv() \
7.3154 + ((REG_CPM_CPCCR & CPM_CPCCR_UDIV_MASK) >> CPM_CPCCR_UDIV_BIT)
7.3155 +#define __cpm_get_i2sdiv() \
7.3156 + ((REG_CPM_I2SCDR & CPM_I2SCDR_I2SDIV_MASK) >> CPM_I2SCDR_I2SDIV_BIT)
7.3157 +#define __cpm_get_pixdiv() \
7.3158 + ((REG_CPM_LPCDR & CPM_LPCDR_PIXDIV_MASK) >> CPM_LPCDR_PIXDIV_BIT)
7.3159 +#define __cpm_get_mscdiv() \
7.3160 + ((REG_CPM_MSCCDR & CPM_MSCCDR_MSCDIV_MASK) >> CPM_MSCCDR_MSCDIV_BIT)
7.3161 +
7.3162 +#define __cpm_set_cdiv(v) \
7.3163 + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_CDIV_MASK) | ((v) << (CPM_CPCCR_CDIV_BIT)))
7.3164 +#define __cpm_set_hdiv(v) \
7.3165 + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_HDIV_MASK) | ((v) << (CPM_CPCCR_HDIV_BIT)))
7.3166 +#define __cpm_set_pdiv(v) \
7.3167 + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_PDIV_MASK) | ((v) << (CPM_CPCCR_PDIV_BIT)))
7.3168 +#define __cpm_set_mdiv(v) \
7.3169 + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_MDIV_MASK) | ((v) << (CPM_CPCCR_MDIV_BIT)))
7.3170 +#define __cpm_set_ldiv(v) \
7.3171 + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_LDIV_MASK) | ((v) << (CPM_CPCCR_LDIV_BIT)))
7.3172 +#define __cpm_set_udiv(v) \
7.3173 + (REG_CPM_CPCCR = (REG_CPM_CPCCR & ~CPM_CPCCR_UDIV_MASK) | ((v) << (CPM_CPCCR_UDIV_BIT)))
7.3174 +#define __cpm_set_i2sdiv(v) \
7.3175 + (REG_CPM_I2SCDR = (REG_CPM_I2SCDR & ~CPM_I2SCDR_I2SDIV_MASK) | ((v) << (CPM_I2SCDR_I2SDIV_BIT)))
7.3176 +#define __cpm_set_pixdiv(v) \
7.3177 + (REG_CPM_LPCDR = (REG_CPM_LPCDR & ~CPM_LPCDR_PIXDIV_MASK) | ((v) << (CPM_LPCDR_PIXDIV_BIT)))
7.3178 +#define __cpm_set_mscdiv(v) \
7.3179 + (REG_CPM_MSCCDR = (REG_CPM_MSCCDR & ~CPM_MSCCDR_MSCDIV_MASK) | ((v) << (CPM_MSCCDR_MSCDIV_BIT)))
7.3180 +
7.3181 +#define __cpm_select_i2sclk_exclk() (REG_CPM_CPCCR &= ~CPM_CPCCR_I2CS)
7.3182 +#define __cpm_select_i2sclk_pll() (REG_CPM_CPCCR |= CPM_CPCCR_I2CS)
7.3183 +#define __cpm_enable_cko() (REG_CPM_CPCCR |= CPM_CPCCR_CLKOEN)
7.3184 +#define __cpm_select_usbclk_exclk() (REG_CPM_CPCCR &= ~CPM_CPCCR_UCS)
7.3185 +#define __cpm_select_usbclk_pll() (REG_CPM_CPCCR |= CPM_CPCCR_UCS)
7.3186 +#define __cpm_enable_pll_change() (REG_CPM_CPCCR |= CPM_CPCCR_CE)
7.3187 +#define __cpm_pllout_direct() (REG_CPM_CPCCR |= CPM_CPCCR_PCS)
7.3188 +#define __cpm_pllout_div2() (REG_CPM_CPCCR &= ~CPM_CPCCR_PCS)
7.3189 +
7.3190 +#define __cpm_pll_is_on() (REG_CPM_CPPCR & CPM_CPPCR_PLLS)
7.3191 +#define __cpm_pll_bypass() (REG_CPM_CPPCR |= CPM_CPPCR_PLLBP)
7.3192 +#define __cpm_pll_enable() (REG_CPM_CPPCR |= CPM_CPPCR_PLLEN)
7.3193 +
7.3194 +#define __cpm_get_cclk_doze_duty() \
7.3195 + ((REG_CPM_LCR & CPM_LCR_DOZE_DUTY_MASK) >> CPM_LCR_DOZE_DUTY_BIT)
7.3196 +#define __cpm_set_cclk_doze_duty(v) \
7.3197 + (REG_CPM_LCR = (REG_CPM_LCR & ~CPM_LCR_DOZE_DUTY_MASK) | ((v) << (CPM_LCR_DOZE_DUTY_BIT)))
7.3198 +
7.3199 +#define __cpm_doze_mode() (REG_CPM_LCR |= CPM_LCR_DOZE_ON)
7.3200 +#define __cpm_idle_mode() \
7.3201 + (REG_CPM_LCR = (REG_CPM_LCR & ~CPM_LCR_LPM_MASK) | CPM_LCR_LPM_IDLE)
7.3202 +#define __cpm_sleep_mode() \
7.3203 + (REG_CPM_LCR = (REG_CPM_LCR & ~CPM_LCR_LPM_MASK) | CPM_LCR_LPM_SLEEP)
7.3204 +
7.3205 +#define __cpm_stop_all() (REG_CPM_CLKGR = 0x7fff)
7.3206 +#define __cpm_stop_uart1() (REG_CPM_CLKGR |= CPM_CLKGR_UART1)
7.3207 +#define __cpm_stop_uhc() (REG_CPM_CLKGR |= CPM_CLKGR_UHC)
7.3208 +#define __cpm_stop_ipu() (REG_CPM_CLKGR |= CPM_CLKGR_IPU)
7.3209 +#define __cpm_stop_dmac() (REG_CPM_CLKGR |= CPM_CLKGR_DMAC)
7.3210 +#define __cpm_stop_udc() (REG_CPM_CLKGR |= CPM_CLKGR_UDC)
7.3211 +#define __cpm_stop_lcd() (REG_CPM_CLKGR |= CPM_CLKGR_LCD)
7.3212 +#define __cpm_stop_cim() (REG_CPM_CLKGR |= CPM_CLKGR_CIM)
7.3213 +#define __cpm_stop_sadc() (REG_CPM_CLKGR |= CPM_CLKGR_SADC)
7.3214 +#define __cpm_stop_msc() (REG_CPM_CLKGR |= CPM_CLKGR_MSC)
7.3215 +#define __cpm_stop_aic1() (REG_CPM_CLKGR |= CPM_CLKGR_AIC1)
7.3216 +#define __cpm_stop_aic2() (REG_CPM_CLKGR |= CPM_CLKGR_AIC2)
7.3217 +#define __cpm_stop_ssi() (REG_CPM_CLKGR |= CPM_CLKGR_SSI)
7.3218 +#define __cpm_stop_i2c() (REG_CPM_CLKGR |= CPM_CLKGR_I2C)
7.3219 +#define __cpm_stop_rtc() (REG_CPM_CLKGR |= CPM_CLKGR_RTC)
7.3220 +#define __cpm_stop_tcu() (REG_CPM_CLKGR |= CPM_CLKGR_TCU)
7.3221 +#define __cpm_stop_uart0() (REG_CPM_CLKGR |= CPM_CLKGR_UART0)
7.3222 +
7.3223 +#define __cpm_start_all() (REG_CPM_CLKGR = 0x0)
7.3224 +#define __cpm_start_uart1() (REG_CPM_CLKGR &= ~CPM_CLKGR_UART1)
7.3225 +#define __cpm_start_uhc() (REG_CPM_CLKGR &= ~CPM_CLKGR_UHC)
7.3226 +#define __cpm_start_ipu() (REG_CPM_CLKGR &= ~CPM_CLKGR_IPU)
7.3227 +#define __cpm_start_dmac() (REG_CPM_CLKGR &= ~CPM_CLKGR_DMAC)
7.3228 +#define __cpm_start_udc() (REG_CPM_CLKGR &= ~CPM_CLKGR_UDC)
7.3229 +#define __cpm_start_lcd() (REG_CPM_CLKGR &= ~CPM_CLKGR_LCD)
7.3230 +#define __cpm_start_cim() (REG_CPM_CLKGR &= ~CPM_CLKGR_CIM)
7.3231 +#define __cpm_start_sadc() (REG_CPM_CLKGR &= ~CPM_CLKGR_SADC)
7.3232 +#define __cpm_start_msc() (REG_CPM_CLKGR &= ~CPM_CLKGR_MSC)
7.3233 +#define __cpm_start_aic1() (REG_CPM_CLKGR &= ~CPM_CLKGR_AIC1)
7.3234 +#define __cpm_start_aic2() (REG_CPM_CLKGR &= ~CPM_CLKGR_AIC2)
7.3235 +#define __cpm_start_ssi() (REG_CPM_CLKGR &= ~CPM_CLKGR_SSI)
7.3236 +#define __cpm_start_i2c() (REG_CPM_CLKGR &= ~CPM_CLKGR_I2C)
7.3237 +#define __cpm_start_rtc() (REG_CPM_CLKGR &= ~CPM_CLKGR_RTC)
7.3238 +#define __cpm_start_tcu() (REG_CPM_CLKGR &= ~CPM_CLKGR_TCU)
7.3239 +#define __cpm_start_uart0() (REG_CPM_CLKGR &= ~CPM_CLKGR_UART0)
7.3240 +
7.3241 +#define __cpm_get_o1st() \
7.3242 + ((REG_CPM_SCR & CPM_SCR_O1ST_MASK) >> CPM_SCR_O1ST_BIT)
7.3243 +#define __cpm_set_o1st(v) \
7.3244 + (REG_CPM_SCR = (REG_CPM_SCR & ~CPM_SCR_O1ST_MASK) | ((v) << (CPM_SCR_O1ST_BIT)))
7.3245 +#define __cpm_suspend_usbphy() (REG_CPM_SCR |= CPM_SCR_USBPHY_SUSPEND)
7.3246 +#define __cpm_enable_osc_in_sleep() (REG_CPM_SCR |= CPM_SCR_OSC_ENABLE)
7.3247 +
7.3248 +
7.3249 +#ifdef CFG_EXTAL
7.3250 +#define JZ_EXTAL CFG_EXTAL
7.3251 +#else
7.3252 +#define JZ_EXTAL 3686400
7.3253 +#endif
7.3254 +#define JZ_EXTAL2 32768 /* RTC clock */
7.3255 +
7.3256 +/* PLL output frequency */
7.3257 +static __inline__ unsigned int __cpm_get_pllout(void)
7.3258 +{
7.3259 + unsigned long m, n, no, pllout;
7.3260 + unsigned long cppcr = REG_CPM_CPPCR;
7.3261 + unsigned long od[4] = {1, 2, 2, 4};
7.3262 + if ((cppcr & CPM_CPPCR_PLLEN) && !(cppcr & CPM_CPPCR_PLLBP)) {
7.3263 + m = __cpm_get_pllm() + 2;
7.3264 + n = __cpm_get_plln() + 2;
7.3265 + no = od[__cpm_get_pllod()];
7.3266 + pllout = ((JZ_EXTAL) / (n * no)) * m;
7.3267 + } else
7.3268 + pllout = JZ_EXTAL;
7.3269 + return pllout;
7.3270 +}
7.3271 +
7.3272 +/* PLL output frequency for MSC/I2S/LCD/USB */
7.3273 +static __inline__ unsigned int __cpm_get_pllout2(void)
7.3274 +{
7.3275 + if (REG_CPM_CPCCR & CPM_CPCCR_PCS)
7.3276 + return __cpm_get_pllout();
7.3277 + else
7.3278 + return __cpm_get_pllout()/2;
7.3279 +}
7.3280 +
7.3281 +/* CPU core clock */
7.3282 +static __inline__ unsigned int __cpm_get_cclk(void)
7.3283 +{
7.3284 + int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
7.3285 +
7.3286 + return __cpm_get_pllout() / div[__cpm_get_cdiv()];
7.3287 +}
7.3288 +
7.3289 +/* AHB system bus clock */
7.3290 +static __inline__ unsigned int __cpm_get_hclk(void)
7.3291 +{
7.3292 + int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
7.3293 +
7.3294 + return __cpm_get_pllout() / div[__cpm_get_hdiv()];
7.3295 +}
7.3296 +
7.3297 +/* Memory bus clock */
7.3298 +static __inline__ unsigned int __cpm_get_mclk(void)
7.3299 +{
7.3300 + int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
7.3301 +
7.3302 + return __cpm_get_pllout() / div[__cpm_get_mdiv()];
7.3303 +}
7.3304 +
7.3305 +/* APB peripheral bus clock */
7.3306 +static __inline__ unsigned int __cpm_get_pclk(void)
7.3307 +{
7.3308 + int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
7.3309 +
7.3310 + return __cpm_get_pllout() / div[__cpm_get_pdiv()];
7.3311 +}
7.3312 +
7.3313 +/* LCDC module clock */
7.3314 +static __inline__ unsigned int __cpm_get_lcdclk(void)
7.3315 +{
7.3316 + return __cpm_get_pllout2() / (__cpm_get_ldiv() + 1);
7.3317 +}
7.3318 +
7.3319 +/* LCD pixel clock */
7.3320 +static __inline__ unsigned int __cpm_get_pixclk(void)
7.3321 +{
7.3322 + return __cpm_get_pllout2() / (__cpm_get_pixdiv() + 1);
7.3323 +}
7.3324 +
7.3325 +/* I2S clock */
7.3326 +static __inline__ unsigned int __cpm_get_i2sclk(void)
7.3327 +{
7.3328 + if (REG_CPM_CPCCR & CPM_CPCCR_I2CS) {
7.3329 + return __cpm_get_pllout2() / (__cpm_get_i2sdiv() + 1);
7.3330 + }
7.3331 + else {
7.3332 + return JZ_EXTAL;
7.3333 + }
7.3334 +}
7.3335 +
7.3336 +/* USB clock */
7.3337 +static __inline__ unsigned int __cpm_get_usbclk(void)
7.3338 +{
7.3339 + if (REG_CPM_CPCCR & CPM_CPCCR_UCS) {
7.3340 + return __cpm_get_pllout2() / (__cpm_get_udiv() + 1);
7.3341 + }
7.3342 + else {
7.3343 + return JZ_EXTAL;
7.3344 + }
7.3345 +}
7.3346 +
7.3347 +/* MSC clock */
7.3348 +static __inline__ unsigned int __cpm_get_mscclk(void)
7.3349 +{
7.3350 + return __cpm_get_pllout2() / (__cpm_get_mscdiv() + 1);
7.3351 +}
7.3352 +
7.3353 +/* EXTAL clock for UART,I2C,SSI,TCU,USB-PHY */
7.3354 +static __inline__ unsigned int __cpm_get_extalclk(void)
7.3355 +{
7.3356 + return JZ_EXTAL;
7.3357 +}
7.3358 +
7.3359 +/* RTC clock for CPM,INTC,RTC,TCU,WDT */
7.3360 +static __inline__ unsigned int __cpm_get_rtcclk(void)
7.3361 +{
7.3362 + return JZ_EXTAL2;
7.3363 +}
7.3364 +
7.3365 +/*
7.3366 + * Output 24MHz for SD and 16MHz for MMC.
7.3367 + */
7.3368 +static inline void __cpm_select_msc_clk(int sd)
7.3369 +{
7.3370 + unsigned int pllout2 = __cpm_get_pllout2();
7.3371 + unsigned int div = 0;
7.3372 +
7.3373 + if (sd) {
7.3374 + div = pllout2 / 24000000;
7.3375 + }
7.3376 + else {
7.3377 + div = pllout2 / 16000000;
7.3378 + }
7.3379 +
7.3380 + REG_CPM_MSCCDR = div - 1;
7.3381 +}
7.3382 +
7.3383 +/***************************************************************************
7.3384 + * TCU
7.3385 + ***************************************************************************/
7.3386 +// where 'n' is the TCU channel
7.3387 +#define __tcu_select_extalclk(n) \
7.3388 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCU_TCSR_EXT_EN | TCU_TCSR_RTC_EN | TCU_TCSR_PCK_EN)) | TCU_TCSR_EXT_EN)
7.3389 +#define __tcu_select_rtcclk(n) \
7.3390 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCU_TCSR_EXT_EN | TCU_TCSR_RTC_EN | TCU_TCSR_PCK_EN)) | TCU_TCSR_RTC_EN)
7.3391 +#define __tcu_select_pclk(n) \
7.3392 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~(TCU_TCSR_EXT_EN | TCU_TCSR_RTC_EN | TCU_TCSR_PCK_EN)) | TCU_TCSR_PCK_EN)
7.3393 +
7.3394 +#define __tcu_select_clk_div1(n) \
7.3395 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE1)
7.3396 +#define __tcu_select_clk_div4(n) \
7.3397 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE4)
7.3398 +#define __tcu_select_clk_div16(n) \
7.3399 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE16)
7.3400 +#define __tcu_select_clk_div64(n) \
7.3401 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE64)
7.3402 +#define __tcu_select_clk_div256(n) \
7.3403 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE256)
7.3404 +#define __tcu_select_clk_div1024(n) \
7.3405 + (REG_TCU_TCSR((n)) = (REG_TCU_TCSR((n)) & ~TCU_TCSR_PRESCALE_MASK) | TCU_TCSR_PRESCALE1024)
7.3406 +
7.3407 +#define __tcu_enable_pwm_output(n) ( REG_TCU_TCSR((n)) |= TCU_TCSR_PWM_EN )
7.3408 +#define __tcu_disable_pwm_output(n) ( REG_TCU_TCSR((n)) &= ~TCU_TCSR_PWM_EN )
7.3409 +
7.3410 +#define __tcu_init_pwm_output_high(n) ( REG_TCU_TCSR((n)) |= TCU_TCSR_PWM_INITL_HIGH )
7.3411 +#define __tcu_init_pwm_output_low(n) ( REG_TCU_TCSR((n)) &= ~TCU_TCSR_PWM_INITL_HIGH )
7.3412 +
7.3413 +#define __tcu_set_pwm_output_shutdown_graceful(n) ( REG_TCU_TCSR((n)) &= ~TCU_TCSR_PWM_SD )
7.3414 +#define __tcu_set_pwm_output_shutdown_abrupt(n) ( REG_TCU_TCSR((n)) |= TCU_TCSR_PWM_SD )
7.3415 +
7.3416 +#define __tcu_start_counter(n) ( REG_TCU_TESR |= (1 << (n)) )
7.3417 +#define __tcu_stop_counter(n) ( REG_TCU_TECR |= (1 << (n)) )
7.3418 +
7.3419 +#define __tcu_half_match_flag(n) ( REG_TCU_TFR & (1 << ((n) + 16)) )
7.3420 +#define __tcu_full_match_flag(n) ( REG_TCU_TFR & (1 << (n)) )
7.3421 +#define __tcu_set_half_match_flag(n) ( REG_TCU_TFSR = (1 << ((n) + 16)) )
7.3422 +#define __tcu_set_full_match_flag(n) ( REG_TCU_TFSR = (1 << (n)) )
7.3423 +#define __tcu_clear_half_match_flag(n) ( REG_TCU_TFCR = (1 << ((n) + 16)) )
7.3424 +#define __tcu_clear_full_match_flag(n) ( REG_TCU_TFCR = (1 << (n)) )
7.3425 +#define __tcu_mask_half_match_irq(n) ( REG_TCU_TMSR = (1 << ((n) + 16)) )
7.3426 +#define __tcu_mask_full_match_irq(n) ( REG_TCU_TMSR = (1 << (n)) )
7.3427 +#define __tcu_unmask_half_match_irq(n) ( REG_TCU_TMCR = (1 << ((n) + 16)) )
7.3428 +#define __tcu_unmask_full_match_irq(n) ( REG_TCU_TMCR = (1 << (n)) )
7.3429 +
7.3430 +#define __tcu_wdt_clock_stopped() ( REG_TCU_TSR & TCU_TSSR_WDTSC )
7.3431 +#define __tcu_timer_clock_stopped(n) ( REG_TCU_TSR & (1 << (n)) )
7.3432 +
7.3433 +#define __tcu_start_wdt_clock() ( REG_TCU_TSCR = TCU_TSSR_WDTSC )
7.3434 +#define __tcu_start_timer_clock(n) ( REG_TCU_TSCR = (1 << (n)) )
7.3435 +
7.3436 +#define __tcu_stop_wdt_clock() ( REG_TCU_TSSR = TCU_TSSR_WDTSC )
7.3437 +#define __tcu_stop_timer_clock(n) ( REG_TCU_TSSR = (1 << (n)) )
7.3438 +
7.3439 +#define __tcu_get_count(n) ( REG_TCU_TCNT((n)) )
7.3440 +#define __tcu_set_count(n,v) ( REG_TCU_TCNT((n)) = (v) )
7.3441 +#define __tcu_set_full_data(n,v) ( REG_TCU_TDFR((n)) = (v) )
7.3442 +#define __tcu_set_half_data(n,v) ( REG_TCU_TDHR((n)) = (v) )
7.3443 +
7.3444 +
7.3445 +/***************************************************************************
7.3446 + * WDT
7.3447 + ***************************************************************************/
7.3448 +#define __wdt_start() ( REG_WDT_TCER |= WDT_TCER_TCEN )
7.3449 +#define __wdt_stop() ( REG_WDT_TCER &= ~WDT_TCER_TCEN )
7.3450 +#define __wdt_set_count(v) ( REG_WDT_TCNT = (v) )
7.3451 +#define __wdt_set_data(v) ( REG_WDT_TDR = (v) )
7.3452 +
7.3453 +#define __wdt_select_extalclk() \
7.3454 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~(WDT_TCSR_EXT_EN | WDT_TCSR_RTC_EN | WDT_TCSR_PCK_EN)) | WDT_TCSR_EXT_EN)
7.3455 +#define __wdt_select_rtcclk() \
7.3456 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~(WDT_TCSR_EXT_EN | WDT_TCSR_RTC_EN | WDT_TCSR_PCK_EN)) | WDT_TCSR_RTC_EN)
7.3457 +#define __wdt_select_pclk() \
7.3458 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~(WDT_TCSR_EXT_EN | WDT_TCSR_RTC_EN | WDT_TCSR_PCK_EN)) | WDT_TCSR_PCK_EN)
7.3459 +
7.3460 +#define __wdt_select_clk_div1() \
7.3461 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE1)
7.3462 +#define __wdt_select_clk_div4() \
7.3463 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE4)
7.3464 +#define __wdt_select_clk_div16() \
7.3465 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE16)
7.3466 +#define __wdt_select_clk_div64() \
7.3467 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE64)
7.3468 +#define __wdt_select_clk_div256() \
7.3469 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE256)
7.3470 +#define __wdt_select_clk_div1024() \
7.3471 + (REG_WDT_TCSR = (REG_WDT_TCSR & ~WDT_TCSR_PRESCALE_MASK) | WDT_TCSR_PRESCALE1024)
7.3472 +
7.3473 +
7.3474 +/***************************************************************************
7.3475 + * UART
7.3476 + ***************************************************************************/
7.3477 +
7.3478 +#define __uart_enable() ( REG8(UART0_FCR) |= UARTFCR_UUE | UARTFCR_FE )
7.3479 +#define __uart_disable() ( REG8(UART0_FCR) = ~UARTFCR_UUE )
7.3480 +
7.3481 +#define __uart_enable_transmit_irq() ( REG8(UART0_IER) |= UARTIER_TIE )
7.3482 +#define __uart_disable_transmit_irq() ( REG8(UART0_IER) &= ~UARTIER_TIE )
7.3483 +
7.3484 +#define __uart_enable_receive_irq() \
7.3485 + ( REG8(UART0_IER) |= UARTIER_RIE | UARTIER_RLIE | UARTIER_RTIE )
7.3486 +#define __uart_disable_receive_irq() \
7.3487 + ( REG8(UART0_IER) &= ~(UARTIER_RIE | UARTIER_RLIE | UARTIER_RTIE) )
7.3488 +
7.3489 +#define __uart_enable_loopback() ( REG8(UART0_MCR) |= UARTMCR_LOOP )
7.3490 +#define __uart_disable_loopback() ( REG8(UART0_MCR) &= ~UARTMCR_LOOP )
7.3491 +
7.3492 +#define __uart_set_8n1() ( REG8(UART0_LCR) = UARTLCR_WLEN_8 )
7.3493 +
7.3494 +#define __uart_set_baud(devclk, baud) \
7.3495 + do { \
7.3496 + REG8(UART0_LCR) |= UARTLCR_DLAB; \
7.3497 + REG8(UART0_DLLR) = (devclk / 16 / baud) & 0xff; \
7.3498 + REG8(UART0_DLHR) = ((devclk / 16 / baud) >> 8) & 0xff; \
7.3499 + REG8(UART0_LCR) &= ~UARTLCR_DLAB; \
7.3500 + } while (0)
7.3501 +
7.3502 +#define __uart_parity_error() ( (REG8(UART0_LSR) & UARTLSR_PER) != 0 )
7.3503 +#define __uart_clear_errors() \
7.3504 + ( REG8(UART0_LSR) &= ~(UARTLSR_ORER | UARTLSR_BRK | UARTLSR_FER | UARTLSR_PER | UARTLSR_RFER) )
7.3505 +
7.3506 +#define __uart_transmit_fifo_empty() ( (REG8(UART0_LSR) & UARTLSR_TDRQ) != 0 )
7.3507 +#define __uart_transmit_end() ( (REG8(UART0_LSR) & UARTLSR_TEMT) != 0 )
7.3508 +#define __uart_transmit_char(ch) ( REG8(UART0_TDR) = (ch) )
7.3509 +#define __uart_receive_fifo_full() ( (REG8(UART0_LSR) & UARTLSR_DR) != 0 )
7.3510 +#define __uart_receive_ready() ( (REG8(UART0_LSR) & UARTLSR_DR) != 0 )
7.3511 +#define __uart_receive_char() REG8(UART0_RDR)
7.3512 +#define __uart_disable_irda() ( REG8(UART0_SIRCR) &= ~(SIRCR_TSIRE | SIRCR_RSIRE) )
7.3513 +#define __uart_enable_irda() \
7.3514 + /* Tx high pulse as 0, Rx low pulse as 0 */ \
7.3515 + ( REG8(UART0_SIRCR) = SIRCR_TSIRE | SIRCR_RSIRE | SIRCR_RXPL | SIRCR_TPWS )
7.3516 +
7.3517 +
7.3518 +/***************************************************************************
7.3519 + * DMAC
7.3520 + ***************************************************************************/
7.3521 +
7.3522 +/* n is the DMA channel (0 - 5) */
7.3523 +
7.3524 +#define __dmac_enable_module() \
7.3525 + ( REG_DMAC_DMACR |= DMAC_DMACR_DMAE | DMAC_DMACR_PR_RR )
7.3526 +#define __dmac_disable_module() \
7.3527 + ( REG_DMAC_DMACR &= ~DMAC_DMACR_DMAE )
7.3528 +
7.3529 +/* p=0,1,2,3 */
7.3530 +#define __dmac_set_priority(p) \
7.3531 +do { \
7.3532 + REG_DMAC_DMACR &= ~DMAC_DMACR_PR_MASK; \
7.3533 + REG_DMAC_DMACR |= ((p) << DMAC_DMACR_PR_BIT); \
7.3534 +} while (0)
7.3535 +
7.3536 +#define __dmac_test_halt_error() ( REG_DMAC_DMACR & DMAC_DMACR_HLT )
7.3537 +#define __dmac_test_addr_error() ( REG_DMAC_DMACR & DMAC_DMACR_AR )
7.3538 +
7.3539 +#define __dmac_enable_descriptor(n) \
7.3540 + ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_NDES )
7.3541 +#define __dmac_disable_descriptor(n) \
7.3542 + ( REG_DMAC_DCCSR((n)) |= DMAC_DCCSR_NDES )
7.3543 +
7.3544 +#define __dmac_enable_channel(n) \
7.3545 + ( REG_DMAC_DCCSR((n)) |= DMAC_DCCSR_EN )
7.3546 +#define __dmac_disable_channel(n) \
7.3547 + ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_EN )
7.3548 +#define __dmac_channel_enabled(n) \
7.3549 + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_EN )
7.3550 +
7.3551 +#define __dmac_channel_enable_irq(n) \
7.3552 + ( REG_DMAC_DCMD((n)) |= DMAC_DCMD_TIE )
7.3553 +#define __dmac_channel_disable_irq(n) \
7.3554 + ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_TIE )
7.3555 +
7.3556 +#define __dmac_channel_transmit_halt_detected(n) \
7.3557 + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_HLT )
7.3558 +#define __dmac_channel_transmit_end_detected(n) \
7.3559 + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_TT )
7.3560 +#define __dmac_channel_address_error_detected(n) \
7.3561 + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_AR )
7.3562 +#define __dmac_channel_count_terminated_detected(n) \
7.3563 + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_CT )
7.3564 +#define __dmac_channel_descriptor_invalid_detected(n) \
7.3565 + ( REG_DMAC_DCCSR((n)) & DMAC_DCCSR_INV )
7.3566 +
7.3567 +#define __dmac_channel_clear_transmit_halt(n) \
7.3568 + ( REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_HLT )
7.3569 +#define __dmac_channel_clear_transmit_end(n) \
7.3570 + ( REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_TT )
7.3571 +#define __dmac_channel_clear_address_error(n) \
7.3572 + ( REG_DMAC_DCCSR(n) &= ~DMAC_DCCSR_AR )
7.3573 +#define __dmac_channel_clear_count_terminated(n) \
7.3574 + ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_CT )
7.3575 +#define __dmac_channel_clear_descriptor_invalid(n) \
7.3576 + ( REG_DMAC_DCCSR((n)) &= ~DMAC_DCCSR_INV )
7.3577 +
7.3578 +#define __dmac_channel_set_single_mode(n) \
7.3579 + ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_TM )
7.3580 +#define __dmac_channel_set_block_mode(n) \
7.3581 + ( REG_DMAC_DCMD((n)) |= DMAC_DCMD_TM )
7.3582 +
7.3583 +#define __dmac_channel_set_transfer_unit_32bit(n) \
7.3584 +do { \
7.3585 + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \
7.3586 + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_32BIT; \
7.3587 +} while (0)
7.3588 +
7.3589 +#define __dmac_channel_set_transfer_unit_16bit(n) \
7.3590 +do { \
7.3591 + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \
7.3592 + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_16BIT; \
7.3593 +} while (0)
7.3594 +
7.3595 +#define __dmac_channel_set_transfer_unit_8bit(n) \
7.3596 +do { \
7.3597 + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \
7.3598 + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_8BIT; \
7.3599 +} while (0)
7.3600 +
7.3601 +#define __dmac_channel_set_transfer_unit_16byte(n) \
7.3602 +do { \
7.3603 + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \
7.3604 + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_16BYTE; \
7.3605 +} while (0)
7.3606 +
7.3607 +#define __dmac_channel_set_transfer_unit_32byte(n) \
7.3608 +do { \
7.3609 + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DS_MASK; \
7.3610 + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DS_32BYTE; \
7.3611 +} while (0)
7.3612 +
7.3613 +/* w=8,16,32 */
7.3614 +#define __dmac_channel_set_dest_port_width(n,w) \
7.3615 +do { \
7.3616 + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DWDH_MASK; \
7.3617 + REG_DMAC_DCMD((n)) |= DMAC_DCMD_DWDH_##w; \
7.3618 +} while (0)
7.3619 +
7.3620 +/* w=8,16,32 */
7.3621 +#define __dmac_channel_set_src_port_width(n,w) \
7.3622 +do { \
7.3623 + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_SWDH_MASK; \
7.3624 + REG_DMAC_DCMD((n)) |= DMAC_DCMD_SWDH_##w; \
7.3625 +} while (0)
7.3626 +
7.3627 +/* v=0-15 */
7.3628 +#define __dmac_channel_set_rdil(n,v) \
7.3629 +do { \
7.3630 + REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_RDIL_MASK; \
7.3631 + REG_DMAC_DCMD((n) |= ((v) << DMAC_DCMD_RDIL_BIT); \
7.3632 +} while (0)
7.3633 +
7.3634 +#define __dmac_channel_dest_addr_fixed(n) \
7.3635 + ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_DAI )
7.3636 +#define __dmac_channel_dest_addr_increment(n) \
7.3637 + ( REG_DMAC_DCMD((n)) |= DMAC_DCMD_DAI )
7.3638 +
7.3639 +#define __dmac_channel_src_addr_fixed(n) \
7.3640 + ( REG_DMAC_DCMD((n)) &= ~DMAC_DCMD_SAI )
7.3641 +#define __dmac_channel_src_addr_increment(n) \
7.3642 + ( REG_DMAC_DCMD((n)) |= DMAC_DCMD_SAI )
7.3643 +
7.3644 +#define __dmac_channel_set_doorbell(n) \
7.3645 + ( REG_DMAC_DMADBSR = (1 << (n)) )
7.3646 +
7.3647 +#define __dmac_channel_irq_detected(n) ( REG_DMAC_DMAIPR & (1 << (n)) )
7.3648 +#define __dmac_channel_ack_irq(n) ( REG_DMAC_DMAIPR &= ~(1 << (n)) )
7.3649 +
7.3650 +static __inline__ int __dmac_get_irq(void)
7.3651 +{
7.3652 + int i;
7.3653 + for (i = 0; i < MAX_DMA_NUM; i++)
7.3654 + if (__dmac_channel_irq_detected(i))
7.3655 + return i;
7.3656 + return -1;
7.3657 +}
7.3658 +
7.3659 +
7.3660 +/***************************************************************************
7.3661 + * AIC (AC'97 & I2S Controller)
7.3662 + ***************************************************************************/
7.3663 +
7.3664 +#define __aic_enable() ( REG_AIC_FR |= AIC_FR_ENB )
7.3665 +#define __aic_disable() ( REG_AIC_FR &= ~AIC_FR_ENB )
7.3666 +
7.3667 +#define __aic_select_ac97() ( REG_AIC_FR &= ~AIC_FR_AUSEL )
7.3668 +#define __aic_select_i2s() ( REG_AIC_FR |= AIC_FR_AUSEL )
7.3669 +
7.3670 +#define __i2s_as_master() ( REG_AIC_FR |= AIC_FR_BCKD | AIC_FR_SYNCD )
7.3671 +#define __i2s_as_slave() ( REG_AIC_FR &= ~(AIC_FR_BCKD | AIC_FR_SYNCD) )
7.3672 +#define __aic_reset_status() ( REG_AIC_FR & AIC_FR_RST )
7.3673 +
7.3674 +#define __aic_reset() \
7.3675 +do { \
7.3676 + REG_AIC_FR |= AIC_FR_RST; \
7.3677 +} while(0)
7.3678 +
7.3679 +
7.3680 +#define __aic_set_transmit_trigger(n) \
7.3681 +do { \
7.3682 + REG_AIC_FR &= ~AIC_FR_TFTH_MASK; \
7.3683 + REG_AIC_FR |= ((n) << AIC_FR_TFTH_BIT); \
7.3684 +} while(0)
7.3685 +
7.3686 +#define __aic_set_receive_trigger(n) \
7.3687 +do { \
7.3688 + REG_AIC_FR &= ~AIC_FR_RFTH_MASK; \
7.3689 + REG_AIC_FR |= ((n) << AIC_FR_RFTH_BIT); \
7.3690 +} while(0)
7.3691 +
7.3692 +#define __aic_enable_record() ( REG_AIC_CR |= AIC_CR_EREC )
7.3693 +#define __aic_disable_record() ( REG_AIC_CR &= ~AIC_CR_EREC )
7.3694 +#define __aic_enable_replay() ( REG_AIC_CR |= AIC_CR_ERPL )
7.3695 +#define __aic_disable_replay() ( REG_AIC_CR &= ~AIC_CR_ERPL )
7.3696 +#define __aic_enable_loopback() ( REG_AIC_CR |= AIC_CR_ENLBF )
7.3697 +#define __aic_disable_loopback() ( REG_AIC_CR &= ~AIC_CR_ENLBF )
7.3698 +
7.3699 +#define __aic_flush_fifo() ( REG_AIC_CR |= AIC_CR_FLUSH )
7.3700 +#define __aic_unflush_fifo() ( REG_AIC_CR &= ~AIC_CR_FLUSH )
7.3701 +
7.3702 +#define __aic_enable_transmit_intr() \
7.3703 + ( REG_AIC_CR |= (AIC_CR_ETFS | AIC_CR_ETUR) )
7.3704 +#define __aic_disable_transmit_intr() \
7.3705 + ( REG_AIC_CR &= ~(AIC_CR_ETFS | AIC_CR_ETUR) )
7.3706 +#define __aic_enable_receive_intr() \
7.3707 + ( REG_AIC_CR |= (AIC_CR_ERFS | AIC_CR_EROR) )
7.3708 +#define __aic_disable_receive_intr() \
7.3709 + ( REG_AIC_CR &= ~(AIC_CR_ERFS | AIC_CR_EROR) )
7.3710 +
7.3711 +#define __aic_enable_transmit_dma() ( REG_AIC_CR |= AIC_CR_TDMS )
7.3712 +#define __aic_disable_transmit_dma() ( REG_AIC_CR &= ~AIC_CR_TDMS )
7.3713 +#define __aic_enable_receive_dma() ( REG_AIC_CR |= AIC_CR_RDMS )
7.3714 +#define __aic_disable_receive_dma() ( REG_AIC_CR &= ~AIC_CR_RDMS )
7.3715 +
7.3716 +#define __aic_enable_mono2stereo() ( REG_AIC_CR |= AIC_CR_M2S )
7.3717 +#define __aic_disable_mono2stereo() ( REG_AIC_CR &= ~AIC_CR_M2S )
7.3718 +#define __aic_enable_byteswap() ( REG_AIC_CR |= AIC_CR_ENDSW )
7.3719 +#define __aic_disable_byteswap() ( REG_AIC_CR &= ~AIC_CR_ENDSW )
7.3720 +#define __aic_enable_unsignadj() ( REG_AIC_CR |= AIC_CR_AVSTSU )
7.3721 +#define __aic_disable_unsignadj() ( REG_AIC_CR &= ~AIC_CR_AVSTSU )
7.3722 +
7.3723 +#define AC97_PCM_XS_L_FRONT AIC_ACCR1_XS_SLOT3
7.3724 +#define AC97_PCM_XS_R_FRONT AIC_ACCR1_XS_SLOT4
7.3725 +#define AC97_PCM_XS_CENTER AIC_ACCR1_XS_SLOT6
7.3726 +#define AC97_PCM_XS_L_SURR AIC_ACCR1_XS_SLOT7
7.3727 +#define AC97_PCM_XS_R_SURR AIC_ACCR1_XS_SLOT8
7.3728 +#define AC97_PCM_XS_LFE AIC_ACCR1_XS_SLOT9
7.3729 +
7.3730 +#define AC97_PCM_RS_L_FRONT AIC_ACCR1_RS_SLOT3
7.3731 +#define AC97_PCM_RS_R_FRONT AIC_ACCR1_RS_SLOT4
7.3732 +#define AC97_PCM_RS_CENTER AIC_ACCR1_RS_SLOT6
7.3733 +#define AC97_PCM_RS_L_SURR AIC_ACCR1_RS_SLOT7
7.3734 +#define AC97_PCM_RS_R_SURR AIC_ACCR1_RS_SLOT8
7.3735 +#define AC97_PCM_RS_LFE AIC_ACCR1_RS_SLOT9
7.3736 +
7.3737 +#define __ac97_set_xs_none() ( REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK )
7.3738 +#define __ac97_set_xs_mono() \
7.3739 +do { \
7.3740 + REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK; \
7.3741 + REG_AIC_ACCR1 |= AC97_PCM_XS_R_FRONT; \
7.3742 +} while(0)
7.3743 +#define __ac97_set_xs_stereo() \
7.3744 +do { \
7.3745 + REG_AIC_ACCR1 &= ~AIC_ACCR1_XS_MASK; \
7.3746 + REG_AIC_ACCR1 |= AC97_PCM_XS_L_FRONT | AC97_PCM_XS_R_FRONT; \
7.3747 +} while(0)
7.3748 +
7.3749 +/* In fact, only stereo is support now. */
7.3750 +#define __ac97_set_rs_none() ( REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK )
7.3751 +#define __ac97_set_rs_mono() \
7.3752 +do { \
7.3753 + REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK; \
7.3754 + REG_AIC_ACCR1 |= AC97_PCM_RS_R_FRONT; \
7.3755 +} while(0)
7.3756 +#define __ac97_set_rs_stereo() \
7.3757 +do { \
7.3758 + REG_AIC_ACCR1 &= ~AIC_ACCR1_RS_MASK; \
7.3759 + REG_AIC_ACCR1 |= AC97_PCM_RS_L_FRONT | AC97_PCM_RS_R_FRONT; \
7.3760 +} while(0)
7.3761 +
7.3762 +#define __ac97_warm_reset_codec() \
7.3763 + do { \
7.3764 + REG_AIC_ACCR2 |= AIC_ACCR2_SA; \
7.3765 + REG_AIC_ACCR2 |= AIC_ACCR2_SS; \
7.3766 + udelay(2); \
7.3767 + REG_AIC_ACCR2 &= ~AIC_ACCR2_SS; \
7.3768 + REG_AIC_ACCR2 &= ~AIC_ACCR2_SA; \
7.3769 + } while (0)
7.3770 +
7.3771 +#define __ac97_cold_reset_codec() \
7.3772 + do { \
7.3773 + REG_AIC_ACCR2 |= AIC_ACCR2_SR; \
7.3774 + udelay(2); \
7.3775 + REG_AIC_ACCR2 &= ~AIC_ACCR2_SR; \
7.3776 + } while (0)
7.3777 +
7.3778 +/* n=8,16,18,20 */
7.3779 +#define __ac97_set_iass(n) \
7.3780 + ( REG_AIC_ACCR2 = (REG_AIC_ACCR2 & ~AIC_ACCR2_IASS_MASK) | AIC_ACCR2_IASS_##n##BIT )
7.3781 +#define __ac97_set_oass(n) \
7.3782 + ( REG_AIC_ACCR2 = (REG_AIC_ACCR2 & ~AIC_ACCR2_OASS_MASK) | AIC_ACCR2_OASS_##n##BIT )
7.3783 +
7.3784 +#define __i2s_select_i2s() ( REG_AIC_I2SCR &= ~AIC_I2SCR_AMSL )
7.3785 +#define __i2s_select_msbjustified() ( REG_AIC_I2SCR |= AIC_I2SCR_AMSL )
7.3786 +
7.3787 +/* n=8,16,18,20,24 */
7.3788 +/*#define __i2s_set_sample_size(n) \
7.3789 + ( REG_AIC_I2SCR |= (REG_AIC_I2SCR & ~AIC_I2SCR_WL_MASK) | AIC_I2SCR_WL_##n##BIT )*/
7.3790 +
7.3791 +#define __i2s_set_oss_sample_size(n) \
7.3792 + ( REG_AIC_CR = (REG_AIC_CR & ~AIC_CR_OSS_MASK) | AIC_CR_OSS_##n##BIT )
7.3793 +#define __i2s_set_iss_sample_size(n) \
7.3794 + ( REG_AIC_CR = (REG_AIC_CR & ~AIC_CR_ISS_MASK) | AIC_CR_ISS_##n##BIT )
7.3795 +
7.3796 +#define __i2s_stop_bitclk() ( REG_AIC_I2SCR |= AIC_I2SCR_STPBK )
7.3797 +#define __i2s_start_bitclk() ( REG_AIC_I2SCR &= ~AIC_I2SCR_STPBK )
7.3798 +
7.3799 +#define __aic_transmit_request() ( REG_AIC_SR & AIC_SR_TFS )
7.3800 +#define __aic_receive_request() ( REG_AIC_SR & AIC_SR_RFS )
7.3801 +#define __aic_transmit_underrun() ( REG_AIC_SR & AIC_SR_TUR )
7.3802 +#define __aic_receive_overrun() ( REG_AIC_SR & AIC_SR_ROR )
7.3803 +
7.3804 +#define __aic_clear_errors() ( REG_AIC_SR &= ~(AIC_SR_TUR | AIC_SR_ROR) )
7.3805 +
7.3806 +#define __aic_get_transmit_resident() \
7.3807 + ( (REG_AIC_SR & AIC_SR_TFL_MASK) >> AIC_SR_TFL_BIT )
7.3808 +#define __aic_get_receive_count() \
7.3809 + ( (REG_AIC_SR & AIC_SR_RFL_MASK) >> AIC_SR_RFL_BIT )
7.3810 +
7.3811 +#define __ac97_command_transmitted() ( REG_AIC_ACSR & AIC_ACSR_CADT )
7.3812 +#define __ac97_status_received() ( REG_AIC_ACSR & AIC_ACSR_SADR )
7.3813 +#define __ac97_status_receive_timeout() ( REG_AIC_ACSR & AIC_ACSR_RSTO )
7.3814 +#define __ac97_codec_is_low_power_mode() ( REG_AIC_ACSR & AIC_ACSR_CLPM )
7.3815 +#define __ac97_codec_is_ready() ( REG_AIC_ACSR & AIC_ACSR_CRDY )
7.3816 +#define __ac97_slot_error_detected() ( REG_AIC_ACSR & AIC_ACSR_SLTERR )
7.3817 +#define __ac97_clear_slot_error() ( REG_AIC_ACSR &= ~AIC_ACSR_SLTERR )
7.3818 +
7.3819 +#define __i2s_is_busy() ( REG_AIC_I2SSR & AIC_I2SSR_BSY )
7.3820 +
7.3821 +#define CODEC_READ_CMD (1 << 19)
7.3822 +#define CODEC_WRITE_CMD (0 << 19)
7.3823 +#define CODEC_REG_INDEX_BIT 12
7.3824 +#define CODEC_REG_INDEX_MASK (0x7f << CODEC_REG_INDEX_BIT) /* 18:12 */
7.3825 +#define CODEC_REG_DATA_BIT 4
7.3826 +#define CODEC_REG_DATA_MASK (0x0ffff << 4) /* 19:4 */
7.3827 +
7.3828 +#define __ac97_out_rcmd_addr(reg) \
7.3829 +do { \
7.3830 + REG_AIC_ACCAR = CODEC_READ_CMD | ((reg) << CODEC_REG_INDEX_BIT); \
7.3831 +} while (0)
7.3832 +
7.3833 +#define __ac97_out_wcmd_addr(reg) \
7.3834 +do { \
7.3835 + REG_AIC_ACCAR = CODEC_WRITE_CMD | ((reg) << CODEC_REG_INDEX_BIT); \
7.3836 +} while (0)
7.3837 +
7.3838 +#define __ac97_out_data(value) \
7.3839 +do { \
7.3840 + REG_AIC_ACCDR = ((value) << CODEC_REG_DATA_BIT); \
7.3841 +} while (0)
7.3842 +
7.3843 +#define __ac97_in_data() \
7.3844 + ( (REG_AIC_ACSDR & CODEC_REG_DATA_MASK) >> CODEC_REG_DATA_BIT )
7.3845 +
7.3846 +#define __ac97_in_status_addr() \
7.3847 + ( (REG_AIC_ACSAR & CODEC_REG_INDEX_MASK) >> CODEC_REG_INDEX_BIT )
7.3848 +
7.3849 +#define __i2s_set_sample_rate(i2sclk, sync) \
7.3850 + ( REG_AIC_I2SDIV = ((i2sclk) / (4*64)) / (sync) )
7.3851 +
7.3852 +#define __aic_write_tfifo(v) ( REG_AIC_DR = (v) )
7.3853 +#define __aic_read_rfifo() ( REG_AIC_DR )
7.3854 +
7.3855 +#define __aic_internal_codec() ( REG_AIC_FR |= AIC_FR_ICDC )
7.3856 +#define __aic_external_codec() ( REG_AIC_FR &= ~AIC_FR_ICDC )
7.3857 +
7.3858 +//
7.3859 +// Define next ops for AC97 compatible
7.3860 +//
7.3861 +
7.3862 +#define AC97_ACSR AIC_ACSR
7.3863 +
7.3864 +#define __ac97_enable() __aic_enable(); __aic_select_ac97()
7.3865 +#define __ac97_disable() __aic_disable()
7.3866 +#define __ac97_reset() __aic_reset()
7.3867 +
7.3868 +#define __ac97_set_transmit_trigger(n) __aic_set_transmit_trigger(n)
7.3869 +#define __ac97_set_receive_trigger(n) __aic_set_receive_trigger(n)
7.3870 +
7.3871 +#define __ac97_enable_record() __aic_enable_record()
7.3872 +#define __ac97_disable_record() __aic_disable_record()
7.3873 +#define __ac97_enable_replay() __aic_enable_replay()
7.3874 +#define __ac97_disable_replay() __aic_disable_replay()
7.3875 +#define __ac97_enable_loopback() __aic_enable_loopback()
7.3876 +#define __ac97_disable_loopback() __aic_disable_loopback()
7.3877 +
7.3878 +#define __ac97_enable_transmit_dma() __aic_enable_transmit_dma()
7.3879 +#define __ac97_disable_transmit_dma() __aic_disable_transmit_dma()
7.3880 +#define __ac97_enable_receive_dma() __aic_enable_receive_dma()
7.3881 +#define __ac97_disable_receive_dma() __aic_disable_receive_dma()
7.3882 +
7.3883 +#define __ac97_transmit_request() __aic_transmit_request()
7.3884 +#define __ac97_receive_request() __aic_receive_request()
7.3885 +#define __ac97_transmit_underrun() __aic_transmit_underrun()
7.3886 +#define __ac97_receive_overrun() __aic_receive_overrun()
7.3887 +
7.3888 +#define __ac97_clear_errors() __aic_clear_errors()
7.3889 +
7.3890 +#define __ac97_get_transmit_resident() __aic_get_transmit_resident()
7.3891 +#define __ac97_get_receive_count() __aic_get_receive_count()
7.3892 +
7.3893 +#define __ac97_enable_transmit_intr() __aic_enable_transmit_intr()
7.3894 +#define __ac97_disable_transmit_intr() __aic_disable_transmit_intr()
7.3895 +#define __ac97_enable_receive_intr() __aic_enable_receive_intr()
7.3896 +#define __ac97_disable_receive_intr() __aic_disable_receive_intr()
7.3897 +
7.3898 +#define __ac97_write_tfifo(v) __aic_write_tfifo(v)
7.3899 +#define __ac97_read_rfifo() __aic_read_rfifo()
7.3900 +
7.3901 +//
7.3902 +// Define next ops for I2S compatible
7.3903 +//
7.3904 +
7.3905 +#define I2S_ACSR AIC_I2SSR
7.3906 +
7.3907 +#define __i2s_enable() __aic_enable(); __aic_select_i2s()
7.3908 +#define __i2s_disable() __aic_disable()
7.3909 +#define __i2s_reset() __aic_reset()
7.3910 +
7.3911 +#define __i2s_set_transmit_trigger(n) __aic_set_transmit_trigger(n)
7.3912 +#define __i2s_set_receive_trigger(n) __aic_set_receive_trigger(n)
7.3913 +
7.3914 +#define __i2s_enable_record() __aic_enable_record()
7.3915 +#define __i2s_disable_record() __aic_disable_record()
7.3916 +#define __i2s_enable_replay() __aic_enable_replay()
7.3917 +#define __i2s_disable_replay() __aic_disable_replay()
7.3918 +#define __i2s_enable_loopback() __aic_enable_loopback()
7.3919 +#define __i2s_disable_loopback() __aic_disable_loopback()
7.3920 +
7.3921 +#define __i2s_enable_transmit_dma() __aic_enable_transmit_dma()
7.3922 +#define __i2s_disable_transmit_dma() __aic_disable_transmit_dma()
7.3923 +#define __i2s_enable_receive_dma() __aic_enable_receive_dma()
7.3924 +#define __i2s_disable_receive_dma() __aic_disable_receive_dma()
7.3925 +
7.3926 +#define __i2s_transmit_request() __aic_transmit_request()
7.3927 +#define __i2s_receive_request() __aic_receive_request()
7.3928 +#define __i2s_transmit_underrun() __aic_transmit_underrun()
7.3929 +#define __i2s_receive_overrun() __aic_receive_overrun()
7.3930 +
7.3931 +#define __i2s_clear_errors() __aic_clear_errors()
7.3932 +
7.3933 +#define __i2s_get_transmit_resident() __aic_get_transmit_resident()
7.3934 +#define __i2s_get_receive_count() __aic_get_receive_count()
7.3935 +
7.3936 +#define __i2s_enable_transmit_intr() __aic_enable_transmit_intr()
7.3937 +#define __i2s_disable_transmit_intr() __aic_disable_transmit_intr()
7.3938 +#define __i2s_enable_receive_intr() __aic_enable_receive_intr()
7.3939 +#define __i2s_disable_receive_intr() __aic_disable_receive_intr()
7.3940 +
7.3941 +#define __i2s_write_tfifo(v) __aic_write_tfifo(v)
7.3942 +#define __i2s_read_rfifo() __aic_read_rfifo()
7.3943 +
7.3944 +#define __i2s_reset_codec() \
7.3945 + do { \
7.3946 + } while (0)
7.3947 +
7.3948 +
7.3949 +/***************************************************************************
7.3950 + * ICDC
7.3951 + ***************************************************************************/
7.3952 +#define __i2s_internal_codec() __aic_internal_codec()
7.3953 +#define __i2s_external_codec() __aic_external_codec()
7.3954 +
7.3955 +/***************************************************************************
7.3956 + * INTC
7.3957 + ***************************************************************************/
7.3958 +#define __intc_unmask_irq(n) ( REG_INTC_IMCR = (1 << (n)) )
7.3959 +#define __intc_mask_irq(n) ( REG_INTC_IMSR = (1 << (n)) )
7.3960 +#define __intc_ack_irq(n) ( REG_INTC_IPR = (1 << (n)) )
7.3961 +
7.3962 +
7.3963 +/***************************************************************************
7.3964 + * I2C
7.3965 + ***************************************************************************/
7.3966 +
7.3967 +#define __i2c_enable() ( REG_I2C_CR |= I2C_CR_I2CE )
7.3968 +#define __i2c_disable() ( REG_I2C_CR &= ~I2C_CR_I2CE )
7.3969 +
7.3970 +#define __i2c_send_start() ( REG_I2C_CR |= I2C_CR_STA )
7.3971 +#define __i2c_send_stop() ( REG_I2C_CR |= I2C_CR_STO )
7.3972 +#define __i2c_send_ack() ( REG_I2C_CR &= ~I2C_CR_AC )
7.3973 +#define __i2c_send_nack() ( REG_I2C_CR |= I2C_CR_AC )
7.3974 +
7.3975 +#define __i2c_set_drf() ( REG_I2C_SR |= I2C_SR_DRF )
7.3976 +#define __i2c_clear_drf() ( REG_I2C_SR &= ~I2C_SR_DRF )
7.3977 +#define __i2c_check_drf() ( REG_I2C_SR & I2C_SR_DRF )
7.3978 +
7.3979 +#define __i2c_received_ack() ( !(REG_I2C_SR & I2C_SR_ACKF) )
7.3980 +#define __i2c_is_busy() ( REG_I2C_SR & I2C_SR_BUSY )
7.3981 +#define __i2c_transmit_ended() ( REG_I2C_SR & I2C_SR_TEND )
7.3982 +
7.3983 +#define __i2c_set_clk(dev_clk, i2c_clk) \
7.3984 + ( REG_I2C_GR = (dev_clk) / (16*(i2c_clk)) - 1 )
7.3985 +
7.3986 +#define __i2c_read() ( REG_I2C_DR )
7.3987 +#define __i2c_write(val) ( REG_I2C_DR = (val) )
7.3988 +
7.3989 +
7.3990 +/***************************************************************************
7.3991 + * MSC
7.3992 + ***************************************************************************/
7.3993 +
7.3994 +#define __msc_start_op() \
7.3995 + ( REG_MSC_STRPCL = MSC_STRPCL_START_OP | MSC_STRPCL_CLOCK_CONTROL_START )
7.3996 +
7.3997 +#define __msc_set_resto(to) ( REG_MSC_RESTO = to )
7.3998 +#define __msc_set_rdto(to) ( REG_MSC_RDTO = to )
7.3999 +#define __msc_set_cmd(cmd) ( REG_MSC_CMD = cmd )
7.4000 +#define __msc_set_arg(arg) ( REG_MSC_ARG = arg )
7.4001 +#define __msc_set_nob(nob) ( REG_MSC_NOB = nob )
7.4002 +#define __msc_get_nob() ( REG_MSC_NOB )
7.4003 +#define __msc_set_blklen(len) ( REG_MSC_BLKLEN = len )
7.4004 +#define __msc_set_cmdat(cmdat) ( REG_MSC_CMDAT = cmdat )
7.4005 +#define __msc_set_cmdat_ioabort() ( REG_MSC_CMDAT |= MSC_CMDAT_IO_ABORT )
7.4006 +#define __msc_clear_cmdat_ioabort() ( REG_MSC_CMDAT &= ~MSC_CMDAT_IO_ABORT )
7.4007 +
7.4008 +#define __msc_set_cmdat_bus_width1() \
7.4009 +do { \
7.4010 + REG_MSC_CMDAT &= ~MSC_CMDAT_BUS_WIDTH_MASK; \
7.4011 + REG_MSC_CMDAT |= MSC_CMDAT_BUS_WIDTH_1BIT; \
7.4012 +} while(0)
7.4013 +
7.4014 +#define __msc_set_cmdat_bus_width4() \
7.4015 +do { \
7.4016 + REG_MSC_CMDAT &= ~MSC_CMDAT_BUS_WIDTH_MASK; \
7.4017 + REG_MSC_CMDAT |= MSC_CMDAT_BUS_WIDTH_4BIT; \
7.4018 +} while(0)
7.4019 +
7.4020 +#define __msc_set_cmdat_dma_en() ( REG_MSC_CMDAT |= MSC_CMDAT_DMA_EN )
7.4021 +#define __msc_set_cmdat_init() ( REG_MSC_CMDAT |= MSC_CMDAT_INIT )
7.4022 +#define __msc_set_cmdat_busy() ( REG_MSC_CMDAT |= MSC_CMDAT_BUSY )
7.4023 +#define __msc_set_cmdat_stream() ( REG_MSC_CMDAT |= MSC_CMDAT_STREAM_BLOCK )
7.4024 +#define __msc_set_cmdat_block() ( REG_MSC_CMDAT &= ~MSC_CMDAT_STREAM_BLOCK )
7.4025 +#define __msc_set_cmdat_read() ( REG_MSC_CMDAT &= ~MSC_CMDAT_WRITE_READ )
7.4026 +#define __msc_set_cmdat_write() ( REG_MSC_CMDAT |= MSC_CMDAT_WRITE_READ )
7.4027 +#define __msc_set_cmdat_data_en() ( REG_MSC_CMDAT |= MSC_CMDAT_DATA_EN )
7.4028 +
7.4029 +/* r is MSC_CMDAT_RESPONSE_FORMAT_Rx or MSC_CMDAT_RESPONSE_FORMAT_NONE */
7.4030 +#define __msc_set_cmdat_res_format(r) \
7.4031 +do { \
7.4032 + REG_MSC_CMDAT &= ~MSC_CMDAT_RESPONSE_FORMAT_MASK; \
7.4033 + REG_MSC_CMDAT |= (r); \
7.4034 +} while(0)
7.4035 +
7.4036 +#define __msc_clear_cmdat() \
7.4037 + REG_MSC_CMDAT &= ~( MSC_CMDAT_IO_ABORT | MSC_CMDAT_DMA_EN | MSC_CMDAT_INIT| \
7.4038 + MSC_CMDAT_BUSY | MSC_CMDAT_STREAM_BLOCK | MSC_CMDAT_WRITE_READ | \
7.4039 + MSC_CMDAT_DATA_EN | MSC_CMDAT_RESPONSE_FORMAT_MASK )
7.4040 +
7.4041 +#define __msc_get_imask() ( REG_MSC_IMASK )
7.4042 +#define __msc_mask_all_intrs() ( REG_MSC_IMASK = 0xff )
7.4043 +#define __msc_unmask_all_intrs() ( REG_MSC_IMASK = 0x00 )
7.4044 +#define __msc_mask_rd() ( REG_MSC_IMASK |= MSC_IMASK_RXFIFO_RD_REQ )
7.4045 +#define __msc_unmask_rd() ( REG_MSC_IMASK &= ~MSC_IMASK_RXFIFO_RD_REQ )
7.4046 +#define __msc_mask_wr() ( REG_MSC_IMASK |= MSC_IMASK_TXFIFO_WR_REQ )
7.4047 +#define __msc_unmask_wr() ( REG_MSC_IMASK &= ~MSC_IMASK_TXFIFO_WR_REQ )
7.4048 +#define __msc_mask_endcmdres() ( REG_MSC_IMASK |= MSC_IMASK_END_CMD_RES )
7.4049 +#define __msc_unmask_endcmdres() ( REG_MSC_IMASK &= ~MSC_IMASK_END_CMD_RES )
7.4050 +#define __msc_mask_datatrandone() ( REG_MSC_IMASK |= MSC_IMASK_DATA_TRAN_DONE )
7.4051 +#define __msc_unmask_datatrandone() ( REG_MSC_IMASK &= ~MSC_IMASK_DATA_TRAN_DONE )
7.4052 +#define __msc_mask_prgdone() ( REG_MSC_IMASK |= MSC_IMASK_PRG_DONE )
7.4053 +#define __msc_unmask_prgdone() ( REG_MSC_IMASK &= ~MSC_IMASK_PRG_DONE )
7.4054 +
7.4055 +/* n=0,1,2,3,4,5,6,7 */
7.4056 +#define __msc_set_clkrt(n) \
7.4057 +do { \
7.4058 + REG_MSC_CLKRT = n; \
7.4059 +} while(0)
7.4060 +
7.4061 +#define __msc_get_ireg() ( REG_MSC_IREG )
7.4062 +#define __msc_ireg_rd() ( REG_MSC_IREG & MSC_IREG_RXFIFO_RD_REQ )
7.4063 +#define __msc_ireg_wr() ( REG_MSC_IREG & MSC_IREG_TXFIFO_WR_REQ )
7.4064 +#define __msc_ireg_end_cmd_res() ( REG_MSC_IREG & MSC_IREG_END_CMD_RES )
7.4065 +#define __msc_ireg_data_tran_done() ( REG_MSC_IREG & MSC_IREG_DATA_TRAN_DONE )
7.4066 +#define __msc_ireg_prg_done() ( REG_MSC_IREG & MSC_IREG_PRG_DONE )
7.4067 +#define __msc_ireg_clear_end_cmd_res() ( REG_MSC_IREG = MSC_IREG_END_CMD_RES )
7.4068 +#define __msc_ireg_clear_data_tran_done() ( REG_MSC_IREG = MSC_IREG_DATA_TRAN_DONE )
7.4069 +#define __msc_ireg_clear_prg_done() ( REG_MSC_IREG = MSC_IREG_PRG_DONE )
7.4070 +
7.4071 +#define __msc_get_stat() ( REG_MSC_STAT )
7.4072 +#define __msc_stat_not_end_cmd_res() ( (REG_MSC_STAT & MSC_STAT_END_CMD_RES) == 0)
7.4073 +#define __msc_stat_crc_err() \
7.4074 + ( REG_MSC_STAT & (MSC_STAT_CRC_RES_ERR | MSC_STAT_CRC_READ_ERROR | MSC_STAT_CRC_WRITE_ERROR_YES) )
7.4075 +#define __msc_stat_res_crc_err() ( REG_MSC_STAT & MSC_STAT_CRC_RES_ERR )
7.4076 +#define __msc_stat_rd_crc_err() ( REG_MSC_STAT & MSC_STAT_CRC_READ_ERROR )
7.4077 +#define __msc_stat_wr_crc_err() ( REG_MSC_STAT & MSC_STAT_CRC_WRITE_ERROR_YES )
7.4078 +#define __msc_stat_resto_err() ( REG_MSC_STAT & MSC_STAT_TIME_OUT_RES )
7.4079 +#define __msc_stat_rdto_err() ( REG_MSC_STAT & MSC_STAT_TIME_OUT_READ )
7.4080 +
7.4081 +#define __msc_rd_resfifo() ( REG_MSC_RES )
7.4082 +#define __msc_rd_rxfifo() ( REG_MSC_RXFIFO )
7.4083 +#define __msc_wr_txfifo(v) ( REG_MSC_TXFIFO = v )
7.4084 +
7.4085 +#define __msc_reset() \
7.4086 +do { \
7.4087 + REG_MSC_STRPCL = MSC_STRPCL_RESET; \
7.4088 + while (REG_MSC_STAT & MSC_STAT_IS_RESETTING); \
7.4089 +} while (0)
7.4090 +
7.4091 +#define __msc_start_clk() \
7.4092 +do { \
7.4093 + REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_START; \
7.4094 +} while (0)
7.4095 +
7.4096 +#define __msc_stop_clk() \
7.4097 +do { \
7.4098 + REG_MSC_STRPCL = MSC_STRPCL_CLOCK_CONTROL_STOP; \
7.4099 +} while (0)
7.4100 +
7.4101 +#define MMC_CLK 19169200
7.4102 +#define SD_CLK 24576000
7.4103 +
7.4104 +/* msc_clk should little than pclk and little than clk retrieve from card */
7.4105 +#define __msc_calc_clk_divisor(type,dev_clk,msc_clk,lv) \
7.4106 +do { \
7.4107 + unsigned int rate, pclk, i; \
7.4108 + pclk = dev_clk; \
7.4109 + rate = type?SD_CLK:MMC_CLK; \
7.4110 + if (msc_clk && msc_clk < pclk) \
7.4111 + pclk = msc_clk; \
7.4112 + i = 0; \
7.4113 + while (pclk < rate) \
7.4114 + { \
7.4115 + i ++; \
7.4116 + rate >>= 1; \
7.4117 + } \
7.4118 + lv = i; \
7.4119 +} while(0)
7.4120 +
7.4121 +/* divide rate to little than or equal to 400kHz */
7.4122 +#define __msc_calc_slow_clk_divisor(type, lv) \
7.4123 +do { \
7.4124 + unsigned int rate, i; \
7.4125 + rate = (type?SD_CLK:MMC_CLK)/1000/400; \
7.4126 + i = 0; \
7.4127 + while (rate > 0) \
7.4128 + { \
7.4129 + rate >>= 1; \
7.4130 + i ++; \
7.4131 + } \
7.4132 + lv = i; \
7.4133 +} while(0)
7.4134 +
7.4135 +
7.4136 +/***************************************************************************
7.4137 + * SSI
7.4138 + ***************************************************************************/
7.4139 +
7.4140 +#define __ssi_enable() ( REG_SSI_CR0 |= SSI_CR0_SSIE )
7.4141 +#define __ssi_disable() ( REG_SSI_CR0 &= ~SSI_CR0_SSIE )
7.4142 +#define __ssi_select_ce() ( REG_SSI_CR0 &= ~SSI_CR0_FSEL )
7.4143 +
7.4144 +#define __ssi_normal_mode() ( REG_SSI_ITR &= ~SSI_ITR_IVLTM_MASK )
7.4145 +
7.4146 +#define __ssi_select_ce2() \
7.4147 +do { \
7.4148 + REG_SSI_CR0 |= SSI_CR0_FSEL; \
7.4149 + REG_SSI_CR1 &= ~SSI_CR1_MULTS; \
7.4150 +} while (0)
7.4151 +
7.4152 +#define __ssi_select_gpc() \
7.4153 +do { \
7.4154 + REG_SSI_CR0 &= ~SSI_CR0_FSEL; \
7.4155 + REG_SSI_CR1 |= SSI_CR1_MULTS; \
7.4156 +} while (0)
7.4157 +
7.4158 +#define __ssi_enable_tx_intr() \
7.4159 + ( REG_SSI_CR0 |= SSI_CR0_TIE | SSI_CR0_TEIE )
7.4160 +
7.4161 +#define __ssi_disable_tx_intr() \
7.4162 + ( REG_SSI_CR0 &= ~(SSI_CR0_TIE | SSI_CR0_TEIE) )
7.4163 +
7.4164 +#define __ssi_enable_rx_intr() \
7.4165 + ( REG_SSI_CR0 |= SSI_CR0_RIE | SSI_CR0_REIE )
7.4166 +
7.4167 +#define __ssi_disable_rx_intr() \
7.4168 + ( REG_SSI_CR0 &= ~(SSI_CR0_RIE | SSI_CR0_REIE) )
7.4169 +
7.4170 +#define __ssi_enable_loopback() ( REG_SSI_CR0 |= SSI_CR0_LOOP )
7.4171 +#define __ssi_disable_loopback() ( REG_SSI_CR0 &= ~SSI_CR0_LOOP )
7.4172 +
7.4173 +#define __ssi_enable_receive() ( REG_SSI_CR0 &= ~SSI_CR0_DISREV )
7.4174 +#define __ssi_disable_receive() ( REG_SSI_CR0 |= SSI_CR0_DISREV )
7.4175 +
7.4176 +#define __ssi_finish_receive() \
7.4177 + ( REG_SSI_CR0 |= (SSI_CR0_RFINE | SSI_CR0_RFINC) )
7.4178 +
7.4179 +#define __ssi_disable_recvfinish() \
7.4180 + ( REG_SSI_CR0 &= ~(SSI_CR0_RFINE | SSI_CR0_RFINC) )
7.4181 +
7.4182 +#define __ssi_flush_txfifo() ( REG_SSI_CR0 |= SSI_CR0_TFLUSH )
7.4183 +#define __ssi_flush_rxfifo() ( REG_SSI_CR0 |= SSI_CR0_RFLUSH )
7.4184 +
7.4185 +#define __ssi_flush_fifo() \
7.4186 + ( REG_SSI_CR0 |= SSI_CR0_TFLUSH | SSI_CR0_RFLUSH )
7.4187 +
7.4188 +#define __ssi_finish_transmit() ( REG_SSI_CR1 &= ~SSI_CR1_UNFIN )
7.4189 +
7.4190 +#define __ssi_spi_format() \
7.4191 +do { \
7.4192 + REG_SSI_CR1 &= ~SSI_CR1_FMAT_MASK; \
7.4193 + REG_SSI_CR1 |= SSI_CR1_FMAT_SPI; \
7.4194 + REG_SSI_CR1 &= ~(SSI_CR1_TFVCK_MASK|SSI_CR1_TCKFI_MASK);\
7.4195 + REG_SSI_CR1 |= (SSI_CR1_TFVCK_1 | SSI_CR1_TCKFI_1); \
7.4196 +} while (0)
7.4197 +
7.4198 +/* TI's SSP format, must clear SSI_CR1.UNFIN */
7.4199 +#define __ssi_ssp_format() \
7.4200 +do { \
7.4201 + REG_SSI_CR1 &= ~(SSI_CR1_FMAT_MASK | SSI_CR1_UNFIN); \
7.4202 + REG_SSI_CR1 |= SSI_CR1_FMAT_SSP; \
7.4203 +} while (0)
7.4204 +
7.4205 +/* National's Microwire format, must clear SSI_CR0.RFINE, and set max delay */
7.4206 +#define __ssi_microwire_format() \
7.4207 +do { \
7.4208 + REG_SSI_CR1 &= ~SSI_CR1_FMAT_MASK; \
7.4209 + REG_SSI_CR1 |= SSI_CR1_FMAT_MW1; \
7.4210 + REG_SSI_CR1 &= ~(SSI_CR1_TFVCK_MASK|SSI_CR1_TCKFI_MASK);\
7.4211 + REG_SSI_CR1 |= (SSI_CR1_TFVCK_3 | SSI_CR1_TCKFI_3); \
7.4212 + REG_SSI_CR0 &= ~SSI_CR0_RFINE; \
7.4213 +} while (0)
7.4214 +
7.4215 +/* CE# level (FRMHL), CE# in interval time (ITFRM),
7.4216 + clock phase and polarity (PHA POL),
7.4217 + interval time (SSIITR), interval characters/frame (SSIICR) */
7.4218 +
7.4219 + /* frmhl,endian,mcom,flen,pha,pol MASK */
7.4220 +#define SSICR1_MISC_MASK \
7.4221 + ( SSI_CR1_FRMHL_MASK | SSI_CR1_LFST | SSI_CR1_MCOM_MASK \
7.4222 + | SSI_CR1_FLEN_MASK | SSI_CR1_PHA | SSI_CR1_POL ) \
7.4223 +
7.4224 +#define __ssi_spi_set_misc(frmhl,endian,flen,mcom,pha,pol) \
7.4225 +do { \
7.4226 + REG_SSI_CR1 &= ~SSICR1_MISC_MASK; \
7.4227 + REG_SSI_CR1 |= ((frmhl) << 30) | ((endian) << 25) | \
7.4228 + (((mcom) - 1) << 12) | (((flen) - 2) << 4) | \
7.4229 + ((pha) << 1) | (pol); \
7.4230 +} while(0)
7.4231 +
7.4232 +/* Transfer with MSB or LSB first */
7.4233 +#define __ssi_set_msb() ( REG_SSI_CR1 &= ~SSI_CR1_LFST )
7.4234 +#define __ssi_set_lsb() ( REG_SSI_CR1 |= SSI_CR1_LFST )
7.4235 +
7.4236 +#define __ssi_set_frame_length(n) \
7.4237 + REG_SSI_CR1 = (REG_SSI_CR1 & ~SSI_CR1_FLEN_MASK) | (((n) - 2) << 4)
7.4238 +
7.4239 +/* n = 1 - 16 */
7.4240 +#define __ssi_set_microwire_command_length(n) \
7.4241 + ( REG_SSI_CR1 = ((REG_SSI_CR1 & ~SSI_CR1_MCOM_MASK) | SSI_CR1_MCOM_##n##BIT) )
7.4242 +
7.4243 +/* Set the clock phase for SPI */
7.4244 +#define __ssi_set_spi_clock_phase(n) \
7.4245 + ( REG_SSI_CR1 = ((REG_SSI_CR1 & ~SSI_CR1_PHA) | (n&0x1)) )
7.4246 +
7.4247 +/* Set the clock polarity for SPI */
7.4248 +#define __ssi_set_spi_clock_polarity(n) \
7.4249 + ( REG_SSI_CR1 = ((REG_SSI_CR1 & ~SSI_CR1_POL) | (n&0x1)) )
7.4250 +
7.4251 +/* n = ix8 */
7.4252 +#define __ssi_set_tx_trigger(n) \
7.4253 +do { \
7.4254 + REG_SSI_CR1 &= ~SSI_CR1_TTRG_MASK; \
7.4255 + REG_SSI_CR1 |= SSI_CR1_TTRG_##n; \
7.4256 +} while (0)
7.4257 +
7.4258 +/* n = ix8 */
7.4259 +#define __ssi_set_rx_trigger(n) \
7.4260 +do { \
7.4261 + REG_SSI_CR1 &= ~SSI_CR1_RTRG_MASK; \
7.4262 + REG_SSI_CR1 |= SSI_CR1_RTRG_##n; \
7.4263 +} while (0)
7.4264 +
7.4265 +#define __ssi_get_txfifo_count() \
7.4266 + ( (REG_SSI_SR & SSI_SR_TFIFONUM_MASK) >> SSI_SR_TFIFONUM_BIT )
7.4267 +
7.4268 +#define __ssi_get_rxfifo_count() \
7.4269 + ( (REG_SSI_SR & SSI_SR_RFIFONUM_MASK) >> SSI_SR_RFIFONUM_BIT )
7.4270 +
7.4271 +#define __ssi_clear_errors() \
7.4272 + ( REG_SSI_SR &= ~(SSI_SR_UNDR | SSI_SR_OVER) )
7.4273 +
7.4274 +#define __ssi_transfer_end() ( REG_SSI_SR & SSI_SR_END )
7.4275 +#define __ssi_is_busy() ( REG_SSI_SR & SSI_SR_BUSY )
7.4276 +
7.4277 +#define __ssi_txfifo_full() ( REG_SSI_SR & SSI_SR_TFF )
7.4278 +#define __ssi_rxfifo_empty() ( REG_SSI_SR & SSI_SR_RFE )
7.4279 +#define __ssi_rxfifo_noempty() ( REG_SSI_SR & SSI_SR_RFHF )
7.4280 +
7.4281 +#define __ssi_set_clk(dev_clk, ssi_clk) \
7.4282 + ( REG_SSI_GR = (dev_clk) / (2*(ssi_clk)) - 1 )
7.4283 +
7.4284 +#define __ssi_receive_data() REG_SSI_DR
7.4285 +#define __ssi_transmit_data(v) ( REG_SSI_DR = (v) )
7.4286 +
7.4287 +
7.4288 +/***************************************************************************
7.4289 + * CIM
7.4290 + ***************************************************************************/
7.4291 +
7.4292 +#define __cim_enable() ( REG_CIM_CTRL |= CIM_CTRL_ENA )
7.4293 +#define __cim_disable() ( REG_CIM_CTRL &= ~CIM_CTRL_ENA )
7.4294 +
7.4295 +#define __cim_input_data_inverse() ( REG_CIM_CFG |= CIM_CFG_INV_DAT )
7.4296 +#define __cim_input_data_normal() ( REG_CIM_CFG &= ~CIM_CFG_INV_DAT )
7.4297 +
7.4298 +#define __cim_vsync_active_low() ( REG_CIM_CFG |= CIM_CFG_VSP )
7.4299 +#define __cim_vsync_active_high() ( REG_CIM_CFG &= ~CIM_CFG_VSP )
7.4300 +
7.4301 +#define __cim_hsync_active_low() ( REG_CIM_CFG |= CIM_CFG_HSP )
7.4302 +#define __cim_hsync_active_high() ( REG_CIM_CFG &= ~CIM_CFG_HSP )
7.4303 +
7.4304 +#define __cim_sample_data_at_pclk_falling_edge() \
7.4305 + ( REG_CIM_CFG |= CIM_CFG_PCP )
7.4306 +#define __cim_sample_data_at_pclk_rising_edge() \
7.4307 + ( REG_CIM_CFG &= ~CIM_CFG_PCP )
7.4308 +
7.4309 +#define __cim_enable_dummy_zero() ( REG_CIM_CFG |= CIM_CFG_DUMMY_ZERO )
7.4310 +#define __cim_disable_dummy_zero() ( REG_CIM_CFG &= ~CIM_CFG_DUMMY_ZERO )
7.4311 +
7.4312 +#define __cim_select_external_vsync() ( REG_CIM_CFG |= CIM_CFG_EXT_VSYNC )
7.4313 +#define __cim_select_internal_vsync() ( REG_CIM_CFG &= ~CIM_CFG_EXT_VSYNC )
7.4314 +
7.4315 +/* n=0-7 */
7.4316 +#define __cim_set_data_packing_mode(n) \
7.4317 +do { \
7.4318 + REG_CIM_CFG &= ~CIM_CFG_PACK_MASK; \
7.4319 + REG_CIM_CFG |= (CIM_CFG_PACK_##n); \
7.4320 +} while (0)
7.4321 +
7.4322 +#define __cim_enable_ccir656_progressive_mode() \
7.4323 +do { \
7.4324 + REG_CIM_CFG &= ~CIM_CFG_DSM_MASK; \
7.4325 + REG_CIM_CFG |= CIM_CFG_DSM_CPM; \
7.4326 +} while (0)
7.4327 +
7.4328 +#define __cim_enable_ccir656_interlace_mode() \
7.4329 +do { \
7.4330 + REG_CIM_CFG &= ~CIM_CFG_DSM_MASK; \
7.4331 + REG_CIM_CFG |= CIM_CFG_DSM_CIM; \
7.4332 +} while (0)
7.4333 +
7.4334 +#define __cim_enable_gated_clock_mode() \
7.4335 +do { \
7.4336 + REG_CIM_CFG &= ~CIM_CFG_DSM_MASK; \
7.4337 + REG_CIM_CFG |= CIM_CFG_DSM_GCM; \
7.4338 +} while (0)
7.4339 +
7.4340 +#define __cim_enable_nongated_clock_mode() \
7.4341 +do { \
7.4342 + REG_CIM_CFG &= ~CIM_CFG_DSM_MASK; \
7.4343 + REG_CIM_CFG |= CIM_CFG_DSM_NGCM; \
7.4344 +} while (0)
7.4345 +
7.4346 +/* sclk:system bus clock
7.4347 + * mclk: CIM master clock
7.4348 + */
7.4349 +#define __cim_set_master_clk(sclk, mclk) \
7.4350 +do { \
7.4351 + REG_CIM_CTRL &= ~CIM_CTRL_MCLKDIV_MASK; \
7.4352 + REG_CIM_CTRL |= (((sclk)/(mclk) - 1) << CIM_CTRL_MCLKDIV_BIT); \
7.4353 +} while (0)
7.4354 +
7.4355 +#define __cim_enable_sof_intr() \
7.4356 + ( REG_CIM_CTRL |= CIM_CTRL_DMA_SOFM )
7.4357 +#define __cim_disable_sof_intr() \
7.4358 + ( REG_CIM_CTRL &= ~CIM_CTRL_DMA_SOFM )
7.4359 +
7.4360 +#define __cim_enable_eof_intr() \
7.4361 + ( REG_CIM_CTRL |= CIM_CTRL_DMA_EOFM )
7.4362 +#define __cim_disable_eof_intr() \
7.4363 + ( REG_CIM_CTRL &= ~CIM_CTRL_DMA_EOFM )
7.4364 +
7.4365 +#define __cim_enable_stop_intr() \
7.4366 + ( REG_CIM_CTRL |= CIM_CTRL_DMA_STOPM )
7.4367 +#define __cim_disable_stop_intr() \
7.4368 + ( REG_CIM_CTRL &= ~CIM_CTRL_DMA_STOPM )
7.4369 +
7.4370 +#define __cim_enable_trig_intr() \
7.4371 + ( REG_CIM_CTRL |= CIM_CTRL_RXF_TRIGM )
7.4372 +#define __cim_disable_trig_intr() \
7.4373 + ( REG_CIM_CTRL &= ~CIM_CTRL_RXF_TRIGM )
7.4374 +
7.4375 +#define __cim_enable_rxfifo_overflow_intr() \
7.4376 + ( REG_CIM_CTRL |= CIM_CTRL_RXF_OFM )
7.4377 +#define __cim_disable_rxfifo_overflow_intr() \
7.4378 + ( REG_CIM_CTRL &= ~CIM_CTRL_RXF_OFM )
7.4379 +
7.4380 +/* n=1-16 */
7.4381 +#define __cim_set_frame_rate(n) \
7.4382 +do { \
7.4383 + REG_CIM_CTRL &= ~CIM_CTRL_FRC_MASK; \
7.4384 + REG_CIM_CTRL |= CIM_CTRL_FRC_##n; \
7.4385 +} while (0)
7.4386 +
7.4387 +#define __cim_enable_dma() ( REG_CIM_CTRL |= CIM_CTRL_DMA_EN )
7.4388 +#define __cim_disable_dma() ( REG_CIM_CTRL &= ~CIM_CTRL_DMA_EN )
7.4389 +
7.4390 +#define __cim_reset_rxfifo() ( REG_CIM_CTRL |= CIM_CTRL_RXF_RST )
7.4391 +#define __cim_unreset_rxfifo() ( REG_CIM_CTRL &= ~CIM_CTRL_RXF_RST )
7.4392 +
7.4393 +/* n=4,8,12,16,20,24,28,32 */
7.4394 +#define __cim_set_rxfifo_trigger(n) \
7.4395 +do { \
7.4396 + REG_CIM_CTRL &= ~CIM_CTRL_RXF_TRIG_MASK; \
7.4397 + REG_CIM_CTRL |= CIM_CTRL_RXF_TRIG_##n; \
7.4398 +} while (0)
7.4399 +
7.4400 +#define __cim_clear_state() ( REG_CIM_STATE = 0 )
7.4401 +
7.4402 +#define __cim_disable_done() ( REG_CIM_STATE & CIM_STATE_VDD )
7.4403 +#define __cim_rxfifo_empty() ( REG_CIM_STATE & CIM_STATE_RXF_EMPTY )
7.4404 +#define __cim_rxfifo_reach_trigger() ( REG_CIM_STATE & CIM_STATE_RXF_TRIG )
7.4405 +#define __cim_rxfifo_overflow() ( REG_CIM_STATE & CIM_STATE_RXF_OF )
7.4406 +#define __cim_clear_rxfifo_overflow() ( REG_CIM_STATE &= ~CIM_STATE_RXF_OF )
7.4407 +#define __cim_dma_stop() ( REG_CIM_STATE & CIM_STATE_DMA_STOP )
7.4408 +#define __cim_dma_eof() ( REG_CIM_STATE & CIM_STATE_DMA_EOF )
7.4409 +#define __cim_dma_sof() ( REG_CIM_STATE & CIM_STATE_DMA_SOF )
7.4410 +
7.4411 +#define __cim_get_iid() ( REG_CIM_IID )
7.4412 +#define __cim_get_image_data() ( REG_CIM_RXFIFO )
7.4413 +#define __cim_get_dam_cmd() ( REG_CIM_CMD )
7.4414 +
7.4415 +#define __cim_set_da(a) ( REG_CIM_DA = (a) )
7.4416 +
7.4417 +/***************************************************************************
7.4418 + * LCD
7.4419 + ***************************************************************************/
7.4420 +#define __lcd_as_smart_lcd() ( REG_LCD_CFG |= (1<<LCD_CFG_LCDPIN_BIT) )
7.4421 +#define __lcd_as_general_lcd() ( REG_LCD_CFG &= ~(1<<LCD_CFG_LCDPIN_BIT) )
7.4422 +
7.4423 +#define __lcd_set_dis() ( REG_LCD_CTRL |= LCD_CTRL_DIS )
7.4424 +#define __lcd_clr_dis() ( REG_LCD_CTRL &= ~LCD_CTRL_DIS )
7.4425 +
7.4426 +#define __lcd_set_ena() ( REG_LCD_CTRL |= LCD_CTRL_ENA )
7.4427 +#define __lcd_clr_ena() ( REG_LCD_CTRL &= ~LCD_CTRL_ENA )
7.4428 +
7.4429 +/* n=1,2,4,8,16 */
7.4430 +#define __lcd_set_bpp(n) \
7.4431 + ( REG_LCD_CTRL = (REG_LCD_CTRL & ~LCD_CTRL_BPP_MASK) | LCD_CTRL_BPP_##n )
7.4432 +
7.4433 +/* n=4,8,16 */
7.4434 +#define __lcd_set_burst_length(n) \
7.4435 +do { \
7.4436 + REG_LCD_CTRL &= ~LCD_CTRL_BST_MASK; \
7.4437 + REG_LCD_CTRL |= LCD_CTRL_BST_n##; \
7.4438 +} while (0)
7.4439 +
7.4440 +#define __lcd_select_rgb565() ( REG_LCD_CTRL &= ~LCD_CTRL_RGB555 )
7.4441 +#define __lcd_select_rgb555() ( REG_LCD_CTRL |= LCD_CTRL_RGB555 )
7.4442 +
7.4443 +#define __lcd_set_ofup() ( REG_LCD_CTRL |= LCD_CTRL_OFUP )
7.4444 +#define __lcd_clr_ofup() ( REG_LCD_CTRL &= ~LCD_CTRL_OFUP )
7.4445 +
7.4446 +/* n=2,4,16 */
7.4447 +#define __lcd_set_stn_frc(n) \
7.4448 +do { \
7.4449 + REG_LCD_CTRL &= ~LCD_CTRL_FRC_MASK; \
7.4450 + REG_LCD_CTRL |= LCD_CTRL_FRC_n##; \
7.4451 +} while (0)
7.4452 +
7.4453 +
7.4454 +#define __lcd_pixel_endian_little() ( REG_LCD_CTRL |= LCD_CTRL_PEDN )
7.4455 +#define __lcd_pixel_endian_big() ( REG_LCD_CTRL &= ~LCD_CTRL_PEDN )
7.4456 +
7.4457 +#define __lcd_reverse_byte_endian() ( REG_LCD_CTRL |= LCD_CTRL_BEDN )
7.4458 +#define __lcd_normal_byte_endian() ( REG_LCD_CTRL &= ~LCD_CTRL_BEDN )
7.4459 +
7.4460 +#define __lcd_enable_eof_intr() ( REG_LCD_CTRL |= LCD_CTRL_EOFM )
7.4461 +#define __lcd_disable_eof_intr() ( REG_LCD_CTRL &= ~LCD_CTRL_EOFM )
7.4462 +
7.4463 +#define __lcd_enable_sof_intr() ( REG_LCD_CTRL |= LCD_CTRL_SOFM )
7.4464 +#define __lcd_disable_sof_intr() ( REG_LCD_CTRL &= ~LCD_CTRL_SOFM )
7.4465 +
7.4466 +#define __lcd_enable_ofu_intr() ( REG_LCD_CTRL |= LCD_CTRL_OFUM )
7.4467 +#define __lcd_disable_ofu_intr() ( REG_LCD_CTRL &= ~LCD_CTRL_OFUM )
7.4468 +
7.4469 +#define __lcd_enable_ifu0_intr() ( REG_LCD_CTRL |= LCD_CTRL_IFUM0 )
7.4470 +#define __lcd_disable_ifu0_intr() ( REG_LCD_CTRL &= ~LCD_CTRL_IFUM0 )
7.4471 +
7.4472 +#define __lcd_enable_ifu1_intr() ( REG_LCD_CTRL |= LCD_CTRL_IFUM1 )
7.4473 +#define __lcd_disable_ifu1_intr() ( REG_LCD_CTRL &= ~LCD_CTRL_IFUM1 )
7.4474 +
7.4475 +#define __lcd_enable_ldd_intr() ( REG_LCD_CTRL |= LCD_CTRL_LDDM )
7.4476 +#define __lcd_disable_ldd_intr() ( REG_LCD_CTRL &= ~LCD_CTRL_LDDM )
7.4477 +
7.4478 +#define __lcd_enable_qd_intr() ( REG_LCD_CTRL |= LCD_CTRL_QDM )
7.4479 +#define __lcd_disable_qd_intr() ( REG_LCD_CTRL &= ~LCD_CTRL_QDM )
7.4480 +
7.4481 +
7.4482 +/* LCD status register indication */
7.4483 +
7.4484 +#define __lcd_quick_disable_done() ( REG_LCD_STATE & LCD_STATE_QD )
7.4485 +#define __lcd_disable_done() ( REG_LCD_STATE & LCD_STATE_LDD )
7.4486 +#define __lcd_infifo0_underrun() ( REG_LCD_STATE & LCD_STATE_IFU0 )
7.4487 +#define __lcd_infifo1_underrun() ( REG_LCD_STATE & LCD_STATE_IFU1 )
7.4488 +#define __lcd_outfifo_underrun() ( REG_LCD_STATE & LCD_STATE_OFU )
7.4489 +#define __lcd_start_of_frame() ( REG_LCD_STATE & LCD_STATE_SOF )
7.4490 +#define __lcd_end_of_frame() ( REG_LCD_STATE & LCD_STATE_EOF )
7.4491 +
7.4492 +#define __lcd_clr_outfifounderrun() ( REG_LCD_STATE &= ~LCD_STATE_OFU )
7.4493 +#define __lcd_clr_sof() ( REG_LCD_STATE &= ~LCD_STATE_SOF )
7.4494 +#define __lcd_clr_eof() ( REG_LCD_STATE &= ~LCD_STATE_EOF )
7.4495 +
7.4496 +#define __lcd_panel_white() ( REG_LCD_CFG |= LCD_CFG_WHITE )
7.4497 +#define __lcd_panel_black() ( REG_LCD_CFG &= ~LCD_CFG_WHITE )
7.4498 +
7.4499 +/* n=1,2,4,8 for single mono-STN
7.4500 + * n=4,8 for dual mono-STN
7.4501 + */
7.4502 +#define __lcd_set_panel_datawidth(n) \
7.4503 +do { \
7.4504 + REG_LCD_CFG &= ~LCD_CFG_PDW_MASK; \
7.4505 + REG_LCD_CFG |= LCD_CFG_PDW_n##; \
7.4506 +} while (0)
7.4507 +
7.4508 +/* m=LCD_CFG_MODE_GENERUIC_TFT_xxx */
7.4509 +#define __lcd_set_panel_mode(m) \
7.4510 +do { \
7.4511 + REG_LCD_CFG &= ~LCD_CFG_MODE_MASK; \
7.4512 + REG_LCD_CFG |= (m); \
7.4513 +} while(0)
7.4514 +
7.4515 +/* n = 0-255 */
7.4516 +#define __lcd_disable_ac_bias() ( REG_LCD_IO = 0xff )
7.4517 +#define __lcd_set_ac_bias(n) \
7.4518 +do { \
7.4519 + REG_LCD_IO &= ~LCD_IO_ACB_MASK; \
7.4520 + REG_LCD_IO |= ((n) << LCD_IO_ACB_BIT); \
7.4521 +} while(0)
7.4522 +
7.4523 +#define __lcd_io_set_dir() ( REG_LCD_IO |= LCD_IO_DIR )
7.4524 +#define __lcd_io_clr_dir() ( REG_LCD_IO &= ~LCD_IO_DIR )
7.4525 +
7.4526 +#define __lcd_io_set_dep() ( REG_LCD_IO |= LCD_IO_DEP )
7.4527 +#define __lcd_io_clr_dep() ( REG_LCD_IO &= ~LCD_IO_DEP )
7.4528 +
7.4529 +#define __lcd_io_set_vsp() ( REG_LCD_IO |= LCD_IO_VSP )
7.4530 +#define __lcd_io_clr_vsp() ( REG_LCD_IO &= ~LCD_IO_VSP )
7.4531 +
7.4532 +#define __lcd_io_set_hsp() ( REG_LCD_IO |= LCD_IO_HSP )
7.4533 +#define __lcd_io_clr_hsp() ( REG_LCD_IO &= ~LCD_IO_HSP )
7.4534 +
7.4535 +#define __lcd_io_set_pcp() ( REG_LCD_IO |= LCD_IO_PCP )
7.4536 +#define __lcd_io_clr_pcp() ( REG_LCD_IO &= ~LCD_IO_PCP )
7.4537 +
7.4538 +#define __lcd_vsync_get_vps() \
7.4539 + ( (REG_LCD_VSYNC & LCD_VSYNC_VPS_MASK) >> LCD_VSYNC_VPS_BIT )
7.4540 +
7.4541 +#define __lcd_vsync_get_vpe() \
7.4542 + ( (REG_LCD_VSYNC & LCD_VSYNC_VPE_MASK) >> LCD_VSYNC_VPE_BIT )
7.4543 +#define __lcd_vsync_set_vpe(n) \
7.4544 +do { \
7.4545 + REG_LCD_VSYNC &= ~LCD_VSYNC_VPE_MASK; \
7.4546 + REG_LCD_VSYNC |= (n) << LCD_VSYNC_VPE_BIT; \
7.4547 +} while (0)
7.4548 +
7.4549 +#define __lcd_hsync_get_hps() \
7.4550 + ( (REG_LCD_HSYNC & LCD_HSYNC_HPS_MASK) >> LCD_HSYNC_HPS_BIT )
7.4551 +#define __lcd_hsync_set_hps(n) \
7.4552 +do { \
7.4553 + REG_LCD_HSYNC &= ~LCD_HSYNC_HPS_MASK; \
7.4554 + REG_LCD_HSYNC |= (n) << LCD_HSYNC_HPS_BIT; \
7.4555 +} while (0)
7.4556 +
7.4557 +#define __lcd_hsync_get_hpe() \
7.4558 + ( (REG_LCD_HSYNC & LCD_HSYNC_HPE_MASK) >> LCD_VSYNC_HPE_BIT )
7.4559 +#define __lcd_hsync_set_hpe(n) \
7.4560 +do { \
7.4561 + REG_LCD_HSYNC &= ~LCD_HSYNC_HPE_MASK; \
7.4562 + REG_LCD_HSYNC |= (n) << LCD_HSYNC_HPE_BIT; \
7.4563 +} while (0)
7.4564 +
7.4565 +#define __lcd_vat_get_ht() \
7.4566 + ( (REG_LCD_VAT & LCD_VAT_HT_MASK) >> LCD_VAT_HT_BIT )
7.4567 +#define __lcd_vat_set_ht(n) \
7.4568 +do { \
7.4569 + REG_LCD_VAT &= ~LCD_VAT_HT_MASK; \
7.4570 + REG_LCD_VAT |= (n) << LCD_VAT_HT_BIT; \
7.4571 +} while (0)
7.4572 +
7.4573 +#define __lcd_vat_get_vt() \
7.4574 + ( (REG_LCD_VAT & LCD_VAT_VT_MASK) >> LCD_VAT_VT_BIT )
7.4575 +#define __lcd_vat_set_vt(n) \
7.4576 +do { \
7.4577 + REG_LCD_VAT &= ~LCD_VAT_VT_MASK; \
7.4578 + REG_LCD_VAT |= (n) << LCD_VAT_VT_BIT; \
7.4579 +} while (0)
7.4580 +
7.4581 +#define __lcd_dah_get_hds() \
7.4582 + ( (REG_LCD_DAH & LCD_DAH_HDS_MASK) >> LCD_DAH_HDS_BIT )
7.4583 +#define __lcd_dah_set_hds(n) \
7.4584 +do { \
7.4585 + REG_LCD_DAH &= ~LCD_DAH_HDS_MASK; \
7.4586 + REG_LCD_DAH |= (n) << LCD_DAH_HDS_BIT; \
7.4587 +} while (0)
7.4588 +
7.4589 +#define __lcd_dah_get_hde() \
7.4590 + ( (REG_LCD_DAH & LCD_DAH_HDE_MASK) >> LCD_DAH_HDE_BIT )
7.4591 +#define __lcd_dah_set_hde(n) \
7.4592 +do { \
7.4593 + REG_LCD_DAH &= ~LCD_DAH_HDE_MASK; \
7.4594 + REG_LCD_DAH |= (n) << LCD_DAH_HDE_BIT; \
7.4595 +} while (0)
7.4596 +
7.4597 +#define __lcd_dav_get_vds() \
7.4598 + ( (REG_LCD_DAV & LCD_DAV_VDS_MASK) >> LCD_DAV_VDS_BIT )
7.4599 +#define __lcd_dav_set_vds(n) \
7.4600 +do { \
7.4601 + REG_LCD_DAV &= ~LCD_DAV_VDS_MASK; \
7.4602 + REG_LCD_DAV |= (n) << LCD_DAV_VDS_BIT; \
7.4603 +} while (0)
7.4604 +
7.4605 +#define __lcd_dav_get_vde() \
7.4606 + ( (REG_LCD_DAV & LCD_DAV_VDE_MASK) >> LCD_DAV_VDE_BIT )
7.4607 +#define __lcd_dav_set_vde(n) \
7.4608 +do { \
7.4609 + REG_LCD_DAV &= ~LCD_DAV_VDE_MASK; \
7.4610 + REG_LCD_DAV |= (n) << LCD_DAV_VDE_BIT; \
7.4611 +} while (0)
7.4612 +
7.4613 +#define __lcd_cmd0_set_sofint() ( REG_LCD_CMD0 |= LCD_CMD_SOFINT )
7.4614 +#define __lcd_cmd0_clr_sofint() ( REG_LCD_CMD0 &= ~LCD_CMD_SOFINT )
7.4615 +#define __lcd_cmd1_set_sofint() ( REG_LCD_CMD1 |= LCD_CMD_SOFINT )
7.4616 +#define __lcd_cmd1_clr_sofint() ( REG_LCD_CMD1 &= ~LCD_CMD_SOFINT )
7.4617 +
7.4618 +#define __lcd_cmd0_set_eofint() ( REG_LCD_CMD0 |= LCD_CMD_EOFINT )
7.4619 +#define __lcd_cmd0_clr_eofint() ( REG_LCD_CMD0 &= ~LCD_CMD_EOFINT )
7.4620 +#define __lcd_cmd1_set_eofint() ( REG_LCD_CMD1 |= LCD_CMD_EOFINT )
7.4621 +#define __lcd_cmd1_clr_eofint() ( REG_LCD_CMD1 &= ~LCD_CMD_EOFINT )
7.4622 +
7.4623 +#define __lcd_cmd0_set_pal() ( REG_LCD_CMD0 |= LCD_CMD_PAL )
7.4624 +#define __lcd_cmd0_clr_pal() ( REG_LCD_CMD0 &= ~LCD_CMD_PAL )
7.4625 +
7.4626 +#define __lcd_cmd0_get_len() \
7.4627 + ( (REG_LCD_CMD0 & LCD_CMD_LEN_MASK) >> LCD_CMD_LEN_BIT )
7.4628 +#define __lcd_cmd1_get_len() \
7.4629 + ( (REG_LCD_CMD1 & LCD_CMD_LEN_MASK) >> LCD_CMD_LEN_BIT )
7.4630 +
7.4631 +/***************************************************************************
7.4632 + * RTC ops
7.4633 + ***************************************************************************/
7.4634 +
7.4635 +#define __rtc_write_ready() ( REG_RTC_RCR & RTC_RCR_WRDY )
7.4636 +#define __rtc_enabled() \
7.4637 +do{ \
7.4638 + while(!__rtc_write_ready()); \
7.4639 + REG_RTC_RCR |= RTC_RCR_RTCE ; \
7.4640 +}while(0) \
7.4641 +
7.4642 +#define __rtc_disabled() \
7.4643 +do{ \
7.4644 + while(!__rtc_write_ready()); \
7.4645 + REG_RTC_RCR &= ~RTC_RCR_RTCE; \
7.4646 +}while(0)
7.4647 +#define __rtc_enable_alarm() \
7.4648 +do{ \
7.4649 + while(!__rtc_write_ready()); \
7.4650 + REG_RTC_RCR |= RTC_RCR_AE; \
7.4651 +}while(0)
7.4652 +
7.4653 +#define __rtc_disable_alarm() \
7.4654 +do{ \
7.4655 + while(!__rtc_write_ready()); \
7.4656 + REG_RTC_RCR &= ~RTC_RCR_AE; \
7.4657 +}while(0)
7.4658 +
7.4659 +#define __rtc_enable_alarm_irq() \
7.4660 +do{ \
7.4661 + while(!__rtc_write_ready()); \
7.4662 + REG_RTC_RCR |= RTC_RCR_AIE; \
7.4663 +}while(0)
7.4664 +
7.4665 +#define __rtc_disable_alarm_irq() \
7.4666 +do{ \
7.4667 + while(!__rtc_write_ready()); \
7.4668 + REG_RTC_RCR &= ~RTC_RCR_AIE; \
7.4669 +}while(0)
7.4670 +#define __rtc_enable_Hz_irq() \
7.4671 +do{ \
7.4672 + while(!__rtc_write_ready()); \
7.4673 + REG_RTC_RCR |= RTC_RCR_HZIE; \
7.4674 +}while(0)
7.4675 +
7.4676 +#define __rtc_disable_Hz_irq() \
7.4677 +do{ \
7.4678 + while(!__rtc_write_ready()); \
7.4679 + REG_RTC_RCR &= ~RTC_RCR_HZIE; \
7.4680 +}while(0)
7.4681 +#define __rtc_get_1Hz_flag() \
7.4682 +do{ \
7.4683 + while(!__rtc_write_ready()); \
7.4684 + ((REG_RTC_RCR >> RTC_RCR_HZ) & 0x1); \
7.4685 +}while(0)
7.4686 +#define __rtc_clear_1Hz_flag() \
7.4687 +do{ \
7.4688 + while(!__rtc_write_ready()); \
7.4689 + REG_RTC_RCR &= ~RTC_RCR_HZ; \
7.4690 +}while(0)
7.4691 +#define __rtc_get_alarm_flag() \
7.4692 +do{ \
7.4693 + while(!__rtc_write_ready()); \
7.4694 + ((REG_RTC_RCR >> RTC_RCR_AF) & 0x1) \
7.4695 +while(0)
7.4696 +#define __rtc_clear_alarm_flag() \
7.4697 +do{ \
7.4698 + while(!__rtc_write_ready()); \
7.4699 + REG_RTC_RCR &= ~RTC_RCR_AF; \
7.4700 +}while(0)
7.4701 +#define __rtc_get_second() \
7.4702 +do{ \
7.4703 + while(!__rtc_write_ready());\
7.4704 + REG_RTC_RSR; \
7.4705 +}while(0)
7.4706 +
7.4707 +#define __rtc_set_second(v) \
7.4708 +do{ \
7.4709 + while(!__rtc_write_ready()); \
7.4710 + REG_RTC_RSR = v; \
7.4711 +}while(0)
7.4712 +
7.4713 +#define __rtc_get_alarm_second() \
7.4714 +do{ \
7.4715 + while(!__rtc_write_ready()); \
7.4716 + REG_RTC_RSAR; \
7.4717 +}while(0)
7.4718 +
7.4719 +
7.4720 +#define __rtc_set_alarm_second(v) \
7.4721 +do{ \
7.4722 + while(!__rtc_write_ready()); \
7.4723 + REG_RTC_RSAR = v; \
7.4724 +}while(0)
7.4725 +
7.4726 +#define __rtc_RGR_is_locked() \
7.4727 +do{ \
7.4728 + while(!__rtc_write_ready()); \
7.4729 + REG_RTC_RGR >> RTC_RGR_LOCK; \
7.4730 +}while(0)
7.4731 +#define __rtc_lock_RGR() \
7.4732 +do{ \
7.4733 + while(!__rtc_write_ready()); \
7.4734 + REG_RTC_RGR |= RTC_RGR_LOCK; \
7.4735 +}while(0)
7.4736 +
7.4737 +#define __rtc_unlock_RGR() \
7.4738 +do{ \
7.4739 + while(!__rtc_write_ready()); \
7.4740 + REG_RTC_RGR &= ~RTC_RGR_LOCK; \
7.4741 +}while(0)
7.4742 +
7.4743 +#define __rtc_get_adjc_val() \
7.4744 +do{ \
7.4745 + while(!__rtc_write_ready()); \
7.4746 + ( (REG_RTC_RGR & RTC_RGR_ADJC_MASK) >> RTC_RGR_ADJC_BIT ); \
7.4747 +}while(0)
7.4748 +#define __rtc_set_adjc_val(v) \
7.4749 +do{ \
7.4750 + while(!__rtc_write_ready()); \
7.4751 + ( REG_RTC_RGR = ( (REG_RTC_RGR & ~RTC_RGR_ADJC_MASK) | (v << RTC_RGR_ADJC_BIT) )) \
7.4752 +}while(0)
7.4753 +
7.4754 +#define __rtc_get_nc1Hz_val() \
7.4755 + while(!__rtc_write_ready()); \
7.4756 + ( (REG_RTC_RGR & RTC_RGR_NC1HZ_MASK) >> RTC_RGR_NC1HZ_BIT )
7.4757 +
7.4758 +#define __rtc_set_nc1Hz_val(v) \
7.4759 +do{ \
7.4760 + while(!__rtc_write_ready()); \
7.4761 + ( REG_RTC_RGR = ( (REG_RTC_RGR & ~RTC_RGR_NC1HZ_MASK) | (v << RTC_RGR_NC1HZ_BIT) )) \
7.4762 +}while(0)
7.4763 +#define __rtc_power_down() \
7.4764 +do{ \
7.4765 + while(!__rtc_write_ready()); \
7.4766 + REG_RTC_HCR |= RTC_HCR_PD; \
7.4767 +}while(0)
7.4768 +
7.4769 +#define __rtc_get_hwfcr_val() \
7.4770 +do{ \
7.4771 + while(!__rtc_write_ready()); \
7.4772 + REG_RTC_HWFCR & RTC_HWFCR_MASK; \
7.4773 +}while(0)
7.4774 +#define __rtc_set_hwfcr_val(v) \
7.4775 +do{ \
7.4776 + while(!__rtc_write_ready()); \
7.4777 + REG_RTC_HWFCR = (v) & RTC_HWFCR_MASK; \
7.4778 +}while(0)
7.4779 +
7.4780 +#define __rtc_get_hrcr_val() \
7.4781 +do{ \
7.4782 + while(!__rtc_write_ready()); \
7.4783 + ( REG_RTC_HRCR & RTC_HRCR_MASK ); \
7.4784 +}while(0)
7.4785 +#define __rtc_set_hrcr_val(v) \
7.4786 +do{ \
7.4787 + while(!__rtc_write_ready()); \
7.4788 + ( REG_RTC_HRCR = (v) & RTC_HRCR_MASK ); \
7.4789 +}while(0)
7.4790 +
7.4791 +#define __rtc_enable_alarm_wakeup() \
7.4792 +do{ \
7.4793 + while(!__rtc_write_ready()); \
7.4794 + ( REG_RTC_HWCR |= RTC_HWCR_EALM ); \
7.4795 +}while(0)
7.4796 +
7.4797 +#define __rtc_disable_alarm_wakeup() \
7.4798 +do{ \
7.4799 + while(!__rtc_write_ready()); \
7.4800 + ( REG_RTC_HWCR &= ~RTC_HWCR_EALM ); \
7.4801 +}while(0)
7.4802 +
7.4803 +#define __rtc_status_hib_reset_occur() \
7.4804 +do{ \
7.4805 + while(!__rtc_write_ready()); \
7.4806 + ( (REG_RTC_HWRSR >> RTC_HWRSR_HR) & 0x1 ); \
7.4807 +}while(0)
7.4808 +#define __rtc_status_ppr_reset_occur() \
7.4809 +do{ \
7.4810 + while(!__rtc_write_ready()); \
7.4811 + ( (REG_RTC_HWRSR >> RTC_HWRSR_PPR) & 0x1 ); \
7.4812 +}while(0)
7.4813 +#define __rtc_status_wakeup_pin_waken_up() \
7.4814 +do{ \
7.4815 + while(!__rtc_write_ready()); \
7.4816 + ( (REG_RTC_HWRSR >> RTC_HWRSR_PIN) & 0x1 ); \
7.4817 +}while(0)
7.4818 +#define __rtc_status_alarm_waken_up() \
7.4819 +do{ \
7.4820 + while(!__rtc_write_ready()); \
7.4821 + ( (REG_RTC_HWRSR >> RTC_HWRSR_ALM) & 0x1 ); \
7.4822 +}while(0)
7.4823 +#define __rtc_clear_hib_stat_all() \
7.4824 +do{ \
7.4825 + while(!__rtc_write_ready()); \
7.4826 + ( REG_RTC_HWRSR = 0 ); \
7.4827 +}while(0)
7.4828 +
7.4829 +#define __rtc_get_scratch_pattern() \
7.4830 + while(!__rtc_write_ready()); \
7.4831 + (REG_RTC_HSPR)
7.4832 +#define __rtc_set_scratch_pattern(n) \
7.4833 +do{ \
7.4834 + while(!__rtc_write_ready()); \
7.4835 + (REG_RTC_HSPR = n ); \
7.4836 +}while(0)
7.4837 +
7.4838 +#endif /* !__ASSEMBLY__ */
7.4839 +
7.4840 +#endif /* __JZ4740_H__ */
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/include/nandflash.h Fri May 22 18:37:44 2015 +0200
8.3 @@ -0,0 +1,56 @@
8.4 +/*
8.5 + * Copyright (C) 2009 Qi Hardware Inc.,
8.6 + * Author: Xiangfu Liu <xiangfu@sharism.cc>
8.7 + *
8.8 + * This program is free software; you can redistribute it and/or
8.9 + * modify it under the terms of the GNU General Public License
8.10 + * version 3 as published by the Free Software Foundation.
8.11 + *
8.12 + * This program is distributed in the hope that it will be useful,
8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.15 + * GNU General Public License for more details.
8.16 + *
8.17 + * You should have received a copy of the GNU General Public License
8.18 + * along with this program; if not, write to the Free Software
8.19 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
8.20 + * Boston, MA 02110-1301, USA
8.21 + */
8.22 +#ifndef __NANDLIB_H__
8.23 +#define __NANDLIB_H__
8.24 +
8.25 +#include "xburst_types.h"
8.26 +
8.27 +#ifndef NULL
8.28 +#define NULL 0
8.29 +#endif
8.30 +
8.31 +/* Jz4740 nandflash interface */
8.32 +unsigned int nand_query_4740(u8 *);
8.33 +int nand_init_4740(int bus_width, int row_cycle, int page_size, int page_per_block,
8.34 + int,int,int,int);
8.35 +int nand_fini_4740(void);
8.36 +u32 nand_program_4740(void *context, int spage, int pages, int option);
8.37 +u32 nand_erase_4740(int blk_num, int sblk, int force);
8.38 +u32 nand_read_4740(void *buf, u32 startpage, u32 pagenum,int option);
8.39 +u32 nand_read_oob_4740(void *buf, u32 startpage, u32 pagenum);
8.40 +u32 nand_read_raw_4740(void *buf, u32 startpage, u32 pagenum,int);
8.41 +u32 nand_mark_bad_4740(int bad);
8.42 +void nand_enable_4740(u32 csn);
8.43 +void nand_disable_4740(u32 csn);
8.44 +
8.45 +/* Jz4760 nandflash interface */
8.46 +unsigned int nand_query_4760(u8 *);
8.47 +int nand_init_4760(int bus_width, int row_cycle, int page_size, int page_per_block,
8.48 + int bch_bit, int ecc_pos, int bad_pos, int bad_page, int force);
8.49 +int nand_fini_4760(void);
8.50 +u32 nand_program_4760(void *context, int spage, int pages, int option);
8.51 +u32 nand_erase_4760(int blk_num, int sblk, int force);
8.52 +u32 nand_read_4760(void *buf, u32 startpage, u32 pagenum,int option);
8.53 +u32 nand_read_oob_4760(void *buf, u32 startpage, u32 pagenum);
8.54 +u32 nand_read_raw_4760(void *buf, u32 startpage, u32 pagenum,int);
8.55 +u32 nand_mark_bad_4760(int bad);
8.56 +void nand_enable_4760(u32 csn);
8.57 +void nand_disable_4760(u32 csn);
8.58 +
8.59 +#endif