blob: f0a892ca4b8d617d4d1cfaec1768d0a573855be4 [file] [log] [blame]
Tony Xief6118cc2016-01-15 17:17:32 +08001/*
2 * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
Antonio Nino Diaz493bf332016-12-14 14:31:32 +000014 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
Tony Xief6118cc2016-01-15 17:17:32 +080018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef __SOC_H__
32#define __SOC_H__
33
34enum plls_id {
35 ABPLL_ID = 0,
36 ALPLL_ID,
37 DPLL_ID,
38 CPLL_ID,
39 GPLL_ID,
40 NPLL_ID,
41 END_PLL_ID,
42};
43
44/*****************************************************************************
45 * secure timer
46 *****************************************************************************/
47#define TIMER_LOADE_COUNT0 0x00
48#define TIMER_LOADE_COUNT1 0x04
49#define TIMER_CURRENT_VALUE0 0x08
50#define TIMER_CURRENT_VALUE1 0x0C
51#define TIMER_CONTROL_REG 0x10
52#define TIMER_INTSTATUS 0x18
53
54#define TIMER_EN 0x1
55
56#define STIMER1_BASE (STIME_BASE + 0x20)
57
58#define CYCL_24M_CNT_US(us) (24 * us)
59#define CYCL_24M_CNT_MS(ms) (ms * CYCL_24M_CNT_US(1000))
60
61/*****************************************************************************
62 * sgrf reg, offset
63 *****************************************************************************/
64#define SGRF_SOC_CON(n) (0x0 + (n) * 4)
65#define SGRF_BUSDMAC_CON(n) (0x100 + (n) * 4)
66
67#define SGRF_SOC_CON_NS 0xffff0000
68
69/*****************************************************************************
70 * con6[2]pmusram is security.
71 * con6[6]stimer is security.
72 *****************************************************************************/
73#define PMUSRAM_S_SHIFT 2
74#define PMUSRAM_S 1
75#define STIMER_S_SHIFT 6
76#define STIMER_S 1
77#define SGRF_SOC_CON7_BITS ((0xffff << 16) | \
78 (PMUSRAM_S << PMUSRAM_S_SHIFT) | \
79 (STIMER_S << STIMER_S_SHIFT))
80
81#define SGRF_BUSDMAC_CON0_NS 0xfffcfff8
82#define SGRF_BUSDMAC_CON1_NS 0xffff0fff
83
84/*
85 * sgrf_soc_con1~2, mask and offset
86 */
87#define CPU_BOOT_ADDR_WMASK 0xffff0000
88#define CPU_BOOT_ADDR_ALIGN 16
89
90/*****************************************************************************
91 * cru reg, offset
92 *****************************************************************************/
93#define CRU_SOFTRST_CON 0x300
94#define CRU_SOFTRSTS_CON(n) (CRU_SOFTRST_CON + ((n) * 4))
95#define CRU_SOFTRSTS_CON_CNT 15
96
97#define SOFTRST_DMA1 0x40004
98#define SOFTRST_DMA2 0x10001
99
100#define RST_DMA1_MSK 0x4
101#define RST_DMA2_MSK 0x0
102
103#define CRU_CLKSEL_CON 0x100
104#define CRU_CLKSELS_CON(i) (CRU_CLKSEL_CON + ((i) * 4))
105#define CRU_CLKSEL_CON_CNT 56
106
107#define CRU_CLKGATE_CON 0x200
108#define CRU_CLKGATES_CON(i) (CRU_CLKGATE_CON + ((i) * 4))
109#define CRU_CLKGATES_CON_CNT 25
110
111#define CRU_GLB_SRST_FST 0x280
112#define CRU_GLB_SRST_SND 0x284
113#define CRU_GLB_RST_CON 0x388
114
115#define CRU_CONS_GATEID(i) (16 * (i))
116#define GATE_ID(reg, bit) ((reg * 16) + bit)
117
118#define PMU_RST_BY_SECOND_SFT (BIT(1) << 2)
119#define PMU_RST_NOT_BY_SFT (BIT(1) << 2)
120
121/***************************************************************************
122 * pll
123 ***************************************************************************/
124#define PLL_PWR_DN_MSK (0x1 << 1)
125#define PLL_PWR_DN REG_WMSK_BITS(1, 1, 0x1)
126#define PLL_PWR_ON REG_WMSK_BITS(0, 1, 0x1)
127#define PLL_RESET REG_WMSK_BITS(1, 5, 0x1)
128#define PLL_RESET_RESUME REG_WMSK_BITS(0, 5, 0x1)
129#define PLL_BYPASS_MSK (0x1 << 0)
130#define PLL_BYPASS_W_MSK (PLL_BYPASS_MSK << 16)
131#define PLL_BYPASS REG_WMSK_BITS(1, 0, 0x1)
132#define PLL_NO_BYPASS REG_WMSK_BITS(0, 0, 0x1)
133#define PLL_MODE_SHIFT 8
134#define PLL_MODE_MSK 0x3
135#define PLLS_MODE_WMASK (PLL_MODE_MSK << (16 + PLL_MODE_SHIFT))
136#define PLL_SLOW 0x0
137#define PLL_NORM 0x1
138#define PLL_DEEP 0x2
139#define PLL_SLOW_BITS REG_WMSK_BITS(PLL_SLOW, 8, 0x3)
140#define PLL_NORM_BITS REG_WMSK_BITS(PLL_NORM, 8, 0x3)
141#define PLL_DEEP_BITS REG_WMSK_BITS(PLL_DEEP, 8, 0x3)
142
143#define PLL_CONS(id, i) ((id) * 0x10 + ((i) * 4))
144
145#define REG_W_MSK(bits_shift, msk) \
146 ((msk) << ((bits_shift) + 16))
147#define REG_VAL_CLRBITS(val, bits_shift, msk) \
148 (val & (~(msk << bits_shift)))
149#define REG_SET_BITS(bits, bits_shift, msk) \
150 (((bits) & (msk)) << (bits_shift))
151#define REG_WMSK_BITS(bits, bits_shift, msk) \
152 (REG_W_MSK(bits_shift, msk) | \
153 REG_SET_BITS(bits, bits_shift, msk))
154
155#define regs_updata_bit_set(addr, shift) \
156 regs_updata_bits((addr), 0x1, 0x1, (shift))
157#define regs_updata_bit_clr(addr, shift) \
158 regs_updata_bits((addr), 0x0, 0x1, (shift))
159
160void __dead2 soc_sys_global_soft_reset(void);
161void regs_updata_bits(uintptr_t addr, uint32_t val,
162 uint32_t mask, uint32_t shift);
163void soc_sleep_config(void);
164void pm_plls_resume(void);
165
166#endif /* __SOC_H__ */