📄 jz4740.h
字号:
/* * Include file for Ingenic Semiconductor's JZ4740 CPU. */#ifndef __JZ4740_H__#define __JZ4740_H__#ifndef __ASSEMBLY__#define __KERNEL__#include <bsp.h>#include <types.h>//#include <addrspace.h>#include <sysdefs.h>#include <cacheops.h>#define cache_unroll(base,op) \ __asm__ __volatile__(" \ .set noreorder; \ .set mips3; \ cache %1, (%0); \ .set mips0; \ .set reorder" \ : \ : "r" (base), \ "i" (op));static inline void jz_flush_dcache(void){ unsigned long start; unsigned long end; start = KSEG0BASE; end = start + CFG_DCACHE_SIZE; while (start < end) { cache_unroll(start,Index_Writeback_Inv_D); start += CFG_CACHELINE_SIZE; }}static inline void jz_flush_icache(void){ unsigned long start; unsigned long end; start = KSEG0BASE; end = start + CFG_ICACHE_SIZE; while(start < end) { cache_unroll(start,Index_Invalidate_I); start += CFG_CACHELINE_SIZE; }}/* cpu pipeline flush */static inline void jz_sync(void){ __asm__ volatile ("sync");}static inline void jz_writeb(u32 address, u8 value){ *((volatile u8 *)address) = value;}static inline void jz_writew(u32 address, u16 value){ *((volatile u16 *)address) = value;}static inline void jz_writel(u32 address, u32 value){ *((volatile u32 *)address) = value;}static inline u8 jz_readb(u32 address){ return *((volatile u8 *)address);}static inline u16 jz_readw(u32 address){ return *((volatile u16 *)address);}static inline u32 jz_readl(u32 address){ return *((volatile u32 *)address);}#if 0#define REG8(addr) *((volatile u8 *)(addr))#define REG16(addr) *((volatile u16 *)(addr))#define REG32(addr) *((volatile u32 *)(addr))#endif#else#define REG8(addr) (addr)#define REG16(addr) (addr)#define REG32(addr) (addr)#endif /* !ASSEMBLY *///----------------------------------------------------------------------// Boot ROM Specification///* NOR Boot config */#define JZ4740_NORBOOT_8BIT 0x00000000 /* 8-bit data bus flash */#define JZ4740_NORBOOT_16BIT 0x10101010 /* 16-bit data bus flash */#define JZ4740_NORBOOT_32BIT 0x20202020 /* 32-bit data bus flash *//* NAND Boot config */#define JZ4740_NANDBOOT_B8R3 0xffffffff /* 8-bit bus & 3 row cycles */#define JZ4740_NANDBOOT_B8R2 0xf0f0f0f0 /* 8-bit bus & 2 row cycles */#define JZ4740_NANDBOOT_B16R3 0x0f0f0f0f /* 16-bit bus & 3 row cycles */#define JZ4740_NANDBOOT_B16R2 0x00000000 /* 16-bit bus & 2 row cycles *///----------------------------------------------------------------------// Register Definitions//#define CPM_BASE 0xB0000000#define INTC_BASE 0xB0001000#define TCU_BASE 0xB0002000#define WDT_BASE 0xB0002000#define RTC_BASE 0xB0003000#define GPIO_BASE 0xB0010000#define AIC_BASE 0xB0020000#define ICDC_BASE 0xB0020000#define MSC_BASE 0xB0021000#define UART0_BASE 0xB0030000#define I2C_BASE 0xB0042000#define SSI_BASE 0xB0043000#define SADC_BASE 0xB0070000#define EMC_BASE 0xB3010000#define DMAC_BASE 0xB3020000#define UHC_BASE 0xB3030000#define UDC_BASE 0xB3040000#define LCD_BASE 0xB3050000#define SLCD_BASE 0xB3050000#define CIM_BASE 0xB3060000#define ETH_BASE 0xB3100000/************************************************************************* * INTC (Interrupt Controller) *************************************************************************/#define INTC_ISR (INTC_BASE + 0x00)#define INTC_IMR (INTC_BASE + 0x04)#define INTC_IMSR (INTC_BASE + 0x08)#define INTC_IMCR (INTC_BASE + 0x0c)#define INTC_IPR (INTC_BASE + 0x10)#define REG_INTC_ISR REG32(INTC_ISR)#define REG_INTC_IMR REG32(INTC_IMR)#define REG_INTC_IMSR REG32(INTC_IMSR)#define REG_INTC_IMCR REG32(INTC_IMCR)#define REG_INTC_IPR REG32(INTC_IPR)// 1st-level interrupts#define IRQ_I2C 1#define IRQ_UHC 3#define IRQ_UART0 9#define IRQ_SADC 12#define IRQ_MSC 14#define IRQ_RTC 15#define IRQ_SSI 16#define IRQ_CIM 17#define IRQ_AIC 18#define IRQ_ETH 19#define IRQ_DMAC 20#define IRQ_TCU2 21#define IRQ_TCU1 22#define IRQ_TCU0 23#define IRQ_UDC 24#define IRQ_GPIO3 25#define IRQ_GPIO2 26#define IRQ_GPIO1 27#define IRQ_GPIO0 28#define IRQ_IPU 29#define IRQ_LCD 30// 2nd-level interrupts#define IRQ_DMA_0 32 /* 32 to 37 for DMAC channel 0 to 5 */#define IRQ_GPIO_0 48 /* 48 to 175 for GPIO pin 0 to 127 *//************************************************************************* * RTC *************************************************************************/#define RTC_RCR (RTC_BASE + 0x00) /* RTC Control Register */#define RTC_RSR (RTC_BASE + 0x04) /* RTC Second Register */#define RTC_RSAR (RTC_BASE + 0x08) /* RTC Second Alarm Register */#define RTC_RGR (RTC_BASE + 0x0c) /* RTC Regulator Register */#define RTC_HCR (RTC_BASE + 0x20) /* Hibernate Control Register */#define RTC_HWFCR (RTC_BASE + 0x24) /* Hibernate Wakeup Filter Counter Reg */#define RTC_HRCR (RTC_BASE + 0x28) /* Hibernate Reset Counter Register */#define RTC_HWCR (RTC_BASE + 0x2c) /* Hibernate Wakeup Control Register */#define RTC_HWSR (RTC_BASE + 0x30) /* Hibernate Wakeup Status Register */#define REG_RTC_RCR REG32(RTC_RCR)#define REG_RTC_RSR REG32(RTC_RSR)#define REG_RTC_RSAR REG32(RTC_RSAR)#define REG_RTC_RGR REG32(RTC_RGR)#define REG_RTC_HCR REG32(RTC_HCR)#define REG_RTC_HWFCR REG32(RTC_HWFCR)#define REG_RTC_HRCR REG32(RTC_HRCR)#define REG_RTC_HWCR REG32(RTC_HWCR)#define REG_RTC_HWSR REG32(RTC_HWSR)/* RTC Control Register */#define RTC_RCR_WRDY (1 << 7) /* Write Ready Flag */#define RTC_RCR_HZ (1 << 6) /* 1Hz Flag */#define RTC_RCR_HZIE (1 << 5) /* 1Hz Interrupt Enable */#define RTC_RCR_AF (1 << 4) /* Alarm Flag */#define RTC_RCR_AIE (1 << 3) /* Alarm Interrupt Enable */#define RTC_RCR_AE (1 << 2) /* Alarm Enable */#define RTC_RCR_RTCE (1 << 0) /* RTC Enable *//* RTC Regulator Register */#define RTC_RGR_LOCK (1 << 31) /* Lock Bit */#define RTC_RGR_ADJC_BIT 16#define RTC_RGR_ADJC_MASK (0x3ff << RTC_RGR_ADJC_BIT)#define RTC_RGR_NC1HZ_BIT 0#define RTC_REG_NC1HZ_MASK (0xffff << RTC_RGR_NC1HZ_BIT)/* Hibernate Control Register */#define RTC_HCR_PD (1 << 0) /* Power Down *//* Hibernate Wakeup Filter Counter Register */#define RTC_HWFCR_BIT 5#define RTC_HWFCR_MASK (0x7ff << RTC_HWFCR_BIT)/* Hibernate Reset Counter Register */#define RTC_HRCR_BIT 5#define RTC_HRCR_MASK (0x7f << RTC_HRCR_BIT)/* Hibernate Wakeup Control Register */#define RTC_HWCR_WL (1 << 2) /* Wakeup pin level: 0-low 1-high */#define RTC_HWCR_EPIN (1 << 1) /* Wakeup pin wakeup enable */#define RTC_HWCR_EALM (1 << 0) /* RTC alarm wakeup enable *//* Hibernate Wakeup Status Register */#define RTC_HWSR_HR (1 << 5) /* Hibernate reset */#define RTC_HWSR_POR (1 << 4) /* POR reset */#define RTC_HWSR_PIN (1 << 1) /* Wakeup pin status bit */#define RTC_HWSR_ALM (1 << 0) /* RTC alarm status bit *//************************************************************************* * CPM (Clock reset and Power control Management) *************************************************************************/#define CPM_CPCCR (CPM_BASE+0x00)#define CPM_CPPCR (CPM_BASE+0x10)#define CPM_I2SCDR (CPM_BASE+0x60)#define CPM_LPCDR (CPM_BASE+0x64)#define CPM_MSCCDR (CPM_BASE+0x68)#define CPM_UHCCDR (CPM_BASE+0x6C)#define CPM_LCR (CPM_BASE+0x04)#define CPM_CLKGR (CPM_BASE+0x20)#define CPM_SCR (CPM_BASE+0x24)#define CPM_HCR (CPM_BASE+0x30)#define CPM_HWFCR (CPM_BASE+0x34)#define CPM_HRCR (CPM_BASE+0x38)#define CPM_HWCR (CPM_BASE+0x3c)#define CPM_HWSR (CPM_BASE+0x40)#define CPM_HSPR (CPM_BASE+0x44)#define CPM_RSR (CPM_BASE+0x08)#define REG_CPM_CPCCR REG32(CPM_CPCCR)#define REG_CPM_CPPCR REG32(CPM_CPPCR)#define REG_CPM_I2SCDR REG32(CPM_I2SCDR)#define REG_CPM_LPCDR REG32(CPM_LPCDR)#define REG_CPM_MSCCDR REG32(CPM_MSCCDR)#define REG_CPM_UHCCDR REG32(CPM_UHCCDR)#define REG_CPM_LCR REG32(CPM_LCR)#define REG_CPM_CLKGR REG32(CPM_CLKGR)#define REG_CPM_SCR REG32(CPM_SCR)#define REG_CPM_HCR REG32(CPM_HCR)#define REG_CPM_HWFCR REG32(CPM_HWFCR)#define REG_CPM_HRCR REG32(CPM_HRCR)#define REG_CPM_HWCR REG32(CPM_HWCR)#define REG_CPM_HWSR REG32(CPM_HWSR)#define REG_CPM_HSPR REG32(CPM_HSPR)#define REG_CPM_RSR REG32(CPM_RSR)/* Clock Control Register */#define CPM_CPCCR_I2CS (1 << 31)#define CPM_CPCCR_CLKOEN (1 << 30)#define CPM_CPCCR_UCS (1 << 29)#define CPM_CPCCR_UDIV_BIT 23#define CPM_CPCCR_UDIV_MASK (0x3f << CPM_CPCCR_UDIV_BIT)#define CPM_CPCCR_CE (1 << 22)#define CPM_CPCCR_PCS (1 << 21)#define CPM_CPCCR_LDIV_BIT 16#define CPM_CPCCR_LDIV_MASK (0x1f << CPM_CPCCR_LDIV_BIT)#define CPM_CPCCR_MDIV_BIT 12#define CPM_CPCCR_MDIV_MASK (0x0f << CPM_CPCCR_MDIV_BIT)#define CPM_CPCCR_PDIV_BIT 8#define CPM_CPCCR_PDIV_MASK (0x0f << CPM_CPCCR_PDIV_BIT)#define CPM_CPCCR_HDIV_BIT 4#define CPM_CPCCR_HDIV_MASK (0x0f << CPM_CPCCR_HDIV_BIT)#define CPM_CPCCR_CDIV_BIT 0#define CPM_CPCCR_CDIV_MASK (0x0f << CPM_CPCCR_CDIV_BIT)/* I2S Clock Divider Register */#define CPM_I2SCDR_I2SDIV_BIT 0#define CPM_I2SCDR_I2SDIV_MASK (0x1ff << CPM_I2SCDR_I2SDIV_BIT)/* LCD Pixel Clock Divider Register */#define CPM_LPCDR_PIXDIV_BIT 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -