summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/boards/mips/dlink-dir-320.rst8
-rw-r--r--Documentation/boards/openrisc.rst68
-rw-r--r--Documentation/boards/x86.rst153
-rw-r--r--Documentation/devel/devel.rst1
-rw-r--r--Documentation/devel/porting.rst509
-rw-r--r--Documentation/devicetree/index.rst2
-rw-r--r--Documentation/user/pbl.rst6
-rw-r--r--Documentation/user/reboot-mode.rst9
-rw-r--r--Documentation/user/system-reset.rst2
-rw-r--r--Documentation/user/user-manual.rst1
-rw-r--r--Makefile36
-rw-r--r--arch/arm/boards/Makefile3
-rw-r--r--arch/arm/boards/kamstrup-mx7-concentrator/Makefile1
-rw-r--r--arch/arm/boards/kamstrup-mx7-concentrator/flash-header-tqma7d.imxcfg79
-rw-r--r--arch/arm/boards/kamstrup-mx7-concentrator/lowlevel.c35
-rw-r--r--arch/arm/boards/skov-arm9cpu/Makefile2
-rw-r--r--arch/arm/boards/skov-arm9cpu/board.c84
-rw-r--r--arch/arm/boards/skov-arm9cpu/lowlevel.c127
-rw-r--r--arch/arm/boards/skov-imx6/Makefile3
-rw-r--r--arch/arm/boards/skov-imx6/board.c528
-rw-r--r--arch/arm/boards/skov-imx6/env/init/automount14
-rw-r--r--arch/arm/boards/skov-imx6/env/nv/boot.default1
-rw-r--r--arch/arm/boards/skov-imx6/flash-header-mx6-skov-imx6.imxcfg4
-rw-r--r--arch/arm/boards/skov-imx6/lowlevel.c664
-rw-r--r--arch/arm/configs/at91_multi_defconfig1
-rw-r--r--arch/arm/configs/imx_v7_defconfig1
-rw-r--r--arch/arm/cpu/uncompress.c1
-rw-r--r--arch/arm/dts/Makefile3
-rw-r--r--arch/arm/dts/at91-skov-arm9cpu.dts451
-rw-r--r--arch/arm/dts/imx6dl-skov-imx6.dts24
-rw-r--r--arch/arm/dts/imx6q-skov-imx6.dts28
-rw-r--r--arch/arm/dts/imx6qdl-skov-imx6.dtsi546
-rw-r--r--arch/arm/dts/imx7d-flex-concentrator-mfg.dts108
-rw-r--r--arch/arm/mach-at91/Kconfig11
-rw-r--r--arch/arm/mach-imx/Kconfig11
-rw-r--r--arch/arm/mach-imx/boot.c3
-rw-r--r--arch/arm/mach-imx/include/mach/imx-gpio.h21
-rw-r--r--arch/riscv/boot/uncompress.c6
-rw-r--r--arch/riscv/dts/erizo.dtsi2
-rw-r--r--arch/riscv/include/asm/sections.h4
-rw-r--r--arch/riscv/lib/Makefile2
-rw-r--r--arch/riscv/lib/riscv_timer.c63
-rw-r--r--arch/sandbox/board/env/init/state9
-rw-r--r--arch/sandbox/board/env/nv/autoboot1
-rw-r--r--arch/x86/Kconfig63
-rw-r--r--arch/x86/Makefile32
-rw-r--r--arch/x86/bios/Makefile3
-rw-r--r--arch/x86/bios/bios_disk.S57
-rw-r--r--arch/x86/bios/memory16.S54
-rw-r--r--arch/x86/bios/traveler.S166
-rw-r--r--arch/x86/boards/x86_generic/Makefile4
-rw-r--r--arch/x86/boards/x86_generic/disk_bios_drive.c33
-rw-r--r--arch/x86/boards/x86_generic/env/bin/boot37
-rw-r--r--arch/x86/boards/x86_generic/env/bin/init15
-rw-r--r--arch/x86/boards/x86_generic/env/config31
-rw-r--r--arch/x86/boards/x86_generic/envsector.h24
-rw-r--r--arch/x86/boards/x86_generic/generic_pc.c18
-rw-r--r--arch/x86/boards/x86_generic/intf_platform_ide.c80
-rw-r--r--arch/x86/boards/x86_generic/serial_ns16550.c35
-rw-r--r--arch/x86/boot/Kconfig20
-rw-r--r--arch/x86/boot/Makefile13
-rw-r--r--arch/x86/boot/a20.c166
-rw-r--r--arch/x86/boot/bioscall.S90
-rw-r--r--arch/x86/boot/boot.h189
-rw-r--r--arch/x86/boot/boot_hdisk.S170
-rw-r--r--arch/x86/boot/boot_main.S39
-rw-r--r--arch/x86/boot/main_entry.c24
-rw-r--r--arch/x86/boot/pmjump.S82
-rw-r--r--arch/x86/boot/prepare_uboot.c80
-rw-r--r--arch/x86/boot/regs.c29
-rw-r--r--arch/x86/boot/tty.c41
-rw-r--r--arch/x86/configs/generic_defconfig26
-rw-r--r--arch/x86/include/asm/syslib.h13
-rw-r--r--arch/x86/lib/.gitignore1
-rw-r--r--arch/x86/lib/Makefile9
-rw-r--r--arch/x86/lib/asm-offsets.c6
-rw-r--r--arch/x86/lib/barebox.lds.S161
-rw-r--r--arch/x86/lib/gdt.c38
-rw-r--r--arch/x86/lib/linux_start.S55
-rw-r--r--arch/x86/lib/memory.c49
-rw-r--r--arch/x86/mach-efi/elf_x86_64_efi.lds.S3
-rw-r--r--arch/x86/mach-i386/Kconfig13
-rw-r--r--arch/x86/mach-i386/Makefile2
-rw-r--r--arch/x86/mach-i386/include/mach/barebox.lds.h82
-rw-r--r--arch/x86/mach-i386/pit_timer.c53
-rw-r--r--commands/Kconfig21
-rw-r--r--commands/Makefile1
-rw-r--r--commands/edit.c8
-rw-r--r--commands/linux16.c331
-rw-r--r--commands/nandtest.c8
-rw-r--r--common/Kconfig8
-rw-r--r--common/clock.c13
-rw-r--r--common/console_common.c18
-rw-r--r--common/efi/Makefile1
-rw-r--r--common/efi/efi-iomem.c175
-rw-r--r--common/imd.c6
-rw-r--r--common/imx-bbu-nand-fcb.c16
-rw-r--r--common/memory.c2
-rw-r--r--common/partitions.c3
-rw-r--r--common/partitions/dos.c29
-rw-r--r--defaultenv/Makefile7
-rw-r--r--defaultenv/defaultenv.c2
-rw-r--r--drivers/ata/Kconfig9
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/disk_bios_drive.c302
-rw-r--r--drivers/clk/clk-divider.c12
-rw-r--r--drivers/clk/imx/clk-pllv1.c11
-rw-r--r--drivers/clocksource/timer-riscv.c13
-rw-r--r--drivers/gpio/gpio-pl061.c11
-rw-r--r--drivers/gpio/gpiolib.c43
-rw-r--r--drivers/mtd/core.c2
-rw-r--r--drivers/mtd/mtdoob.c2
-rw-r--r--drivers/mtd/nand/nand_bbt.c4
-rw-r--r--drivers/mtd/nand/nand_mxs.c29
-rw-r--r--drivers/mtd/peb.c4
-rw-r--r--drivers/mtd/spi-nor/spi-nor.c2
-rw-r--r--drivers/net/phy/at803x.c7
-rw-r--r--drivers/power/reset/Kconfig16
-rw-r--r--drivers/power/reset/Makefile2
-rw-r--r--drivers/power/reset/gpio-poweroff.c93
-rw-r--r--drivers/power/reset/gpio-restart.c99
-rw-r--r--drivers/pwm/Kconfig6
-rw-r--r--drivers/pwm/Makefile1
-rw-r--r--drivers/pwm/pwm-atmel.c289
-rw-r--r--drivers/sound/gpio-beeper.c20
-rw-r--r--drivers/video/atmel_lcdfb_core.c14
-rw-r--r--drivers/video/bochs/bochs_pci.c1
-rw-r--r--drivers/virtio/virtio_pci_common.h2
-rw-r--r--drivers/virtio/virtio_pci_modern.c7
-rw-r--r--drivers/watchdog/Kconfig7
-rw-r--r--drivers/watchdog/Makefile1
-rw-r--r--drivers/watchdog/gpio_wdt.c142
-rw-r--r--dts/Bindings/hwmon/ntc_thermistor.txt2
-rw-r--r--dts/Bindings/i2c/i2c-gpio.yaml2
-rw-r--r--dts/Bindings/i2c/i2c-imx.yaml2
-rw-r--r--dts/Bindings/iio/adc/ingenic,adc.yaml5
-rw-r--r--dts/Bindings/input/adc-joystick.yaml4
-rw-r--r--dts/Bindings/input/touchscreen/resistive-adc-touch.txt5
-rw-r--r--dts/Bindings/leds/cznic,turris-omnia-leds.yaml2
-rw-r--r--dts/Bindings/mfd/ab8500.txt4
-rw-r--r--dts/Bindings/mfd/motorola-cpcap.txt16
-rw-r--r--dts/Bindings/net/brcm,bcm4908-enet.yaml2
-rw-r--r--dts/Bindings/net/ethernet-controller.yaml2
-rw-r--r--dts/Bindings/net/micrel-ksz90x1.txt96
-rw-r--r--dts/Bindings/sound/fsl,spdif.yaml4
-rw-r--r--dts/include/dt-bindings/bus/moxtet.h2
-rw-r--r--dts/src/arc/haps_hs.dts2
-rw-r--r--dts/src/arm/am33xx.dtsi3
-rw-r--r--dts/src/arm/armada-385-turris-omnia.dts4
-rw-r--r--dts/src/arm/at91-sam9x60ek.dts8
-rw-r--r--dts/src/arm/at91-sama5d27_som1.dtsi4
-rw-r--r--dts/src/arm/bcm2711.dtsi12
-rw-r--r--dts/src/arm/imx6qdl-phytec-pfla02.dtsi2
-rw-r--r--dts/src/arm/imx6ul-14x14-evk.dtsi22
-rw-r--r--dts/src/arm/imx6ull-myir-mys-6ulx-eval.dts1
-rw-r--r--dts/src/arm/omap4.dtsi5
-rw-r--r--dts/src/arm/omap44xx-clocks.dtsi8
-rw-r--r--dts/src/arm/omap5.dtsi5
-rw-r--r--dts/src/arm/sam9x60.dtsi9
-rw-r--r--dts/src/arm64/freescale/fsl-ls1012a.dtsi1
-rw-r--r--dts/src/arm64/freescale/fsl-ls1043a.dtsi1
-rw-r--r--dts/src/arm64/freescale/fsl-ls1046a.dtsi1
-rw-r--r--dts/src/arm64/freescale/imx8mm-pinfunc.h2
-rw-r--r--dts/src/arm64/freescale/imx8mp-phyboard-pollux-rdk.dts2
-rw-r--r--dts/src/arm64/freescale/imx8mp-phycore-som.dtsi2
-rw-r--r--dts/src/arm64/freescale/imx8mq-pinfunc.h2
-rw-r--r--dts/src/arm64/marvell/armada-3720-turris-mox.dts2
-rw-r--r--dts/src/arm64/marvell/armada-cp11x.dtsi6
-rw-r--r--images/Makefile.at915
-rw-r--r--images/Makefile.imx7
-rw-r--r--include/clock.h2
-rw-r--r--include/efi.h9
-rw-r--r--include/gpiod.h26
-rw-r--r--include/video/atmel_lcdc.h4
-rw-r--r--net/eth.c16
-rw-r--r--scripts/Makefile1
-rw-r--r--scripts/Makefile.lib3
-rw-r--r--scripts/bareboximd.c53
-rw-r--r--scripts/imx/imx.c52
-rw-r--r--scripts/setupmbr/.gitignore1
-rw-r--r--scripts/setupmbr/Makefile3
-rw-r--r--scripts/setupmbr/arch.h55
-rw-r--r--scripts/setupmbr/setupmbr.c545
183 files changed, 4736 insertions, 3841 deletions
diff --git a/Documentation/boards/mips/dlink-dir-320.rst b/Documentation/boards/mips/dlink-dir-320.rst
index 7595381f55..90de68a9c4 100644
--- a/Documentation/boards/mips/dlink-dir-320.rst
+++ b/Documentation/boards/mips/dlink-dir-320.rst
@@ -21,7 +21,7 @@ Running barebox
Barebox can be started from CFE using tftp.
You must setup tftp-server on host 192.168.0.1.
-Put your barebox.bin to tftp-server directory
+Put your barebox-dlink-dir-320.img to tftp-server directory
(usual /tftpboot or /srv/tftp).
Connect your DIR-320 to your tftp-server network via
one of four <LAN> sockets.
@@ -31,14 +31,14 @@ Next, setup network on DIR-320 and run barebox.bin, e.g.:
.. code-block:: console
CFE> ifconfig eth0 -addr=192.168.0.99
- CFE> boot -tftp -addr=a0800000 -raw 192.168.0.1:barebox.bin
+ CFE> boot -tftp -addr=a0800000 -raw 192.168.0.1:barebox-dlink-dir-320.img
Links
-----
- * http://www.dlink.com.au/products/?pid=768
- * http://wiki.openwrt.org/toh/d-link/dir-320
+ * http://web.archive.org/web/20140301070636/http://www.dlink.com.au/products/?pid=768
+ * https://openwrt.org/toh/d-link/dir-320
CFE links:
diff --git a/Documentation/boards/openrisc.rst b/Documentation/boards/openrisc.rst
index f9d67f9650..34586b4a76 100644
--- a/Documentation/boards/openrisc.rst
+++ b/Documentation/boards/openrisc.rst
@@ -1,6 +1,74 @@
OpenRISC
========
+Optaining an OpenRISC toolchain
+-------------------------------
+
+Toolchain binaries can be obtained from openrisc.io or our github releases page.
+Instructions for building the different toolchains can be found on openrisc.io
+or Stafford's toolchain build and release scripts.
+
+See:
+
+ * https://github.com/stffrdhrn/gcc/releases
+ * https://github.com/stffrdhrn/or1k-toolchain-build
+ * https://openrisc.io/software
+
+Example of downloading and installing a toolchain::
+
+ $ curl --remote-name --location \
+ https://github.com/stffrdhrn/gcc/releases/download/or1k-10.0.0-20190723/or1k-elf-10.0.0-20190723.tar.xz
+ $ tar -xf or1k-elf-10.0.0-20190723.tar.xz
+ $ export PATH=$PATH:$PWD/or1k-elf/bin
+
+Running OpenRISC barebox on qemu
+------------------------------
+
+Running barebox on qemu is similar to running linux on qemu see more details on
+the qemu wiki site at https://wiki.qemu.org/Documentation/Platforms/OpenRISC
+
+Compile the qemu emulator::
+
+ $ git clone https://gitlab.com/qemu-project/qemu.git
+ $ cd qemu
+ $ mkdir build ; cd build
+ $ ../configure \
+ --target-list="or1k-softmmu" \
+ --enable-fdt \
+ --disable-kvm \
+ --disable-xen \
+ --disable-xkbcommon \
+ --enable-debug \
+ --enable-debug-info
+ $ make
+
+Next compile barebox::
+
+ $ make ARCH=openrisc defconfig
+ ...
+ $ make ARCH=openrisc CROSS_COMPILE=or1k-elf-
+
+Run barebox::
+
+ $ <path to qemu source>/build/or1k-softmmu/qemu-system-or1k \
+ -cpu or1200 \
+ -M or1k-sim \
+ -kernel /home/shorne/work/openrisc/barebox/barebox \
+ -net nic -net tap,ifname=tap0,script=no,downscript=no \
+ -serial mon:stdio -nographic -gdb tcp::10001 \
+ -m 32
+
+
+ barebox 2021.02.0-00120-g763c6fee7-dirty #14 Thu Mar 4 05:13:51 JST 2021
+
+
+ Board: or1ksim
+ mdio_bus: miibus0: probed
+ malloc space: 0x01b80000 -> 0x01f7ffff (size 4 MiB)
+
+ Hit any to stop autoboot: 3
+ barebox@or1ksim:/
+
or1ksim
-------
diff --git a/Documentation/boards/x86.rst b/Documentation/boards/x86.rst
deleted file mode 100644
index c0d5a64b9d..0000000000
--- a/Documentation/boards/x86.rst
+++ /dev/null
@@ -1,153 +0,0 @@
-x86
-===
-
-.. note::
- This is about legacy x86 PC boot, which is not as well supported as booting
- under UEFI. Refer to :doc:`boards/efi.rst` for documentation on the barebox
- EFI support.
-
-Features
---------
-
-barebox can act as a bootloader for PC based systems. In this case a special
-binary layout will be created to be able to store it on some media the PC
-BIOS can boot from. It can boot Linux kernels stored also on the same boot
-media and be configured at runtime, with the possibility to store the changed
-configuration on the boot media.
-
-Restrictions
-------------
-
-Due to some BIOS and barebox restrictions the boot media must be
-prepared in some special way:
-
- * barebox must be stored in the MBR (Master Boot Record) of the boot
- media. Currently its not possible to store and boot it in one of
- the partition sectors to use it as a second stage loader). This is
- no eternal restriction. It only needs further effort to add this
- feature.
- * barebox currently cannot run a chained boot loader. Also, this is
- no external restriction, only further effort needed.
- * barebox comes with limited filesystem support. There is currently
- no support for the most common and popular filesystems used in the
- \*NIX world. This restricts locations where to store a kernel and
- other runtime information
- * barebox must be stored to the first n sectors of the boot media.
- To ensure this does not collide with partitions on the boot media,
- the first partition must start at a sector behind the ones barebox
- occupies.
- * barebox handles its runtime configuration in a special way: It
- stores it in a binary way into some reserved sectors ("persistant
- storage").
-
-Boot Preparations
------------------
-
-To store the barebox image to a boot media, it comes with the tool
-setupmbr in the directory scripts/setupmbr/ . To be able to use it on
-the boot media of your choice, some preparations are required.
-
-Keep Sectors free
------------------
-
-Build the barebox image and check its size. At least this amount of
-sectors must be kept free after the MBR prior the first partition. Do this
-simple calulation:
-
-.. code-block:: none
-
- sectors = (size of barebox image + 511) / 512
-
-To be able to store the runtime configuration, further free sectors are
-required. Its up to you and your requirements, how large this persistant
-storage must be. If you need 16 kiB for this purpose, you need to keep
-additional 32 sectors free.
-
-For this example we are reserving 300 sectors for the barebox image and
-additionaly 32 sectors for the persistant storage. So, the first partition on
-the boot media must start at sector 333 or later.
-
-Run the fdisk tool to setup such a partition table:
-
-.. code-block:: none
-
- [jb@host]~> fdisk /dev/sda
- Command (m for help): p
-
- Disk /dev/sda: 20.7 MB, 212680704 bytes
- 16 heads, 63 sectors/track, 406 cylinders
- Units = cylinders of 1008 * 512 = 516096 bytes
-
- Device Boot Start End Blocks Id System
-
-Change the used units to sectors for easier handling.
-
-.. code-block:: none
-
- Command (m for help): u
- Changing display/entry units to sectors
-
- Command (m for help): p
-
- Disk /dev/sda: 20.7 MB, 212680704 bytes
- 16 heads, 63 sectors/track, 406 cylinders, total 409248 sectors
- Units = sectors of 1 * 512 = 512 bytes
-
- Device Boot Start End Blocks Id System
-
-Now its possible to create the first partition with the required offset:
-
-.. code-block:: none
-
- Command (m for help): n
- Command action
- e extended
- p primary partition (1-4)
- p
- Partition number (1-4): 1
- First sector (63-409247, default 63): 333
- Last sector or +size or +sizeM or +sizeK (333-409247, default 409247): +18M
- Command (m for help): p
-
- Disk /dev/sda: 20.7 MB, 212680704 bytes
- 16 heads, 63 sectors/track, 406 cylinders, total 409248 sectors
- Units = sectors of 1 * 512 = 512 bytes
-
- Device Boot Start End Blocks Id System
- /dev/sda 333 35489 17578+ 83 Linux
-
-That's all. Do whatever is required now with the new partition (formatting
-and populating the root filesystem for example) to make it useful.
-
-In the next step, barebox gets installed to this boot media::
-
- [jb@host]~> scripts/setupmbr/setupmbr -s 32 -m ./barebox -d /dev/sda
-
-This command writes the barebox image file './barebox' onto the device
- /dev/sda.
-
-The -s option will keep the persistant storage sectors free and untouched
-and set flags in the MBR to forward its existance, size and location to
-barebox at runtime. setupmbr also does not change the partition table.
-
-The barebox image gets stored on the boot media like this::
-
- sector 0 1 33 333
- |---|-------------|--------------- ~~~ ------------|--------------
- MBR persistant barebox first
- storage main image partition
-
-If the -s option is omitted, the "persistant storage" part simply does
-not exist:
-
-.. code-block:: none
-
- sector 0 1 333
- |---|--------------- ~~~ ------------|--------------
- MBR barebox first
- main image partition
-
-**NOTE:** the ``setupmbr`` tool is also working on real image file than on device
-nodes only. So, there is no restriction what kind of file will be
-modified.
-
diff --git a/Documentation/devel/devel.rst b/Documentation/devel/devel.rst
index f559512ca3..f703c3bf27 100644
--- a/Documentation/devel/devel.rst
+++ b/Documentation/devel/devel.rst
@@ -8,6 +8,7 @@ Contents:
.. toctree::
:maxdepth: 2
+ porting
background-execution
* :ref:`search`
diff --git a/Documentation/devel/porting.rst b/Documentation/devel/porting.rst
new file mode 100644
index 0000000000..aa584de60c
--- /dev/null
+++ b/Documentation/devel/porting.rst
@@ -0,0 +1,509 @@
+##########################
+The barebox Porter's Guide
+##########################
+
+While barebox puts much emphasis on portability, running on bare-metal
+means that there is always machine-specific glue that needs to be provided.
+This guide shows places where the glue needs to be applied and how to go
+about porting barebox to new hardware.
+
+.. note::
+ This guide is written with mainly ARM and RISC-V barebox in mind.
+ Other architectures may differ.
+
+************
+Introduction
+************
+
+Your usual barebox binary consists of two parts. A prebootloader doing
+the bare minimum initialization and then the proper barebox binary.
+
+barebox proper
+==============
+
+This is the main part of barebox and, like a multi-platform Linux kernel,
+is platform-agnostic: The program starts, registers its drivers and tries
+to match the drivers with the devices it discovers at runtime.
+It initializes file systems and common management facilities and finally
+starts an init process. barebox knows no privilege separation and the
+init process is built into barebox.
+The default init is the :ref:`Hush`, but can be overridden if required.
+
+For such a platform-agnostic program to work, it must receive external
+input about what kind of devices are available: For example, is there a
+timer? At what address and how often does it tick? For most barebox
+architectures this hardware description is provided in the form
+of a flattened device tree (FDT). As part of barebox' initialization
+procedure, it unflattens (parses) the device tree and starts probing
+(matching) the devices described within with the drivers that are being
+registered.
+
+The device tree can also describe the RAM available in the system. As
+walking the device tree itself consumes RAM, barebox proper needs to
+be passed information about an initial memory region for use as stack
+and for dynamic allocations. When barebox has probed the memory banks,
+the whole memory will become available.
+
+As result of this design, the same barebox proper binary can be reused for
+many different boards. Unlike Linux, which can expect a bootloader to pass
+it the device tree, barebox *is* the bootloader. For this reason, barebox
+proper is prefixed with what is called a prebootloader (PBL). The PBL
+handles the low-level details that need to happen before invoking barebox
+proper.
+
+Prebootloader (PBL)
+===================
+
+The :ref:`prebootloader <pbl>` is a small chunk of code whose objective is
+to prepare the environment for barebox proper to execute. This means:
+
+ - Setting up a stack
+ - Determining a memory region for initial allocations
+ - Provide the device tree
+ - Jump to barebox proper
+
+The prebootloader often runs from a constrained medium like a small
+(tens of KiB) on-chip SRAM or sometimes even directly from flash.
+
+If the size constraints allow, the PBL will contain the barebox proper
+binary in compressed form. After ensuring any external DRAM can be
+addressed, it will unpack barebox proper there and call it with the
+necessary arguments: an initial memory region and the FDT.
+
+If this is not feasible, the PBL will contain drivers to chain load
+barebox proper from the storage medium. As this is usually the same
+storage medium the PBL itself was loaded from, shortcuts can often
+be taken: e.g. a SD-Card could already be in the correct mode, so the
+PBL driver can just read the blocks without having to reinitialize
+the SD-card.
+
+barebox images
+==============
+
+In a typical build, the barebox build process generates multiple images
+(:ref:`multi_image`). All enabled PBLs are linked with the same barebox
+proper binary and then the resulting image are processed to be in the
+format expected by the loader.
+
+The loader is often a BootROM, but maybe another first stage bootloader
+or a hardware debugger.
+
+Let us now put these new concepts into practice. We will start by adding
+a new board for a platform, for which similar boards already exist.
+Then we'll look at adding a new SoC, then a new SoC family and finally
+a new architecture.
+
+**********************
+Porting to a new board
+**********************
+
+.. note::
+ Parts of this guide are taken from this ELC-E 2020 talk:
+ https://www.youtube.com/watch?v=Oj7lKbFtyM0
+
+Chances are there's already a supported board similar to yours, e.g.
+an evaluation kit from the vendor. Take a look at ``arch/$ARCH/boards/``
+and do likewise for you board. The main steps would be:
+
+Entry point
+===========
+
+The PBL's entry point is the first of your code that's run. What happens
+there depends on the previously running code. If a previous stage has already
+set up a stack and initialized the DRAM, the only thing you need to do
+is to call the common PBL code with a memory region and your device tree blob::
+
+ ENTRY_FUNCTION(start_my_board, r0, r1, r2)
+ {
+ extern char __dtb_my_board_start[];
+ void *fdt;
+
+ relocate_to_current_adr();
+ setup_c();
+
+ pbl_set_putc(my_serial_putc, (void *)BASE_ADDR);
+
+ barebox_arm_entry(0x80000000, SZ_256M, __dtb_my_board_start);
+ }
+
+Lets look at this line by line:
+
+ - ``ENTRY_FUNCTION(start_my_board, r0, r1, r2)``
+ The entry point is special: It needs to be located at the beginning of the
+ image, it does not return and may run before a stack is set up.
+ The ``ENTRY_POINT()`` macro takes care of these details and passes along
+ a number of registers, in case the Boot ROM has placed something interesting there.
+
+ - ``extern char __dtb_my_board_start[];``
+ When a device tree is built as part of the PBL, ``__dtb_*_start`` and
+ ``__dtb_*_end`` will be defined for it. Declare the start variable, so
+ you can pass along the address of the device tree.
+
+ - ``relocate_to_current_adr();``
+ Machine code contains a mixture of relative and absolute addressing.
+ Because the PBL doesn't know in advance which address it's loaded to,
+ the link address of global variables may not be correct. To correct
+ them a runtime offset needs to be added, so they point at the
+ correct location. This procedure is called relocation and is achieved
+ by this function. Note that this is self-modifying code, so it's not
+ safe to call this when executing in-place from flash or ROM.
+
+ - ``setup_c();``
+ As a size optimization, zero-initialized variables of static storage
+ duration are not written to the executable. Instead only the region
+ where they should be located is described and at runtime that region
+ is zeroed. This is what ``setup_c()`` does.
+
+ - ``pbl_set_putc(my_serial_putc, (void *)BASE_ADDR);``
+ Now that we have a C environment set up, lets set our first global
+ variable. ``pbl_set_putc`` saves a function pointer that can be used
+ to output a single character. This can be used for the early PBL
+ console to output messages even before any drivers are initialized.
+
+ - ``barebox_arm_entry`` will compute a new stack top from the supplied memory
+ region and uncompress barebox proper and pass along its arguments.
+
+Looking at other boards you might see some different patterns:
+
+ - ``*_cpu_lowlevel_init();``: Often some common initialization and quirk handling
+ needs to be done at start. If a board similar to yours does this, you probably
+ want to do likewise.
+
+ - ``__dtb_z_my_board_start[];``: Because the PBL normally doesn't parse anything out
+ of the device tree blob, boards can benefit from keeping the device tree blob
+ compressed and only unpack it in barebox proper. Such LZO-compressed device trees
+ are prefixed with ``__dtb_z_``. It's usually a good idea to use this.
+
+ - ``imx6q_barebox_entry(...);`` Sometimes it's possible to query the memory
+ controller for the size of RAM. If there are SoC-specific helpers to achieve
+ this, you should use them.
+
+ - ``get_runtime_offset()/global_variable_offset()`` returns the difference
+ between the link and load address. This is zero after relocation, but the
+ function can be useful to pass along the correct address of a variable when
+ relocation has not yet occurred. If you need to use this for anything more
+ then passing along the FDT address, you should reconsider and probably rather
+ call ``relocate_to_current_adr();``.
+
+ - ``*_start_image(...)/*_load_image(...)/*_xload_*(...)``:
+ If the SRAM couldn't fit both PBL and the compressed barebox proper, PBL
+ will need to chainload full barebox binary from disk.
+
+Repeating previous advice: The specifics about how different SoCs handle
+things can vary widely. You're best served by mimicking a similar recently
+added board if one exists. If there's none, continue reading the following
+sections.
+
+Board code
+==========
+
+If you need board-specific setup that's not covered by any upstream device
+tree binding, you can write a driver that matches against your board's
+``/compatible``::
+
+ static int my_board_probe(struct device_d *dev)
+ {
+ /* Do some board-specific setup */
+ return 0;
+ }
+
+ static const struct of_device_id my_board_of_match[] = {
+ { .compatible = "my,cool-board" },
+ { /* sentinel */ },
+ };
+
+ static struct driver_d my_board_driver = {
+ .name = "board-mine",
+ .probe = my_board_probe,
+ .of_compatible = my_board_of_match,
+ };
+ device_platform_driver(my_board_driver);
+
+Keep what you do here to a minimum. Many thing traditionally done here
+should rather happen in the respective drivers (e.g. PHY fixups).
+
+Device-Tree
+===========
+
+barebox regularly synchronizes its ``/dts/src`` directory with the
+upstream device trees in Linux. If your device tree happens to already
+be there you can just include it::
+
+ #include <arm/stm32mp157c-odyssey.dts>
+ #include "stm32mp151.dtsi"
+
+ / {
+ chosen {
+ environment-emmc {
+ compatible = "barebox,environment";
+ device-path = &sdmmc2, "partname:barebox-environment";
+ };
+ };
+ };
+
+ &phy0 {
+ reset-gpios = <&gpiog 0 GPIO_ACTIVE_LOW>;
+ };
+
+Here, the upstream device tree is included, then a barebox-specific
+SoC device tree ``"stm32mp151.dtsi"`` customizes it. The device tree
+adds some barebox-specific info like the environment used for storing
+persistent data during development. If the upstream device tree lacks
+some info which are necessary for barebox there can be added here
+as well. Refer to :ref:`bareboxdt` for more information.
+
+Boilerplate
+===========
+
+A number of places need to be informed about the new board:
+
+ - Either ``arch/$ARCH/Kconfig`` or ``arch/$ARCH/mach-$platform/Kconfig``
+ needs to define a Kconfig symbol for the new board
+ - ``arch/$ARCH/boards/Makefile`` needs to be told which directory the board
+ code resides in
+ - ``arch/$ARCH/dts/Makefile`` needs to be told the name of the device tree
+ to be built
+ - ``images/Makefile.$platform`` needs to be told the name of the entry point(s)
+ for the board
+
+Example::
+
+ --- /dev/null
+ +++ b/arch/arm/boards/seeed-odyssey/Makefile
+ +lwl-y += lowlevel.o
+ +obj-y += board.o
+
+ --- a/arch/arm/mach-stm32mp/Kconfig
+ +++ b/arch/arm/mach-stm32mp/Kconfig
+ +config MACH_SEEED_ODYSSEY
+ + select ARCH_STM32MP157
+ + bool "Seeed Studio Odyssey"
+
+ --- a/arch/arm/boards/Makefile
+ +++ b/arch/arm/boards/Makefile
+ +obj-$(CONFIG_MACH_SEEED_ODYSSEY) += seeed-odyssey/
+
+ --- a/arch/arm/dts/Makefile
+ +++ b/arch/arm/dts/Makefile
+ +lwl-$(CONFIG_MACH_SEEED_ODYSSEY) += stm32mp157c-odyssey.dtb.o
+
+ --- a/images/Makefile.stm32mp
+ +++ b/images/Makefile.stm32mp
+ $(obj)/%.stm32: $(obj)/% FORCE
+ $(call if_changed,stm32_image)
+
+ STM32MP1_OPTS = -a 0xc0100000 -e 0xc0100000 -v1
+
+ +pblb-$(CONFIG_MACH_SEEED_ODYSSEY) += start_stm32mp157c_seeed_odyssey
+ +FILE_barebox-stm32mp157c-seeed-odyssey.img = start_stm32mp157c_seeed_odyssey.pblb.stm32
+ +OPTS_start_stm32mp157c_seeed_odyssey.pblb.stm32 = $(STM32MP1_OPTS)
+ +image-$(CONFIG_MACH_SEEED_ODYSSEY) += barebox-stm32mp157c-seeed-odyssey.img
+
+********************
+Porting to a new SoC
+********************
+
+So, barebox supports the SoC's family, but not this particular SoC.
+For example, the new fancy network controller is lacking support.
+
+.. note::
+ If your new SoC requires early boot drivers, like e.g. memory
+ controller setup. Refer to the next section.
+
+Often drivers can be ported from other projects. Candidates are
+the Linux kernel, the bootloader maintained by the vendor or other
+projects like Das U-Boot, Zephyr or EDK.
+
+Porting from Linux is often straight-forward, because barebox
+imports many facilities from Linux. A key difference is that
+barebox does not utilize interrupts, so kernel code employing them
+needs to be modified into polling for status change instead.
+In this case, porting from U-Boot may be easier if a driver already
+exists. Usually, ported drivers will be a mixture of both if they're
+not written from scratch.
+
+Drivers should probe from device tree and use the same bindings
+like the Linux kernel. If there's no upstream binding, the barebox
+binding should be documented and prefixed with ``barebox,``.
+
+Considerations when writing Linux drivers also apply to barebox:
+
+ * Avoid use of ``#ifdef HARDWARE``. Multi-image code should detect at
+ runtime what hardware it is, preferably through the device tree
+
+ * Don't use ``__weak`` symbols for ad-hoc plugging in of code. They
+ make code harder to reason about and clash with multi-image.
+
+ * Write drivers so they can be instantiated more than once
+
+ * Modularize. Describe inter-driver dependency in the device tree
+
+Miscellaneous Linux porting advice:
+
+ * Branches dependent on ``system_state``: Take the ``SYSTEM_BOOTING`` branch
+ * ``struct clk_hw``: rename to ``struct clk``
+ * ``struct of_clk_hw_simple_get``: rename to ``struct of_clk_src_simple_get``
+ * ``usleep`` and co.: use ``[mud]elay``
+ * ``.of_node``: use ``.device_node``
+ * ``jiffies``: use ``get_time_ns()``
+ * ``time_before``: use ``!is_timeout()``
+ * ``clk_hw_register_fixed_rate_with_accuracy``: use ``clk_register_fixed_rate`` without accuracy
+ * ``CLK_SET_RATE_GATE`` can be ignored
+ * ``clk_prepare``: is for the non-atomic code preparing for clk enablement. Merge it into ``clk_enable``
+
+***************************
+Porting to a new SoC family
+***************************
+
+Extending support to a new SoC family can involve a number of things:
+
+New header format
+=================
+
+Your loader may require a specific header or format. If the header is meant
+to be executable, it should preferably be added as inline assembly to
+the start of the PBL entry points. See ``__barebox_arm_head`` and
+``__barebox_riscv_header``. Otherwise, add a new tool to ``scripts/``
+and have it run as part the image build process. ``images/`` contains
+various examples.
+
+Memory controller setup
+=======================
+
+If you've an external DRAM controller, you will need to configure it.
+This may involve enabling clocks and PLLs. This should all happen
+in the PBL entry point.
+
+Chainloading
+============
+
+If the whole barebox image couldn't be loaded initially due to size
+constraints, the prebootloader must arrange for chainloading the full
+barebox image.
+
+One good way to go about it is to check whether the program counter
+is in DRAM or SRAM. If in DRAM, we can assume that the image was loaded
+in full and we can just go into the common PBL entry and extract barebox
+proper. If in SRAM, we'll need to load the remainder from the boot medium.
+
+This loading requires the PBL to have a driver for the boot medium as
+well as its prerequisites like clocks, resets or pin multiplexers.
+
+Examples for this are the i.MX xload functions. Some BootROMs boot from
+a FAT file system. There is vfat support in the PBL. Refer to the sama5d2
+baord support for an example.
+
+Core drivers
+============
+
+barebox contains some stop-gap alternatives that can be used before
+dedicated drivers are available:
+
+ * Clocksource: barebox often needs to delay for a specific time.
+ ``CLOCKSOURCE_DUMMY_RATE`` can be used as a stop-gap solution
+ during initial bring up.
+
+ * Console driver: serial output is very useful for debugging. Stop-gap
+ solution can be ``DEBUG_LL`` console
+
+*****************************
+Porting to a new architecture
+*****************************
+
+Makefile
+========
+
+``arch/$ARCH/Makefile`` defines how barebox is built for the
+architecture. Among other things, it configures which compiler
+and linker flags to use and which directories Kbuild should
+descend into.
+
+Kconfig
+=======
+
+``arch/$ARCH/Kconfig`` defines the architecture's main Kconfig symbol,
+the supported subarchitectures as well as other architecture specific
+options. New architectures should select ``OFTREE`` and ``OFDEVICE``
+as well as ``HAVE_PBL_IMAGE`` and ``HAVE_PBL_MULTI_IMAGES``.
+
+Header files
+============
+
+Your architecture needs to implement following headers:
+
+ - ``<asm/bitops.h>``
+ Defines optimized bit operations if available
+ - ``<asm/bitsperlong.h>``
+ ``sizeof(long)`` Should be the size of your pointer
+ - ``<asm/byteorder.h>``
+ If the compiler defines a macro to indicate endianness,
+ use it here.
+ - ``<asm/elf.h>``
+ If using ELF relocation entries
+ - ``<asm/dma.h>``
+ Only if ``HAS_DMA`` is selected by the architecture.
+ - ``<asm/io.h>``
+ Defines I/O memory and port accessors
+ - ``<asm/mmu.h>``
+ - ``<asm/string.h>``
+ - ``<asm/swab.h>``
+ - ``<asm/types.h>``
+ - ``<asm/unaligned.h>``
+ Defines accessors for unaligned access
+ - ``<asm/setjmp.h>``
+ Must define ``setjmp``, ``longjmp`` and ``initjmp``.
+ ``setjmp`` and ``longjmp`` can be taken out of libc. As barebox
+ does no floating point operations, saving/restoring these
+ registers can be dropped. ``initjmp`` is like ``setjmp``, but
+ only needs to store 2 values in the ``jmpbuf``:
+ new stack top and address ``longjmp`` should branch to
+
+Most of these headers can be implemented by referring to the
+respective ``<asm-generic/*.h>`` versions.
+
+Relocation
+==========
+
+Because there might be no single memory region that works for all
+images in a multi-image build, barebox needs to be relocatable.
+This can be done by implementing three functions:
+
+ - ``get_runtime_offset()``: This function should return the
+ difference between the link and load address. One easy way
+ to implement this is to force the link address to ``0`` and to
+ determine the load address of the barebox ``_text`` section.
+
+ - ``relocate_to_current_adr()``: This function walks through
+ the relocation entries and fixes them up by the runtime
+ offset. After this is done ``get_runtime_offset()`` should
+ return `0` as ``_text`` should also be fixed up by it.
+
+ - ``relocate_to_adr()``: This function copies the running barebox
+ to a new location in RAM, then does ``relocate_to_current_adr()``
+ and resumes execution at the new location. This can be omitted
+ if barebox won't initially execute out of ROM.
+
+Of course, for these functions to work. The linker script needs
+to ensure that the ELF relocation records are included in the
+final image and define start and end markers so code can iterate
+over them.
+
+To ease debugging, even when relocation has no yet happened,
+barebox supports ``DEBUG_LL``, which acts similarly to the
+PBL console, but does not require relocation. This is incompatible
+with multi-image, function mso this should only be considered while debugging.
+
+Linker scripts
+==============
+
+You'll need two linker scripts, one for barebox proper and the
+other for the PBL. Refer to the ARM and/or RISC-V linker scripts
+for an example.
+
+Generic DT image
+================
+
+It's a good idea to have the architecture generate an image that
+looks like and can be booted just like a Linux kernel. This allows
+easy testing with QEMU or booting from barebox or other bootloaders.
+Refer to ``BOARD_GENERIC_DT`` for examples.
diff --git a/Documentation/devicetree/index.rst b/Documentation/devicetree/index.rst
index ce62ebe109..198c4893ff 100644
--- a/Documentation/devicetree/index.rst
+++ b/Documentation/devicetree/index.rst
@@ -1,3 +1,5 @@
+.. _bareboxdt:
+
Barebox devicetree handling and bindings
========================================
diff --git a/Documentation/user/pbl.rst b/Documentation/user/pbl.rst
index 6757768e42..f9b2d20305 100644
--- a/Documentation/user/pbl.rst
+++ b/Documentation/user/pbl.rst
@@ -26,6 +26,6 @@ This way source code can be shared between regular barebox and PBL. A special
case is ``lwl-y += file.o`` which expands to ``obj-y`` when PBL is disabled
and to ``pbl-y`` when PBL is enabled.
-**HINT:** for getting an overview over the binaries, disassemble barebox.bin
-(``make barebox.S``) with or without PBL support and also disassemble the
-PBL (``make arch/$ARCH/pbl/zbarebox.S``)
+**HINT:** for getting an overview over the binaries, disassemble
+``barebox.bin`` with or without PBL support and also disassemble the PBL
+(``./images/*.pblb``).
diff --git a/Documentation/user/reboot-mode.rst b/Documentation/user/reboot-mode.rst
index 9321d928f4..8717e39342 100644
--- a/Documentation/user/reboot-mode.rst
+++ b/Documentation/user/reboot-mode.rst
@@ -1,7 +1,8 @@
.. _reboot_mode:
+###########
Reboot Mode
------------
+###########
To simplify debugging, many BootROMs sample registers that survive
a warm reset to customize the boot. These registers can e.g. indicate
@@ -23,7 +24,7 @@ modes in the device tree. If a match is found the associated magic
is written to the location referenced in the device tree node.
User API
-~~~~~~~~
+========
Devices registered with the reboot mode API gain two parameters:
@@ -46,7 +47,7 @@ priority has its parameters aliased as ``$global.system.reboot_mode.prev``
and ``$global.system.reboot_mode.next``.
Reset
-~~~~~
+=====
Reboot modes can be stored on a syscon wrapping general purpose registers
that survives warm resets. If the system instead did reset via an external
@@ -57,7 +58,7 @@ reset provider. In barebox, multiple reset providers may co-exist. They
``reset`` command allows listing and choosing a specific reboot mode.
Disambiguation
-~~~~~~~~~~~~~~
+==============
Some uses of reboot modes partially overlap with other barebox
functionality. They all ultimately serve different purposes, however.
diff --git a/Documentation/user/system-reset.rst b/Documentation/user/system-reset.rst
index e76e3a23c1..bf7369d06f 100644
--- a/Documentation/user/system-reset.rst
+++ b/Documentation/user/system-reset.rst
@@ -31,7 +31,7 @@ But there are some drawbacks within this simple approach.
* some SoC's boot behaviour gets parametrized by so called 'bootstrap pins'.
These pins can have a different meaning at reset time and at run-time later
on (multi purpose pins) but their correct values at reset time are very
- important to boot the SoC sucessfully. If external devices are connected to
+ important to boot the SoC successfully. If external devices are connected to
these multi purpose pins they can disturb the reset values, and so parametrizing
the boot behaviour differently and hence crashing the SoC until the next real
POR happens which also resets the external devices (and keep them away from the
diff --git a/Documentation/user/user-manual.rst b/Documentation/user/user-manual.rst
index c80bfbf263..565e6c11f8 100644
--- a/Documentation/user/user-manual.rst
+++ b/Documentation/user/user-manual.rst
@@ -36,6 +36,7 @@ Contents:
optee
debugging
watchdog
+ reboot-mode
virtio
* :ref:`search`
diff --git a/Makefile b/Makefile
index 6d78d1f58e..db1690bace 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
VERSION = 2021
-PATCHLEVEL = 03
+PATCHLEVEL = 04
SUBLEVEL = 0
EXTRAVERSION =
NAME = None
@@ -350,6 +350,8 @@ endif
KCONFIG_CONFIG ?= .config
+export KCONFIG_CONFIG
+
# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
export KBUILD_DEFCONFIG := defconfig
@@ -650,6 +652,9 @@ CHECKFLAGS += $(NOSTDINC_FLAGS)
# warn about C99 declaration after statement
KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
+# warn about e.g. (unsigned)x < 0
+KBUILD_CFLAGS += $(call cc-option,-Wtype-limits)
+
# disable pointer signed / unsigned warnings in gcc 4.0
KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
@@ -891,33 +896,6 @@ quiet_cmd_barebox_mkimage = MKIMAGE $@
barebox.uimage: $(KBUILD_BINARY) FORCE
$(call if_changed,barebox_mkimage)
-ifdef CONFIG_X86
-barebox.S barebox.s: barebox
-ifdef CONFIG_X86_HDBOOT
- @echo "-------------------------------------------------" > barebox.S
- @echo " * MBR content" >> barebox.S
- $(Q)$(OBJDUMP) -j .bootsector -mi8086 -d barebox >> barebox.S
- @echo "-------------------------------------------------" >> barebox.S
- @echo " * Boot loader content" >> barebox.S
- $(Q)$(OBJDUMP) -j .bootstrapping -mi8086 -d barebox >> barebox.S
-endif
- @echo "-------------------------------------------------" >> barebox.S
- @echo " * Regular Text content" >> barebox.S
- $(Q)$(OBJDUMP) -j .text -d barebox >> barebox.S
- @echo "-------------------------------------------------" >> barebox.S
- @echo " * Regular Data content" >> barebox.S
- $(Q)$(OBJDUMP) -j .data -d barebox >> barebox.S
- @echo "-------------------------------------------------" >> barebox.S
- @echo " * Commands content" >> barebox.S
- $(Q)$(OBJDUMP) -j .barebox_cmd -d barebox >> barebox.S
- @echo "-------------------------------------------------" >> barebox.S
- @echo " * Init Calls content" >> barebox.S
- $(Q)$(OBJDUMP) -j .barebox_initcalls -d barebox >> barebox.S
-else
-barebox.S barebox.s: barebox FORCE
- $(call if_changed,disasm)
-endif
-
# barebox image
barebox: $(BAREBOX_LDS) $(BAREBOX_OBJS) $(kallsyms.o) FORCE
$(call if_changed_rule,barebox__)
@@ -1119,7 +1097,7 @@ endif # CONFIG_MODULES
# Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += barebox System.map include/generated/barebox_default_env.h \
- .tmp_version .tmp_barebox* barebox.bin barebox.map barebox.S \
+ .tmp_version .tmp_barebox* barebox.bin barebox.map \
.tmp_kallsyms* barebox.ldr compile_commands.json \
scripts/bareboxenv-target barebox-flash-image \
barebox.srec barebox.s5p barebox.ubl barebox.zynq \
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 9ccb75e27b..1441264dfa 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -63,6 +63,7 @@ obj-$(CONFIG_MACH_HABA_KNX_LITE) += haba-knx/
obj-$(CONFIG_MACH_IMX21ADS) += freescale-mx21-ads/
obj-$(CONFIG_MACH_IMX233_OLINUXINO) += imx233-olinuxino/
obj-$(CONFIG_MACH_IMX27ADS) += freescale-mx27-ads/
+obj-$(CONFIG_MACH_KAMSTRUP_MX7_CONCENTRATOR) += kamstrup-mx7-concentrator/
obj-$(CONFIG_MACH_KINDLE3) += kindle3/
obj-$(CONFIG_MACH_KONTRON_SAMX6I) += kontron-samx6i/
obj-$(CONFIG_MACH_LENOVO_IX4_300D) += lenovo-ix4-300d/
@@ -114,6 +115,7 @@ obj-$(CONFIG_MACH_RPI_COMMON) += raspberry-pi/
obj-$(CONFIG_MACH_SABRELITE) += freescale-mx6-sabrelite/
obj-$(CONFIG_MACH_SABRESD) += freescale-mx6-sabresd/
obj-$(CONFIG_MACH_AC_SXB) += ac-sxb/
+obj-$(CONFIG_MACH_SKOV_IMX6) += skov-imx6/
obj-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += freescale-mx6sx-sabresdb/
obj-$(CONFIG_MACH_SAMA5D27_GIANTBOARD) += sama5d27-giantboard/
obj-$(CONFIG_MACH_SAMA5D27_SOM1) += sama5d27-som1/
@@ -178,3 +180,4 @@ obj-$(CONFIG_MACH_WAGO_PFC_AM35XX) += wago-pfc-am35xx/
obj-$(CONFIG_MACH_LS1046ARDB) += ls1046ardb/
obj-$(CONFIG_MACH_TQMLS1046A) += tqmls1046a/
obj-$(CONFIG_MACH_MNT_REFORM) += mnt-reform/
+obj-$(CONFIG_MACH_SKOV_ARM9CPU) += skov-arm9cpu/
diff --git a/arch/arm/boards/kamstrup-mx7-concentrator/Makefile b/arch/arm/boards/kamstrup-mx7-concentrator/Makefile
new file mode 100644
index 0000000000..7ab9f52747
--- /dev/null
+++ b/arch/arm/boards/kamstrup-mx7-concentrator/Makefile
@@ -0,0 +1 @@
+lwl-y += lowlevel.o \ No newline at end of file
diff --git a/arch/arm/boards/kamstrup-mx7-concentrator/flash-header-tqma7d.imxcfg b/arch/arm/boards/kamstrup-mx7-concentrator/flash-header-tqma7d.imxcfg
new file mode 100644
index 0000000000..4b36324110
--- /dev/null
+++ b/arch/arm/boards/kamstrup-mx7-concentrator/flash-header-tqma7d.imxcfg
@@ -0,0 +1,79 @@
+soc imx7
+loadaddr 0xbfbff000
+ivtofs 0x400
+
+#include <mach/imx7-ddr-regs.h>
+
+wm 32 0x30340004 0x4F400005 /* IOMUXC_GPR_GPR1 */
+/* Clear then set bit30 to ensure exit from DDR retention */
+wm 32 0x30360388 0x40000000
+wm 32 0x30360384 0x40000000
+
+/* TQMa7x DRAM Timing REV0100 */
+/* DCD Code i.MX7D/S 528 MHz 1 GByte Samsung K4B4G1646D */
+wm 32 0x30360070 0x0070302C /* CCM_ANALOG_PLL_DDRx */
+wm 32 0x30360090 0x00000000 /* CCM_ANALOG_PLL_NUM */
+wm 32 0x30360070 0x0060302C /* CCM_ANALOG_PLL_DDRx */
+check 32 until_all_bits_set 0x30360070 0x80000000
+wm 32 0x30391000 0x00000002 /* SRC_DDRC_RCR */
+
+wm 32 MX7_DDRC_MSTR 0x01040001
+wm 32 MX7_DDRC_DFIUPD0 0x80400003
+wm 32 MX7_DDRC_DFIUPD1 0x00100020
+wm 32 MX7_DDRC_DFIUPD2 0x80100004
+wm 32 MX7_DDRC_RFSHTMG 0x00200045
+wm 32 MX7_DDRC_MP_PCTRL_0 0x00000001
+wm 32 MX7_DDRC_INIT0 0x00020081
+wm 32 MX7_DDRC_INIT1 0x00680000
+wm 32 MX7_DDRC_INIT3 0x09300004
+wm 32 MX7_DDRC_INIT4 0x00480000
+wm 32 MX7_DDRC_INIT5 0x00100004
+wm 32 MX7_DDRC_RANKCTL 0x0000033F
+wm 32 MX7_DDRC_DRAMTMG0 0x090E0809
+wm 32 MX7_DDRC_DRAMTMG1 0x0007020E
+wm 32 MX7_DDRC_DRAMTMG2 0x03040407
+wm 32 MX7_DDRC_DRAMTMG3 0x00002006
+wm 32 MX7_DDRC_DRAMTMG4 0x04020304
+wm 32 MX7_DDRC_DRAMTMG5 0x03030202
+wm 32 MX7_DDRC_DRAMTMG8 0x00000803
+wm 32 MX7_DDRC_ZQCTL0 0x00800020
+wm 32 MX7_DDRC_DFITMG0 0x02098204
+wm 32 MX7_DDRC_DFITMG1 0x00030303
+wm 32 MX7_DDRC_ADDRMAP0 0x00000016
+wm 32 MX7_DDRC_ADDRMAP1 0x00171717
+wm 32 MX7_DDRC_ADDRMAP4 0x00000F0F
+wm 32 MX7_DDRC_ADDRMAP5 0x04040404
+wm 32 MX7_DDRC_ADDRMAP6 0x0F040404
+wm 32 MX7_DDRC_ODTCFG 0x06000604
+wm 32 MX7_DDRC_ODTMAP 0x00000001
+wm 32 0x30391000 0x00000000 /* SRC_DDRC_RCR */
+wm 32 MX7_DDR_PHY_PHY_CON0 0x17420F40
+wm 32 MX7_DDR_PHY_PHY_CON1 0x10210100
+wm 32 MX7_DDR_PHY_PHY_CON4 0x00060807
+wm 32 MX7_DDR_PHY_MDLL_CON0 0x1010007E
+wm 32 MX7_DDR_PHY_DRVDS_CON0 0x00000924
+/* DDR_PHY_CMD_DESKEW_CON0 not set */
+/* DDR_PHY_CMD_DESKEW_CON1 not set */
+/* DDR_PHY_CMD_DESKEW_CON2 not set */
+/* DDR_PHY_CMD_DESKEW_CON3 not set */
+/* DDR_PHY_LVL_CON0 not set */
+wm 32 MX7_DDR_PHY_OFFSET_RD_CON0 0x0B0B0B0B
+wm 32 MX7_DDR_PHY_OFFSET_WR_CON0 0x06060606
+wm 32 MX7_DDR_PHY_CMD_SDLL_CON0 0x01000010
+wm 32 MX7_DDR_PHY_CMD_SDLL_CON0 0x00000010
+
+wm 32 MX7_DDR_PHY_ZQ_CON0 0x0C407304
+wm 32 MX7_DDR_PHY_ZQ_CON0 0x0C447304
+wm 32 MX7_DDR_PHY_ZQ_CON0 0x0C447306
+check 32 until_all_bits_set MX7_DDR_PHY_ZQ_CON1 0x1 /* ZQ Calibration is finished */
+wm 32 MX7_DDR_PHY_ZQ_CON0 0x0C447304
+wm 32 MX7_DDR_PHY_ZQ_CON0 0x0C407304
+
+wm 32 0x30384130 0x00000000 /* CCM_CCGRn */
+wm 32 0x30340020 0x00000178 /* IOMUXC_GPR_GPR8 */
+wm 32 0x30384130 0x00000002 /* CCM_CCGRn */
+wm 32 0x30790018 0x0000000f /* DDR_PHY_LP_CON0 */
+
+/* DDRC_STAT */
+check 32 until_all_bits_set 0x307a0004 0x1
+
diff --git a/arch/arm/boards/kamstrup-mx7-concentrator/lowlevel.c b/arch/arm/boards/kamstrup-mx7-concentrator/lowlevel.c
new file mode 100644
index 0000000000..8cd6d67f7e
--- /dev/null
+++ b/arch/arm/boards/kamstrup-mx7-concentrator/lowlevel.c
@@ -0,0 +1,35 @@
+#include <debug_ll.h>
+#include <io.h>
+#include <common.h>
+#include <linux/sizes.h>
+#include <mach/generic.h>
+#include <asm/barebox-arm-head.h>
+#include <asm/barebox-arm.h>
+#include <mach/imx7-ccm-regs.h>
+#include <mach/iomux-mx7.h>
+#include <mach/debug_ll.h>
+#include <asm/cache.h>
+#include <mach/esdctl.h>
+
+extern char __dtb_z_imx7d_flex_concentrator_mfg_start[];
+
+static inline void setup_uart(void)
+{
+ imx7_early_setup_uart_clock();
+
+ imx7_setup_pad(MX7D_PAD_SAI2_TX_BCLK__UART4_DCE_TX);
+
+ imx7_uart_setup_ll();
+
+ putc_ll('>');
+}
+
+ENTRY_FUNCTION(start_kamstrup_mx7_concentrator, r0, r1, r2)
+{
+ imx7_cpu_lowlevel_init();
+
+ if (IS_ENABLED(CONFIG_DEBUG_LL))
+ setup_uart();
+
+ imx7d_barebox_entry(__dtb_z_imx7d_flex_concentrator_mfg_start + get_runtime_offset());
+}
diff --git a/arch/arm/boards/skov-arm9cpu/Makefile b/arch/arm/boards/skov-arm9cpu/Makefile
new file mode 100644
index 0000000000..01c7a259e9
--- /dev/null
+++ b/arch/arm/boards/skov-arm9cpu/Makefile
@@ -0,0 +1,2 @@
+obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/skov-arm9cpu/board.c b/arch/arm/boards/skov-arm9cpu/board.c
new file mode 100644
index 0000000000..8d5eadbb9a
--- /dev/null
+++ b/arch/arm/boards/skov-arm9cpu/board.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0+
+// SPDX-FileCopyrightText: 2017 Sam Ravnborg <sam@ravnborg.org>
+
+#include <common.h>
+#include <globalvar.h>
+#include <magicvar.h>
+#include <envfs.h>
+#include <init.h>
+#include <gpio.h>
+
+#include <linux/sizes.h>
+
+#include <mach/at91sam9263_matrix.h>
+#include <mach/at91sam9_sdramc.h>
+#include <mach/at91sam9_smc.h>
+#include <mach/hardware.h>
+#include <mach/iomux.h>
+
+static struct sam9_smc_config ek_nand_smc_config = {
+ .ncs_read_setup = 0,
+ .nrd_setup = 1,
+ .ncs_write_setup = 0,
+ .nwe_setup = 1,
+
+ .ncs_read_pulse = 3,
+ .nrd_pulse = 3,
+ .ncs_write_pulse = 3,
+ .nwe_pulse = 3,
+
+ .read_cycle = 5,
+ .write_cycle = 5,
+
+ .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
+ AT91_SMC_EXNWMODE_DISABLE,
+ .tdf_cycles = 2,
+};
+
+BAREBOX_MAGICVAR(board.mem, "The detected memory size in MiB");
+
+static int mem;
+
+/*
+ * Initialize of SMC must come after we
+ * probe the at91sam9_smc_driver.
+ * But is required before we start the other drives.
+ * Use device_initcall() to maintain this order.
+ */
+static int skov_arm9_probe(struct device_d *dev)
+{
+ unsigned long csa;
+
+ add_generic_device("at91sam9-smc", 0, NULL, AT91SAM9263_BASE_SMC0, 0x200,
+ IORESOURCE_MEM, NULL);
+ add_generic_device("at91sam9-smc", 1, NULL, AT91SAM9263_BASE_SMC1, 0x200,
+ IORESOURCE_MEM, NULL);
+
+ csa = readl(AT91SAM9263_BASE_MATRIX + AT91SAM9263_MATRIX_EBI0CSA);
+ csa |= AT91SAM9263_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA;
+ writel(csa, AT91SAM9263_BASE_MATRIX + AT91SAM9263_MATRIX_EBI0CSA);
+
+ /* configure chip-select 3 (NAND) */
+ sam9_smc_configure(0, 3, &ek_nand_smc_config);
+
+ mem = at91_get_sdram_size(IOMEM(AT91SAM9263_BASE_SDRAMC0));
+ mem = mem / SZ_1M;
+ globalvar_add_simple_int("board.mem", &mem, "%u");
+
+ return 0;
+}
+
+static __maybe_unused struct of_device_id skov_arm9_ids[] = {
+ {
+ .compatible = "skov,arm9-cpu",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d skov_arm9_driver = {
+ .name = "skov-arm9",
+ .probe = skov_arm9_probe,
+ .of_compatible = DRV_OF_COMPAT(skov_arm9_ids),
+};
+device_platform_driver(skov_arm9_driver);
diff --git a/arch/arm/boards/skov-arm9cpu/lowlevel.c b/arch/arm/boards/skov-arm9cpu/lowlevel.c
new file mode 100644
index 0000000000..d335953a73
--- /dev/null
+++ b/arch/arm/boards/skov-arm9cpu/lowlevel.c
@@ -0,0 +1,127 @@
+// SPDX-License-Identifier: GPL-2.0
+// PDX-FileCopyrightText: 2018 Sam Ravnborg <sam@ravnborg.org>
+
+#include <linux/sizes.h>
+
+#include <asm/barebox-arm.h>
+
+#include <mach/at91sam926x_board_init.h>
+#include <mach/at91sam9263_matrix.h>
+
+#define MASTER_PLL_MUL 171
+#define MASTER_PLL_DIV 14
+
+static void __bare_init skovarm9cpu_board_config(struct at91sam926x_board_cfg *cfg)
+{
+ /* Disable Watchdog */
+ cfg->wdt_mr =
+ AT91_WDT_WDIDLEHLT | AT91_WDT_WDDBGHLT |
+ AT91_WDT_WDV |
+ AT91_WDT_WDDIS |
+ AT91_WDT_WDD;
+
+ /* define PDC[31:16] as DATA[31:16] */
+ cfg->ebi_pio_pdr = 0xFFFF0000;
+ /* no pull-up for D[31:16] */
+ cfg->ebi_pio_ppudr = 0xFFFF0000;
+ /* EBI0_CSA, CS1 SDRAM, CS3 NAND Flash, 3.3V memories */
+ cfg->ebi_csa =
+ AT91SAM9263_MATRIX_EBI0_DBPUC | AT91SAM9263_MATRIX_EBI0_VDDIOMSEL_3_3V |
+ AT91SAM9263_MATRIX_EBI0_CS1A_SDRAMC;
+
+ cfg->smc_cs = 0;
+ cfg->smc_mode =
+ AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
+ AT91_SMC_DBW_16 |
+ AT91_SMC_TDFMODE |
+ AT91_SMC_TDF_(6);
+ cfg->smc_cycle =
+ AT91_SMC_NWECYCLE_(22) | AT91_SMC_NRDCYCLE_(22);
+ cfg->smc_pulse =
+ AT91_SMC_NWEPULSE_(11) | AT91_SMC_NCS_WRPULSE_(11) |
+ AT91_SMC_NRDPULSE_(11) | AT91_SMC_NCS_RDPULSE_(11);
+ cfg->smc_setup =
+ AT91_SMC_NWESETUP_(10) | AT91_SMC_NCS_WRSETUP_(10) |
+ AT91_SMC_NRDSETUP_(10) | AT91_SMC_NCS_RDSETUP_(10);
+
+ cfg->pmc_mor =
+ AT91_PMC_MOSCEN |
+ (255 << 8); /* Main Oscillator Start-up Time */
+ cfg->pmc_pllar =
+ AT91_PMC_PLLA_WR_ERRATA | /* Bit 29 must be 1 when prog */
+ AT91_PMC_OUT |
+ AT91_PMC_PLLCOUNT | /* PLL Counter */
+ (2 << 28) | /* PLL Clock Frequency Range */
+ ((MASTER_PLL_MUL - 1) << 16) | (MASTER_PLL_DIV);
+ /* PCK/2 = MCK Master Clock from PLLA */
+ cfg->pmc_mckr1 =
+ AT91_PMC_CSS_SLOW |
+ AT91_PMC_PRES_1 |
+ AT91SAM9_PMC_MDIV_2 |
+ AT91_PMC_PDIV_1;
+ /* PCK/2 = MCK Master Clock from PLLA */
+ cfg->pmc_mckr2 =
+ AT91_PMC_CSS_PLLA |
+ AT91_PMC_PRES_1 |
+ AT91SAM9_PMC_MDIV_2 |
+ AT91_PMC_PDIV_1;
+
+ /* SDRAM */
+ /* SDRAMC_TR - Refresh Timer register */
+ cfg->sdrc_tr1 = 0x13C;
+ /* SDRAMC_CR - Configuration register*/
+ cfg->sdrc_cr =
+ AT91_SDRAMC_NC_10 | /* Assume 128MiB */
+ AT91_SDRAMC_NR_13 |
+ AT91_SDRAMC_NB_4 |
+ AT91_SDRAMC_CAS_3 |
+ AT91_SDRAMC_DBW_32 |
+ (1 << 8) | /* Write Recovery Delay */
+ (7 << 12) | /* Row Cycle Delay */
+ (2 << 16) | /* Row Precharge Delay */
+ (2 << 20) | /* Row to Column Delay */
+ (5 << 24) | /* Active to Precharge Delay */
+ (1 << 28); /* Exit Self Refresh to Active Delay */
+
+ /* Memory Device Register -> SDRAM */
+ cfg->sdrc_mdr = AT91_SDRAMC_MD_SDRAM;
+ /* SDRAM_TR */
+ cfg->sdrc_tr2 = 1200;
+
+ /* user reset enable */
+ cfg->rstc_rmr =
+ AT91_RSTC_KEY |
+ AT91_RSTC_PROCRST |
+ AT91_RSTC_RSTTYP_WAKEUP |
+ AT91_RSTC_RSTTYP_WATCHDOG;
+}
+
+static void __bare_init skov_arm9cpu_init(void *fdt)
+{
+ struct at91sam926x_board_cfg cfg;
+
+ cfg.pio = IOMEM(AT91SAM9263_BASE_PIOD);
+ cfg.sdramc = IOMEM(AT91SAM9263_BASE_SDRAMC0);
+ cfg.ebi_pio_is_peripha = true;
+ cfg.matrix_csa = IOMEM(AT91SAM9263_BASE_MATRIX + AT91SAM9263_MATRIX_EBI0CSA);
+
+ skovarm9cpu_board_config(&cfg);
+ at91sam9263_board_init(&cfg);
+
+ barebox_arm_entry(AT91_CHIPSELECT_1, at91_get_sdram_size(cfg.sdramc),
+ fdt);
+}
+
+extern char __dtb_at91_skov_arm9cpu_start[];
+
+ENTRY_FUNCTION(start_skov_arm9cpu, r0, r1, r2)
+{
+ void *fdt;
+
+ arm_cpu_lowlevel_init();
+
+ arm_setup_stack(AT91SAM9263_SRAM0_BASE + AT91SAM9263_SRAM0_SIZE);
+ fdt = __dtb_at91_skov_arm9cpu_start + get_runtime_offset();
+
+ skov_arm9cpu_init(fdt);
+}
diff --git a/arch/arm/boards/skov-imx6/Makefile b/arch/arm/boards/skov-imx6/Makefile
new file mode 100644
index 0000000000..a5e85bc1e1
--- /dev/null
+++ b/arch/arm/boards/skov-imx6/Makefile
@@ -0,0 +1,3 @@
+obj-y += board.o
+lwl-y += lowlevel.o
+obj-pbl-y += version.o
diff --git a/arch/arm/boards/skov-imx6/board.c b/arch/arm/boards/skov-imx6/board.c
new file mode 100644
index 0000000000..a58172b2b1
--- /dev/null
+++ b/arch/arm/boards/skov-imx6/board.c
@@ -0,0 +1,528 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#define pr_fmt(fmt) "skov-imx6: " fmt
+
+#include <common.h>
+#include <init.h>
+#include <mach/bbu.h>
+#include <environment.h>
+#include <bootsource.h>
+#include <globalvar.h>
+#include <net.h>
+#include <of_gpio.h>
+#include <gpio.h>
+
+#include "version.h"
+
+static int eth_of_fixup_node(struct device_node *root, const char *node_path,
+ const u8 *ethaddr)
+{
+ struct device_node *node;
+ int ret;
+
+ if (!is_valid_ether_addr(ethaddr)) {
+ unsigned char ethaddr_str[sizeof("xx:xx:xx:xx:xx:xx")];
+
+ ethaddr_to_string(ethaddr, ethaddr_str);
+ pr_err("The mac-address %s is invalid.\n", ethaddr_str);
+ return -EINVAL;
+ }
+
+ node = of_find_node_by_path_from(root, node_path);
+ if (!node) {
+ pr_err("Did not find node %s to fix up with stored mac-address.\n",
+ node_path);
+ return -ENOENT;
+ }
+
+ ret = of_set_property(node, "mac-address", ethaddr, ETH_ALEN, 1);
+ if (ret)
+ pr_err("Setting mac-address property of %s failed with: %s.\n",
+ node->full_name, strerror(-ret));
+
+ return ret;
+}
+
+static int eth_of_fixup_node_from_eth_device(struct device_node *root,
+ const char *node_path,
+ const char *ethname)
+{
+ struct eth_device *edev;
+
+ edev = eth_get_byname(ethname);
+ if (!edev) {
+ pr_err("Did not find eth device \"%s\" to copy mac-address from.\n", ethname);
+ return -ENOENT;
+ }
+
+ return eth_of_fixup_node(root, node_path, edev->ethaddr);
+}
+
+static int get_mac_address_from_env_variable(const char *env, u8 ethaddr[ETH_ALEN])
+{
+ const char *ethaddr_str;
+ int ret;
+
+ ethaddr_str = getenv(env);
+ if (!ethaddr_str) {
+ pr_err("State variable %s storing the mac-address not found.\n", env);
+ return -ENOENT;
+ }
+
+ ret = string_to_ethaddr(ethaddr_str, ethaddr);
+ if (ret < 0) {
+ pr_err("Could not convert \"%s\" in state variable %s into mac-address.\n",
+ ethaddr_str, env);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int get_default_mac_address_from_state_node(const char *state_node_path,
+ u8 ethaddr[ETH_ALEN])
+{
+ struct device_node *node;
+ int ret;
+
+ node = of_find_node_by_path(state_node_path);
+ if (!node) {
+ pr_err("Node %s defining the state variable not found.\n", state_node_path);
+ return -ENOENT;
+ }
+
+ ret = of_property_read_u8_array(node, "default", ethaddr, ETH_ALEN);
+ if (ret) {
+ pr_err("Node %s has no property \"default\" of proper type.\n", state_node_path);
+ return -ENOENT;
+ }
+
+ return 0;
+}
+
+static int eth2_of_fixup_node_individually(struct device_node *root,
+ const char *node_path,
+ const char *ethname,
+ const char *env,
+ const char *state_node_path)
+{
+ u8 env_ethaddr[ETH_ALEN], default_ethaddr[ETH_ALEN];
+ int ret;
+
+ ret = get_mac_address_from_env_variable(env, env_ethaddr);
+ if (ret)
+ goto copy_mac_from_eth0;
+
+ ret = get_default_mac_address_from_state_node(state_node_path, default_ethaddr);
+ if (ret)
+ goto copy_mac_from_eth0;
+
+ /*
+ * As the default is bogus copy the MAC address from eth0 if
+ * the state variable has not been set to a different variant
+ */
+ if (memcmp(env_ethaddr, default_ethaddr, ETH_ALEN) == 0)
+ goto copy_mac_from_eth0;
+
+ return eth_of_fixup_node(root, node_path, env_ethaddr);
+
+copy_mac_from_eth0:
+ return eth_of_fixup_node_from_eth_device(root, node_path, ethname);
+}
+
+#define MAX_V_GPIO 8
+
+struct board_description {
+ const char *variant;
+ const char *revision;
+ const char *soc;
+ const char *dts_compatible;
+ const char *display;
+ unsigned flags;
+};
+
+#define SKOV_NEED_ENABLE_RMII BIT(0)
+#define SKOV_DISPLAY_PARALLEL BIT(1)
+#define SKOV_ENABLE_MMC_POWER BIT(2)
+#define SKOV_DISPLAY_LVDS BIT(3)
+
+static const struct board_description imx6_variants[] = {
+ [0] = {
+ .variant = "high performance",
+ .revision = "A",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6-imxq-revA",
+ .flags = SKOV_NEED_ENABLE_RMII | SKOV_DISPLAY_PARALLEL,
+ },
+ [1] = {
+ .variant = "low cost",
+ .revision = "A",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6-imxdl-revA",
+ .flags = SKOV_NEED_ENABLE_RMII | SKOV_DISPLAY_PARALLEL,
+ },
+ [2] = {
+ .variant = "high performance",
+ .revision = "A",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6-imxq-revA",
+ .flags = SKOV_NEED_ENABLE_RMII | SKOV_DISPLAY_PARALLEL,
+ },
+ [4] = {
+ .variant = "low cost",
+ .revision = "A",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6-imxdl-revA",
+ .flags = SKOV_NEED_ENABLE_RMII | SKOV_DISPLAY_PARALLEL,
+ },
+ [8] = {
+ .variant = "high performance",
+ .revision = "A",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6-imxq-revA",
+ .flags = SKOV_NEED_ENABLE_RMII | SKOV_DISPLAY_PARALLEL,
+ },
+ [9] = {
+ .variant = "minimum cost",
+ .revision = "B",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6-imxdl-revB",
+ .flags = SKOV_DISPLAY_PARALLEL,
+ },
+ [10] = {
+ .variant = "low cost",
+ .revision = "B",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6-imxdl-revB",
+ .flags = SKOV_DISPLAY_PARALLEL,
+ },
+ [11] = {
+ .variant = "high performance",
+ .revision = "B",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6-imxq-revB",
+ .flags = SKOV_DISPLAY_PARALLEL,
+ },
+ [12] = {
+ /* FIXME this one is a revision 'C' according to the schematics */
+ .variant = "max performance",
+ .revision = "B",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6q-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_DISPLAY_PARALLEL,
+ },
+ [13] = {
+ .variant = "low cost",
+ .revision = "C",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6dl-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [14] = {
+ .variant = "high performance",
+ .revision = "C",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6q-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [15] = {
+ .variant = "middle performance",
+ .revision = "C",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6dl-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [16] = {
+ .variant = "Solo_R512M_F4G",
+ .revision = "C",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6dl-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [17] = {
+ .variant = "Quad_R2G_F8G",
+ .revision = "C",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6q-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [18] = {
+ .variant = "QuadPlus_R4G_F16G",
+ .revision = "C",
+ .soc = "i.MX6Q+",
+ .dts_compatible = "skov,imx6q-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [19] = {
+ .variant = "Solo_R512M_F2G",
+ .revision = "C",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6dl-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [20] = {
+ .variant = "Quad_R1G_F4G",
+ .revision = "C",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6q-skov-revc-lt2",
+ .display = "l2rt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [21] = {
+ .variant = "Solo_R512M_F2G",
+ .revision = "C",
+ .soc = "i.MX6S",
+ .dts_compatible = "skov,imx6dl-skov-revc-lt6",
+ .display = "l6whrt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [22] = {
+ .variant = "Quad_R1G_F4G",
+ .revision = "C",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6q-skov-revc-lt6",
+ .display = "l6whrt",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_PARALLEL,
+ },
+ [24] = {
+ .variant = "Quad_R1G_F4G",
+ .revision = "E",
+ .soc = "i.MX6Q",
+ .dts_compatible = "skov,imx6q-skov-reve-mi1010ait-1cp1",
+ .display = "mi1010ait-1cp1",
+ .flags = SKOV_ENABLE_MMC_POWER | SKOV_DISPLAY_LVDS,
+ },
+};
+
+static int skov_board_no = -1;
+
+static int skov_imx6_fixup(struct device_node *root, void *unused)
+{
+ int ret;
+ const char *val;
+ uint32_t brightness;
+ struct device_node *node;
+ struct device_node *chosen = of_create_node(root, "/chosen");
+
+ eth_of_fixup_node_from_eth_device(root,
+ "/mdio-gpio/ksz8873@3/ports/ports@0", "eth0");
+ eth2_of_fixup_node_individually(root,
+ "/mdio-gpio/ksz8873@3/ports/ports@1", "eth0",
+ "state.ethaddr.eth2", "/state/ethaddr/eth2");
+
+ switch (bootsource_get()) {
+ case BOOTSOURCE_MMC:
+ /* use default variant of state variable defined in devicetree */
+ brightness = 8;
+ break;
+ default:
+ val = getenv("state.display.brightness");
+ if (!val) {
+ pr_err("could not get default display brightness\n");
+ return 0;
+ }
+
+ brightness = simple_strtoul(val, NULL, 0);
+ break;
+ }
+
+ for_each_compatible_node_from(node, root, NULL, "pwm-backlight") {
+ ret = of_property_write_u32(node, "default-brightness-level", brightness);
+ if (ret)
+ pr_err("error %d while setting default-brightness-level property on node %s to %d\n",
+ ret, node->name, brightness);
+ }
+
+ of_property_write_u32(chosen, "skov,imx6-board-version", skov_board_no);
+ of_property_write_string(chosen, "skov,imx6-board-variant",
+ imx6_variants[skov_board_no].variant);
+
+ return 0;
+}
+
+/*
+ * Some variants need tweaks to make them work
+ *
+ * Revision A has no backlight control, since revision B it is present (GPIO6/23)
+ * Revision A needs GPIO1/24 to be low to make network working
+ * Revision C can control the SD main power supply
+ */
+static void skov_init_board(const struct board_description *variant)
+{
+ struct device_node *np;
+ char *environment_path, *envdev;
+ int ret;
+
+ imx6_bbu_internal_spi_i2c_register_handler("spiflash", "/dev/m25p0.barebox",
+ BBU_HANDLER_FLAG_DEFAULT);
+
+ of_register_fixup(skov_imx6_fixup, NULL);
+
+ switch (bootsource_get()) {
+ case BOOTSOURCE_MMC:
+ environment_path = "/chosen/environment-sd";
+ envdev = "MMC";
+ break;
+ default:
+ environment_path = "/chosen/environment-spinor";
+ envdev = "SPI NOR flash";
+ break;
+ }
+
+ pr_notice("Using environment in %s\n", envdev);
+
+ ret = of_device_enable_path(environment_path);
+ if (ret < 0)
+ pr_warn("Failed to enable environment partition '%s' (%d)\n",
+ environment_path, ret);
+
+ if (variant->flags & SKOV_NEED_ENABLE_RMII) {
+ /*
+ * MX6QDL_PAD_ENET_RX_ER__GPIO1_IO24 is a gpio which must be
+ * low to enable the RMII from the switch point of view
+ */
+ gpio_request(24, "must_be_low");
+ gpio_direction_output(24, 0);
+ }
+
+ /* SD card handling */
+ gpio_request(205, "mmc io supply");
+ gpio_direction_output(205, 0); /* select 3.3 V IO voltage */
+
+ if (variant->flags & SKOV_ENABLE_MMC_POWER) {
+ /*
+ * keep in sync with devicetree's 'regulator-boot-on' setting for
+ * this regulator
+ */
+ gpio_request(200, "mmc power supply");
+ gpio_direction_output(200, 0); /* switch on */
+ mdelay(1);
+ gpio_direction_output(200, 1); /* switch on */
+ }
+
+ if (variant->flags & SKOV_DISPLAY_PARALLEL) {
+ np = of_find_compatible_node(NULL, NULL, "fsl,imx-parallel-display");
+ if (np)
+ of_device_enable_and_register(np);
+ else
+ pr_err("Cannot find \"fsl,imx-parallel-display\" node\n");
+ }
+
+ if (variant->flags & SKOV_DISPLAY_LVDS) {
+ np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-ldb");
+ if (np)
+ of_device_enable_and_register(np);
+ else
+ pr_err("Cannot find \"fsl,imx6q-ldb\" node\n");
+
+ /* ... as well as its channel 0 */
+ np = of_find_node_by_name(np, "lvds-channel@0");
+ if (np)
+ of_device_enable(np);
+ else
+ pr_err("Cannot find \"lvds-channel@0\" node\n");
+ }
+}
+
+static void fixup_machine_compatible(const char *compat)
+{
+ const char *curcompat;
+ struct device_node *root;
+ int cclen = 0, clen = strlen(compat) + 1;
+ void *buf;
+
+ root = of_get_root_node();
+ if (!root)
+ return;
+
+ curcompat = of_get_property(root, "compatible", &cclen);
+
+ buf = xzalloc(cclen + clen);
+
+ memcpy(buf, compat, clen);
+ memcpy(buf + clen, curcompat, cclen);
+
+ /*
+ * Prepend the compatible from board entry to the machine compatible.
+ * Used to match bootspec entries against it.
+ */
+ of_set_property(root, "compatible", buf, cclen + clen, true);
+
+ free(buf);
+}
+
+static int skov_imx6_probe(struct device_d *dev)
+{
+ unsigned v = 0;
+ const struct board_description *variant;
+
+ v = skov_imx6_get_version();
+
+ if (v >= ARRAY_SIZE(imx6_variants)) {
+ dev_err(dev, "Invalid variant %u\n", v);
+ return -EINVAL;
+ }
+
+ variant = &imx6_variants[v];
+
+ if (!variant->variant) {
+ dev_err(dev, "Invalid variant %u\n", v);
+ return -EINVAL;
+ }
+
+ skov_board_no = v;
+
+ globalvar_add_simple_int("board.no", &skov_board_no, "%u");
+ globalvar_add_simple("board.variant", variant->variant);
+ globalvar_add_simple("board.revision",variant->revision);
+ globalvar_add_simple("board.soc", variant->soc);
+ globalvar_add_simple("board.dts", variant->dts_compatible);
+ globalvar_add_simple("board.display", variant->display ?: NULL);
+
+ fixup_machine_compatible(variant->dts_compatible);
+
+ skov_init_board(variant);
+
+ return 0;
+}
+
+static __maybe_unused struct of_device_id skov_version_ids[] = {
+ {
+ .compatible = "skov,imx6",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d skov_version_driver = {
+ .name = "skov-imx6",
+ .probe = skov_imx6_probe,
+ .of_compatible = DRV_OF_COMPAT(skov_version_ids),
+};
+coredevice_platform_driver(skov_version_driver);
+
+static void skov_imx6_devices_shutdown(void)
+{
+ const char *external;
+
+ if (skov_board_no < 0)
+ return;
+
+ external = getenv("state.display.external");
+ if (!external) {
+ pr_err("could not get state variable display.external\n");
+ return;
+ }
+
+ if (!strcmp(external, "0"))
+ setenv("backlight0.brightness", "0");
+}
+predevshutdown_exitcall(skov_imx6_devices_shutdown);
diff --git a/arch/arm/boards/skov-imx6/env/init/automount b/arch/arm/boards/skov-imx6/env/init/automount
new file mode 100644
index 0000000000..bc9ff48a0a
--- /dev/null
+++ b/arch/arm/boards/skov-imx6/env/init/automount
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+ init-menu-add-entry "$0" "Automountpoints"
+ exit
+fi
+
+# development support
+mkdir -p /mnt/tftp
+automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp'
+
+# regular SD card based boot procedure
+mkdir -p /mnt/sd
+automount -d /mnt/sd 'mmc2.probe=1 && mount -t ext4 /dev/mmc2.0 /mnt/sd'
diff --git a/arch/arm/boards/skov-imx6/env/nv/boot.default b/arch/arm/boards/skov-imx6/env/nv/boot.default
new file mode 100644
index 0000000000..fe1a363da1
--- /dev/null
+++ b/arch/arm/boards/skov-imx6/env/nv/boot.default
@@ -0,0 +1 @@
+bootchooser
diff --git a/arch/arm/boards/skov-imx6/flash-header-mx6-skov-imx6.imxcfg b/arch/arm/boards/skov-imx6/flash-header-mx6-skov-imx6.imxcfg
new file mode 100644
index 0000000000..4bb615ebb0
--- /dev/null
+++ b/arch/arm/boards/skov-imx6/flash-header-mx6-skov-imx6.imxcfg
@@ -0,0 +1,4 @@
+soc imx6
+loadaddr 0x00907000
+max_load_size 0x11000
+ivtofs 0x400
diff --git a/arch/arm/boards/skov-imx6/lowlevel.c b/arch/arm/boards/skov-imx6/lowlevel.c
new file mode 100644
index 0000000000..eab797faa1
--- /dev/null
+++ b/arch/arm/boards/skov-imx6/lowlevel.c
@@ -0,0 +1,664 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#define pr_fmt(fmt) "skov-imx6: " fmt
+
+#include <common.h>
+#include <mach/generic.h>
+#include <asm/barebox-arm-head.h>
+#include <asm/barebox-arm.h>
+#include <debug_ll.h>
+#include <io.h>
+#include <mach/imx6-mmdc.h>
+#include <mach/imx6-ddr-regs.h>
+#include <mach/imx6.h>
+#include <mach/xload.h>
+#include <mach/esdctl.h>
+#include <serial/imx-uart.h>
+#include <mach/iomux-mx6.h>
+#include <mach/imx-gpio.h>
+#include "version.h"
+
+static void __udelay(int us)
+{
+ volatile int i;
+
+ for (i = 0; i < us * 4; i++);
+}
+
+/* ------------------------------------------------------------------------ */
+
+/*
+ * Micron MT41K512M16HA-125 IT:E -> 8 GBit = 64 Meg x 16 x 8 banks
+ *
+ * Speed Grade Data Rate (MT/s) tRCD-tRP-CL tRCD(ns) tRP(ns) CL(ns)
+ * -125 1600 11-11-11 13.75 13.75 13.75
+ * (=800 MHz)
+ *
+ * Memory configuration used by variant:
+ * - "Max Performance", 64 bit data bus, 1066 MHz, 4 GiB memory
+ */
+static const struct mx6_ddr3_cfg skov_imx6_cfg_4x512Mb_1066MHz = {
+ .mem_speed = 1066,
+ .density = 8, /* GiBit */
+ .width = 16, /* 16 bit data per device */
+ .banks = 8,
+ .rowaddr = 16, /* 64 k */
+ .coladdr = 10, /* 1 k */
+ .pagesz = 2, /* [kiB] */
+ .trcd = 1375, /* 13.75 ns = 11 clocks @ 1.6 GHz */
+ .trcmin = 4875, /* 48.75 ns = 39 clocks @ 1.6 GHz */
+ .trasmin = 3500, /* 35 ns = 28 clocks @ 1.6 GHz */
+ .SRT = 0,
+};
+
+static const struct mx6_ddr_sysinfo skov_imx6_sysinfo_4x512Mb_1066MHz = {
+ .dsize = 2, /* 64 bit wide = 4 devices, 16 bit each */
+ .cs_density = 32, /* four 8 GBit devices connected */
+ .ncs = 1, /* one CS line for all devices */
+ .cs1_mirror = 1, /* TODO */
+ .bi_on = 1, /* TODO */
+ .rtt_nom = 1, /* MX6_MMDC_P0_MPODTCTRL -> 0x00022227 */
+ .rtt_wr = 0, /* is LW_EN is 0 in their code */
+ .ralat = 5, /* TODO */
+ .walat = 1, /* TODO */
+ .mif3_mode = 3, /* TODO */
+ .rst_to_cke = 0x23, /* used in their code as well */
+ .sde_to_rst = 0x10, /* used in their code as well */
+ .pd_fast_exit = 0, /* TODO */
+};
+
+static const struct mx6_mmdc_calibration skov_imx6_calib_4x512Mb_1066MHz = {
+ .p0_mpwldectrl0 = 0x001a0017,
+ .p0_mpwldectrl1 = 0x001F001F,
+ .p0_mpdgctrl0 = 0x43040319,
+ .p0_mpdgctrl1 = 0x03040279,
+ .p0_mprddlctl = 0x4d434248,
+ .p0_mpwrdlctl = 0x34424543,
+
+ .p1_mpwldectrl0 = 0x00170027,
+ .p1_mpwldectrl1 = 0x000a001f,
+ .p1_mpdgctrl0 = 0x43040321,
+ .p1_mpdgctrl1 = 0x03030251,
+ .p1_mprddlctl = 0x42413c4d,
+ .p1_mpwrdlctl = 0x49324933,
+};
+
+/* ------------------------------------------------------------------------ */
+
+/*
+ * Micron MT41K256M16HA-125 IT:E -> 4 GBit = 32 Meg x 16 x 8 banks
+ *
+ * Speed Grade Data Rate (MT/s) tRCD-tRP-CL tRCD(ns) tRP(ns) CL(ns)
+ * -125 1600 11-11-11 13.75 13.75 13.75
+ * (=800 MHz)
+ *
+ * Memory configuration used by variant:
+ * - "Max Performance", 64 bit data bus, 1066 MHz, 2 GiB memory
+ */
+static const struct mx6_ddr3_cfg skov_imx6_cfg_4x256Mb_1066MHz = {
+ .mem_speed = 1066,
+ .density = 4, /* GiBit */
+ .width = 16, /* 16 bit data per device */
+ .banks = 8,
+ .rowaddr = 15, /* 32 k */
+ .coladdr = 10, /* 1 k */
+ .pagesz = 2, /* [kiB] */
+ .trcd = 1375, /* 13.75 ns = 11 clocks @ 1.6 GHz */
+ .trcmin = 4875, /* 48.75 ns = 39 clocks @ 1.6 GHz */
+ .trasmin = 3500, /* 35 ns = 28 clocks @ 1.6 GHz */
+ .SRT = 0,
+};
+
+static const struct mx6_ddr_sysinfo skov_imx6_sysinfo_4x256Mb_1066MHz = {
+ .dsize = 2, /* 64 bit wide = 4 devices, 16 bit each */
+ .cs_density = 16, /* four 4 GBit devices connected */
+ .ncs = 1, /* one CS line for all devices */
+ .cs1_mirror = 1, /* TODO */
+ .bi_on = 1, /* TODO */
+ .rtt_nom = 1, /* MX6_MMDC_P0_MPODTCTRL -> 0x00022227 */
+ .rtt_wr = 0, /* is LW_EN is 0 in their code */
+ .ralat = 5, /* TODO */
+ .walat = 1, /* TODO */
+ .mif3_mode = 3, /* TODO */
+ .rst_to_cke = 0x23, /* used in their code as well */
+ .sde_to_rst = 0x10, /* used in their code as well */
+ .pd_fast_exit = 0, /* TODO */
+};
+
+static const struct mx6_mmdc_calibration skov_imx6_calib_4x256Mb_1066MHz = {
+ .p0_mpwldectrl0 = 0x001a0017,
+ .p0_mpwldectrl1 = 0x001F001F,
+ .p0_mpdgctrl0 = 0x43040319,
+ .p0_mpdgctrl1 = 0x03040279,
+ .p0_mprddlctl = 0x4d434248,
+ .p0_mpwrdlctl = 0x34424543,
+
+ .p1_mpwldectrl0 = 0x00170027,
+ .p1_mpwldectrl1 = 0x000a001f,
+ .p1_mpdgctrl0 = 0x43040321,
+ .p1_mpdgctrl1 = 0x03030251,
+ .p1_mprddlctl = 0x42413c4d,
+ .p1_mpwrdlctl = 0x49324933,
+};
+
+/* ------------------------------------------------------------------------ */
+
+/*
+ * Micron MT41K128M16JT-125 IT:K -> 2 GBit = 16 Meg x 16 x 8 banks
+ *
+ * Speed Grade Data Rate (MT/s) tRCD-tRP-CL tRCD(ns) tRP(ns) CL(ns)
+ * -125 ÂčÂČ 1600 11-11-11 13.75 13.75 13.75
+ * (=800 MHz)
+ *
+ * Âč Backward compatible to 1066 (=533 MHz), CL = 7
+ * ÂČ Backward compatible to 1333 (=667 MHz), CL = 9
+ *
+ * Memory configuration used by variant
+ * - "High Performance", 64 bit data bus, 1066 MHz, 1 GiB memory
+ */
+static const struct mx6_ddr3_cfg skov_imx6_cfg_4x128Mb_1066MHz = {
+ .mem_speed = 1066,
+ .density = 2, /* GiBit */
+ .width = 16, /* 16 bit data per device */
+ .banks = 8,
+ .rowaddr = 14, /* 16 k */
+ .coladdr = 10, /* 1 k */
+ .pagesz = 2, /* [kiB] */
+ .trcd = 1375, /* 13.75 ns = 11 clocks @ 1.6 GHz */
+ .trcmin = 4875, /* 48.75 ns = 39 clocks @ 1.6 GHz */
+ .trasmin = 3500, /* 35 ns = 28 clocks @ 1.6 GHz */
+ .SRT = 0,
+};
+
+static const struct mx6_ddr_sysinfo skov_imx6_sysinfo_4x128Mb_1066MHz = {
+ .dsize = 2, /* 64 bit wide = 4 devices, 16 bit each */
+ .cs_density = 8, /* four 2 GBit devices connected */
+ .ncs = 1, /* one CS line for all devices */
+ .cs1_mirror = 1, /* TODO */
+ .bi_on = 1, /* TODO */
+ .rtt_nom = 1, /* MX6_MMDC_P0_MPODTCTRL -> 0x00022227 */
+ .rtt_wr = 0, /* is LW_EN is 0 in their code */
+ .ralat = 5, /* TODO */
+ .walat = 1, /* TODO */
+ .mif3_mode = 3, /* TODO */
+ .rst_to_cke = 0x23, /* used in their code as well */
+ .sde_to_rst = 0x10, /* used in their code as well */
+ .pd_fast_exit = 0, /* TODO */
+};
+
+/* calibration info for the "max performance" and "high performance" */
+static const struct mx6_mmdc_calibration skov_imx6_calib_4x128Mb_1066MHz = {
+ .p0_mpwldectrl0 = 0x0011000E,
+ .p0_mpwldectrl1 = 0x000E001B,
+ .p0_mpdgctrl0 = 0x42720306,
+ .p0_mpdgctrl1 = 0x026F0266,
+ .p0_mprddlctl = 0x45393B3E,
+ .p0_mpwrdlctl = 0x40434541,
+
+ .p1_mpwldectrl0 = 0x00190015,
+ .p1_mpwldectrl1 = 0x00070018,
+ .p1_mpdgctrl0 = 0x4273030A,
+ .p1_mpdgctrl1 = 0x02740240,
+ .p1_mprddlctl = 0x403A3747,
+ .p1_mpwrdlctl = 0x473E4A3B,
+};
+
+/* ------------------------------------------------------------------------ */
+
+static struct mx6dq_iomux_ddr_regs ddr_iomux_q = {
+ .dram_sdqs0 = 0x00000030,
+ .dram_sdqs1 = 0x00000030,
+ .dram_sdqs2 = 0x00000030,
+ .dram_sdqs3 = 0x00000030,
+ .dram_sdqs4 = 0x00000030,
+ .dram_sdqs5 = 0x00000030,
+ .dram_sdqs6 = 0x00000030,
+ .dram_sdqs7 = 0x00000030,
+ .dram_dqm0 = 0x00020030,
+ .dram_dqm1 = 0x00020030,
+ .dram_dqm2 = 0x00020030,
+ .dram_dqm3 = 0x00020030,
+ .dram_dqm4 = 0x00020030,
+ .dram_dqm5 = 0x00020030,
+ .dram_dqm6 = 0x00020030,
+ .dram_dqm7 = 0x00020030,
+ .dram_cas = 0x00020030,
+ .dram_ras = 0x00020030,
+ .dram_sdclk_0 = 0x00020030,
+ .dram_sdclk_1 = 0x00020030,
+ .dram_sdcke0 = 0x00003000,
+ .dram_sdcke1 = 0x00003000,
+ .dram_reset = 0x00020030,
+ .dram_sdba2 = 0x00000000,
+ .dram_sdodt0 = 0x00003030,
+ .dram_sdodt1 = 0x00003030,
+};
+
+static struct mx6dq_iomux_grp_regs grp_iomux_q = {
+ .grp_b0ds = 0x00000030,
+ .grp_b1ds = 0x00000030,
+ .grp_b2ds = 0x00000030,
+ .grp_b3ds = 0x00000030,
+ .grp_b4ds = 0x00000030,
+ .grp_b5ds = 0x00000030,
+ .grp_b6ds = 0x00000030,
+ .grp_b7ds = 0x00000030,
+ .grp_addds = 0x00000030,
+ .grp_ddrmode_ctl = 0x00020000,
+ .grp_ddrpke = 0x00000000,
+ .grp_ddrmode = 0x00020000,
+ .grp_ctlds = 0x00000030,
+ .grp_ddr_type = 0x000C0000,
+};
+
+static void spl_imx6q_dram_init(const struct mx6_ddr_sysinfo *si,
+ const struct mx6_mmdc_calibration *cb,
+ const struct mx6_ddr3_cfg *cfg)
+{
+ mx6dq_dram_iocfg(64, &ddr_iomux_q, &grp_iomux_q);
+ mx6_dram_cfg(si, cb, cfg);
+ __udelay(100);
+}
+
+/* ------------------------------------------------------------------------ */
+/*
+ * Device Information: Varies per DDR3 part number and speed grade
+ * Note: this SDRAM type is used on the "Low Cost" variant
+ *
+ * Micron MT41K128M16JT-125 IT:K -> 2 GBit = 16 Meg x 16 x 8 banks
+ *
+ * Speed Grade Data Rate (MT/s) tRCD-tRP-CL tRCD(ns) tRP(ns) CL(ns)
+ * -125 ÂčÂČ 1600 11-11-11 13.75 13.75 13.75
+ * (=800 MHz)
+ *
+ * Âč Backward compatible to 1066 (=533 MHz), CL = 7
+ * ÂČ Backward compatible to 1333 (=667 MHz), CL = 9
+ *
+ * Memory configuration used by variant
+ * - "Low Cost", 32 bit data bus, 800 MHz, 512 MiB memory
+ */
+static const struct mx6_ddr3_cfg skov_imx6_cfg_2x128Mb_800MHz = {
+ .mem_speed = 800,
+ .density = 2, /* GiBit */
+ .width = 16, /* 16 bit data per device */
+ .banks = 8,
+ .rowaddr = 14, /* 16 k */
+ .coladdr = 10, /* 1 k */
+ .pagesz = 2, /* [kiB] */
+ .trcd = 1375, /* 13.75 ns = 11 clocks @ 1.6 GHz */
+ .trcmin = 4875, /* 48.75 ns = 39 clocks @ 1.6 GHz */
+ .trasmin = 3500, /* 35 ns = 28 clocks @ 1.6 GHz */
+ .SRT = 0,
+};
+
+static const struct mx6_ddr_sysinfo skov_imx6_sysinfo_2x128Mb_800MHz = {
+ .dsize = 1, /* 32 bit wide = 2 devices, 16 bit each */
+ .cs_density = 4, /* two 2 GBit devices connected */
+ .ncs = 1, /* one CS line for all devices */
+ .cs1_mirror = 1, /* TODO */
+ .bi_on = 1, /* TODO */
+ .rtt_nom = 1, /* MX6_MMDC_P0_MPODTCTRL -> 0x00022227 */
+ .rtt_wr = 0, /* is LW_EN is 0 in their code */
+ .ralat = 5, /* TODO */
+ .walat = 1, /* TODO */
+ .mif3_mode = 3, /* TODO */
+ .rst_to_cke = 0x23, /* used in their code as well */
+ .sde_to_rst = 0x10, /* used in their code as well */
+ .pd_fast_exit = 0, /* TODO */
+};
+
+static const struct mx6_mmdc_calibration skov_imx6_calib_2x128Mb_800MHz = {
+ .p0_mpwldectrl0 = 0x0040003C,
+ .p0_mpwldectrl1 = 0x0032003E,
+ .p0_mpdgctrl0 = 0x42350231,
+ .p0_mpdgctrl1 = 0x021A0218,
+ .p0_mprddlctl = 0x4B4B4E49,
+ .p0_mpwrdlctl = 0x3F3F3035,
+};
+
+/* ------------------------------------------------------------------------ */
+
+static const struct mx6sdl_iomux_ddr_regs ddr_iomux_s = {
+ .dram_sdqs0 = 0x00000030,
+ .dram_sdqs1 = 0x00000030,
+ .dram_sdqs2 = 0x00000030,
+ .dram_sdqs3 = 0x00000030,
+ .dram_sdqs4 = 0x00000030,
+ .dram_sdqs5 = 0x00000030,
+ .dram_sdqs6 = 0x00000030,
+ .dram_sdqs7 = 0x00000030,
+ .dram_dqm0 = 0x00020030,
+ .dram_dqm1 = 0x00020030,
+ .dram_dqm2 = 0x00020030,
+ .dram_dqm3 = 0x00020030,
+ .dram_dqm4 = 0x00020030,
+ .dram_dqm5 = 0x00020030,
+ .dram_dqm6 = 0x00020030,
+ .dram_dqm7 = 0x00020030,
+ .dram_cas = 0x00020030,
+ .dram_ras = 0x00020030,
+ .dram_sdclk_0 = 0x00020030,
+ .dram_sdclk_1 = 0x00020030,
+ .dram_sdcke0 = 0x00003000,
+ .dram_sdcke1 = 0x00003000,
+ .dram_reset = 0x00020030,
+ .dram_sdba2 = 0x00000000,
+ .dram_sdodt0 = 0x00003030,
+ .dram_sdodt1 = 0x00003030,
+};
+
+static const struct mx6sdl_iomux_grp_regs grp_iomux_s = { /* TODO */
+ .grp_b0ds = 0x00000030,
+ .grp_b1ds = 0x00000030,
+ .grp_b2ds = 0x00000030,
+ .grp_b3ds = 0x00000030,
+ .grp_b4ds = 0x00000030,
+ .grp_b5ds = 0x00000030,
+ .grp_b6ds = 0x00000030,
+ .grp_b7ds = 0x00000030,
+ .grp_addds = 0x00000030,
+ .grp_ddrmode_ctl = 0x00020000,
+ .grp_ddrpke = 0x00000000,
+ .grp_ddrmode = 0x00020000,
+ .grp_ctlds = 0x00000030,
+ .grp_ddr_type = 0x000C0000,
+};
+
+static void spl_imx6sdl_dram_init(const struct mx6_ddr_sysinfo *si,
+ const struct mx6_mmdc_calibration *cb,
+ const struct mx6_ddr3_cfg *cfg)
+{
+ mx6sdl_dram_iocfg(64, &ddr_iomux_s, &grp_iomux_s);
+ mx6_dram_cfg(si, cb, cfg);
+ __udelay(100);
+}
+
+/* ------------------------------------------------------------------------ */
+
+#define BKLGT_PWR_PAD_CTRL MX6_PAD_CTL_SPEED_LOW | MX6_PAD_CTL_DSE_80ohm | MX6_PAD_CTL_SRE_SLOW
+
+static inline void init_backlight_gpios(int cpu_type, unsigned board_variant)
+{
+ void __iomem *iomuxbase = IOMEM(MX6_IOMUXC_BASE_ADDR);
+ void __iomem *gpio6base = IOMEM(MX6_GPIO6_BASE_ADDR);
+ void __iomem *gpio1base = IOMEM(MX6_GPIO1_BASE_ADDR);
+
+ /*
+ * since revision B a backlight switch is present which can help to
+ * prevent any kind of flicker when switching on the board. Use it.
+ * GPIO6/23 controls the backlight. High switches off the backlight.
+ */
+ switch (board_variant) {
+ case 0 ... 8:
+ break;
+ default:
+ imx6_gpio_direction_output(gpio6base, 23, 1);
+
+ switch (cpu_type) {
+ case IMX6_CPUTYPE_IMX6S:
+ case IMX6_CPUTYPE_IMX6DL:
+ writel(IOMUX_CONFIG_SION | 0x05, iomuxbase + 0x2D0);
+ writel(BKLGT_PWR_PAD_CTRL, iomuxbase + 0x6B8);
+ break;
+ case IMX6_CPUTYPE_IMX6D:
+ case IMX6_CPUTYPE_IMX6Q:
+ writel(IOMUX_CONFIG_SION | 0x05, iomuxbase + 0x068);
+ writel(BKLGT_PWR_PAD_CTRL, iomuxbase + 0x37C);
+ break;
+ }
+ }
+
+ /*
+ * switch brightness to the lowest available value. This is what we
+ * can do for revision A boards
+ * GPIO1/1 controls (via PWM) the brightness. A static low means
+ * a very dark backlight
+ */
+ imx6_gpio_direction_output(gpio1base, 1, 0);
+
+ switch (cpu_type) {
+ case IMX6_CPUTYPE_IMX6S:
+ case IMX6_CPUTYPE_IMX6DL:
+ writel(IOMUX_CONFIG_SION | 0x05, iomuxbase + 0x210);
+ writel(BKLGT_PWR_PAD_CTRL, iomuxbase + 0x5E0);
+ break;
+ case IMX6_CPUTYPE_IMX6D:
+ case IMX6_CPUTYPE_IMX6Q:
+ writel(IOMUX_CONFIG_SION | 0x05, iomuxbase + 0x224);
+ writel(BKLGT_PWR_PAD_CTRL, iomuxbase + 0x5F4);
+ break;
+ }
+}
+
+#define LED_PAD_CTRL MX6_PAD_CTL_SPEED_LOW | MX6_PAD_CTL_DSE_240ohm | MX6_PAD_CTL_SRE_SLOW
+
+static inline void setup_leds(int cpu_type)
+{
+ void __iomem *iomuxbase = IOMEM(MX6_IOMUXC_BASE_ADDR);
+ void __iomem *gpiobase = IOMEM(MX6_GPIO1_BASE_ADDR);
+
+ switch (cpu_type) {
+ case IMX6_CPUTYPE_IMX6S:
+ case IMX6_CPUTYPE_IMX6DL:
+ writel(0x05, iomuxbase + 0x20C); /* LED1 (GPIO0) */
+ writel(LED_PAD_CTRL, iomuxbase + 0x5DC);
+ writel(0x05, iomuxbase + 0x224); /* LED2 (GPIO2) */
+ writel(LED_PAD_CTRL, iomuxbase + 0x5F4);
+ writel(0x05, iomuxbase + 0x22C); /* LED3 (GPIO4) */
+ writel(LED_PAD_CTRL, iomuxbase + 0x5FC);
+ break;
+ case IMX6_CPUTYPE_IMX6D:
+ case IMX6_CPUTYPE_IMX6Q:
+ writel(0x05, iomuxbase + 0x220); /* LED1 (GPIO0) */
+ writel(LED_PAD_CTRL, iomuxbase + 0x5f0);
+ writel(0x05, iomuxbase + 0x234); /* LED2 (GPIO2) */
+ writel(LED_PAD_CTRL, iomuxbase + 0x604);
+ writel(0x05, iomuxbase + 0x238); /* LED3 (GPIO4) */
+ writel(LED_PAD_CTRL, iomuxbase + 0x608);
+ break;
+ }
+
+ /* Turn off all LEDS */
+ imx6_gpio_direction_output(gpiobase, 1, 0);
+ imx6_gpio_direction_output(gpiobase, 4, 0);
+ imx6_gpio_direction_output(gpiobase, 16, 0);
+}
+
+static inline void setup_uart(int cpu_type)
+{
+ void __iomem *iomuxbase = IOMEM(MX6_IOMUXC_BASE_ADDR);
+
+ /* UART TxD output is pin EIM/D26, e.g. UART is in DTE mode */
+ switch (cpu_type) {
+ case IMX6_CPUTYPE_IMX6S:
+ case IMX6_CPUTYPE_IMX6DL:
+ writel(0x0, iomuxbase + 0x904); /* IOMUXC_UART2_UART_RX_DATA_SELECT_INPUT */
+ writel(0x4, iomuxbase + 0x16c); /* IOMUXC_SW_MUX_CTL_PAD_EIM_DATA26 */
+ break;
+ case IMX6_CPUTYPE_IMX6D:
+ case IMX6_CPUTYPE_IMX6Q:
+ writel(0x0, iomuxbase + 0x928); /* IOMUXC_UART2_UART_RX_DATA_SELECT_INPUT */
+ writel(0x4, iomuxbase + 0x0bc); /* IOMUXC_SW_MUX_CTL_PAD_EIM_DATA26 */
+ break;
+ }
+
+ imx6_ungate_all_peripherals();
+ imx6_uart_setup(IOMEM(MX6_UART2_BASE_ADDR));
+ pbl_set_putc(imx_uart_putc, IOMEM(MX6_UART2_BASE_ADDR));
+
+ pr_debug("\n");
+}
+
+/*
+ * Hardware marked board revisions and deployments
+ *
+ * count board ram flash CPU
+ * rev.
+ * 00000000 A 1024 MiB 1024 MiB i.MX6Q
+ * 00000001 A 512 MiB 256 MiB i.MX6S
+ * 00000010 A 1024 MiB 512 MiB i.MX6Q
+ * 00000011 ---- not defined ----
+ * 00000100 A 512 MiB 256 MiB i.MX6S
+ * 00000101 ---- not defined ----
+ * 00000110 ---- not defined ----
+ * 00000111 ---- not defined ----
+ * 00001000 A 1024 MiB 512 MiB i.MX6Q
+ * 00001001 B 256 MiB 16 MiB i.MX6S
+ * 00001010 B 256 MiB 256 MiB i.MX6S
+ * 00001011 B 1024 MiB 256 MiB i.MX6Q
+ * 00001100 B 2048 MiB 8 GiB i.MX6Q
+ * 00001101 C 256 MiB 256 MiB i.MX6S
+ * 00001110 C 1024 MiB 256 MiB i.MX6Q
+ * 00001111 C 512 MiB 256 MiB i.MX6S
+ * 00010000 C 512 MiB 4 GiB i.MX6S
+ * 00010001 C 2048 MiB 8 GiB i.MX6Q
+ * 00010010 C 4096 MiB 16 GiB i.MX6Q+
+ * 00010011 C 512 MiB 2 GiB i.MX6S
+ * 00010100 C 1024 MiB 4 GiB i.MX6Q
+ * 00010101 D 512 MiB 2 GIB i.MX6S
+ * 00010110 D 1024 MiB 4 GIB i.MX6Q
+ * 00010111 ---- not defined ----
+ * 00011000 E 1024 MiB 4 GIB i.MX6Q
+ *
+ * This routine does not return if starting the image from SD card or NOR
+ * was successful. It restarts skov_imx6_start() instead
+ */
+static void skov_imx6_init(int cpu_type, unsigned board_variant)
+{
+ enum bootsource bootsrc;
+ int instance;
+
+ switch (board_variant) {
+ case 12: /* P2 i.MX6Q, max performance */
+ if (cpu_type != IMX6_CPUTYPE_IMX6Q) {
+ pr_err("Invalid SoC! i.MX6Q expected\n");
+ return;
+ }
+ pr_debug("Initializing a P2 max performance system...\n");
+ spl_imx6q_dram_init(&skov_imx6_sysinfo_4x256Mb_1066MHz,
+ &skov_imx6_calib_4x256Mb_1066MHz,
+ &skov_imx6_cfg_4x256Mb_1066MHz);
+ break;
+ case 18: /* i.MX6Q+ */
+ if (cpu_type != IMX6_CPUTYPE_IMX6Q) {
+ pr_err("Invalid SoC! i.MX6Q expected\n");
+ return;
+ }
+ pr_debug("Initializing board variant 18\n");
+ spl_imx6q_dram_init(&skov_imx6_sysinfo_4x512Mb_1066MHz,
+ &skov_imx6_calib_4x512Mb_1066MHz,
+ &skov_imx6_cfg_4x512Mb_1066MHz);
+ break;
+ case 19: /* i.MX6S "Solo_R512M_F2G" */
+ if (cpu_type != IMX6_CPUTYPE_IMX6S) {
+ pr_err("Invalid SoC! i.MX6S expected\n");
+ return;
+ }
+ pr_debug("Initializing board variant 19\n");
+ spl_imx6sdl_dram_init(&skov_imx6_sysinfo_2x128Mb_800MHz,
+ &skov_imx6_calib_2x128Mb_800MHz,
+ &skov_imx6_cfg_2x128Mb_800MHz);
+ break;
+ case 20: /* i.MX6Q, "Quad_R1G_F2G" */
+ if (cpu_type != IMX6_CPUTYPE_IMX6Q) {
+ pr_err("Invalid SoC! i.MX6Q expected\n");
+ return;
+ }
+ pr_debug("Initializing board variant 20\n");
+ spl_imx6q_dram_init(&skov_imx6_sysinfo_4x128Mb_1066MHz,
+ &skov_imx6_calib_4x128Mb_1066MHz,
+ &skov_imx6_cfg_4x128Mb_1066MHz);
+ break;
+ case 21: /* i.MX6S "Solo_R512M_F2G" */
+ if (cpu_type != IMX6_CPUTYPE_IMX6S) {
+ pr_err("Invalid SoC! i.MX6S expected\n");
+ return;
+ }
+ pr_debug("Initializing board variant 21\n");
+ spl_imx6sdl_dram_init(&skov_imx6_sysinfo_2x128Mb_800MHz,
+ &skov_imx6_calib_2x128Mb_800MHz,
+ &skov_imx6_cfg_2x128Mb_800MHz);
+ break;
+ case 22: /* i.MX6Q, "Quad_R1G_F4G" */
+ if (cpu_type != IMX6_CPUTYPE_IMX6Q) {
+ pr_err("Invalid SoC! i.MX6Q expected\n");
+ return;
+ }
+ pr_debug("Initializing board variant 22\n");
+ spl_imx6q_dram_init(&skov_imx6_sysinfo_4x128Mb_1066MHz,
+ &skov_imx6_calib_4x128Mb_1066MHz,
+ &skov_imx6_cfg_4x128Mb_1066MHz);
+ break;
+ case 24: /* i.MX6Q, "Quad_R1G_F4G" */
+ if (cpu_type != IMX6_CPUTYPE_IMX6Q) {
+ pr_err("Invalid SoC! i.MX6Q expected\n");
+ return;
+ }
+ pr_debug("Initializing board variant 24\n");
+ spl_imx6q_dram_init(&skov_imx6_sysinfo_4x128Mb_1066MHz,
+ &skov_imx6_calib_4x128Mb_1066MHz,
+ &skov_imx6_cfg_4x128Mb_1066MHz);
+ break;
+ default:
+ pr_err("Unsupported board variant: 0x%x\n", board_variant);
+ /* don't continue */
+ while(1);
+ break;
+ }
+
+ imx6_get_boot_source(&bootsrc, &instance);
+ if (bootsrc == BOOTSOURCE_SPI_NOR) {
+ pr_info("Loading bootloader image from SPI flash...");
+ imx6_spi_start_image(0);
+ } else {
+ pr_info("Loading bootloader image from SD card...");
+ imx6_esdhc_start_image(instance);
+ }
+}
+
+extern char __dtb_z_imx6q_skov_imx6_start[];
+extern char __dtb_z_imx6dl_skov_imx6_start[];
+
+/* called twice: once for SDRAM setup only, second for devicetree setup */
+static noinline void skov_imx6_start(void)
+{
+ int cpu_type = __imx6_cpu_type();
+ unsigned board_variant = skov_imx6_get_version();
+
+ setup_uart(cpu_type);
+
+ if (get_pc() <= MX6_MMDC_PORT01_BASE_ADDR) {
+ /* first call: do the lowlevel things first */
+ init_backlight_gpios(cpu_type, board_variant);
+ setup_leds(cpu_type);
+ pr_info("Starting to init IMX6 system...\n");
+ skov_imx6_init(cpu_type, board_variant);
+ pr_err("Unable to start bootloader\n");
+ while (1);
+ }
+
+ /* boot this platform (second call) */
+ switch (cpu_type) {
+ case IMX6_CPUTYPE_IMX6S:
+ case IMX6_CPUTYPE_IMX6DL:
+ pr_debug("Startup i.MX6S/DL based system...\n");
+ imx6q_barebox_entry(__dtb_z_imx6dl_skov_imx6_start);
+ break;
+ case IMX6_CPUTYPE_IMX6D:
+ case IMX6_CPUTYPE_IMX6Q:
+ pr_debug("Startup i.MX6Q based system...\n");
+ imx6q_barebox_entry(__dtb_z_imx6q_skov_imx6_start);
+ break;
+ }
+}
+
+ENTRY_FUNCTION(start_imx6_skov_imx6, r0, r1, r2)
+{
+ arm_cpu_lowlevel_init();
+
+ relocate_to_current_adr();
+ setup_c();
+ barrier();
+
+ skov_imx6_start();
+}
diff --git a/arch/arm/configs/at91_multi_defconfig b/arch/arm/configs/at91_multi_defconfig
index e6a554e87f..f0a4812f0c 100644
--- a/arch/arm/configs/at91_multi_defconfig
+++ b/arch/arm/configs/at91_multi_defconfig
@@ -1,4 +1,5 @@
CONFIG_AT91_MULTI_BOARDS=y
+CONFIG_MACH_SKOV_ARM9CPU=y
CONFIG_MACH_AT91SAM9263EK=y
CONFIG_MACH_AT91SAM9X5EK=y
CONFIG_MACH_MICROCHIP_KSZ9477_EVB=y
diff --git a/arch/arm/configs/imx_v7_defconfig b/arch/arm/configs/imx_v7_defconfig
index 16e109464b..624698ae3c 100644
--- a/arch/arm/configs/imx_v7_defconfig
+++ b/arch/arm/configs/imx_v7_defconfig
@@ -13,6 +13,7 @@ CONFIG_MACH_FREESCALE_MX53_VMX53=y
CONFIG_MACH_TX53=y
CONFIG_MACH_PHYTEC_SOM_IMX6=y
CONFIG_MACH_PROTONIC_IMX6=y
+CONFIG_MACH_KAMSTRUP_MX7_CONCENTRATOR=y
CONFIG_MACH_KONTRON_SAMX6I=y
CONFIG_MACH_DFI_FS700_M60=y
CONFIG_MACH_GUF_SANTARO=y
diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index db0fe98e0d..2250b8ccd3 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -52,6 +52,7 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
void *pg_start, *pg_end;
unsigned long pc = get_pc();
+ /* piggy data is not relocated, so determine the bounds now */
pg_start = input_data + global_variable_offset();
pg_end = input_data_end + global_variable_offset();
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index d5f61768a5..a637869fb6 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -30,6 +30,7 @@ lwl-$(CONFIG_MACH_GRINN_LITEBOARD) += imx6ul-liteboard.dtb.o
lwl-$(CONFIG_MACH_GUF_SANTARO) += imx6q-guf-santaro.dtb.o
lwl-$(CONFIG_MACH_GUF_VINCELL) += imx53-guf-vincell.dtb.o imx53-guf-vincell-lt.dtb.o
lwl-$(CONFIG_MACH_GW_VENTANA) += imx6q-gw54xx.dtb.o
+lwl-$(CONFIG_MACH_KAMSTRUP_MX7_CONCENTRATOR) += imx7d-flex-concentrator-mfg.dtb.o
lwl-$(CONFIG_MACH_KONTRON_SAMX6I) += imx6q-samx6i.dtb.o \
imx6dl-samx6i.dtb.o
lwl-$(CONFIG_MACH_LENOVO_IX4_300D) += armada-xp-lenovo-ix4-300d-bb.dtb.o
@@ -110,6 +111,8 @@ lwl-$(CONFIG_MACH_SOLIDRUN_CUBOX) += dove-cubox-bb.dtb.o
lwl-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += imx6dl-hummingboard.dtb.o imx6q-hummingboard.dtb.o \
imx6dl-hummingboard2.dtb.o imx6q-hummingboard2.dtb.o \
imx6q-h100.dtb.o
+lwl-$(CONFIG_MACH_SKOV_IMX6) += imx6dl-skov-imx6.dtb.o imx6q-skov-imx6.dtb.o
+lwl-$(CONFIG_MACH_SKOV_ARM9CPU) += at91-skov-arm9cpu.dtb.o
lwl-$(CONFIG_MACH_SEEED_ODYSSEY) += stm32mp157c-odyssey.dtb.o
lwl-$(CONFIG_MACH_STM32MP15XX_DKX) += stm32mp157c-dk2.dtb.o stm32mp157a-dk1.dtb.o
lwl-$(CONFIG_MACH_LXA_MC1) += stm32mp157c-lxa-mc1.dtb.o
diff --git a/arch/arm/dts/at91-skov-arm9cpu.dts b/arch/arm/dts/at91-skov-arm9cpu.dts
new file mode 100644
index 0000000000..8e4fddfd3f
--- /dev/null
+++ b/arch/arm/dts/at91-skov-arm9cpu.dts
@@ -0,0 +1,451 @@
+// SPDX-License-Identifier: GPL-2.0
+// SPDX-FileCopyrightText: 2018 Sam Ravnborg <sam@ravnborg.org>
+
+/*
+ * Device Tree file for SKOV ARM9 CPU board with 128 MB RAM and
+ * Logic Technology Display
+ */
+
+/dts-v1/;
+
+#include "arm/at91sam9263.dtsi"
+
+/ {
+ model = "SKOV ARM9 CPU";
+ compatible = "skov,arm9-cpu", "atmel,at91sam9263", "atmel,at91sam9";
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+
+ environment {
+ compatible = "barebox,environment";
+ device-path = &environment_nor;
+ };
+ };
+
+ flash: nor_flash@10000000 {
+ compatible = "cfi-flash";
+ reg = <0x10000000 0x4000000>;
+ linux,mtd-name = "physmap-flash.0";
+ bank-width = <2>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ barebox@0 {
+ label = "bootloader";
+ reg = <0x00000 0x80000>;
+ };
+
+ environment_nor: env@80000 {
+ label = "environment";
+ reg = <0x80000 0x20000>;
+ };
+
+ linux@a0000 {
+ label = "linux";
+ reg = <0xa0000 0x2a0000>;
+ };
+
+ rootfs@340000 {
+ label = "rootfs";
+ reg = <0x340000 0x3cc0000>;
+ };
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ D0 {
+ label = "D0";
+ gpios = <&pioD 0 GPIO_ACTIVE_LOW>;
+ linux,default-trigger = "heartbeat";
+ };
+
+ D1 {
+ label = "D1";
+ gpios = <&pioD 1 GPIO_ACTIVE_LOW>;
+ linux,default-trigger = "mmc0";
+ };
+
+ D2 {
+ label = "D2";
+ gpios = <&pioD 7 GPIO_ACTIVE_LOW>;
+ };
+
+ led_0 {
+ label = "led_0";
+ gpios = <&pioB 14 GPIO_ACTIVE_LOW>;
+ };
+
+ led_1 {
+ label = "led_1";
+ gpios = <&pioB 23 GPIO_ACTIVE_LOW>;
+ };
+
+ led_2 {
+ label = "led_2";
+ gpios = <&pioB 18 GPIO_ACTIVE_LOW>;
+ };
+
+ led_3 {
+ label = "led_3";
+ gpios = <&pioB 22 GPIO_ACTIVE_LOW>;
+ };
+
+ led_4 {
+ label = "led_4";
+ gpios = <&pioA 22 GPIO_ACTIVE_LOW>;
+ };
+
+ led_5 {
+ label = "led_5";
+ gpios = <&pioA 23 GPIO_ACTIVE_LOW>;
+ };
+
+ led_6 {
+ label = "led_6";
+ gpios = <&pioA 24 GPIO_ACTIVE_LOW>;
+ };
+
+ led_7 {
+ label = "led_7";
+ gpios = <&pioA 20 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ i2c-gpio-0 {
+ status = "okay";
+
+ 24c512@50 {
+ compatible = "24c512";
+ reg = <0x50>;
+ pagesize = <128>;
+ };
+ };
+
+ rotary-encoder {
+ compatible = "rotary-encoder";
+ gpios = <&pioB 19 GPIO_ACTIVE_LOW>, <&pioB 20 GPIO_ACTIVE_LOW>;
+ linux,axis = <0>; /* REL_X */
+ rotary-encoder,steps-per-period = <4>;
+ rotary-encoder,relative-axis;
+ };
+
+ gpio-keys {
+ compatible = "gpio-keys";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ rotary_button {
+ label = "rotary_button";
+ gpios = <&pioB 15 GPIO_ACTIVE_LOW>;
+ debounce-interval = <10>;
+ linux,code = <28>; /* enter */
+ };
+ };
+
+ matrix-keypad-6x5 {
+ compatible = "gpio-matrix-keypad";
+ debounce-delay-ms = <10>;
+ col-scan-delay-us = <10>;
+
+ row-gpios = <&pioB 25 GPIO_ACTIVE_HIGH /* 1 */
+ &pioB 21 GPIO_ACTIVE_HIGH /* 2 */
+ &pioB 16 GPIO_ACTIVE_HIGH /* 3 */
+ &pioB 24 GPIO_ACTIVE_HIGH /* 4 */
+ &pioB 12 GPIO_ACTIVE_HIGH>; /* 5 */
+
+ col-gpios = <&pioB 13 GPIO_ACTIVE_HIGH /* 1 */
+ &pioB 17 GPIO_ACTIVE_HIGH /* 2 */
+ &pioA 25 GPIO_ACTIVE_HIGH /* 3 */
+ &pioA 21 GPIO_ACTIVE_HIGH /* 4 */
+ &pioA 19 GPIO_ACTIVE_HIGH /* 5 */
+ &pioA 18 GPIO_ACTIVE_HIGH>; /* 6 */
+
+
+ linux,keymap = <
+ 0x00000011 /* col0 row0 KEY_W */
+ 0x01000021 /* col0 row1 KEY_F */
+ 0x02000031 /* col0 row2 KEY_N */
+ 0x03000041 /* col0 row3 KEY_F7 */
+ 0x04000051 /* col0 row4 KEY_KP3 */
+ 0x00010012 /* col1 row0 KEY_E */
+ 0x01010022 /* col1 row1 KEY_G */
+ 0x02010032 /* col1 row2 KEY_M */
+ 0x03010042 /* col1 row3 KEY_F8 */
+ 0x04010052 /* col1 row4 KEY_KP0 */
+ 0x00020013 /* col2 row0 KEY_R */
+ 0x01020023 /* col2 row1 KEY_H */
+ 0x02020033 /* col2 row2 KEY_COMMA */
+ 0x03020043 /* col2 row3 KEY_F9 */
+ 0x04020053 /* col2 row4 KEY_F9 */
+ 0x00030014 /* col3 row0 KEY_T */
+ 0x01030024 /* col3 row1 KEY_J */
+ 0x02030034 /* col3 row2 KEY_DOT */
+ 0x03030044 /* col3 row3 KEY_NUMLOCK */
+ 0x04030054 /* col3 row4 */
+ 0x00040015 /* col4 row0 KEY_Y */
+ 0x01040025 /* col4 row1 KEY_K */
+ 0x02040035 /* col4 row2 KEY_SLASH */
+ 0x03040045 /* col4 row3 KEY_NUMLOCK */
+ 0x04040055 /* col4 row4 KEY_ZENKAKUHANKAKU */
+ 0x00050016 /* col5 row0 KEY_U */
+ 0x01050026 /* col5 row1 KEY_L */
+ 0x02050036 /* col5 row2 KEY_RIGH_SHIFT */
+ 0x03050046 /* col5 row3 KEY_SCROLLLOCK */
+ 0x04050056 /* col5 row4 KEY_102ND */
+ >;
+ };
+};
+
+&{/ahb/apb} {
+ pinctrl: pinctrl@fffff200 {
+ };
+
+ watchdog@fffffd40 {
+ status = "okay";
+ };
+};
+
+&dbgu {
+ status = "okay";
+};
+
+&fb0 {
+ status = "okay";
+ display = <&display0>;
+ display0: display0 {
+ bits-per-pixel = <16>;
+ atmel,lcdcon-backlight;
+ atmel,dmacon = <0x1>;
+ atmel,lcdcon2 = <0x80008002>;
+ atmel,guard-time = <1>;
+ atmel,lcd-wiring-mode = "BRG";
+ pinctrl-names = "default";
+ pinctrl-0 = <
+ &pinctrl_board_fb
+ &pinctrl_disp_type
+ &pinctrl_logic_type
+ >;
+
+ atmel,power-control-gpio = <&pioA 30 GPIO_ACTIVE_HIGH>;
+
+ display-timings {
+ native-mode = <&l2rt>;
+
+ l2rt: l2rt {
+ /* LTTD800480070-L2RT @ 55 */
+ clock-frequency = <30000000>;
+ hactive = <800>;
+ vactive = <480>;
+ /* Atmel calculation
+ * Horizontal =
+ * Hsync + left margin + picture + right_margin + 1
+ * (3 + 85 + 800 + 0 + 1 = 889)
+ */
+ hback-porch = <85>;
+ hfront-porch = <1>;
+ hsync-len = <3>;
+ /* Vertical =
+ * upper margin + picture + lower_margin
+ * (32 + 480 + 1 = 513) (25MHz / ( 889 * 513 ) = 54,8Hz
+ */
+ vback-porch = <32>;
+ vfront-porch = <1>;
+ vsync-len = <3>;
+ pixelclk-active = <1>;
+ hsync-active = <0>;
+ vsync-active = <0>;
+ de-active = <1>;
+ };
+
+ l6whrt: l6whrt {
+ clock-frequency = <33000000>;
+ hactive = <800>;
+ vactive = <480>;
+ hback-porch = <43>;
+ hfront-porch = <154>;
+ vback-porch = <20>;
+ vfront-porch = <47>;
+ hsync-len = <3>;
+ vsync-len = <3>;
+ pixelclk-active = <1>;
+ hsync-active = <0>;
+ vsync-active = <0>;
+ de-active = <1>;
+ };
+
+ seiko: seiko {
+ /* 70WVW2AZ0 @ 55 */
+ clock-frequency = <33000000>;
+ hactive = <800>;
+ vactive = <480>;
+ hback-porch = <0>;
+ hfront-porch = <256>;
+ vback-porch = <45>;
+ vfront-porch = <0>;
+ hsync-len = <0>;
+ vsync-len = <0>;
+ pixelclk-active = <1>;
+ hsync-active = <0>;
+ vsync-active = <0>;
+ de-active = <1>;
+ };
+ };
+ };
+};
+
+&macb0 {
+ status = "okay";
+ phy-mode = "rmii";
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ ethphy0: ethernet-phy@1 {
+ reg = <3>;
+ reset-gpios = <&pioE 17 GPIO_ACTIVE_LOW>;
+ reset-assert-us = <1000>;
+ reset-deassert-us = <100>;
+ };
+};
+
+&main_xtal {
+ clock-frequency = <16000000>;
+};
+
+&mmc1 {
+ status = "okay";
+ pinctrl-0 = <
+ &pinctrl_board_mmc1
+ &pinctrl_mmc1_clk
+ &pinctrl_mmc1_slot0_cmd_dat0
+ &pinctrl_mmc1_slot0_dat1_3>;
+ cd-gpios = <&pioE 18 GPIO_ACTIVE_HIGH>;
+ slot@0 {
+ reg = <0>;
+ bus-width = <4>;
+ cd-gpios = <&pioE 18 GPIO_ACTIVE_HIGH>;
+ wp-gpios = <&pioE 19 GPIO_ACTIVE_HIGH>;
+ };
+};
+
+&pinctrl {
+ mmc1 {
+ pinctrl_board_mmc1: mmc1-board {
+ atmel,pins =
+ <AT91_PIOE 18 AT91_PERIPH_GPIO
+ AT91_PINCTRL_PULL_UP_DEGLITCH /* PE18 gpio CD pin pull up and deglitch */
+ AT91_PIOE 19 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP>; /* PE19 gpio WP pin pull up */
+ };
+ };
+
+ display_type_inputs {
+ pinctrl_disp_type: disp_type-0 {
+ /* Pull-up (HIGH) if Seiko display, otherwise Logic display */
+ atmel,pins =
+ <AT91_PIOD 2 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP>;
+ };
+ pinctrl_logic_type: logic_type-0 {
+ /* Pull-down (LOW) if l6whrt display, otherwise l2rt display */
+ atmel,pins =
+ <AT91_PIOC 28 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP>;
+ };
+ };
+
+ fb {
+ pinctrl_board_fb: fb-0 {
+ atmel,pins =
+ <AT91_PIOC 0 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDVSYNC */
+ AT91_PIOC 1 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDHSYNC */
+ AT91_PIOC 2 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDDOTCK */
+ AT91_PIOC 3 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDDEN */
+ AT91_PIOB 9 AT91_PERIPH_B AT91_PINCTRL_NONE /* LCDCC */
+ AT91_PIOC 6 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD2 */
+ AT91_PIOC 7 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD3 */
+ AT91_PIOC 8 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD4 */
+ AT91_PIOC 9 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD5 */
+ AT91_PIOC 10 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD6 */
+ AT91_PIOC 11 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD7 */
+ AT91_PIOC 14 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD10 */
+ AT91_PIOC 15 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD11 */
+ AT91_PIOC 16 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD12 */
+ AT91_PIOC 12 AT91_PERIPH_B AT91_PINCTRL_NONE /* LCDD13 */
+ AT91_PIOC 18 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD14 */
+ AT91_PIOC 19 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD15 */
+ AT91_PIOC 22 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD18 */
+ AT91_PIOC 23 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD19 */
+ AT91_PIOC 24 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD20 */
+ AT91_PIOC 17 AT91_PERIPH_B AT91_PINCTRL_NONE /* LCDD21 */
+ AT91_PIOC 26 AT91_PERIPH_A AT91_PINCTRL_NONE /* LCDD22 */
+ AT91_PIOC 27 AT91_PERIPH_A AT91_PINCTRL_NONE>; /* LCDD23 */
+ };
+ };
+
+ pwm0 {
+ pinctrl_pwm0: pwm0_pwm1 {
+ atmel,pins = <AT91_PIOB 8 AT91_PERIPH_B AT91_PINCTRL_NONE>;
+ };
+ };
+};
+
+&pwm0 {
+ status = "okay";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_pwm0>;
+};
+
+&slow_xtal {
+ clock-frequency = <32768>;
+};
+
+&spi0 {
+ status = "okay";
+ cs-gpios = <&pioA 3 0>, <&pioB 11 0>;
+
+ mcp3002@0 {
+ compatible = "microchip,mcp3002";
+ reg = <0>;
+ spi-max-frequency = <750000>;
+ };
+
+ tsc2046@1 {
+ compatible = "ti,tsc2046";
+ reg = <1>;
+ interrupts-extended = <&pioA 15 IRQ_TYPE_EDGE_BOTH>;
+ spi-max-frequency = <500000>;
+ pendown-gpio = <&pioA 15 GPIO_ACTIVE_LOW>;
+
+ ti,x-min = /bits/ 16 <800>;
+ ti,x-max = /bits/ 16 <3830>;
+ ti,y-min = /bits/ 16 <500>;
+ ti,y-max = /bits/ 16 <3830>;
+ ti,vref-delay-usecs = /bits/ 16 <300>;
+ ti,x-plate-ohms = /bits/ 16 <642>;
+ ti,y-plate-ohms = /bits/ 16 <295>;
+ ti,pressure-max = /bits/ 16 <1500>;
+ ti,debounce-rep = /bits/ 16 <8>;
+ ti,debounce-tol = /bits/ 16 <(~0)>;
+ ti,debounce-max = /bits/ 16 <100>;
+
+ wakeup-source;
+ };
+};
+
+&usart0 {
+ status = "okay";
+ pinctrl-0 = <
+ &pinctrl_usart0
+ &pinctrl_usart0_rts
+ &pinctrl_usart0_cts>;
+};
+
+&usb0 {
+ status = "okay";
+ num-ports = <2>;
+};
diff --git a/arch/arm/dts/imx6dl-skov-imx6.dts b/arch/arm/dts/imx6dl-skov-imx6.dts
new file mode 100644
index 0000000000..c2dac68204
--- /dev/null
+++ b/arch/arm/dts/imx6dl-skov-imx6.dts
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 Juergen Borleis, Pengutronix <kernel@pengutronix.de>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include <arm/imx6dl.dtsi>
+#include "imx6dl.dtsi"
+#include "imx6qdl-skov-imx6.dtsi"
+
+/ {
+ model = "Skov IMX6";
+ compatible = "skov,imx6", "fsl,imx6dl";
+
+ chosen {
+ stdout-path = &uart2;
+ };
+};
diff --git a/arch/arm/dts/imx6q-skov-imx6.dts b/arch/arm/dts/imx6q-skov-imx6.dts
new file mode 100644
index 0000000000..fea84cb498
--- /dev/null
+++ b/arch/arm/dts/imx6q-skov-imx6.dts
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2015 Juergen Borleis, Pengutronix <kernel@pengutronix.de>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+/dts-v1/;
+#include <arm/imx6q.dtsi>
+#include "imx6q.dtsi"
+#include "imx6qdl-skov-imx6.dtsi"
+
+/ {
+ model = "Skov IMX6";
+ compatible = "skov,imx6", "fsl,imx6q";
+
+ chosen {
+ stdout-path = &uart2;
+ };
+};
+
+&i2c2 {
+ status = "okay";
+};
diff --git a/arch/arm/dts/imx6qdl-skov-imx6.dtsi b/arch/arm/dts/imx6qdl-skov-imx6.dtsi
new file mode 100644
index 0000000000..03f3cb02fc
--- /dev/null
+++ b/arch/arm/dts/imx6qdl-skov-imx6.dtsi
@@ -0,0 +1,546 @@
+/*
+ * Copyright 2015 Juergen Borleis, Pengutronix <kernel@pengutronix.de>
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+ aliases {
+ state = &state;
+ };
+
+ chosen {
+ environment-sd {
+ compatible = "barebox,environment";
+ device-path = &usdhc3, "partname:2";
+ status = "disabled";
+ };
+
+ environment-spinor {
+ compatible = "barebox,environment";
+ device-path = &barebox_env;
+ status = "disabled";
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led0: D1 {
+ label = "D1";
+ gpios = <&gpio1 2 0>;
+ default-state = "on";
+ linux,default-trigger = "heartbeat";
+ };
+
+ led1: D2 {
+ label = "D2";
+ gpios = <&gpio1 0 0>;
+ default-state = "off";
+ };
+
+ led2: D3 {
+ label = "D3";
+ gpios = <&gpio1 4 0>;
+ default-state = "on";
+ };
+ };
+
+ /* State: mutable part */
+ state: state {
+ magic = <0x34a0fc27>;
+ compatible = "barebox,state";
+ backend-type = "raw";
+ backend = <&state_storage>;
+ backend-stridesize = <0x40>;
+
+ bootstate {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ system0 { /* the node's name here must match the subnode's name in the 'bootstate' node */
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts@0 {
+ reg = <0x0 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+ priority@4 {
+ reg = <0x4 0x4>;
+ type = "uint32";
+ default = <30>;
+ };
+ };
+
+ system1 { /* the node's name here must match the subnode's name in the 'bootstate' node */
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts@8 {
+ reg = <0x8 0x4>;
+ type = "uint32";
+ default = <3>;
+ };
+ priority@C {
+ reg = <0xC 0x4>;
+ type = "uint32";
+ default = <20>;
+ };
+ };
+
+ last_chosen@10 {
+ reg = <0x10 0x4>;
+ type = "uint32";
+ };
+ };
+
+ display {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ xres@14 {
+ reg = <0x14 0x4>;
+ type = "uint32";
+ default = <0>;
+ };
+
+ yres@18 {
+ reg = <0x18 0x4>;
+ type = "uint32";
+ default = <0>;
+ };
+
+ brightness@1C {
+ reg = <0x1C 0x1>;
+ type = "uint8";
+ default = <8>;
+ };
+
+ external@1D {
+ reg = <0x1D 0x1>;
+ type = "uint8";
+ default = <0>;
+ };
+ };
+
+ ethaddr {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ eth2 {
+ reg = <0x1E 0x6>;
+ type = "mac";
+ default = [00 11 22 33 44 55];
+ };
+ };
+ };
+
+ backlight_lcd: backlight_lcd {
+ compatible = "pwm-backlight";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_backlight>;
+ pwms = <&pwm2 0 20000 0>;
+ brightness-levels = <0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 255>;
+ default-brightness-level = <8>;
+ enable-gpios = <&gpio6 23 GPIO_ACTIVE_LOW>;
+ status = "okay";
+ };
+
+ display {
+ status = "disabled";
+ compatible = "fsl,imx-parallel-display";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_ipu1_4>;
+ interface-pix-fmt = "rgb24";
+
+ port {
+ display0_in: endpoint {
+ remote-endpoint = <&ipu1_di0_disp0>;
+ };
+ };
+
+ display-timings {
+ native-mode = &l2rt;
+
+ l2rt: l2rt {
+ native-mode;
+ clock-frequency = <33000000>;
+ hactive = <800>;
+ vactive = <480>;
+ hback-porch = <85>;
+ hfront-porch = <112>;
+ vback-porch = <29>;
+ vfront-porch = <38>;
+ hsync-len = <3>;
+ vsync-len = <3>;
+ pixelclk-active = <1>;
+ hsync-active = <0>;
+ vsync-active = <0>;
+ de-active = <1>;
+ };
+
+ l6whrt: l6whrt {
+ native-mode;
+ clock-frequency = <33000000>;
+ hactive = <800>;
+ vactive = <480>;
+ hback-porch = <43>;
+ hfront-porch = <154>;
+ vback-porch = <20>;
+ vfront-porch = <47>;
+ hsync-len = <3>;
+ vsync-len = <3>;
+ pixelclk-active = <1>;
+ hsync-active = <0>;
+ vsync-active = <0>;
+ de-active = <1>;
+ };
+ };
+ };
+
+ panel {
+ compatible = "simple-panel";
+ backlight = <&backlight_lcd>;
+ /* power-supply = <&reg_3p3v>; */
+
+ display-timings {
+ native-mode = &mi1010ait_1cp1;
+
+ mi1010ait_1cp1: mi1010ait-1cp1 {
+ native-mode;
+ clock-frequency = <70000000>;
+ hactive = <1280>;
+ vactive = <800>;
+ hback-porch = <60>;
+ hfront-porch = <60>;
+ vback-porch = <10>;
+ vfront-porch = <10>;
+ hsync-len = <10>;
+ vsync-len = <6>;
+ /* pixelclk-active = <>; */
+ hsync-active = <0>;
+ vsync-active = <0>;
+ de-active = <1>;
+ };
+ };
+
+ port {
+ panel_in: endpoint {
+ remote-endpoint = <&lvds0_out>;
+ };
+ };
+ };
+};
+
+&pwm2 {
+ /* used for backlight brightness */
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_pwm2_2>;
+ status = "okay";
+};
+
+&pwm3 {
+ /* used for LCD contrast control */
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_pwm3_2>;
+ status = "okay";
+};
+
+&i2c2 {
+ clock-frequency = <100000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_i2c2_2>;
+};
+
+&hdmi {
+ status = "okay";
+ ddc-i2c-bus = <&i2c2>;
+};
+
+/delete-node/&ipu1_di0_hdmi;
+/delete-node/&hdmi_mux_0;
+
+&ipu1_di0_disp0 {
+ remote-endpoint = <&display0_in>;
+};
+
+&iomuxc {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_hog>;
+
+ pinctrl_hog: hoggrp {
+ /* we need a few pins as GPIOs */
+ fsl,pins = <
+ /* MMC IO voltage select */
+ MX6QDL_PAD_GPIO_18__GPIO7_IO13 0x40000058
+ /* MMC Power Supply Switch (since revision C)
+ MX6QDL_PAD_SD3_RST__GPIO7_IO08 0x40000058
+ /* Backlight Power Supply Switch (since revision B)
+ MX6QDL_PAD_RGMII_TD3__GPIO6_IO23 0x40000058
+ /* Backlight Brightness */
+ MX6QDL_PAD_GPIO_1__GPIO1_IO01 0x40000058
+ /* must be high */
+ MX6QDL_PAD_ENET_RX_ER__GPIO1_IO24 0x40000058
+ >;
+ };
+
+ pinctrl_uart2: uart2grp {
+ fsl,pins = <
+ MX6QDL_PAD_EIM_D26__UART2_TX_DATA 0x1b0b1
+ MX6QDL_PAD_EIM_D27__UART2_RX_DATA 0x1b0b1
+ >;
+ };
+
+ pinctrl_ecspi1: ecspi1grp {
+ fsl,pins = <
+ MX6QDL_PAD_EIM_D17__ECSPI1_MISO 0x100b1
+ MX6QDL_PAD_EIM_D18__ECSPI1_MOSI 0x100b1
+ MX6QDL_PAD_EIM_D16__ECSPI1_SCLK 0x100b1
+ MX6QDL_PAD_EIM_D24__GPIO3_IO24 0x40000058 /* CS# signal */
+ >;
+ };
+
+ /* pins for eth0 */
+ pinctrl_enet: enetgrp {
+ fsl,pins = <
+ MX6QDL_PAD_ENET_MDIO__ENET_MDIO 0x100b0
+ MX6QDL_PAD_ENET_MDC__ENET_MDC 0x100b0
+ MX6QDL_PAD_ENET_CRS_DV__ENET_RX_EN 0x100b0
+ MX6QDL_PAD_ENET_TX_EN__ENET_TX_EN 0x100b0
+ MX6QDL_PAD_ENET_RXD0__ENET_RX_DATA0 0x100b0
+ MX6QDL_PAD_ENET_RXD1__ENET_RX_DATA1 0x100b0
+ MX6QDL_PAD_ENET_TXD0__ENET_TX_DATA0 0x100b0
+ MX6QDL_PAD_ENET_TXD1__ENET_TX_DATA1 0x100b0
+ MX6QDL_PAD_GPIO_16__ENET_REF_CLK 0x400000c0
+ >;
+ };
+
+ pinctrl_usdhc3: usdhc3grp {
+ fsl,pins = <
+ MX6QDL_PAD_SD3_CMD__SD3_CMD 0x17059
+ MX6QDL_PAD_SD3_CLK__SD3_CLK 0x10059
+ MX6QDL_PAD_SD3_DAT0__SD3_DATA0 0x17059
+ MX6QDL_PAD_SD3_DAT1__SD3_DATA1 0x17059
+ MX6QDL_PAD_SD3_DAT2__SD3_DATA2 0x17059
+ MX6QDL_PAD_SD3_DAT3__SD3_DATA3 0x17059
+ MX6QDL_PAD_SD3_DAT4__GPIO7_IO01 0x1b040 /* WP */
+ MX6QDL_PAD_SD3_DAT5__GPIO7_IO00 0x1b040 /* CD */
+ >;
+ };
+
+ pinctrl_gpmi_nand: gpminandgrp {
+ fsl,pins = <
+ MX6QDL_PAD_NANDF_CLE__NAND_CLE 0xb0b1
+ MX6QDL_PAD_NANDF_ALE__NAND_ALE 0xb0b1
+ MX6QDL_PAD_NANDF_RB0__NAND_READY_B 0xb000
+ MX6QDL_PAD_NANDF_CS0__NAND_CE0_B 0xb0b1
+ MX6QDL_PAD_NANDF_CS1__NAND_CE1_B 0xb0b1
+ MX6QDL_PAD_SD4_CMD__NAND_RE_B 0xb0b1
+ MX6QDL_PAD_SD4_CLK__NAND_WE_B 0xb0b1
+ MX6QDL_PAD_NANDF_D0__NAND_DATA00 0xb0b1
+ MX6QDL_PAD_NANDF_D1__NAND_DATA01 0xb0b1
+ MX6QDL_PAD_NANDF_D2__NAND_DATA02 0xb0b1
+ MX6QDL_PAD_NANDF_D3__NAND_DATA03 0xb0b1
+ MX6QDL_PAD_NANDF_D4__NAND_DATA04 0xb0b1
+ MX6QDL_PAD_NANDF_D5__NAND_DATA05 0xb0b1
+ MX6QDL_PAD_NANDF_D6__NAND_DATA06 0xb0b1
+ MX6QDL_PAD_NANDF_D7__NAND_DATA07 0xb0b1
+ >;
+ };
+
+ pinctrl_i2c2_2: i2c2grp-2 {
+ fsl,pins = <
+ /* internal 22 k pull up required */
+ MX6QDL_PAD_KEY_COL3__I2C2_SCL 0x4001F878
+ /* internal 22 k pull up required */
+ MX6QDL_PAD_KEY_ROW3__I2C2_SDA 0x4001F878
+ >;
+ };
+
+ pinctrl_ipu1_4: ipu1grp-4 {
+ fsl,pins = <
+ MX6QDL_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK 0x10
+ MX6QDL_PAD_DI0_PIN15__IPU1_DI0_PIN15 0x10
+ MX6QDL_PAD_DI0_PIN2__IPU1_DI0_PIN02 0x10
+ MX6QDL_PAD_DI0_PIN3__IPU1_DI0_PIN03 0x10
+ MX6QDL_PAD_DISP0_DAT0__IPU1_DISP0_DATA00 0x10
+ MX6QDL_PAD_DISP0_DAT1__IPU1_DISP0_DATA01 0x10
+ MX6QDL_PAD_DISP0_DAT2__IPU1_DISP0_DATA02 0x10
+ MX6QDL_PAD_DISP0_DAT3__IPU1_DISP0_DATA03 0x10
+ MX6QDL_PAD_DISP0_DAT4__IPU1_DISP0_DATA04 0x10
+ MX6QDL_PAD_DISP0_DAT5__IPU1_DISP0_DATA05 0x10
+ MX6QDL_PAD_DISP0_DAT6__IPU1_DISP0_DATA06 0x10
+ MX6QDL_PAD_DISP0_DAT7__IPU1_DISP0_DATA07 0x10
+ MX6QDL_PAD_DISP0_DAT8__IPU1_DISP0_DATA08 0x10
+ MX6QDL_PAD_DISP0_DAT9__IPU1_DISP0_DATA09 0x10
+ MX6QDL_PAD_DISP0_DAT10__IPU1_DISP0_DATA10 0x10
+ MX6QDL_PAD_DISP0_DAT11__IPU1_DISP0_DATA11 0x10
+ MX6QDL_PAD_DISP0_DAT12__IPU1_DISP0_DATA12 0x10
+ MX6QDL_PAD_DISP0_DAT13__IPU1_DISP0_DATA13 0x10
+ MX6QDL_PAD_DISP0_DAT14__IPU1_DISP0_DATA14 0x10
+ MX6QDL_PAD_DISP0_DAT15__IPU1_DISP0_DATA15 0x10
+ MX6QDL_PAD_DISP0_DAT16__IPU1_DISP0_DATA16 0x10
+ MX6QDL_PAD_DISP0_DAT17__IPU1_DISP0_DATA17 0x10
+ MX6QDL_PAD_DISP0_DAT18__IPU1_DISP0_DATA18 0x10
+ MX6QDL_PAD_DISP0_DAT19__IPU1_DISP0_DATA19 0x10
+ MX6QDL_PAD_DISP0_DAT20__IPU1_DISP0_DATA20 0x10
+ MX6QDL_PAD_DISP0_DAT21__IPU1_DISP0_DATA21 0x10
+ MX6QDL_PAD_DISP0_DAT22__IPU1_DISP0_DATA22 0x10
+ MX6QDL_PAD_DISP0_DAT23__IPU1_DISP0_DATA23 0x10
+ >;
+ };
+
+ pinctrl_backlight: backlight_grp {
+ fsl,pins = <
+ MX6QDL_PAD_RGMII_TD3__GPIO6_IO23 0x40000058
+ >;
+ };
+
+ pinctrl_pwm2_2: pwm2grp-2 {
+ fsl,pins = <
+ MX6QDL_PAD_GPIO_1__PWM2_OUT 0x00058
+ >;
+ };
+
+ pinctrl_pwm3_2: pwm3grp-2 {
+ fsl,pins = <
+ MX6QDL_PAD_SD1_DAT1__PWM3_OUT 0x00058
+ >;
+ };
+};
+
+&clks {
+ assigned-clocks = <&clks IMX6QDL_CLK_LDB_DI0_SEL>,
+ <&clks IMX6QDL_CLK_LDB_DI1_SEL>;
+ assigned-clock-parents = <&clks IMX6QDL_CLK_PLL5_VIDEO_DIV>,
+ <&clks IMX6QDL_CLK_PLL5_VIDEO_DIV>;
+};
+
+/* console */
+&uart2 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_uart2>;
+ status = "okay";
+};
+
+/* spi */
+&ecspi1 {
+ fsl,spi-num-chipselects = <1>;
+ cs-gpios = <&gpio3 24 0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_ecspi1>;
+ status = "okay";
+
+ norflash: m25p80@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "jedec,spi-nor";
+ spi-max-frequency = <54000000>;
+ reg = <0>;
+ };
+};
+
+/* eth0 */
+&fec {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_enet>;
+ phy-mode = "rmii";
+ status = "okay";
+ phy-reset-gpios = <&gpio1 5 0>;
+ phy-reset-duration = <100>;
+ #address-cells = <0>;
+ #size-cells = <1>;
+ fixed-link {
+ speed = <100>;
+ full-duplex;
+ };
+};
+
+&ldb {
+ status = "disabled";
+
+ lvds0: lvds-channel@0 {
+ status = "disabled";
+ fsl,data-width = <24>;
+ fsl,data-mapping = "spwg";
+
+ port@4 {
+ reg = <4>;
+ lvds0_out: endpoint {
+ remote-endpoint = <&panel_in>;
+ };
+ };
+ };
+};
+
+&wdog1 {
+ status = "okay";
+};
+
+&usdhc3 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_usdhc3>;
+ wp-gpios = <&gpio7 1 0>;
+ cd-gpios = <&gpio7 0 0>;
+ status = "okay";
+ fsl,delay-line;
+};
+
+&gpmi {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_gpmi_nand>;
+ nand-on-flash-bbt;
+ status = "okay";
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "firmware";
+ reg = <0x00000000 0x000000000>; /* keep zero sized to enable autodetection */
+ };
+ };
+};
+
+/* define the SPI based 8 MiB NOR flash layout */
+&norflash {
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "barebox";
+ reg = <0x0 0x100000>;
+ };
+
+ /* space left to let barebox grow */
+
+ /* placed near the end of the NOR memory */
+ barebox_env: partition@780000 {
+ label = "barebox-environment";
+ reg = <0x780000 0x40000>;
+ };
+
+ /* placed at the end of the NOR memory */
+ state_storage: partition@7C0000 {
+ label = "barebox-state";
+ reg = <0x7C0000 0x40000>; /* four times mirrored */
+ };
+ };
+};
+
+&ocotp {
+ barebox,provide-mac-address = <&fec 0x620>;
+};
diff --git a/arch/arm/dts/imx7d-flex-concentrator-mfg.dts b/arch/arm/dts/imx7d-flex-concentrator-mfg.dts
new file mode 100644
index 0000000000..d174ef7250
--- /dev/null
+++ b/arch/arm/dts/imx7d-flex-concentrator-mfg.dts
@@ -0,0 +1,108 @@
+/*
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include <arm/imx7d-flex-concentrator-mfg.dts>
+
+/ {
+ chosen {
+ environment {
+ compatible = "barebox,environment";
+ device-path = &environment_emmc;
+ };
+ };
+
+ aliases {
+ state = &state_emmc;
+ };
+
+ state_emmc: state {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "barebox,state";
+ magic = <0x4b414d31>;
+ backend-type = "raw";
+ backend = <&backend_state_emmc>;
+ backend-stridesize = <0x200>;
+
+ bootstate {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ system0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts@0 {
+ reg = <0x0 0x4>;
+ type = "uint32";
+ default = <10>;
+ };
+
+ priority@4 {
+ reg = <0x4 0x4>;
+ type = "uint32";
+ default = <21>;
+ };
+ };
+
+ system1 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ remaining_attempts@8 {
+ reg = <0x8 0x4>;
+ type = "uint32";
+ default = <0>;
+ };
+
+ priority@c {
+ reg = <0xc 0x4>;
+ type = "uint32";
+ default = <20>;
+ };
+ };
+
+ last_chosen@10 {
+ reg = <0x10 0x4>;
+ type = "uint32";
+ };
+ };
+ };
+};
+
+/* eMMC */
+&usdhc3 {
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "barebox";
+ reg = <0x0 0x100000>;
+ };
+
+ environment_emmc: partition@100000 {
+ label = "barebox-environment";
+ reg = <0x100000 0x100000>;
+ };
+
+ backend_state_emmc: partition@200000 {
+ label = "barebox-state";
+ reg = <0x200000 0x100000>;
+ };
+ };
+};
+
+/* FIXME: barebox serial is broken when barebox applies requested reparenting */
+&uart4 {
+ /delete-property/ assigned-clocks;
+ /delete-property/ assigned-clock-parents;
+};
+
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 52eefc7361..810c00d495 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -577,6 +577,17 @@ config AT91_MULTI_BOARDS
if AT91_MULTI_BOARDS
+config MACH_SKOV_ARM9CPU
+ bool "SKOV ARM9 CPU"
+ select SOC_AT91SAM9263
+ select OFDEVICE
+ select COMMON_CLK_OF_PROVIDER
+ select HAVE_AT91_USB_CLK
+ select HAVE_AT91_BOOTSTRAP
+ select AT91SAM926X_BOARD_INIT
+ help
+ Say y here if you are using SKOV's ARM9 CPU board
+
config MACH_AT91SAM9263EK
bool "Atmel AT91SAM9263-EK"
select SOC_AT91SAM9263
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 3f8012c732..38aee42bf2 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -526,6 +526,11 @@ config MACH_FREESCALE_MX7_SABRESD
https://goo.gl/6EKGdk
+config MACH_KAMSTRUP_MX7_CONCENTRATOR
+ bool "Kamstrup i.MX7 Concentrator"
+ select ARCH_IMX7
+ select ARM_USE_COMPRESSED_DTB
+
config MACH_NXP_IMX6ULL_EVK
bool "NXP i.MX6ull EVK Board"
select ARCH_IMX6UL
@@ -592,6 +597,12 @@ config MACH_MNT_REFORM
select MCI_IMX_ESDHC_PBL
select I2C_IMX_EARLY
+config MACH_SKOV_IMX6
+ bool "Skov IMX6"
+ select ARCH_IMX6
+ select ARM_USE_COMPRESSED_DTB
+ select MCI_IMX_ESDHC_PBL
+
endif
# ----------------------------------------------------------
diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
index c3cf4b85ff..e9b5a49443 100644
--- a/arch/arm/mach-imx/boot.c
+++ b/arch/arm/mach-imx/boot.c
@@ -506,6 +506,9 @@ static void __imx7_get_boot_source(enum bootsource *src, int *instance,
case 5:
*src = BOOTSOURCE_NOR;
break;
+ case 15:
+ *src = BOOTSOURCE_SERIAL;
+ break;
default:
break;
}
diff --git a/arch/arm/mach-imx/include/mach/imx-gpio.h b/arch/arm/mach-imx/include/mach/imx-gpio.h
index 0cfd16f4fa..64ac278d61 100644
--- a/arch/arm/mach-imx/include/mach/imx-gpio.h
+++ b/arch/arm/mach-imx/include/mach/imx-gpio.h
@@ -32,7 +32,7 @@ static inline void imx_gpio_direction(void __iomem *gdir, void __iomem *dr,
writel(val, dr);
}
-static inline void imx1_gpio_direction_output(void *base, int gpio, int value)
+static inline void imx1_gpio_direction_output(void __iomem *base, int gpio, int value)
{
imx_gpio_direction(base + 0x0, base + 0x1c, gpio, 1, value);
}
@@ -40,7 +40,7 @@ static inline void imx1_gpio_direction_output(void *base, int gpio, int value)
#define imx21_gpio_direction_output(base, gpio, value) imx1_gpio_direction_output(base, gpio,value)
#define imx27_gpio_direction_output(base, gpio, value) imx1_gpio_direction_output(base, gpio,value)
-static inline void imx31_gpio_direction_output(void *base, int gpio, int value)
+static inline void imx31_gpio_direction_output(void __iomem *base, int gpio, int value)
{
imx_gpio_direction(base + 0x4, base + 0x0, gpio, 1, value);
}
@@ -52,7 +52,7 @@ static inline void imx31_gpio_direction_output(void *base, int gpio, int value)
#define imx6_gpio_direction_output(base, gpio, value) imx31_gpio_direction_output(base, gpio,value)
#define imx8m_gpio_direction_output(base, gpio, value) imx31_gpio_direction_output(base, gpio,value)
-static inline void imx1_gpio_direction_input(void *base, int gpio, int value)
+static inline void imx1_gpio_direction_input(void __iomem *base, int gpio, int value)
{
imx_gpio_direction(base + 0x0, base + 0x1c, gpio, 0, 0);
}
@@ -60,7 +60,7 @@ static inline void imx1_gpio_direction_input(void *base, int gpio, int value)
#define imx21_gpio_direction_input(base, gpio, value) imx1_gpio_direction_input(base, gpio)
#define imx27_gpio_direction_input(base, gpio, value) imx1_gpio_direction_input(base, gpio)
-static inline void imx31_gpio_direction_input(void *base, int gpio)
+static inline void imx31_gpio_direction_input(void __iomem *base, int gpio)
{
imx_gpio_direction(base + 0x4, base + 0x0, gpio, 0, 0);
}
@@ -72,11 +72,18 @@ static inline void imx31_gpio_direction_input(void *base, int gpio)
#define imx6_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
#define imx8m_gpio_direction_input(base, gpio) imx31_gpio_direction_input(base, gpio)
-#define imx1_gpio_val(base, gpio) readl(base + 0x1c) & (1 << gpio) ? 1 : 0
+static inline int imx1_gpio_val(void __iomem *base, int gpio)
+{
+ return readl(base + 0x1c) & (1 << gpio) ? 1 : 0;
+}
+
+static inline int imx31_gpio_val(void __iomem *base, int gpio)
+{
+ return readl(base) & (1 << gpio) ? 1 : 0;
+}
+
#define imx21_gpio_val(base, gpio) imx1_gpio_val(base, gpio)
#define imx27_gpio_val(base, gpio) imx1_gpio_val(base, gpio)
-
-#define imx31_gpio_val(base, gpio) readl(base) & (1 << gpio) ? 1 : 0
#define imx25_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
#define imx35_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
#define imx51_gpio_val(base, gpio) imx31_gpio_val(base, gpio)
diff --git a/arch/riscv/boot/uncompress.c b/arch/riscv/boot/uncompress.c
index 411cefb0e3..b4e010998a 100644
--- a/arch/riscv/boot/uncompress.c
+++ b/arch/riscv/boot/uncompress.c
@@ -32,8 +32,11 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
void *pg_start, *pg_end;
unsigned long pc = get_pc();
+ /* piggy data is not relocated, so determine the bounds now */
pg_start = input_data + get_runtime_offset();
pg_end = input_data_end + get_runtime_offset();
+ pg_len = pg_end - pg_start;
+ uncompressed_len = input_data_len();
/*
* If we run from inside the memory just relocate the binary
@@ -45,9 +48,6 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
else
relocate_to_adr(membase);
- pg_len = pg_end - pg_start;
- uncompressed_len = input_data_len();
-
barebox_base = riscv_mem_barebox_image(membase, endmem,
uncompressed_len + MAX_BSS_SIZE);
diff --git a/arch/riscv/dts/erizo.dtsi b/arch/riscv/dts/erizo.dtsi
index e854a48ae5..228711bd69 100644
--- a/arch/riscv/dts/erizo.dtsi
+++ b/arch/riscv/dts/erizo.dtsi
@@ -20,6 +20,8 @@
#address-cells = <1>;
#size-cells = <0>;
+ timebase-frequency = <24000000>;
+
cpu@0 {
device_type = "cpu";
compatible = "cliffordwolf,picorv32", "riscv";
diff --git a/arch/riscv/include/asm/sections.h b/arch/riscv/include/asm/sections.h
index 725fd8db47..6673648bcd 100644
--- a/arch/riscv/include/asm/sections.h
+++ b/arch/riscv/include/asm/sections.h
@@ -15,9 +15,11 @@ extern char __dynsym_end[];
extern char input_data[];
extern char input_data_end[];
+unsigned long get_runtime_offset(void);
+
static inline unsigned int input_data_len(void)
{
- return get_unaligned((const u32 *)(input_data_end - 4));
+ return get_unaligned((const u32 *)(input_data_end + get_runtime_offset() - 4));
}
#endif
diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
index a9bf68bca5..a4eaa1005d 100644
--- a/arch/riscv/lib/Makefile
+++ b/arch/riscv/lib/Makefile
@@ -2,7 +2,7 @@
extra-y += barebox.lds
-obj-y += riscv_timer.o dtb.o
+obj-y += dtb.o
obj-pbl-y += sections.o setupc.o reloc.o sections.o runtime-offset.o
obj-$(CONFIG_HAS_ARCH_SJLJ) += setjmp.o longjmp.o
obj-$(CONFIG_RISCV_OPTIMZED_STRING_FUNCTIONS) += memcpy.o memset.o memmove.o
diff --git a/arch/riscv/lib/riscv_timer.c b/arch/riscv/lib/riscv_timer.c
deleted file mode 100644
index 919d77d4b5..0000000000
--- a/arch/riscv/lib/riscv_timer.c
+++ /dev/null
@@ -1,63 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (C) 2017 Antony Pavlov <antonynpavlov@gmail.com>
- *
- * This file is part of barebox.
- *
- * 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.
- *
- */
-
-/**
- * @file
- * @brief Clocksource based on RISC-V cycle CSR timer
- */
-
-#include <init.h>
-#include <of.h>
-#include <linux/clk.h>
-#include <clock.h>
-
-static uint64_t rdcycle_read(void)
-{
- register unsigned long __v;
-
- __asm__ __volatile__ ("rdcycle %0" : "=r" (__v));
-
- return __v;
-}
-
-static struct clocksource rdcycle_cs = {
- .read = rdcycle_read,
- .mask = CLOCKSOURCE_MASK(32),
-};
-
-static int rdcycle_cs_init(void)
-{
- unsigned int cycle_frequency;
-
- /* default rate: 100 MHz */
- cycle_frequency = 100000000;
-
- if (IS_ENABLED(CONFIG_OFTREE)) {
- struct device_node *np;
- struct clk *clk;
-
- np = of_get_cpu_node(0, NULL);
- if (np) {
- clk = of_clk_get(np, 0);
- if (!IS_ERR(clk)) {
- cycle_frequency = clk_get_rate(clk);
- }
- }
- }
-
- clocks_calc_mult_shift(&rdcycle_cs.mult, &rdcycle_cs.shift,
- cycle_frequency, NSEC_PER_SEC, 10);
-
- return init_clock(&rdcycle_cs);
-}
-postcore_initcall(rdcycle_cs_init);
diff --git a/arch/sandbox/board/env/init/state b/arch/sandbox/board/env/init/state
index 0b8e40409f..b8a2b42a53 100644
--- a/arch/sandbox/board/env/init/state
+++ b/arch/sandbox/board/env/init/state
@@ -5,8 +5,9 @@ fi
source /env/data/ansi-colors
echo -e $CYAN
-echo "******************************************************************"
-echo "*** Inconsistent barebox state buckets detected on first boot ***"
-echo "*** barebox will repair them on next shutdown ***"
-echo "*****************************************************************"
+echo "*******************************************************"
+echo "*** Inconsistent barebox state buckets detected ***"
+echo "*** This is normal for a first boot ***"
+echo "*** barebox will repair them on next poweroff/reset ***"
+echo "*******************************************************"
echo -e -n $NC
diff --git a/arch/sandbox/board/env/nv/autoboot b/arch/sandbox/board/env/nv/autoboot
new file mode 100644
index 0000000000..f7d13fd046
--- /dev/null
+++ b/arch/sandbox/board/env/nv/autoboot
@@ -0,0 +1 @@
+abort
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index e942c79cbd..311c3d1a8e 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -9,17 +9,7 @@ config X86
config ARCH_TEXT_BASE
hex
- default 0x00007c00 if MACH_X86_GENERIC
- default 0x0 if MACH_EFI_GENERIC
-
-config BOARD_LINKER_SCRIPT
- bool
- default n
-
-config GENERIC_LINKER_SCRIPT
- bool
- default y
- depends on !BOARD_LINKER_SCRIPT
+ default 0x0
menu "ARCH specific settings"
@@ -45,51 +35,18 @@ config X86_64
endmenu
-config X86_BOOTLOADER
- bool
- select X86_32
- select HAS_MODULES
- select HAVE_CONFIGURABLE_MEMORY_LAYOUT
- select HAVE_CONFIGURABLE_TEXT_BASE
-
-choice
- prompt "Select your board"
-
-config MACH_X86_GENERIC
- bool "Generic x86"
- select X86_BOOTLOADER
- depends on !X86_EFI
- help
- Say Y here if you want barebox to be your BIOS based bootloader
-
config MACH_EFI_GENERIC
- bool "Generic EFI"
- depends on X86_EFI
+ def_bool y
+ depends on X86_EFI
select HAS_DEBUG_LL
help
Say Y here if you want barebox to be your EFI based bootloader
-endchoice
-
-choice
- prompt "Bring up type"
- config X86_EFI
- bool "EFI"
- select EFI_BOOTUP
- select EFI_GUID
- select EFI_DEVICEPATH
- select PRINTF_UUID
- select CLOCKSOURCE_EFI_X86
-
- config X86_BIOS_BRINGUP
- bool "16 bit BIOS"
- help
- Barebox will act as a BIOS based bootloader. This includes
- some 16 bit real mode code and some restrictions everyone knows
- from BIOS based systems.
-
-endchoice
-
-source "arch/x86/boot/Kconfig"
-source "arch/x86/mach-i386/Kconfig"
+config X86_EFI
+ def_bool y
+ select EFI_BOOTUP
+ select EFI_GUID
+ select EFI_DEVICEPATH
+ select PRINTF_UUID
+ select CLOCKSOURCE_EFI_X86
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 61e51abc71..fd871ca214 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -1,12 +1,9 @@
-KBUILD_DEFCONFIG := generic_defconfig
+KBUILD_DEFCONFIG := efi_defconfig
KBUILD_CPPFLAGS += -D__X86__
-board-$(CONFIG_MACH_X86_GENERIC) := x86_generic
-
TEXT_BASE = $(CONFIG_TEXT_BASE)
-ifeq ($(CONFIG_X86_EFI),y)
machine-y := efi
KBUILD_CFLAGS += -fpic -fshort-wchar -mno-sse -mno-mmx
ifeq ($(CONFIG_X86_32),y)
@@ -14,13 +11,6 @@ ifeq ($(CONFIG_X86_32),y)
else
TARGET = efi-app-x86_64
endif
-else
-KBUILD_CPPFLAGS += -fno-strict-aliasing
-KBUILD_CPPFLAGS += -march=i386 -DTEXT_BASE=$(TEXT_BASE) \
- -fno-unwind-tables -fno-asynchronous-unwind-tables
-
-machine-y := i386
-endif
ifeq ($(CONFIG_X86_32),y)
UTS_MACHINE := i386
@@ -48,25 +38,17 @@ machdirs := $(patsubst %,arch/x86/mach-%/,$(machine-y))
KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
-ifneq ($(board-y),)
-BOARD := arch/x86/boards/$(board-y)/
-else
-BOARD :=
-endif
-
ifneq ($(machine-y),)
MACH := arch/x86/mach-$(machine-y)/
else
MACH :=
endif
-common-y += $(BOARD) $(MACH)
+common-y += $(MACH)
common-y += arch/x86/lib/
-common-$(CONFIG_X86_BIOS_BRINGUP) += arch/x86/bios/
# arch/x86/cpu/
-ifeq ($(CONFIG_X86_EFI),y)
lds-$(CONFIG_X86_32) := arch/x86/mach-efi/elf_ia32_efi.lds
lds-$(CONFIG_X86_64) := arch/x86/mach-efi/elf_x86_64_efi.lds
@@ -92,16 +74,6 @@ barebox.efi: $(KBUILD_BINARY) FORCE
KBUILD_IMAGE := barebox.efi
-else
-common-y += arch/x86/boot/
-
-lds-$(CONFIG_GENERIC_LINKER_SCRIPT) := arch/x86/lib/barebox.lds
-lds-$(CONFIG_BOARD_LINKER_SCRIPT) := $(BOARD)/barebox.lds
-
-endif
-
KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE)
CLEAN_FILES += $(lds-y)
-CLEAN_FILES += arch/x86/lib/barebox.lds barebox.map barebox.S
-
diff --git a/arch/x86/bios/Makefile b/arch/x86/bios/Makefile
deleted file mode 100644
index 414ee42a4a..0000000000
--- a/arch/x86/bios/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-obj-y += memory16.o
-obj-y += traveler.o
-obj-y += bios_disk.o
diff --git a/arch/x86/bios/bios_disk.S b/arch/x86/bios/bios_disk.S
deleted file mode 100644
index c2a824ed6e..0000000000
--- a/arch/x86/bios/bios_disk.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-/* SPDX-FileCopyrightText: 1999-2008 Free Software Foundation, Inc. */
-
-/* Mostly stolen from the GRUB2 project */
-
-/**
- * @file
- * @brief Do BIOS calls to load or save data from disks
- *
- * @note These functions are running in flat and real mode. Due to some
- * other restrictions these routines must running from an address
- * space below 0x10000
- */
-
-/*
- * int bios_disk_rw_int13_extensions (int ah, int drive, void *dap)
- *
- * Call IBM/MS INT13 Extensions (int 13 %ah=AH) for DRIVE. DAP
- * is passed for disk address packet. If an error occurs, return
- * non-zero, otherwise zero.
- */
- .section .boot.text.bios_disk_rw_int13_extensions, "ax"
- .code32
- .globl bios_disk_rw_int13_extensions
- .type bios_disk_rw_int13_extensions, @function
-
- .extern prot_to_real
- .extern real_to_prot
-
-bios_disk_rw_int13_extensions:
- pushl %ebp
- pushl %esi
-
- /* compute the address of disk_address_packet */
- movw %cx, %si
- xorw %cx, %cx
- shrl $4, %ecx /* save the segment to cx */
-
- movb %al, %dh
- call prot_to_real /* enter real mode right now */
-
- .code16
- movb %dh, %ah
- movw %cx, %ds
- int $0x13 /* do the operation */
- movb %ah, %dl /* save return value */
- /* back to protected mode */
- DATA32 call real_to_prot
-
- .code32
- movb %dl, %al /* return value in %eax */
-
- popl %esi
- popl %ebp
-
- ret
diff --git a/arch/x86/bios/memory16.S b/arch/x86/bios/memory16.S
deleted file mode 100644
index e4aef2f256..0000000000
--- a/arch/x86/bios/memory16.S
+++ /dev/null
@@ -1,54 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-/* This code was inspired by the GRUB2 project. */
-
-/**
- * @file
- * @brief Query the memory layout information from the BIOS
- *
- * Note: This function is running in flat and real mode. Due to some
- * other restrictions it must running from an address space below 0x10000
- */
-
-/**
- * @fn unsigned short bios_get_memsize(void)
- * @brief Does a BIOS call "INT 15H, AH=88H" to get extended memory size
- * @return Extended memory size in KB
- *
- * @note This call is limited to 64 MiB. So, if the system provides more than
- * 64 MiB of memory, still 64 MiB are reported.
- *
- */
-
-
- .section .boot.text.bios_get_memsize, "ax"
- .code32
- .globl bios_get_memsize
- .type bios_get_memsize, @function
-
- .extern prot_to_real
-
-bios_get_memsize:
-
- pushl %ebp
-
- call prot_to_real /* enter real mode */
- .code16
-
- movb $0x88, %ah
- int $0x15
-
- movw %ax, %dx
-
- DATA32 call real_to_prot
-
- .code32
-
- movw %dx, %ax
-
- popl %ebp
- ret
-
- .size bios_get_memsize, .-bios_get_memsize
-
diff --git a/arch/x86/bios/traveler.S b/arch/x86/bios/traveler.S
deleted file mode 100644
index 1c11c9dc74..0000000000
--- a/arch/x86/bios/traveler.S
+++ /dev/null
@@ -1,166 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-/* Mostly stolen from the GRUB2 project */
-
-/**
- * @file
- * @brief Switch from the flat mode world into the real mode world and vice versa
- *
- * Note: These functions are *called* and return in a different operating mode
- */
-
-/**
- * @fn void real_to_prot(void)
- * @brief Switch from temp. real mode back to flat mode
- *
- * Called from a 32 bit flat mode segment and returns into a 16 bit segment
- */
-
-/**
- * @fn void prot_to_real(void)
- * @brief Switch from flat mode to real mode
- *
- * Called from a 16 bit real mode segment and returns into a 32 bit segment
- */
-
-#include <asm/modes.h>
-
- .file "walkyrie.S"
-
-/* keep the current flat mode stack pointer, while playing in real mode */
- .section .boot.data.protstack
- .code32
-protstack: .long 4
-/* temp. store */
-return_addr: .long 4
-
-
- .section .boot.text.real_to_prot, "ax"
- .code16
- .globl real_to_prot
- .type real_to_prot, @function
-
-/* Note: This routine should not change any other standard registers than eax */
-real_to_prot:
- /*
- * Always disable the interrupts, when returning to flat mode
- */
- cli
-
- /* turn on protected mode */
- movl %cr0, %eax
- orl $0x00000001, %eax
- movl %eax, %cr0
-
- /* jump to relocation, flush prefetch queue, and reload %cs */
- DATA32 ljmp $__BOOT_CS, $return_to_flatmode
- .size real_to_prot, .-real_to_prot
-
-/* ----------------------------------------------------------------------- */
- .section .boot.text.return_to_flatmode, "ax"
- .type return_to_flatmode, @function
- .code32
-
-return_to_flatmode:
- /* reload other segment registers */
- movw $__BOOT_DS, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %fs
- movw %ax, %gs
- movw %ax, %ss
-
- /* move the return address from the real mode to the flat mode stack */
- movl (%esp), %eax
- movl %eax, return_addr
-
- /* setup again the flat mode stack */
- movl protstack, %eax
- movl %eax, %esp
- movl %eax, %ebp
-
- movl return_addr, %eax
- movl %eax, (%esp)
-
- /* flag we returned happy here */
- xorl %eax, %eax
- ret
- .size return_to_flatmode, .-return_to_flatmode
-
-/* ------------------------------------------------------------------------ */
-
-/* Note: This routine should not change any other standard registers than eax */
-
- .section .boot.text.prot_to_real, "ax"
- .globl prot_to_real
- .type prot_to_real, @function
- .extern boot_stack
- .code32
-
-prot_to_real:
- /* save the protected mode stack */
- movl %esp, %eax
- movl %eax, protstack
-
- /* prepare the real mode stack */
- /* - address to call to the top of this stack */
- movl (%esp), %eax
- movl %eax, boot_stack - 4
-
- /* - the stack itself */
- movl $boot_stack - 4, %eax
- movl %eax, %esp
- movl %eax, %ebp
-
- /* prepare segments limits to 16 bit */
- movw $__REAL_DS, %ax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %fs
- movw %ax, %gs
- movw %ax, %ss
-
- /* at last, also limit the code segment to 16 bit */
- ljmp $__REAL_CS, $return_to_realmode
- .size prot_to_real, .-prot_to_real
-
-/* ----------------------------------------------------------------------- */
-
- .section .boot.text.return_to_realmode, "ax"
- .globl return_to_realmode
- .type return_to_realmode, @function
- .code16
-
-return_to_realmode:
- /* disable protected mode */
- movl %cr0, %eax
- andl $(~0x00000001), %eax
- movl %eax, %cr0
-
- /*
- * all the protected mode settings are still cached in the CPU.
- * Refresh them by re-loading all registers in realmode
- * Start with the CS, continue with the data registers
- */
- ljmp $0, $enter_realmode
-
-enter_realmode:
- xorl %eax, %eax
- movw %ax, %ds
- movw %ax, %es
- movw %ax, %fs
- movw %ax, %gs
- movw %ax, %ss
- /*
- * back in plain real mode now, we can play again with the BIOS
- */
-
- /* restore interrupts */
- sti
-
- /* return on realmode stack! */
- DATA32 ret
-
- .size return_to_realmode, .-return_to_realmode
-
diff --git a/arch/x86/boards/x86_generic/Makefile b/arch/x86/boards/x86_generic/Makefile
deleted file mode 100644
index fca707dd8b..0000000000
--- a/arch/x86/boards/x86_generic/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-obj-y += generic_pc.o
-obj-$(CONFIG_DISK_INTF_PLATFORM_IDE) += intf_platform_ide.o
-obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
-obj-$(CONFIG_DRIVER_SERIAL_NS16550) += serial_ns16550.o
diff --git a/arch/x86/boards/x86_generic/disk_bios_drive.c b/arch/x86/boards/x86_generic/disk_bios_drive.c
deleted file mode 100644
index c8e9ae8523..0000000000
--- a/arch/x86/boards/x86_generic/disk_bios_drive.c
+++ /dev/null
@@ -1,33 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/**
- * @file
- * @brief Generic PC support for the BIOS disk interface
- */
-
-#include <common.h>
-#include <driver.h>
-#include <init.h>
-#include <linux/err.h>
-#include "envsector.h"
-
-static int bios_disk_init(void)
-{
- struct cdev *cdev;
-
- add_generic_device("biosdrive", DEVICE_ID_DYNAMIC, NULL, 0, 0,
- IORESOURCE_MEM, NULL);
-
- if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
- cdev = devfs_add_partition("biosdisk0",
- pers_env_storage * 512,
- (unsigned)pers_env_size * 512,
- DEVFS_PARTITION_FIXED, "env0");
- printf("Partition: %ld\n", IS_ERR(cdev) ? PTR_ERR(cdev) : 0);
- } else
- printf("No persistent storage defined\n");
-
- return 0;
-}
-device_initcall(bios_disk_init);
diff --git a/arch/x86/boards/x86_generic/env/bin/boot b/arch/x86/boards/x86_generic/env/bin/boot
deleted file mode 100644
index fcfffe3194..0000000000
--- a/arch/x86/boards/x86_generic/env/bin/boot
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-
-. /env/config
-
-if [ x$1 = xdisk ]; then
- root=disk
- kernel=disk
-fi
-
-if [ x$1 = xnet ]; then
- root=net
- kernel=net
-fi
-
-if [ x$ip = xdhcp ]; then
- bootargs="$bootargs ip=dhcp"
-else
- bootargs="$bootargs ip=$eth0.ipaddr:$eth0.serverip:$eth0.gateway:$eth0.netmask:::"
-fi
-
-if [ x$root = xdisk ]; then
- bootargs="$bootargs root=$rootpart_disk rootfstype=$rootpart_fs rw"
-else
- bootargs="$bootargs root=/dev/nfs nfsroot=$eth0.serverip:$nfsroot,v3,tcp rw"
-fi
-
-if [ $kernel = net ]; then
- if [ x$ip = xdhcp ]; then
- dhcp
- fi
- tftp $uimage uImage || exit 1
- bootm uImage
-else
- bootargs="BOOT_IMAGE=$kernel_device auto $bootargs"
- linux16 $kernel_device
-fi
-
diff --git a/arch/x86/boards/x86_generic/env/bin/init b/arch/x86/boards/x86_generic/env/bin/init
deleted file mode 100644
index 2924a4449a..0000000000
--- a/arch/x86/boards/x86_generic/env/bin/init
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-PATH=/env/bin
-export PATH
-
-. /env/config
-
-echo
-echo -n "Hit any key to stop autoboot: "
-timeout -a $autoboot_timeout
-if [ $? != 0 ]; then
- exit
-fi
-
-boot
diff --git a/arch/x86/boards/x86_generic/env/config b/arch/x86/boards/x86_generic/env/config
deleted file mode 100644
index dd57aad716..0000000000
--- a/arch/x86/boards/x86_generic/env/config
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# basic config
-#
-# boot source: 'disk' or 'net'
-kernel=disk
-root=disk
-
-# data for the NFS case
-nfsroot="/path/to/nfs_root"
-
-# data for the disk case
-kernel_device=/dev/biosdisk0.1
-rootpart_disk=/dev/sda1
-rootpart_fs=ext2
-
-baudrate=115200
-serial=ttyS0
-
-# use UART for console
-bootargs="console=$serial,$baudrate"
-
-autoboot_timeout=3
-
-# use 'dhcp' to do dhcp in uboot and in kernel
-# ip=dhcp
-# or set your networking parameters here
-# eth0.ipaddr=192.168.3.11
-# eth0.netmask=255.255.255.0
-# eth0.gateway=a.b.c.d
-# eth0.serverip=192.168.3.10
-# eth0.ethaddr=aa.bb.cc.dd.ee.ff
diff --git a/arch/x86/boards/x86_generic/envsector.h b/arch/x86/boards/x86_generic/envsector.h
deleted file mode 100644
index 57a6d2a21f..0000000000
--- a/arch/x86/boards/x86_generic/envsector.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-/**
- * @file
- * @brief x86 Generic PC common definitions
- */
-#ifndef __X86_ENVSECTOR_H
-#define __ENVSECTOR_H
-
-/*
- * These datas are from the MBR, created by the linker and filled by the
- * setup tool while installing barebox on the disk drive
- */
-extern uint64_t pers_env_storage;
-extern uint16_t pers_env_size;
-extern uint8_t pers_env_drive;
-
-/**
- * Persistent environment "not used" marker.
- * Note: Must be in accordance to the value the tool "setup_mbr" writes.
- */
-#define PATCH_AREA_PERS_SIZE_UNUSED 0x000
-
-#endif
diff --git a/arch/x86/boards/x86_generic/generic_pc.c b/arch/x86/boards/x86_generic/generic_pc.c
deleted file mode 100644
index 2f1db7aca1..0000000000
--- a/arch/x86/boards/x86_generic/generic_pc.c
+++ /dev/null
@@ -1,18 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-#include <common.h>
-#include <types.h>
-#include <driver.h>
-#include <init.h>
-#include <asm/syslib.h>
-#include <linux/err.h>
-
-static int devices_init(void)
-{
- /* extended memory only */
- add_mem_device("ram0", 0x0, bios_get_memsize() << 10,
- IORESOURCE_MEM_WRITEABLE);
- return 0;
-}
-device_initcall(devices_init);
diff --git a/arch/x86/boards/x86_generic/intf_platform_ide.c b/arch/x86/boards/x86_generic/intf_platform_ide.c
deleted file mode 100644
index 0db031484f..0000000000
--- a/arch/x86/boards/x86_generic/intf_platform_ide.c
+++ /dev/null
@@ -1,80 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2014 Juergen Beisert, Pengutronix
-// SPDX-FileCopyrightText: 2014 Michel Stam, Fugro Intersite
-
-/**
- * @file
- * @brief Generic PC support for the IDE platform driver
- */
-
-#include <common.h>
-#include <driver.h>
-#include <init.h>
-#include <linux/err.h>
-#include <platform_data/ide.h>
-#include "envsector.h"
-
-static struct ide_port_info ide_plat = {
- .ioport_shift = 0,
- .dataif_be = 0,
-};
-
-static struct resource primary_ide_resources[] = {
- {
- .name = "base",
- .start = 0x1f0,
- .end = 0x1f7,
- .flags = IORESOURCE_IO
- },
- {
- .name = "alt",
- .start = 0x3f6,
- .end = 0x3f7,
- .flags = IORESOURCE_IO
- }
-};
-
-static struct resource secondary_ide_resources[] = {
- {
- .name = "base",
- .start = 0x170,
- .end = 0x177,
- .flags = IORESOURCE_IO
- },
-};
-
-static struct device_d primary_ide_device = {
- .name = "ide_intf",
- .id = 0,
- .platform_data = &ide_plat,
- .resource = primary_ide_resources,
- .num_resources = ARRAY_SIZE(primary_ide_resources),
-};
-
-static struct device_d secondary_ide_device = {
- .name = "ide_intf",
- .id = 1,
- .platform_data = &ide_plat,
- .resource = secondary_ide_resources,
- .num_resources = ARRAY_SIZE(secondary_ide_resources),
-};
-
-static int platform_ide_init(void)
-{
- struct cdev *cdev;
-
- platform_device_register(&primary_ide_device);
- platform_device_register(&secondary_ide_device);
-
- if (pers_env_size != PATCH_AREA_PERS_SIZE_UNUSED) {
- cdev = devfs_add_partition("ata0",
- pers_env_storage * 512,
- (unsigned)pers_env_size * 512,
- DEVFS_PARTITION_FIXED, "env0");
- printf("Partition: %ld\n", IS_ERR(cdev) ? PTR_ERR(cdev) : 0);
- } else
- printf("No persistent storage defined\n");
-
- return 0;
-}
-device_initcall(platform_ide_init);
diff --git a/arch/x86/boards/x86_generic/serial_ns16550.c b/arch/x86/boards/x86_generic/serial_ns16550.c
deleted file mode 100644
index 4159bc39fb..0000000000
--- a/arch/x86/boards/x86_generic/serial_ns16550.c
+++ /dev/null
@@ -1,35 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-// SPDX-FileCopyrightText: 2009 Michel Stam, Fugro Intersite
-
-/**
- * @file
- * @brief Generic PC support to let barebox acting as a boot loader
- */
-
-#include <common.h>
-#include <types.h>
-#include <driver.h>
-#include <init.h>
-#include <asm/syslib.h>
-#include <platform_data/serial-ns16550.h>
-#include <linux/err.h>
-
-static struct NS16550_plat serial_plat = {
- .clock = 1843200,
-};
-
-static int pc_console_init(void)
-{
- barebox_set_model("X86 generic barebox");
- barebox_set_hostname("x86");
-
- /* Register the serial port */
- add_ns16550_device(DEVICE_ID_DYNAMIC, 0x3f8, 8, IORESOURCE_IO,
- &serial_plat);
- add_ns16550_device(DEVICE_ID_DYNAMIC, 0x2f8, 8, IORESOURCE_IO,
- &serial_plat);
-
- return 0;
-}
-console_initcall(pc_console_init);
diff --git a/arch/x86/boot/Kconfig b/arch/x86/boot/Kconfig
deleted file mode 100644
index 8dba00d591..0000000000
--- a/arch/x86/boot/Kconfig
+++ /dev/null
@@ -1,20 +0,0 @@
-if X86_BIOS_BRINGUP
-
-menu "BIOS boot source"
-
-config X86_HDBOOT
- bool "HD boot"
- help
- Add code to boot from harddisk
-
-config X86_VESA
- bool
- default y if X86_GENERIC_HAS_VIDEO
-
-config X86_VGA
- bool
- default y if X86_GENERIC_HAS_VIDEO
-
-endmenu
-
-endif
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
deleted file mode 100644
index 4a520a2a84..0000000000
--- a/arch/x86/boot/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-
-KBUILD_CPPFLAGS += -D__I386__ -fno-strict-aliasing -m32 -g -Os -march=i386 \
- -mregparm=3 -fno-strict-aliasing -fomit-frame-pointer -ffreestanding \
- -fno-toplevel-reorder -fno-unit-at-a-time -fno-stack-protector \
- -mpreferred-stack-boundary=2
-
-obj-$(CONFIG_X86_HDBOOT) += boot_main.o boot_hdisk.o
-
-obj-$(CONFIG_X86_BIOS_BRINGUP) += prepare_uboot.o a20.o bioscall.o regs.o tty.o pmjump.o main_entry.o
-
-obj-$(CONFIG_X86_VESA) += console_vesa.o
-obj-$(CONFIG_X86_VGA) += console_vga.o
-obj-$(CONFIG_X86_SERIAL) += console_serial.o
diff --git a/arch/x86/boot/a20.c b/arch/x86/boot/a20.c
deleted file mode 100644
index f501feeedd..0000000000
--- a/arch/x86/boot/a20.c
+++ /dev/null
@@ -1,166 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-// SPDX-FileCopyrightText: 1991,1992 Linus Torvalds
-// SPDX-FileCopyrightText: 2007-2008 rPath, Inc.
-// SPDX-FileCopyrightText: 2009 Intel Corporation
-
-/* Author: H. Peter Anvin and others */
-
-/*
- * Enable A20 gate (return -1 on failure)
- */
-
-#include <asm/segment.h>
-#include <io.h>
-#include "boot.h"
-
-#define MAX_8042_LOOPS 100000
-#define MAX_8042_FF 32
-
-/* be aware of: */
-THIS_IS_REALMODE_CODE
-
-static int __bootcode empty_8042(void)
-{
- u8 status;
- int loops = MAX_8042_LOOPS;
- int ffs = MAX_8042_FF;
-
- while (loops--) {
- io_delay();
-
- status = inb(0x64);
- if (status == 0xff) {
- /* FF is a plausible, but very unlikely status */
- if (!--ffs)
- return -1; /* Assume no KBC present */
- }
- if (status & 1) {
- /* Read and discard input data */
- io_delay();
- (void)inb(0x60);
- } else if (!(status & 2)) {
- /* Buffers empty, finished! */
- return 0;
- }
- }
-
- return -1;
-}
-
-/* Returns nonzero if the A20 line is enabled. The memory address
- used as a test is the int $0x80 vector, which should be safe. */
-
-#define A20_TEST_ADDR (4*0x80)
-#define A20_TEST_SHORT 32
-#define A20_TEST_LONG 2097152 /* 2^21 */
-
-static int __bootcode a20_test(int loops)
-{
- int ok = 0;
- int saved, ctr;
-
- set_fs(0x0000);
- set_gs(0xffff);
-
- saved = ctr = rdfs32(A20_TEST_ADDR);
-
- while (loops--) {
- wrfs32(++ctr, A20_TEST_ADDR);
- io_delay(); /* Serialize and make delay constant */
- ok = rdgs32(A20_TEST_ADDR+0x10) ^ ctr;
- if (ok)
- break;
- }
-
- wrfs32(saved, A20_TEST_ADDR);
- return ok;
-}
-
-/* Quick test to see if A20 is already enabled */
-static int __bootcode a20_test_short(void)
-{
- return a20_test(A20_TEST_SHORT);
-}
-
-/* Longer test that actually waits for A20 to come on line; this
- is useful when dealing with the KBC or other slow external circuitry. */
-static int __bootcode a20_test_long(void)
-{
- return a20_test(A20_TEST_LONG);
-}
-
-static void __bootcode enable_a20_bios(void)
-{
- struct biosregs ireg;
-
- initregs(&ireg);
- ireg.ax = 0x2401;
- intcall(0x15, &ireg, NULL);
-}
-
-static void __bootcode enable_a20_kbc(void)
-{
- empty_8042();
-
- outb(0xd1, 0x64); /* Command write */
- empty_8042();
-
- outb(0xdf, 0x60); /* A20 on */
- empty_8042();
-
- outb(0xff, 0x64); /* Null command, but UHCI wants it */
- empty_8042();
-}
-
-static void __bootcode enable_a20_fast(void)
-{
- u8 port_a;
-
- port_a = inb(0x92); /* Configuration port A */
- port_a |= 0x02; /* Enable A20 */
- port_a &= ~0x01; /* Do not reset machine */
- outb(port_a, 0x92);
-}
-
-/*
- * Actual routine to enable A20; return 0 on ok, -1 on failure
- */
-
-#define A20_ENABLE_LOOPS 255 /* Number of times to try */
-
-int __bootcode enable_a20(void)
-{
- int loops = A20_ENABLE_LOOPS;
- int kbc_err;
-
- while (loops--) {
- /* First, check to see if A20 is already enabled
- (legacy free, etc.) */
- if (a20_test_short())
- return 0;
-
- /* Next, try the BIOS (INT 0x15, AX=0x2401) */
- enable_a20_bios();
- if (a20_test_short())
- return 0;
-
- /* Try enabling A20 through the keyboard controller */
- kbc_err = empty_8042();
-
- if (a20_test_short())
- return 0; /* BIOS worked, but with delayed reaction */
-
- if (!kbc_err) {
- enable_a20_kbc();
- if (a20_test_long())
- return 0;
- }
-
- /* Finally, try enabling the "fast A20 gate" */
- enable_a20_fast();
- if (a20_test_long())
- return 0;
- }
-
- return -1;
-}
diff --git a/arch/x86/boot/bioscall.S b/arch/x86/boot/bioscall.S
deleted file mode 100644
index 6cda1eb40a..0000000000
--- a/arch/x86/boot/bioscall.S
+++ /dev/null
@@ -1,90 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Intel Corporation */
-
-/* Author: H. Peter Anvin */
-
-/*
- * "Glove box" for BIOS calls. Avoids the constant problems with BIOSes
- * touching registers they shouldn't be.
- */
-
- .file "bioscall.S"
- .code16
- .section .boot.text.intcall, "ax"
-
- .globl intcall
- .type intcall, @function
-intcall:
- /* Self-modify the INT instruction. Ugly, but works. */
- cmpb %al, 3f
- je 1f
- movb %al, 3f
- jmp 1f /* Synchronize pipeline */
-1:
- /* Save state */
- pushfl
- pushw %fs
- pushw %gs
- pushal
-
- /* Copy input state to stack frame */
- subw $44, %sp
- movw %dx, %si
- movw %sp, %di
- movw $11, %cx
- rep; movsd
-
- /* Pop full state from the stack */
- popal
- popw %gs
- popw %fs
- popw %es
- popw %ds
- popfl
-
- /* Actual INT */
- .byte 0xcd /* INT opcode */
-3: .byte 0
-
- /* Push full state to the stack */
- pushfl
- pushw %ds
- pushw %es
- pushw %fs
- pushw %gs
- pushal
-
- /* Re-establish C environment invariants */
- cld
- movzwl %sp, %esp
- movw %cs, %ax
- movw %ax, %ds
- movw %ax, %es
-
- /* Copy output state from stack frame */
- movw 68(%esp), %di /* Original %cx == 3rd argument */
- andw %di, %di
- jz 4f
- movw %sp, %si
- movw $11, %cx
- rep; movsd
-4: addw $44, %sp
-
- /* Restore state and return */
- popal
- popw %gs
- popw %fs
- popfl
- retl
- .size intcall, .-intcall
-
-/* ------------------------------------------------------------------------ */
- .code16
- .section .boot.text.die, "ax"
-
- .globl die
- .type die, @function
-die:
- hlt
- jmp die
- .size die, .-die
diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
deleted file mode 100644
index 54483c46c6..0000000000
--- a/arch/x86/boot/boot.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/* SPDX-FileCopyrightText: 1991,1992 Linus Torvalds */
-/* SPDX-FileCopyrightText: 2007 rPath, Inc. */
-/* SPDX-FileCopyrightText: 2009 Intel Corporation */
-
-/* Author: H. Peter Anvin and others */
-
-/**
- * @file
- * @brief Main declarations for the real mode code
- */
-
-#ifndef BOOT_BOOT_H
-#define BOOT_BOOT_H
-
-#define STACK_SIZE 512 /* Minimum number of bytes for stack */
-
-/** Carry flag */
-#define X86_EFLAGS_CF 0x00000001
-
-/** PE flag */
-#define X86_CR0_PE 0x00000001
-
-#ifndef __ASSEMBLY__
-
-#include <types.h>
-
-/* we are still in real mode here! */
-#define THIS_IS_REALMODE_CODE asm(".code16gcc");
-
-struct biosregs {
- union {
- struct {
- uint32_t edi;
- uint32_t esi;
- uint32_t ebp;
- uint32_t _esp;
- uint32_t ebx;
- uint32_t edx;
- uint32_t ecx;
- uint32_t eax;
- uint32_t _fsgs;
- uint32_t _dses;
- uint32_t eflags;
- };
- struct {
- uint16_t di, hdi;
- uint16_t si, hsi;
- uint16_t bp, hbp;
- uint16_t _sp, _hsp;
- uint16_t bx, hbx;
- uint16_t dx, hdx;
- uint16_t cx, hcx;
- uint16_t ax, hax;
- uint16_t gs, fs;
- uint16_t es, ds;
- uint16_t flags, hflags;
- };
- struct {
- uint8_t dil, dih, edi2, edi3;
- uint8_t sil, sih, esi2, esi3;
- uint8_t bpl, bph, ebp2, ebp3;
- uint8_t _spl, _sph, _esp2, _esp3;
- uint8_t bl, bh, ebx2, ebx3;
- uint8_t dl, dh, edx2, edx3;
- uint8_t cl, ch, ecx2, ecx3;
- uint8_t al, ah, eax2, eax3;
- };
- };
-};
-
-/* functions in the realmode part */
-extern int enable_a20(void);
-extern void initregs(struct biosregs *regs);
-extern void intcall(uint8_t int_no, const struct biosregs *ireg, struct biosregs *oreg);
-extern void boot_puts(char*);
-extern void __attribute__((noreturn)) die(void);
-extern void __attribute__((noreturn)) protected_mode_jump(void);
-
-struct gdt_ptr {
- uint16_t len;
- uint32_t ptr;
-} __attribute__((packed));
-
-/* These functions are used to reference data in other segments. */
-
-static inline uint16_t ds(void)
-{
- uint16_t seg;
- asm("movw %%ds,%0" : "=rm" (seg));
- return seg;
-}
-
-static inline void set_fs(uint16_t seg)
-{
- asm volatile("movw %0,%%fs" : : "rm" (seg));
-}
-
-static inline uint16_t fs(void)
-{
- uint16_t seg;
- asm volatile("movw %%fs,%0" : "=rm" (seg));
- return seg;
-}
-
-static inline void set_gs(uint16_t seg)
-{
- asm volatile("movw %0,%%gs" : : "rm" (seg));
-}
-
-static inline uint16_t gs(void)
-{
- uint16_t seg;
- asm volatile("movw %%gs,%0" : "=rm" (seg));
- return seg;
-}
-
-typedef unsigned int addr_t;
-
-static inline uint8_t rdfs8(addr_t addr)
-{
- uint8_t v;
- asm volatile("movb %%fs:%1,%0" : "=q" (v) : "m" (*(uint8_t *)addr));
- return v;
-}
-static inline uint16_t rdfs16(addr_t addr)
-{
- uint16_t v;
- asm volatile("movw %%fs:%1,%0" : "=r" (v) : "m" (*(uint16_t *)addr));
- return v;
-}
-static inline uint32_t rdfs32(addr_t addr)
-{
- uint32_t v;
- asm volatile("movl %%fs:%1,%0" : "=r" (v) : "m" (*(uint32_t *)addr));
- return v;
-}
-
-static inline void wrfs8(uint8_t v, addr_t addr)
-{
- asm volatile("movb %1,%%fs:%0" : "+m" (*(uint8_t *)addr) : "qi" (v));
-}
-static inline void wrfs16(uint16_t v, addr_t addr)
-{
- asm volatile("movw %1,%%fs:%0" : "+m" (*(uint16_t *)addr) : "ri" (v));
-}
-static inline void wrfs32(uint32_t v, addr_t addr)
-{
- asm volatile("movl %1,%%fs:%0" : "+m" (*(uint32_t *)addr) : "ri" (v));
-}
-
-static inline uint8_t rdgs8(addr_t addr)
-{
- uint8_t v;
- asm volatile("movb %%gs:%1,%0" : "=q" (v) : "m" (*(uint8_t *)addr));
- return v;
-}
-static inline uint16_t rdgs16(addr_t addr)
-{
- uint16_t v;
- asm volatile("movw %%gs:%1,%0" : "=r" (v) : "m" (*(uint16_t *)addr));
- return v;
-}
-static inline uint32_t rdgs32(addr_t addr)
-{
- uint32_t v;
- asm volatile("movl %%gs:%1,%0" : "=r" (v) : "m" (*(uint32_t *)addr));
- return v;
-}
-
-static inline void wrgs8(uint8_t v, addr_t addr)
-{
- asm volatile("movb %1,%%gs:%0" : "+m" (*(uint8_t *)addr) : "qi" (v));
-}
-static inline void wrgs16(uint16_t v, addr_t addr)
-{
- asm volatile("movw %1,%%gs:%0" : "+m" (*(uint16_t *)addr) : "ri" (v));
-}
-static inline void wrgs32(uint32_t v, addr_t addr)
-{
- asm volatile("movl %1,%%gs:%0" : "+m" (*(uint32_t *)addr) : "ri" (v));
-}
-
-/** use the built in memset function for the real mode code */
-#define memset(d,c,l) __builtin_memset(d,c,l)
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* BOOT_BOOT_H */
diff --git a/arch/x86/boot/boot_hdisk.S b/arch/x86/boot/boot_hdisk.S
deleted file mode 100644
index 6f98197512..0000000000
--- a/arch/x86/boot/boot_hdisk.S
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2009 Juergen Beisert, Pengutronix
- *
- * This code was inspired by the GRUB2 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.
- *
- *
- */
-
-/**
- * @file
- * @brief Loading the barebox image from a disk drive in LBA mode
- */
-
-/**
- * @fn void real_start(void)
- * @brief A very simple and small loader to fetch all required sectors
- * from the boot media.
- */
-
-
- .file "boot_hdisk.S"
- .code16
-
- /*
- * These symbols are generated by the linker, because they need a
- * special layout. This layout is needed to be able to setup this
- * bootloader by patching the binary when it gets stored into the
- * master boot record.
- */
- .extern indirect_sector_lba
- .extern boot_stack
- .extern start_pre_uboot
- .extern boot_disk
- .section .boot_code, "ax"
-
- .globl real_start
- .type real_start, @function
-
-real_start:
-
- xorw %ax, %ax /* set up %ds and %ss as offset from 0 */
- movw %ax, %ds
- movw %ax, %ss
-
- /* set up the REAL stack */
- movw $boot_stack, %sp
-
- sti /* we're safe again */
-
- /* save drive reference first thing! */
- movb %dl, boot_disk
- pushw %dx
-
- movw $notification_string, %si
- call output_message
-
- /*
- * This boot code only supports LBA. We fail here, if the BIOS
- * does not support LBA for the harddisk
- */
-
- /* check if LBA is supported */
- movb $0x41, %ah
- movw $0x55aa, %bx
- int $0x13
-
- /*
- * %dl may have been clobbered by INT 13, AH=41H.
- * This happens, for example, with AST BIOS 1.04.
- */
- popw %dx
- pushw %dx
-
- /* stop if no LBA support */
- jc no_lba
- cmpw $0xaa55, %bx
- jne no_lba
- andw $1, %cx
- jz no_lba
-
-lba_mode:
- /*
- * Load the indirect sector. Its content is ready for use,
- * provided by the installer
- */
- movw $indirect_sector_lba, %si
- movb $0x42, %ah
- int $0x13
- jc no_lba /* error? Then die */
-
- /*
- * Now loop through all valid entries in the indirect sector
- */
- movw $indirect_area, %si
-
-load_loop:
- /*
- * Stop if this "Disk Address Packet Structure" is invalid
- * We call it invalid, if the size member is zero. If it is invalid
- * we are optimistic and calling the loaded image
- */
- movw (%si), %ax
- cmpw $0x0000, %ax
- je start_main
-
- /*
- * Load this entry
- */
- movb $0x42, %ah
- int $0x13
- jc no_lba
-
- addw (%si), %si /* next entry */
- cmpw $indirect_area + 512, %si
- jne load_loop
- /*
- * fall through to start u-boot.
- */
-start_main:
- movw $jmp_string, %si
- call output_message
- jmp start_pre_uboot
-/*
- * die if there is no LBA support
- */
-no_lba: movw $chs_string, %si
- call output_message
- hlt
-
-/*
- * message: write the string pointed to by %si
- *
- * WARNING: trashes %si, %ax, and %bx
- */
-
-/*
- * Use BIOS "int 10H Function 0Eh" to write character in teletype mode
- * %ah = 0xe %al = character
- * %bh = page %bl = foreground color (graphics modes)
- */
-
-1:
- movw $0x0001, %bx
- movb $0xe, %ah
- int $0x10 /* display this char */
-
-output_message:
- lodsb
- cmpb $0, %al
- jne 1b /* if not end of string, next char */
- ret
-
-/* ---------------------------------------------------------------------- */
-
- .section .boot_data
-
-notification_string: .asciz "BAREBOX "
-chs_string: .asciz "CHS "
-jmp_string: .asciz "JMP "
-
diff --git a/arch/x86/boot/boot_main.S b/arch/x86/boot/boot_main.S
deleted file mode 100644
index 632b3f4ffa..0000000000
--- a/arch/x86/boot/boot_main.S
+++ /dev/null
@@ -1,39 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: Juergen Beisert, Pengutronix */
-
-/* This code was inspired by the GRUB2 project. */
-
-/**
- * @file
- * @brief Common boot sector main routine to be entered by the BIOS
- */
-/**
- * @fn void _start(void)
- *
- * @brief Fix segment:offset settings of some buggy BIOSs
- */
-
-
- .file "boot_main.S"
- .code16
-
- .extern real_start
-
- .section .boot_start, "ax"
- .type _start, @function
-
- /*
- * The BIOS loads this code to address 0x00007c00.
- * The code should be called with CS:IP 0:0x7c00 (hopefully).
- */
- .globl _start
-_start:
- cli /* we're not safe here! */
- /*
- * It seems there are implementations in the wild which call this
- * code with CS:IP 0x07C0:0000 instead. We fix it immediately.
- */
- ljmp $0, $real_start
-
- .size _start, .-_start
-
diff --git a/arch/x86/boot/main_entry.c b/arch/x86/boot/main_entry.c
deleted file mode 100644
index b37aa38fca..0000000000
--- a/arch/x86/boot/main_entry.c
+++ /dev/null
@@ -1,24 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/**
- * @file
- * @brief Start of the 32 bit flat mode
- */
-
-#include <string.h>
-#include <asm/sections.h>
-
-extern void x86_start_barebox(void);
-
-/**
- * Called plainly from assembler that switches from real to flat mode
- *
- * @note The C environment isn't initialized yet
- */
-void uboot_entry(void)
-{
- /* clear the BSS first */
- memset(__bss_start, 0x00, __bss_stop - __bss_start);
- x86_start_barebox();
-}
diff --git a/arch/x86/boot/pmjump.S b/arch/x86/boot/pmjump.S
deleted file mode 100644
index 4dd1881e65..0000000000
--- a/arch/x86/boot/pmjump.S
+++ /dev/null
@@ -1,82 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/* SPDX-FileCopyrightText: 1991,1992 Linus Torvalds */
-/* SPDX-FileCopyrightText: 2007 rPath, Inc. */
-
-/**
- * @file
- * @brief The actual transition into protected mode
- *
- * Note: This function is running in flat and real mode. Due to some
- * other restrictions it must running from an address space below 0x10000
- */
-
-/**
- * @fn void protected_mode_jump(void)
- * @brief Switches the first time from real mode to flat mode
- */
-
-#include <asm/modes.h>
-#include "boot.h"
-
- .file "pmjump.S"
- .code16
- .section .boot.text.protected_mode_jump, "ax"
-
- .globl protected_mode_jump
- .type protected_mode_jump, @function
-
-protected_mode_jump:
- jmp 1f /* Short jump to serialize on 386/486 */
-1:
-
- movw $__BOOT_DS, %cx
- movw $__BOOT_TSS, %di
-
- movl %cr0, %edx
- orb $X86_CR0_PE, %dl /* enable protected mode */
- movl %edx, %cr0
-
- /* Transition to 32-bit flat mode */
- data32 ljmp $__BOOT_CS, $in_pm32
- .size protected_mode_jump, .-protected_mode_jump
-
-/* ------------------------------------------------------------------------ */
-
- .section ".text.in_pm32","ax"
- .code32
-
- .extern uboot_entry
- .extern __bss_stop
-
- .type in_pm32, @function
-in_pm32:
- # Set up data segments for flat 32-bit mode
- movl %ecx, %ds
- movl %ecx, %es
- movl %ecx, %fs
- movl %ecx, %gs
- movl %ecx, %ss
-/*
- * Our flat mode code uses its own stack area behind the bss. With this we
- * are still able to return to real mode temporarely
- */
- movl $__bss_stop + 32768, %esp
-
- # Set up TR to make Intel VT happy
- ltr %di
-
- # Clear registers to allow for future extensions to the
- # 32-bit boot protocol
- xorl %ecx, %ecx
- xorl %edx, %edx
- xorl %ebx, %ebx
- xorl %ebp, %ebp
- xorl %edi, %edi
-
- # Set up LDTR to make Intel VT happy
- lldt %cx
-
- jmp uboot_entry
-
- .size in_pm32, .-in_pm32
-
diff --git a/arch/x86/boot/prepare_uboot.c b/arch/x86/boot/prepare_uboot.c
deleted file mode 100644
index 9cac594a46..0000000000
--- a/arch/x86/boot/prepare_uboot.c
+++ /dev/null
@@ -1,80 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-// SPDX-FileCopyrightText: 1991,1992 Linus Torvalds
-// SPDX-FileCopyrightText: 2007 rPath, Inc.
-
-/*
- * Prepare the machine for transition to protected mode.
- */
-#include <asm/segment.h>
-#include <asm/modes.h>
-#include <io.h>
-#include "boot.h"
-
-/* be aware of: */
-THIS_IS_REALMODE_CODE
-
-/*
- * While we are in flat mode, we can't handle interrupts. But we can't
- * switch them off for ever in the PIC, because we need them again while
- * entering real mode code again and again....
- */
-static void __bootcode realmode_switch_hook(void)
-{
- asm volatile("cli");
- outb(0x80, 0x70); /* Disable NMI */
- io_delay();
-}
-
-/*
- * Reset IGNNE# if asserted in the FPU.
- */
-static void __bootcode reset_coprocessor(void)
-{
- outb(0, 0xf0);
- io_delay();
- outb(0, 0xf1);
- io_delay();
-}
-
-/**
- * Setup and register the global descriptor table (GDT)
- *
- * @note This is for the first time only
- */
-static void __bootcode setup_gdt(void)
-{
- /* Xen HVM incorrectly stores a pointer to the gdt_ptr, instead
- of the gdt_ptr contents. Thus, make it static so it will
- stay in memory, at least long enough that we switch to the
- proper kernel GDT. */
- static struct gdt_ptr __bootdata gdt_ptr;
-
- gdt_ptr.len = gdt_size - 1;
- gdt_ptr.ptr = (uint32_t)&gdt + (ds() << 4);
-
- asm volatile("lgdtl %0" : : "m" (gdt_ptr));
-}
-
-static char a20_message[] __bootdata = "A20 gate not responding, unable to boot...\n";
-
-/*
- * Actual invocation sequence
- */
-void __bootcode start_pre_uboot(void)
-{
- /* Hook before leaving real mode, also disables interrupts */
- realmode_switch_hook();
-
- /* Enable the A20 gate */
- if (enable_a20()) {
- boot_puts(a20_message);
- die();
- }
-
- /* Reset coprocessor (IGNNE#) */
- reset_coprocessor();
-
- setup_gdt();
- /* Actual transition to protected mode... */
- protected_mode_jump();
-}
diff --git a/arch/x86/boot/regs.c b/arch/x86/boot/regs.c
deleted file mode 100644
index 318b662175..0000000000
--- a/arch/x86/boot/regs.c
+++ /dev/null
@@ -1,29 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Intel Corporation
-
-/* Author: H. Peter Anvin */
-
-/**
- * @file
- * @brief Simple helper function for initializing a register set.
- *
- * Note that this sets EFLAGS_CF in the input register set; this
- * makes it easier to catch functions which do nothing but don't
- * explicitly set CF.
- */
-
-#include <asm/segment.h>
-#include "boot.h"
-
-/* be aware of: */
-THIS_IS_REALMODE_CODE
-
-void __bootcode initregs(struct biosregs *reg)
-{
- memset(reg, 0, sizeof *reg);
- reg->eflags |= X86_EFLAGS_CF;
- reg->ds = ds();
- reg->es = ds();
- reg->fs = fs();
- reg->gs = gs();
-}
diff --git a/arch/x86/boot/tty.c b/arch/x86/boot/tty.c
deleted file mode 100644
index 620197c677..0000000000
--- a/arch/x86/boot/tty.c
+++ /dev/null
@@ -1,41 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-// SPDX-FileCopyrightText: 1991,1992 Linus Torvalds
-// SPDX-FileCopyrightText: 2007 rPath, Inc.
-// SPDX-FileCopyrightText: 2009 Intel Corporation
-
-/* Author: H. Peter Anvin and others */
-
-/**
- * @file
- * @brief Very simple screen I/O for the initialization stage
- *
- * @todo Probably should add very simple serial I/O?
- * @attention This is real mode code!
- */
-
-#include <asm/segment.h>
-#include "boot.h"
-
-/* be aware of: */
-THIS_IS_REALMODE_CODE
-
-static void __bootcode putchar(int ch)
-{
- struct biosregs ireg;
-
- if (ch == '\n')
- putchar('\r'); /* \n -> \r\n */
-
- initregs(&ireg);
- ireg.bx = 0x0007;
- ireg.cx = 0x0001;
- ireg.ah = 0x0e;
- ireg.al = ch;
- intcall(0x10, &ireg, NULL);
-}
-
-void __bootcode boot_puts(char *str)
-{
- while (*str)
- putchar(*str++);
-}
diff --git a/arch/x86/configs/generic_defconfig b/arch/x86/configs/generic_defconfig
deleted file mode 100644
index 4620280136..0000000000
--- a/arch/x86/configs/generic_defconfig
+++ /dev/null
@@ -1,26 +0,0 @@
-CONFIG_X86_BIOS_BRINGUP=y
-CONFIG_X86_HDBOOT=y
-CONFIG_STACK_SIZE=0x7000
-CONFIG_EXPERIMENTAL=y
-CONFIG_GLOB=y
-CONFIG_CMDLINE_EDITING=y
-CONFIG_AUTO_COMPLETE=y
-CONFIG_PARTITION=y
-CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/x86/boards/x86_generic/env"
-CONFIG_LONGHELP=y
-CONFIG_CMD_MEMINFO=y
-# CONFIG_CMD_BOOTM is not set
-CONFIG_CMD_GO=y
-CONFIG_CMD_RESET=y
-CONFIG_CMD_EXPORT=y
-CONFIG_CMD_LOADENV=y
-CONFIG_CMD_PRINTENV=y
-CONFIG_CMD_SAVEENV=y
-# CONFIG_CMD_FALSE is not set
-CONFIG_CMD_SLEEP=y
-# CONFIG_CMD_TRUE is not set
-CONFIG_CMD_EDIT=y
-CONFIG_CMD_READLINE=y
-CONFIG_CMD_TIMEOUT=y
-CONFIG_DRIVER_SERIAL_NS16550=y
-# CONFIG_SPI is not set
diff --git a/arch/x86/include/asm/syslib.h b/arch/x86/include/asm/syslib.h
deleted file mode 100644
index 7e08cfd44e..0000000000
--- a/arch/x86/include/asm/syslib.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-#ifdef CONFIG_X86_BIOS_BRINGUP
-
-extern int bios_disk_rw_int13_extensions(int, int, void*) __attribute__((regparm(3)));
-extern uint16_t bios_get_memsize(void);
-
-#endif
-
-#ifdef CONFIG_CMD_LINUX16
-extern void bios_start_linux(unsigned) __attribute__((regparm(1)));
-#endif
diff --git a/arch/x86/lib/.gitignore b/arch/x86/lib/.gitignore
deleted file mode 100644
index d1165788c9..0000000000
--- a/arch/x86/lib/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-barebox.lds
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 6a8fa7c0ff..360aebf569 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -1,11 +1,2 @@
-extra-$(CONFIG_GENERIC_LINKER_SCRIPT) += barebox.lds
-ifneq ($(CONFIG_X86_EFI),y)
-obj-y += memory.o
-obj-y += gdt.o
-endif
-
obj-$(CONFIG_X86_32) += setjmp_32.o
obj-$(CONFIG_X86_64) += setjmp_64.o
-
-# needed, when running via a 16 bit BIOS
-obj-$(CONFIG_CMD_LINUX16) += linux_start.o
diff --git a/arch/x86/lib/asm-offsets.c b/arch/x86/lib/asm-offsets.c
index 0f9c47eaa9..22f382b71e 100644
--- a/arch/x86/lib/asm-offsets.c
+++ b/arch/x86/lib/asm-offsets.c
@@ -6,13 +6,7 @@
#include <linux/kbuild.h>
-#ifdef CONFIG_EFI_BOOTUP
int main(void)
{
return 0;
}
-#else
-void common(void)
-{
-}
-#endif
diff --git a/arch/x86/lib/barebox.lds.S b/arch/x86/lib/barebox.lds.S
deleted file mode 100644
index b24c4807b5..0000000000
--- a/arch/x86/lib/barebox.lds.S
+++ /dev/null
@@ -1,161 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-
-#undef i386
-#include <asm-generic/barebox.lds.h>
-
-OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
-OUTPUT_ARCH(i386)
-ENTRY(_start)
-
-MEMORY
-{
- mbr(rwx): ORIGIN = TEXT_BASE, LENGTH = 2 * SECTOR_SIZE
- barebox (rwx) : ORIGIN = TEXT_BASE + SECTOR_SIZE, LENGTH = (256 * 1024 * 1024)
-}
-
-SECTIONS
-{
-#ifdef CONFIG_X86_HDBOOT
-
- .ramlayout : {
- boot_stack = INDIRECT_AREA;
- indirect_area = INDIRECT_AREA;
- }
- /* describing the main boot sector */
- .bootsector : AT (0) {
- *(.boot_start)
-
- . = 0x00b;
- /*
- * Maybe later on occupied by a "BIOS parameter block". So,
- * keep it free from code.
- * - BytesPerSector dw@0x000B
- * - SectorsPerCluster db@0x000D
- * - ReservedSectors dw@0x000E
- * - FatCopies db@0x0010
- * - RootDirEntries dw@0x0011
- * - NumSectors dw@0x0013
- * - MediaType db@0x0015
- * - SectorsPerFAT dw@0x0016
- * - SectorsPerTrack dw@0x0018
- * - NumberOfHeads dw@0x001A
- * - HiddenSectors dd@0x001C
- * - SectorsBig dd@0x0020
- */
- LONG(0);
-
- . = 0x024;
- *(.boot_code)
- *(.boot_data)
-
- /*
- * embed one "Disk Address Packet Structure" into the boot sector
- * This DAPS points to the 'indirect' sector to give the boot code
- * an idea what and where to load. Its content must be adapted
- * to the system it should run on, so, this structure must be
- * located at a well known offset.
- */
- . = PATCH_AREA;
- indirect_sector_lba = .;
- SHORT(0x0010); /* size of this structure */
- SHORT(0x0001); /* one sector */
- SHORT(indirect_area); /* where to store: offset */
- SHORT(0x0000); /* where to store: segment */
- /* the following values are filled by the installer */
- LONG(0x00000000); /* LBA start lower */
- LONG(0x00000000); /* LBA start upper */
-
- /* boot disk number used by upper layers */
- . = PATCH_AREA + PATCH_AREA_BOOT_DEV;
- boot_disk = .;
- BYTE(0x00); /* boot disk number (provided by the BIOS)
-
- /* information about the persistent environment storage */
- . = PATCH_AREA + PATCH_AREA_PERS_START;
- pers_env_storage = .;
- LONG(0x00000000); /* LBA start lower */
- LONG(0x00000000); /* LBA start upper */
-
- . = PATCH_AREA + PATCH_AREA_PERS_SIZE;
- pers_env_size = .;
- SHORT(PATCH_AREA_PERS_SIZE_UNUSED); /* size of this area in sectors */
-
- . = PATCH_AREA + PATCH_AREA_PERS_DRIVE;
- pers_env_drive = .;
- BYTE(0x00); /* used drive */
-
- /* partition table area (fixed location) */
- . = OFFSET_OF_PARTITION_TABLE;
- /* create an empty one */
- LONG(0x00000000); LONG(0x00000000); LONG(0x00000000); LONG(0x00000000);
- LONG(0x00000000); LONG(0x00000000); LONG(0x00000000); LONG(0x00000000);
- LONG(0x00000000); LONG(0x00000000); LONG(0x00000000); LONG(0x00000000);
- LONG(0x00000000); LONG(0x00000000); LONG(0x00000000); LONG(0x00000000);
-
- /* boot sector signature */
- . = OFFSET_OF_SIGNATURE;
- BYTE(0x55);
- BYTE(0xAA);
- /* end of the first sector */
-
- /*
- * The indirect sector starts here
- */
- . = SECTOR_SIZE;
- BYTE(MARK_DAPS_INVALID); /* mark the first entry invalid */
- BYTE(0x00);
- . = SECTOR_SIZE + 496;
- BYTE(MARK_DAPS_INVALID); /* mark the last entry invalid */
- BYTE(0x00);
- . = SECTOR_SIZE + 508;
- LONG(0x00000000); /* LBA start upper */
- } > mbr
-
- /* some real mode bootstrapping */
- .bootstrapping : AT ( LOADADDR(.bootsector) + SIZEOF(.bootsector) ) {
- *(.boot.head)
- *(.boot.text*)
- *(.boot.rodata*)
- *(.boot.data*)
- . = ALIGN(4);
- RO_DATA_SECTION
- } > barebox
-#endif
-
- /* the main barebox part (32 bit) */
- .text : AT ( LOADADDR(.bootstrapping) + SIZEOF(.bootstrapping) ) {
- /* do not align here! It may fails with the LOADADDR! */
- _stext = .;
- _text = .;
- *(.text_entry*)
- __bare_init_start = .;
- *(.text_bare_init*)
- __bare_init_end = .;
- *(.text*)
- . = ALIGN(4);
- *(.rodata*)
- . = ALIGN(4);
- _etext = .; /* End of text and rodata section */
- } > barebox
- BAREBOX_BARE_INIT_SIZE
-
- _sdata = .;
- .data : AT ( LOADADDR(.text) + SIZEOF(.text) ) {
- *(.data*)
- . = ALIGN(4);
- } > barebox
-
- .got : AT ( LOADADDR(.data) + SIZEOF (.data) ) {
- *(.got*)
- . = ALIGN(4);
- } > barebox
-
- _edata = .;
- .bss : {
- __bss_start = .;
- *(.bss*);
- *( COMMON )
- __bss_stop = .;
- _end = .;
- } > barebox
-}
diff --git a/arch/x86/lib/gdt.c b/arch/x86/lib/gdt.c
deleted file mode 100644
index 4cd1622b6b..0000000000
--- a/arch/x86/lib/gdt.c
+++ /dev/null
@@ -1,38 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/**
- * @file
- * @brief Definition of the Global Descriptor Table
- */
-
-#include <types.h>
-#include <asm/modes.h>
-#include <asm/segment.h>
-
-/**
- * The 'Global Descriptor Table' used in barebox
- *
- * Note: This table must reachable by real and flat mode code
- */
-uint64_t gdt[] __attribute__((aligned(16))) __bootdata = {
- /* CS: code, read/execute, 4 GB, base 0 */
- [GDT_ENTRY_BOOT_CS] = GDT_ENTRY(0xc09b, 0, 0xfffff),
- /* DS: data, read/write, 4 GB, base 0 */
- [GDT_ENTRY_BOOT_DS] = GDT_ENTRY(0xc093, 0, 0xfffff),
- /* CS: for real mode calls */
- [GDT_ENTRY_REAL_CS] = GDT_ENTRY(0x009E, 0, 0x0ffff),
- /* DS: for real mode calls */
- [GDT_ENTRY_REAL_DS] = GDT_ENTRY(0x0092, 0, 0x0ffff),
- /* TSS: 32-bit tss, 104 bytes, base 4096 */
- /* We only have a TSS here to keep Intel VT happy;
- we don't actually use it for anything. */
- [GDT_ENTRY_BOOT_TSS] = GDT_ENTRY(0x0089, 4096, 103),
-};
-
-/**
- * Size of the GDT must be known to load it
- *
- * Note: This varibale must reachable by real and flat mode code
- */
-unsigned gdt_size __bootdata = sizeof(gdt);
diff --git a/arch/x86/lib/linux_start.S b/arch/x86/lib/linux_start.S
deleted file mode 100644
index 07be37fed4..0000000000
--- a/arch/x86/lib/linux_start.S
+++ /dev/null
@@ -1,55 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-/* SPDX-FileCopyrightText: 1999-2008 Free Software Foundation, Inc. */
-
-/* Mostly stolen from the GRUB2 project */
-
-/**
- * @file
- * @brief Start the Linux real mode setup code
- *
- * Note: These functions are running in flat and real mode. Due to some
- * other restrictions these routines must running from an address
- * space below 0x10000
- */
-
-/*
- * void bios_start_linux(unsigned segment)
- *
- */
-
- .section .boot.text.bios_start_linux, "ax"
- .code32
- .globl bios_start_linux
- .type bios_start_linux, @function
-
- .extern prot_to_real
-
-bios_start_linux:
- /* 'prot_to_real' eats our eax content */
- movl %eax, %ebx
- addl $0x20, %eax
- movw %ax, setup_seg
-
- call prot_to_real
-
- .code16
-
- cli
- /* all segment registers are using the same segment */
- movw %bx, %ss
- movw %bx, %ds
- movw %bx, %es
- movw %bx, %fs
- movw %bx, %gs
-
- /* stack for the setup code (end of heap) */
- movw $0x9000, %sp
-
- /* do an 'ljmp' and never return */
- .byte 0xea
- .word 0
-setup_seg:
- .word 0
-
- .code32
diff --git a/arch/x86/lib/memory.c b/arch/x86/lib/memory.c
deleted file mode 100644
index 64fbbb9300..0000000000
--- a/arch/x86/lib/memory.c
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/* This code was inspired by the GRUB2 project. */
-
-/**
- * @file
- * @brief Memory management
- */
-
-#include <common.h>
-#include <init.h>
-#include <stdio.h>
-#include <memory.h>
-#include <asm/syslib.h>
-#include <asm-generic/memory_layout.h>
-
-/**
- * Handling of free memory
- *
- * Topics:
- * - areas used by BIOS code
- * - The 0xa0000... 0xfffff hole
- * - memory above 0x100000
- */
-
-int x86_start_barebox(void)
-{
-#ifdef CONFIG_MEMORY_LAYOUT_DEFAULT
- unsigned long memory_size;
-
- memory_size = bios_get_memsize();
- memory_size <<= 10; /* BIOS reports in kiB */
-
- /*
- * We do not want to conflict with the kernel. So, we keep the
- * area from 0x100000 ... 0xFFFFFF free from usage
- */
- if (memory_size >= (15 * 1024 * 1024 + MALLOC_SIZE))
- mem_malloc_init((void*)(16 * 1024 * 1024),
- (void*)(16 * 1024 * 1024 + MALLOC_SIZE - 1));
- else
- return -1;
-#else
- mem_malloc_init((void *)MALLOC_BASE,
- (void *)(MALLOC_BASE + MALLOC_SIZE - 1));
-#endif
- start_barebox();
-}
diff --git a/arch/x86/mach-efi/elf_x86_64_efi.lds.S b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
index ed79118a36..ab4a9e815c 100644
--- a/arch/x86/mach-efi/elf_x86_64_efi.lds.S
+++ b/arch/x86/mach-efi/elf_x86_64_efi.lds.S
@@ -42,6 +42,7 @@ SECTIONS
*(.got.plt)
*(.got)
*(.data*)
+ __bss_start = .;
*(.sdata)
/* the EFI loader doesn't seem to like a .bss section, so we stick
* it all into .data: */
@@ -51,7 +52,9 @@ SECTIONS
*(.bss)
*(COMMON)
*(.rel.local)
+ __bss_stop = .;
}
+ _edata = .;
. = ALIGN(4096);
.dynamic : { *(.dynamic) }
diff --git a/arch/x86/mach-i386/Kconfig b/arch/x86/mach-i386/Kconfig
deleted file mode 100644
index 2d0bfb4759..0000000000
--- a/arch/x86/mach-i386/Kconfig
+++ /dev/null
@@ -1,13 +0,0 @@
-
-menu "Board specific settings"
-
-if X86_BOOTLOADER
-
-config X86_GENERIC_HAS_VIDEO
- bool "video support"
- help
- Say Y here if the target supports a video output
-
-endif
-
-endmenu
diff --git a/arch/x86/mach-i386/Makefile b/arch/x86/mach-i386/Makefile
deleted file mode 100644
index 225b4811c5..0000000000
--- a/arch/x86/mach-i386/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-# reference clocksource
-obj-y += pit_timer.o
diff --git a/arch/x86/mach-i386/include/mach/barebox.lds.h b/arch/x86/mach-i386/include/mach/barebox.lds.h
deleted file mode 100644
index 50f17340e4..0000000000
--- a/arch/x86/mach-i386/include/mach/barebox.lds.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/* SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-/**
- * @file
- * @brief Adapt linker script content in accordance to Kconfig settings
- */
-
-/**
- * Area in the MBR of the barebox basic boot code. This offset must be in
- * accordance to the 'indirect_sector_lba' label.
- */
-#define PATCH_AREA 400
-
-/**
- * Offset where to store the boot drive number (BIOS number, 1 byte)
- */
-#define PATCH_AREA_BOOT_DEV 16
-
-/**
- * Offset where to store information about the persistent environment storage
- * It points to an LBA number (8 bytes) and defines the first sector of this
- * storage on disk.
- */
-#define PATCH_AREA_PERS_START 20
-
-/**
- * Offset where to store information about the persistent environment storage
- * It points to a short number (2 bytes) and defines the sector count of this
- * storage on disk.
- */
-#define PATCH_AREA_PERS_SIZE 28
-
-/**
- * Offset where to store information about the persistent environment storage
- * drive number (BIOS number, 1 byte)
- */
-#define PATCH_AREA_PERS_DRIVE 30
-
-/**
- * Mark the persistent environment as not used
- */
-#define PATCH_AREA_PERS_SIZE_UNUSED 0x000
-
-/**
- * Mark a DAPS as unused/invalid
- */
-#define MARK_DAPS_INVALID 0x0000
-
-/**
- * Offset of the partition table in an MBR
- */
-#define OFFSET_OF_PARTITION_TABLE 446
-
-/**
- * Offset of the signature in an MBR
- */
-#define OFFSET_OF_SIGNATURE 510
-
-/**
- * Area where to store indirect sector to loop through. Keep this value
- * in accordance to the 'indirect_area' label. Note: .
- *
- * @attention These addresses are real mode ones (seg:offset)
- */
-#define INDIRECT_AREA 0x7A00
-#define INDIRECT_SEGMENT 0x0000
-
-/**
- * Area where to load sectors from disk to. They should start after the
- * MBR area and must be in accordance to the offset of the '.bootstrapping'
- * section in the linker file.
- *
- * @attention The address must be a multiple of 512.
- */
-#define LOAD_AREA 0x7e00
-#define LOAD_SEGMENT 0x0000
-
-/**
- * Size of one sector.
- */
-#define SECTOR_SIZE 512
diff --git a/arch/x86/mach-i386/pit_timer.c b/arch/x86/mach-i386/pit_timer.c
deleted file mode 100644
index d2da3b60d4..0000000000
--- a/arch/x86/mach-i386/pit_timer.c
+++ /dev/null
@@ -1,53 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix */
-
-/**
- * @file
- * @brief Clocksource based on the 'Programmable Interval Timer' PIT (8253)
- *
- * This timer should be available on almost all PCs. It also should be run
- * at a fixed frequency (1193181.8181 Hz) and not modified to use another
- * reload value than 0xFFFF. So, it always counts from 0xffff down to 0.
- *
- * @note: We can't reprogram the PIT, it will be still used by the BIOS. This
- * clocksource driver does not touch any PIT settings.
- */
-
-#include <init.h>
-#include <clock.h>
-#include <io.h>
-
-/** base address of the PIT in a standard PC */
-#define PIT 0x40
-
-static uint64_t pit_clocksource_read(void)
-{
- uint16_t val1, val2;
-
- outb(0x00, PIT + 3); /* latch counter 0 */
- outb(0x00, 0x80);
-
- val1 = inb(PIT);
- outb(0x00, 0x80);
-
- val2 = inb(PIT);
- val2 <<= 8;
-
- /* note: its a down counter */
- return 0xFFFFU - (val1 | val2);
-}
-
-static struct clocksource cs = {
- .read = pit_clocksource_read,
- .mask = CLOCKSOURCE_MASK(16),
- .shift = 10,
-};
-
-static int clocksource_init (void)
-{
- cs.mult = clocksource_hz2mult(1193182, cs.shift);
-
- return init_clock(&cs);
-}
-
-core_initcall(clocksource_init);
diff --git a/commands/Kconfig b/commands/Kconfig
index 6d84c956e5..b3937fdd8d 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -380,26 +380,6 @@ config CMD_BOOTZ
Usage: bootz FILE
-config CMD_LINUX16
- tristate
- depends on X86 && !X86_EFI
- default y if X86
- prompt "linux16"
- help
- Usage: linux16 [-v VESAMODE] FILE
-
- Load kernel from FILE and boot on x86 in real-mode.
-
- Only kernel images in bzImage format are supported by now.
-
- For the video mode refer the Linux kernel documentation
- 'Documentation/fb/vesafb.txt' for correct VESA mode numbers. Use 'ask'
- instead of a number to make Linux prompt for options.
-
- Options:
- -v VESAMODE set VESAMODE
-
-
config CMD_GO
tristate
prompt "go"
@@ -1884,7 +1864,6 @@ config CMD_NANDTEST
tristate
depends on NAND
depends on PARTITION
- depends on NAND_ECC_HW || NAND_ECC_SOFT
prompt "nandtest"
help
NAND flash memory test
diff --git a/commands/Makefile b/commands/Makefile
index cdf14a5e1d..447349fd15 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -3,7 +3,6 @@ obj-$(CONFIG_CMD_DIGEST) += digest.o
obj-$(CONFIG_COMPILE_HASH) += hashsum.o
obj-$(CONFIG_CMD_BOOTM) += bootm.o
obj-$(CONFIG_CMD_UIMAGE) += uimage.o
-obj-$(CONFIG_CMD_LINUX16) += linux16.o
obj-$(CONFIG_CMD_LOADB) += loadb.o
obj-$(CONFIG_CMD_LOADY) += loadxy.o
obj-$(CONFIG_CMD_LOADS) += loads.o
diff --git a/commands/edit.c b/commands/edit.c
index 3ab4beaa4f..f1e4e4d5c2 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -495,6 +495,10 @@ static int do_edit(int argc, char *argv[])
if (argc != 2)
return COMMAND_ERROR_USAGE;
+ buffer = NULL;
+ if(edit_read_file(argv[1]))
+ return 1;
+
screenwidth = 80;
/*
@@ -517,10 +521,6 @@ static int do_edit(int argc, char *argv[])
is_vi = true;
}
- buffer = NULL;
- if(edit_read_file(argv[1]))
- return 1;
-
cursx = 0;
cursy = 0;
textx = 0;
diff --git a/commands/linux16.c b/commands/linux16.c
deleted file mode 100644
index 73e402d877..0000000000
--- a/commands/linux16.c
+++ /dev/null
@@ -1,331 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: © 2009 Juergen Beisert, Pengutronix
-
-/*
- * In parts from the GRUB2 project:
- *
- * GRUB -- GRand Unified Bootloader
- * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2008 Free Software Foundation, Inc.
- */
-
-#include <common.h>
-#include <command.h>
-#include <environment.h>
-#include <fs.h>
-#include <errno.h>
-#include <libfile.h>
-#include <getopt.h>
-#include <malloc.h>
-#include <boot.h>
-#include <asm/syslib.h>
-
-/** FIXME */
-#define LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */
-
-/** FIXME */
-#define LINUX_FLAG_BIG_KERNEL 0x1
-
-/** FIXME */
-#define LINUX_BOOT_LOADER_TYPE 0x72
-
-/** FIXME */
-#define LINUX_DEFAULT_SETUP_SECTS 4
-
-/** FIXME */
-#define LINUX_MAX_SETUP_SECTS 64
-
-/** FIXME */
-#define LINUX_OLD_REAL_MODE_SEGMT 0x9000
-
-/** FIXME */
-#define LINUX_OLD_REAL_MODE_ADDR (LINUX_OLD_REAL_MODE_SEGMT << 4)
-
-/** FIXME */
-#define LINUX_HEAP_END_OFFSET (LINUX_OLD_REAL_MODE_SEGMT - 0x200)
-
-/** FIXME */
-#define LINUX_FLAG_CAN_USE_HEAP 0x80
-
-/** Define kernel command lines's start offset in the setup segment */
-#define LINUX_CL_OFFSET 0x9000
-
-/** Define kernel command lines's end offset */
-#define LINUX_CL_END_OFFSET 0x90FF
-
-/** FIXME */
-#define LINUX_CL_MAGIC 0xA33F
-
-/** FIXME */
-#define LINUX_SETUP_MOVE_SIZE 0x9100
-
-/** Sector size */
-#define DISK_SECTOR_BITS 9
-#define DISK_SECTOR_SIZE 0x200
-
-/** Where to load a bzImage */
-#define LINUX_BZIMAGE_ADDR 0x100000
-
-struct linux_kernel_header {
- /* first sector of the image */
- uint8_t code1[0x0020];
- uint16_t cl_magic; /**< Magic number 0xA33F */
- uint16_t cl_offset; /**< The offset of command line */
- uint8_t code2[0x01F1 - 0x0020 - 2 - 2];
- uint8_t setup_sects; /**< The size of the setup in sectors */
- uint16_t root_flags; /**< If the root is mounted readonly */
- uint16_t syssize; /**< obsolete */
- uint16_t swap_dev; /**< obsolete */
- uint16_t ram_size; /**< obsolete */
- uint16_t vid_mode; /**< Video mode control */
- uint16_t root_dev; /**< Default root device number */
- uint16_t boot_flag; /**< 0xAA55 magic number */
-
- /* second sector of the image */
- uint16_t jump; /**< Jump instruction (this is code!) */
- uint32_t header; /**< Magic signature "HdrS" */
- uint16_t version; /**< Boot protocol version supported */
- uint32_t realmode_swtch; /**< Boot loader hook */
- uint16_t start_sys; /**< The load-low segment (obsolete) */
- uint16_t kernel_version; /**< Points to kernel version string */
- uint8_t type_of_loader; /**< Boot loader identifier */
-#define LINUX_LOADER_ID_LILO 0x0
-#define LINUX_LOADER_ID_LOADLIN 0x1
-#define LINUX_LOADER_ID_BOOTSECT 0x2
-#define LINUX_LOADER_ID_SYSLINUX 0x3
-#define LINUX_LOADER_ID_ETHERBOOT 0x4
-#define LINUX_LOADER_ID_ELILO 0x5
-#define LINUX_LOADER_ID_GRUB 0x7
-#define LINUX_LOADER_ID_UBOOT 0x8
-#define LINUX_LOADER_ID_XEN 0x9
-#define LINUX_LOADER_ID_GUJIN 0xa
-#define LINUX_LOADER_ID_QEMU 0xb
- uint8_t loadflags; /**< Boot protocol option flags */
- uint16_t setup_move_size; /**< Move to high memory size */
- uint32_t code32_start; /**< Boot loader hook */
- uint32_t ramdisk_image; /**< initrd load address */
- uint32_t ramdisk_size; /**< initrd size */
- uint32_t bootsect_kludge; /**< obsolete */
- uint16_t heap_end_ptr; /**< Free memory after setup end */
- uint8_t ext_loader_ver; /**< boot loader's extension of the version number */
- uint8_t ext_loader_type; /**< boot loader's extension of its type */
- char *cmd_line_ptr; /**< Points to the kernel command line */
- uint32_t initrd_addr_max; /**< Highest address for initrd */
-#if 0
- /* for the records only. These members are defined in
- * more recent Linux kernels
- */
- uint32_t kernel_alignment; /**< Alignment unit required by the kernel */
- uint8_t relocatable_kernel; /** */
- uint8_t min_alignment; /** */
- uint32_t cmdline_size; /** */
- uint32_t hardware_subarch; /** */
- uint64_t hardware_subarch_data; /** */
- uint32_t payload_offset; /** */
- uint32_t payload_length; /** */
- uint64_t setup_data; /** */
- uint64_t pref_address; /** */
- uint32_t init_size; /** */
-#endif
-} __attribute__ ((packed));
-
-/* This is -1. Keep this value in sync with the kernel */
-#define NORMAL_VGA 0xffff /* 80x25 mode */
-#define ASK_VGA 0xfffd /* ask for it at bootup */
-
-/**
- * Load an x86 Linux kernel bzImage and start it
- * @param argc parameter count
- * @param argv list of parameter
- *
- * Loads an x86 bzImage, checks for its integrity, stores the two parts
- * (setup = 'real mode code' and kernel = 'protected mode code') to their
- * default locations, switches back to real mode and runs the setup code.
- */
-static int do_linux16(int argc, char *argv[])
-{
- struct linux_kernel_header *lh = NULL;
- int rc, opt;
- unsigned setup_sects;
- unsigned real_mode_size;
- int vid_mode = NORMAL_VGA;
- size_t image_size;
- const char *cmdline = linux_bootargs_get();
- const char *kernel_file;
-
- while((opt = getopt(argc, argv, "v:")) > 0) {
- switch(opt) {
- case 'v':
- vid_mode = simple_strtoul(optarg, NULL, 0);
- if (vid_mode == 0) {
- if (!strcmp(optarg, "ask"))
- vid_mode = ASK_VGA;
- else {
- printf("Unknown video mode: %s\n", optarg);
- return 1;
- }
- }
- break;
- default:
- return COMMAND_ERROR_USAGE;
- }
- }
-
- if (optind == argc) {
- printf("No kernel filename given\n");
- return 1;
- }
- kernel_file = argv[optind];
-
- lh = read_file(kernel_file, &image_size);
- if (lh == NULL) {
- printf("Cannot read file '%s'\n", argv[1]);
- return 1;
- }
-
- if (lh->boot_flag != 0xaa55) {
- printf("File '%s' has invalid magic number\n", argv[1]);
- rc = 1;
- goto on_error;
- }
-
- if (lh->setup_sects > LINUX_MAX_SETUP_SECTS) {
- printf("File '%s' contains too many setup sectors\n", argv[1]);
- rc = 1;
- goto on_error;
- }
-
- setup_sects = lh->setup_sects;
-
- printf("Found a %d.%d image header\n", lh->version >> 8, lh->version & 0xFF);
-
- if (lh->header == LINUX_MAGIC_SIGNATURE && lh->version >= 0x0200) {
- /* kernel is recent enough */
- ;
- if (!(lh->loadflags & LINUX_FLAG_BIG_KERNEL)) {
- printf("Cannot load a classic zImage. Use a bzImage instead\n");
- goto on_error;
- }
- lh->type_of_loader = LINUX_BOOT_LOADER_TYPE; /* TODO */
-
- if (lh->version >= 0x0201) {
- lh->heap_end_ptr = LINUX_HEAP_END_OFFSET;
- lh->loadflags |= LINUX_FLAG_CAN_USE_HEAP;
- }
-
- if (lh->version >= 0x0202)
- lh->cmd_line_ptr = (void*)(LINUX_OLD_REAL_MODE_ADDR + LINUX_CL_OFFSET); /* FIXME */
- else {
- lh->cl_magic = LINUX_CL_MAGIC;
- lh->cl_offset = LINUX_CL_OFFSET;
- lh->setup_move_size = LINUX_SETUP_MOVE_SIZE;
- }
- } else {
- printf("Kernel too old to handle\n");
- rc = 1;
- goto on_error;
- }
-
- if (strlen(cmdline) >= (LINUX_CL_END_OFFSET - LINUX_CL_OFFSET)) {
- printf("Kernel command line exceeds the available space\n");
- rc = 1;
- goto on_error;
- }
-
- /*
- * The kernel does not check for the "vga=<val>" kernel command line
- * parameter anymore. It expects this kind of information in the
- * boot parameters instead.
- */
- if (vid_mode != NORMAL_VGA)
- lh->vid_mode = vid_mode;
-
- /* If SETUP_SECTS is not set, set it to the default. */
- if (setup_sects == 0) {
- printf("Fixing setup sector count\n");
- setup_sects = LINUX_DEFAULT_SETUP_SECTS;
- }
-
- if (setup_sects >= 15) {
- void *src = lh;
- if (lh->kernel_version != 0)
- printf("Kernel version: '%s'\n",
- (char *)src + lh->kernel_version + DISK_SECTOR_SIZE);
- }
-
- /*
- * Size of the real mode part to handle in a separate way
- */
- real_mode_size = (setup_sects << DISK_SECTOR_BITS) + DISK_SECTOR_SIZE;
-
- /*
- * real mode space hole extended memory
- * |---------------------------------------------->|----------->|------------------------------>
- * 0 0xa0000 0x100000
- * <-1-|----------2-----------><-3- |
- * 0x7e00 0x90000
- * <-4--|-5--> |---------6------------->
- *
- * 1) real mode stack
- * 2) barebox code
- * 3) flat mode stack
- * 4) realmode stack when starting a Linux kernel
- * 5) Kernel's real mode setup code
- * 6) compressed kernel image
- */
- /*
- * Parts of the image we know:
- * - real mode part
- * - kernel payload
- */
- /*
- * NOTE: This part is dangerous, as it copies some image content to
- * various locations in the main memory. This could overwrite important
- * data of the running barebox (hopefully not)
- */
- /* copy the real mode part of the image to the 9th segment */
- memcpy((void*)LINUX_OLD_REAL_MODE_ADDR, lh, LINUX_SETUP_MOVE_SIZE);
-
- /* TODO add 'BOOT_IMAGE=<file>' and 'auto' if no user intervention was done (in front of all other params) */
- /* copy also the command line into this area */
- memcpy((void*)(LINUX_OLD_REAL_MODE_ADDR + LINUX_CL_OFFSET), cmdline, strlen(cmdline) + 1);
- printf("Using kernel command line: '%s'\n", cmdline);
-
- /* copy the compressed image part to its final address the setup code expects it
- * Note: The protected mode part starts at offset (setup_sects + 1) * 512
- */
- memcpy((void*)LINUX_BZIMAGE_ADDR, ((void*)lh) + real_mode_size, image_size - real_mode_size);
-
- /*
- * switch back to real mode now and start the real mode part of the
- * image at address "(LINUX_OLD_REAL_MODE_ADDR >> 4) + 0x20:0x0000"
- * which means "0x9020:0x000" -> 0x90200
- */
- bios_start_linux(LINUX_OLD_REAL_MODE_SEGMT); /* does not return */
-
-on_error:
- if (lh != NULL)
- free(lh);
-
- return rc;
-}
-
-BAREBOX_CMD_HELP_START(linux16)
-BAREBOX_CMD_HELP_TEXT("Load kernel from FILE and boot on x86 in real-mode.")
-BAREBOX_CMD_HELP_TEXT("")
-BAREBOX_CMD_HELP_TEXT("Only kernel images in bzImage format are supported by now.")
-BAREBOX_CMD_HELP_TEXT("")
-BAREBOX_CMD_HELP_TEXT("For the video mode refer the Linux kernel documentation")
-BAREBOX_CMD_HELP_TEXT("'Documentation/fb/vesafb.txt' for correct VESA mode numbers. Use 'ask'")
-BAREBOX_CMD_HELP_TEXT("instead of a number to make Linux for options..")
-BAREBOX_CMD_HELP_TEXT("")
-BAREBOX_CMD_HELP_TEXT("Options:")
-BAREBOX_CMD_HELP_OPT ("-v VESAMODE", "set VESAMODE")
-BAREBOX_CMD_HELP_END
-
-BAREBOX_CMD_START(linux16)
- .cmd = do_linux16,
- BAREBOX_CMD_DESC("boot a linux kernel on x86 via real-mode code")
- BAREBOX_CMD_OPTS("[-v VESAMODE] FILE")
- BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
- BAREBOX_CMD_HELP(cmd_linux16_help)
-BAREBOX_CMD_END
diff --git a/commands/nandtest.c b/commands/nandtest.c
index bfe4c4c0ed..1bb59c7fdb 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -178,12 +178,14 @@ static int erase_and_write(loff_t ofs, unsigned char *data,
}
/* Print stats of nandtest. */
-static void print_stats(int nr_passes, int length)
+static void print_stats(int nr_passes, loff_t length)
{
unsigned int i;
+ uint64_t blocks = (uint64_t)length;
+
+ do_div(blocks, meminfo.erasesize);
printf("-------- Summary --------\n");
- printf("Tested blocks : %d\n", (length/meminfo.erasesize)
- * nr_passes);
+ printf("Tested blocks : %lld\n", blocks * nr_passes);
for (i = 0; i < MAX_ECC_BITS; i++)
printf("ECC %d bit error(s) : %u\n", i + 1, ecc_stats[i]);
diff --git a/common/Kconfig b/common/Kconfig
index 342817bbcb..bddf802d3b 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -941,6 +941,14 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW_REBOOT_MODE
depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
depends on REBOOT_MODE
+config DEFAULT_ENVIRONMENT_GENERIC_NEW_IKCONFIG
+ bool "Ship .config as /env/data/config"
+ depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
+ help
+ This option embeds the used barebox Kconfig .config file into the
+ environment as /env/data/config. This will increases barebox image
+ size. If unsure, say n here.
+
config DEFAULT_ENVIRONMENT_PATH
string
depends on DEFAULT_ENVIRONMENT
diff --git a/common/clock.c b/common/clock.c
index fa90d1a457..b300e5798a 100644
--- a/common/clock.c
+++ b/common/clock.c
@@ -17,12 +17,6 @@
static uint64_t time_ns;
-/*
- * The first timestamp when the clocksource is registered.
- * Useful for measuring the time spent in barebox.
- */
-uint64_t time_beginning;
-
static uint64_t dummy_read(void)
{
static uint64_t dummy_counter;
@@ -222,8 +216,13 @@ int init_clock(struct clocksource *cs)
return ret;
}
+ /*
+ * If clocksource is freerunning it might have been running for a while
+ * before barebox started, we only care about the time spent in barebox
+ * thus we must discard the clocksource cycles up to this exact moment:
+ */
+ cs->cycle_last = cs->read() & cs->mask;
current_clock = cs;
- time_beginning = get_time_ns();
return 0;
}
diff --git a/common/console_common.c b/common/console_common.c
index 3e07415723..4c1230464c 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -188,8 +188,8 @@ void log_print(unsigned flags, unsigned levels)
unsigned long last = 0;
list_for_each_entry(log, &barebox_logbuf, list) {
- uint64_t diff = log->timestamp - time_beginning;
- unsigned long difful;
+ uint64_t time_ns = log->timestamp;
+ unsigned long time;
if (levels && !(levels & (1 << log->level)))
continue;
@@ -201,21 +201,19 @@ void log_print(unsigned flags, unsigned levels)
if (flags & BAREBOX_LOG_PRINT_RAW)
printf("<%i>", log->level);
- do_div(diff, 1000);
- difful = diff;
-
- if (!log->timestamp)
- difful = 0;
+ /* convert ns to us */
+ do_div(time_ns, 1000);
+ time = time_ns;
if (flags & (BAREBOX_LOG_PRINT_TIME | BAREBOX_LOG_DIFF_TIME))
printf("[");
if (flags & BAREBOX_LOG_PRINT_TIME)
- printf("%10luus", difful);
+ printf("%10luus", time);
if (flags & BAREBOX_LOG_DIFF_TIME) {
- printf(" < %10luus", difful - last);
- last = difful;
+ printf(" < %10luus", time - last);
+ last = time;
}
if (flags & (BAREBOX_LOG_PRINT_TIME | BAREBOX_LOG_DIFF_TIME))
diff --git a/common/efi/Makefile b/common/efi/Makefile
index ef19969f93..d746fabe21 100644
--- a/common/efi/Makefile
+++ b/common/efi/Makefile
@@ -1,3 +1,4 @@
obj-y += efi.o
obj-y += efi-image.o
bbenv-y += env-efi
+obj-$(CONFIG_CMD_IOMEM) += efi-iomem.o
diff --git a/common/efi/efi-iomem.c b/common/efi/efi-iomem.c
new file mode 100644
index 0000000000..e223c595c4
--- /dev/null
+++ b/common/efi/efi-iomem.c
@@ -0,0 +1,175 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2019 Ahmad Fatoum, Pengutronix
+
+#define pr_fmt(fmt) "efi-iomem: " fmt
+
+#include <common.h>
+#include <init.h>
+#include <efi.h>
+#include <efi/efi.h>
+#include <memory.h>
+#include <linux/sizes.h>
+
+static int efi_parse_mmap(struct efi_memory_desc *desc)
+{
+ struct resource *res;
+ u32 flags;
+ const char *name;
+ char *fullname;
+ resource_size_t va_base, va_size;
+ int ret = 0;
+
+ va_size = desc->npages * SZ_4K;
+ if (!va_size)
+ return 0;
+
+ /* XXX At least OVMF doesn't populate ->virt_start and leaves it at zero
+ * for all mapping. Thus assume a 1:1 mapping and ignore virt_start
+ */
+ va_base = desc->phys_start;
+
+ switch (desc->type) {
+ case EFI_RESERVED_TYPE:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "reserved";
+ flags = IORESOURCE_MEM | IORESOURCE_DISABLED;
+ break;
+ case EFI_LOADER_CODE:
+ return barebox_add_memory_bank("loader code", va_base, va_size);
+ case EFI_LOADER_DATA:
+ return barebox_add_memory_bank("loader data", va_base, va_size);
+ case EFI_BOOT_SERVICES_CODE:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "boot services code";
+ flags = IORESOURCE_MEM | IORESOURCE_READONLY;
+ break;
+ case EFI_BOOT_SERVICES_DATA:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "boot services data";
+ flags = IORESOURCE_MEM;
+ break;
+ case EFI_RUNTIME_SERVICES_CODE:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "runtime services code";
+ flags = IORESOURCE_MEM | IORESOURCE_READONLY;
+ break;
+ case EFI_RUNTIME_SERVICES_DATA:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "runtime services data";
+ flags = IORESOURCE_MEM;
+ break;
+ case EFI_CONVENTIONAL_MEMORY:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "conventional memory";
+ flags = IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_CACHEABLE;
+ break;
+ case EFI_UNUSABLE_MEMORY:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "unusable";
+ flags = IORESOURCE_MEM | IORESOURCE_DISABLED;
+ break;
+ case EFI_ACPI_RECLAIM_MEMORY:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "ACPI reclaim memory";
+ flags = IORESOURCE_MEM | IORESOURCE_READONLY;
+ break;
+ case EFI_ACPI_MEMORY_NVS:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "ACPI NVS memory";
+ flags = IORESOURCE_MEM | IORESOURCE_READONLY;
+ break;
+ case EFI_MEMORY_MAPPED_IO:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "MMIO";
+ flags = IORESOURCE_MEM;
+ break;
+ case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "MMIOPORT";
+ flags = IORESOURCE_IO;
+ break;
+ case EFI_PAL_CODE:
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+ name = "PAL code";
+ flags = IORESOURCE_MEM | IORESOURCE_ROM_BIOS_COPY;
+ break;
+ default:
+ if (!(desc->type & (1U << 31))) {
+ pr_warn("illegal memory type = %u >= %u\n",
+ desc->type, EFI_MAX_MEMORY_TYPE);
+ return -EINVAL;
+ }
+
+ if (!IS_ENABLED(DEBUG))
+ return 0;
+
+ name = "vendor reserved";
+ flags = IORESOURCE_MEM | IORESOURCE_ROM_BIOS_COPY;
+ }
+
+ fullname = xasprintf("%s@%llx", name, desc->phys_start);
+
+ pr_debug("%s: (0x%llx+0x%llx)\n", fullname, va_base, va_size);
+
+ res = request_iomem_region(fullname, va_base, va_base + va_size - 1);
+ if (IS_ERR(res)) {
+ ret = PTR_ERR(res);
+ goto out;
+ }
+
+ res->flags |= flags;
+
+out:
+ free(fullname);
+ return ret;
+}
+
+static int efi_barebox_populate_mmap(void)
+{
+ void *desc;
+ u8 *mmap_buf = NULL;
+ efi_status_t efiret;
+ size_t mmap_size;
+ size_t mapkey;
+ size_t descsz;
+ u32 descver;
+ int ret = 0;
+
+ mmap_size = sizeof(struct efi_memory_desc);
+
+ do {
+ mmap_buf = xrealloc(mmap_buf, mmap_size);
+ efiret = BS->get_memory_map(&mmap_size, mmap_buf,
+ &mapkey, &descsz, &descver);
+ } while (efiret == EFI_BUFFER_TOO_SMALL);
+
+ if (EFI_ERROR(efiret)) {
+ ret = -efi_errno(efiret);
+ goto out;
+ }
+
+ if (descver != 1) {
+ ret = -ENOSYS;
+ goto out;
+ }
+
+ for (desc = mmap_buf; (u8 *)desc < &mmap_buf[mmap_size]; desc += descsz)
+ efi_parse_mmap(desc);
+
+out:
+ free(mmap_buf);
+ return ret;
+}
+mem_initcall(efi_barebox_populate_mmap);
diff --git a/common/imd.c b/common/imd.c
index aff3b00b6b..e1d5733c6b 100644
--- a/common/imd.c
+++ b/common/imd.c
@@ -17,6 +17,10 @@ int imd_command_setenv(const char *variable_name, const char *value)
return -ENOSYS;
}
#endif
+static inline void read_file_2_free(void *buf)
+{
+ free(buf);
+}
#endif
/*
@@ -542,6 +546,6 @@ int imd_command(int argc, char *argv[])
ret = 0;
out:
- free(buf);
+ read_file_2_free(buf);
return ret;
}
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
index 0e008c6bc2..4e680a0a51 100644
--- a/common/imx-bbu-nand-fcb.c
+++ b/common/imx-bbu-nand-fcb.c
@@ -501,7 +501,8 @@ static int imx_bbu_firmware_start_block(struct mtd_info *mtd, int num)
* @num: The slot number (0 or 1)
*
* This returns the start page for a firmware slot, to be written into the
- * Firmwaren_startingPage field in the FCB.
+ * Firmwaren_startingPage field in the FCB or a negative error code in case
+ * of a failure.
*/
static int imx_bbu_firmware_fcb_start_page(struct mtd_info *mtd, int num)
{
@@ -512,6 +513,11 @@ static int imx_bbu_firmware_fcb_start_page(struct mtd_info *mtd, int num)
blocksleft = imx_bbu_firmware_max_blocks(mtd);
+ if (blocksleft <= 0) {
+ pr_err("partition size too small for both firmwares\n");
+ return -ENOMEM;
+ }
+
/*
* The ROM only checks for a bad block when advancing the read position,
* but not if the initial block is good, hence we cannot directly point
@@ -1258,7 +1264,15 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
free(fcb);
fcb = xzalloc(sizeof(*fcb));
fcb->Firmware1_startingPage = imx_bbu_firmware_fcb_start_page(mtd, !used);
+ if (fcb->Firmware1_startingPage < 0) {
+ ret = fcb->Firmware1_startingPage;
+ goto out;
+ }
fcb->Firmware2_startingPage = imx_bbu_firmware_fcb_start_page(mtd, used);
+ if (fcb->Firmware2_startingPage < 0) {
+ ret = fcb->Firmware2_startingPage;
+ goto out;
+ }
fcb->PagesInFirmware1 = fw_size / mtd->writesize;
fcb->PagesInFirmware2 = fcb->PagesInFirmware1;
diff --git a/common/memory.c b/common/memory.c
index a56eaf9494..392522bfc3 100644
--- a/common/memory.c
+++ b/common/memory.c
@@ -53,7 +53,7 @@ void mem_malloc_init(void *start, void *end)
mem_malloc_initialized = 1;
}
-#if !defined __SANDBOX__ && !defined CONFIG_EFI_BOOTUP
+#if !defined __SANDBOX__
static int mem_malloc_resource(void)
{
/*
diff --git a/common/partitions.c b/common/partitions.c
index deb931f329..d80878e065 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -6,9 +6,6 @@
/**
* @file
* @brief Generic support for partition tables on disk like media
- *
- * @todo Support for disks larger than 4 GiB
- * @todo Reliable size detection for BIOS based disks (on x86 only)
*/
#include <common.h>
#include <malloc.h>
diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 0012c48756..6c76aac371 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -36,31 +36,6 @@ static inline int is_extended_partition(struct partition *p)
p->dos_partition_type == LINUX_EXTENDED_PARTITION);
}
-/**
- * Guess the size of the disk, based on the partition table entries
- * @param dev device to create partitions for
- * @param table partition table
- * @return sector count
- */
-static uint64_t disk_guess_size(struct device_d *dev,
- struct partition_entry *table)
-{
- uint64_t size = 0;
- int i;
-
- for (i = 0; i < 4; i++) {
- if (get_unaligned_le32(&table[i].partition_start) != 0) {
- uint64_t part_end = get_unaligned_le32(&table[i].partition_start) +
- get_unaligned_le32(&table[i].partition_size);
-
- if (size < part_end)
- size = part_end;
- }
- }
-
- return size;
-}
-
static void *read_mbr(struct block_device *blk)
{
void *buf = malloc(SECTOR_SIZE);
@@ -209,10 +184,6 @@ static void dos_partition(void *buf, struct block_device *blk,
table = (struct partition_entry *)&buffer[446];
- /* valid for x86 BIOS based disks only */
- if (IS_ENABLED(CONFIG_DISK_BIOS) && blk->num_blocks == 0)
- blk->num_blocks = disk_guess_size(blk->dev, table);
-
for (i = 0; i < 4; i++) {
pentry.first_sec = get_unaligned_le32(&table[i].partition_start);
pentry.size = get_unaligned_le32(&table[i].partition_size);
diff --git a/defaultenv/Makefile b/defaultenv/Makefile
index 91293567c0..6879032118 100644
--- a/defaultenv/Makefile
+++ b/defaultenv/Makefile
@@ -32,3 +32,10 @@ cmd_env_zero = ($(objtree)/scripts/bareboxenv -z $(CONFIG_DEFAULT_ENVIRONMENT_PA
$(obj)/barebox_zero_env: FORCE
$(call if_changed,env_zero)
+
+bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_IKCONFIG) += defaultenv-2-ikconfig
+
+defaultenv/defaultenv-2-ikconfig.bbenv$(DEFAULT_COMPRESSION_SUFFIX): $(KCONFIG_CONFIG)
+ @mkdir -p defaultenv/defaultenv-2-ikconfig/data
+ @cp $(KCONFIG_CONFIG) defaultenv/defaultenv-2-ikconfig/data/config
+ $(call cmd,envgen,defaultenv/defaultenv-2-ikconfig)
diff --git a/defaultenv/defaultenv.c b/defaultenv/defaultenv.c
index d69446c893..055475eb47 100644
--- a/defaultenv/defaultenv.c
+++ b/defaultenv/defaultenv.c
@@ -47,6 +47,8 @@ static void defaultenv_add_base(void)
defaultenv_append_directory(defaultenv_2_dfu);
if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_REBOOT_MODE))
defaultenv_append_directory(defaultenv_2_reboot_mode);
+ if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW_IKCONFIG))
+ defaultenv_append_directory(defaultenv_2_ikconfig);
if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
defaultenv_append_directory(defaultenv_1);
}
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index c0f0a3dbe3..50d3ba7f3a 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -20,15 +20,6 @@ source "drivers/block/Kconfig"
comment "drive types"
-config DISK_BIOS
- bool "BIOS based"
- depends on X86_BIOS_BRINGUP
- help
- Gain disk drive access via int13 calls to the standard PC-BIOS.
- The advantage of this driver is, it still uses user's defined boot
- media to work on. Disadvantage is: Due to its 16 bit nature it is
- slow.
-
config DISK_ATA
bool "ATA type drives"
help
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 6b83ae2ef5..d3f5a0b57e 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -1,6 +1,5 @@
# drive types
-obj-$(CONFIG_DISK_BIOS) += disk_bios_drive.o
obj-$(CONFIG_DISK_IDE_SFF) += ide-sff.o
obj-$(CONFIG_DISK_ATA) += disk_ata_drive.o
obj-$(CONFIG_DISK_AHCI) += ahci.o
diff --git a/drivers/ata/disk_bios_drive.c b/drivers/ata/disk_bios_drive.c
deleted file mode 100644
index 8f522eeba6..0000000000
--- a/drivers/ata/disk_bios_drive.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (C) 2009...2011 Juergen Beisert, Pengutronix
- *
- * Mostly stolen from the GRUB2 project
- * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
- *
- * 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.
- *
- *
- */
-
-/**
- * @file
- * @brief Media communication layer through the standard 16 bit PC-BIOS
- *
- * This communication driver does all accesses to the boot medium via 16 bit
- * real mode calls into the standard BIOS. Due to this method, its possible
- * to use all the medias to boot from that are supported by the BIOS. This
- * also includes emulated only medias.
- *
- * To be able to call the real mode BIOS, this driver must switch back to
- * real mode for each access. This will slow down the access a little bit, but
- * we are a boot loader here, not an operating system...
- *
- * Note: We need scratch memory for the BIOS communication, because the BIOS
- * can only handle memory below 0xA0000. So we must copy all data between
- * the flat mode buffers and realmode buffers.
- *
- * Note: This driver makes no sense on other architectures than x86.
- *
- * Note: This driver does only support LBA addressing. Currently no CHS!
- */
-
-#include <common.h>
-#include <init.h>
-#include <asm/syslib.h>
-#include <errno.h>
-#include <block.h>
-#include <disks.h>
-#include <malloc.h>
-
-/**
- * Sector count handled in one count
- *
- * @todo 127 are always possible, some BIOS manufacturer supports up to 255.
- * Is it's worth to detect Phoenic's restriction?
- */
-#define SECTORS_AT_ONCE 64
-
-/** Command to read sectors from media */
-#define BIOS_READ_CMD 0
-
-/** Command to write sectors to media */
-#define BIOS_WRT_CMD 1
-
-/**
- * "Disk Address Packet Structure" to be used when calling
- * BIOS's int13, function 0x42/0x43
- */
-struct DAPS
-{
- uint8_t size; /**< always '16' */
- uint8_t res1; /**< always '0' */
- int8_t count; /**< number of sectors 0...127 */
- uint8_t res2; /**< always '0' */
- uint16_t offset; /**< buffer address: offset */
- uint16_t segment; /**< buffer address: segment */
- uint64_t lba; /**< LBA of the start sector */
-} __attribute__ ((packed));
-
-/**
- * Collection of data we need to know about the connected drive
- */
-struct media_access {
- struct block_device blk; /**< the main device */
- int drive_no; /**< drive number used by the BIOS */
- int is_cdrom; /**< drive is a CDROM e.g. no write support */
-};
-
-#define to_media_access(x) container_of((x), struct media_access, blk)
-
-/**
- * Scratch memory for BIOS communication to handle data in chunks of 32 kiB
- *
- * Note: This variable is located in the .bss segment, assuming it is located
- * below 0xA0000. If not, the BIOS is not able to read or store any data
- * from/to it. The variable must also aligned to a 16 byte boundary to easify
- * linear to segment:offset address conversion.
- */
-static uint8_t scratch_buffer[SECTORS_AT_ONCE * SECTOR_SIZE] __attribute__((aligned(16)));
-
-/**
- * Communication buffer for the 16 bit int13 BIOS call
- *
- * Note: This variable is located in the .bss segment, assuming it is located
- * below 0xA0000. If not, the BIOS is not able to read or store any data
- * from/to it. The variable must also aligned to a 16 byte boundary to easify
- * linear to segment:offset conversion.
- */
-static struct DAPS bios_daps __attribute__((aligned(16)));
-
-/**
- * @param media our data we need to do the access
- * @param cmd Command to forward to the BIOS
- * @param sector_start LBA of the start sector
- * @param sector_count Sector count
- * @param buffer Buffer to read from or write to (in the low memory area)
- * @return 0 on success, anything else on failure
- */
-static int biosdisk_bios_call(struct media_access *media, int cmd, sector_t sector_start, blkcnt_t sector_count, void *buffer)
-{
- int rc;
-
- /* prepare the DAPS for the int13 call */
- bios_daps.size = sizeof(struct DAPS);
- bios_daps.res1 = 0;
- bios_daps.count = sector_count; /* always less than 128! */
- bios_daps.res2 = 0;
- bios_daps.segment = (unsigned long)buffer >> 4;
- bios_daps.offset = (unsigned long)buffer - (unsigned long)(bios_daps.segment << 4);
- bios_daps.lba = sector_start;
-
- if (cmd == BIOS_READ_CMD)
- rc = bios_disk_rw_int13_extensions(0x42, media->drive_no, &bios_daps);
- else if (cmd == BIOS_WRT_CMD)
- rc = bios_disk_rw_int13_extensions(0x43, media->drive_no, &bios_daps);
- else
- return -1;
-
- return rc;
-}
-
-/**
- * Read a chunk of sectors from media
- * @param blk All info about the block device we need
- * @param buffer Buffer to read into
- * @param block Sector's LBA number to start read from
- * @param num_blocks Sector count to read
- * @return 0 on success, anything else on failure
- *
- * This routine expects the buffer has the correct size to store all data!
- *
- * @note Due to 'block' is of type 'int' only small disks can be handled!
- */
-static int biosdisk_read(struct block_device *blk, void *buffer, sector_t block,
- blkcnt_t num_blocks)
-{
- int rc;
- sector_t sector_start = block;
- blkcnt_t sector_count = num_blocks;
- struct media_access *media = to_media_access(blk);
-
- while (sector_count >= SECTORS_AT_ONCE) {
- rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
- if (rc != 0)
- return rc;
- __builtin_memcpy(buffer, scratch_buffer, sizeof(scratch_buffer));
- buffer += sizeof(scratch_buffer);
- sector_start += SECTORS_AT_ONCE;
- sector_count -= SECTORS_AT_ONCE;
- };
-
- /* Are sectors still remaining? */
- if (sector_count) {
- rc = biosdisk_bios_call(media, BIOS_READ_CMD, sector_start, sector_count, scratch_buffer);
- __builtin_memcpy(buffer, scratch_buffer, sector_count * SECTOR_SIZE);
- } else
- rc = 0;
-
- return rc;
-}
-
-/**
- * Write a chunk of sectors to media
- * @param blk All info about the block device we need
- * @param buffer Buffer to write from
- * @param block Sector's LBA number to start write to
- * @param num_blocks Sector count to write
- * @return 0 on success, anything else on failure
- *
- * This routine expects the buffer has the correct size to read all data!
- *
- * @note Due to 'block' is of type 'int' only small disks can be handled!
- */
-static int __maybe_unused biosdisk_write(struct block_device *blk,
- const void *buffer, sector_t block, blkcnt_t num_blocks)
-{
- int rc;
- sector_t sector_start = block;
- blkcnt_t sector_count = num_blocks;
- struct media_access *media = to_media_access(blk);
-
- while (sector_count >= SECTORS_AT_ONCE) {
- __builtin_memcpy(scratch_buffer, buffer, sizeof(scratch_buffer));
- rc = biosdisk_bios_call(media, BIOS_WRT_CMD, sector_start, SECTORS_AT_ONCE, scratch_buffer);
- if (rc != 0)
- return rc;
- buffer += sizeof(scratch_buffer);
- sector_start += SECTORS_AT_ONCE;
- sector_count -= SECTORS_AT_ONCE;
- };
-
- /* Are sectors still remaining? */
- if (sector_count) {
- __builtin_memcpy(scratch_buffer, buffer, sector_count * SECTOR_SIZE);
- rc = biosdisk_bios_call(media, BIOS_WRT_CMD, sector_start, sector_count, scratch_buffer);
- } else
- rc = 0;
-
- return rc;
-}
-
-static struct block_device_ops bios_ata = {
- .read = biosdisk_read,
-#ifdef CONFIG_BLOCK_WRITE
- .write = biosdisk_write,
-#endif
-};
-
-/**
- * Probe for connected drives and register them
- *
- * Detecting if a drive is present is done by simply reading its MBR.
- *
- * FIXME: Relation between BIOS disk numbering scheme and our representation
- * here in barebox (and later on in the linux kernel)
- */
-static int biosdisk_probe(struct device_d *dev)
-{
- int drive, rc;
- struct media_access media, *m;
-
- for (drive = 0x80; drive < 0x90; drive++) {
- media.drive_no = drive;
- media.is_cdrom = 0; /* don't know yet */
- rc = biosdisk_bios_call(&media, BIOS_READ_CMD, 0, 1, scratch_buffer);
- if (rc != 0)
- continue;
-
- printf("BIOSdrive %d seems valid. Registering...\n", media.drive_no);
-
- m = xzalloc(sizeof(struct media_access));
-
- m->blk.dev = dev;
- m->blk.ops = &bios_ata;
- /*
- * keep the 'blk.num_blocks' member 0, as we don't know
- * the size of this disk yet!
- */
- rc = cdev_find_free_index("disk");
- if (rc < 0)
- pr_err("Cannot find a free number for the disk node\n");
- m->blk.cdev.name = basprintf("disk%d", rc);
- m->blk.blockbits = SECTOR_SHIFT;
-
- rc = blockdevice_register(&m->blk);
- if (rc != 0) {
- dev_err(dev, "Cannot register BIOSdrive %d\n",
- media.drive_no);
- free(m);
- return rc;
- }
-
- /* create partitions on demand */
- rc = parse_partition_table(&m->blk);
- if (rc != 0)
- dev_warn(dev, "No partition table found\n");
- }
-
- return 0;
-}
-
-static struct driver_d biosdisk_driver = {
- .name = "biosdrive",
- .probe = biosdisk_probe,
-};
-
-static int biosdisk_init(void)
-{
- /* sanity */
- if (scratch_buffer > (uint8_t*)0x9FFFF) {
- printf("BIOS driver: Scratch memory not in real mode area. Cannot continue!\n");
- return -EIO;
- }
- if (&bios_daps > (struct DAPS*)0x9FFFF) {
- printf("BIOS driver: DAPS memory not in real mode area. Cannot continue!\n");
- return -EIO;
- }
-
- platform_driver_register(&biosdisk_driver);
- return 0;
-}
-
-device_initcall(biosdisk_init);
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 9c2e50e4a5..7119dd4e59 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -265,19 +265,17 @@ static int clk_divider_set_rate(struct clk *clk, unsigned long rate,
unsigned long parent_rate)
{
struct clk_divider *divider = container_of(clk, struct clk_divider, clk);
- unsigned int div, value;
+ unsigned int value;
u32 val;
if (divider->flags & CLK_DIVIDER_READ_ONLY)
return 0;
if (clk->flags & CLK_SET_RATE_PARENT) {
- unsigned long best_parent_rate = parent_rate;
- div = clk_divider_bestdiv(clk, rate, &best_parent_rate,
- divider->table, divider->width, divider->flags);
- clk_set_rate(clk_get_parent(clk), best_parent_rate);
- } else {
- div = DIV_ROUND_UP(parent_rate, rate);
+ clk_divider_bestdiv(clk, rate, &parent_rate,
+ divider->table, divider->width,
+ divider->flags);
+ clk_set_rate(clk_get_parent(clk), parent_rate);
}
value = divider_get_val(rate, parent_rate, divider->table,
diff --git a/drivers/clk/imx/clk-pllv1.c b/drivers/clk/imx/clk-pllv1.c
index 283ae843a7..36192bb211 100644
--- a/drivers/clk/imx/clk-pllv1.c
+++ b/drivers/clk/imx/clk-pllv1.c
@@ -12,12 +12,21 @@
#include "clk.h"
+#define MFN_BITS (10)
+#define MFN_SIGN (BIT(MFN_BITS - 1))
+#define MFN_MASK (MFN_SIGN - 1)
+
struct clk_pllv1 {
struct clk clk;
void __iomem *reg;
const char *parent;
};
+static inline bool mfn_is_negative(unsigned int mfn)
+{
+ return mfn & MFN_SIGN;
+}
+
static unsigned long clk_pllv1_recalc_rate(struct clk *clk,
unsigned long parent_rate)
{
@@ -50,7 +59,7 @@ static unsigned long clk_pllv1_recalc_rate(struct clk *clk,
ll = (unsigned long long)freq * mfn_abs;
do_div(ll, mfd + 1);
- if (mfn < 0)
+ if (mfn_is_negative(mfn))
ll = (freq * mfi) - ll;
else
ll = (freq * mfi) + ll;
diff --git a/drivers/clocksource/timer-riscv.c b/drivers/clocksource/timer-riscv.c
index eb5ba2d8c2..ef67cff475 100644
--- a/drivers/clocksource/timer-riscv.c
+++ b/drivers/clocksource/timer-riscv.c
@@ -30,10 +30,17 @@ static u64 notrace riscv_timer_get_count_sbi(void)
static u64 notrace riscv_timer_get_count_rdcycle(void)
{
- u64 ticks;
- asm volatile("rdcycle %0" : "=r" (ticks));
+ __maybe_unused u32 hi, lo;
+
+ if (IS_ENABLED(CONFIG_64BIT))
+ return csr_read(CSR_CYCLE);
- return ticks;
+ do {
+ hi = csr_read(CSR_CYCLEH);
+ lo = csr_read(CSR_CYCLE);
+ } while (hi != csr_read(CSR_CYCLEH));
+
+ return ((u64)hi << 32) | lo;
}
static u64 notrace riscv_timer_get_count(void)
diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index b9a8846ded..8dd9ca3bd5 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -84,7 +84,18 @@ static void pl061_set_value(struct gpio_chip *gc, unsigned offset, int value)
writeb(!!value << offset, chip->base + (1 << (offset + 2)));
}
+static int pl061_get_direction(struct gpio_chip *gc, unsigned offset)
+{
+ struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
+
+ if (readb(chip->base + GPIODIR) & (1 << offset))
+ return GPIOF_DIR_OUT;
+
+ return GPIOF_DIR_IN;
+}
+
static struct gpio_ops pl061_gpio_ops = {
+ .get_direction = pl061_get_direction,
.direction_input = pl061_direction_input,
.direction_output = pl061_direction_output,
.get = pl061_get_value,
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6088cadd8a..7b7261d01f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -6,6 +6,7 @@
#include <complete.h>
#include <gpio.h>
#include <of_gpio.h>
+#include <gpiod.h>
#include <errno.h>
#include <malloc.h>
@@ -554,6 +555,48 @@ static int of_gpiochip_scan_hogs(struct gpio_chip *chip)
return 0;
}
+/* Linux compatibility helper: Get a GPIO descriptor from device tree */
+int gpiod_get(struct device_d *dev, const char *_con_id, enum gpiod_flags flags)
+{
+ struct device_node *np = dev->device_node;
+ enum of_gpio_flags of_flags;
+ const char *con_id = "gpios", *label = dev_name(dev);
+ char *buf = NULL;
+ int gpio;
+ int ret;
+
+ if (!IS_ENABLED(CONFIG_OFDEVICE) || !dev->device_node)
+ return -ENODEV;
+
+ if (_con_id) {
+ con_id = buf = basprintf("%s-gpios", _con_id);
+ if (!buf)
+ return -ENOMEM;
+ }
+
+ gpio = of_get_named_gpio_flags(np, con_id, 0, &of_flags);
+ free(buf);
+
+ if (!gpio_is_valid(gpio))
+ return gpio < 0 ? gpio : -EINVAL;
+
+ if (of_flags & OF_GPIO_ACTIVE_LOW)
+ flags |= GPIOF_ACTIVE_LOW;
+
+ buf = NULL;
+
+ if (_con_id) {
+ label = buf = basprintf("%s-%s", dev_name(dev), _con_id);
+ if (!label)
+ return -ENOMEM;
+ }
+
+ ret = gpio_request_one(gpio, flags, label);
+ free(buf);
+
+ return ret ?: gpio;
+}
+
int gpiochip_add(struct gpio_chip *chip)
{
int base, i;
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 22eb2a056c..37fccda6be 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -131,7 +131,7 @@ static struct mtd_erase_region_info *mtd_find_erase_region(struct mtd_info *mtd,
for (i = 0; i < mtd->numeraseregions; i++) {
struct mtd_erase_region_info *e = &mtd->eraseregions[i];
- if (offset > e->offset + e->erasesize * e->numblocks)
+ if (offset > e->offset + (loff_t)e->erasesize * e->numblocks)
continue;
return e;
}
diff --git a/drivers/mtd/mtdoob.c b/drivers/mtd/mtdoob.c
index 04e064b227..19719c4d62 100644
--- a/drivers/mtd/mtdoob.c
+++ b/drivers/mtd/mtdoob.c
@@ -77,7 +77,7 @@ static int add_mtdoob_device(struct mtd_info *mtd, const char *devname, void **p
mtdoob = xzalloc(sizeof(*mtdoob));
mtdoob->cdev.ops = &mtd_ops_oob;
- mtdoob->cdev.size = mtd_div_by_wb(mtd->size, mtd) * mtd->oobsize;
+ mtdoob->cdev.size = mtd_div_by_wb(mtd->size, mtd) * (loff_t)mtd->oobsize;
mtdoob->cdev.name = basprintf("%s.oob", mtd->cdev.name);
mtdoob->cdev.priv = mtdoob;
mtdoob->cdev.dev = &mtd->dev;
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index a86b5b2da3..0b48373e6a 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -528,6 +528,7 @@ static int search_bbt(struct nand_chip *this, uint8_t *buf,
{
u64 targetsize = nanddev_target_size(&this->base);
struct mtd_info *mtd = nand_to_mtd(this);
+ struct nand_bbt_descr *bd = this->badblock_pattern;
int i, chips;
int startblock, block, dir;
int scanlen = mtd->writesize + mtd->oobsize;
@@ -563,6 +564,9 @@ static int search_bbt(struct nand_chip *this, uint8_t *buf,
int actblock = startblock + dir * block;
loff_t offs = (loff_t)actblock << this->bbt_erase_shift;
+ /* Check if block is marked bad */
+ if (scan_block_fast(this, bd, offs, buf))
+ continue;
/* Read first page */
scan_read(this, buf, offs, mtd->writesize, td);
if (!check_pattern(buf, scanlen, mtd->writesize, td)) {
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 96ae71364e..e4bad45a18 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -269,6 +269,33 @@ static void mxs_nand_return_dma_descs(struct mxs_nand_info *info)
info->desc_index = 0;
}
+/*
+ * We don't support writing the oob area so simply return the whole oob
+ * as ECC.
+ */
+static int mxs_nand_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *oobregion)
+{
+ if (section)
+ return -ERANGE;
+
+ oobregion->offset = 0;
+ oobregion->length = mtd->oobsize;
+
+ return 0;
+}
+
+static int mxs_nand_ooblayout_free(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *oobregion)
+{
+ return -ERANGE;
+}
+
+static const struct mtd_ooblayout_ops mxs_nand_ooblayout_ops = {
+ .ecc = mxs_nand_ooblayout_ecc,
+ .free = mxs_nand_ooblayout_free,
+};
+
static uint32_t mxs_nand_ecc_chunk_cnt(uint32_t page_data_size)
{
return page_data_size / MXS_NAND_CHUNK_DATA_CHUNK_SIZE;
@@ -2213,6 +2240,8 @@ static int mxs_nand_probe(struct device_d *dev)
mxs_nand_setup_timing(nand_info);
+ mtd_set_ooblayout(mtd, &mxs_nand_ooblayout_ops);
+
/* second phase scan */
err = nand_scan_tail(chip);
if (err)
diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c
index f3c51a61b4..03d96c2a5a 100644
--- a/drivers/mtd/peb.c
+++ b/drivers/mtd/peb.c
@@ -695,7 +695,7 @@ int mtd_peb_create_bitflips(struct mtd_info *mtd, int pnum, int offset,
ops.ooblen = mtd->oobsize;
for (i = 0; i < pages_per_block; i++) {
- loff_t offs = (loff_t)pnum * mtd->erasesize + i * mtd->writesize;
+ loff_t offs = (loff_t)pnum * mtd->erasesize + i * (loff_t)mtd->writesize;
ops.datbuf = buf + i * mtd->writesize;
ops.oobbuf = oobbuf + i * mtd->oobsize;
@@ -738,7 +738,7 @@ int mtd_peb_create_bitflips(struct mtd_info *mtd, int pnum, int offset,
}
for (i = 0; i < pages_per_block; i++) {
- loff_t offs = (loff_t)pnum * mtd->erasesize + i * mtd->writesize;
+ loff_t offs = (loff_t)pnum * mtd->erasesize + i * (loff_t)mtd->writesize;
ops.datbuf = buf + i * mtd->writesize;
ops.oobbuf = oobbuf + i * mtd->oobsize;
diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
index bd748ff5b4..383916e3f4 100644
--- a/drivers/mtd/spi-nor/spi-nor.c
+++ b/drivers/mtd/spi-nor/spi-nor.c
@@ -1131,7 +1131,7 @@ static int spi_nor_init_params(struct spi_nor *nor,
memset(params, 0, sizeof(*params));
/* Set SPI NOR sizes. */
- params->size = info->sector_size * info->n_sectors;
+ params->size = info->sector_size * (u64)info->n_sectors;
params->page_size = info->page_size;
/* (Fast) Read settings. */
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index e0e147b191..93a8bb9df1 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -141,13 +141,12 @@ static int at803x_parse_dt(struct phy_device *phydev)
const struct device_d *dev = &phydev->dev;
const struct device_node *node = dev->device_node;
struct at803x_priv *priv = phydev->priv;
- unsigned int sel, mask;
+ unsigned int sel;
u32 freq, strength;
int ret;
ret = of_property_read_u32(node, "qca,clk-out-frequency", &freq);
if (!ret) {
- mask = AT803X_CLK_OUT_MASK;
switch (freq) {
case 25000000:
sel = AT803X_CLK_OUT_25MHZ_XTAL;
@@ -166,8 +165,8 @@ static int at803x_parse_dt(struct phy_device *phydev)
return -EINVAL;
}
- priv->clk_25m_reg |= FIELD_PREP(mask, sel);
- priv->clk_25m_mask |= mask;
+ priv->clk_25m_reg |= FIELD_PREP(AT803X_CLK_OUT_MASK, sel);
+ priv->clk_25m_mask |= AT803X_CLK_OUT_MASK;
/* Fixup for the AR8030/AR8035. This chip has another mask and
* doesn't support the DSP reference. Eg. the lowest bit of the
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index e60037a6e6..dec1482ccd 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -28,3 +28,19 @@ config POWER_RESET_SYSCON_POWEROFF
select MFD_SYSCON
help
Poweroff support for generic SYSCON mapped register poweroff.
+
+config POWER_RESET_GPIO
+ bool "GPIO power-off driver"
+ depends on OF_GPIO
+ help
+ This driver supports turning off your board via a GPIO line.
+ If your board needs a GPIO high/low to power down, say Y and
+ create a binding in your devicetree.
+
+config POWER_RESET_GPIO_RESTART
+ bool "GPIO restart driver"
+ depends on OF_GPIO
+ help
+ This driver supports restarting your board via a GPIO line.
+ If your board needs a GPIO high/low to restart, say Y and
+ create a binding in your devicetree.
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index a490dce873..33d29d2d95 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -3,3 +3,5 @@ obj-$(CONFIG_REBOOT_MODE) += reboot-mode.o
obj-$(CONFIG_SYSCON_REBOOT_MODE) += syscon-reboot-mode.o
obj-$(CONFIG_POWER_RESET_SYSCON) += syscon-reboot.o
obj-$(CONFIG_POWER_RESET_SYSCON_POWEROFF) += syscon-poweroff.o
+obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
+obj-$(CONFIG_POWER_RESET_GPIO_RESTART) += gpio-restart.o
diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
new file mode 100644
index 0000000000..45b0d274e7
--- /dev/null
+++ b/drivers/power/reset/gpio-poweroff.c
@@ -0,0 +1,93 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Toggles a GPIO pin to power down a device
+ *
+ * Jamie Lentin <jm@lentin.co.uk>
+ * Andrew Lunn <andrew@lunn.ch>
+ *
+ * Copyright (C) 2012 Jamie Lentin
+ */
+#include <common.h>
+#include <driver.h>
+#include <poweroff.h>
+#include <gpiod.h>
+
+#define DEFAULT_TIMEOUT_MS 3000
+/*
+ * Hold configuration here, cannot be more than one instance of the driver
+ * since pm_power_off itself is global.
+ */
+static int reset_gpio;
+static u32 timeout = DEFAULT_TIMEOUT_MS;
+static u32 active_delay = 100;
+static u32 inactive_delay = 100;
+
+static void gpio_poweroff_do_poweroff(struct poweroff_handler *handler)
+{
+ /* drive it active, also inactive->active edge */
+ gpio_direction_active(reset_gpio, true);
+ mdelay(active_delay);
+
+ /* drive inactive, also active->inactive edge */
+ gpio_set_active(reset_gpio, false);
+ mdelay(inactive_delay);
+
+ /* drive it active, also inactive->active edge */
+ gpio_set_active(reset_gpio, true);
+
+ /* give it some time */
+ mdelay(timeout);
+
+ WARN_ON(1);
+}
+
+static struct poweroff_handler handler;
+
+static int gpio_poweroff_probe(struct device_d *dev)
+{
+ struct device_node *np = dev->device_node;
+ bool input = false;
+ enum gpiod_flags flags;
+
+ if (handler.poweroff != NULL) {
+ dev_err(dev, "%s: pm_power_off function already registered\n", __func__);
+ return -EBUSY;
+ }
+
+ input = of_property_read_bool(np, "input");
+ if (input)
+ flags = GPIOD_IN;
+ else
+ flags = GPIOD_OUT_LOW;
+
+ of_property_read_u32(np, "active-delay-ms", &active_delay);
+ of_property_read_u32(np, "inactive-delay-ms", &inactive_delay);
+ of_property_read_u32(np, "timeout-ms", &timeout);
+
+ reset_gpio = gpiod_get(dev, NULL, flags);
+ if (reset_gpio < 0)
+ return reset_gpio;
+
+ handler.name = "gpio-poweroff";
+ handler.poweroff = gpio_poweroff_do_poweroff;
+ handler.priority = 129;
+
+ return poweroff_handler_register(&handler);
+}
+
+static const struct of_device_id of_gpio_poweroff_match[] = {
+ { .compatible = "gpio-poweroff", },
+ {},
+};
+
+static struct driver_d gpio_poweroff_driver = {
+ .name = "poweroff-gpio",
+ .of_compatible = of_gpio_poweroff_match,
+ .probe = gpio_poweroff_probe,
+};
+device_platform_driver(gpio_poweroff_driver);
+
+MODULE_AUTHOR("Jamie Lentin <jm@lentin.co.uk>");
+MODULE_DESCRIPTION("GPIO poweroff driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:poweroff-gpio");
diff --git a/drivers/power/reset/gpio-restart.c b/drivers/power/reset/gpio-restart.c
new file mode 100644
index 0000000000..72c690a3cf
--- /dev/null
+++ b/drivers/power/reset/gpio-restart.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Toggles a GPIO pin to restart a device
+ *
+ * Copyright (C) 2014 Google, Inc.
+ *
+ * Based on the gpio-poweroff driver.
+ */
+#include <common.h>
+#include <driver.h>
+#include <restart.h>
+#include <gpiod.h>
+
+struct gpio_restart {
+ int reset_gpio;
+ struct restart_handler restart_handler;
+ u32 active_delay_ms;
+ u32 inactive_delay_ms;
+ u32 wait_delay_ms;
+};
+
+static void __noreturn gpio_restart_handle(struct restart_handler *this)
+{
+ struct gpio_restart *gpio_restart =
+ container_of(this, struct gpio_restart, restart_handler);
+
+ /* drive it active, also inactive->active edge */
+ gpio_direction_active(gpio_restart->reset_gpio, true);
+ mdelay(gpio_restart->active_delay_ms);
+
+ /* drive inactive, also active->inactive edge */
+ gpio_set_active(gpio_restart->reset_gpio, false);
+ mdelay(gpio_restart->inactive_delay_ms);
+
+ /* drive it active, also inactive->active edge */
+ gpio_set_active(gpio_restart->reset_gpio, true);
+
+ /* give it some time */
+ mdelay(gpio_restart->wait_delay_ms);
+
+ mdelay(1000);
+
+ panic("Unable to restart system\n");
+}
+
+static int gpio_restart_probe(struct device_d *dev)
+{
+ struct device_node *np = dev->device_node;
+ struct gpio_restart *gpio_restart;
+ bool open_source = false;
+ u32 property;
+ int ret;
+
+ gpio_restart = xzalloc(sizeof(*gpio_restart));
+
+ open_source = of_property_read_bool(np, "open-source");
+
+ gpio_restart->reset_gpio = gpiod_get(dev, NULL,
+ open_source ? GPIOD_IN : GPIOD_OUT_LOW);
+ ret = gpio_restart->reset_gpio;
+ if (ret < 0) {
+ if (ret != -EPROBE_DEFER)
+ dev_err(dev, "Could not get reset GPIO\n");
+ return ret;
+ }
+
+ gpio_restart->restart_handler.restart = gpio_restart_handle;
+ gpio_restart->restart_handler.name = "gpio-restart";
+ gpio_restart->restart_handler.priority = 129;
+ gpio_restart->active_delay_ms = 100;
+ gpio_restart->inactive_delay_ms = 100;
+ gpio_restart->wait_delay_ms = 3000;
+
+ ret = of_property_read_u32(dev->device_node, "priority", &property);
+ if (!ret)
+ gpio_restart->restart_handler.priority = property;
+
+ of_property_read_u32(np, "active-delay", &gpio_restart->active_delay_ms);
+ of_property_read_u32(np, "inactive-delay", &gpio_restart->inactive_delay_ms);
+ of_property_read_u32(np, "wait-delay", &gpio_restart->wait_delay_ms);
+
+ return restart_handler_register(&gpio_restart->restart_handler);
+}
+
+static const struct of_device_id of_gpio_restart_match[] = {
+ { .compatible = "gpio-restart", },
+ {},
+};
+
+static struct driver_d gpio_restart_driver = {
+ .name = "restart-gpio",
+ .of_compatible = of_gpio_restart_match,
+ .probe = gpio_restart_probe,
+};
+device_platform_driver(gpio_restart_driver);
+
+MODULE_AUTHOR("David Riley <davidriley@chromium.org>");
+MODULE_DESCRIPTION("GPIO restart driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 478ea49eed..a6e141817b 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -16,6 +16,12 @@ config PWM_PXA
This enables PWM support for Intel/Marvell PXA chips, such
as the PXA25x, PXA27x.
+config PWM_ATMEL
+ bool "Atmel PWM Support"
+ depends on ARCH_AT91
+ help
+ This enables PWM support for Ateml AT91 SoCs
+
config PWM_IMX
bool "i.MX PWM Support"
depends on ARCH_IMX || COMPILE_TEST
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index c0a27becef..55558aa42e 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_PWM) += core.o
obj-$(CONFIG_PWM_PXA) += pxa_pwm.o
+obj-$(CONFIG_PWM_ATMEL) += pwm-atmel.o
obj-$(CONFIG_PWM_IMX) += pwm-imx.o
obj-$(CONFIG_PWM_MXS) += pwm-mxs.o
obj-$(CONFIG_PWM_STM32) += pwm-stm32.o
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
new file mode 100644
index 0000000000..7fa394934a
--- /dev/null
+++ b/drivers/pwm/pwm-atmel.c
@@ -0,0 +1,289 @@
+/*
+ * Driver for Atmel Pulse Width Modulation Controller
+ *
+ * Copyright (C) 2013 Atmel Corporation
+ * Bo Shen <voice.shen@atmel.com>
+ * Copyright (C) 2018 Sam Ravnborg <sam@ravnborg.org>
+ *
+ * Licensed under GPLv2.
+ */
+
+#include <of_device.h>
+#include <common.h>
+#include <driver.h>
+#include <module.h>
+#include <printk.h>
+#include <stdio.h>
+#include <init.h>
+#include <pwm.h>
+#include <io.h>
+#include <of.h>
+
+#include <asm-generic/div64.h>
+
+#include <linux/time.h>
+#include <linux/clk.h>
+
+
+#define PWM_CHANNELS 4
+
+/* The following is global registers for PWM controller */
+#define PWM_ENA 0x04
+#define PWM_DIS 0x08
+#define PWM_SR 0x0C
+#define PWM_ISR 0x1C
+/* Bit field in SR */
+#define PWM_SR_ALL_CH_ON 0x0F
+
+/* The following register is PWM channel related registers */
+#define PWM_CH_REG_OFFSET 0x200
+#define PWM_CH_REG_SIZE 0x20
+
+#define PWM_CMR 0x0
+/* Bit field in CMR */
+#define PWM_CMR_CPOL (1 << 9)
+#define PWM_CMR_UPD_CDTY (1 << 10)
+#define PWM_CMR_CPRE_MSK 0xF
+
+/* The following registers for PWM v1 */
+#define PWMV1_CDTY 0x04
+#define PWMV1_CPRD 0x08
+#define PWMV1_CUPD 0x10
+
+/* The following registers for PWM v2 */
+#define PWMV2_CDTY 0x04
+#define PWMV2_CDTYUPD 0x08
+#define PWMV2_CPRD 0x0C
+#define PWMV2_CPRDUPD 0x10
+
+/*
+ * Max value for duty and period
+ *
+ * Although the duty and period register is 32 bit,
+ * however only the LSB 16 bits are significant.
+ */
+#define PWM_MAX_DTY 0xFFFF
+#define PWM_MAX_PRD 0xFFFF
+#define PRD_MAX_PRES 10
+
+struct atmel_pwm_registers {
+ u8 period;
+ u8 period_upd;
+ u8 duty;
+ u8 duty_upd;
+};
+
+struct atmel_pwm;
+
+struct atmel_pwm_chip {
+ struct pwm_chip chip;
+ struct atmel_pwm *atmel;
+};
+
+struct atmel_pwm {
+ struct atmel_pwm_chip atmel_pwm_chip[PWM_CHANNELS];
+ const struct atmel_pwm_registers *regs;
+ struct clk *clk;
+ void __iomem *base;
+ struct device_d *dev;
+};
+
+static inline struct atmel_pwm_chip *to_atmel_pwm_chip(struct pwm_chip *chip)
+{
+ return container_of(chip, struct atmel_pwm_chip, chip);
+}
+
+static inline void atmel_pwm_writel(struct atmel_pwm_chip *chip,
+ unsigned long offset, unsigned long val)
+{
+ writel(val, chip->atmel->base + offset);
+}
+
+static inline u32 atmel_pwm_ch_readl(struct atmel_pwm_chip *chip,
+ unsigned int ch, unsigned long offset)
+{
+ unsigned long base = PWM_CH_REG_OFFSET + ch * PWM_CH_REG_SIZE;
+
+ return readl(chip->atmel->base + base + offset);
+}
+
+static inline void atmel_pwm_ch_writel(struct atmel_pwm_chip *chip,
+ unsigned int ch, unsigned long offset,
+ unsigned long val)
+{
+ unsigned long base = PWM_CH_REG_OFFSET + ch * PWM_CH_REG_SIZE;
+
+ writel(val, chip->atmel->base + base + offset);
+}
+
+static int atmel_pwm_calculate_cprd_and_pres(struct atmel_pwm_chip *atmel_pwm,
+ int period,
+ unsigned long *cprd, u32 *pres)
+{
+ unsigned long long cycles = period;
+ /* Calculate the period cycles and prescale value */
+ cycles *= clk_get_rate(atmel_pwm->atmel->clk);
+ do_div(cycles, NSEC_PER_SEC);
+
+ for (*pres = 0; cycles > PWM_MAX_PRD; cycles >>= 1)
+ (*pres)++;
+
+ if (*pres > PRD_MAX_PRES) {
+ dev_err(atmel_pwm->atmel->dev, "pres exceeds the maximum value\n");
+ return -EINVAL;
+ }
+
+ *cprd = cycles;
+
+ return 0;
+}
+
+static void atmel_pwm_calculate_cdty(int duty, int period,
+ unsigned long cprd, unsigned long *cdty)
+{
+ unsigned long long cycles = duty;
+
+ cycles *= cprd;
+ do_div(cycles, period);
+ *cdty = cprd - cycles;
+}
+
+static void atmel_pwm_set_cprd_cdty(struct atmel_pwm_chip *atmel_pwm, int ch,
+ unsigned long cprd, unsigned long cdty)
+{
+ const struct atmel_pwm_registers *regs = atmel_pwm->atmel->regs;
+
+ atmel_pwm_ch_writel(atmel_pwm, ch, regs->duty, cdty);
+ atmel_pwm_ch_writel(atmel_pwm, ch, regs->period, cprd);
+}
+
+static int atmel_pwm_config(struct pwm_chip *chip, int duty_ns, int period_ns)
+{
+ struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
+ unsigned long cprd, cdty;
+ u32 pres, val;
+ int ret;
+ int ch;
+
+ ch = atmel_pwm->chip.id;
+ ret = atmel_pwm_calculate_cprd_and_pres(atmel_pwm, period_ns, &cprd, &pres);
+ if (ret)
+ return ret;
+
+ atmel_pwm_calculate_cdty(duty_ns, period_ns, cprd, &cdty);
+
+ /* It is necessary to preserve CPOL, inside CMR */
+ val = atmel_pwm_ch_readl(atmel_pwm, ch, PWM_CMR);
+ val = (val & ~PWM_CMR_CPRE_MSK) | (pres & PWM_CMR_CPRE_MSK);
+ /* Assuming normal polarity */
+ val &= ~PWM_CMR_CPOL;
+
+ atmel_pwm_ch_writel(atmel_pwm, ch, PWM_CMR, val);
+ atmel_pwm_set_cprd_cdty(atmel_pwm, ch, cprd, cdty);
+
+ return 0;
+}
+
+static int atmel_pwm_enable(struct pwm_chip *chip)
+{
+ struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
+
+ atmel_pwm_writel(atmel_pwm, PWM_ENA, 1 << atmel_pwm->chip.id);
+ return 0;
+}
+
+static void atmel_pwm_disable(struct pwm_chip *chip)
+{
+ struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
+
+ atmel_pwm_writel(atmel_pwm, PWM_DIS, 1 << atmel_pwm->chip.id);
+}
+
+static struct pwm_ops atmel_pwm_ops = {
+ .config = atmel_pwm_config,
+ .enable = atmel_pwm_enable,
+ .disable = atmel_pwm_disable,
+};
+
+static const struct atmel_pwm_registers atmel_pwm_regs_v1 = {
+ .period = PWMV1_CPRD,
+ .period_upd = PWMV1_CUPD,
+ .duty = PWMV1_CDTY,
+ .duty_upd = PWMV1_CUPD,
+};
+
+static const struct atmel_pwm_registers atmel_pwm_regs_v2 = {
+ .period = PWMV2_CPRD,
+ .period_upd = PWMV2_CPRDUPD,
+ .duty = PWMV2_CDTY,
+ .duty_upd = PWMV2_CDTYUPD,
+};
+
+static const struct of_device_id atmel_pwm_dt_ids[] = {
+ {
+ .compatible = "atmel,at91sam9rl-pwm",
+ .data = &atmel_pwm_regs_v1,
+ }, {
+ .compatible = "atmel,sama5d3-pwm",
+ .data = &atmel_pwm_regs_v2,
+ }, {
+ .compatible = "atmel,sama5d2-pwm",
+ .data = &atmel_pwm_regs_v2,
+ }, {
+ /* sentinel */
+ },
+};
+
+static int atmel_pwm_probe(struct device_d *dev)
+{
+ const struct atmel_pwm_registers *regs;
+ struct atmel_pwm *atmel_pwm;
+ struct resource *res;
+ int ret;
+ int i;
+
+ ret = dev_get_drvdata(dev, (const void **)&regs);
+ if (ret)
+ return ret;
+
+ atmel_pwm = xzalloc(sizeof(*atmel_pwm));
+ atmel_pwm->regs = regs;
+ atmel_pwm->dev = dev;
+ atmel_pwm->clk = clk_get(dev, "pwm_clk");
+ if (IS_ERR(atmel_pwm->clk))
+ return PTR_ERR(atmel_pwm->clk);
+
+ res = dev_request_mem_resource(dev, 0);
+ if (IS_ERR(res))
+ return PTR_ERR(res);
+
+ atmel_pwm->base = IOMEM(res);
+
+ for (i = 0; i < PWM_CHANNELS; i++) {
+ struct atmel_pwm_chip *chip = &atmel_pwm->atmel_pwm_chip[i];
+ chip->chip.ops = &atmel_pwm_ops;
+ chip->chip.devname = basprintf("pwm%d", i);
+ chip->chip.id = i;
+ chip->atmel = atmel_pwm;
+
+ ret = pwmchip_add(&chip->chip, dev);
+ if (ret < 0) {
+ dev_err(dev, "failed to add pwm chip[%d] %d\n", i, ret);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static struct driver_d atmel_pwm_driver = {
+ .name = "atmel-pwm",
+ .of_compatible = atmel_pwm_dt_ids,
+ .probe = atmel_pwm_probe,
+};
+
+coredevice_platform_driver(atmel_pwm_driver);
+
+MODULE_AUTHOR("Bo Shen <voice.shen@atmel.com>");
+MODULE_DESCRIPTION("Atmel PWM driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/sound/gpio-beeper.c b/drivers/sound/gpio-beeper.c
index 86fd4a4ee6..300998d607 100644
--- a/drivers/sound/gpio-beeper.c
+++ b/drivers/sound/gpio-beeper.c
@@ -7,8 +7,7 @@
#include <regulator.h>
#include <sound.h>
#include <of.h>
-#include <gpio.h>
-#include <of_gpio.h>
+#include <gpiod.h>
struct gpio_beeper {
int gpio;
@@ -28,21 +27,12 @@ static int gpio_beeper_probe(struct device_d *dev)
struct device_node *np = dev->device_node;
struct gpio_beeper *beeper;
struct sound_card *card;
- enum of_gpio_flags of_flags;
- unsigned long gpio_flags = GPIOF_OUT_INIT_ACTIVE;
- int ret, gpio;
+ int gpio;
- gpio = of_get_named_gpio_flags(np, "gpios", 0, &of_flags);
- if (!gpio_is_valid(gpio))
+ gpio = gpiod_get(dev, NULL, GPIOD_OUT_LOW);
+ if (gpio < 0) {
+ dev_err(dev, "failed to request gpio: %pe\n", ERR_PTR(gpio));
return gpio;
-
- if (of_flags & OF_GPIO_ACTIVE_LOW)
- gpio_flags |= GPIOF_ACTIVE_LOW;
-
- ret = gpio_request_one(gpio, gpio_flags, "gpio-beeper");
- if (ret) {
- dev_err(dev, "failed to request gpio %d: %d\n", gpio, ret);
- return ret;
}
beeper = xzalloc(sizeof(*beeper));
diff --git a/drivers/video/atmel_lcdfb_core.c b/drivers/video/atmel_lcdfb_core.c
index d8c35b2755..daabfe92d2 100644
--- a/drivers/video/atmel_lcdfb_core.c
+++ b/drivers/video/atmel_lcdfb_core.c
@@ -129,7 +129,7 @@ static int atmel_lcdfb_check_var(struct fb_info *info)
= info->bits_per_pixel;
break;
case 16:
- /* Older SOCs use BGR:555 rather than BGR:565. */
+ /* Older SOCs use BRG:555 rather than BRG:565. */
if (sinfo->have_intensity_bit)
info->green.length = 5;
else
@@ -139,7 +139,7 @@ static int atmel_lcdfb_check_var(struct fb_info *info)
info->red.offset = info->green.length + 5;
info->blue.offset = 0;
} else {
- /* BGR:5X5 mode */
+ /* BRG:5X5 mode */
info->red.offset = 0;
info->blue.offset = info->green.length + 5;
}
@@ -156,7 +156,7 @@ static int atmel_lcdfb_check_var(struct fb_info *info)
info->red.offset = 16;
info->blue.offset = 0;
} else {
- /* BGR:888 mode */
+ /* BRG:888 mode */
info->red.offset = 0;
info->blue.offset = 16;
}
@@ -279,7 +279,7 @@ static int power_control_init(struct device_d *dev,
}
/*
- * Syntax: atmel,lcd-wiring-mode: lcd wiring mode "RGB", "BGR"
+ * Syntax: atmel,lcd-wiring-mode: lcd wiring mode "RGB", "BRG"
*/
static int of_get_wiring_mode(struct device_node *np,
struct atmel_lcdfb_info *sinfo)
@@ -290,12 +290,12 @@ static int of_get_wiring_mode(struct device_node *np,
ret = of_property_read_string(np, "atmel,lcd-wiring-mode", &mode);
if (ret < 0) {
/* Not present, use defaults */
- sinfo->lcd_wiring_mode = ATMEL_LCDC_WIRING_BGR;
+ sinfo->lcd_wiring_mode = ATMEL_LCDC_WIRING_BRG;
return 0;
}
- if (!strcasecmp(mode, "BGR")) {
- sinfo->lcd_wiring_mode = ATMEL_LCDC_WIRING_BGR;
+ if (!strcasecmp(mode, "BRG")) {
+ sinfo->lcd_wiring_mode = ATMEL_LCDC_WIRING_BRG;
} else if (!strcasecmp(mode, "RGB")) {
sinfo->lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB;
} else {
diff --git a/drivers/video/bochs/bochs_pci.c b/drivers/video/bochs/bochs_pci.c
index 28785e1c06..39c4d1b662 100644
--- a/drivers/video/bochs/bochs_pci.c
+++ b/drivers/video/bochs/bochs_pci.c
@@ -27,6 +27,7 @@ static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent
static DEFINE_PCI_DEVICE_TABLE(bochs_pci_tbl) = {
/* https://github.com/qemu/qemu/blob/master/docs/specs/standard-vga.txt */
{ PCI_DEVICE(0x1234, 0x1111) },
+ { },
};
static struct pci_driver bochs_pci_driver = {
diff --git a/drivers/virtio/virtio_pci_common.h b/drivers/virtio/virtio_pci_common.h
index 32f0f451ab..8f97d12188 100644
--- a/drivers/virtio/virtio_pci_common.h
+++ b/drivers/virtio/virtio_pci_common.h
@@ -47,7 +47,7 @@ struct virtio_pci_device {
void __iomem *notify_base;
/* So we can sanity-check accesses. */
- size_t device_len;
+ u32 device_len;
/* Multiply queue_notify_off by this value. (non-legacy mode). */
u32 notify_offset_multiplier;
diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
index 180c14771a..d828bee69e 100644
--- a/drivers/virtio/virtio_pci_modern.c
+++ b/drivers/virtio/virtio_pci_modern.c
@@ -335,13 +335,6 @@ static void __iomem *virtio_pci_map_capability(struct pci_dev *dev, int off)
offset = off + offsetof(struct virtio_pci_cap, offset);
pci_read_config_dword(dev, offset, &offset);
- /*
- * TODO: adding 64-bit BAR support
- *
- * Per spec, the BAR is permitted to be either 32-bit or 64-bit.
- * For simplicity, only read the BAR address as 32-bit.
- */
-
return pci_iomap(dev, bar) + offset;
}
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index cf83b6a15b..df85a227ac 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -117,4 +117,11 @@ config F71808E_WDT
F71862FG, F71868, F71869, F71882FG, F71889FG, F81865 and F81866
Super I/O controllers.
+config GPIO_WATCHDOG
+ tristate "Watchdog device controlled through GPIO-line"
+ depends on OF_GPIO
+ help
+ If you say yes here you get support for watchdog device
+ controlled through GPIO-line.
+
endif
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index dc9842770a..e88da0adaf 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -16,3 +16,4 @@ obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o
obj-$(CONFIG_STM32_IWDG_WATCHDOG) += stm32_iwdg.o
obj-$(CONFIG_STPMIC1_WATCHDOG) += stpmic1_wdt.o
obj-$(CONFIG_F71808E_WDT) += f71808e_wdt.o
+obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o
diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
new file mode 100644
index 0000000000..4de49dcee3
--- /dev/null
+++ b/drivers/watchdog/gpio_wdt.c
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Driver for watchdog device controlled through GPIO-line
+ *
+ * Author: 2013, Alexander Shiyan <shc_work@mail.ru>
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <watchdog.h>
+#include <superio.h>
+#include <gpiod.h>
+
+enum {
+ HW_ALGO_TOGGLE,
+ HW_ALGO_LEVEL,
+};
+
+struct gpio_wdt_priv {
+ int gpio;
+ bool state;
+ bool started;
+ unsigned int hw_algo;
+ struct watchdog wdd;
+};
+
+static inline struct gpio_wdt_priv *to_gpio_wdt_priv(struct watchdog *wdd)
+{
+ return container_of(wdd, struct gpio_wdt_priv, wdd);
+}
+
+static void gpio_wdt_disable(struct gpio_wdt_priv *priv)
+{
+ /* Eternal ping */
+ gpio_set_active(priv->gpio, 1);
+
+ /* Put GPIO back to tristate */
+ if (priv->hw_algo == HW_ALGO_TOGGLE)
+ gpio_direction_input(priv->gpio);
+
+ priv->started = false;
+}
+
+static void gpio_wdt_ping(struct gpio_wdt_priv *priv)
+{
+ switch (priv->hw_algo) {
+ case HW_ALGO_TOGGLE:
+ /* Toggle output pin */
+ priv->state = !priv->state;
+ gpio_set_active(priv->gpio, priv->state);
+ break;
+ case HW_ALGO_LEVEL:
+ /* Pulse */
+ gpio_set_active(priv->gpio, true);
+ udelay(1);
+ gpio_set_active(priv->gpio, false);
+ break;
+ }
+}
+
+static void gpio_wdt_start(struct gpio_wdt_priv *priv)
+{
+ priv->state = false;
+ gpio_direction_active(priv->gpio, priv->state);
+ priv->started = true;
+}
+
+static int gpio_wdt_set_timeout(struct watchdog *wdd, unsigned int new_timeout)
+{
+ struct gpio_wdt_priv *priv = to_gpio_wdt_priv(wdd);
+
+ if (!new_timeout) {
+ gpio_wdt_disable(priv);
+ return 0;
+ }
+
+ if (!priv->started)
+ gpio_wdt_start(priv);
+
+ gpio_wdt_ping(priv);
+ return 0;
+}
+
+static int gpio_wdt_probe(struct device_d *dev)
+{
+ struct device_node *np = dev->device_node;
+ struct gpio_wdt_priv *priv;
+ enum gpiod_flags gflags;
+ unsigned int hw_margin;
+ const char *algo;
+ int ret;
+
+ priv = xzalloc(sizeof(*priv));
+
+ ret = of_property_read_u32(np, "hw_margin_ms", &hw_margin);
+ if (ret)
+ return ret;
+
+ /* Autoping is fixed at one ping every 500 ms. Round it up to a second */
+ if (hw_margin < 1000)
+ return -EINVAL;
+
+ ret = of_property_read_string(np, "hw_algo", &algo);
+ if (ret)
+ return ret;
+ if (!strcmp(algo, "toggle")) {
+ priv->hw_algo = HW_ALGO_TOGGLE;
+ gflags = GPIOD_IN;
+ } else if (!strcmp(algo, "level")) {
+ priv->hw_algo = HW_ALGO_LEVEL;
+ gflags = GPIOD_OUT_LOW;
+ } else {
+ return -EINVAL;
+ }
+
+ priv->gpio = gpiod_get(dev, NULL, gflags);
+ if (priv->gpio < 0)
+ return priv->gpio;
+
+ priv->wdd.hwdev = dev;
+ priv->wdd.timeout_max = hw_margin / 1000;
+ priv->wdd.priority = 129;
+ priv->wdd.set_timeout = gpio_wdt_set_timeout;
+
+ return watchdog_register(&priv->wdd);
+}
+
+static const struct of_device_id gpio_wdt_dt_ids[] = {
+ { .compatible = "linux,wdt-gpio", },
+ { }
+};
+
+static struct driver_d gpio_wdt_driver = {
+ .name = "gpio-wdt",
+ .of_compatible = gpio_wdt_dt_ids,
+ .probe = gpio_wdt_probe,
+};
+device_platform_driver(gpio_wdt_driver);
+
+MODULE_AUTHOR("Alexander Shiyan <shc_work@mail.ru>");
+MODULE_DESCRIPTION("GPIO Watchdog");
+MODULE_LICENSE("GPL");
diff --git a/dts/Bindings/hwmon/ntc_thermistor.txt b/dts/Bindings/hwmon/ntc_thermistor.txt
index 37f18d684f..4c5c371297 100644
--- a/dts/Bindings/hwmon/ntc_thermistor.txt
+++ b/dts/Bindings/hwmon/ntc_thermistor.txt
@@ -32,7 +32,7 @@ Optional node properties:
- "#thermal-sensor-cells" Used to expose itself to thermal fw.
Read more about iio bindings at
- Documentation/devicetree/bindings/iio/iio-bindings.txt
+ https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/
Example:
ncp15wb473@0 {
diff --git a/dts/Bindings/i2c/i2c-gpio.yaml b/dts/Bindings/i2c/i2c-gpio.yaml
index ff99344788..fd04028456 100644
--- a/dts/Bindings/i2c/i2c-gpio.yaml
+++ b/dts/Bindings/i2c/i2c-gpio.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Bindings for GPIO bitbanged I2C
maintainers:
- - Wolfram Sang <wolfram@the-dreams.de>
+ - Wolfram Sang <wsa@kernel.org>
allOf:
- $ref: /schemas/i2c/i2c-controller.yaml#
diff --git a/dts/Bindings/i2c/i2c-imx.yaml b/dts/Bindings/i2c/i2c-imx.yaml
index f23966b0d6..3592d49235 100644
--- a/dts/Bindings/i2c/i2c-imx.yaml
+++ b/dts/Bindings/i2c/i2c-imx.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: Freescale Inter IC (I2C) and High Speed Inter IC (HS-I2C) for i.MX
maintainers:
- - Wolfram Sang <wolfram@the-dreams.de>
+ - Oleksij Rempel <o.rempel@pengutronix.de>
allOf:
- $ref: /schemas/i2c/i2c-controller.yaml#
diff --git a/dts/Bindings/iio/adc/ingenic,adc.yaml b/dts/Bindings/iio/adc/ingenic,adc.yaml
index 9f414dbdae..433a3fb55a 100644
--- a/dts/Bindings/iio/adc/ingenic,adc.yaml
+++ b/dts/Bindings/iio/adc/ingenic,adc.yaml
@@ -14,8 +14,9 @@ description: >
Industrial I/O subsystem bindings for ADC controller found in
Ingenic JZ47xx SoCs.
- ADC clients must use the format described in iio-bindings.txt, giving
- a phandle and IIO specifier pair ("io-channels") to the ADC controller.
+ ADC clients must use the format described in
+ https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml,
+ giving a phandle and IIO specifier pair ("io-channels") to the ADC controller.
properties:
compatible:
diff --git a/dts/Bindings/input/adc-joystick.yaml b/dts/Bindings/input/adc-joystick.yaml
index 054406bbd2..721878d5b7 100644
--- a/dts/Bindings/input/adc-joystick.yaml
+++ b/dts/Bindings/input/adc-joystick.yaml
@@ -24,7 +24,9 @@ properties:
description: >
List of phandle and IIO specifier pairs.
Each pair defines one ADC channel to which a joystick axis is connected.
- See Documentation/devicetree/bindings/iio/iio-bindings.txt for details.
+ See
+ https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml
+ for details.
'#address-cells':
const: 1
diff --git a/dts/Bindings/input/touchscreen/resistive-adc-touch.txt b/dts/Bindings/input/touchscreen/resistive-adc-touch.txt
index 51456c0e9a..af5223bb5b 100644
--- a/dts/Bindings/input/touchscreen/resistive-adc-touch.txt
+++ b/dts/Bindings/input/touchscreen/resistive-adc-touch.txt
@@ -5,7 +5,10 @@ Required properties:
- compatible: must be "resistive-adc-touch"
The device must be connected to an ADC device that provides channels for
position measurement and optional pressure.
-Refer to ../iio/iio-bindings.txt for details
+Refer to
+https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml
+for details
+
- iio-channels: must have at least two channels connected to an ADC device.
These should correspond to the channels exposed by the ADC device and should
have the right index as the ADC device registers them. These channels
diff --git a/dts/Bindings/leds/cznic,turris-omnia-leds.yaml b/dts/Bindings/leds/cznic,turris-omnia-leds.yaml
index fe7fa25877..c7ed2871da 100644
--- a/dts/Bindings/leds/cznic,turris-omnia-leds.yaml
+++ b/dts/Bindings/leds/cznic,turris-omnia-leds.yaml
@@ -7,7 +7,7 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
title: CZ.NIC's Turris Omnia LEDs driver
maintainers:
- - Marek BehĂșn <marek.behun@nic.cz>
+ - Marek BehĂșn <kabel@kernel.org>
description:
This module adds support for the RGB LEDs found on the front panel of the
diff --git a/dts/Bindings/mfd/ab8500.txt b/dts/Bindings/mfd/ab8500.txt
index d2a6e835c2..937b3e5505 100644
--- a/dts/Bindings/mfd/ab8500.txt
+++ b/dts/Bindings/mfd/ab8500.txt
@@ -72,7 +72,9 @@ Required child device properties:
pwm|regulator|rtc|sysctrl|usb]";
A few child devices require ADC channels from the GPADC node. Those follow the
- standard bindings from iio/iio-bindings.txt and iio/adc/adc.txt
+ standard bindings from
+ https://github.com/devicetree-org/dt-schema/blob/master/schemas/iio/iio-consumer.yaml
+ and Documentation/devicetree/bindings/iio/adc/adc.yaml
abx500-temp : io-channels "aux1" and "aux2" for measuring external
temperatures.
diff --git a/dts/Bindings/mfd/motorola-cpcap.txt b/dts/Bindings/mfd/motorola-cpcap.txt
index 5ddcc8f4fe..b52e7a33f0 100644
--- a/dts/Bindings/mfd/motorola-cpcap.txt
+++ b/dts/Bindings/mfd/motorola-cpcap.txt
@@ -16,14 +16,14 @@ Optional subnodes:
The sub-functions of CPCAP get their own node with their own compatible values,
which are described in the following files:
-- ../power/supply/cpcap-battery.txt
-- ../power/supply/cpcap-charger.txt
-- ../regulator/cpcap-regulator.txt
-- ../phy/phy-cpcap-usb.txt
-- ../input/cpcap-pwrbutton.txt
-- ../rtc/cpcap-rtc.txt
-- ../leds/leds-cpcap.txt
-- ../iio/adc/cpcap-adc.txt
+- Documentation/devicetree/bindings/power/supply/cpcap-battery.txt
+- Documentation/devicetree/bindings/power/supply/cpcap-charger.txt
+- Documentation/devicetree/bindings/regulator/cpcap-regulator.txt
+- Documentation/devicetree/bindings/phy/phy-cpcap-usb.txt
+- Documentation/devicetree/bindings/input/cpcap-pwrbutton.txt
+- Documentation/devicetree/bindings/rtc/cpcap-rtc.txt
+- Documentation/devicetree/bindings/leds/leds-cpcap.txt
+- Documentation/devicetree/bindings/iio/adc/motorola,cpcap-adc.yaml
The only exception is the audio codec. Instead of a compatible value its
node must be named "audio-codec".
diff --git a/dts/Bindings/net/brcm,bcm4908-enet.yaml b/dts/Bindings/net/brcm,bcm4908-enet.yaml
index 79c38ea142..13c26f23a8 100644
--- a/dts/Bindings/net/brcm,bcm4908-enet.yaml
+++ b/dts/Bindings/net/brcm,bcm4908-enet.yaml
@@ -32,7 +32,7 @@ required:
- interrupts
- interrupt-names
-additionalProperties: false
+unevaluatedProperties: false
examples:
- |
diff --git a/dts/Bindings/net/ethernet-controller.yaml b/dts/Bindings/net/ethernet-controller.yaml
index 4b7d1e5d00..e8f04687a3 100644
--- a/dts/Bindings/net/ethernet-controller.yaml
+++ b/dts/Bindings/net/ethernet-controller.yaml
@@ -49,7 +49,7 @@ properties:
description:
Reference to an nvmem node for the MAC address
- nvmem-cells-names:
+ nvmem-cell-names:
const: mac-address
phy-connection-type:
diff --git a/dts/Bindings/net/micrel-ksz90x1.txt b/dts/Bindings/net/micrel-ksz90x1.txt
index b921731cd9..df9e844dd6 100644
--- a/dts/Bindings/net/micrel-ksz90x1.txt
+++ b/dts/Bindings/net/micrel-ksz90x1.txt
@@ -65,6 +65,71 @@ KSZ9031:
step is 60ps. The default value is the neutral setting, so setting
rxc-skew-ps=<0> actually results in -900 picoseconds adjustment.
+ The KSZ9031 hardware supports a range of skew values from negative to
+ positive, where the specific range is property dependent. All values
+ specified in the devicetree are offset by the minimum value so they
+ can be represented as positive integers in the devicetree since it's
+ difficult to represent a negative number in the devictree.
+
+ The following 5-bit values table apply to rxc-skew-ps and txc-skew-ps.
+
+ Pad Skew Value Delay (ps) Devicetree Value
+ ------------------------------------------------------
+ 0_0000 -900ps 0
+ 0_0001 -840ps 60
+ 0_0010 -780ps 120
+ 0_0011 -720ps 180
+ 0_0100 -660ps 240
+ 0_0101 -600ps 300
+ 0_0110 -540ps 360
+ 0_0111 -480ps 420
+ 0_1000 -420ps 480
+ 0_1001 -360ps 540
+ 0_1010 -300ps 600
+ 0_1011 -240ps 660
+ 0_1100 -180ps 720
+ 0_1101 -120ps 780
+ 0_1110 -60ps 840
+ 0_1111 0ps 900
+ 1_0000 60ps 960
+ 1_0001 120ps 1020
+ 1_0010 180ps 1080
+ 1_0011 240ps 1140
+ 1_0100 300ps 1200
+ 1_0101 360ps 1260
+ 1_0110 420ps 1320
+ 1_0111 480ps 1380
+ 1_1000 540ps 1440
+ 1_1001 600ps 1500
+ 1_1010 660ps 1560
+ 1_1011 720ps 1620
+ 1_1100 780ps 1680
+ 1_1101 840ps 1740
+ 1_1110 900ps 1800
+ 1_1111 960ps 1860
+
+ The following 4-bit values table apply to the txdX-skew-ps, rxdX-skew-ps
+ data pads, and the rxdv-skew-ps, txen-skew-ps control pads.
+
+ Pad Skew Value Delay (ps) Devicetree Value
+ ------------------------------------------------------
+ 0000 -420ps 0
+ 0001 -360ps 60
+ 0010 -300ps 120
+ 0011 -240ps 180
+ 0100 -180ps 240
+ 0101 -120ps 300
+ 0110 -60ps 360
+ 0111 0ps 420
+ 1000 60ps 480
+ 1001 120ps 540
+ 1010 180ps 600
+ 1011 240ps 660
+ 1100 300ps 720
+ 1101 360ps 780
+ 1110 420ps 840
+ 1111 480ps 900
+
Optional properties:
Maximum value of 1860, default value 900:
@@ -120,11 +185,21 @@ KSZ9131:
Examples:
+ /* Attach to an Ethernet device with autodetected PHY */
+ &enet {
+ rxc-skew-ps = <1800>;
+ rxdv-skew-ps = <0>;
+ txc-skew-ps = <1800>;
+ txen-skew-ps = <0>;
+ status = "okay";
+ };
+
+ /* Attach to an explicitly-specified PHY */
mdio {
phy0: ethernet-phy@0 {
- rxc-skew-ps = <3000>;
+ rxc-skew-ps = <1800>;
rxdv-skew-ps = <0>;
- txc-skew-ps = <3000>;
+ txc-skew-ps = <1800>;
txen-skew-ps = <0>;
reg = <0>;
};
@@ -133,3 +208,20 @@ Examples:
phy = <&phy0>;
phy-mode = "rgmii-id";
};
+
+References
+
+ Micrel ksz9021rl/rn Data Sheet, Revision 1.2. Dated 2/13/2014.
+ http://www.micrel.com/_PDF/Ethernet/datasheets/ksz9021rl-rn_ds.pdf
+
+ Micrel ksz9031rnx Data Sheet, Revision 2.1. Dated 11/20/2014.
+ http://www.micrel.com/_PDF/Ethernet/datasheets/KSZ9031RNX.pdf
+
+Notes:
+
+ Note that a previous version of the Micrel ksz9021rl/rn Data Sheet
+ was missing extended register 106 (transmit data pad skews), and
+ incorrectly specified the ps per step as 200ps/step instead of
+ 120ps/step. The latest update to this document reflects the latest
+ revision of the Micrel specification even though usage in the kernel
+ still reflects that incorrect document.
diff --git a/dts/Bindings/sound/fsl,spdif.yaml b/dts/Bindings/sound/fsl,spdif.yaml
index 50449b6d10..4454aca34d 100644
--- a/dts/Bindings/sound/fsl,spdif.yaml
+++ b/dts/Bindings/sound/fsl,spdif.yaml
@@ -21,6 +21,10 @@ properties:
- fsl,vf610-spdif
- fsl,imx6sx-spdif
- fsl,imx8qm-spdif
+ - fsl,imx8qxp-spdif
+ - fsl,imx8mq-spdif
+ - fsl,imx8mm-spdif
+ - fsl,imx8mn-spdif
reg:
maxItems: 1
diff --git a/dts/include/dt-bindings/bus/moxtet.h b/dts/include/dt-bindings/bus/moxtet.h
index dc9345440e..10528de7b3 100644
--- a/dts/include/dt-bindings/bus/moxtet.h
+++ b/dts/include/dt-bindings/bus/moxtet.h
@@ -2,7 +2,7 @@
/*
* Constant for device tree bindings for Turris Mox module configuration bus
*
- * Copyright (C) 2019 Marek Behun <marek.behun@nic.cz>
+ * Copyright (C) 2019 Marek BehĂșn <kabel@kernel.org>
*/
#ifndef _DT_BINDINGS_BUS_MOXTET_H
diff --git a/dts/src/arc/haps_hs.dts b/dts/src/arc/haps_hs.dts
index 60d578e278..76ad527a08 100644
--- a/dts/src/arc/haps_hs.dts
+++ b/dts/src/arc/haps_hs.dts
@@ -16,7 +16,7 @@
memory {
device_type = "memory";
/* CONFIG_LINUX_RAM_BASE needs to match low mem start */
- reg = <0x0 0x80000000 0x0 0x20000000 /* 512 MB low mem */
+ reg = <0x0 0x80000000 0x0 0x40000000 /* 1 GB low mem */
0x1 0x00000000 0x0 0x40000000>; /* 1 GB highmem */
};
diff --git a/dts/src/arm/am33xx.dtsi b/dts/src/arm/am33xx.dtsi
index 5b213a1e68..5e33d0e88f 100644
--- a/dts/src/arm/am33xx.dtsi
+++ b/dts/src/arm/am33xx.dtsi
@@ -40,6 +40,9 @@
ethernet1 = &cpsw_emac1;
spi0 = &spi0;
spi1 = &spi1;
+ mmc0 = &mmc1;
+ mmc1 = &mmc2;
+ mmc2 = &mmc3;
};
cpus {
diff --git a/dts/src/arm/armada-385-turris-omnia.dts b/dts/src/arm/armada-385-turris-omnia.dts
index 646a06420c..5bd6a66d2c 100644
--- a/dts/src/arm/armada-385-turris-omnia.dts
+++ b/dts/src/arm/armada-385-turris-omnia.dts
@@ -32,7 +32,8 @@
ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
MBUS_ID(0x01, 0x1d) 0 0xfff00000 0x100000
MBUS_ID(0x09, 0x19) 0 0xf1100000 0x10000
- MBUS_ID(0x09, 0x15) 0 0xf1110000 0x10000>;
+ MBUS_ID(0x09, 0x15) 0 0xf1110000 0x10000
+ MBUS_ID(0x0c, 0x04) 0 0xf1200000 0x100000>;
internal-regs {
@@ -389,6 +390,7 @@
phy1: ethernet-phy@1 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <1>;
+ marvell,reg-init = <3 18 0 0x4985>;
/* irq is connected to &pcawan pin 7 */
};
diff --git a/dts/src/arm/at91-sam9x60ek.dts b/dts/src/arm/at91-sam9x60ek.dts
index 73b6b1f89d..775ceb3acb 100644
--- a/dts/src/arm/at91-sam9x60ek.dts
+++ b/dts/src/arm/at91-sam9x60ek.dts
@@ -334,14 +334,6 @@
};
&pinctrl {
- atmel,mux-mask = <
- /* A B C */
- 0xFFFFFE7F 0xC0E0397F 0xEF00019D /* pioA */
- 0x03FFFFFF 0x02FC7E68 0x00780000 /* pioB */
- 0xffffffff 0xF83FFFFF 0xB800F3FC /* pioC */
- 0x003FFFFF 0x003F8000 0x00000000 /* pioD */
- >;
-
adc {
pinctrl_adc_default: adc_default {
atmel,pins = <AT91_PIOB 15 AT91_PERIPH_A AT91_PINCTRL_NONE>;
diff --git a/dts/src/arm/at91-sama5d27_som1.dtsi b/dts/src/arm/at91-sama5d27_som1.dtsi
index 1b1163858b..e3251f3e3e 100644
--- a/dts/src/arm/at91-sama5d27_som1.dtsi
+++ b/dts/src/arm/at91-sama5d27_som1.dtsi
@@ -84,8 +84,8 @@
pinctrl-0 = <&pinctrl_macb0_default>;
phy-mode = "rmii";
- ethernet-phy@0 {
- reg = <0x0>;
+ ethernet-phy@7 {
+ reg = <0x7>;
interrupt-parent = <&pioA>;
interrupts = <PIN_PD31 IRQ_TYPE_LEVEL_LOW>;
pinctrl-names = "default";
diff --git a/dts/src/arm/bcm2711.dtsi b/dts/src/arm/bcm2711.dtsi
index 462b1dfb03..720beec54d 100644
--- a/dts/src/arm/bcm2711.dtsi
+++ b/dts/src/arm/bcm2711.dtsi
@@ -308,14 +308,6 @@
#reset-cells = <1>;
};
- bsc_intr: interrupt-controller@7ef00040 {
- compatible = "brcm,bcm2711-l2-intc", "brcm,l2-intc";
- reg = <0x7ef00040 0x30>;
- interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>;
- interrupt-controller;
- #interrupt-cells = <1>;
- };
-
aon_intr: interrupt-controller@7ef00100 {
compatible = "brcm,bcm2711-l2-intc", "brcm,l2-intc";
reg = <0x7ef00100 0x30>;
@@ -362,8 +354,6 @@
reg = <0x7ef04500 0x100>, <0x7ef00b00 0x300>;
reg-names = "bsc", "auto-i2c";
clock-frequency = <97500>;
- interrupt-parent = <&bsc_intr>;
- interrupts = <0>;
status = "disabled";
};
@@ -405,8 +395,6 @@
reg = <0x7ef09500 0x100>, <0x7ef05b00 0x300>;
reg-names = "bsc", "auto-i2c";
clock-frequency = <97500>;
- interrupt-parent = <&bsc_intr>;
- interrupts = <1>;
status = "disabled";
};
};
diff --git a/dts/src/arm/imx6qdl-phytec-pfla02.dtsi b/dts/src/arm/imx6qdl-phytec-pfla02.dtsi
index 7a1e531957..f28a96fcf2 100644
--- a/dts/src/arm/imx6qdl-phytec-pfla02.dtsi
+++ b/dts/src/arm/imx6qdl-phytec-pfla02.dtsi
@@ -433,6 +433,7 @@
pinctrl-0 = <&pinctrl_usdhc2>;
cd-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
wp-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
+ vmmc-supply = <&vdd_sd1_reg>;
status = "disabled";
};
@@ -442,5 +443,6 @@
&pinctrl_usdhc3_cdwp>;
cd-gpios = <&gpio1 27 GPIO_ACTIVE_LOW>;
wp-gpios = <&gpio1 29 GPIO_ACTIVE_HIGH>;
+ vmmc-supply = <&vdd_sd0_reg>;
status = "disabled";
};
diff --git a/dts/src/arm/imx6ul-14x14-evk.dtsi b/dts/src/arm/imx6ul-14x14-evk.dtsi
index c593597b21..5a1e10def6 100644
--- a/dts/src/arm/imx6ul-14x14-evk.dtsi
+++ b/dts/src/arm/imx6ul-14x14-evk.dtsi
@@ -210,9 +210,6 @@
micrel,led-mode = <1>;
clocks = <&clks IMX6UL_CLK_ENET_REF>;
clock-names = "rmii-ref";
- reset-gpios = <&gpio_spi 1 GPIO_ACTIVE_LOW>;
- reset-assert-us = <10000>;
- reset-deassert-us = <100>;
};
@@ -222,9 +219,6 @@
micrel,led-mode = <1>;
clocks = <&clks IMX6UL_CLK_ENET2_REF>;
clock-names = "rmii-ref";
- reset-gpios = <&gpio_spi 2 GPIO_ACTIVE_LOW>;
- reset-assert-us = <10000>;
- reset-deassert-us = <100>;
};
};
};
@@ -243,6 +237,22 @@
status = "okay";
};
+&gpio_spi {
+ eth0-phy-hog {
+ gpio-hog;
+ gpios = <1 GPIO_ACTIVE_HIGH>;
+ output-high;
+ line-name = "eth0-phy";
+ };
+
+ eth1-phy-hog {
+ gpio-hog;
+ gpios = <2 GPIO_ACTIVE_HIGH>;
+ output-high;
+ line-name = "eth1-phy";
+ };
+};
+
&i2c1 {
clock-frequency = <100000>;
pinctrl-names = "default";
diff --git a/dts/src/arm/imx6ull-myir-mys-6ulx-eval.dts b/dts/src/arm/imx6ull-myir-mys-6ulx-eval.dts
index ecbb2cc5b9..79cc45728c 100644
--- a/dts/src/arm/imx6ull-myir-mys-6ulx-eval.dts
+++ b/dts/src/arm/imx6ull-myir-mys-6ulx-eval.dts
@@ -14,5 +14,6 @@
};
&gpmi {
+ fsl,use-minimum-ecc;
status = "okay";
};
diff --git a/dts/src/arm/omap4.dtsi b/dts/src/arm/omap4.dtsi
index 72e4f64817..4a9f9496a8 100644
--- a/dts/src/arm/omap4.dtsi
+++ b/dts/src/arm/omap4.dtsi
@@ -22,6 +22,11 @@
i2c1 = &i2c2;
i2c2 = &i2c3;
i2c3 = &i2c4;
+ mmc0 = &mmc1;
+ mmc1 = &mmc2;
+ mmc2 = &mmc3;
+ mmc3 = &mmc4;
+ mmc4 = &mmc5;
serial0 = &uart1;
serial1 = &uart2;
serial2 = &uart3;
diff --git a/dts/src/arm/omap44xx-clocks.dtsi b/dts/src/arm/omap44xx-clocks.dtsi
index 5328685911..1f1c04d8f4 100644
--- a/dts/src/arm/omap44xx-clocks.dtsi
+++ b/dts/src/arm/omap44xx-clocks.dtsi
@@ -770,14 +770,6 @@
ti,max-div = <2>;
};
- sha2md5_fck: sha2md5_fck@15c8 {
- #clock-cells = <0>;
- compatible = "ti,gate-clock";
- clocks = <&l3_div_ck>;
- ti,bit-shift = <1>;
- reg = <0x15c8>;
- };
-
usb_phy_cm_clk32k: usb_phy_cm_clk32k@640 {
#clock-cells = <0>;
compatible = "ti,gate-clock";
diff --git a/dts/src/arm/omap5.dtsi b/dts/src/arm/omap5.dtsi
index e025b7c9a3..ee821d0ab3 100644
--- a/dts/src/arm/omap5.dtsi
+++ b/dts/src/arm/omap5.dtsi
@@ -25,6 +25,11 @@
i2c2 = &i2c3;
i2c3 = &i2c4;
i2c4 = &i2c5;
+ mmc0 = &mmc1;
+ mmc1 = &mmc2;
+ mmc2 = &mmc3;
+ mmc3 = &mmc4;
+ mmc4 = &mmc5;
serial0 = &uart1;
serial1 = &uart2;
serial2 = &uart3;
diff --git a/dts/src/arm/sam9x60.dtsi b/dts/src/arm/sam9x60.dtsi
index 84066c1298..ec45ced3cd 100644
--- a/dts/src/arm/sam9x60.dtsi
+++ b/dts/src/arm/sam9x60.dtsi
@@ -606,6 +606,15 @@
compatible = "microchip,sam9x60-pinctrl", "atmel,at91sam9x5-pinctrl", "atmel,at91rm9200-pinctrl", "simple-bus";
ranges = <0xfffff400 0xfffff400 0x800>;
+ /* mux-mask corresponding to sam9x60 SoC in TFBGA228L package */
+ atmel,mux-mask = <
+ /* A B C */
+ 0xffffffff 0xffe03fff 0xef00019d /* pioA */
+ 0x03ffffff 0x02fc7e7f 0x00780000 /* pioB */
+ 0xffffffff 0xffffffff 0xf83fffff /* pioC */
+ 0x003fffff 0x003f8000 0x00000000 /* pioD */
+ >;
+
pioA: gpio@fffff400 {
compatible = "microchip,sam9x60-gpio", "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
reg = <0xfffff400 0x200>;
diff --git a/dts/src/arm64/freescale/fsl-ls1012a.dtsi b/dts/src/arm64/freescale/fsl-ls1012a.dtsi
index 7de6b376d7..9058cfa498 100644
--- a/dts/src/arm64/freescale/fsl-ls1012a.dtsi
+++ b/dts/src/arm64/freescale/fsl-ls1012a.dtsi
@@ -198,6 +198,7 @@
ranges = <0x0 0x00 0x1700000 0x100000>;
reg = <0x00 0x1700000 0x0 0x100000>;
interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
+ dma-coherent;
sec_jr0: jr@10000 {
compatible = "fsl,sec-v5.4-job-ring",
diff --git a/dts/src/arm64/freescale/fsl-ls1043a.dtsi b/dts/src/arm64/freescale/fsl-ls1043a.dtsi
index 5a8a1dc426..28c51e521c 100644
--- a/dts/src/arm64/freescale/fsl-ls1043a.dtsi
+++ b/dts/src/arm64/freescale/fsl-ls1043a.dtsi
@@ -348,6 +348,7 @@
ranges = <0x0 0x00 0x1700000 0x100000>;
reg = <0x00 0x1700000 0x0 0x100000>;
interrupts = <0 75 0x4>;
+ dma-coherent;
sec_jr0: jr@10000 {
compatible = "fsl,sec-v5.4-job-ring",
diff --git a/dts/src/arm64/freescale/fsl-ls1046a.dtsi b/dts/src/arm64/freescale/fsl-ls1046a.dtsi
index 1d6dfd189c..39458305e3 100644
--- a/dts/src/arm64/freescale/fsl-ls1046a.dtsi
+++ b/dts/src/arm64/freescale/fsl-ls1046a.dtsi
@@ -354,6 +354,7 @@
ranges = <0x0 0x00 0x1700000 0x100000>;
reg = <0x00 0x1700000 0x0 0x100000>;
interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
+ dma-coherent;
sec_jr0: jr@10000 {
compatible = "fsl,sec-v5.4-job-ring",
diff --git a/dts/src/arm64/freescale/imx8mm-pinfunc.h b/dts/src/arm64/freescale/imx8mm-pinfunc.h
index 5ccc4cc919..a003e6af33 100644
--- a/dts/src/arm64/freescale/imx8mm-pinfunc.h
+++ b/dts/src/arm64/freescale/imx8mm-pinfunc.h
@@ -124,7 +124,7 @@
#define MX8MM_IOMUXC_SD1_CMD_USDHC1_CMD 0x0A4 0x30C 0x000 0x0 0x0
#define MX8MM_IOMUXC_SD1_CMD_GPIO2_IO1 0x0A4 0x30C 0x000 0x5 0x0
#define MX8MM_IOMUXC_SD1_DATA0_USDHC1_DATA0 0x0A8 0x310 0x000 0x0 0x0
-#define MX8MM_IOMUXC_SD1_DATA0_GPIO2_IO2 0x0A8 0x31 0x000 0x5 0x0
+#define MX8MM_IOMUXC_SD1_DATA0_GPIO2_IO2 0x0A8 0x310 0x000 0x5 0x0
#define MX8MM_IOMUXC_SD1_DATA1_USDHC1_DATA1 0x0AC 0x314 0x000 0x0 0x0
#define MX8MM_IOMUXC_SD1_DATA1_GPIO2_IO3 0x0AC 0x314 0x000 0x5 0x0
#define MX8MM_IOMUXC_SD1_DATA2_USDHC1_DATA2 0x0B0 0x318 0x000 0x0 0x0
diff --git a/dts/src/arm64/freescale/imx8mp-phyboard-pollux-rdk.dts b/dts/src/arm64/freescale/imx8mp-phyboard-pollux-rdk.dts
index 0e1a6d9533..122c95ddad 100644
--- a/dts/src/arm64/freescale/imx8mp-phyboard-pollux-rdk.dts
+++ b/dts/src/arm64/freescale/imx8mp-phyboard-pollux-rdk.dts
@@ -35,7 +35,7 @@
&i2c2 {
clock-frequency = <400000>;
- pinctrl-names = "default";
+ pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c2>;
pinctrl-1 = <&pinctrl_i2c2_gpio>;
sda-gpios = <&gpio5 17 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
diff --git a/dts/src/arm64/freescale/imx8mp-phycore-som.dtsi b/dts/src/arm64/freescale/imx8mp-phycore-som.dtsi
index 44a8c2337c..f3965ec5b3 100644
--- a/dts/src/arm64/freescale/imx8mp-phycore-som.dtsi
+++ b/dts/src/arm64/freescale/imx8mp-phycore-som.dtsi
@@ -67,7 +67,7 @@
&i2c1 {
clock-frequency = <400000>;
- pinctrl-names = "default";
+ pinctrl-names = "default", "gpio";
pinctrl-0 = <&pinctrl_i2c1>;
pinctrl-1 = <&pinctrl_i2c1_gpio>;
sda-gpios = <&gpio5 15 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
diff --git a/dts/src/arm64/freescale/imx8mq-pinfunc.h b/dts/src/arm64/freescale/imx8mq-pinfunc.h
index b94b02080a..68e8fa1729 100644
--- a/dts/src/arm64/freescale/imx8mq-pinfunc.h
+++ b/dts/src/arm64/freescale/imx8mq-pinfunc.h
@@ -130,7 +130,7 @@
#define MX8MQ_IOMUXC_SD1_CMD_USDHC1_CMD 0x0A4 0x30C 0x000 0x0 0x0
#define MX8MQ_IOMUXC_SD1_CMD_GPIO2_IO1 0x0A4 0x30C 0x000 0x5 0x0
#define MX8MQ_IOMUXC_SD1_DATA0_USDHC1_DATA0 0x0A8 0x310 0x000 0x0 0x0
-#define MX8MQ_IOMUXC_SD1_DATA0_GPIO2_IO2 0x0A8 0x31 0x000 0x5 0x0
+#define MX8MQ_IOMUXC_SD1_DATA0_GPIO2_IO2 0x0A8 0x310 0x000 0x5 0x0
#define MX8MQ_IOMUXC_SD1_DATA1_USDHC1_DATA1 0x0AC 0x314 0x000 0x0 0x0
#define MX8MQ_IOMUXC_SD1_DATA1_GPIO2_IO3 0x0AC 0x314 0x000 0x5 0x0
#define MX8MQ_IOMUXC_SD1_DATA2_USDHC1_DATA2 0x0B0 0x318 0x000 0x0 0x0
diff --git a/dts/src/arm64/marvell/armada-3720-turris-mox.dts b/dts/src/arm64/marvell/armada-3720-turris-mox.dts
index d239ab70ed..53e817c5f6 100644
--- a/dts/src/arm64/marvell/armada-3720-turris-mox.dts
+++ b/dts/src/arm64/marvell/armada-3720-turris-mox.dts
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
* Device Tree file for CZ.NIC Turris Mox Board
- * 2019 by Marek Behun <marek.behun@nic.cz>
+ * 2019 by Marek BehĂșn <kabel@kernel.org>
*/
/dts-v1/;
diff --git a/dts/src/arm64/marvell/armada-cp11x.dtsi b/dts/src/arm64/marvell/armada-cp11x.dtsi
index 64179a372e..c6f5df2dec 100644
--- a/dts/src/arm64/marvell/armada-cp11x.dtsi
+++ b/dts/src/arm64/marvell/armada-cp11x.dtsi
@@ -310,9 +310,11 @@
};
CP11X_LABEL(sata0): sata@540000 {
- compatible = "marvell,armada-8k-ahci";
+ compatible = "marvell,armada-8k-ahci",
+ "generic-ahci";
reg = <0x540000 0x30000>;
dma-coherent;
+ interrupts = <107 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&CP11X_LABEL(clk) 1 15>,
<&CP11X_LABEL(clk) 1 16>;
#address-cells = <1>;
@@ -320,12 +322,10 @@
status = "disabled";
sata-port@0 {
- interrupts = <109 IRQ_TYPE_LEVEL_HIGH>;
reg = <0>;
};
sata-port@1 {
- interrupts = <107 IRQ_TYPE_LEVEL_HIGH>;
reg = <1>;
};
};
diff --git a/images/Makefile.at91 b/images/Makefile.at91
index 00fa4cab27..7ab92edf14 100644
--- a/images/Makefile.at91
+++ b/images/Makefile.at91
@@ -31,3 +31,8 @@ pblb-$(CONFIG_MACH_SAMA5D27_GIANTBOARD) += start_sama5d27_giantboard_xload_mmc
FILE_barebox-groboards-sama5d27-giantboard-xload-mmc.img = start_sama5d27_giantboard_xload_mmc.pblb
MAX_PBL_IMAGE_SIZE_start_sama5d27_giantboard_xload_mmc = 0xffff
image-$(CONFIG_MACH_SAMA5D27_GIANTBOARD) += barebox-groboards-sama5d27-giantboard-xload-mmc.img
+
+pblb-$(CONFIG_MACH_SKOV_ARM9CPU) += start_skov_arm9cpu
+FILE_barebox-skov-arm9cpu.img = start_skov_arm9cpu.pblb
+MAX_PBL_MEMORY_SIZE_start_skov_arm9cpu = 0x12000
+image-$(CONFIG_MACH_SKOV_ARM9CPU) += barebox-skov-arm9cpu.img
diff --git a/images/Makefile.imx b/images/Makefile.imx
index b892ec0196..382493488b 100644
--- a/images/Makefile.imx
+++ b/images/Makefile.imx
@@ -331,6 +331,8 @@ $(call build_imx_habv4img, CONFIG_MACH_KONTRON_SAMX6I, start_imx6q_samx6i, kontr
$(call build_imx_habv4img, CONFIG_MACH_KONTRON_SAMX6I, start_imx6dl_samx6i, kontron-samx6i/flash-header-samx6i-duallite, imx6dl-samx6i)
+$(call build_imx_habv4img, CONFIG_MACH_SKOV_IMX6, start_imx6_skov_imx6, skov-imx6/flash-header-mx6-skov-imx6, skov-imx6)
+
$(call build_imx_habv4img, CONFIG_MACH_GW_VENTANA, start_imx6q_gw54xx_1gx64, gateworks-ventana/flash-header-ventana-quad-1gx64, gateworks-imx6q-ventana-1gx64)
$(call build_imx_habv4img, CONFIG_MACH_ELTEC_HIPERCAM, start_imx6dl_eltec_hipercam, eltec-hipercam/flash-header-eltec-hipercam, eltec-hipercam)
@@ -403,6 +405,11 @@ CFG_start_zii_imx7d_dev.pblb.imximg = $(board)/zii-imx7d-dev/flash-header-zii-im
FILE_barebox-zii-imx7d-dev.img = start_zii_imx7d_dev.pblb.imximg
image-$(CONFIG_MACH_ZII_IMX7D_DEV) += barebox-zii-imx7d-dev.img
+pblb-$(CONFIG_MACH_KAMSTRUP_MX7_CONCENTRATOR) += start_kamstrup_mx7_concentrator
+CFG_start_kamstrup_mx7_concentrator.pblb.imximg = $(board)/kamstrup-mx7-concentrator/flash-header-tqma7d.imxcfg
+FILE_barebox-kamstrup-mx7-concentrator.img = start_kamstrup_mx7_concentrator.pblb.imximg
+image-$(CONFIG_MACH_KAMSTRUP_MX7_CONCENTRATOR) += barebox-kamstrup-mx7-concentrator.img
+
# ----------------------- i.MX8mm based boards --------------------------
pblb-$(CONFIG_MACH_NXP_IMX8MM_EVK) += start_nxp_imx8mm_evk
CFG_start_nxp_imx8mm_evk.pblb.imximg = $(board)/nxp-imx8mm-evk/flash-header-imx8mm-evk.imxcfg
diff --git a/include/clock.h b/include/clock.h
index d681bf630e..e6197e7eb0 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -17,7 +17,7 @@ struct clocksource {
int (*init)(struct clocksource*);
};
-static inline uint32_t cyc2ns(struct clocksource *cs, uint64_t cycles)
+static inline uint64_t cyc2ns(struct clocksource *cs, uint64_t cycles)
{
uint64_t ret = cycles;
ret = (ret * cs->mult) >> cs->shift;
diff --git a/include/efi.h b/include/efi.h
index b9f3428dc5..439803c294 100644
--- a/include/efi.h
+++ b/include/efi.h
@@ -91,6 +91,15 @@ typedef struct {
* Memory map descriptor:
*/
+struct efi_memory_desc {
+ u32 type; /* enum efi_memory_type */
+ u32 _padding;
+ efi_physical_addr_t phys_start;
+ void *virt_start;
+ u64 npages;
+ u64 attrs;
+};
+
/* Memory types: */
enum efi_memory_type {
EFI_RESERVED_TYPE,
diff --git a/include/gpiod.h b/include/gpiod.h
new file mode 100644
index 0000000000..c8b2cd47a3
--- /dev/null
+++ b/include/gpiod.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __GPIOD_H_
+#define __GPIOD_H_
+
+#include <gpio.h>
+#include <of_gpio.h>
+
+/**
+ * Optional flags that can be passed to one of gpiod_* to configure direction
+ * and output value. These values cannot be OR'd.
+ */
+enum gpiod_flags {
+ GPIOD_ASIS = 0,
+ GPIOD_IN = GPIOF_IN,
+ /*
+ * To change this later to a different logic level (i.e. taking
+ * active low into account), use gpio_direction_active()
+ */
+ GPIOD_OUT_LOW = GPIOF_OUT_INIT_INACTIVE,
+ GPIOD_OUT_HIGH = GPIOF_OUT_INIT_ACTIVE,
+};
+
+/* returned gpio descriptor can be passed to any normal gpio_* function */
+int gpiod_get(struct device_d *dev, const char *_con_id, enum gpiod_flags flags);
+
+#endif
diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h
index 07a30e2e6f..7e3f95873c 100644
--- a/include/video/atmel_lcdc.h
+++ b/include/video/atmel_lcdc.h
@@ -23,10 +23,10 @@
#define __ATMEL_LCDC_H__
/* Way LCD wires are connected to the chip:
- * Some Atmel chips use BGR color mode (instead of standard RGB)
+ * Some Atmel chips use BRG color mode (instead of standard RGB)
* A swapped wiring onboard can bring to RGB mode.
*/
-#define ATMEL_LCDC_WIRING_BGR 0
+#define ATMEL_LCDC_WIRING_BRG 0
#define ATMEL_LCDC_WIRING_RGB 1
#define ATMEL_LCDC_WIRING_RGB555 2
diff --git a/net/eth.c b/net/eth.c
index 626b35d5cc..84f99d3aa8 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -304,7 +304,8 @@ static void eth_of_fixup_node(struct device_node *root,
const char *node_path, int ethid,
const u8 ethaddr[ETH_ALEN])
{
- struct device_node *node;
+ struct device_node *bb_node, *fixup_node;
+ char *name;
int ret;
if (!is_valid_ether_addr(ethaddr)) {
@@ -314,22 +315,25 @@ static void eth_of_fixup_node(struct device_node *root,
}
if (node_path) {
- node = of_find_node_by_path_from(root, node_path);
+ bb_node = of_find_node_by_path_from(0, node_path);
+ name = of_get_reproducible_name(bb_node);
+ fixup_node = of_find_node_by_reproducible_name(root, name);
+ free(name);
} else {
char eth[12];
sprintf(eth, "ethernet%d", ethid);
- node = of_find_node_by_alias(root, eth);
+ fixup_node = of_find_node_by_alias(root, eth);
}
- if (!node) {
+ if (!fixup_node) {
pr_debug("%s: no node to fixup\n", __func__);
return;
}
- ret = of_set_property(node, "mac-address", ethaddr, ETH_ALEN, 1);
+ ret = of_set_property(fixup_node, "mac-address", ethaddr, ETH_ALEN, 1);
if (ret)
pr_err("Setting mac-address property of %s failed with: %s\n",
- node->full_name, strerror(-ret));
+ fixup_node->full_name, strerror(-ret));
}
static int eth_of_fixup(struct device_node *root, void *unused)
diff --git a/scripts/Makefile b/scripts/Makefile
index 4dc70815b7..2d322fd1c9 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -43,7 +43,6 @@ userccflags += -I $(srctree)/$(src)/include
subdir-y += mod
subdir-y += imx
-subdir-$(CONFIG_X86) += setupmbr
subdir-$(CONFIG_DTC) += dtc
subdir-$(CONFIG_ARCH_TEGRA) += tegra
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 319ac19975..80d76b177c 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -365,6 +365,9 @@ cmd_env_S = \
$(obj)/%.bbenv$(DEFAULT_COMPRESSION_SUFFIX).S: $(src)/%.bbenv$(DEFAULT_COMPRESSION_SUFFIX) FORCE
$(call if_changed,env_S)
+quiet_cmd_envgen = ENVGEN $@
+cmd_envgen=$(srctree)/scripts/genenv $(objtree) $(objtree) $@ $2
+
quiet_cmd_env = ENV $@
cmd_env=$(srctree)/scripts/genenv $(srctree) $(objtree) $@ $<
diff --git a/scripts/bareboximd.c b/scripts/bareboximd.c
index 9558c77d1a..c3dcb4dcf0 100644
--- a/scripts/bareboximd.c
+++ b/scripts/bareboximd.c
@@ -15,6 +15,7 @@
#include <stdarg.h>
#include <linux/err.h>
#include <linux/kernel.h>
+#include <sys/mman.h>
#include "../include/image-metadata.h"
@@ -96,29 +97,35 @@ static int read_file_2(const char *filename, size_t *size, void **outbuf, size_t
goto close;
}
- buf = malloc(max_size);
- if (!buf) {
- fprintf(stderr, "Cannot allocate memory\n");
- ret = -ENOMEM;
- goto close;
- }
+ buf = mmap(NULL, max_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (buf == MAP_FAILED ) {
+ buf = malloc(max_size);
+ if (!buf) {
+ fprintf(stderr, "Cannot allocate memory\n");
+ ret = -ENOMEM;
+ goto close;
+ }
- *outbuf = buf;
- while (*size < max_size) {
- rsize = read(fd, buf, max_size-*size);
- if (rsize == 0) {
- ret = -EIO;
- goto free;
- } else if (rsize < 0) {
- if (errno == EAGAIN)
- continue;
- else {
+ *outbuf = buf;
+
+ while (*size < max_size) {
+ rsize = read(fd, buf, max_size - *size);
+ if (rsize == 0) {
+ ret = -EIO;
+ goto free;
+ }
+
+ if (rsize < 0) {
ret = -errno;
goto free;
}
- } /* ret > 0 */
- buf += rsize;
- *size += rsize;
+
+ buf += rsize;
+ *size += rsize;
+ }
+ } else {
+ *outbuf = buf;
+ *size = max_size;
}
ret = 0;
@@ -131,6 +138,14 @@ close:
return ret;
}
+static inline void read_file_2_free(void *buf)
+{
+ /*
+ * Can't free() here because buffer might be mmapped. No need
+ * to do anything as we are exitting in a moment anyway.
+ */
+}
+
static unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base)
{
return strtoul(cp, endp, base);
diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
index 6b8dabd047..ce18778f54 100644
--- a/scripts/imx/imx.c
+++ b/scripts/imx/imx.c
@@ -328,6 +328,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
{
char *str;
int ret;
+ int i;
uint32_t signed_size = data->load_size;
uint32_t offset = data->image_ivt_offset;
@@ -352,7 +353,7 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
}
if (signed_size > 0) {
- ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"\n",
+ ret = asprintf(&str, "Blocks = 0x%08x 0x%08x 0x%08x \"%s\"",
data->image_load_addr + data->image_ivt_offset, offset,
signed_size - data->image_ivt_offset, data->outfile);
} else {
@@ -365,10 +366,57 @@ static int do_hab_blocks(struct config_data *data, int argc, char *argv[])
return -ENOMEM;
ret = hab_add_str(data, str);
+ free(str);
if (ret)
return ret;
- return 0;
+ for (i = 1; i < argc; i++) {
+ uint32_t addr;
+ uint32_t off;
+ uint32_t size;
+ char *b;
+ char *e;
+
+ b = argv[i];
+ if (*b == '"') // remove leading qoute
+ b++;
+ if (!*b || *b == '"')
+ continue; // skip if empty
+
+ off = strtoul(b, &e, 0);
+ if (*e != '+') {
+ fprintf(stderr, "failed to find '+' in '%s'\n", b);
+ fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+ return -EINVAL;
+ }
+
+ b = e + 1;
+ size = strtoul(b, &e, 0);
+ if (*e != '@') {
+ fprintf(stderr, "failed to find '@' in '%s'\n", b);
+ fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+ return -EINVAL;
+ }
+
+ b = e + 1;
+ addr = strtoul(b, &e, 0);
+ if (*e && *e != '"') { // ignore trailing qoute
+ fprintf(stderr, "unexpected char at the end: '%c'\n", *e);
+ fprintf(stderr, "format off+size@addr expected, but given: %s\n", argv[i]);
+ return -EINVAL;
+ }
+
+ ret = asprintf(&str, ", 0x%08x 0x%08x 0x%08x \"%s\"", addr, off, size, data->outfile);
+ if (ret < 0)
+ return -ENOMEM;
+
+ ret = hab_add_str(data, str);
+ free(str);
+ if (ret)
+ return ret;
+ }
+
+ return hab_add_str(data, "\n");
}
static int do_hab_encrypt(struct config_data *data, int argc, char *argv[])
diff --git a/scripts/setupmbr/.gitignore b/scripts/setupmbr/.gitignore
deleted file mode 100644
index a7301f9111..0000000000
--- a/scripts/setupmbr/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-setupmbr
diff --git a/scripts/setupmbr/Makefile b/scripts/setupmbr/Makefile
deleted file mode 100644
index 6e33d15362..0000000000
--- a/scripts/setupmbr/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-HOST_EXTRACFLAGS=-I$(srctree)
-
-hostprogs-always-y += setupmbr
diff --git a/scripts/setupmbr/arch.h b/scripts/setupmbr/arch.h
deleted file mode 100644
index a720dfe95e..0000000000
--- a/scripts/setupmbr/arch.h
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/* we need the one from the host */
-#include <endian.h>
-#include <stdint.h>
-
-/* Byte-orders. */
-#define swap16(x) \
-({ \
- uint16_t _x = (x); \
- (uint16_t) ((_x << 8) | (_x >> 8)); \
-})
-
-#define swap32(x) \
-({ \
- uint32_t _x = (x); \
- (uint32_t) ((_x << 24) \
- | ((_x & (uint32_t) 0xFF00UL) << 8) \
- | ((_x & (uint32_t) 0xFF0000UL) >> 8) \
- | (_x >> 24)); \
-})
-
-#define swap64(x) \
-({ \
- uint64_t _x = (x); \
- (uint64_t) ((_x << 56) \
- | ((_x & (uint64_t) 0xFF00ULL) << 40) \
- | ((_x & (uint64_t) 0xFF0000ULL) << 24) \
- | ((_x & (uint64_t) 0xFF000000ULL) << 8) \
- | ((_x & (uint64_t) 0xFF00000000ULL) >> 8) \
- | ((_x & (uint64_t) 0xFF0000000000ULL) >> 24) \
- | ((_x & (uint64_t) 0xFF000000000000ULL) >> 40) \
- | (_x >> 56)); \
-})
-
-#if __BYTE_ORDER == __BIG_ENDIAN
-
-/* Our target is a ia32 machine, always little endian */
-
-# define host2target_16(x) swap16(x)
-# define host2target_32(x) swap32(x)
-# define host2target_64(x) swap64(x)
-# define target2host_16(x) swap16(x)
-# define target2host_32(x) swap32(x)
-# define target2host_64(x) swap64(x)
-
-#else
-
-# define host2target_16(x) (x)
-# define host2target_32(x) (x)
-# define host2target_64(x) (x)
-# define target2host_16(x) (x)
-# define target2host_32(x) (x)
-# define target2host_64(x) (x)
-
-#endif
diff --git a/scripts/setupmbr/setupmbr.c b/scripts/setupmbr/setupmbr.c
deleted file mode 100644
index 38af550809..0000000000
--- a/scripts/setupmbr/setupmbr.c
+++ /dev/null
@@ -1,545 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-// SPDX-FileCopyrightText: 2009 Juergen Beisert, Pengutronix
-
-/**
- * @file
- * @brief Write the barebox binary to the MBR and the following disk sectors
- *
- * Also patch dedicated locations in the image to make it work at runtime
- *
- * Current restrictions are:
- * - only installs into MBR and the sectors after it
- * - tested only with QEMU
- * - and maybe some others
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <assert.h>
-
-/* include the info from this barebox release */
-#include "../../include/generated/utsrelease.h"
-#include "../../arch/x86/mach-i386/include/mach/barebox.lds.h"
-
-/** define to disable integrity tests and debug messages */
-#define NDEBUG
-
-/* some infos about our target architecture */
-#include "arch.h"
-
-/**
- * "Disk Address Packet Structure" to be used when calling int13,
- * function 0x42
- *
- * @note All entries are in target endianess
- */
-struct DAPS
-{
- uint8_t size; /**< size of this data set, 0 marks it as invalid */
- uint8_t res1; /**< always 0 */
- int8_t count; /**< number of sectors 0...127 to handle */
- uint8_t res2; /**< always 0 */
- uint16_t offset; /**< store address: offset */
- uint16_t segment; /**< store address: segment */
- uint64_t lba; /**< start sector number in LBA */
-} __attribute__ ((packed));
-
-/**
- * Description of one partition table entry (D*S type)
- *
- * @note All entries are in target endianess
- */
-struct partition_entry {
- uint8_t boot_indicator;
- uint8_t chs_begin[3];
- uint8_t type;
- uint8_t chs_end[3];
- uint32_t partition_start; /* LE */
- uint32_t partition_size; /* LE */
-} __attribute__ ((packed));
-
-#ifndef NDEBUG
-static void debugout(const struct DAPS *entry, int supress_entry)
-{
- if (supress_entry)
- printf("DAPS entry: ");
- else
- printf("DAPS entry % 3u: ", ((unsigned)entry & ( SECTOR_SIZE - 1)) / sizeof(struct DAPS));
-
- printf("Size: % 2u, Count: % 3d, Offset: 0x%04hX, Segment: 0x%04hX, LBA: %llu\n",
- entry->size, entry->count,
- target2host_16(entry->offset), target2host_16(entry->segment),
- target2host_64(entry->lba));
-}
-#else
-# define debugout(x,y) (__ASSERT_VOID_CAST(0))
-#endif
-
-/**
- * Fill *one* DAPS
- * @param sector The DAPS to fill
- * @param count Sector count
- * @param offset Realmode offset in the segment
- * @param segment Real mode segment
- * @param lba LBA of the first sector to read
- * @return 0 on success
- */
-static int fill_daps(struct DAPS *sector, unsigned count, unsigned offset, unsigned segment, uint64_t lba)
-{
- assert(sector != NULL);
- assert(count < 128);
- assert(offset < 0x10000);
- assert(segment < 0x10000);
-
- sector->size = sizeof(struct DAPS);
- sector->res1 = 0;
- sector->count = (int8_t)count;
- sector->res2 = 0;
- sector->offset = host2target_16(offset);
- sector->segment = host2target_16(segment);
- sector->lba = host2target_64(lba);
-
- return 0;
-}
-
-/**
- * Mark a DAPS invalid to let the boot loader code stop at this entry.
- * @param sector The DAPS to be marked as invalid
- *
- * Marking as invalid must be done in accordance to the detection method
- * the assembler routine in the boot loader uses:
- * The current code tests for zero in the first two bytes of the DAPS.
- */
-static void invalidate_daps(struct DAPS *sector)
-{
- sector->size = MARK_DAPS_INVALID;
- sector->res1 = 0;
-}
-
-/**
- * Create the indirect sector with the DAPS entries
- * @param daps_table Where to store the entries
- * @param size Size of the whole image in bytes
- * @param pers_sector_count Count of sectors to skip after MBR for the persistent environment storage
- * @return 0 on success
- *
- * This routine calculates the DAPS entries for the case the whole
- * barebox images fits into the MBR itself and the sectors after it.
- * This means the start of the first partition must keep enough sectors
- * unused.
- * It also skips 'pers_sector_count' sectors after the MBR for special
- * usage if given.
- */
-static int barebox_linear_image(struct DAPS *daps_table, off_t size, long pers_sector_count)
-{
- unsigned offset = LOAD_AREA, next_offset;
- unsigned segment = LOAD_SEGMENT;
- unsigned chunk_size, i = 0;
- uint64_t lba = 2 + pers_sector_count;
- int rc;
-
- /*
- * We can load up to 127 sectors in one chunk. What a bad number...
- * So, we will load in chunks of 32 kiB.
- */
-
- /* at runtime two sectors from the image are already loaded: MBR and indirect */
- size -= 2 * SECTOR_SIZE;
- /* and now round up to multiple of sector size */
- size = (size + SECTOR_SIZE - 1) & ~(SECTOR_SIZE - 1);
-
- /*
- * The largest image we can load with this method is:
- * (SECTOR_SIZE / sizeof(DAPS) - 1) * 32 kiB
- * For a 512 byte sector and a 16 byte DAPS:
- * (512 / 16 - 1) * 32 kiB = 992 kiB
- * Note: '- 1' to consider one entry is required to pad to a 32 kiB boundary
- */
-
- if (size >= (SECTOR_SIZE / sizeof(struct DAPS) - 1) * 32 * 1024) {
- fprintf(stderr, "Image too large to boot. Max size is %zu kiB, image size is %lu kiB\n",
- (SECTOR_SIZE / sizeof(struct DAPS) - 1) * 32, size / 1024);
- return -1;
- }
-
- if (size > 32 * 1024) {
- /* first fill up until the next 32 k boundary */
- next_offset = (offset + 32 * 1024 -1) & ~0x7fff;
- chunk_size = next_offset - offset;
- if (chunk_size & (SECTOR_SIZE-1)) {
- fprintf(stderr, "Unable to pad from %X to %X in multiple of sectors\n", offset, next_offset);
- return -1;
- }
-
- rc = fill_daps(&daps_table[i], chunk_size / SECTOR_SIZE, offset, segment, lba);
- if (rc != 0)
- return -1;
- debugout(&daps_table[i], 0);
-
- /* calculate values to enter the loop for the other entries */
- size -= chunk_size;
- i++;
- lba += chunk_size / SECTOR_SIZE;
- offset += chunk_size;
- if (offset >= 0x10000) {
- segment += 4096;
- offset = 0;
- }
-
- /*
- * Now load the remaining image part in 32 kiB chunks
- */
- while (size) {
- if (size >= 32 * 1024 ) {
- if (i >= (SECTOR_SIZE / sizeof(struct DAPS))) {
- fprintf(stderr, "Internal tool error: Too many DAPS entries!\n");
- return -1;
- }
- rc = fill_daps(&daps_table[i], 64, offset, segment, lba);
- if (rc != 0)
- return -1;
- debugout(&daps_table[i], 0);
-
- size -= 32 * 1024;
- lba += 64;
- offset += 32 * 1024;
- if (offset >= 0x10000) {
- segment += 4096;
- offset = 0;
- }
- i++;
- } else {
- if (i >= (SECTOR_SIZE / sizeof(struct DAPS))) {
- fprintf(stderr, "Internal tool error: Too many DAPS entries!\n");
- return -1;
- }
- rc = fill_daps(&daps_table[i], size / SECTOR_SIZE, offset, segment, lba);
- if (rc != 0)
- return -1;
- debugout(&daps_table[i], 0);
- size = 0; /* finished */
- i++;
- }
- };
- } else {
- /* less than 32 kiB. Very small image... */
- rc = fill_daps(&daps_table[i], size / SECTOR_SIZE, offset, segment, lba);
- if (rc != 0)
- return -1;
- debugout(&daps_table[i], 0);
- i++;
- }
-
- /*
- * Do not mark an entry as invalid if the buffer is full. The
- * boot code stops if all entries of a buffer are read.
- */
- if (i >= (SECTOR_SIZE / sizeof(struct DAPS)))
- return 0;
-
- /* mark the last DAPS invalid */
- invalidate_daps(&daps_table[i]);
- debugout(&daps_table[i], 0);
-
- return 0;
-}
-
-/**
- * Do some simple sanity checks if this sector could be an MBR
- * @param sector Sector with data to check
- * @param size Size of the buffer
- * @return 0 if successfull
- */
-static int check_for_valid_mbr(const uint8_t *sector, off_t size)
-{
- if (size < SECTOR_SIZE) {
- fprintf(stderr, "MBR too small to be valid\n");
- return -1;
- }
-
- if ((sector[OFFSET_OF_SIGNATURE] != 0x55) ||
- (sector[OFFSET_OF_SIGNATURE + 1] != 0xAA)) {
- fprintf(stderr, "No MBR signature found\n");
- return -1;
- }
-
- /* FIXME: try to check if there is a valid partition table */
- return 0;
-}
-
-/**
- * Check space between start of the image and the start of the first partition
- * @param hd_image HD image to examine
- * @param size Size of the barebox image
- * @return 0 on success, -1 if the barebox image is too large
- */
-static int check_for_space(const void *hd_image, off_t size)
-{
- struct partition_entry *partition;
- uint8_t *mbr_disk_sector = (uint8_t*)hd_image;
- off_t spare_sector_count;
-
- assert(hd_image != NULL);
- assert(size > 0);
-
- if (check_for_valid_mbr(hd_image, size) != 0)
- return -1;
-
- /* where to read */
- partition = (struct partition_entry*) &mbr_disk_sector[OFFSET_OF_PARTITION_TABLE];
-
- /* TODO describes the first entry always the first partition? */
- spare_sector_count = target2host_32(partition->partition_start);
-
-#ifdef DEBUG
- printf("Debug: Required free sectors for barebox prior first partition: %lu, hd image provides: %lu\n",
- (size + SECTOR_SIZE - 1) / SECTOR_SIZE, spare_sector_count);
-#endif
- spare_sector_count *= SECTOR_SIZE;
- if (spare_sector_count < size) {
- fprintf(stderr, "Not enough space after MBR to store barebox\n");
- fprintf(stderr, "Move begin of the first partition beyond sector %lu\n", (size + SECTOR_SIZE - 1) / SECTOR_SIZE);
- return -1;
- }
-
- return 0;
-}
-
-/**
- * Setup the persistent environment storage information
- * @param patch_area Where to patch
- * @param pers_sector_start Start sector of the persistent environment storage
- * @param pers_sector_count Count of sectors for the persistent environment storage
- * @return 0 on success
- */
-static int store_pers_env_info(void *patch_area, uint64_t pers_sector_start, long pers_sector_count)
-{
- uint64_t *start_lba = (uint64_t*)(patch_area + PATCH_AREA_PERS_START);
- uint16_t *count_lba = (uint16_t*)(patch_area + PATCH_AREA_PERS_SIZE);
-
- assert(patch_area != NULL);
- assert(pers_sector_count >= 0);
-
- if (pers_sector_count == 0) {
- *count_lba = host2target_16(PATCH_AREA_PERS_SIZE_UNUSED);
- return 0;
- }
-
- *start_lba = host2target_64(pers_sector_start);
- *count_lba = host2target_16(pers_sector_count);
-
- return 0;
-}
-
-/**
- * Prepare the MBR and indirect sector for runtime
- * @param fd_barebox barebox image to use
- * @param fd_hd Hard disk image to prepare
- * @param pers_sector_count Count of sectors to skip after MBR for the persistent environment storage
- * @return 0 on success
- *
- * This routine expects a prepared hard disk image file with a partition table
- * in its first sector. This method only is currently supported.
- */
-static int barebox_overlay_mbr(int fd_barebox, int fd_hd, long pers_sector_count)
-{
- const void *barebox_image;
- void *hd_image;
- int rc;
- struct stat sb;
- struct DAPS *embed; /* part of the MBR */
- struct DAPS *indirect; /* sector with indirect DAPS */
- off_t required_size;
-
- if (fstat(fd_barebox, &sb) == -1) {
- perror("fstat");
- return -1;
- }
-
- /* the barebox image won't be touched */
- barebox_image = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd_barebox, 0);
- if (barebox_image == MAP_FAILED) {
- perror("mmap");
- return -1;
- }
-
- rc = check_for_valid_mbr(barebox_image, sb.st_size);
- if (rc != 0) {
- fprintf(stderr, "barebox image seems not valid: Bad MBR signature\n");
- goto on_error_hd;
- }
-
- /*
- * the persistent environment storage is in front of the main
- * barebox image. To handle both, we need more space in front of the
- * the first partition.
- */
- required_size = sb.st_size + pers_sector_count * SECTOR_SIZE;
-
- /* the hd image will be modified */
- hd_image = mmap(NULL, required_size, PROT_READ | PROT_WRITE,
- MAP_SHARED, fd_hd, 0);
- if (hd_image == MAP_FAILED) {
- perror("mmap");
- rc = -1;
- goto on_error_hd;
- }
-
- /* check for space */
- rc = check_for_space(hd_image, required_size);
- if (rc != 0)
- goto on_error_space;
-
- /* embed barebox's boot code into the disk drive image */
- memcpy(hd_image, barebox_image, OFFSET_OF_PARTITION_TABLE);
-
- /*
- * embed the barebox main image into the disk drive image,
- * but keep the persistent environment storage untouched
- * (if defined), e.g. store the main image behind this special area.
- */
- memcpy(hd_image + ((pers_sector_count + 1) * SECTOR_SIZE),
- barebox_image + SECTOR_SIZE, sb.st_size - SECTOR_SIZE);
-
- /* now, prepare this hard disk image for BIOS based booting */
- embed = hd_image + PATCH_AREA;
- indirect = hd_image + ((pers_sector_count + 1) * SECTOR_SIZE);
-
- /*
- * Fill the embedded DAPS to let the basic boot code find the
- * indirect sector at runtime
- */
-#ifdef DEBUG
- printf("Debug: Fill in embedded DAPS\n");
-#endif
- rc = fill_daps(embed, 1, INDIRECT_AREA, INDIRECT_SEGMENT,
- 1 + pers_sector_count);
- if (rc != 0)
- goto on_error_space;
- debugout(embed, 1);
-
-#ifdef DEBUG
- printf("Debug: Fill in indirect sector\n");
-#endif
- /*
- * fill the indirect sector with the remaining DAPS to load the
- * whole barebox image at runtime
- */
- rc = barebox_linear_image(indirect, sb.st_size, pers_sector_count);
- if (rc != 0)
- goto on_error_space;
-
- /*
- * TODO: Replace the fixed LBA starting number by a calculated one,
- * to support barebox as a chained loader in a different start
- * sector than the MBR
- */
- rc = store_pers_env_info(embed, 1, pers_sector_count);
- if (rc != 0)
- goto on_error_space;
-
-on_error_space:
- munmap(hd_image, required_size);
-
-on_error_hd:
- munmap((void*)barebox_image, sb.st_size);
-
- return rc;
-}
-
-static void print_usage(const char *pname)
-{
- printf("%s: Preparing a hard disk image for boot with barebox on x86.\n", pname);
- printf("Usage is\n %s [options] -m <barebox image> -d <hd image>\n", pname);
- printf(" [options] are:\n -s <count> sector count of the persistent environment storage\n");
- printf(" <barebox image> barebox's boot image file\n");
- printf(" <hd image> HD image to store the barebox image\n");
- printf(" If no '-s <x>' was given, barebox occupies sectors 0 to n, else sector 0 and x+1 to n\n");
-}
-
-int main(int argc, char *argv[])
-{
- int rc = 0, c;
- char *barebox_image_filename = NULL, *hd_image_filename = NULL;
- int fd_barebox_image = 0, fd_hd_image = 0;
- long barebox_pers_size = -1;
-
- if (argc == 1) {
- print_usage(argv[0]);
- exit(0);
- }
-
- /* handle command line options first */
- while (1) {
- c = getopt(argc, argv, "m:d:s:hv");
- if (c == -1)
- break;
-
- switch (c) {
- case 's':
- barebox_pers_size = strtol(optarg, NULL, 0);
- break;
- case 'm':
- barebox_image_filename = strdup(optarg);
- break;
- case 'd':
- hd_image_filename = strdup(optarg);
- break;
- case 'h':
- print_usage(argv[0]);
- rc = 0;
- goto on_error;
- case 'v':
- printf("setupmbr for u-boot-v%s\n", UTS_RELEASE);
- printf("Send bug reports to 'barebox@lists.infradead.org'\n");
- rc = 0;
- goto on_error;
- }
- }
-
- if (barebox_image_filename == NULL) {
- print_usage(argv[0]);
- rc = -1;
- goto on_error;
- }
-
- fd_barebox_image = open(barebox_image_filename, O_RDONLY);
- if (fd_barebox_image == -1) {
- fprintf(stderr, "Cannot open '%s' for reading\n",
- barebox_image_filename);
- rc = -1;
- goto on_error;
- }
-
- fd_hd_image = open(hd_image_filename, O_RDWR);
- if (fd_hd_image == -1) {
- fprintf(stderr, "Cannot open '%s'\n", hd_image_filename);
- rc = -1;
- goto on_error;
- }
-
- if (barebox_pers_size < 0)
- barebox_pers_size = 0;
-
- rc = barebox_overlay_mbr(fd_barebox_image, fd_hd_image, barebox_pers_size);
-
-on_error:
- if (fd_barebox_image != -1)
- close(fd_barebox_image);
- if (fd_hd_image != -1)
- close(fd_hd_image);
-
- if (barebox_image_filename != NULL)
- free(barebox_image_filename);
- if (hd_image_filename != NULL)
- free(hd_image_filename);
-
- return rc;
-}