2 * Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
3 * Copyright (C) 2013 Imagination Technologies
5 * SPDX-License-Identifier: GPL-2.0
12 #include <pci_gt64120.h>
13 #include <pci_msc01.h>
16 #include <asm/addrspace.h>
18 #include <asm/malta.h>
34 static void malta_lcd_puts(const char *str)
37 void *reg = (void *)CKSEG1ADDR(MALTA_ASCIIPOS0);
39 /* print up to 8 characters of the string */
40 for (i = 0; i < min((int)strlen(str), 8); i++) {
41 __raw_writel(str[i], reg);
42 reg += MALTA_ASCIIPOS1 - MALTA_ASCIIPOS0;
45 /* fill the rest of the display with spaces */
47 __raw_writel(' ', reg);
48 reg += MALTA_ASCIIPOS1 - MALTA_ASCIIPOS0;
52 static enum core_card malta_core_card(void)
55 const void *reg = (const void *)CKSEG1ADDR(MALTA_REVISION);
57 rev = __raw_readl(reg);
58 corid = (rev & MALTA_REVISION_CORID_MSK) >> MALTA_REVISION_CORID_SHF;
61 case MALTA_REVISION_CORID_CORE_LV:
64 case MALTA_REVISION_CORID_CORE_FPGA6:
72 static enum sys_con malta_sys_con(void)
74 switch (malta_core_card()) {
76 return SYSCON_GT64120;
82 return SYSCON_UNKNOWN;
86 phys_size_t initdram(int board_type)
88 return CONFIG_SYS_MEM_SIZE;
95 malta_lcd_puts("U-Boot");
96 puts("Board: MIPS Malta");
98 core = malta_core_card();
109 puts(" CoreUnknown");
116 int board_eth_init(bd_t *bis)
118 return pci_eth_init(bis);
121 void _machine_restart(void)
123 void __iomem *reset_base;
125 reset_base = (void __iomem *)CKSEG1ADDR(MALTA_RESET_BASE);
126 __raw_writel(GORESET, reset_base);
130 int board_early_init_f(void)
134 /* choose correct PCI I/O base */
135 switch (malta_sys_con()) {
137 io_base = CKSEG1ADDR(MALTA_GT_PCIIO_BASE);
141 io_base = CKSEG1ADDR(MALTA_MSC01_PCIIO_BASE);
148 set_io_port_base(io_base);
150 /* setup FDC37M817 super I/O controller */
151 malta_superio_init();
156 int misc_init_r(void)
163 void pci_init_board(void)
169 switch (malta_sys_con()) {
171 gt64120_pci_init((void *)CKSEG1ADDR(MALTA_GT_BASE),
172 0x00000000, 0x00000000, CONFIG_SYS_MEM_SIZE,
173 0x10000000, 0x10000000, 128 * 1024 * 1024,
174 0x00000000, 0x00000000, 0x20000);
179 msc01_pci_init((void *)CKSEG1ADDR(MALTA_MSC01_PCI_BASE),
180 0x00000000, 0x00000000, CONFIG_SYS_MEM_SIZE,
181 MALTA_MSC01_PCIMEM_MAP,
182 CKSEG1ADDR(MALTA_MSC01_PCIMEM_BASE),
183 MALTA_MSC01_PCIMEM_SIZE, MALTA_MSC01_PCIIO_MAP,
184 0x00000000, MALTA_MSC01_PCIIO_SIZE);
188 bdf = pci_find_device(PCI_VENDOR_ID_INTEL,
189 PCI_DEVICE_ID_INTEL_82371AB_0, 0);
191 panic("Failed to find PIIX4 PCI bridge\n");
193 /* setup PCI interrupt routing */
194 pci_write_config_byte(bdf, PCI_CFG_PIIX4_PIRQRCA, 10);
195 pci_write_config_byte(bdf, PCI_CFG_PIIX4_PIRQRCB, 10);
196 pci_write_config_byte(bdf, PCI_CFG_PIIX4_PIRQRCC, 11);
197 pci_write_config_byte(bdf, PCI_CFG_PIIX4_PIRQRCD, 11);
199 /* mux SERIRQ onto SERIRQ pin */
200 pci_read_config_dword(bdf, PCI_CFG_PIIX4_GENCFG, &val32);
201 val32 |= PCI_CFG_PIIX4_GENCFG_SERIRQ;
202 pci_write_config_dword(bdf, PCI_CFG_PIIX4_GENCFG, val32);
204 /* enable SERIRQ - Linux currently depends upon this */
205 pci_read_config_byte(bdf, PCI_CFG_PIIX4_SERIRQC, &val8);
206 val8 |= PCI_CFG_PIIX4_SERIRQC_EN | PCI_CFG_PIIX4_SERIRQC_CONT;
207 pci_write_config_byte(bdf, PCI_CFG_PIIX4_SERIRQC, val8);
209 bdf = pci_find_device(PCI_VENDOR_ID_INTEL,
210 PCI_DEVICE_ID_INTEL_82371AB, 0);
212 panic("Failed to find PIIX4 IDE controller\n");
214 /* enable bus master & IO access */
215 val32 |= PCI_COMMAND_MASTER | PCI_COMMAND_IO;
216 pci_write_config_dword(bdf, PCI_COMMAND, val32);
219 pci_write_config_byte(bdf, PCI_LATENCY_TIMER, 0x40);
222 pci_write_config_dword(bdf, PCI_CFG_PIIX4_IDETIM_PRI,
223 PCI_CFG_PIIX4_IDETIM_IDE);
224 pci_write_config_dword(bdf, PCI_CFG_PIIX4_IDETIM_SEC,
225 PCI_CFG_PIIX4_IDETIM_IDE);