blob: 2fd5b2350b029720ad0c5fa8b3daba08ad5bb1ca [file] [log] [blame]
Vitaly Andrianov7bcf4d62014-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 Andrianov7bcf4d62014-04-04 13:16:53 -040025#endif
26
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040027#define KS2_DDRPHY_PIR_OFFSET 0x04
28#define KS2_DDRPHY_PGCR0_OFFSET 0x08
29#define KS2_DDRPHY_PGCR1_OFFSET 0x0C
30#define KS2_DDRPHY_PGSR0_OFFSET 0x10
31#define KS2_DDRPHY_PGSR1_OFFSET 0x14
32#define KS2_DDRPHY_PLLCR_OFFSET 0x18
33#define KS2_DDRPHY_PTR0_OFFSET 0x1C
34#define KS2_DDRPHY_PTR1_OFFSET 0x20
35#define KS2_DDRPHY_PTR2_OFFSET 0x24
36#define KS2_DDRPHY_PTR3_OFFSET 0x28
37#define KS2_DDRPHY_PTR4_OFFSET 0x2C
38#define KS2_DDRPHY_DCR_OFFSET 0x44
39
40#define KS2_DDRPHY_DTPR0_OFFSET 0x48
41#define KS2_DDRPHY_DTPR1_OFFSET 0x4C
42#define KS2_DDRPHY_DTPR2_OFFSET 0x50
43
44#define KS2_DDRPHY_MR0_OFFSET 0x54
45#define KS2_DDRPHY_MR1_OFFSET 0x58
46#define KS2_DDRPHY_MR2_OFFSET 0x5C
47#define KS2_DDRPHY_DTCR_OFFSET 0x68
48#define KS2_DDRPHY_PGCR2_OFFSET 0x8C
49
50#define KS2_DDRPHY_ZQ0CR1_OFFSET 0x184
51#define KS2_DDRPHY_ZQ1CR1_OFFSET 0x194
52#define KS2_DDRPHY_ZQ2CR1_OFFSET 0x1A4
53#define KS2_DDRPHY_ZQ3CR1_OFFSET 0x1B4
54
Vitaly Andrianovbbf8ac22015-09-19 16:26:43 +053055#define KS2_DDRPHY_DATX8_4_OFFSET 0x2C0
56#define KS2_DDRPHY_DATX8_5_OFFSET 0x300
57#define KS2_DDRPHY_DATX8_6_OFFSET 0x340
58#define KS2_DDRPHY_DATX8_7_OFFSET 0x380
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040059#define KS2_DDRPHY_DATX8_8_OFFSET 0x3C0
60
61#define IODDRM_MASK 0x00000180
62#define ZCKSEL_MASK 0x01800000
63#define CL_MASK 0x00000072
64#define WR_MASK 0x00000E00
65#define BL_MASK 0x00000003
66#define RRMODE_MASK 0x00040000
67#define UDIMM_MASK 0x20000000
68#define BYTEMASK_MASK 0x0003FC00
69#define MPRDQ_MASK 0x00000080
70#define PDQ_MASK 0x00000070
71#define NOSRA_MASK 0x08000000
72#define ECC_MASK 0x00000001
73
Hao Zhang46267d82014-07-16 00:59:22 +030074/* DDR3 definitions */
75#define KS2_DDR3A_EMIF_CTRL_BASE 0x21010000
76#define KS2_DDR3A_EMIF_DATA_BASE 0x80000000
77#define KS2_DDR3A_DDRPHYC 0x02329000
78
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -040079#define KS2_DDR3_MIDR_OFFSET 0x00
80#define KS2_DDR3_STATUS_OFFSET 0x04
81#define KS2_DDR3_SDCFG_OFFSET 0x08
82#define KS2_DDR3_SDRFC_OFFSET 0x10
83#define KS2_DDR3_SDTIM1_OFFSET 0x18
84#define KS2_DDR3_SDTIM2_OFFSET 0x1C
85#define KS2_DDR3_SDTIM3_OFFSET 0x20
86#define KS2_DDR3_SDTIM4_OFFSET 0x28
87#define KS2_DDR3_PMCTL_OFFSET 0x38
88#define KS2_DDR3_ZQCFG_OFFSET 0xC8
89
Hao Zhangd6c508c2014-07-09 19:48:41 +030090#define KS2_DDR3_PLLCTRL_PHY_RESET 0x80000000
91
Vitaly Andrianov19173012014-10-22 17:47:58 +030092/* DDR3 ECC */
93#define KS2_DDR3_ECC_INT_STATUS_OFFSET 0x0AC
94#define KS2_DDR3_ECC_INT_ENABLE_SET_SYS_OFFSET 0x0B4
95#define KS2_DDR3_ECC_CTRL_OFFSET 0x110
96#define KS2_DDR3_ECC_ADDR_RANGE1_OFFSET 0x114
97#define KS2_DDR3_ONE_BIT_ECC_ERR_CNT_OFFSET 0x130
98#define KS2_DDR3_ONE_BIT_ECC_ERR_ADDR_LOG_OFFSET 0x13C
99
100/* DDR3 ECC Interrupt Status register */
101#define KS2_DDR3_1B_ECC_ERR_SYS BIT(5)
102#define KS2_DDR3_2B_ECC_ERR_SYS BIT(4)
103#define KS2_DDR3_WR_ECC_ERR_SYS BIT(3)
104
105/* DDR3 ECC Control register */
106#define KS2_DDR3_ECC_EN BIT(31)
107#define KS2_DDR3_ECC_ADDR_RNG_PROT BIT(30)
108#define KS2_DDR3_ECC_VERIFY_EN BIT(29)
109#define KS2_DDR3_ECC_RMW_EN BIT(28)
110#define KS2_DDR3_ECC_ADDR_RNG_1_EN BIT(0)
111
112#define KS2_DDR3_ECC_ENABLE (KS2_DDR3_ECC_EN | \
113 KS2_DDR3_ECC_ADDR_RNG_PROT | \
114 KS2_DDR3_ECC_VERIFY_EN)
115
116/* EDMA */
117#define KS2_EDMA0_BASE 0x02700000
118
119/* EDMA3 register offsets */
120#define KS2_EDMA_QCHMAP0 0x0200
121#define KS2_EDMA_IPR 0x1068
122#define KS2_EDMA_ICR 0x1070
123#define KS2_EDMA_QEECR 0x1088
124#define KS2_EDMA_QEESR 0x108c
125#define KS2_EDMA_PARAM_1(x) (0x4020 + (4 * x))
126
Khoronzhuk, Ivan1bc679a2014-10-29 13:09:31 +0200127/* NETCP pktdma */
128#define KS2_NETCP_PDMA_RX_FREE_QUEUE 4001
129#define KS2_NETCP_PDMA_RX_RCV_QUEUE 4002
130
Vitaly Andrianov19173012014-10-22 17:47:58 +0300131/* Chip Interrupt Controller */
132#define KS2_CIC2_BASE 0x02608000
133
134/* Chip Interrupt Controller register offsets */
135#define KS2_CIC_CTRL 0x04
136#define KS2_CIC_HOST_CTRL 0x0C
137#define KS2_CIC_GLOBAL_ENABLE 0x10
138#define KS2_CIC_SYS_ENABLE_IDX_SET 0x28
139#define KS2_CIC_HOST_ENABLE_IDX_SET 0x34
140#define KS2_CIC_CHAN_MAP(n) (0x0400 + (n << 2))
141
Murali Karicherif90901c2014-05-29 18:57:12 +0300142#define KS2_UART0_BASE 0x02530c00
143#define KS2_UART1_BASE 0x02531000
144
Hao Zhang46267d82014-07-16 00:59:22 +0300145/* Boot Config */
146#define KS2_DEVICE_STATE_CTRL_BASE 0x02620000
147#define KS2_JTAG_ID_REG (KS2_DEVICE_STATE_CTRL_BASE + 0x18)
148#define KS2_DEVSTAT (KS2_DEVICE_STATE_CTRL_BASE + 0x20)
Karicheri, Muralidharan54a55122014-12-09 14:32:26 -0500149#define KS2_DEVCFG (KS2_DEVICE_STATE_CTRL_BASE + 0x14c)
Hao Zhang46267d82014-07-16 00:59:22 +0300150
Khoronzhuk, Ivan2df64102014-07-09 19:48:39 +0300151/* PSC */
152#define KS2_PSC_BASE 0x02350000
Hao Zhang58a0d662014-07-09 19:48:44 +0300153#define KS2_LPSC_GEM_0 15
154#define KS2_LPSC_TETRIS 52
155#define KS2_TETRIS_PWR_DOMAIN 31
Khoronzhuk, Ivan2df64102014-07-09 19:48:39 +0300156
Hao Zhang46267d82014-07-16 00:59:22 +0300157/* Chip configuration unlock codes and registers */
158#define KS2_KICK0 (KS2_DEVICE_STATE_CTRL_BASE + 0x38)
159#define KS2_KICK1 (KS2_DEVICE_STATE_CTRL_BASE + 0x3c)
160#define KS2_KICK0_MAGIC 0x83e70b13
161#define KS2_KICK1_MAGIC 0x95a4f1e0
162
163/* PLL control registers */
164#define KS2_MAINPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x350)
165#define KS2_MAINPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x354)
166#define KS2_PASSPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x358)
167#define KS2_PASSPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x35C)
168#define KS2_DDR3APLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x360)
169#define KS2_DDR3APLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x364)
Lokesh Vutla0d73cc22015-07-28 14:16:45 +0530170#define KS2_DDR3BPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x368)
171#define KS2_DDR3BPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x36C)
Hao Zhang46267d82014-07-16 00:59:22 +0300172#define KS2_ARMPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x370)
173#define KS2_ARMPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x374)
Vitaly Andrianov29646842015-09-19 16:26:40 +0530174#define KS2_UARTPLLCTL0 (KS2_DEVICE_STATE_CTRL_BASE + 0x390)
175#define KS2_UARTPLLCTL1 (KS2_DEVICE_STATE_CTRL_BASE + 0x394)
Hao Zhang46267d82014-07-16 00:59:22 +0300176
177#define KS2_PLL_CNTRL_BASE 0x02310000
178#define KS2_CLOCK_BASE KS2_PLL_CNTRL_BASE
Hao Zhang82be0132014-07-16 00:59:27 +0300179#define KS2_RSTCTRL_RSTYPE (KS2_PLL_CNTRL_BASE + 0xe4)
Hao Zhang46267d82014-07-16 00:59:22 +0300180#define KS2_RSTCTRL (KS2_PLL_CNTRL_BASE + 0xe8)
Murali Karicheri39f45202014-09-10 15:54:59 +0300181#define KS2_RSTCTRL_RSCFG (KS2_PLL_CNTRL_BASE + 0xec)
Hao Zhang46267d82014-07-16 00:59:22 +0300182#define KS2_RSTCTRL_KEY 0x5a69
183#define KS2_RSTCTRL_MASK 0xffff0000
184#define KS2_RSTCTRL_SWRST 0xfffe0000
Murali Karicheri39f45202014-09-10 15:54:59 +0300185#define KS2_RSTYPE_PLL_SOFT BIT(13)
Hao Zhang46267d82014-07-16 00:59:22 +0300186
187/* SPI */
188#define KS2_SPI0_BASE 0x21000400
189#define KS2_SPI1_BASE 0x21000600
190#define KS2_SPI2_BASE 0x21000800
191#define KS2_SPI_BASE KS2_SPI0_BASE
192
Khoronzhuk, Ivan8062b052014-06-07 05:10:49 +0300193/* AEMIF */
194#define KS2_AEMIF_CNTRL_BASE 0x21000a00
195#define DAVINCI_ASYNC_EMIF_CNTRL_BASE KS2_AEMIF_CNTRL_BASE
196
Hao Zhang58a0d662014-07-09 19:48:44 +0300197/* Flag from ks2_debug options to check if DSPs need to stay ON */
198#define DBG_LEAVE_DSPS_ON 0x1
199
Hao Zhang9000ea92014-10-22 16:32:30 +0300200/* MSMC control */
201#define KS2_MSMC_CTRL_BASE 0x0bc00000
Hao Zhangd5dff712014-10-22 16:32:32 +0300202#define KS2_MSMC_DATA_BASE 0x0c000000
Hao Zhang9000ea92014-10-22 16:32:30 +0300203#define KS2_MSMC_SEGMENT_TETRIS 8
204#define KS2_MSMC_SEGMENT_NETCP 9
205#define KS2_MSMC_SEGMENT_QM_PDSP 10
206#define KS2_MSMC_SEGMENT_PCIE0 11
207
Vitaly Andrianov5184ff92014-10-22 17:47:57 +0300208/* MSMC segment size shift bits */
209#define KS2_MSMC_SEG_SIZE_SHIFT 12
210#define KS2_MSMC_MAP_SEG_NUM (2 << (30 - KS2_MSMC_SEG_SIZE_SHIFT))
211#define KS2_MSMC_DST_SEG_BASE (CONFIG_SYS_LPAE_SDRAM_BASE >> \
212 KS2_MSMC_SEG_SIZE_SHIFT)
213
Vitaly Andrianov047e7802014-07-25 22:23:19 +0300214/* Device speed */
215#define KS2_REV1_DEVSPEED (KS2_DEVICE_STATE_CTRL_BASE + 0xc98)
216#define KS2_EFUSE_BOOTROM (KS2_DEVICE_STATE_CTRL_BASE + 0xc90)
Hao Zhang1b466652014-10-22 16:32:28 +0300217#define KS2_MISC_CTRL (KS2_DEVICE_STATE_CTRL_BASE + 0xc7c)
Vitaly Andrianov047e7802014-07-25 22:23:19 +0300218
Hao Zhang46267d82014-07-16 00:59:22 +0300219/* Queue manager */
Khoronzhuk, Ivan29310e72014-09-05 19:02:45 +0300220#define KS2_QM_BASE_ADDRESS 0x23a80000
221#define KS2_QM_CONF_BASE 0x02a02000
Hao Zhang46267d82014-07-16 00:59:22 +0300222#define KS2_QM_DESC_SETUP_BASE 0x02a03000
Khoronzhuk, Ivan29310e72014-09-05 19:02:45 +0300223#define KS2_QM_STATUS_RAM_BASE 0x02a06000
224#define KS2_QM_INTD_CONF_BASE 0x02a0c000
225#define KS2_QM_PDSP1_CMD_BASE 0x02a20000
226#define KS2_QM_PDSP1_CTRL_BASE 0x02a0f000
227#define KS2_QM_PDSP1_IRAM_BASE 0x02a10000
228#define KS2_QM_MANAGER_QUEUES_BASE 0x02a80000
Hao Zhang46267d82014-07-16 00:59:22 +0300229#define KS2_QM_MANAGER_Q_PROXY_BASE 0x02ac0000
230#define KS2_QM_QUEUE_STATUS_BASE 0x02a40000
Khoronzhuk, Ivan29310e72014-09-05 19:02:45 +0300231#define KS2_QM_LINK_RAM_BASE 0x00100000
232#define KS2_QM_REGION_NUM 64
233#define KS2_QM_QPOOL_NUM 4000
Hao Zhang46267d82014-07-16 00:59:22 +0300234
WingMan Kwok66c5b9f2014-09-05 22:26:23 +0300235/* USB */
236#define KS2_USB_SS_BASE 0x02680000
237#define KS2_USB_HOST_XHCI_BASE (KS2_USB_SS_BASE + 0x10000)
238#define KS2_DEV_USB_PHY_BASE 0x02620738
239#define KS2_USB_PHY_CFG_BASE 0x02630000
240
Khoronzhuk, Ivanf2c13ba2014-09-29 22:17:22 +0300241#define KS2_MAC_ID_BASE_ADDR (KS2_DEVICE_STATE_CTRL_BASE + 0x110)
242
Hao Zhangae3ed412014-10-22 17:18:22 +0300243/* SGMII SerDes */
244#define KS2_SGMII_SERDES_BASE 0x0232a000
245
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530246/* JTAG ID register */
247#define JTAGID_VARIANT_SHIFT 28
248#define JTAGID_VARIANT_MASK (0xf << 28)
249#define JTAGID_PART_NUM_SHIFT 12
250#define JTAGID_PART_NUM_MASK (0xffff << 12)
251
252/* PART NUMBER definitions */
253#define CPU_66AK2Hx 0xb981
254#define CPU_66AK2Ex 0xb9a6
255#define CPU_66AK2Lx 0xb9a7
Lokesh Vutla05b8e492015-09-19 16:26:38 +0530256#define CPU_66AK2Gx 0xbb06
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530257
Lokesh Vutla9da9afa2015-07-28 14:16:44 +0530258/* DEVSPEED register */
259#define DEVSPEED_DEVSPEED_SHIFT 16
260#define DEVSPEED_DEVSPEED_MASK (0xfff << 16)
261#define DEVSPEED_ARMSPEED_SHIFT 0
262#define DEVSPEED_ARMSPEED_MASK 0xfff
263#define DEVSPEED_NUMSPDS 12
264
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400265#ifdef CONFIG_SOC_K2HK
266#include <asm/arch/hardware-k2hk.h>
267#endif
268
Hao Zhang46267d82014-07-16 00:59:22 +0300269#ifdef CONFIG_SOC_K2E
270#include <asm/arch/hardware-k2e.h>
271#endif
272
Hao Zhang1b466652014-10-22 16:32:28 +0300273#ifdef CONFIG_SOC_K2L
274#include <asm/arch/hardware-k2l.h>
275#endif
276
Vitaly Andrianovb00e9cd2015-09-19 16:26:42 +0530277#ifdef CONFIG_SOC_K2G
278#include <asm/arch/hardware-k2g.h>
279#endif
280
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400281#ifndef __ASSEMBLY__
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530282
283static inline u16 get_part_number(void)
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400284{
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530285 u32 jtag_id = __raw_readl(KS2_JTAG_ID_REG);
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400286
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530287 return (jtag_id & JTAGID_PART_NUM_MASK) >> JTAGID_PART_NUM_SHIFT;
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400288}
289
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530290static inline u8 cpu_is_k2hk(void)
Hao Zhang46267d82014-07-16 00:59:22 +0300291{
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530292 return get_part_number() == CPU_66AK2Hx;
Hao Zhang46267d82014-07-16 00:59:22 +0300293}
294
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530295static inline u8 cpu_is_k2e(void)
Hao Zhang1b466652014-10-22 16:32:28 +0300296{
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530297 return get_part_number() == CPU_66AK2Ex;
298}
Hao Zhang1b466652014-10-22 16:32:28 +0300299
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530300static inline u8 cpu_is_k2l(void)
301{
302 return get_part_number() == CPU_66AK2Lx;
Hao Zhang1b466652014-10-22 16:32:28 +0300303}
304
Lokesh Vutla05b8e492015-09-19 16:26:38 +0530305static inline u8 cpu_is_k2g(void)
306{
307 return get_part_number() == CPU_66AK2Gx;
308}
309
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530310static inline u8 cpu_revision(void)
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400311{
Lokesh Vutla8379f2b2015-07-28 14:16:41 +0530312 u32 jtag_id = __raw_readl(KS2_JTAG_ID_REG);
313 u8 rev = (jtag_id & JTAGID_VARIANT_MASK) >> JTAGID_VARIANT_SHIFT;
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400314
315 return rev;
316}
317
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400318int cpu_to_bus(u32 *ptr, u32 length);
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -0400319void sdelay(unsigned long);
320
321#endif
322
323#endif /* __ASM_ARCH_HARDWARE_H */