ingenic_regs.h revision 1.1 1 1.1 macallan /* $NetBSD: ingenic_regs.h,v 1.1 2014/11/22 15:17:01 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.1 macallan #define TCSR_EXT_EN 0x04 /* EXTCLK - 12MHz? */
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.1 macallan #define TESR_TCST5 0x0014 /* enable counter 5 */
67 1.1 macallan #define TESR_TCST6 0x0018 /* enable counter 6 */
68 1.1 macallan #define TESR_TCST7 0x001c /* 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.1 macallan
72 1.1 macallan /* operating system timer */
73 1.1 macallan #define JZ_OST_DATA 0x100020e0 /* compare */
74 1.1 macallan #define JZ_OST_CNT_LO 0x100020e4
75 1.1 macallan #define JZ_OST_CNT_HI 0x100020e8
76 1.1 macallan #define JZ_OST_CTRL 0x100020ec
77 1.1 macallan #define OSTC_PCK_EN 0x0001 /* use PCLK */
78 1.1 macallan #define OSTC_RTC_EN 0x0002 /* use RTCCLK */
79 1.1 macallan #define OSTC_EXT_EN 0x0004 /* use EXTCLK */
80 1.1 macallan #define OSTC_PRESCALE_M 0x0038
81 1.1 macallan #define OSTC_DIV_1 0x0000
82 1.1 macallan #define OSTC_DIV_4 0x0008
83 1.1 macallan #define OSTC_DIV_16 0x0010
84 1.1 macallan #define OSTC_DIV_64 0x0018
85 1.1 macallan #define OSTC_DIV_256 0x0020
86 1.1 macallan #define OSTC_DIV_1024 0x0028
87 1.1 macallan #define OSTC_SHUTDOWN 0x0200
88 1.1 macallan #define OSTC_MODE 0x8000 /* 0 - reset to 0 when = OST_DATA */
89 1.1 macallan #define JZ_OST_CNT_U32 0x100020fc /* copy of CNT_HI when reading CNT_LO */
90 1.1 macallan
91 1.1 macallan static inline void
92 1.1 macallan writereg(uint32_t reg, uint32_t val)
93 1.1 macallan {
94 1.1 macallan *(int32_t *)MIPS_PHYS_TO_KSEG1(reg) = val;
95 1.1 macallan wbflush();
96 1.1 macallan }
97 1.1 macallan
98 1.1 macallan static inline uint32_t
99 1.1 macallan readreg(uint32_t reg)
100 1.1 macallan {
101 1.1 macallan wbflush();
102 1.1 macallan return *(int32_t *)MIPS_PHYS_TO_KSEG1(reg);
103 1.1 macallan }
104 1.1 macallan
105 1.1 macallan #endif /* INGENIC_REGS_H */