Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eed0eabd authored by Paul Burton's avatar Paul Burton Committed by Ralf Baechle
Browse files

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: default avatarPaul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14353/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent cf2a5e0b
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@ platforms += cavium-octeon
platforms += cobalt
platforms += cobalt
platforms += dec
platforms += dec
platforms += emma
platforms += emma
platforms += generic
platforms += jazz
platforms += jazz
platforms += jz4740
platforms += jz4740
platforms += lantiq
platforms += lantiq
+52 −0
Original line number Original line Diff line number Diff line
@@ -73,6 +73,57 @@ choice
	prompt "System type"
	prompt "System type"
	default SGI_IP22
	default SGI_IP22


config MIPS_GENERIC
	bool "Generic board-agnostic MIPS kernel"
	select BOOT_RAW
	select BUILTIN_DTB
	select CEVT_R4K
	select CLKSRC_MIPS_GIC
	select COMMON_CLK
	select CPU_MIPSR2_IRQ_VI
	select CPU_MIPSR2_IRQ_EI
	select CSRC_R4K
	select DMA_PERDEV_COHERENT
	select HW_HAS_PCI
	select IRQ_MIPS_CPU
	select LIBFDT
	select MIPS_CPU_SCACHE
	select MIPS_GIC
	select MIPS_L1_CACHE_SHIFT_7
	select NO_EXCEPT_FILL
	select PCI_DRIVERS_GENERIC
	select PINCTRL
	select SMP_UP if SMP
	select SYS_HAS_CPU_MIPS32_R1
	select SYS_HAS_CPU_MIPS32_R2
	select SYS_HAS_CPU_MIPS32_R6
	select SYS_HAS_CPU_MIPS64_R1
	select SYS_HAS_CPU_MIPS64_R2
	select SYS_HAS_CPU_MIPS64_R6
	select SYS_SUPPORTS_32BIT_KERNEL
	select SYS_SUPPORTS_64BIT_KERNEL
	select SYS_SUPPORTS_BIG_ENDIAN
	select SYS_SUPPORTS_HIGHMEM
	select SYS_SUPPORTS_LITTLE_ENDIAN
	select SYS_SUPPORTS_MICROMIPS
	select SYS_SUPPORTS_MIPS_CPS
	select SYS_SUPPORTS_MIPS16
	select SYS_SUPPORTS_MULTITHREADING
	select SYS_SUPPORTS_RELOCATABLE
	select SYS_SUPPORTS_SMARTMIPS
	select USB_EHCI_BIG_ENDIAN_DESC if BIG_ENDIAN
	select USB_EHCI_BIG_ENDIAN_MMIO if BIG_ENDIAN
	select USB_OHCI_BIG_ENDIAN_DESC if BIG_ENDIAN
	select USB_OHCI_BIG_ENDIAN_MMIO if BIG_ENDIAN
	select USB_UHCI_BIG_ENDIAN_DESC if BIG_ENDIAN
	select USB_UHCI_BIG_ENDIAN_MMIO if BIG_ENDIAN
	select USE_OF
	help
	  Select this to build a kernel which aims to support multiple boards,
	  generally using a flattened device tree passed from the bootloader
	  using the boot protocol defined in the UHI (Unified Hosting
	  Interface) specification.

config MIPS_ALCHEMY
config MIPS_ALCHEMY
	bool "Alchemy processor based machines"
	bool "Alchemy processor based machines"
	select ARCH_PHYS_ADDR_T_64BIT
	select ARCH_PHYS_ADDR_T_64BIT
@@ -989,6 +1040,7 @@ source "arch/mips/ath79/Kconfig"
source "arch/mips/bcm47xx/Kconfig"
source "arch/mips/bcm47xx/Kconfig"
source "arch/mips/bcm63xx/Kconfig"
source "arch/mips/bcm63xx/Kconfig"
source "arch/mips/bmips/Kconfig"
source "arch/mips/bmips/Kconfig"
source "arch/mips/generic/Kconfig"
source "arch/mips/jazz/Kconfig"
source "arch/mips/jazz/Kconfig"
source "arch/mips/jz4740/Kconfig"
source "arch/mips/jz4740/Kconfig"
source "arch/mips/lantiq/Kconfig"
source "arch/mips/lantiq/Kconfig"
+56 −0
Original line number Original line Diff line number Diff line
@@ -264,6 +264,12 @@ KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
bootvars-y	= VMLINUX_LOAD_ADDRESS=$(load-y) \
bootvars-y	= VMLINUX_LOAD_ADDRESS=$(load-y) \
		  VMLINUX_ENTRY_ADDRESS=$(entry-y) \
		  VMLINUX_ENTRY_ADDRESS=$(entry-y) \
		  PLATFORM=$(platform-y)
		  PLATFORM=$(platform-y)
