Skip to content

Commit e4855aa

Browse files
author
Abhijit A. Mahajani
committed
Merge pull request #3 from pratik-prajapati-imgtec/add_build_cmds_in_readme
Add pistachio soc support
2 parents 325849f + 2890efa commit e4855aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+10315
-62
lines changed

Makefile

+31
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ libs-$(CONFIG_CMD_NAND) += drivers/mtd/nand/
638638
libs-y += drivers/mtd/onenand/
639639
libs-$(CONFIG_CMD_UBI) += drivers/mtd/ubi/
640640
libs-y += drivers/mtd/spi/
641+
libs-y += drivers/mtd/spi-nand/
641642
libs-y += drivers/net/
642643
libs-y += drivers/net/phy/
643644
libs-y += drivers/pci/
@@ -767,6 +768,23 @@ endif
767768
endif
768769
endif
769770

771+
ifeq ($(CONFIG_MIPS),y)
772+
ifeq ($(CONFIG_SPL),y)
773+
ifeq ($(CONFIG_TARGET_PISTACHIO_BUB),y)
774+
ALL-y += u-boot-pistachio-nor.img
775+
endif
776+
ifeq ($(CONFIG_TARGET_PISTACHIO_BEETLE),y)
777+
ALL-y += u-boot-pistachio-nor.img
778+
endif
779+
ifeq ($(CONFIG_TARGET_PISTACHIO_MARDUK),y)
780+
ALL-y += u-boot-pistachio-nor.img
781+
endif
782+
ifeq ($(CONFIG_TARGET_PISTACHIO_CONCERTO),y)
783+
ALL-y += u-boot-pistachio-nor.img
784+
endif
785+
endif
786+
endif
787+
770788
# Add optional build target if defined in board/cpu/soc headers
771789
ifneq ($(CONFIG_BUILD_TARGET),)
772790
ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
@@ -897,6 +915,12 @@ u-boot.img u-boot.kwb u-boot.pbl: u-boot.bin FORCE
897915
u-boot-spl.kwb: u-boot.img spl/u-boot-spl.bin FORCE
898916
$(call if_changed,mkimage)
899917

918+
u-boot-spl-dtb.bin: spl/u-boot-spl.bin dts/dt.dtb FORCE
919+
$(call if_changed,cat)
920+
921+
u-boot-spl-pistachio.bimg: u-boot-spl-dtb.bin FORCE
922+
tools/bimgtool $< $@ $(CONFIG_SYS_GRAM_BASE)
923+
900924
MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img)
901925

902926
u-boot-dtb.img: u-boot-dtb.bin FORCE
@@ -1005,6 +1029,13 @@ u-boot-nand.gph: u-boot.bin FORCE
10051029
$(call if_changed,mkimage)
10061030
@dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@
10071031

1032+
DEC_UBOOT_OFF:=$(shell $(PERL) -e 'print hex("$(CONFIG_SYS_SPI_U_BOOT_OFFS)");')
1033+
# 512KB of the flash reserved for SPL and 1MB for u-boot payload
1034+
u-boot-pistachio-nor.img: u-boot-dtb.img u-boot-spl-pistachio.bimg FORCE
1035+
@dd if=/dev/zero of=$@ bs=4K count=384 conv=notrunc
1036+
@dd if=u-boot-spl-pistachio.bimg of=$@ bs=4K count=128 conv=notrunc
1037+
@dd if=u-boot-dtb.img of=$@ bs=4K count=256 seek=128 conv=notrunc
1038+
10081039
# x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including
10091040
# reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in
10101041
# the middle.

README

+9
Original file line numberDiff line numberDiff line change
@@ -3092,6 +3092,15 @@ CBFS (Coreboot Filesystem) support
30923092
memories can be connected with a given cs line.
30933093
Currently Xilinx Zynq qspi supports these type of connections.
30943094

