Skip to content

Commit eed0eab

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: generic: Introduce generic DT-based board support
Introduce a "generic" platform, which aims to be board-agnostic by making use of device trees passed by the boot protocol defined in the MIPS UHI (Universal Hosting Interface) specification. Provision is made for supporting boards which use a legacy boot protocol that can't be changed, but adding support for such boards or any others is left to followon patches. Right now the built kernels expect to be loaded to 0x80100000, ie. in kseg0. This is fine for the vast majority of MIPS platforms, but nevertheless it would be good to remove this limitation in the future by mapping the kernel via the TLB such that it can be loaded anywhere & map itself appropriately. Configuration is handled by dynamically generating configs using scripts/kconfig/merge_config.sh, somewhat similar to the way powerpc makes use of it. This allows for variations upon the configuration, eg. differing architecture revisions or subsets of driver support for differing boards, to be handled without having a large number of defconfig files. Signed-off-by: Paul Burton <[email protected]> Cc: [email protected] Patchwork: https://patchwork.linux-mips.org/patch/14353/ Signed-off-by: Ralf Baechle <[email protected]>
1 parent cf2a5e0 commit eed0eab

22 files changed

+643
-1
lines changed

arch/mips/Kbuild.platforms

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ platforms += cavium-octeon
1111
platforms += cobalt
1212
platforms += dec
1313
platforms += emma
14+
platforms += generic
1415
platforms += jazz
1516
platforms += jz4740
1617
platforms += lantiq

arch/mips/Kconfig

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,57 @@ choice
7373
prompt "System type"
7474
default SGI_IP22
7575

76+
config MIPS_GENERIC
77+
bool "Generic board-agnostic MIPS kernel"
78+
select BOOT_RAW
79+
select BUILTIN_DTB
80+
select CEVT_R4K
81+
select CLKSRC_MIPS_GIC
82+
select COMMON_CLK
83+
select CPU_MIPSR2_IRQ_VI
84+
select CPU_MIPSR2_IRQ_EI
85+
select CSRC_R4K
86+
select DMA_PERDEV_COHERENT
87+
select HW_HAS_PCI
88+
select IRQ_MIPS_CPU
89+
select LIBFDT
90+
select MIPS_CPU_SCACHE
91+
select MIPS_GIC
92+
select MIPS_L1_CACHE_SHIFT_7
93+
select NO_EXCEPT_FILL
94+
select PCI_DRIVERS_GENERIC
95+
select PINCTRL
96+
select SMP_UP if SMP
97+
select SYS_HAS_CPU_MIPS32_R1
98+
select SYS_HAS_CPU_MIPS32_R2
99+
select SYS_HAS_CPU_MIPS32_R6
100+
select SYS_HAS_CPU_MIPS64_R1
101+
select SYS_HAS_CPU_MIPS64_R2
102+
select SYS_HAS_CPU_MIPS64_R6
103+
select SYS_SUPPORTS_32BIT_KERNEL
104+
select SYS_SUPPORTS_64BIT_KERNEL
105+
select SYS_SUPPORTS_BIG_ENDIAN
106+
select SYS_SUPPORTS_HIGHMEM
107+
select SYS_SUPPORTS_LITTLE_ENDIAN
108+
select SYS_SUPPORTS_MICROMIPS
109+
select SYS_SUPPORTS_MIPS_CPS
110+
select SYS_SUPPORTS_MIPS16
111+
select SYS_SUPPORTS_MULTITHREADING
112+
select SYS_SUPPORTS_RELOCATABLE
113+
select SYS_SUPPORTS_SMARTMIPS
114+
select USB_EHCI_BIG_ENDIAN_DESC if BIG_ENDIAN
115+
select USB_EHCI_BIG_ENDIAN_MMIO if BIG_ENDIAN
116+
select USB_OHCI_BIG_ENDIAN_DESC if BIG_ENDIAN
117+
select USB_OHCI_BIG_ENDIAN_MMIO if BIG_ENDIAN
118+
select USB_UHCI_BIG_ENDIAN_DESC if BIG_ENDIAN
119+
select USB_UHCI_BIG_ENDIAN_MMIO if BIG_ENDIAN
120+
select USE_OF
121+
help
122+
Select this to build a kernel which aims to support multiple boards,
123+
generally using a flattened device tree passed from the bootloader
124+
using the boot protocol defined in the UHI (Unified Hosting
125+
Interface) specification.
126+
76127
config MIPS_ALCHEMY
77128
bool "Alchemy processor based machines"
78129
select ARCH_PHYS_ADDR_T_64BIT
@@ -989,6 +1040,7 @@ source "arch/mips/ath79/Kconfig"
9891040
source "arch/mips/bcm47xx/Kconfig"
9901041
source "arch/mips/bcm63xx/Kconfig"
9911042
source "arch/mips/bmips/Kconfig"
1043+
source "arch/mips/generic/Kconfig"
9921044
source "arch/mips/jazz/Kconfig"
9931045
source "arch/mips/jz4740/Kconfig"
9941046
source "arch/mips/lantiq/Kconfig"

