blob: 6b0e9631b3f97659fa1c72820309912d48f5ba60 [file] [log] [blame]
Aleksandar Gerasimovski032bdbc2021-02-22 18:18:11 +00001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2020 Hitachi Power Grids. All rights reserved.
4 */
5
6#include <common.h>
7#include <i2c.h>
8#include <asm/io.h>
9#include <asm/arch/immap_ls102xa.h>
10#include <asm/arch/clock.h>
11#include <asm/arch/fsl_serdes.h>
12#include <asm/arch/ls102xa_devdis.h>
13#include <asm/arch/ls102xa_soc.h>
14#include <hwconfig.h>
15#include <mmc.h>
16#include <fsl_csu.h>
17#include <fsl_esdhc.h>
18#include <fsl_ifc.h>
19#include <fsl_immap.h>
20#include <netdev.h>
21#include <fsl_mdio.h>
22#include <tsec.h>
23#include <fsl_sec.h>
24#include <fsl_devdis.h>
25#include <fsl_ddr.h>
26#include <spl.h>
27#include <fdt_support.h>
28#include <fsl_qe.h>
29#include <fsl_validate.h>
30
31#include "../common/common.h"
32#include "../common/qrio.h"
33
34DECLARE_GLOBAL_DATA_PTR;
35
36static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
37
38int checkboard(void)
39{
40 show_qrio();
41
42 return 0;
43}
44
45int dram_init(void)
46{
47 return fsl_initdram();
48}
49
50int board_early_init_f(void)
51{
52 struct ccsr_scfg *scfg = (struct ccsr_scfg *)CONFIG_SYS_FSL_SCFG_ADDR;
53 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
54 struct fsl_ifc ifc = {(void *)CONFIG_SYS_IFC_ADDR, (void *)NULL};
55
56 /* Disable unused MCK1 */
57 setbits_be32(&gur->ddrclkdr, 2);
58
59 /* IFC Global Configuration */
60 setbits_be32(&ifc.gregs->ifc_gcr, 12 << IFC_GCR_TBCTL_TRN_TIME_SHIFT);
61 setbits_be32(&ifc.gregs->ifc_ccr, IFC_CCR_CLK_DIV(3) |
62 IFC_CCR_INV_CLK_EN);
63
64 /* clear BD & FR bits for BE BD's and frame data */
65 clrbits_be32(&scfg->etsecdmamcr, SCFG_ETSECDMAMCR_LE_BD_FR);
66 out_be32(&scfg->etsecmcr, SCFG_ETSECCMCR_GE2_CLK125);
67
68 init_early_memctl_regs();
69
70 /* QRIO Configuration */
71 qrio_uprstreq(UPREQ_CORE_RST);
72
73 if (IS_ENABLED(CONFIG_TARGET_PG_WCOM_SELI8)) {
74 qrio_prstcfg(KM_LIU_RST, PRSTCFG_POWUP_UNIT_RST);
75 qrio_wdmask(KM_LIU_RST, true);
76
77 qrio_prstcfg(KM_PAXK_RST, PRSTCFG_POWUP_UNIT_RST);
78 qrio_wdmask(KM_PAXK_RST, true);
79
80 qrio_prstcfg(KM_DBG_ETH_RST, PRSTCFG_POWUP_UNIT_CORE_RST);
81 qrio_prst(KM_DBG_ETH_RST, false, false);
82 }
83
84 i2c_deblock_gpio_cfg();
85
86 arch_soc_init();
87
88 return 0;
89}
90
91int board_init(void)
92{
93 if (IS_ENABLED(CONFIG_SYS_FSL_ERRATUM_A010315))
94 erratum_a010315();
95
96 fsl_serdes_init();
97
98 ls102xa_smmu_stream_id_init();
99
100 u_qe_init();
101
102 return 0;
103}
104
105int board_late_init(void)
106{
107 return 0;
108}
109
110int misc_init_r(void)
111{
112 if (IS_ENABLED(CONFIG_FSL_DEVICE_DISABLE))
113 device_disable(devdis_tbl, ARRAY_SIZE(devdis_tbl));
114
115 ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN,
116 CONFIG_PIGGY_MAC_ADDRESS_OFFSET);
117
118 return 0;
119}
120
121int ft_board_setup(void *blob, struct bd_info *bd)
122{
123 ft_cpu_setup(blob, bd);
124
125 if (IS_ENABLED(CONFIG_PCI))
126 ft_pci_setup(blob, bd);
127
128 return 0;
129}
130
131u8 flash_read8(void *addr)
132{
133 return __raw_readb(addr + 1);
134}
135
136void flash_write16(u16 val, void *addr)
137{
138 u16 shftval = (((val >> 8) & 0xff) | ((val << 8) & 0xff00));
139
140 __raw_writew(shftval, addr);
141}
142
143u16 flash_read16(void *addr)
144{
145 u16 val = __raw_readw(addr);
146
147 return (((val) >> 8) & 0x00ff) | (((val) << 8) & 0xff00);
148}
149
150int hush_init_var(void)
151{
152 ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
153 return 0;
154}
155
156int last_stage_init(void)
157{
158 set_km_env();
159 return 0;
160}