3095+
CONFIG_SPI_FLASH_MTD spi-flash MTD layer
3096+
3097+
Define this option to use mtd support for spi flash layer, this
3098+
adapter is for translating mtd_read/mtd_write commands into
3099+
spi_flash_read/spi_flash_write commands. It is not intended to
3100+
use it within sf_cmd or the SPI flash subsystem. Such an adapter
3101+
is needed for subsystems like UBI which can only operate on top
3102+
of the MTD layer.
3103+
30953104
- SystemACE Support:
30963105
CONFIG_SYSTEMACE
30973106

README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Using u-boot on Creator (Ci40) Marduk platform
2+
3+
### How to build/cross-compile for Ci40:
4+
5+
$ export CROSS_COMPILE=/path/to/mips-toolchain/mips-toolchain-prefix
6+
$ make pistachio_marduk_defconfig
7+
$ make
8+
9+
This will generate u-boot-pistachio-nor.img
10+
11+
Note: Using OpenWrt's toolchain toolchain-mipsel_mips32_gcc-5.2.0_musl-1.1.11 will require [this patch](http://lists.denx.de/pipermail/u-boot/2015-July/217911.html) to be applied.
12+
13+
### How to flash on Ci40:
14+
15+
1. [Load OpenWrt](https://github.com/IMGCreator/openwrt/blob/master-pistachio/README.md)
16+
17+
2. Erase and write u-boot image on bootloader partition of Ci40
18+
19+
$ flashcp -v u-boot-pistachio-nor.img /dev/mtd0
20+
21+
Note: flashcp needs to be manually selected in OpneWrt menuconfig
22+
23+
Base system -> busybox -> Cutomize busybox options -> Miscellaneous Utilities -> flashcp
24+
25+
3. Reboot
26+
27+
$ reboot
28+
29+
_Please be aware that you may brick the board if you flashed a wrong bootloader. Only way to re-cover back the board is to use Dedi-prog SF100 programmer to flash the pre-built bootloader again._

arch/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ config MIPS
4848
select HAVE_PRIVATE_LIBGCC
4949
select HAVE_GENERIC_BOARD
5050
select SYS_GENERIC_BOARD
51+
select SUPPORT_OF_CONTROL
5152

5253
config NDS32
5354
bool "NDS32 architecture"

arch/mips/Kconfig

+26
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ config SYS_CPU
1111
config USE_PRIVATE_LIBGCC
1212
default y
1313

14+
config MACH_PISTACHIO
15+
bool
16+
select SUPPORTS_LITTLE_ENDIAN
17+
select SUPPORTS_CPU_MIPS32_R1
18+
select SUPPORTS_CPU_MIPS32_R2
19+
select DM
20+
select DM_SERIAL
21+
select SUPPORT_SPL
22+
select SPL_DM
23+
1424
choice
1525
prompt "Target select"
1626
optional
@@ -54,11 +64,27 @@ config TARGET_PB1X00
5464
select SUPPORTS_CPU_MIPS32_R2
5565
select SYS_MIPS_CACHE_INIT_RAM_LOAD
5666

67+
config TARGET_PISTACHIO_BUB
68+
bool "Support Pistachio bring up board"
69+
select MACH_PISTACHIO
70+
71+
config TARGET_PISTACHIO_MARDUK
72+
bool "Support Pistachio Marduk"
73+
select MACH_PISTACHIO
74+
75+
config TARGET_PISTACHIO_BEETLE
76+
bool "Support Pistachio Beetle"
77+
select MACH_PISTACHIO
78+
79+
config TARGET_PISTACHIO_CONCERTO
80+
bool "Support Pistachio Concerto"
81+
select MACH_PISTACHIO
5782

5883
endchoice
5984

6085
source "board/dbau1x00/Kconfig"
6186
source "board/imgtec/malta/Kconfig"
87+
source "board/imgtec/pistachio_bub/Kconfig"
6288
source "board/micronas/vct/Kconfig"
6389
source "board/pb1x00/Kconfig"
6490
source "board/qemu-mips/Kconfig"

arch/mips/Makefile

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
# SPDX-License-Identifier: GPL-2.0+
33
#
44

5-
head-y := arch/mips/cpu/start.o
5+
ifneq ($(CONFIG_SPL_START_S_PATH),)
6+
head-y := $(CONFIG_SPL_START_S_PATH:"%"=%)/start.o
7+
else
8+
head-y := arch/mips/cpu/start.o
9+
endif
610

7-
libs-y += arch/mips/cpu/
8-
libs-y += arch/mips/lib/
11+
libs-y += arch/mips/cpu/
12+
libs-y += arch/mips/lib/
913

10-
libs-$(CONFIG_SOC_AU1X00) += arch/mips/mach-au1x00/
14+
libs-$(CONFIG_SOC_AU1X00) += arch/mips/mach-au1x00/

arch/mips/cpu/Makefile

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
# SPDX-License-Identifier: GPL-2.0+
33
#
44

5-
extra-y = start.o
5+
extra-y := start.o
66

7-
obj-y += time.o
8-
obj-y += interrupts.o
9-
obj-y += cpu.o
7+
obj-y += cpu.o
8+
obj-y += interrupts.o
9+
obj-y += mmu.o
10+
obj-y += time.o

arch/mips/cpu/mmu.c

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright (C) 2015 Imagination Technologies
3+
*
4+
* SPDX-License-Identifier: GPL-2.0+
5+
*/
6+
7+
#include <asm/mipsregs.h>
8+
#include <asm/mmu.h>
9+
10+
#include <linux/kernel.h>
11+
#include <linux/sizes.h>
12+
13+
#include <common.h>
14+
15+
#define MIN_PAGE_SIZE SZ_4K
16+
17+
static int add_wired_tlb_entry(u32 entrylo0, u32 entrylo1,
18+
u32 entryhi, u32 pgsize)
19+
{
20+
u32 tlbindex;
21+
22+
tlbindex = read_c0_wired();
23+
if (tlbindex >= get_tlb_size() || tlbindex >= C0_WIRED_MASK) {
24+
return -1;
25+
}
26+
write_c0_wired(tlbindex + 1);
27+
write_c0_index(tlbindex);
28+
write_c0_pagemask(((pgsize / MIN_PAGE_SIZE) - 1) << C0_PAGEMASK_SHIFT);
29+
write_c0_entryhi(entryhi);
30+
write_c0_entrylo0(entrylo0);
31+
write_c0_entrylo1(entrylo1);
32+
mtc0_tlbw_hazard();
33+
tlb_write_indexed();
34+
tlbw_use_hazard();
35+
36+
return 0;
37+
}
38+
39+
static u32 pick_pagesize(u32 start, u32 len)
40+
{
41+
u32 pgsize, max_pgsize;
42+
43+
max_pgsize = get_max_pagesize();
44+
for (pgsize = max_pgsize;
45+
pgsize >= MIN_PAGE_SIZE;
46+
pgsize = pgsize / 4) {
47+
/*
48+
* Each TLB entry maps a pair of virtual pages. To avoid
49+
* aliasing, pick the largest page size that is at most
50+
* half the size of the region we're trying to map.
51+
*/
52+
if (IS_ALIGNED(start, 2 * pgsize) && (2 * pgsize <= len))
53+
break;
54+
}
55+
56+
return pgsize;
57+
}
58+
59+
/*
60+
* Identity map the memory from [start,start+len] in the TLB using the
61+
* largest suitable page size so as to conserve TLB entries.
62+
*/
63+
int identity_map(u32 start, size_t len, u32 coherency)
64+
{
65+
u32 pgsize, pfn, entryhi, entrylo0, entrylo1;
66+
67+
coherency &= C0_ENTRYLO_COHERENCY_MASK;
68+
while (len > 0) {
69+
pgsize = pick_pagesize(start, len);
70+
entryhi = start;
71+
pfn = start >> 12;
72+
entrylo0 = (pfn << C0_ENTRYLO_PFN_SHIFT) | coherency |
73+
C0_ENTRYLO_D | C0_ENTRYLO_V | C0_ENTRYLO_G;
74+
start += pgsize;
75+
len -= min(len, pgsize);
76+
if (len >= pgsize) {
77+
pfn = start >> 12;
78+
entrylo1 = (pfn << C0_ENTRYLO_PFN_SHIFT) |
79+
coherency | C0_ENTRYLO_D | C0_ENTRYLO_V |
80+
C0_ENTRYLO_G;
81+
start += pgsize;
82+
len -= min(len, pgsize);
83+
} else {
84+
entrylo1 = 0;
85+
}
86+
if (add_wired_tlb_entry(entrylo0, entrylo1, entryhi, pgsize))
87+
return -1;
88+
}
89+
90+
return 0;
91+
}

arch/mips/cpu/start.S

+31
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@
1616
#define CONFIG_SYS_MIPS_CACHE_MODE CONF_CM_CACHABLE_NONCOHERENT
1717
#endif
1818

19+
#ifndef CONFIG_SPL_BUILD
1920
#ifndef CONFIG_SYS_INIT_SP_ADDR
2021
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SDRAM_BASE + \
2122
CONFIG_SYS_INIT_SP_OFFSET)
2223
#endif
24+
#else
25+
#define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_SRAM_BASE + \
26+
CONFIG_SYS_SRAM_SIZE)
27+
#endif
2328

