From 5a4dcfac1e05f7c025a465d3372a1c1425004c2b Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Wed, 22 May 2013 03:57:37 +0000 Subject: MIPS: qemu-malta: add support for emulated MIPS Malta board Add minimal support for the MIPS Malta CoreLV board emulated by Qemu. The only supported peripherial is the UART. This is enough to boot U-Boot to the command prompt both in little and big endian mode. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- board/qemu-malta/Makefile | 45 ++++++++++++++++++++++++++++++++++++++++ board/qemu-malta/lowlevel_init.S | 19 +++++++++++++++++ board/qemu-malta/qemu-malta.c | 20 ++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 board/qemu-malta/Makefile create mode 100644 board/qemu-malta/lowlevel_init.S create mode 100644 board/qemu-malta/qemu-malta.c (limited to 'board/qemu-malta') diff --git a/board/qemu-malta/Makefile b/board/qemu-malta/Makefile new file mode 100644 index 0000000000..6251bb84ad --- /dev/null +++ b/board/qemu-malta/Makefile @@ -0,0 +1,45 @@ +# +# (C) Copyright 2003-2006 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. +# +# See file CREDITS for list of people who contributed to this +# project. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + +include $(TOPDIR)/config.mk + +LIB = $(obj)lib$(BOARD).o + +COBJS = $(BOARD).o +SOBJS = lowlevel_init.o + +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS)) +SOBJS := $(addprefix $(obj),$(SOBJS)) + +$(LIB): $(OBJS) $(SOBJS) + $(call cmd_link_o_target, $(OBJS) $(SOBJS)) + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +######################################################################### diff --git a/board/qemu-malta/lowlevel_init.S b/board/qemu-malta/lowlevel_init.S new file mode 100644 index 0000000000..c5c5bd98a9 --- /dev/null +++ b/board/qemu-malta/lowlevel_init.S @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2013 Gabor Juhos + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include + + .text + .set noreorder + .set mips32 + + .globl lowlevel_init +lowlevel_init: + + jr ra + nop diff --git a/board/qemu-malta/qemu-malta.c b/board/qemu-malta/qemu-malta.c new file mode 100644 index 0000000000..9ba711dba3 --- /dev/null +++ b/board/qemu-malta/qemu-malta.c @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2013 Gabor Juhos + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include + +phys_size_t initdram(int board_type) +{ + return CONFIG_SYS_MEM_SIZE; +} + +int checkboard(void) +{ + puts("Board: MIPS Malta CoreLV (Qemu)\n"); + return 0; +} -- cgit From 015643152aee4c333e3f95d153347f50b7e92ea7 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Wed, 22 May 2013 03:57:38 +0000 Subject: MIPS: qemu-malta: add reset support The MIPS Malta board has a SOFTRES register. Writing a magic value into that register initiates a board reset. Use this feature to implement reset support. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- board/qemu-malta/qemu-malta.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'board/qemu-malta') diff --git a/board/qemu-malta/qemu-malta.c b/board/qemu-malta/qemu-malta.c index 9ba711dba3..449da9c859 100644 --- a/board/qemu-malta/qemu-malta.c +++ b/board/qemu-malta/qemu-malta.c @@ -8,6 +8,9 @@ #include +#include +#include + phys_size_t initdram(int board_type) { return CONFIG_SYS_MEM_SIZE; @@ -18,3 +21,11 @@ int checkboard(void) puts("Board: MIPS Malta CoreLV (Qemu)\n"); return 0; } + +void _machine_restart(void) +{ + void __iomem *reset_base; + + reset_base = (void __iomem *)CKSEG1ADDR(MALTA_RESET_BASE); + __raw_writel(GORESET, reset_base); +} -- cgit From ac12984de8e2239a19c054ffcc615ad4a2e57cc4 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Wed, 22 May 2013 03:57:41 +0000 Subject: MIPS: qemu-malta: setup GT64120 registers as done by YAMON Move the GT64120 register base to 0x1be00000 and setup PCI BAR registers as done by the original YAMON bootloader. This is needed for running Linux kernel. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- board/qemu-malta/lowlevel_init.S | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'board/qemu-malta') diff --git a/board/qemu-malta/lowlevel_init.S b/board/qemu-malta/lowlevel_init.S index c5c5bd98a9..ff4a072ff8 100644 --- a/board/qemu-malta/lowlevel_init.S +++ b/board/qemu-malta/lowlevel_init.S @@ -6,7 +6,20 @@ * by the Free Software Foundation. */ +#include +#include + +#include #include +#include + +#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 @@ -15,5 +28,44 @@ .globl lowlevel_init lowlevel_init: + /* + * Load BAR registers of GT64120 as done by YAMON + * + * based on a patch sent by Antony Pavlov + * 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 + */ + + /* move GT64120 registers from 0x14000000 to 0x1be00000 */ + li t1, KSEG1ADDR(GT_DEF_BASE) + li t0, CPU_TO_GT32(0xdf000000) + sw t0, GT_ISD_OFS(t1) + + /* setup MEM-to-PCI0 mapping */ + li t1, KSEG1ADDR(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 -- cgit From feaa60662768dcc97fdf7c593583876ce4e1564c Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Wed, 22 May 2013 03:57:42 +0000 Subject: MIPS: qemu-malta: add PCI support Qemu emulates the Galileo GT64120 System Controller which provides a CPU bus to PCI bus bridge. The patch adds driver for this bridge and enables PCI support for the emulated Malta board. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- board/qemu-malta/qemu-malta.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'board/qemu-malta') diff --git a/board/qemu-malta/qemu-malta.c b/board/qemu-malta/qemu-malta.c index 449da9c859..e3a733f42f 100644 --- a/board/qemu-malta/qemu-malta.c +++ b/board/qemu-malta/qemu-malta.c @@ -8,8 +8,10 @@ #include +#include #include #include +#include phys_size_t initdram(int board_type) { @@ -29,3 +31,13 @@ void _machine_restart(void) reset_base = (void __iomem *)CKSEG1ADDR(MALTA_RESET_BASE); __raw_writel(GORESET, reset_base); } + +void pci_init_board(void) +{ + set_io_port_base(CKSEG1ADDR(MALTA_IO_PORT_BASE)); + + gt64120_pci_init((void *)CKSEG1ADDR(MALTA_GT_BASE), + 0x00000000, 0x00000000, CONFIG_SYS_MEM_SIZE, + 0x10000000, 0x10000000, 128 * 1024 * 1024, + 0x00000000, 0x00000000, 0x20000); +} -- cgit From f1957499ea545c0ee6d2cbedd3dbc36edc26508d Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Wed, 22 May 2013 03:57:44 +0000 Subject: MIPS: qemu-malta: bring up ethernet Qemu emulates a PCNET PCI card for the Malta CoreLV board. Enable the pcnet driver and add board specific ethernet initialization function to bring it up. Also enable the CONFIG_CMD_NET and CONFIG_CMD_PING options. Signed-off-by: Gabor Juhos Cc: Daniel Schwierzeck --- board/qemu-malta/qemu-malta.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'board/qemu-malta') diff --git a/board/qemu-malta/qemu-malta.c b/board/qemu-malta/qemu-malta.c index e3a733f42f..4cbd7368fe 100644 --- a/board/qemu-malta/qemu-malta.c +++ b/board/qemu-malta/qemu-malta.c @@ -7,6 +7,7 @@ */ #include +#include #include #include @@ -24,6 +25,11 @@ int checkboard(void) return 0; } +int board_eth_init(bd_t *bis) +{ + return pci_eth_init(bis); +} + void _machine_restart(void) { void __iomem *reset_base; -- cgit