Home | History | Annotate | Line # | Download | only in ingenic
ingenic_regs.h revision 1.3
      1  1.3  macallan /*	$NetBSD: ingenic_regs.h,v 1.3 2014/12/23 15:03:56 macallan Exp $ */
      2  1.1  macallan 
      3  1.1  macallan /*-
      4  1.1  macallan  * Copyright (c) 2014 Michael Lorenz
      5  1.1  macallan  * All rights reserved.
      6  1.1  macallan  *
      7  1.1  macallan  * Redistribution and use in source and binary forms, with or without
      8  1.1  macallan  * modification, are permitted provided that the following conditions
      9  1.1  macallan  * are met:
     10  1.1  macallan  * 1. Redistributions of source code must retain the above copyright
     11  1.1  macallan  *    notice, this list of conditions and the following disclaimer.
     12  1.1  macallan  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  macallan  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  macallan  *    documentation and/or other materials provided with the distribution.
     15  1.1  macallan  *
     16  1.1  macallan  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     17  1.1  macallan  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     18  1.1  macallan  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     19  1.1  macallan  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     20  1.1  macallan  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     21  1.1  macallan  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     22  1.1  macallan  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     23  1.1  macallan  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     24  1.1  macallan  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     25  1.1  macallan  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26  1.1  macallan  * POSSIBILITY OF SUCH DAMAGE.
     27  1.1  macallan  */
     28  1.1  macallan 
     29  1.1  macallan #include <mips/locore.h>
     30  1.1  macallan 
     31  1.1  macallan #ifndef INGENIC_REGS_H
     32  1.1  macallan #define INGENIC_REGS_H
     33  1.1  macallan 
     34  1.1  macallan /* UARTs, mostly 16550 compatible with 32bit spaced registers */
     35  1.1  macallan #define JZ_UART0 0x10030000
     36  1.1  macallan #define JZ_UART1 0x10031000
     37  1.1  macallan #define JZ_UART2 0x10032000
     38  1.1  macallan #define JZ_UART3 0x10033000
     39  1.1  macallan #define JZ_UART4 0x10034000
     40  1.1  macallan 
     41  1.1  macallan /* watchdog */
     42  1.1  macallan #define JZ_WDOG_TDR	0x10002000	/* compare */
     43  1.1  macallan #define JZ_WDOG_TCER	0x10002004
     44  1.1  macallan 	#define TCER_ENABLE	0x01	/* enable counter */
     45  1.1  macallan #define JZ_WDOG_TCNT	0x10002008	/* 16bit up count */
     46  1.1  macallan #define JZ_WDOG_TCSR	0x1000200c
     47  1.1  macallan 	#define TCSR_PCK_EN	0x01	/* PCLK */
     48  1.1  macallan 	#define TCSR_RTC_EN	0x02	/* RTCCLK - 32.768kHz */
     49  1.2  macallan 	#define TCSR_EXT_EN	0x04	/* EXTCLK - 48MHz */
     50  1.1  macallan 	#define TCSR_PRESCALE_M	0x38
     51  1.1  macallan 	#define TCSR_DIV_1	0x00
     52  1.1  macallan 	#define TCSR_DIV_4	0x08
     53  1.1  macallan 	#define TCSR_DIV_16	0x10
     54  1.1  macallan 	#define TCSR_DIV_64	0x18
     55  1.1  macallan 	#define TCSR_DIV_256	0x20
     56  1.1  macallan 	#define TCSR_DIV_1024	0x28
     57  1.1  macallan 
     58  1.1  macallan /* timers and PWMs */
     59  1.1  macallan #define JZ_TC_TER	0x10002010	/* TC enable reg, ro */
     60  1.1  macallan #define JZ_TC_TESR	0x10002014	/* TC enable set reg. */
     61  1.1  macallan 	#define TESR_TCST0	0x0001	/* enable counter 0 */
     62  1.1  macallan 	#define TESR_TCST1	0x0002	/* enable counter 1 */
     63  1.1  macallan 	#define TESR_TCST2	0x0004	/* enable counter 2 */
     64  1.1  macallan 	#define TESR_TCST3	0x0008	/* enable counter 3 */
     65  1.1  macallan 	#define TESR_TCST4	0x0010	/* enable counter 4 */
     66  1.2  macallan 	#define TESR_TCST5	0x0020	/* enable counter 5 */
     67  1.2  macallan 	#define TESR_TCST6	0x0040	/* enable counter 6 */
     68  1.2  macallan 	#define TESR_TCST7	0x0080	/* enable counter 7 */
     69  1.1  macallan 	#define TESR_OST	0x8000	/* enable OST */
     70  1.1  macallan #define JZ_TC_TECR	0x10002018	/* TC enable clear reg. */
     71  1.2  macallan #define JZ_TC_TFR	0x10002020
     72  1.2  macallan 	#define TFR_FFLAG0	0x00000001	/* channel 0 */
     73  1.2  macallan 	#define TFR_FFLAG1	0x00000002	/* channel 1 */
     74  1.2  macallan 	#define TFR_FFLAG2	0x00000004	/* channel 2 */
     75  1.2  macallan 	#define TFR_FFLAG3	0x00000008	/* channel 3 */
     76  1.2  macallan 	#define TFR_FFLAG4	0x00000010	/* channel 4 */
     77  1.2  macallan 	#define TFR_FFLAG5	0x00000020	/* channel 5 */
     78  1.2  macallan 	#define TFR_FFLAG6	0x00000040	/* channel 6 */
     79  1.2  macallan 	#define TFR_FFLAG7	0x00000080	/* channel 7 */
     80  1.2  macallan 	#define TFR_OSTFLAG	0x00008000	/* OS timer */
     81  1.2  macallan #define JZ_TC_TFSR	0x10002024	/* timer flag set */
     82  1.2  macallan #define JZ_TC_TFCR	0x10002028	/* timer flag clear */
     83  1.2  macallan #define JZ_TC_TMR	0x10002030	/* timer flag mask */
     84  1.2  macallan #define JZ_TC_TMSR	0x10002034	/* timer flag mask set */
     85  1.2  macallan #define JZ_TC_TMCR	0x10002038	/* timer flag mask clear*/
     86  1.2  macallan 
     87  1.2  macallan #define JZ_TC_TDFR(n)	(0x10002040 + (n * 0x10))	/* FULL compare */
     88  1.2  macallan #define JZ_TC_TDHR(n)	(0x10002044 + (n * 0x10))	/* HALF compare */
     89  1.2  macallan #define JZ_TC_TCNT(n)	(0x10002048 + (n * 0x10))	/* count */
     90  1.2  macallan 
     91  1.2  macallan #define JZ_TC_TCSR(n)	(0x1000204c + (n * 0x10))
     92  1.2  macallan /* same bits as in JZ_WDOG_TCSR	*/
     93  1.1  macallan 
     94  1.1  macallan /* operating system timer */
     95  1.1  macallan #define JZ_OST_DATA	0x100020e0	/* compare */
     96  1.1  macallan #define JZ_OST_CNT_LO	0x100020e4
     97  1.1  macallan #define JZ_OST_CNT_HI	0x100020e8
     98  1.1  macallan #define JZ_OST_CTRL	0x100020ec
     99  1.1  macallan 	#define OSTC_PCK_EN	0x0001	/* use PCLK */
    100  1.1  macallan 	#define OSTC_RTC_EN	0x0002	/* use RTCCLK */
    101  1.1  macallan 	#define OSTC_EXT_EN	0x0004	/* use EXTCLK */
    102  1.1  macallan 	#define OSTC_PRESCALE_M	0x0038
    103  1.1  macallan 	#define OSTC_DIV_1	0x0000
    104  1.1  macallan 	#define OSTC_DIV_4	0x0008
    105  1.1  macallan 	#define OSTC_DIV_16	0x0010
    106  1.1  macallan 	#define OSTC_DIV_64	0x0018
    107  1.1  macallan 	#define OSTC_DIV_256	0x0020
    108  1.1  macallan 	#define OSTC_DIV_1024	0x0028
    109  1.1  macallan 	#define OSTC_SHUTDOWN	0x0200
    110  1.1  macallan 	#define OSTC_MODE	0x8000	/* 0 - reset to 0 when = OST_DATA */
    111  1.1  macallan #define JZ_OST_CNT_U32	0x100020fc	/* copy of CNT_HI when reading CNT_LO */
    112  1.1  macallan 
    113  1.1  macallan static inline void
    114  1.1  macallan writereg(uint32_t reg, uint32_t val)
    115  1.1  macallan {
    116  1.1  macallan 	*(int32_t *)MIPS_PHYS_TO_KSEG1(reg) = val;
    117  1.1  macallan 	wbflush();
    118  1.1  macallan }
    119  1.1  macallan 
    120  1.1  macallan static inline uint32_t
    121  1.1  macallan readreg(uint32_t reg)
    122  1.1  macallan {
    123  1.1  macallan 	wbflush();
    124  1.1  macallan 	return *(int32_t *)MIPS_PHYS_TO_KSEG1(reg);
    125  1.1  macallan }
    126  1.1  macallan 
    127  1.2  macallan /* extra CP0 registers */
    128  1.2  macallan static inline uint32_t
    129  1.2  macallan MFC0(uint32_t r, uint32_t s)
    130  1.2  macallan {
    131  1.2  macallan 	uint32_t ret = 0x12345678;
    132  1.2  macallan 
    133  1.2  macallan 	__asm volatile("mfc0 %0, $%1, %2; nop;" : "=r"(ret) : "i"(r), "i"(s));
    134  1.2  macallan 	return ret;
    135  1.2  macallan }
    136  1.2  macallan 
    137  1.2  macallan #define MTC0(v, r, s) __asm volatile("mtc0 %0, $%1, %2; nop;" :: "r"(v), "i"(r), "i"(s))
    138  1.2  macallan 
    139  1.2  macallan #define CP0_CORE_CTRL	12	/* select 2 */
    140  1.2  macallan 	#define CC_SW_RST0	1	/* reset core 0 */
    141  1.2  macallan 	#define CC_SW_RST1	2	/* reset core 1 */
    142  1.2  macallan 	#define CC_RPC0		0x100	/* dedicater reset entry core 0 */
    143  1.2  macallan 	#define CC_RPC1		0x200	/* -- || -- core 1 */
    144  1.2  macallan 	#define CC_SLEEP0M	0x10000	/* mask sleep core 0 */
    145  1.2  macallan 	#define CC_SLEEP1M	0x20000	/* mask sleep core 1 */
    146  1.2  macallan 
    147  1.2  macallan /* cores status, 12 select 3 */
    148  1.2  macallan #define CS_MIRQ0_P	0x00001	/* mailbox IRQ for 0 pending */
    149  1.2  macallan #define CS_MIRQ1_P	0x00002	/* || core 1 */
    150  1.2  macallan #define CS_IRQ0_P	0x00100	/* peripheral IRQ for core 0 */
    151  1.2  macallan #define CS_IRQ1_P	0x00200	/* || core 1 */
    152  1.2  macallan #define CS_SLEEP0	0x10000	/* core 0 sleeping */
    153  1.2  macallan #define CS_SLEEP1	0x20000	/* core 1 sleeping */
    154  1.2  macallan 
    155  1.2  macallan /* cores reset entry & IRQ masks - 12 select 4 */
    156  1.2  macallan #define REIM_MIRQ0_M	0x00001	/* allow mailbox IRQ for core 0 */
    157  1.2  macallan #define REIM_MIRQ1_M	0x00002	/* allow mailbox IRQ for core 1 */
    158  1.2  macallan #define REIM_IRQ0_M	0x00100	/* allow peripheral IRQ for core 0 */
    159  1.2  macallan #define REIM_IRQ1_M	0x00200	/* allow peripheral IRQ for core 1 */
    160  1.2  macallan #define REIM_ENTRY_M	0xffff0000	/* reset exception entry if RPCn=1 */
    161  1.2  macallan 
    162  1.2  macallan #define CP0_CORE_MBOX	20	/* select 0 for core 0, 1 for 1 */
    163  1.2  macallan 
    164  1.3  macallan /* power management */
    165  1.3  macallan #define JZ_CLKGR0	0x10000020	/* CLocK Gating Registers */
    166  1.3  macallan #define JZ_OPCR		0x10000024	/* Oscillator Power Control Reg. */
    167  1.3  macallan #define JZ_CLKGR1	0x10000028	/* CLocK Gating Registers */
    168  1.3  macallan #define JZ_USBPCR	0x1000003c
    169  1.3  macallan 	#define USB_MODE	0x80000000	/* 1 - otg */
    170  1.3  macallan 	#define AVLD_REG	0x40000000
    171  1.3  macallan 	#define IDPULLUP_MASK	0x30000000
    172  1.3  macallan 	#define INCR_MASK	0x08000000
    173  1.3  macallan 	#define TCRISETUNE	0x04000000
    174  1.3  macallan 	#define COMMONONN	0x02000000
    175  1.3  macallan 	#define VBUSVLDEXT	0x01000000
    176  1.3  macallan 	#define VBUSVLDEXTSEL	0x00800000
    177  1.3  macallan 	#define POR		0x00400000
    178  1.3  macallan 	#define SIDDQ		0x00200000
    179  1.3  macallan 	#define OTG_DISABLE	0x00100000
    180  1.3  macallan 	#define COMPDISTUNE_M	0x000e0000
    181  1.3  macallan 	#define OTGTUNE		0x0001c000
    182  1.3  macallan 	#define SQRXTUNE	0x00003800
    183  1.3  macallan 	#define TXFSLSTUNE	0x00000780
    184  1.3  macallan 	#define TXPREEMPHTUNE	0x00000040
    185  1.3  macallan 	#define TXHSXVTUNE	0x00000030
    186  1.3  macallan 	#define TXVREFTUNE	0x0000000f
    187  1.3  macallan 
    188  1.3  macallan #define JZ_USBPCR1	0x10000048
    189  1.3  macallan 	#define PCR_SYNOPSYS	0x10000000	/* Mentor mode otherwise */
    190  1.3  macallan 	#define PCR_REFCLK_CORE	0x0c000000
    191  1.3  macallan 	#define PCR_REFCLK_XO25	0x04000000
    192  1.3  macallan 	#define PCR_REFCLK_CO	0x00000000
    193  1.3  macallan 	#define PCR_CLK_M	0x03000000	/* clock */
    194  1.3  macallan 	#define PCR_CLK_192	0x03000000	/* 19.2MHz */
    195  1.3  macallan 	#define PCR_CLK_48	0x02000000	/* 48MHz */
    196  1.3  macallan 	#define PCR_CLK_24	0x01000000	/* 24MHz */
    197  1.3  macallan 	#define PCR_CLK_12	0x00000000	/* 12MHz */
    198  1.3  macallan 	#define PCR_DMPD1	0x00800000	/* pull down D- on port 1 */
    199  1.3  macallan 	#define PCR_DPPD1	0x00400000	/* pull down D+ on port 1 */
    200  1.3  macallan 	#define PCR_PORT0_RST	0x00200000	/* port 0 reset */
    201  1.3  macallan 	#define PCR_PORT1_RST	0x00100000	/* port 1 reset */
    202  1.3  macallan 	#define PCR_WORD_I_F0	0x00080000	/* 1: 16bit/30M, 8/60 otherw. */
    203  1.3  macallan 	#define PCR_WORD_I_F1	0x00040000	/* same for port 1 */
    204  1.3  macallan 	#define PCR_COMPDISTUNE	0x00038000	/* disconnect threshold */
    205  1.3  macallan 	#define PCR_SQRXTUNE1	0x00007000	/* squelch threshold */
    206  1.3  macallan 	#define PCR_TXFSLSTUNE1	0x00000f00	/* FS/LS impedance adj. */
    207  1.3  macallan 	#define PCR_TXPREEMPH	0x00000080	/* HS transm. pre-emphasis */
    208  1.3  macallan 	#define PCR_TXHSXVTUNE1	0x00000060	/* dp/dm voltage adj. */
    209  1.3  macallan 	#define PCR_TXVREFTUNE1	0x00000017	/* HS DC voltage adj. */
    210  1.3  macallan 	#define PCR_TXRISETUNE1	0x00000001	/* risa/fall wave adj. */
    211  1.3  macallan 
    212  1.3  macallan #define JZ_SPCR0	0x100000b8	/* SRAM Power Control Registers */
    213  1.3  macallan #define JZ_SPCR1	0x100000bc
    214  1.3  macallan #define JZ_SRBC		0x100000c4	/* Soft Reset & Bus Control */
    215  1.3  macallan 
    216  1.2  macallan /* interrupt controller */
    217  1.2  macallan #define JZ_ICSR0	0x10001000	/* raw IRQ line status */
    218  1.2  macallan #define JZ_ICMR0	0x10001004	/* IRQ mask, 1 masks IRQ */
    219  1.2  macallan #define JZ_ICMSR0	0x10001008	/* sets bits in mask register */
    220  1.2  macallan #define JZ_ICMCR0	0x1000100c	/* clears bits in maks register */
    221  1.2  macallan #define JZ_ICPR0	0x10001010	/* line status after masking */
    222  1.2  macallan 
    223  1.2  macallan #define JZ_ICSR1	0x10001020	/* raw IRQ line status */
    224  1.2  macallan #define JZ_ICMR1	0x10001024	/* IRQ mask, 1 masks IRQ */
    225  1.2  macallan #define JZ_ICMSR1	0x10001028	/* sets bits in mask register */
    226  1.2  macallan #define JZ_ICMCR1	0x1000102c	/* clears bits in maks register */
    227  1.2  macallan #define JZ_ICPR1	0x10001030	/* line status after masking */
    228  1.2  macallan 
    229  1.2  macallan #define JZ_DSR0		0x10001034	/* source for PDMA */
    230  1.2  macallan #define JZ_DMR0		0x10001038	/* mask for PDMA */
    231  1.2  macallan #define JZ_DPR0		0x1000103c	/* pending for PDMA */
    232  1.2  macallan 
    233  1.2  macallan #define JZ_DSR1		0x10001040	/* source for PDMA */
    234  1.2  macallan #define JZ_DMR1		0x10001044	/* mask for PDMA */
    235  1.2  macallan #define JZ_DPR1		0x10001048	/* pending for PDMA */
    236  1.2  macallan 
    237  1.2  macallan #endif /* INGENIC_REGS_H */
    238