arch/mips/Makefile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
264264
bootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y) \
265265
VMLINUX_ENTRY_ADDRESS=$(entry-y) \
266266
PLATFORM=$(platform-y)
267+
ifdef CONFIG_32BIT
268+
bootvars-y += ADDR_BITS=32
269+
endif
270+
ifdef CONFIG_64BIT
271+
bootvars-y += ADDR_BITS=64
272+
endif
267273

268274
LDFLAGS += -m $(ld-emul)
269275

@@ -431,4 +437,54 @@ define archhelp
431437
echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'
432438
echo
433439
echo ' These will be default as appropriate for a configured platform.'
440+
echo
441+
echo ' If you are targeting a system supported by generic kernels you may'
442+
echo ' configure the kernel for a given architecture target like so:'
443+
echo
444+
echo ' {micro32,32,64}{r1,r2,r6}{el,}_defconfig <BOARDS="list of boards">'
445+
echo
446+
echo ' Otherwise, the following default configurations are available:'
434447
endef
448+
449+
generic_config_dir = $(srctree)/arch/$(ARCH)/configs/generic
450+
generic_defconfigs :=
451+
452+
#
453+
# If the user generates a generic kernel configuration without specifying a
454+
# list of boards to include the config fragments for, default to including all
455+
# available board config fragments.
456+
#
457+
ifeq ($(BOARDS),)
458+
BOARDS = $(patsubst board-%.config,%,$(notdir $(wildcard $(generic_config_dir)/board-*.config)))
459+
endif
460+
461+
#
462+
# Generic kernel configurations which merge generic_defconfig with the
463+
# appropriate config fragments from arch/mips/configs/generic/, resulting in
464+
# the ability to easily configure the kernel for a given architecture,
465+
# endianness & set of boards without duplicating the needed configuration in
466+
# hundreds of defconfig files.
467+
#
468+
define gen_generic_defconfigs
469+
$(foreach bits,$(1),$(foreach rev,$(2),$(foreach endian,$(3),
470+
target := $(bits)$(rev)$(filter el,$(endian))_defconfig
471+
generic_defconfigs += $$(target)
472+
$$(target): $(generic_config_dir)/$(bits)$(rev).config
473+
$$(target): $(generic_config_dir)/$(endian).config
474+
)))
475+
endef
476+
477+
$(eval $(call gen_generic_defconfigs,32 64,r1 r2 r6,eb el))
478+
$(eval $(call gen_generic_defconfigs,micro32,r2,eb el))
479+
480+
.PHONY: $(generic_defconfigs)
481+
$(generic_defconfigs):
482+
$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
483+
-m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ \
484+
$(foreach board,$(BOARDS),$(generic_config_dir)/board-$(board).config)
485+
$(Q)$(MAKE) olddefconfig
486+
487+
#
488+
# Prevent generic merge_config rules attempting to merge single fragments
489+
#
490+
$(generic_config_dir)/%.config: ;

arch/mips/boot/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,22 @@ targets += vmlinux.bz2.itb
111111
targets += vmlinux.lzma.itb
112112
targets += vmlinux.lzo.itb
113113

114+
ifeq ($(ADDR_BITS),32)
115+
itb_addr_cells = 1
116+
endif
117+
ifeq ($(ADDR_BITS),64)
118+
itb_addr_cells = 2
119+
endif
120+
114121
quiet_cmd_cpp_its_S = ITS $@
115122
cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \
116123
-DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
117124
-DVMLINUX_BINARY="\"$(3)\"" \
118125
-DVMLINUX_COMPRESSION="\"$(2)\"" \
119126
-DVMLINUX_LOAD_ADDRESS=$(VMLINUX_LOAD_ADDRESS) \
120-
-DVMLINUX_ENTRY_ADDRESS=$(VMLINUX_ENTRY_ADDRESS)
127+
-DVMLINUX_ENTRY_ADDRESS=$(VMLINUX_ENTRY_ADDRESS) \
128+
-DADDR_BITS=$(ADDR_BITS) \
129+
-DADDR_CELLS=$(itb_addr_cells)
121130

