2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2013-05-22 03:57:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
|
2013-11-08 11:18:50 +00:00
|
|
|
* Copyright (C) 2013 Imagination Technologies
|
2013-05-22 03:57:37 +00:00
|
|
|
*/
|
|
|
|
|
2021-07-15 18:54:00 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <fdt_support.h>
|
2015-01-29 10:38:20 +00:00
|
|
|
#include <ide.h>
|
2019-11-14 19:57:47 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <net.h>
|
2013-05-22 03:57:44 +00:00
|
|
|
#include <netdev.h>
|
2013-11-08 11:18:57 +00:00
|
|
|
#include <pci.h>
|
2013-11-08 11:18:50 +00:00
|
|
|
#include <pci_gt64120.h>
|
|
|
|
#include <pci_msc01.h>
|
2013-11-08 11:18:55 +00:00
|
|
|
#include <rtc.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2013-05-22 03:57:37 +00:00
|
|
|
|
2013-05-22 03:57:42 +00:00
|
|
|
#include <asm/addrspace.h>
|
2013-05-22 03:57:38 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/malta.h>
|
|
|
|
|
2013-11-08 11:18:49 +00:00
|
|
|
#include "superio.h"
|
|
|
|
|
2017-03-31 14:40:25 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2021-07-15 18:54:00 +00:00
|
|
|
#define MALTA_GT_PATH "/pci0@1be00000"
|
|
|
|
#define MALTA_MSC_PATH "/pci0@1bd00000"
|
|
|
|
|
2013-11-08 11:18:50 +00:00
|
|
|
enum core_card {
|
|
|
|
CORE_UNKNOWN,
|
|
|
|
CORE_LV,
|
|
|
|
CORE_FPGA6,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum sys_con {
|
|
|
|
SYSCON_UNKNOWN,
|
|
|
|
SYSCON_GT64120,
|
|
|
|
SYSCON_MSC01,
|
|
|
|
};
|
|
|
|
|
2013-11-08 11:18:51 +00:00
|
|
|
static void malta_lcd_puts(const char *str)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
void *reg = (void *)CKSEG1ADDR(MALTA_ASCIIPOS0);
|
|
|
|
|
|
|
|
/* print up to 8 characters of the string */
|
linux/kernel.h: sync min, max, min3, max3 macros with Linux
U-Boot has never cared about the type when we get max/min of two
values, but Linux Kernel does. This commit gets min, max, min3, max3
macros synced with the kernel introducing type checks.
Many of references of those macros must be fixed to suppress warnings.
We have two options:
- Use min, max, min3, max3 only when the arguments have the same type
(or add casts to the arguments)
- Use min_t/max_t instead with the appropriate type for the first
argument
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Pavel Machek <pavel@denx.de>
Acked-by: Lukasz Majewski <l.majewski@samsung.com>
Tested-by: Lukasz Majewski <l.majewski@samsung.com>
[trini: Fixup arch/blackfin/lib/string.c]
Signed-off-by: Tom Rini <trini@ti.com>
2014-11-06 18:03:31 +00:00
|
|
|
for (i = 0; i < min((int)strlen(str), 8); i++) {
|
2013-11-08 11:18:51 +00:00
|
|
|
__raw_writel(str[i], reg);
|
|
|
|
reg += MALTA_ASCIIPOS1 - MALTA_ASCIIPOS0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill the rest of the display with spaces */
|
|
|
|
for (; i < 8; i++) {
|
|
|
|
__raw_writel(' ', reg);
|
|
|
|
reg += MALTA_ASCIIPOS1 - MALTA_ASCIIPOS0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-08 11:18:50 +00:00
|
|
|
static enum core_card malta_core_card(void)
|
|
|
|
{
|
|
|
|
u32 corid, rev;
|
2016-01-09 16:32:45 +00:00
|
|
|
const void *reg = (const void *)CKSEG1ADDR(MALTA_REVISION);
|
2013-11-08 11:18:50 +00:00
|
|
|
|
2016-01-09 16:32:45 +00:00
|
|
|
rev = __raw_readl(reg);
|
2013-11-08 11:18:50 +00:00
|
|
|
corid = (rev & MALTA_REVISION_CORID_MSK) >> MALTA_REVISION_CORID_SHF;
|
|
|
|
|
|
|
|
switch (corid) {
|
|
|
|
case MALTA_REVISION_CORID_CORE_LV:
|
|
|
|
return CORE_LV;
|
|
|
|
|
|
|
|
case MALTA_REVISION_CORID_CORE_FPGA6:
|
|
|
|
return CORE_FPGA6;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return CORE_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static enum sys_con malta_sys_con(void)
|
|
|
|
{
|
|
|
|
switch (malta_core_card()) {
|
|
|
|
case CORE_LV:
|
|
|
|
return SYSCON_GT64120;
|
|
|
|
|
|
|
|
case CORE_FPGA6:
|
|
|
|
return SYSCON_MSC01;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return SYSCON_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-06 18:47:05 +00:00
|
|
|
int dram_init(void)
|
2013-05-22 03:57:37 +00:00
|
|
|
{
|
2022-07-23 17:04:57 +00:00
|
|
|
gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
|
2017-03-31 14:40:25 +00:00
|
|
|
|
|
|
|
return 0;
|
2013-05-22 03:57:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int checkboard(void)
|
|
|
|
{
|
2013-11-08 11:18:50 +00:00
|
|
|
enum core_card core;
|
|
|
|
|
2016-02-06 03:30:11 +00:00
|
|
|
malta_lcd_puts("U-Boot");
|
2013-11-08 11:18:50 +00:00
|
|
|
puts("Board: MIPS Malta");
|
|
|
|
|
|
|
|
core = malta_core_card();
|
|
|
|
switch (core) {
|
|
|
|
case CORE_LV:
|
|
|
|
puts(" CoreLV");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CORE_FPGA6:
|
|
|
|
puts(" CoreFPGA6");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
puts(" CoreUnknown");
|
|
|
|
}
|
|
|
|
|
|
|
|
putc('\n');
|
2013-05-22 03:57:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2013-05-22 03:57:38 +00:00
|
|
|
|
2021-07-15 18:54:00 +00:00
|
|
|
#if !IS_ENABLED(CONFIG_DM_ETH)
|
2020-06-26 06:13:33 +00:00
|
|
|
int board_eth_init(struct bd_info *bis)
|
2013-05-22 03:57:44 +00:00
|
|
|
{
|
|
|
|
return pci_eth_init(bis);
|
|
|
|
}
|
2021-07-15 18:54:00 +00:00
|
|
|
#endif
|
2013-05-22 03:57:44 +00:00
|
|
|
|
2013-05-22 03:57:38 +00:00
|
|
|
void _machine_restart(void)
|
|
|
|
{
|
|
|
|
void __iomem *reset_base;
|
|
|
|
|
|
|
|
reset_base = (void __iomem *)CKSEG1ADDR(MALTA_RESET_BASE);
|
|
|
|
__raw_writel(GORESET, reset_base);
|
2015-01-29 10:38:21 +00:00
|
|
|
mdelay(1000);
|
2013-05-22 03:57:38 +00:00
|
|
|
}
|
2013-05-22 03:57:42 +00:00
|
|
|
|
2013-11-08 11:18:49 +00:00
|
|
|
int board_early_init_f(void)
|
|
|
|
{
|
2016-01-29 13:54:54 +00:00
|
|
|
ulong io_base;
|
2013-11-08 11:18:50 +00:00
|
|
|
|
|
|
|
/* choose correct PCI I/O base */
|
|
|
|
switch (malta_sys_con()) {
|
|
|
|
case SYSCON_GT64120:
|
2016-01-29 13:54:54 +00:00
|
|
|
io_base = CKSEG1ADDR(MALTA_GT_PCIIO_BASE);
|
2013-11-08 11:18:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SYSCON_MSC01:
|
2016-01-29 13:54:54 +00:00
|
|
|
io_base = CKSEG1ADDR(MALTA_MSC01_PCIIO_BASE);
|
2013-11-08 11:18:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-01-29 13:54:54 +00:00
|
|
|
set_io_port_base(io_base);
|
2016-01-29 13:54:53 +00:00
|
|
|
|
2013-11-08 11:18:49 +00:00
|
|
|
/* setup FDC37M817 super I/O controller */
|
2016-01-29 13:54:54 +00:00
|
|
|
malta_superio_init();
|
2013-11-08 11:18:49 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-08 11:18:55 +00:00
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
|
|
|
rtc_reset();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-07-15 18:54:00 +00:00
|
|
|
#if IS_ENABLED(CONFIG_OF_BOARD_FIXUP)
|
|
|
|
/*
|
|
|
|
* TODO: currently doesn't work because rw_fdt_blob points to a
|
|
|
|
* NOR flash address. This needs some changes in board_init_f.
|
|
|
|
*/
|
|
|
|
int board_fix_fdt(void *rw_fdt_blob)
|
|
|
|
{
|
|
|
|
int node = -1;
|
|
|
|
|
|
|
|
switch (malta_sys_con()) {
|
|
|
|
case SYSCON_GT64120:
|
|
|
|
node = fdt_path_offset(rw_fdt_blob, MALTA_GT_PATH);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case SYSCON_MSC01:
|
|
|
|
node = fdt_path_offset(rw_fdt_blob, MALTA_MSC_PATH);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fdt_status_okay(rw_fdt_blob, node);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int board_early_init_r(void)
|
|
|
|
{
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
pci_init();
|
|
|
|
|
|
|
|
ret = dm_pci_find_device(PCI_VENDOR_ID_INTEL,
|
|
|
|
PCI_DEVICE_ID_INTEL_82371AB_0, 0, &dev);
|
|
|
|
if (ret)
|
|
|
|
panic("Failed to find PIIX4 PCI bridge\n");
|
|
|
|
|
|
|
|
/* setup PCI interrupt routing */
|
|
|
|
dm_pci_write_config8(dev, PCI_CFG_PIIX4_PIRQRCA, 10);
|
|
|
|
dm_pci_write_config8(dev, PCI_CFG_PIIX4_PIRQRCB, 10);
|
|
|
|
dm_pci_write_config8(dev, PCI_CFG_PIIX4_PIRQRCC, 11);
|
|
|
|
dm_pci_write_config8(dev, PCI_CFG_PIIX4_PIRQRCD, 11);
|
|
|
|
|
|
|
|
/* mux SERIRQ onto SERIRQ pin */
|
|
|
|
dm_pci_clrset_config32(dev, PCI_CFG_PIIX4_GENCFG, 0,
|
|
|
|
PCI_CFG_PIIX4_GENCFG_SERIRQ);
|
|
|
|
|
|
|
|
/* enable SERIRQ - Linux currently depends upon this */
|
|
|
|
dm_pci_clrset_config8(dev, PCI_CFG_PIIX4_SERIRQC, 0,
|
|
|
|
PCI_CFG_PIIX4_SERIRQC_EN | PCI_CFG_PIIX4_SERIRQC_CONT);
|
|
|
|
|
|
|
|
ret = dm_pci_find_device(PCI_VENDOR_ID_INTEL,
|
|
|
|
PCI_DEVICE_ID_INTEL_82371AB, 0, &dev);
|
|
|
|
if (ret)
|
|
|
|
panic("Failed to find PIIX4 IDE controller\n");
|
|
|
|
|
|
|
|
/* enable bus master & IO access */
|
|
|
|
dm_pci_clrset_config32(dev, PCI_COMMAND, 0,
|
|
|
|
PCI_COMMAND_MASTER | PCI_COMMAND_IO);
|
|
|
|
|
|
|
|
/* set latency */
|
|
|
|
dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x40);
|
|
|
|
|
|
|
|
/* enable IDE/ATA */
|
|
|
|
dm_pci_write_config32(dev, PCI_CFG_PIIX4_IDETIM_PRI,
|
|
|
|
PCI_CFG_PIIX4_IDETIM_IDE);
|
|
|
|
dm_pci_write_config32(dev, PCI_CFG_PIIX4_IDETIM_SEC,
|
|
|
|
PCI_CFG_PIIX4_IDETIM_IDE);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|