1 From 53ffd67d944fa23037e7f97e583fae300d4367f7 Mon Sep 17 00:00:00 2001
2 From: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
3 Date: Sat, 23 Apr 2016 15:23:52 +0530
4 Subject: [PATCH 13/93] armv8: fsl-layerscape: Add support of QorIQ LS1012A
9 The QorIQ LS1012A processor, optimized for battery-backed or
10 USB-powered, integrates a single ARM Cortex-A53 core with a hardware
11 packet forwarding engine and high-speed interfaces to deliver
12 line-rate networking performance.
14 This patch add support of LS1012A SoC along with
15 - Update platform & DDR clock read logic as per SVR
16 - Define MMDC controller register set.
17 - Update LUT base address for PCIe
18 - Avoid L3 platform cache compilation
19 - Update USB address, errata
22 Signed-off-by: Rajat Srivastava <rajat.srivastava@nxp.com>
23 Signed-off-by: Rajesh Bhagat <rajesh.bhagat@nxp.com>
24 Signed-off-by: Calvin Johnson <calvin.johnson@nxp.com>
25 Signed-off-by: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
26 Integrated-by: Jiang Yutang <yutang.jiang@nxp.com>
28 arch/arm/cpu/armv8/fsl-layerscape/Makefile | 4 ++
29 .../arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c | 24 +++++--
30 arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S | 2 +
31 arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c | 74 ++++++++++++++++++++
32 arch/arm/cpu/armv8/fsl-layerscape/soc.c | 6 +-
33 arch/arm/include/asm/arch-fsl-layerscape/config.h | 32 +++++++++
34 arch/arm/include/asm/arch-fsl-layerscape/cpu.h | 1 +
35 .../include/asm/arch-fsl-layerscape/fsl_serdes.h | 1 +
36 .../include/asm/arch-fsl-layerscape/immap_lsch2.h | 4 ++
37 arch/arm/include/asm/arch-fsl-layerscape/soc.h | 1 +
38 include/fsl_mmdc.h | 53 ++++++++++++++
39 include/linux/usb/xhci-fsl.h | 4 ++
40 12 files changed, 199 insertions(+), 7 deletions(-)
41 create mode 100644 arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c
42 create mode 100644 include/fsl_mmdc.h
44 diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Makefile b/arch/arm/cpu/armv8/fsl-layerscape/Makefile
45 index 27bfeb1..03f73d1 100644
46 --- a/arch/arm/cpu/armv8/fsl-layerscape/Makefile
47 +++ b/arch/arm/cpu/armv8/fsl-layerscape/Makefile
48 @@ -33,3 +33,7 @@ endif
49 ifneq ($(CONFIG_LS1043A),)
50 obj-$(CONFIG_SYS_HAS_SERDES) += ls1043a_serdes.o
53 +ifneq ($(CONFIG_LS1012A),)
54 +obj-$(CONFIG_SYS_HAS_SERDES) += ls1012a_serdes.o
56 diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c
57 index 078b087..63e5bed 100644
58 --- a/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c
59 +++ b/arch/arm/cpu/armv8/fsl-layerscape/fsl_lsch2_speed.c
60 @@ -33,6 +33,7 @@ void get_sys_info(struct sys_info *sys_info)
62 struct ccsr_clk *clk = (void *)(CONFIG_SYS_FSL_CLK_ADDR);
64 + unsigned int svr, ver;
65 const u8 core_cplx_pll[8] = {
66 [0] = 0, /* CC1 PPL / 1 */
67 [1] = 0, /* CC1 PPL / 2 */
68 @@ -59,12 +60,20 @@ void get_sys_info(struct sys_info *sys_info)
69 sys_info->freq_ddrbus = sysclk;
72 - sys_info->freq_systembus *= (gur_in32(&gur->rcwsr[0]) >>
73 - FSL_CHASSIS2_RCWSR0_SYS_PLL_RAT_SHIFT) &
74 - FSL_CHASSIS2_RCWSR0_SYS_PLL_RAT_MASK;
75 - sys_info->freq_ddrbus *= (gur_in32(&gur->rcwsr[0]) >>
76 - FSL_CHASSIS2_RCWSR0_MEM_PLL_RAT_SHIFT) &
77 - FSL_CHASSIS2_RCWSR0_MEM_PLL_RAT_MASK;
78 + svr = gur_in32(&gur->svr);
79 + ver = SVR_SOC_VER(svr);
80 + if (ver == SVR_LS1012) {
81 + sys_info->freq_ddrbus *= (gur_in32(&gur->rcwsr[0]) >>
82 + FSL_CHASSIS2_RCWSR0_SYS_PLL_RAT_SHIFT) &
83 + FSL_CHASSIS2_RCWSR0_SYS_PLL_RAT_MASK;
85 + sys_info->freq_systembus *= (gur_in32(&gur->rcwsr[0]) >>
86 + FSL_CHASSIS2_RCWSR0_SYS_PLL_RAT_SHIFT) &
87 + FSL_CHASSIS2_RCWSR0_SYS_PLL_RAT_MASK;
88 + sys_info->freq_ddrbus *= (gur_in32(&gur->rcwsr[0]) >>
89 + FSL_CHASSIS2_RCWSR0_MEM_PLL_RAT_SHIFT) &
90 + FSL_CHASSIS2_RCWSR0_MEM_PLL_RAT_MASK;
93 for (i = 0; i < CONFIG_SYS_FSL_NUM_CC_PLLS; i++) {
94 ratio[i] = (in_be32(&clk->pllcgsr[i].pllcngsr) >> 1) & 0xff;
95 @@ -83,6 +92,9 @@ void get_sys_info(struct sys_info *sys_info)
96 freq_c_pll[cplx_pll] / core_cplx_pll_div[c_pll_sel];
99 + if (ver == SVR_LS1012)
100 + sys_info->freq_systembus = sys_info->freq_ddrbus / 2;
102 #define HWA_CGA_M1_CLK_SEL 0xe0000000
103 #define HWA_CGA_M1_CLK_SHIFT 29
104 #ifdef CONFIG_SYS_DPAA_FMAN
105 diff --git a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
106 index 5f5bfb9..b40834a 100644
107 --- a/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
108 +++ b/arch/arm/cpu/armv8/fsl-layerscape/lowlevel.S
109 @@ -184,6 +184,7 @@ ENTRY(lowlevel_init)
111 ENDPROC(lowlevel_init)
113 +#ifdef CONFIG_FSL_LSCH3
115 /* x0 has the desired status, return 0 for success, 1 for timeout
116 * clobber x1, x2, x3, x4, x6, x7
117 @@ -261,6 +262,7 @@ ENTRY(__asm_flush_l3_cache)
120 ENDPROC(__asm_flush_l3_cache)
124 /* Keep literals not used by the secondary boot code outside it */
125 diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c b/arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c
127 index 0000000..ff0903c
129 +++ b/arch/arm/cpu/armv8/fsl-layerscape/ls1012a_serdes.c
132 + * Copyright 2016 Freescale Semiconductor, Inc.
134 + * SPDX-License-Identifier: GPL-2.0+
138 +#include <asm/arch/fsl_serdes.h>
139 +#include <asm/arch/immap_lsch2.h>
141 +struct serdes_config {
143 + u8 lanes[SRDS_MAX_LANES];
146 +static struct serdes_config serdes1_cfg_tbl[] = {
147 + {0x2208, {SGMII_2500_FM1_DTSEC1, SGMII_2500_FM1_DTSEC2, NONE, SATA1} },
148 + {0x0008, {NONE, NONE, NONE, SATA1} },
149 + {0x3508, {SGMII_FM1_DTSEC1, PCIE1, NONE, SATA1} },
150 + {0x3305, {SGMII_FM1_DTSEC1, SGMII_FM1_DTSEC2, NONE, PCIE1} },
151 + {0x2205, {SGMII_2500_FM1_DTSEC1, SGMII_2500_FM1_DTSEC2, NONE, PCIE1} },
152 + {0x2305, {SGMII_2500_FM1_DTSEC1, SGMII_FM1_DTSEC2, NONE, PCIE1} },
153 + {0x9508, {TX_CLK, PCIE1, NONE, SATA1} },
154 + {0x3905, {SGMII_FM1_DTSEC1, TX_CLK, NONE, PCIE1} },
155 + {0x9305, {TX_CLK, SGMII_FM1_DTSEC2, NONE, PCIE1} },
159 +static struct serdes_config *serdes_cfg_tbl[] = {
163 +enum srds_prtcl serdes_get_prtcl(int serdes, int cfg, int lane)
165 + struct serdes_config *ptr;
167 + if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
170 + ptr = serdes_cfg_tbl[serdes];
171 + while (ptr->protocol) {
172 + if (ptr->protocol == cfg)
173 + return ptr->lanes[lane];
180 +int is_serdes_prtcl_valid(int serdes, u32 prtcl)
183 + struct serdes_config *ptr;
185 + if (serdes >= ARRAY_SIZE(serdes_cfg_tbl))
188 + ptr = serdes_cfg_tbl[serdes];
189 + while (ptr->protocol) {
190 + if (ptr->protocol == prtcl)
195 + if (!ptr->protocol)
198 + for (i = 0; i < SRDS_MAX_LANES; i++) {
199 + if (ptr->lanes[i] != NONE)
205 diff --git a/arch/arm/cpu/armv8/fsl-layerscape/soc.c b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
206 index 23f0c88..ec561a7 100644
207 --- a/arch/arm/cpu/armv8/fsl-layerscape/soc.c
208 +++ b/arch/arm/cpu/armv8/fsl-layerscape/soc.c
211 #include <asm/global_data.h>
212 #include <asm/arch-fsl-layerscape/config.h>
213 +#ifdef CONFIG_SYS_FSL_DDR
214 #include <fsl_ddr_sdram.h>
217 #ifdef CONFIG_CHAIN_OF_TRUST
218 #include <fsl_validate.h>
220 @@ -46,14 +48,16 @@ static void erratum_a009008(void)
221 static void erratum_a009798(void)
223 #ifdef CONFIG_SYS_FSL_ERRATUM_A009798
224 -#if defined(CONFIG_LS1043A)
225 +#if defined(CONFIG_LS1043A) || defined(CONFIG_LS1012A)
226 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
227 u32 val = scfg_in32(scfg + SCFG_USB3PRM1CR_USB1 / 4);
228 scfg_out32(scfg + SCFG_USB3PRM1CR_USB1 / 4 , val & USB_SQRXTUNE);
229 +#if defined(CONFIG_LS1043A)
230 val = gur_in32(scfg + SCFG_USB3PRM1CR_USB2 / 4);
231 scfg_out32(scfg + SCFG_USB3PRM1CR_USB2 / 4 , val & USB_SQRXTUNE);
232 val = scfg_in32(scfg + SCFG_USB3PRM1CR_USB3 / 4);
233 scfg_out32(scfg + SCFG_USB3PRM1CR_USB3 / 4 , val & USB_SQRXTUNE);
235 #elif defined(CONFIG_LS2080A) || defined(CONFIG_LS2085A)
236 u32 __iomem *scfg = (u32 __iomem *)SCFG_BASE;
237 u32 val = scfg_in32(scfg + SCFG_USB3PRM1CR / 4);
238 diff --git a/arch/arm/include/asm/arch-fsl-layerscape/config.h b/arch/arm/include/asm/arch-fsl-layerscape/config.h
239 index f876c56..6ea4e8e 100644
240 --- a/arch/arm/include/asm/arch-fsl-layerscape/config.h
241 +++ b/arch/arm/include/asm/arch-fsl-layerscape/config.h
244 #define CONFIG_SYS_FSL_DDRC_ARM_GEN3 /* Enable Freescale ARM DDR3 driver */
247 +#ifndef CONFIG_LS1012A
248 #define CONFIG_SYS_FSL_DDR /* Freescale DDR driver */
249 #define CONFIG_SYS_FSL_DDR_VER FSL_DDR_VER_5_0
253 * Reserve secure memory
255 #define CONFIG_SYS_FSL_ERRATUM_A008997
256 #define CONFIG_SYS_FSL_ERRATUM_A009007
257 #define CONFIG_SYS_FSL_MAX_NUM_OF_SEC 1
258 +#elif defined(CONFIG_LS1012A)
259 +#define CONFIG_MAX_CPUS 1
260 +#define CONFIG_SYS_CACHELINE_SIZE 64
261 +#define CONFIG_NUM_DDR_CONTROLLERS 1
262 +#define CONFIG_SYS_CCSRBAR_DEFAULT 0x01000000
263 +#define CONFIG_SYS_FSL_SEC_COMPAT 5
264 +#undef CONFIG_SYS_FSL_DDRC_ARM_GEN3
266 +#define CONFIG_SYS_FSL_OCRAM_BASE 0x10000000 /* initial RAM */
267 +#define CONFIG_SYS_FSL_OCRAM_SIZE 0x200000 /* 2 MiB */
269 +#define GICD_BASE 0x01401000
270 +#define GICC_BASE 0x01402000
272 +#define CONFIG_SYS_FSL_CCSR_GUR_BE
273 +#define CONFIG_SYS_FSL_CCSR_SCFG_BE
274 +#define CONFIG_SYS_FSL_ESDHC_BE
275 +#define CONFIG_SYS_FSL_WDOG_BE
276 +#define CONFIG_SYS_FSL_DSPI_BE
277 +#define CONFIG_SYS_FSL_QSPI_BE
278 +#define CONFIG_SYS_FSL_PEX_LUT_BE
280 +#define SRDS_MAX_LANES 4
281 +#define CONFIG_SYS_FSL_SRDS_1
282 +#define CONFIG_SYS_FSL_PCIE_COMPAT "fsl,qoriq-pcie-v2.4"
283 +#define CONFIG_SYS_FSL_SEC_BE
285 +#define CONFIG_SYS_FSL_ERRATUM_A009798
288 #error SoC not defined
290 diff --git a/arch/arm/include/asm/arch-fsl-layerscape/cpu.h b/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
291 index a7522da..e4ff990 100644
292 --- a/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
293 +++ b/arch/arm/include/asm/arch-fsl-layerscape/cpu.h
294 @@ -14,6 +14,7 @@ static struct cpu_type cpu_type_list[] = {
295 CPU_TYPE_ENTRY(LS1043, LS1043, 4),
296 CPU_TYPE_ENTRY(LS1023, LS1023, 2),
297 CPU_TYPE_ENTRY(LS2040, LS2040, 4),
298 + CPU_TYPE_ENTRY(LS1012, LS1012, 1),
301 #ifndef CONFIG_SYS_DCACHE_OFF
302 diff --git a/arch/arm/include/asm/arch-fsl-layerscape/fsl_serdes.h b/arch/arm/include/asm/arch-fsl-layerscape/fsl_serdes.h
303 index 7096dac..4a3f4f3 100644
304 --- a/arch/arm/include/asm/arch-fsl-layerscape/fsl_serdes.h
305 +++ b/arch/arm/include/asm/arch-fsl-layerscape/fsl_serdes.h
306 @@ -134,6 +134,7 @@ enum srds_prtcl {
307 SGMII_2500_FM2_DTSEC6,
308 SGMII_2500_FM2_DTSEC9,
309 SGMII_2500_FM2_DTSEC10,
314 diff --git a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
315 index 2852f9c..5b026f8 100644
316 --- a/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
317 +++ b/arch/arm/include/asm/arch-fsl-layerscape/immap_lsch2.h
319 #define CONFIG_SYS_PCIE2_PHYS_ADDR 0x4800000000ULL
320 #define CONFIG_SYS_PCIE3_PHYS_ADDR 0x5000000000ULL
322 +#ifdef CONFIG_LS1012A
323 +#define PCIE_LUT_BASE 0xC0000
325 #define PCIE_LUT_BASE 0x10000
327 #define PCIE_LUT_LCTRL0 0x7F8
328 #define PCIE_LUT_DBG 0x7FC
330 diff --git a/arch/arm/include/asm/arch-fsl-layerscape/soc.h b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
331 index 56989e1..0822b49 100644
332 --- a/arch/arm/include/asm/arch-fsl-layerscape/soc.h
333 +++ b/arch/arm/include/asm/arch-fsl-layerscape/soc.h
334 @@ -41,6 +41,7 @@ struct cpu_type {
335 { .name = #n, .soc_ver = SVR_##v, .num_cores = (nc)}
337 #define SVR_WO_E 0xFFFFFE
338 +#define SVR_LS1012 0x870400
339 #define SVR_LS1043 0x879200
340 #define SVR_LS1023 0x879208
341 #define SVR_LS2045 0x870120
342 diff --git a/include/fsl_mmdc.h b/include/fsl_mmdc.h
344 index 0000000..3df822e
346 +++ b/include/fsl_mmdc.h
349 + * Copyright 2015 Freescale Semiconductor, Inc.
351 + * SPDX-License-Identifier: GPL-2.0+
357 +/* MMDC Registers */
358 +struct mmdc_p_regs {
400 +#endif /* FSL_MMDC_H */
401 diff --git a/include/linux/usb/xhci-fsl.h b/include/linux/usb/xhci-fsl.h
402 index 4966608..72a5d5b 100644
403 --- a/include/linux/usb/xhci-fsl.h
404 +++ b/include/linux/usb/xhci-fsl.h
405 @@ -66,6 +66,10 @@ struct fsl_xhci {
406 #define CONFIG_SYS_FSL_XHCI_USB1_ADDR CONFIG_SYS_LS1043A_XHCI_USB1_ADDR
407 #define CONFIG_SYS_FSL_XHCI_USB2_ADDR CONFIG_SYS_LS1043A_XHCI_USB2_ADDR
408 #define CONFIG_SYS_FSL_XHCI_USB3_ADDR CONFIG_SYS_LS1043A_XHCI_USB3_ADDR
409 +#elif defined(CONFIG_LS1012A)
410 +#define CONFIG_SYS_FSL_XHCI_USB1_ADDR CONFIG_SYS_LS1043A_XHCI_USB1_ADDR
411 +#define CONFIG_SYS_FSL_XHCI_USB2_ADDR 0
412 +#define CONFIG_SYS_FSL_XHCI_USB3_ADDR 0
415 #define FSL_USB_XHCI_ADDR {CONFIG_SYS_FSL_XHCI_USB1_ADDR, \