122131
$(obj)/vmlinux.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
123132
$(call if_changed_dep,cpp_its_S,none,vmlinux.bin)

arch/mips/configs/generic/32r1.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_CPU_MIPS32_R1=y
2+
CONFIG_HIGHMEM=y

arch/mips/configs/generic/32r2.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_CPU_MIPS32_R2=y
2+
CONFIG_MIPS_O32_FP64_SUPPORT=y
3+
CONFIG_HIGHMEM=y

arch/mips/configs/generic/32r6.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_CPU_MIPS32_R6=y
2+
CONFIG_HIGHMEM=y

arch/mips/configs/generic/64r1.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_CPU_MIPS64_R1=y
2+
CONFIG_64BIT=y
3+
CONFIG_MIPS32_O32=y
4+
CONFIG_MIPS32_N32=y

arch/mips/configs/generic/64r2.config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_CPU_MIPS64_R2=y
2+
CONFIG_MIPS_O32_FP64_SUPPORT=y
3+
CONFIG_64BIT=y
4+
CONFIG_MIPS32_O32=y
5+
CONFIG_MIPS32_N32=y

arch/mips/configs/generic/64r6.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_CPU_MIPS64_R6=y
2+
CONFIG_64BIT=y
3+
CONFIG_MIPS32_O32=y
4+
CONFIG_MIPS32_N32=y

arch/mips/configs/generic/eb.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_CPU_BIG_ENDIAN=y

arch/mips/configs/generic/el.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_CPU_LITTLE_ENDIAN=y
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_CPU_MIPS32_R2=y
2+
CONFIG_CPU_MICROMIPS=y
3+
CONFIG_MIPS_O32_FP64_SUPPORT=y
4+
CONFIG_HIGHMEM=y

