blob: 295c6b0ea9bd5dc1de52c70531f4d5bc8801d0dd [file] [log] [blame]
Vitaly Andrianovef509b92014-04-04 13:16:53 -04001/*
2 * Keystone2: Common SoC definitions, structures etc.
3 *
4 * (C) Copyright 2012-2014
5 * Texas Instruments Incorporated, <www.ti.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9#ifndef __ASM_ARCH_HARDWARE_H
10#define __ASM_ARCH_HARDWARE_H
11
12#include <config.h>
13
14#ifndef __ASSEMBLY__
15
16#include <linux/sizes.h>
17#include <asm/io.h>
18
19#define REG(addr) (*(volatile unsigned int *)(addr))
20#define REG_P(addr) ((volatile unsigned int *)(addr))
21
22typedef volatile unsigned int dv_reg;
23typedef volatile unsigned int *dv_reg_p;
24
Vitaly Andrianovef509b92014-04-04 13:16:53 -040025#endif
26
27#define BIT(x) (1 << (x))
28
29#define KS2_DDRPHY_PIR_OFFSET 0x04
30#define KS2_DDRPHY_PGCR0_OFFSET 0x08
31#define KS2_DDRPHY_PGCR1_OFFSET 0x0C
32#define KS2_DDRPHY_PGSR0_OFFSET 0x10
33#define KS2_DDRPHY_PGSR1_OFFSET 0x14
34#define KS2_DDRPHY_PLLCR_OFFSET 0x18
35#define KS2_DDRPHY_PTR0_OFFSET 0x1C
36#define KS2_DDRPHY_PTR1_OFFSET 0x20
37#define KS2_DDRPHY_PTR2_OFFSET 0x24
38#define KS2_DDRPHY_PTR3_OFFSET 0x28
39#define KS2_DDRPHY_PTR4_OFFSET 0x2C
40#define KS2_DDRPHY_DCR_OFFSET 0x44
41
42#define KS2_DDRPHY_DTPR0_OFFSET 0x48
43#define KS2_DDRPHY_DTPR1_OFFSET 0x4C
44#define KS2_DDRPHY_DTPR2_OFFSET 0x50
45
46#define KS2_DDRPHY_MR0_OFFSET 0x54
47#define KS2_DDRPHY_MR1_OFFSET 0x58
48#define KS2_DDRPHY_MR2_OFFSET 0x5C
49#define KS2_DDRPHY_DTCR_OFFSET 0x68
50#define KS2_DDRPHY_PGCR2_OFFSET 0x8C
51
52#define KS2_DDRPHY_ZQ0CR1_OFFSET 0x184
53#define KS2_DDRPHY_ZQ1CR1_OFFSET 0x194
54#define KS2_DDRPHY_ZQ2CR1_OFFSET 0x1A4
55#define KS2_DDRPHY_ZQ3CR1_OFFSET 0x1B4
56
57#define KS2_DDRPHY_DATX8_8_OFFSET 0x3C0
58
59#define IODDRM_MASK 0x00000180
60#define ZCKSEL_MASK 0x01800000
61#define CL_MASK 0x00000072
62#define WR_MASK 0x00000E00
63#define BL_MASK 0x00000003
64#define RRMODE_MASK 0x00040000
65#define UDIMM_MASK 0x20000000
66#define BYTEMASK_MASK 0x0003FC00
67#define MPRDQ_MASK 0x00000080
68#define PDQ_MASK 0x00000070
69#define NOSRA_MASK 0x08000000
70#define ECC_MASK 0x00000001
71
Hao Zhang5c76f782014-07-16 00:59:22 +030072/* DDR3 definitions */
73#define KS2_DDR3A_EMIF_CTRL_BASE 0x21010000
74#define KS2_DDR3A_EMIF_DATA_BASE 0x80000000
75#define KS2_DDR3A_DDRPHYC 0x02329000
76
Vitaly Andrianovef509b92014-04-04 13:16:53 -040077#define KS2_DDR3_MIDR_OFFSET 0x00
78#define KS2_DDR3_STATUS_OFFSET 0x04
79#define KS2_DDR3_SDCFG_OFFSET 0x08
80#define KS2_DDR3_SDRFC_OFFSET 0x10
81#define KS2_DDR3_SDTIM1_OFFSET 0x18
82#define KS2_DDR3_SDTIM2_OFFSET 0x1C
83#define KS2_DDR3_SDTIM3_OFFSET 0x20
84#define KS2_DDR3_SDTIM4_OFFSET 0x28
85#define KS2_DDR3_PMCTL_OFFSET 0x38
86#define KS2_DDR3_ZQCFG_OFFSET 0xC8
87
Hao Zhang101eec52014-07-09 19:48:41 +030088#define KS2_DDR3_PLLCTRL_PHY_RESET 0x80000000
89
Murali Karicheriafee59c2014-05-29 18:57:12 +030090#define KS2_UART0_BASE 0x02530c00
91#define KS2_UART1_BASE 0x02531000
92
Hao Zhang5c76f782014-07-16 00:59:22 +030093/* Boot Config */
94#define KS2_DEVICE_STATE_CTRL_BASE 0x02620000
95#define KS2_JTAG_ID_REG (KS2_DEVICE_STATE_CTRL_BASE + 0x18)
96#define KS2_DEVSTAT (KS2_DEVICE_STATE_CTRL_BASE + 0x20)
97
Khoronzhuk, Ivan04b7ce02014-07-09 19:48:39 +030098/* PSC */
99#define KS2_PSC_BASE 0x02350000
Hao Zhang7b26c1f2014-07-09 19:48:44 +0300100#define KS2_LPSC_GEM_0 15
101#define KS2_LPSC_TETRIS 52
102#define KS2_TETRIS_PWR_DOMAIN 31
Khoronzhuk, Ivan04b7ce02014-07-09 19:48:39 +0300103
Hao Zhang5c76f782014-07-16 00:59:22 +0300104/* Chip configuration unlock codes and registers */
105#define KS2_KICK0 (KS2_DEVICE_STATE_CTRL_BASE + 0x38)
106#define KS2_KICK1 (KS2_DEVICE_STATE_CTRL_BASE + 0x3c)
107#define KS2_KICK0_MAGIC 0x83e70b13
108#define KS2_KICK1_MAGIC 0x95a4f1e0
109
110/* PLL control registers */
111#define KS2_MAINPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x350)
112#define KS2_MAINPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x354)
113#define KS2_PASSPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x358)
114#define KS2_PASSPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x35C)
115#define KS2_DDR3APLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x360)
116#define KS2_DDR3APLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x364)
117#define KS2_ARMPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x370)
118#define KS2_ARMPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x374)
119
120#define KS2_PLL_CNTRL_BASE 0x02310000
121#define KS2_CLOCK_BASE KS2_PLL_CNTRL_BASE
Hao Zhanga9068472014-07-16 00:59:27 +0300122#define KS2_RSTCTRL_RSTYPE (KS2_PLL_CNTRL_BASE + 0xe4)
Hao Zhang5c76f782014-07-16 00:59:22 +0300123#define KS2_RSTCTRL (KS2_PLL_CNTRL_BASE + 0xe8)
Murali Karicheri6c343822014-09-10 15:54:59 +0300124#define KS2_RSTCTRL_RSCFG (KS2_PLL_CNTRL_BASE + 0xec)
Hao Zhang5c76f782014-07-16 00:59:22 +0300125#define KS2_RSTCTRL_KEY 0x5a69
126#define KS2_RSTCTRL_MASK 0xffff0000
127#define KS2_RSTCTRL_SWRST 0xfffe0000
Murali Karicheri6c343822014-09-10 15:54:59 +0300128#define KS2_RSTYPE_PLL_SOFT BIT(13)
Hao Zhang5c76f782014-07-16 00:59:22 +0300129
130/* SPI */
131#define KS2_SPI0_BASE 0x21000400
132#define KS2_SPI1_BASE 0x21000600
133#define KS2_SPI2_BASE 0x21000800
134#define KS2_SPI_BASE KS2_SPI0_BASE
135
Khoronzhuk, Ivan909ea9a2014-06-07 05:10:49 +0300136/* AEMIF */
137#define KS2_AEMIF_CNTRL_BASE 0x21000a00
138#define DAVINCI_ASYNC_EMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE
139
Hao Zhang7b26c1f2014-07-09 19:48:44 +0300140/* Flag from ks2_debug options to check if DSPs need to stay ON */
141#define DBG_LEAVE_DSPS_ON 0x1
142
Hao Zhangbc45d572014-10-22 16:32:30 +0300143/* MSMC control */
144#define KS2_MSMC_CTRL_BASE 0x0bc00000
145#define KS2_MSMC_SEGMENT_TETRIS 8
146#define KS2_MSMC_SEGMENT_NETCP 9
147#define KS2_MSMC_SEGMENT_QM_PDSP 10
148#define KS2_MSMC_SEGMENT_PCIE0 11
149
Vitaly Andrianov61f66fd2014-07-25 22:23:19 +0300150/* Device speed */
151#define KS2_REV1_DEVSPEED (KS2_DEVICE_STATE_CTRL_BASE + 0xc98)
152#define KS2_EFUSE_BOOTROM (KS2_DEVICE_STATE_CTRL_BASE + 0xc90)
Hao Zhangc4995a82014-10-22 16:32:28 +0300153#define KS2_MISC_CTRL (KS2_DEVICE_STATE_CTRL_BASE + 0xc7c)
Vitaly Andrianov61f66fd2014-07-25 22:23:19 +0300154
Hao Zhang5c76f782014-07-16 00:59:22 +0300155/* Queue manager */
Khoronzhuk, Ivanafa479c2014-09-05 19:02:45 +0300156#define KS2_QM_BASE_ADDRESS 0x23a80000
157#define KS2_QM_CONF_BASE 0x02a02000
Hao Zhang5c76f782014-07-16 00:59:22 +0300158#define KS2_QM_DESC_SETUP_BASE 0x02a03000
Khoronzhuk, Ivanafa479c2014-09-05 19:02:45 +0300159#define KS2_QM_STATUS_RAM_BASE 0x02a06000
160#define KS2_QM_INTD_CONF_BASE 0x02a0c000
161#define KS2_QM_PDSP1_CMD_BASE 0x02a20000
162#define KS2_QM_PDSP1_CTRL_BASE 0x02a0f000
163#define KS2_QM_PDSP1_IRAM_BASE 0x02a10000
164#define KS2_QM_MANAGER_QUEUES_BASE 0x02a80000
Hao Zhang5c76f782014-07-16 00:59:22 +0300165#define KS2_QM_MANAGER_Q_PROXY_BASE 0x02ac0000
166#define KS2_QM_QUEUE_STATUS_BASE 0x02a40000
Khoronzhuk, Ivanafa479c2014-09-05 19:02:45 +0300167#define KS2_QM_LINK_RAM_BASE 0x00100000
168#define KS2_QM_REGION_NUM 64
169#define KS2_QM_QPOOL_NUM 4000
Hao Zhang5c76f782014-07-16 00:59:22 +0300170
WingMan Kwokbc0e8d72014-09-05 22:26:23 +0300171/* USB */
172#define KS2_USB_SS_BASE 0x02680000
173#define KS2_USB_HOST_XHCI_BASE (KS2_USB_SS_BASE + 0x10000)
174#define KS2_DEV_USB_PHY_BASE 0x02620738
175#define KS2_USB_PHY_CFG_BASE 0x02630000
176
Vitaly Andrianovef509b92014-04-04 13:16:53 -0400177#ifdef CONFIG_SOC_K2HK
178#include <asm/arch/hardware-k2hk.h>
179#endif
180
Hao Zhang5c76f782014-07-16 00:59:22 +0300181#ifdef CONFIG_SOC_K2E
182#include <asm/arch/hardware-k2e.h>
183#endif
184
Hao Zhangc4995a82014-10-22 16:32:28 +0300185#ifdef CONFIG_SOC_K2L
186#include <asm/arch/hardware-k2l.h>
187#endif
188
Vitaly Andrianovef509b92014-04-04 13:16:53 -0400189#ifndef __ASSEMBLY__
190static inline int cpu_is_k2hk(void)
191{
Khoronzhuk, Ivan3d315382014-07-09 23:44:44 +0300192 unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG);
Vitaly Andrianovef509b92014-04-04 13:16:53 -0400193 unsigned int part_no = (jtag_id >> 12) & 0xffff;
194
195 return (part_no == 0xb981) ? 1 : 0;
196}
197
Hao Zhang5c76f782014-07-16 00:59:22 +0300198static inline int cpu_is_k2e(void)
199{
200 unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG);
201 unsigned int part_no = (jtag_id >> 12) & 0xffff;
202
203 return (part_no == 0xb9a6) ? 1 : 0;
204}
205
Hao Zhangc4995a82014-10-22 16:32:28 +0300206static inline int cpu_is_k2l(void)
207{
208 unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG);
209 unsigned int part_no = (jtag_id >> 12) & 0xffff;
210
211 return (part_no == 0xb9a7) ? 1 : 0;
212}
213
Vitaly Andrianovef509b92014-04-04 13:16:53 -0400214static inline int cpu_revision(void)
215{
Khoronzhuk, Ivan3d315382014-07-09 23:44:44 +0300216 unsigned int jtag_id = __raw_readl(KS2_JTAG_ID_REG);
Vitaly Andrianovef509b92014-04-04 13:16:53 -0400217 unsigned int rev = (jtag_id >> 28) & 0xf;
218
219 return rev;
220}
221
Vitaly Andrianovef509b92014-04-04 13:16:53 -0400222int cpu_to_bus(u32 *ptr, u32 length);
Vitaly Andrianovef509b92014-04-04 13:16:53 -0400223void sdelay(unsigned long);
224
225#endif
226
227#endif /* __ASM_ARCH_HARDWARE_H */