ifdef CONFIG_32BIT
bootvars-y	+= ADDR_BITS=32
endif
ifdef CONFIG_64BIT
bootvars-y	+= ADDR_BITS=64
endif


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


@@ -431,4 +437,54 @@ define archhelp
	echo '  dtbs_install         - Install dtbs to $(INSTALL_DTBS_PATH)'
	echo '  dtbs_install         - Install dtbs to $(INSTALL_DTBS_PATH)'
	echo
	echo
	echo '  These will be default as appropriate for a configured platform.'
	echo '  These will be default as appropriate for a configured platform.'
	echo
	echo '  If you are targeting a system supported by generic kernels you may'
	echo '  configure the kernel for a given architecture target like so:'
	echo
	echo '  {micro32,32,64}{r1,r2,r6}{el,}_defconfig <BOARDS="list of boards">'
	echo
	echo '  Otherwise, the following default configurations are available:'
endef
endef

generic_config_dir = $(srctree)/arch/$(ARCH)/configs/generic
generic_defconfigs :=

#
# If the user generates a generic kernel configuration without specifying a
# list of boards to include the config fragments for, default to including all
# available board config fragments.
#
ifeq ($(BOARDS),)
BOARDS = $(patsubst board-%.config,%,$(notdir $(wildcard $(generic_config_dir)/board-*.config)))
endif

#
# Generic kernel configurations which merge generic_defconfig with the
# appropriate config fragments from arch/mips/configs/generic/, resulting in
# the ability to easily configure the kernel for a given architecture,
# endianness & set of boards without duplicating the needed configuration in
# hundreds of defconfig files.
#
define gen_generic_defconfigs
$(foreach bits,$(1),$(foreach rev,$(2),$(foreach endian,$(3),
target := $(bits)$(rev)$(filter el,$(endian))_defconfig
generic_defconfigs += $$(target)
$$(target): $(generic_config_dir)/$(bits)$(rev).config
$$(target): $(generic_config_dir)/$(endian).config
)))
endef

$(eval $(call gen_generic_defconfigs,32 64,r1 r2 r6,eb el))
$(eval $(call gen_generic_defconfigs,micro32,r2,eb el))

.PHONY: $(generic_defconfigs)
$(generic_defconfigs):
	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
		-m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ \
		$(foreach board,$(BOARDS),$(generic_config_dir)/board-$(board).config)
	$(Q)$(MAKE) olddefconfig

#
# Prevent generic merge_config rules attempting to merge single fragments
#
$(generic_config_dir)/%.config: ;
+10 −1
Original line number Original line Diff line number Diff line
@@ -111,13 +111,22 @@ targets += vmlinux.bz2.itb
targets += vmlinux.lzma.itb
targets += vmlinux.lzma.itb
targets += vmlinux.lzo.itb
targets += vmlinux.lzo.itb


ifeq ($(ADDR_BITS),32)
	itb_addr_cells = 1
endif
ifeq ($(ADDR_BITS),64)
	itb_addr_cells = 2
endif

quiet_cmd_cpp_its_S = ITS     $@
quiet_cmd_cpp_its_S = ITS     $@
      cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \
      cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \
		        -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
		        -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
			-DVMLINUX_BINARY="\"$(3)\"" \
			-DVMLINUX_BINARY="\"$(3)\"" \
			-DVMLINUX_COMPRESSION="\"$(2)\"" \
			-DVMLINUX_COMPRESSION="\"$(2)\"" \
			-DVMLINUX_LOAD_ADDRESS=$(VMLINUX_LOAD_ADDRESS) \
			-DVMLINUX_LOAD_ADDRESS=$(VMLINUX_LOAD_ADDRESS) \
			-DVMLINUX_ENTRY_ADDRESS=$(VMLINUX_ENTRY_ADDRESS)
			-DVMLINUX_ENTRY_ADDRESS=$(VMLINUX_ENTRY_ADDRESS) \
			-DADDR_BITS=$(ADDR_BITS) \
			-DADDR_CELLS=$(itb_addr_cells)


$(obj)/vmlinux.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
$(obj)/vmlinux.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
	$(call if_changed_dep,cpp_its_S,none,vmlinux.bin)
	$(call if_changed_dep,cpp_its_S,none,vmlinux.bin)
+2 −0
Original line number Original line Diff line number Diff line
CONFIG_CPU_MIPS32_R1=y
CONFIG_HIGHMEM=y
Loading