arch/mips/configs/generic_defconfig

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
CONFIG_MIPS_GENERIC=y
2+
CONFIG_CPU_LITTLE_ENDIAN=y
3+
CONFIG_MIPS_CPS=y
4+
CONFIG_CPU_HAS_MSA=y
5+
CONFIG_HIGHMEM=y
6+
CONFIG_NR_CPUS=2
7+
CONFIG_MIPS_O32_FP64_SUPPORT=y
8+
CONFIG_SYSVIPC=y
9+
CONFIG_NO_HZ_IDLE=y
10+
CONFIG_IKCONFIG=y
11+
CONFIG_IKCONFIG_PROC=y
12+
CONFIG_MEMCG=y
13+
CONFIG_MEMCG_SWAP=y
14+
CONFIG_BLK_CGROUP=y
15+
CONFIG_CFS_BANDWIDTH=y
16+
CONFIG_RT_GROUP_SCHED=y
17+
CONFIG_CGROUP_PIDS=y
18+
CONFIG_CGROUP_FREEZER=y
19+
CONFIG_CPUSETS=y
20+
CONFIG_CGROUP_DEVICE=y
21+
CONFIG_CGROUP_CPUACCT=y
22+
CONFIG_NAMESPACES=y
23+
CONFIG_USER_NS=y
24+
CONFIG_SCHED_AUTOGROUP=y
25+
CONFIG_BLK_DEV_INITRD=y
26+
CONFIG_BPF_SYSCALL=y
27+
CONFIG_USERFAULTFD=y
28+
CONFIG_EMBEDDED=y
29+
# CONFIG_SLUB_DEBUG is not set
30+
# CONFIG_COMPAT_BRK is not set
31+
CONFIG_CC_STACKPROTECTOR_REGULAR=y
32+
CONFIG_MODULES=y
33+
CONFIG_MODULE_UNLOAD=y
34+
CONFIG_TRIM_UNUSED_KSYMS=y
35+
CONFIG_NET=y
36+
CONFIG_PACKET=y
37+
CONFIG_UNIX=y
38+
CONFIG_INET=y
39+
CONFIG_NETFILTER=y
40+
# CONFIG_WIRELESS is not set
41+
CONFIG_DEVTMPFS=y
42+
CONFIG_DEVTMPFS_MOUNT=y
43+
CONFIG_SCSI=y
44+
# CONFIG_INPUT_MOUSEDEV is not set
45+
# CONFIG_INPUT_KEYBOARD is not set
46+
# CONFIG_INPUT_MOUSE is not set
47+
# CONFIG_SERIO is not set
48+
CONFIG_HW_RANDOM=y
49+
# CONFIG_HWMON is not set
50+
CONFIG_MFD_SYSCON=y
51+
CONFIG_HID_A4TECH=y
52+
CONFIG_HID_APPLE=y
53+
CONFIG_HID_BELKIN=y
54+
CONFIG_HID_CHERRY=y
55+
CONFIG_HID_CHICONY=y
56+
CONFIG_HID_CYPRESS=y
57+
CONFIG_HID_EZKEY=y
58+
CONFIG_HID_KENSINGTON=y
59+
CONFIG_HID_LOGITECH=y
60+
CONFIG_HID_MICROSOFT=y
61+
CONFIG_HID_MONTEREY=y
62+
# CONFIG_USB_SUPPORT is not set
63+
# CONFIG_MIPS_PLATFORM_DEVICES is not set
64+
# CONFIG_IOMMU_SUPPORT is not set
65+
CONFIG_EXT4_FS=y
66+
CONFIG_EXT4_FS_POSIX_ACL=y
67+
CONFIG_EXT4_FS_SECURITY=y
68+
CONFIG_EXT4_ENCRYPTION=y
69+
CONFIG_FANOTIFY=y
70+
CONFIG_FUSE_FS=y
71+
CONFIG_CUSE=y
72+
CONFIG_OVERLAY_FS=y
73+
CONFIG_MSDOS_FS=y
74+
CONFIG_VFAT_FS=y
75+
CONFIG_TMPFS=y
76+
CONFIG_TMPFS_POSIX_ACL=y
77+
# CONFIG_MISC_FILESYSTEMS is not set
78+
CONFIG_NFS_FS=y
79+
CONFIG_NFS_V3_ACL=y
80+
CONFIG_NFS_V4=y
81+
CONFIG_NFS_V4_1=y
82+
CONFIG_NFS_V4_2=y
83+
CONFIG_PRINTK_TIME=y
84+
CONFIG_DEBUG_INFO=y
85+
CONFIG_DEBUG_INFO_REDUCED=y
86+
CONFIG_DEBUG_FS=y
87+
# CONFIG_SCHED_DEBUG is not set
88+
# CONFIG_FTRACE is not set
89+
CONFIG_CMDLINE_BOOL=y
90+
CONFIG_CMDLINE="earlycon"
91+
# CONFIG_XZ_DEC_X86 is not set
92+
# CONFIG_XZ_DEC_POWERPC is not set
93+
# CONFIG_XZ_DEC_IA64 is not set
94+
# CONFIG_XZ_DEC_ARM is not set
95+
# CONFIG_XZ_DEC_ARMTHUMB is not set
96+
# CONFIG_XZ_DEC_SPARC is not set

arch/mips/generic/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
if MIPS_GENERIC
2+
3+
config LEGACY_BOARDS
4+
bool
5+
help
6+
Select this from your board if the board must use a legacy, non-UHI,
7+
boot protocol. This will cause the kernel to scan through the list of
8+
supported machines calling their detect functions in turn if the
9+
kernel is booted without being provided with an FDT via the UHI
10+
boot protocol.
11+
12+
endif

arch/mips/generic/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (C) 2016 Imagination Technologies
3+
# Author: Paul Burton <[email protected]>
4+
#
5+
# This program is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU General Public License as published by the
7+
# Free Software Foundation; either version 2 of the License, or (at your
8+
# option) any later version.
9+
#
10+
11+
obj-y += init.o
12+
obj-y += irq.o
13+
obj-y += proc.o

arch/mips/generic/Platform

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (C) 2016 Imagination Technologies
3+
# Author: Paul Burton <[email protected]>
4+
#
5+
# This program is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU General Public License as published by the
7+
# Free Software Foundation; either version 2 of the License, or (at your
8+
# option) any later version.
9+
#
10+
11+
platform-$(CONFIG_MIPS_GENERIC) += generic/
12+
cflags-$(CONFIG_MIPS_GENERIC) += -I$(srctree)/arch/mips/include/asm/mach-generic
13+
load-$(CONFIG_MIPS_GENERIC) += 0xffffffff80100000
14+
all-$(CONFIG_MIPS_GENERIC) := vmlinux.gz.itb

0 commit comments

Comments
 (0)