GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)

This commit is contained in:
lai
2026-09-06 03:52:57 +08:00
commit b1928b41c0
21813 changed files with 4413081 additions and 0 deletions
@@ -0,0 +1,16 @@
if TARGET_BOSTON
config SYS_BOARD
default "boston"
config SYS_VENDOR
default "imgtec"
config SYS_CONFIG_NAME
default "boston"
config SYS_TEXT_BASE
default 0x9fc00000 if 32BIT
default 0xffffffff9fc00000 if 64BIT
endif
@@ -0,0 +1,13 @@
BOSTON BOARD
M: Paul Burton <paul.burton@mips.com>
S: Maintained
F: board/imgtec/boston/
F: include/configs/boston.h
F: configs/boston32r2_defconfig
F: configs/boston32r2el_defconfig
F: configs/boston32r6_defconfig
F: configs/boston32r6el_defconfig
F: configs/boston64r2_defconfig
F: configs/boston64r2el_defconfig
F: configs/boston64r6_defconfig
F: configs/boston64r6el_defconfig
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2016 Imagination Technologies
obj-y += checkboard.o
obj-y += ddr.o
obj-y += dt.o
obj-y += lowlevel_init.o
@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2016 Imagination Technologies
*/
#ifndef __BOARD_BOSTON_LCD_H__
#define __BOARD_BOSTON_LCD_H__
/**
* lowlevel_display() - Display a message on Boston's LCD
* @msg: The string to display
*
* Display the string @msg on the 7 character LCD display of the Boston board.
* This is typically used for debug or to present some form of status
* indication to the user, allowing faults to be identified when things go
* wrong early enough that the UART isn't up.
*/
void lowlevel_display(const char msg[static 8]);
#endif /* __BOARD_BOSTON_LCD_H__ */
@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2016 Imagination Technologies
*/
#ifndef __BOARD_BOSTON_REGS_H__
#define __BOARD_BOSTON_REGS_H__
#include <asm/addrspace.h>
#define BOSTON_PLAT_BASE CKSEG1ADDR(0x17ffd000)
#define BOSTON_LCD_BASE CKSEG1ADDR(0x17fff000)
/*
* Platform Register Definitions
*/
#define BOSTON_PLAT_CORE_CL (BOSTON_PLAT_BASE + 0x04)
#define BOSTON_PLAT_DDR3STAT (BOSTON_PLAT_BASE + 0x14)
# define BOSTON_PLAT_DDR3STAT_CALIB (1 << 2)
#define BOSTON_PLAT_DDRCONF0 (BOSTON_PLAT_BASE + 0x38)
# define BOSTON_PLAT_DDRCONF0_SIZE (0xf << 0)
#endif /* __BOARD_BOSTON_REGS_H__ */
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2016 Imagination Technologies
*/
#include <common.h>
#include <asm/io.h>
#include <asm/mipsregs.h>
#include "boston-lcd.h"
#include "boston-regs.h"
int checkboard(void)
{
u32 changelist;
lowlevel_display("U-boot ");
printf("Board: MIPS Boston\n");
printf("CPU: 0x%08x", read_c0_prid());
changelist = __raw_readl((uint32_t *)BOSTON_PLAT_CORE_CL);
if (changelist > 1)
printf(" cl%x", changelist);
putc('\n');
return 0;
}
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: GPL-2.0+
quiet_cmd_srec_cat = SRECCAT $@
cmd_srec_cat = srec_cat -output $@ -$2 \
$< -binary \
-fill 0x00 -within $< -binary -range-pad 16 \
-offset $3
u-boot.mcs: u-boot.bin
$(call cmd,srec_cat,intel,0x7c00000)
# if srec_cat is present build u-boot.mcs by default
has_srec_cat = $(call try-run,srec_cat -VERSion,y,n)
ALL-$(has_srec_cat) += u-boot.mcs
CLEAN_FILES += u-boot.mcs
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2016 Imagination Technologies
*/
#include <common.h>
#include <init.h>
#include <asm/io.h>
#include "boston-regs.h"
DECLARE_GLOBAL_DATA_PTR;
int dram_init(void)
{
u32 ddrconf0 = __raw_readl((uint32_t *)BOSTON_PLAT_DDRCONF0);
gd->ram_size = (phys_size_t)(ddrconf0 & BOSTON_PLAT_DDRCONF0_SIZE) <<
30;
return 0;
}
ulong board_get_usable_ram_top(ulong total_size)
{
DECLARE_GLOBAL_DATA_PTR;
if (gd->ram_top < CONFIG_SYS_SDRAM_BASE) {
/* 2GB wrapped around to 0 */
return CKSEG0ADDR(256 << 20);
}
return min_t(unsigned long, gd->ram_top, CKSEG0ADDR(256 << 20));
}
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2016 Imagination Technologies
*/
#include <common.h>
#include <fdt_support.h>
int ft_board_setup(void *blob, bd_t *bd)
{
DECLARE_GLOBAL_DATA_PTR;
u64 mem_start[2], mem_size[2];
int mem_regions;
mem_start[0] = 0;
mem_size[0] = min_t(u64, 256llu << 20, gd->ram_size);
mem_regions = 1;
if (gd->ram_size > mem_size[0]) {
mem_start[1] = 0x80000000 + mem_size[0];
mem_size[1] = gd->ram_size - mem_size[0];
mem_regions++;
}
return fdt_fixup_memory_banks(blob, mem_start, mem_size, mem_regions);
}
@@ -0,0 +1,54 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2016 Imagination Technologies
*/
#include <config.h>
#include <asm/addrspace.h>
#include <asm/asm.h>
#include <asm/mipsregs.h>
#include <asm/regdef.h>
#include "boston-regs.h"
.data
msg_ddr_cal: .ascii "DDR Cal "
msg_ddr_ok: .ascii "DDR OK "
.text
LEAF(lowlevel_init)
move s0, ra
PTR_LA a0, msg_ddr_cal
bal lowlevel_display
PTR_LI t0, BOSTON_PLAT_DDR3STAT
1: lw t1, 0(t0)
andi t1, t1, BOSTON_PLAT_DDR3STAT_CALIB
beqz t1, 1b
PTR_LA a0, msg_ddr_ok
bal lowlevel_display
jr s0
END(lowlevel_init)
LEAF(lowlevel_display)
.set push
.set noat
PTR_LI AT, BOSTON_LCD_BASE
#ifdef CONFIG_64BIT
ld k1, 0(a0)
sd k1, 0(AT)
#else
lw k1, 0(a0)
sw k1, 0(AT)
lw k1, 4(a0)
sw k1, 4(AT)
#endif
.set pop
jr ra
END(lowlevel_display)
@@ -0,0 +1,15 @@
if TARGET_JZ4780_CI20
config SYS_BOARD
default "ci20"
config SYS_VENDOR
default "imgtec"
config SYS_CONFIG_NAME
default "ci20"
config SYS_TEXT_BASE
default 0x80000000
endif
@@ -0,0 +1,6 @@
Creator CI20 BOARD
M: Ezequiel Garcia <ezequiel@collabora.com>
S: Maintained
F: board/imgtec/ci20/
F: include/configs/ci20.h
F: configs/ci20_mmc_defconfig
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: GPL-2.0+
obj-y := ci20.o
@@ -0,0 +1,10 @@
CI20 U-Boot
Installation to an SD card:
Repartition your card with an MBR such that the first partition starts at an
offset of no less than 270KB. Then install U-Boot SPL & the full U-Boot image
to the card like so:
dd if=spl/u-boot-spl.bin of=/dev/sdX obs=512 seek=1
dd if=u-boot-dtb.img of=/dev/sdX obs=1K seek=14
sync
@@ -0,0 +1,362 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* CI20 setup code
*
* Copyright (c) 2013 Imagination Technologies
* Author: Paul Burton <paul.burton@imgtec.com>
*/
#include <common.h>
#include <env.h>
#include <net.h>
#include <netdev.h>
#include <asm/io.h>
#include <asm/gpio.h>
#include <mach/jz4780.h>
#include <mach/jz4780_dram.h>
#include <mach/jz4780_gpio.h>
struct ci20_otp {
u32 serial_number;
u32 date;
u8 manufacturer[2];
u8 mac[6];
} __packed;
static void ci20_mux_mmc(void)
{
void __iomem *gpio_regs = (void __iomem *)GPIO_BASE;
/* setup MSC1 pins */
writel(0x30f00000, gpio_regs + GPIO_PXINTC(4));
writel(0x30f00000, gpio_regs + GPIO_PXMASKC(4));
writel(0x30f00000, gpio_regs + GPIO_PXPAT1C(4));
writel(0x30f00000, gpio_regs + GPIO_PXPAT0C(4));
writel(0x30f00000, gpio_regs + GPIO_PXPENC(4));
jz4780_clk_ungate_mmc();
}
#ifndef CONFIG_SPL_BUILD
static void ci20_mux_eth(void)
{
void __iomem *gpio_regs = (void __iomem *)GPIO_BASE;
#ifdef CONFIG_MTD_RAW_NAND
/* setup pins (some already setup for NAND) */
writel(0x04030000, gpio_regs + GPIO_PXINTC(0));
writel(0x04030000, gpio_regs + GPIO_PXMASKC(0));
writel(0x04030000, gpio_regs + GPIO_PXPAT1C(0));
writel(0x04030000, gpio_regs + GPIO_PXPAT0C(0));
writel(0x04030000, gpio_regs + GPIO_PXPENS(0));
#else
/* setup pins (as above +NAND CS +RD/WE +SDx +SAx) */
writel(0x0dff00ff, gpio_regs + GPIO_PXINTC(0));
writel(0x0dff00ff, gpio_regs + GPIO_PXMASKC(0));
writel(0x0dff00ff, gpio_regs + GPIO_PXPAT1C(0));
writel(0x0dff00ff, gpio_regs + GPIO_PXPAT0C(0));
writel(0x0dff00ff, gpio_regs + GPIO_PXPENS(0));
writel(0x00000003, gpio_regs + GPIO_PXINTC(1));
writel(0x00000003, gpio_regs + GPIO_PXMASKC(1));
writel(0x00000003, gpio_regs + GPIO_PXPAT1C(1));
writel(0x00000003, gpio_regs + GPIO_PXPAT0C(1));
writel(0x00000003, gpio_regs + GPIO_PXPENS(1));
#endif
}
static void ci20_mux_jtag(void)
{
#ifdef CONFIG_JTAG
void __iomem *gpio_regs = (void __iomem *)GPIO_BASE;
/* enable JTAG */
writel(3 << 30, gpio_regs + GPIO_PXINTC(0));
writel(3 << 30, gpio_regs + GPIO_PXMASKC(0));
writel(3 << 30, gpio_regs + GPIO_PXPAT1C(0));
writel(3 << 30, gpio_regs + GPIO_PXPAT0C(0));
#endif
}
static void ci20_mux_nand(void)
{
void __iomem *gpio_regs = (void __iomem *)GPIO_BASE;
/* setup pins */
writel(0x002c00ff, gpio_regs + GPIO_PXINTC(0));
writel(0x002c00ff, gpio_regs + GPIO_PXMASKC(0));
writel(0x002c00ff, gpio_regs + GPIO_PXPAT1C(0));
writel(0x002c00ff, gpio_regs + GPIO_PXPAT0C(0));
writel(0x002c00ff, gpio_regs + GPIO_PXPENS(0));
writel(0x00000003, gpio_regs + GPIO_PXINTC(1));
writel(0x00000003, gpio_regs + GPIO_PXMASKC(1));
writel(0x00000003, gpio_regs + GPIO_PXPAT1C(1));
writel(0x00000003, gpio_regs + GPIO_PXPAT0C(1));
writel(0x00000003, gpio_regs + GPIO_PXPENS(1));
/* FRB0_N */
jz47xx_gpio_direction_input(JZ_GPIO(0, 20));
writel(20, gpio_regs + GPIO_PXPENS(0));
/* disable write protect */
jz47xx_gpio_direction_output(JZ_GPIO(5, 22), 1);
}
static void ci20_mux_uart(void)
{
void __iomem *gpio_regs = (void __iomem *)GPIO_BASE;
/* UART0 */
writel(0x9, gpio_regs + GPIO_PXINTC(5));
writel(0x9, gpio_regs + GPIO_PXMASKC(5));
writel(0x9, gpio_regs + GPIO_PXPAT1C(5));
writel(0x9, gpio_regs + GPIO_PXPAT0C(5));
writel(0x9, gpio_regs + GPIO_PXPENC(5));
jz4780_clk_ungate_uart(0);
/* UART 1 and 2 */
jz4780_clk_ungate_uart(1);
jz4780_clk_ungate_uart(2);
#ifndef CONFIG_JTAG
/* UART3 */
writel(1 << 12, gpio_regs + GPIO_PXINTC(3));
writel(1 << 12, gpio_regs + GPIO_PXMASKS(3));
writel(1 << 12, gpio_regs + GPIO_PXPAT1S(3));
writel(1 << 12, gpio_regs + GPIO_PXPAT0C(3));
writel(3 << 30, gpio_regs + GPIO_PXINTC(0));
writel(3 << 30, gpio_regs + GPIO_PXMASKC(0));
writel(3 << 30, gpio_regs + GPIO_PXPAT1C(0));
writel(1 << 30, gpio_regs + GPIO_PXPAT0C(0));
writel(1 << 31, gpio_regs + GPIO_PXPAT0S(0));
jz4780_clk_ungate_uart(3);
#endif
/* UART4 */
writel(0x100400, gpio_regs + GPIO_PXINTC(2));
writel(0x100400, gpio_regs + GPIO_PXMASKC(2));
writel(0x100400, gpio_regs + GPIO_PXPAT1S(2));
writel(0x100400, gpio_regs + GPIO_PXPAT0C(2));
writel(0x100400, gpio_regs + GPIO_PXPENC(2));
jz4780_clk_ungate_uart(4);
}
int board_early_init_f(void)
{
ci20_mux_jtag();
ci20_mux_uart();
ci20_mux_eth();
ci20_mux_mmc();
ci20_mux_nand();
/* SYS_POWER_IND high (LED blue, VBUS off) */
jz47xx_gpio_direction_output(JZ_GPIO(5, 15), 0);
/* LEDs off */
jz47xx_gpio_direction_output(JZ_GPIO(2, 0), 0);
jz47xx_gpio_direction_output(JZ_GPIO(2, 1), 0);
jz47xx_gpio_direction_output(JZ_GPIO(2, 2), 0);
jz47xx_gpio_direction_output(JZ_GPIO(2, 3), 0);
return 0;
}
int misc_init_r(void)
{
const u32 efuse_clk = jz4780_clk_get_efuse_clk();
struct ci20_otp otp;
char manufacturer[3];
/* Read the board OTP data */
jz4780_efuse_init(efuse_clk);
jz4780_efuse_read(0x18, 16, (u8 *)&otp);
/* Set MAC address */
if (!is_valid_ethaddr(otp.mac)) {
/* no MAC assigned, generate one from the unique chip ID */
jz4780_efuse_read(0x8, 4, &otp.mac[0]);
jz4780_efuse_read(0x12, 2, &otp.mac[4]);
otp.mac[0] = (otp.mac[0] | 0x02) & ~0x01;
}
eth_env_set_enetaddr("ethaddr", otp.mac);
/* Put other board information into the environment */
env_set_ulong("serial#", otp.serial_number);
env_set_ulong("board_date", otp.date);
manufacturer[0] = otp.manufacturer[0];
manufacturer[1] = otp.manufacturer[1];
manufacturer[2] = 0;
env_set("board_mfr", manufacturer);
return 0;
}
#ifdef CONFIG_DRIVER_DM9000
int board_eth_init(bd_t *bis)
{
/* Enable clock */
jz4780_clk_ungate_ethernet();
/* Enable power (PB25) */
jz47xx_gpio_direction_output(JZ_GPIO(1, 25), 1);
/* Reset (PF12) */
mdelay(10);
jz47xx_gpio_direction_output(JZ_GPIO(5, 12), 0);
mdelay(10);
jz47xx_gpio_direction_output(JZ_GPIO(5, 12), 1);
mdelay(10);
return dm9000_initialize(bis);
}
#endif /* CONFIG_DRIVER_DM9000 */
#endif
static u8 ci20_revision(void)
{
void __iomem *gpio_regs = (void __iomem *)GPIO_BASE;
int val;
jz47xx_gpio_direction_input(JZ_GPIO(2, 18));
jz47xx_gpio_direction_input(JZ_GPIO(2, 19));
/* Enable pullups */
writel(BIT(18) | BIT(19), gpio_regs + GPIO_PXPENC(2));
/* Read PC18/19 for version */
val = (!!jz47xx_gpio_get_value(JZ_GPIO(2, 18))) |
((!!jz47xx_gpio_get_value(JZ_GPIO(2, 19))) << 1);
if (val == 3) /* Rev 1 boards had no pulldowns - giving 3 */
return 1;
if (val == 1) /* Rev 2 boards pulldown port C bit 18 giving 1 */
return 2;
return 0;
}
int dram_init(void)
{
gd->ram_size = sdram_size(0) + sdram_size(1);
return 0;
}
/* U-Boot common routines */
int checkboard(void)
{
printf("Board: Creator CI20 (rev.%d)\n", ci20_revision());
return 0;
}
#ifdef CONFIG_SPL_BUILD
#if defined(CONFIG_SPL_MMC_SUPPORT)
int board_mmc_init(bd_t *bd)
{
ci20_mux_mmc();
return jz_mmc_init((void __iomem *)MSC0_BASE);
}
#endif
static const struct jz4780_ddr_config K4B2G0846Q_48_config = {
.timing = {
(4 << DDRC_TIMING1_TRTP_BIT) | (13 << DDRC_TIMING1_TWTR_BIT) |
(6 << DDRC_TIMING1_TWR_BIT) | (5 << DDRC_TIMING1_TWL_BIT),
(4 << DDRC_TIMING2_TCCD_BIT) | (15 << DDRC_TIMING2_TRAS_BIT) |
(6 << DDRC_TIMING2_TRCD_BIT) | (6 << DDRC_TIMING2_TRL_BIT),
(4 << DDRC_TIMING3_ONUM) | (7 << DDRC_TIMING3_TCKSRE_BIT) |
(6 << DDRC_TIMING3_TRP_BIT) | (4 << DDRC_TIMING3_TRRD_BIT) |
(21 << DDRC_TIMING3_TRC_BIT),
(31 << DDRC_TIMING4_TRFC_BIT) | (1 << DDRC_TIMING4_TRWCOV_BIT) |
(4 << DDRC_TIMING4_TCKE_BIT) | (9 << DDRC_TIMING4_TMINSR_BIT) |
(8 << DDRC_TIMING4_TXP_BIT) | (3 << DDRC_TIMING4_TMRD_BIT),
(8 << DDRC_TIMING5_TRTW_BIT) | (4 << DDRC_TIMING5_TRDLAT_BIT) |
(4 << DDRC_TIMING5_TWDLAT_BIT),
(25 << DDRC_TIMING6_TXSRD_BIT) | (12 << DDRC_TIMING6_TFAW_BIT) |
(2 << DDRC_TIMING6_TCFGW_BIT) | (2 << DDRC_TIMING6_TCFGR_BIT),
},
/* PHY */
/* Mode Register 0 */
.mr0 = 0x420,
#ifdef SDRAM_DISABLE_DLL
.mr1 = (DDR3_MR1_DIC_7 | DDR3_MR1_RTT_DIS | DDR3_MR1_DLL_DISABLE),
#else
.mr1 = (DDR3_MR1_DIC_7 | DDR3_MR1_RTT_DIS),
#endif
.ptr0 = 0x002000d4,
.ptr1 = 0x02230d40,
.ptr2 = 0x04013880,
.dtpr0 = 0x2a8f6690,
.dtpr1 = 0x00400860,
.dtpr2 = 0x10042a00,
.pullup = 0x0b,
.pulldn = 0x0b,
};
static const struct jz4780_ddr_config H5TQ2G83CFR_48_config = {
.timing = {
(4 << DDRC_TIMING1_TRTP_BIT) | (13 << DDRC_TIMING1_TWTR_BIT) |
(6 << DDRC_TIMING1_TWR_BIT) | (5 << DDRC_TIMING1_TWL_BIT),
(4 << DDRC_TIMING2_TCCD_BIT) | (16 << DDRC_TIMING2_TRAS_BIT) |
(6 << DDRC_TIMING2_TRCD_BIT) | (6 << DDRC_TIMING2_TRL_BIT),
(4 << DDRC_TIMING3_ONUM) | (7 << DDRC_TIMING3_TCKSRE_BIT) |
(6 << DDRC_TIMING3_TRP_BIT) | (4 << DDRC_TIMING3_TRRD_BIT) |
(22 << DDRC_TIMING3_TRC_BIT),
(42 << DDRC_TIMING4_TRFC_BIT) | (1 << DDRC_TIMING4_TRWCOV_BIT) |
(4 << DDRC_TIMING4_TCKE_BIT) | (7 << DDRC_TIMING4_TMINSR_BIT) |
(3 << DDRC_TIMING4_TXP_BIT) | (3 << DDRC_TIMING4_TMRD_BIT),
(8 << DDRC_TIMING5_TRTW_BIT) | (4 << DDRC_TIMING5_TRDLAT_BIT) |
(4 << DDRC_TIMING5_TWDLAT_BIT),
(25 << DDRC_TIMING6_TXSRD_BIT) | (20 << DDRC_TIMING6_TFAW_BIT) |
(2 << DDRC_TIMING6_TCFGW_BIT) | (2 << DDRC_TIMING6_TCFGR_BIT),
},
/* PHY */
/* Mode Register 0 */
.mr0 = 0x420,
#ifdef SDRAM_DISABLE_DLL
.mr1 = (DDR3_MR1_DIC_7 | DDR3_MR1_RTT_DIS | DDR3_MR1_DLL_DISABLE),
#else
.mr1 = (DDR3_MR1_DIC_7 | DDR3_MR1_RTT_DIS),
#endif
.ptr0 = 0x002000d4,
.ptr1 = 0x02d30d40,
.ptr2 = 0x04013880,
.dtpr0 = 0x2c906690,
.dtpr1 = 0x005608a0,
.dtpr2 = 0x10042a00,
.pullup = 0x0e,
.pulldn = 0x0e,
};
#if (CONFIG_SYS_MHZ != 1200)
#error No DDR configuration for CPU speed
#endif
const struct jz4780_ddr_config *jz4780_get_ddr_config(void)
{
const int board_revision = ci20_revision();
if (board_revision == 2)
return &K4B2G0846Q_48_config;
else /* Fall back to H5TQ2G83CFR RAM */
return &H5TQ2G83CFR_48_config;
}
#endif
@@ -0,0 +1,16 @@
if TARGET_MALTA
config SYS_BOARD
default "malta"
config SYS_VENDOR
default "imgtec"
config SYS_CONFIG_NAME
default "malta"
config SYS_TEXT_BASE
default 0xbe000000 if 32BIT
default 0xffffffffbe000000 if 64BIT
endif
@@ -0,0 +1,9 @@
MALTA BOARD
M: Paul Burton <paul.burton@mips.com>
S: Maintained
F: board/imgtec/malta/
F: include/configs/malta.h
F: configs/malta64_defconfig
F: configs/malta64el_defconfig
F: configs/malta_defconfig
F: configs/maltael_defconfig
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: GPL-2.0+
#
# (C) Copyright 2003-2006
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
obj-y = malta.o
obj-y += lowlevel_init.o
obj-y += superio.o
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: GPL-2.0+
#
# Copyright (C) 2013 Imagination Technologies
#
# Programs a MIPS Malta boot flash with a flat binary image.
proc flash-boot { binfile } {
puts "flash monitor binary $binfile"
config Coherent on
config CoherencyDuringLoad on
if {[endian]=="big"} {
puts "CPU in BE mode"
flash device sharp_16x32_be;
} else {
puts "CPU in LE mode"
flash device sharp_16x32;
}
flash clear all;
flash set 0xBE000000..0xBE0FFFFF
flash erase sector 0xbe000000;
flash erase sector 0xbe020000;
flash erase sector 0xbe040000;
flash erase sector 0xbe060000;
flash erase sector 0xbe080000;
flash erase sector 0xbe0a0000;
flash erase sector 0xbe0c0000;
flash erase sector 0xbe0e0000;
puts "finished erasing boot flash";
puts "programming flash, please be patient"
load bin 0xbe000000 $binfile size4
flash clear all
config CoherencyDuringLoad off
puts "finished programming boot flash";
}
@@ -0,0 +1,231 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
*/
#include <config.h>
#include <gt64120.h>
#include <msc01.h>
#include <pci.h>
#include <asm/addrspace.h>
#include <asm/asm.h>
#include <asm/regdef.h>
#include <asm/malta.h>
#include <asm/mipsregs.h>
#ifdef CONFIG_SYS_BIG_ENDIAN
#define CPU_TO_GT32(_x) ((_x))
#else
#define CPU_TO_GT32(_x) ( \
(((_x) & 0xff) << 24) | (((_x) & 0xff00) << 8) | \
(((_x) & 0xff0000) >> 8) | (((_x) & 0xff000000) >> 24))
#endif
.text
.set noreorder
.globl lowlevel_init
lowlevel_init:
/* detect the core card */
PTR_LI t0, CKSEG1ADDR(MALTA_REVISION)
lw t0, 0(t0)
srl t0, t0, MALTA_REVISION_CORID_SHF
andi t0, t0, (MALTA_REVISION_CORID_MSK >> \
MALTA_REVISION_CORID_SHF)
/* core cards using the gt64120 system controller */
li t1, MALTA_REVISION_CORID_CORE_LV
beq t0, t1, _gt64120
/* core cards using the MSC01 system controller */
li t1, MALTA_REVISION_CORID_CORE_FPGA6
beq t0, t1, _msc01
nop
/* unknown system controller */
b .
nop
/*
* Load BAR registers of GT64120 as done by YAMON
*
* based on a patch sent by Antony Pavlov <antonynpavlov@gmail.com>
* to the barebox mailing list.
* The subject of the original patch:
* 'MIPS: qemu-malta: add YAMON-style GT64120 memory map'
* URL:
* http://www.mail-archive.com/barebox@lists.infradead.org/msg06128.html
*
* based on write_bootloader() in qemu.git/hw/mips_malta.c
* see GT64120 manual and qemu.git/hw/gt64xxx.c for details
*/
_gt64120:
/* move GT64120 registers from 0x14000000 to 0x1be00000 */
PTR_LI t1, CKSEG1ADDR(GT_DEF_BASE)
li t0, CPU_TO_GT32(0xdf000000)
sw t0, GT_ISD_OFS(t1)
/* setup MEM-to-PCI0 mapping */
PTR_LI t1, CKSEG1ADDR(MALTA_GT_BASE)
/* setup PCI0 io window to 0x18000000-0x181fffff */
li t0, CPU_TO_GT32(0xc0000000)
sw t0, GT_PCI0IOLD_OFS(t1)
li t0, CPU_TO_GT32(0x40000000)
sw t0, GT_PCI0IOHD_OFS(t1)
/* setup PCI0 mem windows */
li t0, CPU_TO_GT32(0x80000000)
sw t0, GT_PCI0M0LD_OFS(t1)
li t0, CPU_TO_GT32(0x3f000000)
sw t0, GT_PCI0M0HD_OFS(t1)
li t0, CPU_TO_GT32(0xc1000000)
sw t0, GT_PCI0M1LD_OFS(t1)
li t0, CPU_TO_GT32(0x5e000000)
sw t0, GT_PCI0M1HD_OFS(t1)
jr ra
nop
/*
*
*/
_msc01:
/* setup peripheral bus controller clock divide */
PTR_LI t0, CKSEG1ADDR(MALTA_MSC01_PBC_BASE)
li t1, 0x1 << MSC01_PBC_CLKCFG_SHF
sw t1, MSC01_PBC_CLKCFG_OFS(t0)
/* tweak peripheral bus controller timings */
li t1, (0x1 << MSC01_PBC_CS0TIM_CDT_SHF) | \
(0x1 << MSC01_PBC_CS0TIM_CAT_SHF)
sw t1, MSC01_PBC_CS0TIM_OFS(t0)
li t1, (0x0 << MSC01_PBC_CS0RW_RDT_SHF) | \
(0x2 << MSC01_PBC_CS0RW_RAT_SHF) | \
(0x0 << MSC01_PBC_CS0RW_WDT_SHF) | \
(0x2 << MSC01_PBC_CS0RW_WAT_SHF)
sw t1, MSC01_PBC_CS0RW_OFS(t0)
lw t1, MSC01_PBC_CS0CFG_OFS(t0)
li t2, MSC01_PBC_CS0CFG_DTYP_MSK
and t1, t2
ori t1, (0x0 << MSC01_PBC_CS0CFG_ADM_SHF) | \
(0x3 << MSC01_PBC_CS0CFG_WSIDLE_SHF) | \
(0x10 << MSC01_PBC_CS0CFG_WS_SHF)
sw t1, MSC01_PBC_CS0CFG_OFS(t0)
/* setup basic address decode */
PTR_LI t0, CKSEG1ADDR(MALTA_MSC01_BIU_BASE)
li t1, 0x0
li t2, -CONFIG_SYS_MEM_SIZE
sw t1, MSC01_BIU_MCBAS1L_OFS(t0)
sw t2, MSC01_BIU_MCMSK1L_OFS(t0)
sw t1, MSC01_BIU_MCBAS2L_OFS(t0)
sw t2, MSC01_BIU_MCMSK2L_OFS(t0)
/* initialise IP1 - unused */
li t1, MALTA_MSC01_IP1_BASE
li t2, -MALTA_MSC01_IP1_SIZE
sw t1, MSC01_BIU_IP1BAS1L_OFS(t0)
sw t2, MSC01_BIU_IP1MSK1L_OFS(t0)
sw t1, MSC01_BIU_IP1BAS2L_OFS(t0)
sw t2, MSC01_BIU_IP1MSK2L_OFS(t0)
/* initialise IP2 - PCI */
li t1, MALTA_MSC01_IP2_BASE1
li t2, -MALTA_MSC01_IP2_SIZE1
sw t1, MSC01_BIU_IP2BAS1L_OFS(t0)
sw t2, MSC01_BIU_IP2MSK1L_OFS(t0)
li t1, MALTA_MSC01_IP2_BASE2
li t2, -MALTA_MSC01_IP2_SIZE2
sw t1, MSC01_BIU_IP2BAS2L_OFS(t0)
sw t2, MSC01_BIU_IP2MSK2L_OFS(t0)
/* initialise IP3 - peripheral bus controller */
li t1, MALTA_MSC01_IP3_BASE
li t2, -MALTA_MSC01_IP3_SIZE
sw t1, MSC01_BIU_IP3BAS1L_OFS(t0)
sw t2, MSC01_BIU_IP3MSK1L_OFS(t0)
sw t1, MSC01_BIU_IP3BAS2L_OFS(t0)
sw t2, MSC01_BIU_IP3MSK2L_OFS(t0)
/* setup PCI memory */
PTR_LI t0, CKSEG1ADDR(MALTA_MSC01_PCI_BASE)
li t1, MALTA_MSC01_PCIMEM_BASE
li t2, (-MALTA_MSC01_PCIMEM_SIZE) & MSC01_PCI_SC2PMMSKL_MSK_MSK
li t3, MALTA_MSC01_PCIMEM_MAP
sw t1, MSC01_PCI_SC2PMBASL_OFS(t0)
sw t2, MSC01_PCI_SC2PMMSKL_OFS(t0)
sw t3, MSC01_PCI_SC2PMMAPL_OFS(t0)
/* setup PCI I/O */
li t1, MALTA_MSC01_PCIIO_BASE
li t2, (-MALTA_MSC01_PCIIO_SIZE) & MSC01_PCI_SC2PIOMSKL_MSK_MSK
li t3, MALTA_MSC01_PCIIO_MAP
sw t1, MSC01_PCI_SC2PIOBASL_OFS(t0)
sw t2, MSC01_PCI_SC2PIOMSKL_OFS(t0)
sw t3, MSC01_PCI_SC2PIOMAPL_OFS(t0)
/* setup PCI_BAR0 memory window */
li t1, -CONFIG_SYS_MEM_SIZE
sw t1, MSC01_PCI_BAR0_OFS(t0)
/* setup PCI to SysCon/CPU translation */
sw t1, MSC01_PCI_P2SCMSKL_OFS(t0)
sw zero, MSC01_PCI_P2SCMAPL_OFS(t0)
/* setup PCI vendor & device IDs */
li t1, (PCI_VENDOR_ID_MIPS << MSC01_PCI_HEAD0_VENDORID_SHF) | \
(PCI_DEVICE_ID_MIPS_MSC01 << MSC01_PCI_HEAD0_DEVICEID_SHF)
sw t1, MSC01_PCI_HEAD0_OFS(t0)
/* setup PCI subsystem vendor & device IDs */
sw t1, MSC01_PCI_HEAD11_OFS(t0)
/* setup PCI class, revision */
li t1, (PCI_CLASS_BRIDGE_HOST << MSC01_PCI_HEAD2_CLASS_SHF) | \
(0x1 << MSC01_PCI_HEAD2_REV_SHF)
sw t1, MSC01_PCI_HEAD2_OFS(t0)
/* ensure a sane setup */
sw zero, MSC01_PCI_HEAD3_OFS(t0)
sw zero, MSC01_PCI_HEAD4_OFS(t0)
sw zero, MSC01_PCI_HEAD5_OFS(t0)
sw zero, MSC01_PCI_HEAD6_OFS(t0)
sw zero, MSC01_PCI_HEAD7_OFS(t0)
sw zero, MSC01_PCI_HEAD8_OFS(t0)
sw zero, MSC01_PCI_HEAD9_OFS(t0)
sw zero, MSC01_PCI_HEAD10_OFS(t0)
sw zero, MSC01_PCI_HEAD12_OFS(t0)
sw zero, MSC01_PCI_HEAD13_OFS(t0)
sw zero, MSC01_PCI_HEAD14_OFS(t0)
sw zero, MSC01_PCI_HEAD15_OFS(t0)
/* setup PCI command register */
li t1, (PCI_COMMAND_FAST_BACK | \
PCI_COMMAND_SERR | \
PCI_COMMAND_PARITY | \
PCI_COMMAND_MASTER | \
PCI_COMMAND_MEMORY)
sw t1, MSC01_PCI_HEAD1_OFS(t0)
/* setup PCI byte swapping */
#ifdef CONFIG_SYS_BIG_ENDIAN
li t1, (0x1 << MSC01_PCI_SWAP_BAR0_BSWAP_SHF) | \
(0x1 << MSC01_PCI_SWAP_IO_BSWAP_SHF)
sw t1, MSC01_PCI_SWAP_OFS(t0)
#else
sw zero, MSC01_PCI_SWAP_OFS(t0)
#endif
/* enable PCI host configuration cycles */
lw t1, MSC01_PCI_CFG_OFS(t0)
li t2, MSC01_PCI_CFG_RA_MSK | \
MSC01_PCI_CFG_G_MSK | \
MSC01_PCI_CFG_EN_MSK
or t1, t1, t2
sw t1, MSC01_PCI_CFG_OFS(t0)
jr ra
nop
@@ -0,0 +1,230 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2013 Gabor Juhos <juhosg@openwrt.org>
* Copyright (C) 2013 Imagination Technologies
*/
#include <common.h>
#include <ide.h>
#include <init.h>
#include <netdev.h>
#include <pci.h>
#include <pci_gt64120.h>
#include <pci_msc01.h>
#include <rtc.h>
#include <asm/addrspace.h>
#include <asm/io.h>
#include <asm/malta.h>
#include "superio.h"
DECLARE_GLOBAL_DATA_PTR;
enum core_card {
CORE_UNKNOWN,
CORE_LV,
CORE_FPGA6,
};
enum sys_con {
SYSCON_UNKNOWN,
SYSCON_GT64120,
SYSCON_MSC01,
};
static void malta_lcd_puts(const char *str)
{
int i;
void *reg = (void *)CKSEG1ADDR(MALTA_ASCIIPOS0);
/* print up to 8 characters of the string */
for (i = 0; i < min((int)strlen(str), 8); i++) {
__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;
}
}
static enum core_card malta_core_card(void)
{
u32 corid, rev;
const void *reg = (const void *)CKSEG1ADDR(MALTA_REVISION);
rev = __raw_readl(reg);
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;
}
}
int dram_init(void)
{
gd->ram_size = CONFIG_SYS_MEM_SIZE;
return 0;
}
int checkboard(void)
{
enum core_card core;
malta_lcd_puts("U-Boot");
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');
return 0;
}
int board_eth_init(bd_t *bis)
{
return pci_eth_init(bis);
}
void _machine_restart(void)
{
void __iomem *reset_base;
reset_base = (void __iomem *)CKSEG1ADDR(MALTA_RESET_BASE);
__raw_writel(GORESET, reset_base);
mdelay(1000);
}
int board_early_init_f(void)
{
ulong io_base;
/* choose correct PCI I/O base */
switch (malta_sys_con()) {
case SYSCON_GT64120:
io_base = CKSEG1ADDR(MALTA_GT_PCIIO_BASE);
break;
case SYSCON_MSC01:
io_base = CKSEG1ADDR(MALTA_MSC01_PCIIO_BASE);
break;
default:
return -1;
}
set_io_port_base(io_base);
/* setup FDC37M817 super I/O controller */
malta_superio_init();
return 0;
}
int misc_init_r(void)
{
rtc_reset();
return 0;
}
void pci_init_board(void)
{
pci_dev_t bdf;
u32 val32;
u8 val8;
switch (malta_sys_con()) {
case SYSCON_GT64120:
gt64120_pci_init((void *)CKSEG1ADDR(MALTA_GT_BASE),
0x00000000, 0x00000000, CONFIG_SYS_MEM_SIZE,
0x10000000, 0x10000000, 128 * 1024 * 1024,
0x00000000, 0x00000000, 0x20000);
break;
default:
case SYSCON_MSC01:
msc01_pci_init((void *)CKSEG1ADDR(MALTA_MSC01_PCI_BASE),
0x00000000, 0x00000000, CONFIG_SYS_MEM_SIZE,
MALTA_MSC01_PCIMEM_MAP,
CKSEG1ADDR(MALTA_MSC01_PCIMEM_BASE),
MALTA_MSC01_PCIMEM_SIZE, MALTA_MSC01_PCIIO_MAP,
0x00000000, MALTA_MSC01_PCIIO_SIZE);
break;
}
bdf = pci_find_device(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82371AB_0, 0);
if (bdf == -1)
panic("Failed to find PIIX4 PCI bridge\n");
/* setup PCI interrupt routing */
pci_write_config_byte(bdf, PCI_CFG_PIIX4_PIRQRCA, 10);
pci_write_config_byte(bdf, PCI_CFG_PIIX4_PIRQRCB, 10);
pci_write_config_byte(bdf, PCI_CFG_PIIX4_PIRQRCC, 11);
pci_write_config_byte(bdf, PCI_CFG_PIIX4_PIRQRCD, 11);
/* mux SERIRQ onto SERIRQ pin */
pci_read_config_dword(bdf, PCI_CFG_PIIX4_GENCFG, &val32);
val32 |= PCI_CFG_PIIX4_GENCFG_SERIRQ;
pci_write_config_dword(bdf, PCI_CFG_PIIX4_GENCFG, val32);
/* enable SERIRQ - Linux currently depends upon this */
pci_read_config_byte(bdf, PCI_CFG_PIIX4_SERIRQC, &val8);
val8 |= PCI_CFG_PIIX4_SERIRQC_EN | PCI_CFG_PIIX4_SERIRQC_CONT;
pci_write_config_byte(bdf, PCI_CFG_PIIX4_SERIRQC, val8);
bdf = pci_find_device(PCI_VENDOR_ID_INTEL,
PCI_DEVICE_ID_INTEL_82371AB, 0);
if (bdf == -1)
panic("Failed to find PIIX4 IDE controller\n");
/* enable bus master & IO access */
val32 |= PCI_COMMAND_MASTER | PCI_COMMAND_IO;
pci_write_config_dword(bdf, PCI_COMMAND, val32);
/* set latency */
pci_write_config_byte(bdf, PCI_LATENCY_TIMER, 0x40);
/* enable IDE/ATA */
pci_write_config_dword(bdf, PCI_CFG_PIIX4_IDETIM_PRI,
PCI_CFG_PIIX4_IDETIM_IDE);
pci_write_config_dword(bdf, PCI_CFG_PIIX4_IDETIM_SEC,
PCI_CFG_PIIX4_IDETIM_IDE);
}
@@ -0,0 +1,62 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2013 Imagination Technologies
* Author: Paul Burton <paul.burton@mips.com>
*
* Setup code for the FDC37M817 super I/O controller
*/
#include <common.h>
#include <asm/io.h>
#define SIO_CONF_PORT 0x3f0
#define SIO_DATA_PORT 0x3f1
enum sio_conf_key {
SIOCONF_DEVNUM = 0x07,
SIOCONF_ACTIVATE = 0x30,
SIOCONF_ENTER_SETUP = 0x55,
SIOCONF_BASE_HIGH = 0x60,
SIOCONF_BASE_LOW = 0x61,
SIOCONF_PRIMARY_INT = 0x70,
SIOCONF_EXIT_SETUP = 0xaa,
SIOCONF_MODE = 0xf0,
};
static struct {
u8 key;
u8 data;
} sio_config[] = {
/* tty0 */
{ SIOCONF_DEVNUM, 0x04 },
{ SIOCONF_BASE_HIGH, 0x03 },
{ SIOCONF_BASE_LOW, 0xf8 },
{ SIOCONF_MODE, 0x02 },
{ SIOCONF_PRIMARY_INT, 0x04 },
{ SIOCONF_ACTIVATE, 0x01 },
/* tty1 */
{ SIOCONF_DEVNUM, 0x05 },
{ SIOCONF_BASE_HIGH, 0x02 },
{ SIOCONF_BASE_LOW, 0xf8 },
{ SIOCONF_MODE, 0x02 },
{ SIOCONF_PRIMARY_INT, 0x03 },
{ SIOCONF_ACTIVATE, 0x01 },
};
void malta_superio_init(void)
{
unsigned i;
/* enter config state */
outb(SIOCONF_ENTER_SETUP, SIO_CONF_PORT);
/* configure peripherals */
for (i = 0; i < ARRAY_SIZE(sio_config); i++) {
outb(sio_config[i].key, SIO_CONF_PORT);
outb(sio_config[i].data, SIO_DATA_PORT);
}
/* exit config state */
outb(SIOCONF_EXIT_SETUP, SIO_CONF_PORT);
}
@@ -0,0 +1,14 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Copyright (C) 2013 Imagination Technologies
* Author: Paul Burton <paul.burton@mips.com>
*
* Setup code for the FDC37M817 super I/O controller
*/
#ifndef __BOARD_MALTA_SUPERIO_H__
#define __BOARD_MALTA_SUPERIO_H__
void malta_superio_init(void);
#endif /* __BOARD_MALTA_SUPERIO_H__ */
@@ -0,0 +1,15 @@
if TARGET_XILFPGA
config SYS_BOARD
default "xilfpga"
config SYS_VENDOR
default "imgtec"
config SYS_CONFIG_NAME
default "imgtec_xilfpga"
config SYS_TEXT_BASE
default 0x80C00000
endif
@@ -0,0 +1,6 @@
XILFPGA BOARD
M: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
S: Maintained
F: board/imgtec/xilfpga
F: include/configs/xilfpga.h
F: configs/imgtec_xilfpga_defconfig
@@ -0,0 +1,7 @@
#
# Copyright (C) 2016, Imagination Technologies Ltd.
# Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
#
# SPDX-License-Identifier: GPL-2.0+
#
obj-y := xilfpga.o
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2016, Imagination Technologies Ltd.
*
* Zubair Lutfullah Kakakhel, Zubair.Kakakhel@imgtec.com
*/
MIPSfpga
=======================================
MIPSfpga is an FPGA based development platform by Imagination Technologies
As we are dealing with a MIPS core instantiated on an FPGA, specifications
are fluid and can be varied in RTL.
The example project provided by IMGTEC runs on the Nexys4DDR board by
Digilent powered by the ARTIX-7 FPGA by Xilinx. Relevant details about
the example project and the Nexys4DDR board:
- microAptiv UP core m14Kc
- 50MHz clock speed
- 128Mbyte DDR RAM at 0x0000_0000
- 8Kbyte RAM at 0x1000_0000
- axi_intc at 0x1020_0000
- axi_uart16550 at 0x1040_0000
- axi_gpio at 0x1060_0000
- axi_i2c at 0x10A0_0000
- custom_gpio at 0x10C0_0000
- axi_ethernetlite at 0x10E0_0000
- 8Kbyte BootRAM at 0x1FC0_0000
- 16Mbyte QPI at 0x1D00_0000
Boot protocol:
--------------
The BootRAM is a writeable "RAM" in FPGA at 0x1FC0_0000.
This is for easy reprogrammibility via JTAG.
DDR initialization is already handled by a HW IP block.
When the example project bitstream is loaded, the cpu_reset button
needs to be pressed.
The bootram initializes the cache and axi_uart
Then checks if there is anything non 0xffff_ffff at location 0x1D40_0000
If there is, then that is considered as u-boot. u-boot is copied from
0x1D40_0000 to memory and the bootram jumps into u-boot code.
At this point, the board is ready to load the Linux kernel + buildroot initramfs
This can be done in multiple ways:
1- JTAG load the binary and jump into it.
2- Load kernel stored in the QSPI flash at 0x1D80_0000
3- Load uImage via tftp. Ethernet works in u-boot.
e.g. env set server ip 192.168.154.45; dhcp uImage; bootm
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Imagination Technologies MIPSfpga platform code
*
* Copyright (C) 2016, Imagination Technologies Ltd.
*
* Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>
*
*/
#include <common.h>
DECLARE_GLOBAL_DATA_PTR;
/* initialize the DDR Controller and PHY */
int dram_init(void)
{
/* MIG IP block is smart and doesn't need SW
* to do any init */
gd->ram_size = CONFIG_SYS_SDRAM_SIZE; /* in bytes */
return 0;
}