2429
#ifdef CONFIG_32BIT
2530
# define MIPS_RELOC 3
@@ -162,6 +167,23 @@ reset:
162167
mtc0 t0, CP0_CONFIG
163168
#endif
164169

170+
#ifdef CONFIG_SPL_BUILD
171+
172+
/* Initialize bss */
173+
la t0, __bss_start
174+
move k0, t0
175+
sw zero, (t0)
176+
la t1, __bss_end - 4
177+
blt t1, t0, stack
178+
nop
179+
clear_bss:
180+
addiu t0, 4
181+
sw zero, (t0)
182+
bne t0, t1, clear_bss
183+
nop
184+
#endif
185+
186+
stack:
165187
/* Set up temporary stack */
166188
PTR_LI t0, -16
167189
PTR_LI t1, CONFIG_SYS_INIT_SP_ADDR
@@ -188,10 +210,19 @@ reset:
188210
sw sp, 0(t0)
189211
#endif
190212

213+
#ifdef CONFIG_IGNORE_BOOT_FLAG
214+
move a0, zero
215+
#endif
216+
191217
PTR_LA t9, board_init_f
192218
jr t9
193219
move ra, zero
194220

221+
/* Hang for debugging purposes */
222+
loop: nop
223+
b loop
224+
nop
225+
195226
/*
196227
* void relocate_code (addr_sp, gd, addr_moni)
197228
*

arch/mips/cpu/u-boot.lds

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ SECTIONS
1919

2020
. = ALIGN(4);
2121
.text : {
22+
__text_start = .;
2223
*(.text*)
24+
. = ALIGN(8192);
25+
__text_end = .;
2326
}
2427

25-
. = ALIGN(4);
2628
.rodata : {
2729
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
2830
}

arch/mips/dts/Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dtb-$(CONFIG_MACH_PISTACHIO) += pistachio_bub.dtb pistachio_marduk.dtb pistachio_beetle_mbub.dtb pistachio_concerto_mbub.dtb
2+
3+
targets += $(dtb-y)
4+
5+
# Add any required device tree compiler flags here
6+
DTC_FLAGS +=
7+
8+
PHONY += dtbs
9+
dtbs: $(addprefix $(obj)/, $(dtb-y))
10+
@:
11+
12+
clean-files := *.dtb

arch/mips/dts/include/dt-bindings

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../include/dt-bindings

0 commit comments

Comments
 (0)