blob: e78a271c5090935acbfeb0d684e3afcd34b085d9 [file] [log] [blame]
Bin Meng81da5a82015-02-02 22:35:27 +08001/*
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 Mengd79593b2015-02-04 16:26:13 +08008#include <mmc.h>
Bin Meng7e96d312015-03-11 11:25:56 +08009#include <netdev.h>
10#include <phy.h>
Bin Meng81da5a82015-02-02 22:35:27 +080011#include <asm/io.h>
12#include <asm/pci.h>
13#include <asm/post.h>
14#include <asm/processor.h>
Bin Meng34469862015-02-04 16:26:09 +080015#include <asm/arch/device.h>
16#include <asm/arch/msg_port.h>
17#include <asm/arch/quark.h>
18
Bin Mengd79593b2015-02-04 16:26:13 +080019static struct pci_device_id mmc_supported[] = {
20 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_SDIO },
21};
22
Bin Mengba6faff2015-02-04 16:26:12 +080023/*
24 * TODO:
25 *
26 * This whole routine should be removed until we fully convert the ICH SPI
27 * driver to DM and make use of DT to pass the bios control register offset
28 */
29static void unprotect_spi_flash(void)
30{
31 u32 bc;
32
Simon Glass240d06d2015-03-05 12:25:15 -070033 bc = x86_pci_read_config32(QUARK_LEGACY_BRIDGE, 0xd8);
Bin Mengba6faff2015-02-04 16:26:12 +080034 bc |= 0x1; /* unprotect the flash */
Simon Glass240d06d2015-03-05 12:25:15 -070035 x86_pci_write_config32(QUARK_LEGACY_BRIDGE, 0xd8, bc);
Bin Mengba6faff2015-02-04 16:26:12 +080036}
37
Bin Meng34469862015-02-04 16:26:09 +080038static void quark_setup_bars(void)
39{
40 /* GPIO - D31:F0:R44h */
41 pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA,
42 CONFIG_GPIO_BASE | IO_BAR_EN);
43
44 /* ACPI PM1 Block - D31:F0:R48h */
45 pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_PM1BLK,
46 CONFIG_ACPI_PM1_BASE | IO_BAR_EN);
47
48 /* GPE0 - D31:F0:R4Ch */
49 pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_GPE0BLK,
50 CONFIG_ACPI_GPE0_BASE | IO_BAR_EN);
51
52 /* WDT - D31:F0:R84h */
53 pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_WDTBA,
54 CONFIG_WDT_BASE | IO_BAR_EN);
55
56 /* RCBA - D31:F0:RF0h */
57 pci_write_config_dword(QUARK_LEGACY_BRIDGE, LB_RCBA,
58 CONFIG_RCBA_BASE | MEM_BAR_EN);
59
60 /* ACPI P Block - Msg Port 04:R70h */
61 msg_port_write(MSG_PORT_RMU, PBLK_BA,
62 CONFIG_ACPI_PBLK_BASE | IO_BAR_EN);
63
64 /* SPI DMA - Msg Port 04:R7Ah */
65 msg_port_write(MSG_PORT_RMU, SPI_DMA_BA,
66 CONFIG_SPI_DMA_BASE | IO_BAR_EN);
67
68 /* PCIe ECAM */
69 msg_port_write(MSG_PORT_MEM_ARBITER, AEC_CTRL,
70 CONFIG_PCIE_ECAM_BASE | MEM_BAR_EN);
71 msg_port_write(MSG_PORT_HOST_BRIDGE, HEC_REG,
72 CONFIG_PCIE_ECAM_BASE | MEM_BAR_EN);
73}
Bin Meng81da5a82015-02-02 22:35:27 +080074
Bin Meng6db14482015-04-27 14:16:02 +080075static void quark_enable_legacy_seg(void)
76{
77 u32 hmisc2;
78
79 hmisc2 = msg_port_read(MSG_PORT_HOST_BRIDGE, HMISC2);
80 hmisc2 |= (HMISC2_SEGE | HMISC2_SEGF | HMISC2_SEGAB);
81 msg_port_write(MSG_PORT_HOST_BRIDGE, HMISC2, hmisc2);
82}
83
Bin Meng81da5a82015-02-02 22:35:27 +080084int arch_cpu_init(void)
85{
86 struct pci_controller *hose;
87 int ret;
88
89 post_code(POST_CPU_INIT);
90#ifdef CONFIG_SYS_X86_TSC_TIMER
91 timer_set_base(rdtsc());
92#endif
93
94 ret = x86_cpu_init_f();
95 if (ret)
96 return ret;
97
98 ret = pci_early_init_hose(&hose);
99 if (ret)
100 return ret;
101
Bin Meng34469862015-02-04 16:26:09 +0800102 /*
103 * Quark SoC has some non-standard BARs (excluding PCI standard BARs)
104 * which need be initialized with suggested values
105 */
106 quark_setup_bars();
107
Bin Meng6db14482015-04-27 14:16:02 +0800108 /* Turn on legacy segments (A/B/E/F) decode to system RAM */
109 quark_enable_legacy_seg();
110
Bin Mengba6faff2015-02-04 16:26:12 +0800111 unprotect_spi_flash();
112
Bin Meng81da5a82015-02-02 22:35:27 +0800113 return 0;
114}
115
116int print_cpuinfo(void)
117{
118 post_code(POST_CPU_INFO);
119 return default_print_cpuinfo();
120}
121
122void reset_cpu(ulong addr)
123{
124 /* cold reset */
Simon Glassd0963d42015-04-28 20:11:31 -0600125 x86_full_reset();
Bin Meng81da5a82015-02-02 22:35:27 +0800126}
Bin Mengd79593b2015-02-04 16:26:13 +0800127
128int cpu_mmc_init(bd_t *bis)
129{
130 return pci_mmc_init("Quark SDHCI", mmc_supported,
131 ARRAY_SIZE(mmc_supported));
132}
Bin Meng7e96d312015-03-11 11:25:56 +0800133
134int cpu_eth_init(bd_t *bis)
135{
136 u32 base;
137 int ret0, ret1;
138
139 pci_read_config_dword(QUARK_EMAC0, PCI_BASE_ADDRESS_0, &base);
140 ret0 = designware_initialize(base, PHY_INTERFACE_MODE_RMII);
141
142 pci_read_config_dword(QUARK_EMAC1, PCI_BASE_ADDRESS_0, &base);
143 ret1 = designware_initialize(base, PHY_INTERFACE_MODE_RMII);
144
145 if (ret0 < 0 && ret1 < 0)
146 return -1;
147 else
148 return 0;
149}