1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * SPDX-License-Identifier: GPL-2.0+
5*4882a593Smuzhiyun */
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun #include <common.h>
8*4882a593Smuzhiyun #include <mmc.h>
9*4882a593Smuzhiyun #include <asm/io.h>
10*4882a593Smuzhiyun #include <asm/ioapic.h>
11*4882a593Smuzhiyun #include <asm/mrccache.h>
12*4882a593Smuzhiyun #include <asm/mtrr.h>
13*4882a593Smuzhiyun #include <asm/pci.h>
14*4882a593Smuzhiyun #include <asm/post.h>
15*4882a593Smuzhiyun #include <asm/arch/device.h>
16*4882a593Smuzhiyun #include <asm/arch/msg_port.h>
17*4882a593Smuzhiyun #include <asm/arch/quark.h>
18*4882a593Smuzhiyun
quark_setup_mtrr(void)19*4882a593Smuzhiyun static void quark_setup_mtrr(void)
20*4882a593Smuzhiyun {
21*4882a593Smuzhiyun u32 base, mask;
22*4882a593Smuzhiyun int i;
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun disable_caches();
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun /* mark the VGA RAM area as uncacheable */
27*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_FIX_16K_A0000,
28*4882a593Smuzhiyun MTRR_FIX_TYPE(MTRR_TYPE_UNCACHEABLE));
29*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_FIX_16K_B0000,
30*4882a593Smuzhiyun MTRR_FIX_TYPE(MTRR_TYPE_UNCACHEABLE));
31*4882a593Smuzhiyun
32*4882a593Smuzhiyun /* mark other fixed range areas as cacheable */
33*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_FIX_64K_00000,
34*4882a593Smuzhiyun MTRR_FIX_TYPE(MTRR_TYPE_WRBACK));
35*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_FIX_64K_40000,
36*4882a593Smuzhiyun MTRR_FIX_TYPE(MTRR_TYPE_WRBACK));
37*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_FIX_16K_80000,
38*4882a593Smuzhiyun MTRR_FIX_TYPE(MTRR_TYPE_WRBACK));
39*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_FIX_16K_90000,
40*4882a593Smuzhiyun MTRR_FIX_TYPE(MTRR_TYPE_WRBACK));
41*4882a593Smuzhiyun for (i = MTRR_FIX_4K_C0000; i <= MTRR_FIX_4K_FC000; i++)
42*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, i,
43*4882a593Smuzhiyun MTRR_FIX_TYPE(MTRR_TYPE_WRBACK));
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun /* variable range MTRR#0: ROM area */
46*4882a593Smuzhiyun mask = ~(CONFIG_SYS_MONITOR_LEN - 1);
47*4882a593Smuzhiyun base = CONFIG_SYS_TEXT_BASE & mask;
48*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_VAR_PHYBASE(MTRR_VAR_ROM),
49*4882a593Smuzhiyun base | MTRR_TYPE_WRBACK);
50*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_VAR_PHYMASK(MTRR_VAR_ROM),
51*4882a593Smuzhiyun mask | MTRR_PHYS_MASK_VALID);
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun /* variable range MTRR#1: eSRAM area */
54*4882a593Smuzhiyun mask = ~(ESRAM_SIZE - 1);
55*4882a593Smuzhiyun base = CONFIG_ESRAM_BASE & mask;
56*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_VAR_PHYBASE(MTRR_VAR_ESRAM),
57*4882a593Smuzhiyun base | MTRR_TYPE_WRBACK);
58*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_VAR_PHYMASK(MTRR_VAR_ESRAM),
59*4882a593Smuzhiyun mask | MTRR_PHYS_MASK_VALID);
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun /* enable both variable and fixed range MTRRs */
62*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, MTRR_DEF_TYPE,
63*4882a593Smuzhiyun MTRR_DEF_TYPE_EN | MTRR_DEF_TYPE_FIX_EN);
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun enable_caches();
66*4882a593Smuzhiyun }
67*4882a593Smuzhiyun
quark_setup_bars(void)68*4882a593Smuzhiyun static void quark_setup_bars(void)
69*4882a593Smuzhiyun {
70*4882a593Smuzhiyun /* GPIO - D31:F0:R44h */
71*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA,
72*4882a593Smuzhiyun CONFIG_GPIO_BASE | IO_BAR_EN);
73*4882a593Smuzhiyun
74*4882a593Smuzhiyun /* ACPI PM1 Block - D31:F0:R48h */
75*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_PM1BLK,
76*4882a593Smuzhiyun CONFIG_ACPI_PM1_BASE | IO_BAR_EN);
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun /* GPE0 - D31:F0:R4Ch */
79*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_GPE0BLK,
80*4882a593Smuzhiyun CONFIG_ACPI_GPE0_BASE | IO_BAR_EN);
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun /* WDT - D31:F0:R84h */
83*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_WDTBA,
84*4882a593Smuzhiyun CONFIG_WDT_BASE | IO_BAR_EN);
85*4882a593Smuzhiyun
86*4882a593Smuzhiyun /* RCBA - D31:F0:RF0h */
87*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_RCBA,
88*4882a593Smuzhiyun CONFIG_RCBA_BASE | MEM_BAR_EN);
89*4882a593Smuzhiyun
90*4882a593Smuzhiyun /* ACPI P Block - Msg Port 04:R70h */
91*4882a593Smuzhiyun msg_port_write(MSG_PORT_RMU, PBLK_BA,
92*4882a593Smuzhiyun CONFIG_ACPI_PBLK_BASE | IO_BAR_EN);
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun /* SPI DMA - Msg Port 04:R7Ah */
95*4882a593Smuzhiyun msg_port_write(MSG_PORT_RMU, SPI_DMA_BA,
96*4882a593Smuzhiyun CONFIG_SPI_DMA_BASE | IO_BAR_EN);
97*4882a593Smuzhiyun
98*4882a593Smuzhiyun /* PCIe ECAM */
99*4882a593Smuzhiyun msg_port_write(MSG_PORT_MEM_ARBITER, AEC_CTRL,
100*4882a593Smuzhiyun CONFIG_PCIE_ECAM_BASE | MEM_BAR_EN);
101*4882a593Smuzhiyun msg_port_write(MSG_PORT_HOST_BRIDGE, HEC_REG,
102*4882a593Smuzhiyun CONFIG_PCIE_ECAM_BASE | MEM_BAR_EN);
103*4882a593Smuzhiyun }
104*4882a593Smuzhiyun
quark_pcie_early_init(void)105*4882a593Smuzhiyun static void quark_pcie_early_init(void)
106*4882a593Smuzhiyun {
107*4882a593Smuzhiyun /*
108*4882a593Smuzhiyun * Step1: Assert PCIe signal PERST#
109*4882a593Smuzhiyun *
110*4882a593Smuzhiyun * The CPU interface to the PERST# signal is platform dependent.
111*4882a593Smuzhiyun * Call the board-specific codes to perform this task.
112*4882a593Smuzhiyun */
113*4882a593Smuzhiyun board_assert_perst();
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun /* Step2: PHY common lane reset */
116*4882a593Smuzhiyun msg_port_alt_setbits(MSG_PORT_SOC_UNIT, PCIE_CFG, PCIE_PHY_LANE_RST);
117*4882a593Smuzhiyun /* wait 1 ms for PHY common lane reset */
118*4882a593Smuzhiyun mdelay(1);
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun /* Step3: PHY sideband interface reset and controller main reset */
121*4882a593Smuzhiyun msg_port_alt_setbits(MSG_PORT_SOC_UNIT, PCIE_CFG,
122*4882a593Smuzhiyun PCIE_PHY_SB_RST | PCIE_CTLR_MAIN_RST);
123*4882a593Smuzhiyun /* wait 80ms for PLL to lock */
124*4882a593Smuzhiyun mdelay(80);
125*4882a593Smuzhiyun
126*4882a593Smuzhiyun /* Step4: Controller sideband interface reset */
127*4882a593Smuzhiyun msg_port_alt_setbits(MSG_PORT_SOC_UNIT, PCIE_CFG, PCIE_CTLR_SB_RST);
128*4882a593Smuzhiyun /* wait 20ms for controller sideband interface reset */
129*4882a593Smuzhiyun mdelay(20);
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun /* Step5: De-assert PERST# */
132*4882a593Smuzhiyun board_deassert_perst();
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun /* Step6: Controller primary interface reset */
135*4882a593Smuzhiyun msg_port_alt_setbits(MSG_PORT_SOC_UNIT, PCIE_CFG, PCIE_CTLR_PRI_RST);
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun /* Mixer Load Lane 0 */
138*4882a593Smuzhiyun msg_port_io_clrbits(MSG_PORT_PCIE_AFE, PCIE_RXPICTRL0_L0,
139*4882a593Smuzhiyun (1 << 6) | (1 << 7));
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun /* Mixer Load Lane 1 */
142*4882a593Smuzhiyun msg_port_io_clrbits(MSG_PORT_PCIE_AFE, PCIE_RXPICTRL0_L1,
143*4882a593Smuzhiyun (1 << 6) | (1 << 7));
144*4882a593Smuzhiyun }
145*4882a593Smuzhiyun
quark_usb_early_init(void)146*4882a593Smuzhiyun static void quark_usb_early_init(void)
147*4882a593Smuzhiyun {
148*4882a593Smuzhiyun /* The sequence below comes from Quark firmware writer guide */
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_USB_AFE, USB2_GLOBAL_PORT,
151*4882a593Smuzhiyun 1 << 1, (1 << 6) | (1 << 7));
152*4882a593Smuzhiyun
153*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_USB_AFE, USB2_COMPBG,
154*4882a593Smuzhiyun (1 << 8) | (1 << 9), (1 << 7) | (1 << 10));
155*4882a593Smuzhiyun
156*4882a593Smuzhiyun msg_port_alt_setbits(MSG_PORT_USB_AFE, USB2_PLL2, 1 << 29);
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun msg_port_alt_setbits(MSG_PORT_USB_AFE, USB2_PLL1, 1 << 1);
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_USB_AFE, USB2_PLL1,
161*4882a593Smuzhiyun (1 << 3) | (1 << 4) | (1 << 5), 1 << 6);
162*4882a593Smuzhiyun
163*4882a593Smuzhiyun msg_port_alt_clrbits(MSG_PORT_USB_AFE, USB2_PLL2, 1 << 29);
164*4882a593Smuzhiyun
165*4882a593Smuzhiyun msg_port_alt_setbits(MSG_PORT_USB_AFE, USB2_PLL2, 1 << 24);
166*4882a593Smuzhiyun }
167*4882a593Smuzhiyun
quark_thermal_early_init(void)168*4882a593Smuzhiyun static void quark_thermal_early_init(void)
169*4882a593Smuzhiyun {
170*4882a593Smuzhiyun /* The sequence below comes from Quark firmware writer guide */
171*4882a593Smuzhiyun
172*4882a593Smuzhiyun /* thermal sensor mode config */
173*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_SOC_UNIT, TS_CFG1,
174*4882a593Smuzhiyun (1 << 3) | (1 << 4) | (1 << 5), 1 << 5);
175*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_SOC_UNIT, TS_CFG1,
176*4882a593Smuzhiyun (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) |
177*4882a593Smuzhiyun (1 << 12), 1 << 9);
178*4882a593Smuzhiyun msg_port_alt_setbits(MSG_PORT_SOC_UNIT, TS_CFG1, 1 << 14);
179*4882a593Smuzhiyun msg_port_alt_clrbits(MSG_PORT_SOC_UNIT, TS_CFG1, 1 << 17);
180*4882a593Smuzhiyun msg_port_alt_clrbits(MSG_PORT_SOC_UNIT, TS_CFG1, 1 << 18);
181*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_SOC_UNIT, TS_CFG2, 0xffff, 0x011f);
182*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_SOC_UNIT, TS_CFG3, 0xff, 0x17);
183*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_SOC_UNIT, TS_CFG3,
184*4882a593Smuzhiyun (1 << 8) | (1 << 9), 1 << 8);
185*4882a593Smuzhiyun msg_port_alt_clrbits(MSG_PORT_SOC_UNIT, TS_CFG3, 0xff000000);
186*4882a593Smuzhiyun msg_port_alt_clrsetbits(MSG_PORT_SOC_UNIT, TS_CFG4,
187*4882a593Smuzhiyun 0x7ff800, 0xc8 << 11);
188*4882a593Smuzhiyun
189*4882a593Smuzhiyun /* thermal monitor catastrophic trip set point (105 celsius) */
190*4882a593Smuzhiyun msg_port_clrsetbits(MSG_PORT_RMU, TS_TRIP, 0xff, 155);
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun /* thermal monitor catastrophic trip clear point (0 celsius) */
193*4882a593Smuzhiyun msg_port_clrsetbits(MSG_PORT_RMU, TS_TRIP, 0xff0000, 50 << 16);
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun /* take thermal sensor out of reset */
196*4882a593Smuzhiyun msg_port_alt_clrbits(MSG_PORT_SOC_UNIT, TS_CFG4, 1 << 0);
197*4882a593Smuzhiyun
198*4882a593Smuzhiyun /* enable thermal monitor */
199*4882a593Smuzhiyun msg_port_setbits(MSG_PORT_RMU, TS_MODE, 1 << 15);
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun /* lock all thermal configuration */
202*4882a593Smuzhiyun msg_port_setbits(MSG_PORT_RMU, RMU_CTRL, (1 << 5) | (1 << 6));
203*4882a593Smuzhiyun }
204*4882a593Smuzhiyun
quark_enable_legacy_seg(void)205*4882a593Smuzhiyun static void quark_enable_legacy_seg(void)
206*4882a593Smuzhiyun {
207*4882a593Smuzhiyun msg_port_setbits(MSG_PORT_HOST_BRIDGE, HMISC2,
208*4882a593Smuzhiyun HMISC2_SEGE | HMISC2_SEGF | HMISC2_SEGAB);
209*4882a593Smuzhiyun }
210*4882a593Smuzhiyun
arch_cpu_init(void)211*4882a593Smuzhiyun int arch_cpu_init(void)
212*4882a593Smuzhiyun {
213*4882a593Smuzhiyun int ret;
214*4882a593Smuzhiyun
215*4882a593Smuzhiyun post_code(POST_CPU_INIT);
216*4882a593Smuzhiyun
217*4882a593Smuzhiyun ret = x86_cpu_init_f();
218*4882a593Smuzhiyun if (ret)
219*4882a593Smuzhiyun return ret;
220*4882a593Smuzhiyun
221*4882a593Smuzhiyun /*
222*4882a593Smuzhiyun * Quark SoC does not support MSR MTRRs. Fixed and variable range MTRRs
223*4882a593Smuzhiyun * are accessed indirectly via the message port and not the traditional
224*4882a593Smuzhiyun * MSR mechanism. Only UC, WT and WB cache types are supported.
225*4882a593Smuzhiyun */
226*4882a593Smuzhiyun quark_setup_mtrr();
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun /*
229*4882a593Smuzhiyun * Quark SoC has some non-standard BARs (excluding PCI standard BARs)
230*4882a593Smuzhiyun * which need be initialized with suggested values
231*4882a593Smuzhiyun */
232*4882a593Smuzhiyun quark_setup_bars();
233*4882a593Smuzhiyun
234*4882a593Smuzhiyun /* Initialize USB2 PHY */
235*4882a593Smuzhiyun quark_usb_early_init();
236*4882a593Smuzhiyun
237*4882a593Smuzhiyun /* Initialize thermal sensor */
238*4882a593Smuzhiyun quark_thermal_early_init();
239*4882a593Smuzhiyun
240*4882a593Smuzhiyun /* Turn on legacy segments (A/B/E/F) decode to system RAM */
241*4882a593Smuzhiyun quark_enable_legacy_seg();
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun return 0;
244*4882a593Smuzhiyun }
245*4882a593Smuzhiyun
arch_cpu_init_dm(void)246*4882a593Smuzhiyun int arch_cpu_init_dm(void)
247*4882a593Smuzhiyun {
248*4882a593Smuzhiyun /*
249*4882a593Smuzhiyun * Initialize PCIe controller
250*4882a593Smuzhiyun *
251*4882a593Smuzhiyun * Quark SoC holds the PCIe controller in reset following a power on.
252*4882a593Smuzhiyun * U-Boot needs to release the PCIe controller from reset. The PCIe
253*4882a593Smuzhiyun * controller (D23:F0/F1) will not be visible in PCI configuration
254*4882a593Smuzhiyun * space and any access to its PCI configuration registers will cause
255*4882a593Smuzhiyun * system hang while it is held in reset.
256*4882a593Smuzhiyun */
257*4882a593Smuzhiyun quark_pcie_early_init();
258*4882a593Smuzhiyun
259*4882a593Smuzhiyun return 0;
260*4882a593Smuzhiyun }
261*4882a593Smuzhiyun
checkcpu(void)262*4882a593Smuzhiyun int checkcpu(void)
263*4882a593Smuzhiyun {
264*4882a593Smuzhiyun return 0;
265*4882a593Smuzhiyun }
266*4882a593Smuzhiyun
print_cpuinfo(void)267*4882a593Smuzhiyun int print_cpuinfo(void)
268*4882a593Smuzhiyun {
269*4882a593Smuzhiyun post_code(POST_CPU_INFO);
270*4882a593Smuzhiyun return default_print_cpuinfo();
271*4882a593Smuzhiyun }
272*4882a593Smuzhiyun
reset_cpu(ulong addr)273*4882a593Smuzhiyun void reset_cpu(ulong addr)
274*4882a593Smuzhiyun {
275*4882a593Smuzhiyun /* cold reset */
276*4882a593Smuzhiyun x86_full_reset();
277*4882a593Smuzhiyun }
278*4882a593Smuzhiyun
quark_pcie_init(void)279*4882a593Smuzhiyun static void quark_pcie_init(void)
280*4882a593Smuzhiyun {
281*4882a593Smuzhiyun u32 val;
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun /* PCIe upstream non-posted & posted request size */
284*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_PCIE0, PCIE_RP_CCFG,
285*4882a593Smuzhiyun CCFG_UPRS | CCFG_UNRS);
286*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_PCIE1, PCIE_RP_CCFG,
287*4882a593Smuzhiyun CCFG_UPRS | CCFG_UNRS);
288*4882a593Smuzhiyun
289*4882a593Smuzhiyun /* PCIe packet fast transmit mode (IPF) */
290*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_PCIE0, PCIE_RP_MPC2, MPC2_IPF);
291*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_PCIE1, PCIE_RP_MPC2, MPC2_IPF);
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun /* PCIe message bus idle counter (SBIC) */
294*4882a593Smuzhiyun qrk_pci_read_config_dword(QUARK_PCIE0, PCIE_RP_MBC, &val);
295*4882a593Smuzhiyun val |= MBC_SBIC;
296*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_PCIE0, PCIE_RP_MBC, val);
297*4882a593Smuzhiyun qrk_pci_read_config_dword(QUARK_PCIE1, PCIE_RP_MBC, &val);
298*4882a593Smuzhiyun val |= MBC_SBIC;
299*4882a593Smuzhiyun qrk_pci_write_config_dword(QUARK_PCIE1, PCIE_RP_MBC, val);
300*4882a593Smuzhiyun }
301*4882a593Smuzhiyun
quark_usb_init(void)302*4882a593Smuzhiyun static void quark_usb_init(void)
303*4882a593Smuzhiyun {
304*4882a593Smuzhiyun u32 bar;
305*4882a593Smuzhiyun
306*4882a593Smuzhiyun /* Change USB EHCI packet buffer OUT/IN threshold */
307*4882a593Smuzhiyun qrk_pci_read_config_dword(QUARK_USB_EHCI, PCI_BASE_ADDRESS_0, &bar);
308*4882a593Smuzhiyun writel((0x7f << 16) | 0x7f, bar + EHCI_INSNREG01);
309*4882a593Smuzhiyun
310*4882a593Smuzhiyun /* Disable USB device interrupts */
311*4882a593Smuzhiyun qrk_pci_read_config_dword(QUARK_USB_DEVICE, PCI_BASE_ADDRESS_0, &bar);
312*4882a593Smuzhiyun writel(0x7f, bar + USBD_INT_MASK);
313*4882a593Smuzhiyun writel((0xf << 16) | 0xf, bar + USBD_EP_INT_MASK);
314*4882a593Smuzhiyun writel((0xf << 16) | 0xf, bar + USBD_EP_INT_STS);
315*4882a593Smuzhiyun }
316*4882a593Smuzhiyun
arch_early_init_r(void)317*4882a593Smuzhiyun int arch_early_init_r(void)
318*4882a593Smuzhiyun {
319*4882a593Smuzhiyun quark_pcie_init();
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun quark_usb_init();
322*4882a593Smuzhiyun
323*4882a593Smuzhiyun return 0;
324*4882a593Smuzhiyun }
325*4882a593Smuzhiyun
arch_misc_init(void)326*4882a593Smuzhiyun int arch_misc_init(void)
327*4882a593Smuzhiyun {
328*4882a593Smuzhiyun #ifdef CONFIG_ENABLE_MRC_CACHE
329*4882a593Smuzhiyun /*
330*4882a593Smuzhiyun * We intend not to check any return value here, as even MRC cache
331*4882a593Smuzhiyun * is not saved successfully, it is not a severe error that will
332*4882a593Smuzhiyun * prevent system from continuing to boot.
333*4882a593Smuzhiyun */
334*4882a593Smuzhiyun mrccache_save();
335*4882a593Smuzhiyun #endif
336*4882a593Smuzhiyun
337*4882a593Smuzhiyun /* Assign a unique I/O APIC ID */
338*4882a593Smuzhiyun io_apic_set_id(1);
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun return 0;
341*4882a593Smuzhiyun }
342*4882a593Smuzhiyun
board_final_cleanup(void)343*4882a593Smuzhiyun void board_final_cleanup(void)
344*4882a593Smuzhiyun {
345*4882a593Smuzhiyun struct quark_rcba *rcba;
346*4882a593Smuzhiyun u32 base, val;
347*4882a593Smuzhiyun
348*4882a593Smuzhiyun qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_RCBA, &base);
349*4882a593Smuzhiyun base &= ~MEM_BAR_EN;
350*4882a593Smuzhiyun rcba = (struct quark_rcba *)base;
351*4882a593Smuzhiyun
352*4882a593Smuzhiyun /* Initialize 'Component ID' to zero */
353*4882a593Smuzhiyun val = readl(&rcba->esd);
354*4882a593Smuzhiyun val &= ~0xff0000;
355*4882a593Smuzhiyun writel(val, &rcba->esd);
356*4882a593Smuzhiyun
357*4882a593Smuzhiyun /* Lock HMBOUND for security */
358*4882a593Smuzhiyun msg_port_setbits(MSG_PORT_HOST_BRIDGE, HM_BOUND, HM_BOUND_LOCK);
359*4882a593Smuzhiyun
360*4882a593Smuzhiyun return;
361*4882a593Smuzhiyun }
362