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