Initial commit

master
Dustin 2023-02-13 17:52:13 -06:00
commit 025b7c6115
90 changed files with 5010 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/images
/linux
/output

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "u-boot"]
path = u-boot
url = https://source.denx.de/u-boot/u-boot.git
branch = v2023.01

18
README.md Normal file
View File

@ -0,0 +1,18 @@
## Errors
### SWIOTLB Buffer
> OF: reserved mem: failed to allocate memory for node
> …
> Can not allocate SWIOTLB buffer earlier and can't now provide you with the
> DMA bounce buffer
Ensure `start_x=1` is in `config.txt` and `start_file`/`fixup_file` are not
specified.
### U-Boot: Overwrite Reserved Memory
> ** Reading file would overwrite reserved memory **
Set `CONFIG_LMB_MAX_REGIONS=16` in `u-boot/.config`

21
build-all.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
./prepare.sh
./config-portage.sh
./setup-local-repo.sh
./build.sh
./build-host-tools.sh
./build-rootfs.sh
./build-uboot.sh
./build-grub.sh
./build-kernel.sh
./build-squashfs.sh
./post-build.sh
./genimage.sh
./build-update.sh

42
build-grub.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
GRUB_MODULES='
boot
echo
efi_gop
eval
fat
gzio
linux
loadenv
normal
part_gpt
probe
regexp
serial
squash4
test
xzio
zstd
'
echo 'Creating GRUB image ...'
mkdir -p output/efi-part/EFI/BOOT
grub-mkimage \
-O arm64-efi \
-o output/efi-part/EFI/BOOT/BOOTAA64.efi \
-d /usr/${target}/usr/lib/grub/arm64-efi \
-p /EFI/gentoo \
${GRUB_MODULES}
echo 'Generating GRUB configuration file ...'
mkdir -p output/efi-part/EFI/gentoo
cp -uv grub.cfg output/efi-part/EFI/gentoo
grub-editenv output/efi-part/EFI/gentoo/grubenv set rootflags='ro'
grub-editenv output/efi-part/EFI/gentoo/grubenv set default=0
grub-editenv output/efi-part/EFI/gentoo/grubenv set timeout=5

13
build-host-tools.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
emerge -vnUj \
dev-vcs/git \
sys-apps/systemd \
sys-boot/grub \
sys-fs/btrfs-progs \
sys-fs/dosfstools \
sys-fs/genimage \
sys-fs/mtools \
sys-fs/squashfs-tools \
|| exit

34
build-kernel.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
emerge -vnj ${kernel_pkg}
export ARCH=arm64 CROSS_COMPILE=${target}-
mkdir -p linux
cd linux
/usr/src/linux/scripts/kconfig/merge_config.sh -m \
/usr/src/linux/arch/*/configs/${kernel_defconfig}_defconfig \
../linux.config
make -C /usr/src/linux O=${PWD} olddefconfig
make -j$(nproc)
kver=$(make kernelversion)
make modules_install INSTALL_MOD_PATH=/mnt/gentoo
cd -
printf 'Installing Kernel ...\n'
mkdir -p /mnt/gentoo/boot
cp -au linux/arch/arm64/boot/Image.gz /mnt/gentoo/boot/vmlinuz-${kver}
cp -au linux/.config /mnt/gentoo/boot/config-${kver}
cp -au linux/System.map /mnt/gentoo/boot/System.map-${kver}
printf 'Installing device tree binaries ...\n'
mkdir -p output/efi-part/overlays
cp -au linux/arch/arm64/boot/dts/${device_tree} output/efi-part/
cp -au \
linux/arch/arm64/boot/dts/overlays/*.dtb \
linux/arch/arm64/boot/dts/overlays/*.dtbo \
output/efi-part/overlays/

72
build-rootfs.sh Executable file
View File

@ -0,0 +1,72 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
mkdir -p /mnt/gentoo/usr/bin
[ -h /mnt/gentoo/bin ] || ln -s usr/bin /mnt/gentoo/bin
[ -h /mnt/gentoo/sbin ] || ln -s usr/sbin /mnt/gentoo/sbin
[ -h /mnt/gentoo/usr/sbin ] || ln -s bin /mnt/gentoo/usr/sbin
mkdir -p /mnt/gentoo/etc/portage
ln -snf \
/var/db/repos/gentoo/profiles/${profile} \
/mnt/gentoo/etc/portage/make.profile
cp -r portage/. /mnt/gentoo/etc/portage/
ROOT=/mnt/gentoo \
PORTAGE_CONFIGROOT=/mnt/gentoo \
${target}-emerge -Kvnj \
sys-apps/busybox \
sys-apps/systemd \
net-misc/openssh \
net-misc/wget \
sys-fs/btrfs-progs \
--
ROOT=/mnt/gentoo \
PORTAGE_CONFIGROOT=/mnt/gentoo \
${target}-emerge -vnj \
net-wireless/wireless-regdb \
sys-kernel/linux-firmware \
--
mkdir -p \
/mnt/gentoo/boot/efi \
/mnt/gentoo/dev \
/mnt/gentoo/home \
/mnt/gentoo/proc \
/mnt/gentoo/sys \
|| exit
: > /mnt/gentoo/etc/machine-id
while read name; do
if [ ! -h /mnt/gentoo/bin/"${name}" ]; then
printf "'/bin/%s' -> 'busybox'\n" "${name}"
ln -snf busybox /mnt/gentoo/bin/"${name}" \
|| printf 'Failed to create busybox symlink for %s\n' "${name}"
fi
done < busybox.symlinks
tar -c -C overlay . \
| tar -x --keep-newer-files -C /mnt/gentoo
cp -uv /usr/${target}/usr/bin/grub-editenv /mnt/gentoo/usr/bin/
if [ -f /mnt/gentoo/etc/udev/hwdb.bin ]; then
mv /mnt/gentoo/etc/udev/hwdb.bin /mnt/gentoo/usr/lib/udev/
fi
systemctl preset-all --root=/mnt/gentoo
systemd-sysusers --root=/mnt/gentoo
if grep -q '^root:.*/bin/bash$' /mnt/gentoo/etc/passwd; then
sed -ri 's@(root:.*):/bin/bash@\1:/bin/sh@' /mnt/gentoo/etc/passwd
fi
if ! grep -q Include /mnt/gentoo/etc/ssh/sshd_config; then
echo 'Include /etc/ssh/sshd_config.d/*.conf' \
>> /mnt/gentoo/etc/ssh/sshd_config
fi

16
build-squashfs.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
mkdir -p images
mksquashfs \
/mnt/gentoo \
images/rootfs.squashfs \
-comp gzip \
-ef squashfs.exclude \
-no-exports \
-noappend \
-wildcards

22
build-uboot.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
cd u-boot
if [ ! -f .patched ]; then
for x in ../patches/uboot/*.patch; do
printf 'Applying patch %s ...\n' "${x##*/}"
patch -p1 < "${x}"
done
: > .patched
fi
cat configs/rpi_4_defconfig ../u-boot.config > configs/yellow_defconfig
make yellow_defconfig
CROSS_COMPILE=${target}- make
cd ..
mkdir -p output/efi-part
cp -au u-boot/u-boot.bin output/efi-part

18
build-update.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
cd images
sha256sum firmware.img > digests
sha256sum rootfs.squashfs >> digests
ln ../install-update.sh install
tar -c --zstd -f ../output/update.tar.zstd \
digests \
firmware.img \
rootfs.squashfs \
install \
|| exit
rm install

22
build.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
USE=-pam \
${target}-emerge -1nvj --nodeps sys-libs/libcap
USE='-cramfs -ncurses -nls -pam -readline -su -suid -systemd -udev' \
${target}-emerge -1nvj --nodeps sys-apps/util-linux
${target}-emerge -vnuUDj \
net-misc/openssh \
net-misc/wget \
sys-apps/busybox \
sys-apps/systemd \
sys-boot/grub \
sys-boot/raspberrypi-firmware \
sys-fs/btrfs-progs \
--
${target}-emerge -v @preserved-rebuild

60
busybox.symlinks Normal file
View File

@ -0,0 +1,60 @@
basename
cat
cp
dd
df
echo
env
false
free
fsync
fuser
grep
groups
head
id
install
ip
kill
less
link
ln
ls
lsof
mkdir
mkfifo
mktemp
mv
nice
nproc
pgrep
ping
ping6
pkill
ppidof
printf
ps
readahead
readlink
realpath
rm
rmdir
sed
seq
sh
sha1sum
sha256sum
sha3sum
sha512sum
sort
stat
stty
sync
tac
tail
tar
tee
truncate
tty
uname
uptime

5
config Normal file
View File

@ -0,0 +1,5 @@
target=aarch64-unknown-linux-gnu
profile=default/linux/arm64/17.0/systemd/merged-usr
kernel_pkg=sys-kernel/raspberrypi-sources
kernel_defconfig=bcm2835
device_tree=broadcom/bcm2711-rpi-cm4-ha-yellow.dtb

9
config-portage.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
cp -r host-portage/. /etc/portage/
cp -r portage/. /usr/${target}/etc/portage/

17
config.txt Normal file
View File

@ -0,0 +1,17 @@
arm_64bit=1
start_x=1
bootcode_delay=0
boot_delay=0
gpu_mem=32
kernel=u-boot.bin
enable_uart=1
dtoverlay=miniuart-bt
dtparam i2c_arm=on
device_tree=bcm2711-rpi-cm4-ha-yellow.dtb

40
genimage.cfg Normal file
View File

@ -0,0 +1,40 @@
# vim: set sw=4 ts=4 sts=4 :
image firmware.img {
vfat {
}
srcpath = "output/efi-part"
size = 32M
}
image sdcard.img {
hdimage {
partition-table-type = hybrid
}
partition "EFI System Partition" {
partition-type = 0xC
partition-type-uuid = "U"
bootable = true
image = "firmware.img"
}
partition rootfs-a {
partition-type-uuid = "L"
image = "rootfs.squashfs"
size = 512M
}
partition rootfs-b {
partition-type-uuid = "L"
size = 512M
}
partition dch-data {
partition-type-uuid = "L"
autoresize = true
}
size = 4G
}

27
genimage.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
cleanup() {
if [ -n "${tmproot}" ]; then
if [ "${tmproot}" != / ]; then
rm -rf "${tmproot}"
fi
unset tmproot
fi
}
. ./config
trap cleanup INT TERM QUIT EXIT
tmproot=$(mktemp -d)
tmppath=$(mktemp -d)
genimage \
--rootpath "${tmproot}" \
--tmppath "${tmppath}" \
--inputpath images/ \
--outputpath images/ \
--mkdosfs mkfs.vfat \
--config genimage.cfg

19
grub.cfg Normal file
View File

@ -0,0 +1,19 @@
# vim: set ft=sh :
# vim: set sw=4 ts=4 sts=4 et:
load_env
regexp --set 1:disk '(.*),.*' $root
for dev in ($disk,gpt*); do
probe --set partuuid --part-uuid $dev
for path in $dev/boot/vmlinuz-*; do
if [ -f $path ]; then
regexp --set 1:kernel '.*/(vmlinuz-.*)' $path
regexp --set 1:kver 'vmlinuz-(.*)' $kernel
menuentry "Gentoo Linux $kver on $dev" --class gnu-linux --id "id-$partuuid-$kver" "$dev" "$kernel" $partuuid {
set root="$2"
linux "/boot/$3" root=PARTUUID=$4 $rootflags
}
fi
done
done

1
host-portage/env/nobuildpkg vendored Normal file
View File

@ -0,0 +1 @@
FEATURES=-buildpkg

View File

@ -0,0 +1 @@
ACCEPT_KEYWORDS="~${ARCH} ${ARCH}"

View File

@ -0,0 +1,2 @@
FEATURES="${FEATURES} binpkg-multi-instance buildpkg"
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --usepkg --binpkg-respect-use=y"

View File

@ -0,0 +1,2 @@
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --quiet-build=y --quiet-fail=y"
FEATURES="${FEATURES} -news"

View File

@ -0,0 +1 @@
sys-kernel/raspberrypi-sources **

View File

@ -0,0 +1,6 @@
# vim: set ft=gentoo-package-use :
# Dustin C. Hatch <dustin@hatch.name> (09 Feb 2023)
# Do not build binary packages for kernel sources
sys-kernel/gentoo-sources nobuildpkg
sys-kernel/raspberrypi-sources nobuildpkg

View File

@ -0,0 +1 @@
sys-fs/btrfs-progs -man

View File

@ -0,0 +1 @@
dev-vcs/git -perl

View File

@ -0,0 +1 @@
sys-boot/grub -* GRUB_PLATFORMS: -*

View File

@ -0,0 +1,2 @@
sys-kernel/gentoo-sources symlink
sys-kernel/raspberrypi-sources symlink

View File

@ -0,0 +1 @@
sys-fs/squashfs-tools zstd

View File

@ -0,0 +1,2 @@
sys-apps/dbus systemd
sys-apps/systemd -*

View File

@ -0,0 +1,659 @@
From b28a8f5b591841f88f19cbf9850d713a602d912e Mon Sep 17 00:00:00 2001
Message-Id: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Mon, 11 Apr 2022 14:47:59 +0200
Subject: [PATCH] ARM: dts: bcm2711: Add device tree for Home Assistant Yellow
Add device tree for Home Assistant Yellow, a Compute Module 4 based I/O
board.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/Makefile | 3 +-
.../boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 598 ++++++++++++++++++
arch/arm64/boot/dts/broadcom/Makefile | 1 +
.../broadcom/bcm2711-rpi-cm4-ha-yellow.dts | 1 +
4 files changed, 602 insertions(+), 1 deletion(-)
create mode 100644 arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
create mode 100644 arch/arm64/boot/dts/broadcom/bcm2711-rpi-cm4-ha-yellow.dts
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 3dfe451bcb16..d147c3400732 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -18,7 +18,8 @@ dtb-$(CONFIG_ARCH_BCM2835) += \
bcm2709-rpi-cm2.dtb \
bcm2710-rpi-cm3.dtb \
bcm2711-rpi-cm4.dtb \
- bcm2711-rpi-cm4s.dtb
+ bcm2711-rpi-cm4s.dtb \
+ bcm2711-rpi-cm4-ha-yellow.dtb
dtb-$(CONFIG_ARCH_ALPINE) += \
alpine-db.dtb
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
new file mode 100644
index 000000000000..61d8c81d3de4
--- /dev/null
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -0,0 +1,598 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+#include "bcm2711.dtsi"
+#include "bcm2711-rpi.dtsi"
+//#include "bcm283x-rpi-usb-peripheral.dtsi"
+
+/ {
+ compatible = "raspberrypi,4-compute-module-ha-yellow", "raspberrypi,4-compute-module", "brcm,bcm2711";
+ model = "Raspberry Pi Compute Module 4 on Home Assistant Yellow";
+
+ chosen {
+ /* 8250 auxiliary UART instead of pl011 */
+ stdout-path = "serial1:115200n8";
+ };
+
+ leds {
+ led-act {
+ gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
+ };
+
+ led-pwr {
+ label = "PWR";
+ gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
+ default-state = "keep";
+ linux,default-trigger = "default-on";
+ };
+ };
+
+ wifi_pwrseq: wifi-pwrseq {
+ compatible = "mmc-pwrseq-simple";
+ reset-gpios = <&expgpio 1 GPIO_ACTIVE_LOW>;
+ };
+
+ sd_io_1v8_reg: sd_io_1v8_reg {
+ compatible = "regulator-gpio";
+ regulator-name = "vdd-sd-io";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ regulator-always-on;
+ regulator-settling-time-us = <5000>;
+ gpios = <&expgpio 4 GPIO_ACTIVE_HIGH>;
+ states = <1800000 0x1>,
+ <3300000 0x0>;
+ status = "okay";
+ };
+
+ sd_vcc_reg: sd_vcc_reg {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc-sd";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ enable-active-high;
+ gpio = <&expgpio 6 GPIO_ACTIVE_HIGH>;
+ };
+};
+
+&ddc0 {
+ status = "okay";
+};
+
+&ddc1 {
+ status = "okay";
+};
+
+&expgpio {
+ gpio-line-names = "BT_ON",
+ "WL_ON",
+ "PWR_LED_OFF",
+ "ANT1",
+ "VDD_SD_IO_SEL",
+ "CAM_GPIO",
+ "SD_PWR_ON",
+ "ANT2";
+
+ ant1: ant1 {
+ gpio-hog;
+ gpios = <3 GPIO_ACTIVE_HIGH>;
+ output-high;
+ };
+
+ ant2: ant2 {
+ gpio-hog;
+ gpios = <7 GPIO_ACTIVE_HIGH>;
+ output-low;
+ };
+};
+
+&gpio {
+ /*
+ * Parts taken from rpi_SCH_4b_4p0_reduced.pdf and
+ * the official GPU firmware DT blob.
+ *
+ * Legend:
+ * "FOO" = GPIO line named "FOO" on the schematic
+ * "FOO_N" = GPIO line named "FOO" on schematic, active low
+ */
+ gpio-line-names = "ID_SDA",
+ "ID_SCL",
+ "SDA1",
+ "SCL1",
+ "GPIO_GCLK",
+ "GPIO5",
+ "GPIO6",
+ "SPI_CE1_N",
+ "SPI_CE0_N",
+ "SPI_MISO",
+ "SPI_MOSI",
+ "SPI_SCLK",
+ "GPIO12",
+ "GPIO13",
+ /* Serial port */
+ "TXD1",
+ "RXD1",
+ "GPIO16",
+ "GPIO17",
+ "GPIO18",
+ "GPIO19",
+ "GPIO20",
+ "GPIO21",
+ "GPIO22",
+ "GPIO23",
+ "GPIO24",
+ "GPIO25",
+ "GPIO26",
+ "GPIO27",
+ "RGMII_MDIO",
+ "RGMIO_MDC",
+ /* Used by BT module */
+ "CTS0",
+ "RTS0",
+ "TXD0",
+ "RXD0",
+ /* Used by Wifi */
+ "SD1_CLK",
+ "SD1_CMD",
+ "SD1_DATA0",
+ "SD1_DATA1",
+ "SD1_DATA2",
+ "SD1_DATA3",
+ /* Shared with SPI flash */
+ "PWM0_MISO",
+ "PWM1_MOSI",
+ "STATUS_LED_G_CLK",
+ "SPIFLASH_CE_N",
+ "SDA0",
+ "SCL0",
+ "RGMII_RXCLK",
+ "RGMII_RXCTL",
+ "RGMII_RXD0",
+ "RGMII_RXD1",
+ "RGMII_RXD2",
+ "RGMII_RXD3",
+ "RGMII_TXCLK",
+ "RGMII_TXCTL",
+ "RGMII_TXD0",
+ "RGMII_TXD1",
+ "RGMII_TXD2",
+ "RGMII_TXD3";
+};
+
+&hdmi0 {
+ status = "okay";
+};
+
+&hdmi1 {
+ status = "okay";
+};
+
+&pixelvalve0 {
+ status = "okay";
+};
+
+&pixelvalve1 {
+ status = "okay";
+};
+
+&pixelvalve2 {
+ status = "okay";
+};
+
+&pixelvalve4 {
+ status = "okay";
+};
+
+&pwm1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm1_0_gpio40 &pwm1_1_gpio41>;
+ status = "okay";
+};
+
+/* SDHCI is used to control the SDIO for wireless */
+&sdhci {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&emmc_gpio34>;
+ bus-width = <4>;
+ non-removable;
+ mmc-pwrseq = <&wifi_pwrseq>;
+ status = "okay";
+
+ brcmf: wifi@1 {
+ reg = <1>;
+ compatible = "brcm,bcm4329-fmac";
+ };
+};
+
+/* EMMC2 is used to drive the EMMC card */
+&emmc2 {
+ bus-width = <8>;
+ vqmmc-supply = <&sd_io_1v8_reg>;
+ vmmc-supply = <&sd_vcc_reg>;
+ broken-cd;
+ status = "okay";
+};
+
+&genet {
+ phy-handle = <&phy1>;
+ phy-mode = "rgmii-rxid";
+ status = "okay";
+};
+
+&genet_mdio {
+ phy1: ethernet-phy@0 {
+ /* No PHY interrupt */
+ reg = <0x0>;
+ };
+};
+
+&pcie0 {
+ pci@0,0 {
+ device-type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+
+ reg = <0 0 0 0 0>;
+ };
+};
+
+/* uart0 communicates with the BT module */
+&uart0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart0_ctsrts_gpio30 &uart0_gpio32>;
+ uart-has-rtscts;
+ status = "okay";
+
+ bluetooth {
+ compatible = "brcm,bcm43438-bt";
+ max-speed = <2000000>;
+ shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
+ };
+};
+
+/* uart1 is mapped to the pin header */
+&uart1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart1_gpio14>;
+ status = "okay";
+};
+
+&vchiq {
+ interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
+};
+
+&vc4 {
+ status = "okay";
+};
+
+&vec {
+ status = "disabled";
+};
+
+// =============================================
+// Downstream rpi- changes
+
+#define BCM2711
+
+#include "bcm270x.dtsi"
+#include "bcm271x-rpi-bt.dtsi"
+
+/ {
+ soc {
+ /delete-node/ pixelvalve@7e807000;
+ /delete-node/ hdmi@7e902000;
+ };
+};
+
+#include "bcm2711-rpi-ds.dtsi"
+#include "bcm283x-rpi-csi0-2lane.dtsi"
+#include "bcm283x-rpi-csi1-4lane.dtsi"
+#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
+
+/ {
+ chosen {
+ bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
+ };
+
+ aliases {
+ serial0 = &uart1;
+ serial1 = &uart0;
+ mmc0 = &emmc2;
+ mmc1 = &mmcnr;
+ mmc2 = &sdhost;
+ i2c3 = &i2c3;
+ i2c4 = &i2c4;
+ i2c5 = &i2c5;
+ i2c6 = &i2c6;
+ i2c20 = &ddc0;
+ i2c21 = &ddc1;
+ spi3 = &spi3;
+ spi4 = &spi4;
+ spi5 = &spi5;
+ spi6 = &spi6;
+ /delete-property/ intc;
+ };
+
+ /delete-node/ wifi-pwrseq;
+};
+
+&mmcnr {
+ pinctrl-names = "default";
+ pinctrl-0 = <&sdio_pins>;
+ bus-width = <4>;
+ status = "okay";
+};
+
+&uart0 {
+ pinctrl-0 = <&uart0_pins &bt_pins>;
+ status = "okay";
+};
+
+&uart1 {
+ pinctrl-0 = <&uart1_pins>;
+};
+
+&spi0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
+ cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
+
+ spidev0: spidev@0{
+ compatible = "spidev";
+ reg = <0>; /* CE0 */
+ #address-cells = <1>;
+ #size-cells = <0>;
+ spi-max-frequency = <125000000>;
+ };
+
+ spidev1: spidev@1{
+ compatible = "spidev";
+ reg = <1>; /* CE1 */
+ #address-cells = <1>;
+ #size-cells = <0>;
+ spi-max-frequency = <125000000>;
+ };
+};
+
+&gpio {
+ spi0_pins: spi0_pins {
+ brcm,pins = <9 10 11>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ };
+
+ spi0_cs_pins: spi0_cs_pins {
+ brcm,pins = <8 7>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ spi3_pins: spi3_pins {
+ brcm,pins = <1 2 3>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ };
+
+ spi3_cs_pins: spi3_cs_pins {
+ brcm,pins = <0 24>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ spi4_pins: spi4_pins {
+ brcm,pins = <5 6 7>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ };
+
+ spi4_cs_pins: spi4_cs_pins {
+ brcm,pins = <4 25>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ spi5_pins: spi5_pins {
+ brcm,pins = <13 14 15>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ };
+
+ spi5_cs_pins: spi5_cs_pins {
+ brcm,pins = <12 26>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ spi6_pins: spi6_pins {
+ brcm,pins = <19 20 21>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ };
+
+ spi6_cs_pins: spi6_cs_pins {
+ brcm,pins = <18 27>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ i2c0_pins: i2c0 {
+ brcm,pins = <0 1>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c1_pins: i2c1 {
+ brcm,pins = <2 3>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c3_pins: i2c3 {
+ brcm,pins = <4 5>;
+ brcm,function = <BCM2835_FSEL_ALT5>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c4_pins: i2c4 {
+ brcm,pins = <8 9>;
+ brcm,function = <BCM2835_FSEL_ALT5>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c5_pins: i2c5 {
+ brcm,pins = <12 13>;
+ brcm,function = <BCM2835_FSEL_ALT5>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c6_pins: i2c6 {
+ brcm,pins = <22 23>;
+ brcm,function = <BCM2835_FSEL_ALT5>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2s_pins: i2s {
+ brcm,pins = <18 19 20 21>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ };
+
+ sdio_pins: sdio_pins {
+ brcm,pins = <34 35 36 37 38 39>;
+ brcm,function = <BCM2835_FSEL_ALT3>; // alt3 = SD1
+ brcm,pull = <0 2 2 2 2 2>;
+ };
+
+ bt_pins: bt_pins {
+ brcm,pins = "-"; // non-empty to keep btuart happy, //4 = 0
+ // to fool pinctrl
+ brcm,function = <0>;
+ brcm,pull = <2>;
+ };
+
+ uart0_pins: uart0_pins {
+ brcm,pins = <32 33>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ brcm,pull = <0 2>;
+ };
+
+ uart1_pins: uart1_pins {
+ brcm,pins;
+ brcm,function;
+ brcm,pull;
+ };
+
+ uart2_pins: uart2_pins {
+ brcm,pins = <0 1>;
+ brcm,function = <BCM2835_FSEL_ALT4>;
+ brcm,pull = <0 2>;
+ };
+
+ uart3_pins: uart3_pins {
+ brcm,pins = <4 5>;
+ brcm,function = <BCM2835_FSEL_ALT4>;
+ brcm,pull = <0 2>;
+ };
+
+ uart4_pins: uart4_pins {
+ brcm,pins = <8 9>;
+ brcm,function = <BCM2835_FSEL_ALT4>;
+ brcm,pull = <0 2>;
+ };
+
+ uart5_pins: uart5_pins {
+ brcm,pins = <12 13>;
+ brcm,function = <BCM2835_FSEL_ALT4>;
+ brcm,pull = <0 2>;
+ };
+};
+
+&i2c0if {
+ clock-frequency = <100000>;
+};
+
+&i2c1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c1_pins>;
+ clock-frequency = <100000>;
+};
+
+&i2s {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2s_pins>;
+};
+
+// =============================================
+// Board specific stuff here
+
+&pcie0 {
+ brcm,enable-l1ss;
+};
+
+&sdhost {
+ status = "disabled";
+};
+
+&phy1 {
+ led-modes = <0x00 0x08>; /* link/activity link */
+};
+
+&gpio {
+ audio_pins: audio_pins {
+ brcm,pins = <>;
+ brcm,function = <>;
+ };
+};
+
+&leds {
+ act_led: led-act {
+ label = "led0";
+ linux,default-trigger = "mmc0";
+ gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
+ };
+
+ pwr_led: led-pwr {
+ label = "led1";
+ linux,default-trigger = "default-on";
+ gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
+ };
+};
+
+&pwm1 {
+ status = "disabled";
+};
+
+&audio {
+ pinctrl-names = "default";
+ pinctrl-0 = <&audio_pins>;
+ brcm,disable-headphones = <1>;
+};
+
+cam0_reg: &cam1_reg {
+ gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
+};
+
+/ {
+ __overrides__ {
+ act_led_gpio = <&act_led>,"gpios:4";
+ act_led_activelow = <&act_led>,"gpios:8";
+ act_led_trigger = <&act_led>,"linux,default-trigger";
+
+ pwr_led_gpio = <&pwr_led>,"gpios:4";
+ pwr_led_activelow = <&pwr_led>,"gpios:8";
+ pwr_led_trigger = <&pwr_led>,"linux,default-trigger";
+
+ eth_led0 = <&phy1>,"led-modes:0";
+ eth_led1 = <&phy1>,"led-modes:4";
+
+ ant1 = <&ant1>,"output-high?=on",
+ <&ant1>, "output-low?=off",
+ <&ant2>, "output-high?=off",
+ <&ant2>, "output-low?=on";
+ ant2 = <&ant1>,"output-high?=off",
+ <&ant1>, "output-low?=on",
+ <&ant2>, "output-high?=on",
+ <&ant2>, "output-low?=off";
+ noant = <&ant1>,"output-high?=off",
+ <&ant1>, "output-low?=on",
+ <&ant2>, "output-high?=off",
+ <&ant2>, "output-low?=on";
+
+ sd_poll_once = <&emmc2>, "non-removable?";
+ spi_dma4 = <&spi0>, "dmas:0=", <&dma40>,
+ <&spi0>, "dmas:8=", <&dma40>;
+ };
+};
diff --git a/arch/arm64/boot/dts/broadcom/Makefile b/arch/arm64/boot/dts/broadcom/Makefile
index 9873335d0ed2..8c19b62e189e 100644
--- a/arch/arm64/boot/dts/broadcom/Makefile
+++ b/arch/arm64/boot/dts/broadcom/Makefile
@@ -15,6 +15,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2710-rpi-cm3.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-cm4.dtb
dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-cm4s.dtb
+dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-cm4-ha-yellow.dtb
subdir-y += bcm4908
subdir-y += northstar2
diff --git a/arch/arm64/boot/dts/broadcom/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm64/boot/dts/broadcom/bcm2711-rpi-cm4-ha-yellow.dts
new file mode 100644
index 000000000000..fdc5ec5bc956
--- /dev/null
+++ b/arch/arm64/boot/dts/broadcom/bcm2711-rpi-cm4-ha-yellow.dts
@@ -0,0 +1 @@
+#include "../../../../arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts"
--
2.37.3

View File

@ -0,0 +1,656 @@
From b28a8f5b591841f88f19cbf9850d713a602d912e Mon Sep 17 00:00:00 2001
Message-Id: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Mon, 11 Apr 2022 14:47:59 +0200
Subject: [PATCH] ARM: dts: bcm2711: Add device tree for Home Assistant Yellow
Add device tree for Home Assistant Yellow, a Compute Module 4 based I/O
board.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/Makefile | 3 +-
.../boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 598 ++++++++++++++++++
arch/arm64/boot/dts/broadcom/Makefile | 1 +
.../broadcom/bcm2711-rpi-cm4-ha-yellow.dts | 1 +
4 files changed, 602 insertions(+), 1 deletion(-)
create mode 100644 arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
create mode 100644 arch/arm64/boot/dts/broadcom/bcm2711-rpi-cm4-ha-yellow.dts
diff -ruN a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
--- a/arch/arm/boot/dts/Makefile 2023-02-09 15:33:00.362946319 -0000
+++ b/arch/arm/boot/dts/Makefile 2023-02-09 15:35:14.619413829 -0000
@@ -93,7 +93,8 @@
bcm2711-rpi-400.dtb \
bcm2711-rpi-4-b.dtb \
bcm2835-rpi-zero.dtb \
- bcm2835-rpi-zero-w.dtb
+ bcm2835-rpi-zero-w.dtb \
+ bcm2711-rpi-cm4-ha-yellow.dtb
dtb-$(CONFIG_ARCH_BCM_5301X) += \
bcm4708-asus-rt-ac56u.dtb \
bcm4708-asus-rt-ac68u.dtb \
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
new file mode 100644
index 000000000000..61d8c81d3de4
--- /dev/null
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -0,0 +1,598 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+#include "bcm2711.dtsi"
+#include "bcm2711-rpi.dtsi"
+//#include "bcm283x-rpi-usb-peripheral.dtsi"
+
+/ {
+ compatible = "raspberrypi,4-compute-module-ha-yellow", "raspberrypi,4-compute-module", "brcm,bcm2711";
+ model = "Raspberry Pi Compute Module 4 on Home Assistant Yellow";
+
+ chosen {
+ /* 8250 auxiliary UART instead of pl011 */
+ stdout-path = "serial1:115200n8";
+ };
+
+ leds {
+ led-act {
+ gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
+ };
+
+ led-pwr {
+ label = "PWR";
+ gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
+ default-state = "keep";
+ linux,default-trigger = "default-on";
+ };
+ };
+
+ wifi_pwrseq: wifi-pwrseq {
+ compatible = "mmc-pwrseq-simple";
+ reset-gpios = <&expgpio 1 GPIO_ACTIVE_LOW>;
+ };
+
+ sd_io_1v8_reg: sd_io_1v8_reg {
+ compatible = "regulator-gpio";
+ regulator-name = "vdd-sd-io";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ regulator-always-on;
+ regulator-settling-time-us = <5000>;
+ gpios = <&expgpio 4 GPIO_ACTIVE_HIGH>;
+ states = <1800000 0x1>,
+ <3300000 0x0>;
+ status = "okay";
+ };
+
+ sd_vcc_reg: sd_vcc_reg {
+ compatible = "regulator-fixed";
+ regulator-name = "vcc-sd";
+ regulator-min-microvolt = <3300000>;
+ regulator-max-microvolt = <3300000>;
+ regulator-boot-on;
+ enable-active-high;
+ gpio = <&expgpio 6 GPIO_ACTIVE_HIGH>;
+ };
+};
+
+&ddc0 {
+ status = "okay";
+};
+
+&ddc1 {
+ status = "okay";
+};
+
+&expgpio {
+ gpio-line-names = "BT_ON",
+ "WL_ON",
+ "PWR_LED_OFF",
+ "ANT1",
+ "VDD_SD_IO_SEL",
+ "CAM_GPIO",
+ "SD_PWR_ON",
+ "ANT2";
+
+ ant1: ant1 {
+ gpio-hog;
+ gpios = <3 GPIO_ACTIVE_HIGH>;
+ output-high;
+ };
+
+ ant2: ant2 {
+ gpio-hog;
+ gpios = <7 GPIO_ACTIVE_HIGH>;
+ output-low;
+ };
+};
+
+&gpio {
+ /*
+ * Parts taken from rpi_SCH_4b_4p0_reduced.pdf and
+ * the official GPU firmware DT blob.
+ *
+ * Legend:
+ * "FOO" = GPIO line named "FOO" on the schematic
+ * "FOO_N" = GPIO line named "FOO" on schematic, active low
+ */
+ gpio-line-names = "ID_SDA",
+ "ID_SCL",
+ "SDA1",
+ "SCL1",
+ "GPIO_GCLK",
+ "GPIO5",
+ "GPIO6",
+ "SPI_CE1_N",
+ "SPI_CE0_N",
+ "SPI_MISO",
+ "SPI_MOSI",
+ "SPI_SCLK",
+ "GPIO12",
+ "GPIO13",
+ /* Serial port */
+ "TXD1",
+ "RXD1",
+ "GPIO16",
+ "GPIO17",
+ "GPIO18",
+ "GPIO19",
+ "GPIO20",
+ "GPIO21",
+ "GPIO22",
+ "GPIO23",
+ "GPIO24",
+ "GPIO25",
+ "GPIO26",
+ "GPIO27",
+ "RGMII_MDIO",
+ "RGMIO_MDC",
+ /* Used by BT module */
+ "CTS0",
+ "RTS0",
+ "TXD0",
+ "RXD0",
+ /* Used by Wifi */
+ "SD1_CLK",
+ "SD1_CMD",
+ "SD1_DATA0",
+ "SD1_DATA1",
+ "SD1_DATA2",
+ "SD1_DATA3",
+ /* Shared with SPI flash */
+ "PWM0_MISO",
+ "PWM1_MOSI",
+ "STATUS_LED_G_CLK",
+ "SPIFLASH_CE_N",
+ "SDA0",
+ "SCL0",
+ "RGMII_RXCLK",
+ "RGMII_RXCTL",
+ "RGMII_RXD0",
+ "RGMII_RXD1",
+ "RGMII_RXD2",
+ "RGMII_RXD3",
+ "RGMII_TXCLK",
+ "RGMII_TXCTL",
+ "RGMII_TXD0",
+ "RGMII_TXD1",
+ "RGMII_TXD2",
+ "RGMII_TXD3";
+};
+
+&hdmi0 {
+ status = "okay";
+};
+
+&hdmi1 {
+ status = "okay";
+};
+
+&pixelvalve0 {
+ status = "okay";
+};
+
+&pixelvalve1 {
+ status = "okay";
+};
+
+&pixelvalve2 {
+ status = "okay";
+};
+
+&pixelvalve4 {
+ status = "okay";
+};
+
+&pwm1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm1_0_gpio40 &pwm1_1_gpio41>;
+ status = "okay";
+};
+
+/* SDHCI is used to control the SDIO for wireless */
+&sdhci {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&emmc_gpio34>;
+ bus-width = <4>;
+ non-removable;
+ mmc-pwrseq = <&wifi_pwrseq>;
+ status = "okay";
+
+ brcmf: wifi@1 {
+ reg = <1>;
+ compatible = "brcm,bcm4329-fmac";
+ };
+};
+
+/* EMMC2 is used to drive the EMMC card */
+&emmc2 {
+ bus-width = <8>;
+ vqmmc-supply = <&sd_io_1v8_reg>;
+ vmmc-supply = <&sd_vcc_reg>;
+ broken-cd;
+ status = "okay";
+};
+
+&genet {
+ phy-handle = <&phy1>;
+ phy-mode = "rgmii-rxid";
+ status = "okay";
+};
+
+&genet_mdio {
+ phy1: ethernet-phy@0 {
+ /* No PHY interrupt */
+ reg = <0x0>;
+ };
+};
+
+&pcie0 {
+ pci@0,0 {
+ device-type = "pci";
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges;
+
+ reg = <0 0 0 0 0>;
+ };
+};
+
+/* uart0 communicates with the BT module */
+&uart0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart0_ctsrts_gpio30 &uart0_gpio32>;
+ uart-has-rtscts;
+ status = "okay";
+
+ bluetooth {
+ compatible = "brcm,bcm43438-bt";
+ max-speed = <2000000>;
+ shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
+ };
+};
+
+/* uart1 is mapped to the pin header */
+&uart1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart1_gpio14>;
+ status = "okay";
+};
+
+&vchiq {
+ interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
+};
+
+&vc4 {
+ status = "okay";
+};
+
+&vec {
+ status = "disabled";
+};
+
+// =============================================
+// Downstream rpi- changes
+
+#define BCM2711
+
+#include "bcm270x.dtsi"
+#include "bcm271x-rpi-bt.dtsi"
+
+/ {
+ soc {
+ /delete-node/ pixelvalve@7e807000;
+ /delete-node/ hdmi@7e902000;
+ };
+};
+
+#include "bcm2711-rpi-ds.dtsi"
+#include "bcm283x-rpi-csi0-2lane.dtsi"
+#include "bcm283x-rpi-csi1-4lane.dtsi"
+#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
+
+/ {
+ chosen {
+ bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
+ };
+
+ aliases {
+ serial0 = &uart1;
+ serial1 = &uart0;
+ mmc0 = &emmc2;
+ mmc1 = &mmcnr;
+ mmc2 = &sdhost;
+ i2c3 = &i2c3;
+ i2c4 = &i2c4;
+ i2c5 = &i2c5;
+ i2c6 = &i2c6;
+ i2c20 = &ddc0;
+ i2c21 = &ddc1;
+ spi3 = &spi3;
+ spi4 = &spi4;
+ spi5 = &spi5;
+ spi6 = &spi6;
+ /delete-property/ intc;
+ };
+
+ /delete-node/ wifi-pwrseq;
+};
+
+&mmcnr {
+ pinctrl-names = "default";
+ pinctrl-0 = <&sdio_pins>;
+ bus-width = <4>;
+ status = "okay";
+};
+
+&uart0 {
+ pinctrl-0 = <&uart0_pins &bt_pins>;
+ status = "okay";
+};
+
+&uart1 {
+ pinctrl-0 = <&uart1_pins>;
+};
+
+&spi0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&spi0_pins &spi0_cs_pins>;
+ cs-gpios = <&gpio 8 1>, <&gpio 7 1>;
+
+ spidev0: spidev@0{
+ compatible = "spidev";
+ reg = <0>; /* CE0 */
+ #address-cells = <1>;
+ #size-cells = <0>;
+ spi-max-frequency = <125000000>;
+ };
+
+ spidev1: spidev@1{
+ compatible = "spidev";
+ reg = <1>; /* CE1 */
+ #address-cells = <1>;
+ #size-cells = <0>;
+ spi-max-frequency = <125000000>;
+ };
+};
+
+&gpio {
+ spi0_pins: spi0_pins {
+ brcm,pins = <9 10 11>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ };
+
+ spi0_cs_pins: spi0_cs_pins {
+ brcm,pins = <8 7>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ spi3_pins: spi3_pins {
+ brcm,pins = <1 2 3>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ };
+
+ spi3_cs_pins: spi3_cs_pins {
+ brcm,pins = <0 24>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ spi4_pins: spi4_pins {
+ brcm,pins = <5 6 7>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ };
+
+ spi4_cs_pins: spi4_cs_pins {
+ brcm,pins = <4 25>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ spi5_pins: spi5_pins {
+ brcm,pins = <13 14 15>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ };
+
+ spi5_cs_pins: spi5_cs_pins {
+ brcm,pins = <12 26>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ spi6_pins: spi6_pins {
+ brcm,pins = <19 20 21>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ };
+
+ spi6_cs_pins: spi6_cs_pins {
+ brcm,pins = <18 27>;
+ brcm,function = <BCM2835_FSEL_GPIO_OUT>;
+ };
+
+ i2c0_pins: i2c0 {
+ brcm,pins = <0 1>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c1_pins: i2c1 {
+ brcm,pins = <2 3>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c3_pins: i2c3 {
+ brcm,pins = <4 5>;
+ brcm,function = <BCM2835_FSEL_ALT5>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c4_pins: i2c4 {
+ brcm,pins = <8 9>;
+ brcm,function = <BCM2835_FSEL_ALT5>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c5_pins: i2c5 {
+ brcm,pins = <12 13>;
+ brcm,function = <BCM2835_FSEL_ALT5>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2c6_pins: i2c6 {
+ brcm,pins = <22 23>;
+ brcm,function = <BCM2835_FSEL_ALT5>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
+ i2s_pins: i2s {
+ brcm,pins = <18 19 20 21>;
+ brcm,function = <BCM2835_FSEL_ALT0>;
+ };
+
+ sdio_pins: sdio_pins {
+ brcm,pins = <34 35 36 37 38 39>;
+ brcm,function = <BCM2835_FSEL_ALT3>; // alt3 = SD1
+ brcm,pull = <0 2 2 2 2 2>;
+ };
+
+ bt_pins: bt_pins {
+ brcm,pins = "-"; // non-empty to keep btuart happy, //4 = 0
+ // to fool pinctrl
+ brcm,function = <0>;
+ brcm,pull = <2>;
+ };
+
+ uart0_pins: uart0_pins {
+ brcm,pins = <32 33>;
+ brcm,function = <BCM2835_FSEL_ALT3>;
+ brcm,pull = <0 2>;
+ };
+
+ uart1_pins: uart1_pins {
+ brcm,pins;
+ brcm,function;
+ brcm,pull;
+ };
+
+ uart2_pins: uart2_pins {
+ brcm,pins = <0 1>;
+ brcm,function = <BCM2835_FSEL_ALT4>;
+ brcm,pull = <0 2>;
+ };
+
+ uart3_pins: uart3_pins {
+ brcm,pins = <4 5>;
+ brcm,function = <BCM2835_FSEL_ALT4>;
+ brcm,pull = <0 2>;
+ };
+
+ uart4_pins: uart4_pins {
+ brcm,pins = <8 9>;
+ brcm,function = <BCM2835_FSEL_ALT4>;
+ brcm,pull = <0 2>;
+ };
+
+ uart5_pins: uart5_pins {
+ brcm,pins = <12 13>;
+ brcm,function = <BCM2835_FSEL_ALT4>;
+ brcm,pull = <0 2>;
+ };
+};
+
+&i2c0if {
+ clock-frequency = <100000>;
+};
+
+&i2c1 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c1_pins>;
+ clock-frequency = <100000>;
+};
+
+&i2s {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2s_pins>;
+};
+
+// =============================================
+// Board specific stuff here
+
+&pcie0 {
+ brcm,enable-l1ss;
+};
+
+&sdhost {
+ status = "disabled";
+};
+
+&phy1 {
+ led-modes = <0x00 0x08>; /* link/activity link */
+};
+
+&gpio {
+ audio_pins: audio_pins {
+ brcm,pins = <>;
+ brcm,function = <>;
+ };
+};
+
+&leds {
+ act_led: led-act {
+ label = "led0";
+ linux,default-trigger = "mmc0";
+ gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
+ };
+
+ pwr_led: led-pwr {
+ label = "led1";
+ linux,default-trigger = "default-on";
+ gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
+ };
+};
+
+&pwm1 {
+ status = "disabled";
+};
+
+&audio {
+ pinctrl-names = "default";
+ pinctrl-0 = <&audio_pins>;
+ brcm,disable-headphones = <1>;
+};
+
+cam0_reg: &cam1_reg {
+ gpio = <&expgpio 5 GPIO_ACTIVE_HIGH>;
+};
+
+/ {
+ __overrides__ {
+ act_led_gpio = <&act_led>,"gpios:4";
+ act_led_activelow = <&act_led>,"gpios:8";
+ act_led_trigger = <&act_led>,"linux,default-trigger";
+
+ pwr_led_gpio = <&pwr_led>,"gpios:4";
+ pwr_led_activelow = <&pwr_led>,"gpios:8";
+ pwr_led_trigger = <&pwr_led>,"linux,default-trigger";
+
+ eth_led0 = <&phy1>,"led-modes:0";
+ eth_led1 = <&phy1>,"led-modes:4";
+
+ ant1 = <&ant1>,"output-high?=on",
+ <&ant1>, "output-low?=off",
+ <&ant2>, "output-high?=off",
+ <&ant2>, "output-low?=on";
+ ant2 = <&ant1>,"output-high?=off",
+ <&ant1>, "output-low?=on",
+ <&ant2>, "output-high?=on",
+ <&ant2>, "output-low?=off";
+ noant = <&ant1>,"output-high?=off",
+ <&ant1>, "output-low?=on",
+ <&ant2>, "output-high?=off",
+ <&ant2>, "output-low?=on";
+
+ sd_poll_once = <&emmc2>, "non-removable?";
+ spi_dma4 = <&spi0>, "dmas:0=", <&dma40>,
+ <&spi0>, "dmas:8=", <&dma40>;
+ };
+};
diff --git a/arch/arm64/boot/dts/broadcom/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm64/boot/dts/broadcom/bcm2711-rpi-cm4-ha-yellow.dts
new file mode 100644
index 000000000000..fdc5ec5bc956
--- /dev/null
+++ b/arch/arm64/boot/dts/broadcom/bcm2711-rpi-cm4-ha-yellow.dts
@@ -0,0 +1 @@
+#include "../../../../arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts"
--
2.37.3
diff -ruN a/arch/arm64/boot/dts/broadcom/Makefile b/arch/arm64/boot/dts/broadcom/Makefile
--- a/arch/arm64/boot/dts/broadcom/Makefile 2023-02-09 16:15:32.939847341 -0000
+++ b/arch/arm64/boot/dts/broadcom/Makefile 2023-02-09 16:16:03.899185742 -0000
@@ -2,6 +2,7 @@
dtb-$(CONFIG_ARCH_BCM2835) += bcm2711-rpi-400.dtb \
bcm2711-rpi-4-b.dtb \
bcm2711-rpi-cm4-io.dtb \
+ bcm2711-rpi-cm4-ha-yellow.dtb \
bcm2837-rpi-3-a-plus.dtb \
bcm2837-rpi-3-b.dtb \
bcm2837-rpi-3-b-plus.dtb \

View File

@ -0,0 +1,74 @@
From 2230740c7f74678ca80da55f74ccc24f5aa6bd35 Mon Sep 17 00:00:00 2001
Message-Id: <2230740c7f74678ca80da55f74ccc24f5aa6bd35.1614676528.git.stefan@agner.ch>
From: Pascal Vizeli <pvizeli@syshack.ch>
Date: Tue, 2 Jun 2020 21:20:08 +0000
Subject: [PATCH] ARM: dts: bcm283x: add compatible picked up by U-Boot
Without brcm,bcm2835-pl011 in compatible U-Boot uses the regular PL011
driver which seems to crash when enable_uart=1 is not used. Using
brcm,bcm2835-pl011 works around that and does not affect Linux since its
not using that compatible string.
Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711.dtsi | 8 ++++----
arch/arm/boot/dts/bcm283x.dtsi | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index b4bca5af95e1..c31b87b5bb3a 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -127,7 +127,7 @@ rng@7e104000 {
};
uart2: serial@7e201400 {
- compatible = "arm,pl011", "arm,primecell";
+ compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell";
reg = <0x7e201400 0x200>;
interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clocks BCM2835_CLOCK_UART>,
@@ -138,7 +138,7 @@ uart2: serial@7e201400 {
};
uart3: serial@7e201600 {
- compatible = "arm,pl011", "arm,primecell";
+ compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell";
reg = <0x7e201600 0x200>;
interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clocks BCM2835_CLOCK_UART>,
@@ -149,7 +149,7 @@ uart3: serial@7e201600 {
};
uart4: serial@7e201800 {
- compatible = "arm,pl011", "arm,primecell";
+ compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell";
reg = <0x7e201800 0x200>;
interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clocks BCM2835_CLOCK_UART>,
@@ -160,7 +160,7 @@ uart4: serial@7e201800 {
};
uart5: serial@7e201a00 {
- compatible = "arm,pl011", "arm,primecell";
+ compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell";
reg = <0x7e201a00 0x200>;
interrupts = <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clocks BCM2835_CLOCK_UART>,
diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
index 346838ee9d21..7f289fbca28c 100644
--- a/arch/arm/boot/dts/bcm283x.dtsi
+++ b/arch/arm/boot/dts/bcm283x.dtsi
@@ -300,7 +300,7 @@ uart1_ctsrts_gpio42: uart1_ctsrts_gpio42 {
};
uart0: serial@7e201000 {
- compatible = "arm,pl011", "arm,primecell";
+ compatible = "brcm,bcm2835-pl011", "arm,pl011", "arm,primecell";
reg = <0x7e201000 0x200>;
interrupts = <2 25>;
clocks = <&clocks BCM2835_CLOCK_UART>,
--
2.30.1

View File

@ -0,0 +1,60 @@
From 7eb647452bb1a3294fae8edc5a323070adff922b Mon Sep 17 00:00:00 2001
Message-Id: <7eb647452bb1a3294fae8edc5a323070adff922b.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 4 Mar 2021 14:33:09 +0100
Subject: [PATCH] ARM: dts: bcm2711: yellow: Mux UART4 for SiLabs radio module
Enable UART4 by default and mux pins including hardware flow control.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index 61d8c81d3de4..8db71876a78c 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -8,6 +8,10 @@ / {
compatible = "raspberrypi,4-compute-module-ha-yellow", "raspberrypi,4-compute-module", "brcm,bcm2711";
model = "Raspberry Pi Compute Module 4 on Home Assistant Yellow";
+ aliases {
+ serial4 = &uart4;
+ };
+
chosen {
/* 8250 auxiliary UART instead of pl011 */
stdout-path = "serial1:115200n8";
@@ -261,6 +265,14 @@ &uart1 {
status = "okay";
};
+/* uart4 for Zigbee */
+&uart4 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart4_pins>;
+ uart-has-rtscts;
+ status = "okay";
+};
+
&vchiq {
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
};
@@ -488,9 +500,9 @@ uart3_pins: uart3_pins {
};
uart4_pins: uart4_pins {
- brcm,pins = <8 9>;
+ brcm,pins = <8 9 10 11>;
brcm,function = <BCM2835_FSEL_ALT4>;
- brcm,pull = <0 2>;
+ brcm,pull = <0 2 2 0>;
};
uart5_pins: uart5_pins {
--
2.37.3

View File

@ -0,0 +1,50 @@
From a7b86d8d0d81f841d8399a83f0f59f383d1556ed Mon Sep 17 00:00:00 2001
Message-Id: <a7b86d8d0d81f841d8399a83f0f59f383d1556ed.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 4 Mar 2021 14:44:23 +0100
Subject: [PATCH] ARM: dts: bcm2711: yellow: Mux debug UART5
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index 8db71876a78c..d1dea0a214a6 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -10,6 +10,7 @@ / {
aliases {
serial4 = &uart4;
+ serial5 = &uart5;
};
chosen {
@@ -273,6 +274,13 @@ &uart4 {
status = "okay";
};
+/* uart5 default Debug UART */
+&uart5 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart5_pins>;
+ status = "okay";
+};
+
&vchiq {
interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
};
@@ -308,6 +316,7 @@ soc {
/ {
chosen {
bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
+ stdout-path = "serial5:115200n8";
};
aliases {
--
2.37.3

View File

@ -0,0 +1,35 @@
From 8ec364f50abcd9f5fa89f421a7ef8f70dfb2564a Mon Sep 17 00:00:00 2001
Message-Id: <8ec364f50abcd9f5fa89f421a7ef8f70dfb2564a.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 4 Mar 2021 14:48:48 +0100
Subject: [PATCH] ARM: dts: bcm2711: yellow: Enable I2C6 by default
The main I2C bus used on Yellow is I2C6. Enable it by default.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index d1dea0a214a6..0bdbfdd44aed 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -531,6 +531,12 @@ &i2c1 {
clock-frequency = <100000>;
};
+&i2c6 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c6_pins>;
+ status = "okay";
+};
+
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
--
2.37.3

View File

@ -0,0 +1,67 @@
From 50abc7980f8c575930cc4c928d356763742e81fb Mon Sep 17 00:00:00 2001
Message-Id: <50abc7980f8c575930cc4c928d356763742e81fb.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 4 Mar 2021 17:19:01 +0100
Subject: [PATCH] ARM: dts: bcm2711: yellow: add I2S audio codec
Add TI PCM5122 I2S audio codec.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
.../boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 26 +++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index 0bdbfdd44aed..f6f42bf45c92 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -535,11 +535,22 @@ &i2c6 {
pinctrl-names = "default";
pinctrl-0 = <&i2c6_pins>;
status = "okay";
+
+ card_codec: pcm5121@4c {
+ #sound-dai-cells = <0>;
+ compatible = "ti,pcm5121";
+ reg = <0x4c>;
+ AVDD-supply = <&vdd_3v3_reg>;
+ DVDD-supply = <&vdd_3v3_reg>;
+ CPVDD-supply = <&vdd_3v3_reg>;
+ status = "okay";
+ };
};
&i2s {
pinctrl-names = "default";
pinctrl-0 = <&i2s_pins>;
+ status = "okay";
};
// =============================================
@@ -582,6 +593,21 @@ &pwm1 {
status = "disabled";
};
+&sound {
+ compatible = "simple-audio-card";
+ simple-audio-card,format = "i2s";
+ simple-audio-card,name = "pcm5121-sound";
+ status = "okay";
+
+ simple-audio-card,cpu {
+ sound-dai = <&i2s>;
+ };
+
+ dailink0_slave: simple-audio-card,codec {
+ sound-dai = <&card_codec>;
+ };
+};
+
&audio {
pinctrl-names = "default";
pinctrl-0 = <&audio_pins>;
--
2.37.3

View File

@ -0,0 +1,72 @@
From 67751f4575c3837ada1bdec85184c77ea917b83a Mon Sep 17 00:00:00 2001
Message-Id: <67751f4575c3837ada1bdec85184c77ea917b83a.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Tue, 9 Mar 2021 15:02:53 +0100
Subject: [PATCH] ARM: dts: bcm2711: yellow: enable GPIO keys
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
.../boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 31 +++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index f6f42bf45c92..e2fa42a11cc9 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -4,6 +4,8 @@
#include "bcm2711-rpi.dtsi"
//#include "bcm283x-rpi-usb-peripheral.dtsi"
+#include <dt-bindings/input/input.h>
+
/ {
compatible = "raspberrypi,4-compute-module-ha-yellow", "raspberrypi,4-compute-module", "brcm,bcm2711";
model = "Raspberry Pi Compute Module 4 on Home Assistant Yellow";
@@ -18,6 +20,29 @@ chosen {
stdout-path = "serial1:115200n8";
};
+ keys: gpio-keys {
+ compatible = "gpio-keys";
+
+ pinctrl-names = "default";
+ pinctrl-0 = <&gpio_button_pins>;
+
+ status = "okay";
+
+ power {
+ label = "Blue Button";
+ linux,code = <KEY_POWER>;
+ gpios = <&gpio 26 GPIO_ACTIVE_LOW>;
+ debounce-interval = <100>; // ms
+ };
+
+ user {
+ label = "Red Button";
+ linux,code = <BTN_1>;
+ gpios = <&gpio 27 GPIO_ACTIVE_LOW>;
+ debounce-interval = <100>; // ms
+ };
+ };
+
leds {
led-act {
gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
@@ -380,6 +405,12 @@ spidev1: spidev@1{
};
&gpio {
+ gpio_button_pins: gpio_button_pins {
+ brcm,pins = <26 27>;
+ brcm,function = <BCM2835_FSEL_GPIO_IN>;
+ brcm,pull = <BCM2835_PUD_UP>;
+ };
+
spi0_pins: spi0_pins {
brcm,pins = <9 10 11>;
brcm,function = <BCM2835_FSEL_ALT0>;
--
2.37.3

View File

@ -0,0 +1,43 @@
From e4db609b1080e4aabb027394966c07e050e02aab Mon Sep 17 00:00:00 2001
Message-Id: <e4db609b1080e4aabb027394966c07e050e02aab.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 28 Oct 2021 19:38:04 +0200
Subject: [PATCH] ARM: dts: bcm2711: yellow: add user LED
Add yellow user LED.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index e2fa42a11cc9..6039c7894796 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -336,7 +336,6 @@ soc {
#include "bcm2711-rpi-ds.dtsi"
#include "bcm283x-rpi-csi0-2lane.dtsi"
#include "bcm283x-rpi-csi1-4lane.dtsi"
-#include "bcm283x-rpi-i2c0mux_0_44.dtsi"
/ {
chosen {
@@ -618,6 +617,12 @@ pwr_led: led-pwr {
linux,default-trigger = "default-on";
gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
};
+
+ user_led: led-user {
+ label = "led2";
+ linux,default-trigger = "heartbeat";
+ gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+ };
};
&pwm1 {
--
2.37.3

View File

@ -0,0 +1,32 @@
From 6625adc479a3e89873127a91064a94881449c0d8 Mon Sep 17 00:00:00 2001
Message-Id: <6625adc479a3e89873127a91064a94881449c0d8.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Fri, 12 Nov 2021 17:33:32 +0100
Subject: [PATCH] ARM: dts: bcm2711: yellow: add NXP PCF85063A RTC
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index 6039c7894796..f78428ea64f3 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -575,6 +575,11 @@ card_codec: pcm5121@4c {
CPVDD-supply = <&vdd_3v3_reg>;
status = "okay";
};
+
+ pcf85063a: rtc@51 {
+ compatible = "nxp,pcf85063a";
+ reg = <0x51>;
+ };
};
&i2s {
--
2.37.3

View File

@ -0,0 +1,39 @@
From 1acd279eca810707856e5038438f52d694a62170 Mon Sep 17 00:00:00 2001
Message-Id: <1acd279eca810707856e5038438f52d694a62170.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Fri, 7 Jan 2022 17:10:00 +0100
Subject: [PATCH] ARM: dts: bcm2711: yellow: enable USB host mode by default
The DWC2 controller is disable by default. Enable it since Home
Assistant Yellow has a USB hub and USB ports connected to it.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index f78428ea64f3..711a09441ad0 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -599,6 +599,15 @@ &sdhost {
status = "disabled";
};
+&usb {
+ compatible = "brcm,bcm2835-usb";
+ dr_mode = "host";
+ g-np-tx-fifo-size = <32>;
+ g-rx-fifo-size = <558>;
+ g-tx-fifo-size = <512 512 512 512 512 256 256>;
+ status = "okay";
+};
+
&phy1 {
led-modes = <0x00 0x08>; /* link/activity link */
};
--
2.37.3

View File

@ -0,0 +1,33 @@
From 92332ba4302096777ea47e408f3406da0b2ef2c5 Mon Sep 17 00:00:00 2001
Message-Id: <92332ba4302096777ea47e408f3406da0b2ef2c5.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Wed, 27 Apr 2022 20:36:19 +0200
Subject: [PATCH] ARM: dts: bcm2711: yellow: use generic activity trigger for
green LED
Use the generic trigger "activity" for the green LED so that any
system activity is shown.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index 711a09441ad0..f2f4f1a49592 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -622,7 +622,7 @@ audio_pins: audio_pins {
&leds {
act_led: led-act {
label = "led0";
- linux,default-trigger = "mmc0";
+ linux,default-trigger = "activity";
gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
};
--
2.37.3

View File

@ -0,0 +1,32 @@
From 59e44006c1e7406bd1fc52aa9b1fc88a67652ddd Mon Sep 17 00:00:00 2001
Message-Id: <59e44006c1e7406bd1fc52aa9b1fc88a67652ddd.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Tue, 26 Jul 2022 15:53:59 +0200
Subject: [PATCH] ARM: dts: bcm2711: yellow: use USB OTG mode by default
OTG seems to work fine, and allows to use the USB-C port as a USB
peripheral (e.g. in U-Boot via UMS command).
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index f2f4f1a49592..f354bfb69093 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -601,7 +601,7 @@ &sdhost {
&usb {
compatible = "brcm,bcm2835-usb";
- dr_mode = "host";
+ dr_mode = "otg";
g-np-tx-fifo-size = <32>;
g-rx-fifo-size = <558>;
g-tx-fifo-size = <512 512 512 512 512 256 256>;
--
2.37.3

View File

@ -0,0 +1,68 @@
From f69ef30ade36371215d02546d603143cc13adef2 Mon Sep 17 00:00:00 2001
Message-Id: <f69ef30ade36371215d02546d603143cc13adef2.1662565903.git.stefan@agner.ch>
In-Reply-To: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
References: <b28a8f5b591841f88f19cbf9850d713a602d912e.1662565903.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Sat, 30 Jul 2022 11:21:31 +0200
Subject: [PATCH] ARM: dts: bcm2711: yellow: Add LED overrides
Add device tree overrides for all three LEDs.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
index f354bfb69093..2d272a02128b 100644
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4-ha-yellow.dts
@@ -621,20 +621,24 @@ audio_pins: audio_pins {
&leds {
act_led: led-act {
- label = "led0";
+ label = "act";
linux,default-trigger = "activity";
+ default-state = "off";
gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
};
pwr_led: led-pwr {
- label = "led1";
+ label = "pwr";
linux,default-trigger = "default-on";
+ default-state = "off";
gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
};
- user_led: led-user {
- label = "led2";
+ usr_led: led-usr {
+ label = "usr";
linux,default-trigger = "heartbeat";
+ default-state = "off";
+ panic-indicator;
gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
};
};
@@ -670,14 +674,13 @@ cam0_reg: &cam1_reg {
/ {
__overrides__ {
- act_led_gpio = <&act_led>,"gpios:4";
- act_led_activelow = <&act_led>,"gpios:8";
act_led_trigger = <&act_led>,"linux,default-trigger";
- pwr_led_gpio = <&pwr_led>,"gpios:4";
pwr_led_activelow = <&pwr_led>,"gpios:8";
pwr_led_trigger = <&pwr_led>,"linux,default-trigger";
+ usr_led_trigger = <&usr_led>,"linux,default-trigger";
+
eth_led0 = <&phy1>,"led-modes:0";
eth_led1 = <&phy1>,"led-modes:4";
--
2.37.3

103
install-update.sh Executable file
View File

@ -0,0 +1,103 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
die() {
rc=$?
if [ $rc -eq 0 ]; then
rc=1
fi
error "$@"
exit $rc
}
error() {
printf 'ERROR: '
info "$@"
}
get_partuuid() {
blkid -o value -s PARTUUID "$1"
}
info() {
if [ $# -eq 1 ]; then
echo "$1" >&2
elif [ $# -gt 1 ]; then
printf "$@" >&2
fi
}
set_default_boot() {
_rc=0
mkdir -p newroot || return
mount -oro "$1" newroot || return
_kernel=$(find newroot/boot -name 'vmlinuz-*' -printf '%P\n' \
| sort -V \
| tail -n1
)
_kver=${_kernel#vmlinuz-}
_partuuid=$(get_partuuid "$1")
_id=id-${_partuuid}-${_kver}
printf 'Setting default boot entry to %s\n' "${_id}"
grub-editenv /boot/efi/EFI/gentoo/grubenv set "default=${_id}" || rc=$?
umount newroot
return $rc
}
warn() {
printf 'WARNING: '
info "$@"
}
write_firmware() {
_rc=0
_esp=$(findfs PARTLABEL='EFI System Partition')
if [ -z "${_esp}" ]; then
error 'Could not identify EFI System Partition'
return 1
fi
if ! mountpoint -q /boot/efi; then
mount -o ro "${_esp}" /boot/efi \
|| warn 'Failed to mount EFI System Partition'
fi
if [ -f /boot/efi/EFI/gentoo/grubenv ]; then
info 'Saving current GRUB environment ...'
cp /boot/efi/EFI/gentoo/grubenv . \
|| warn 'Failed to save GRUB environment'
fi
if mountpoint -q /boot/efi; then
umount /boot/efi || return
fi
info 'Writing firmware image to EFI System Partition (%s) ...\n' "${_esp}"
dd if=firmware.img of="${_esp}" bs=1M || _rc=$?
if [ $_rc -eq 0 ]; then
mount -orw "${_esp}" /boot/efi || rc=$?
fi
if [ $_rc -eq 0 ]; then
if [ -f grubenv ]; then
printf 'Restoring GRUB environment ...\n'
cp grubenv /boot/efi/EFI/gentoo/grubenv || _rc=$?
fi
fi
return $_rc
}
write_rootfs() {
printf 'Writing rootfs image to %s ...\n' "$1"
dd if=rootfs.squashfs of="$1" bs=1M
}
rc=0
newroot="$1"
write_rootfs "${newroot}" || die 'Failed to write new rootfs image to disk'
write_firmware || die 'Failed to write new firmware image to disk'
if ! set_default_boot "${newroot}"; then
rc=$?
error 'Failed to set default boot option'
fi
if [ $rc -eq 0 ]; then
info 'Successfully installed update'
fi
exit $rc

46
linux.config Normal file
View File

@ -0,0 +1,46 @@
CONFIG_BTRFS_FS=y
CONFIG_OVERLAY_FS=m
CONFIG_MISC_FILESYSTEMS=y
CONFIG_SQUASHFS=y
CONFIG_SQUASHFS_XATTR=y
CONFIG_SQUASHFS_ZSTD=y
CONFIG_EFI=y
CONFIG_EFI_STUB=y
CONFIG_PCI=y
CONFIG_PCIE_BRCMSTB=y
CONFIG_BLK_DEV_NVME=y
CONFIG_FW_LOADER_COMPRESS=y
CONFIG_I2C=y
CONFIG_I2C_CHARDEV=m
CONFIG_I2C_MUX=m
CONFIG_I2C_MUX_GPMUX=m
CONFIG_I2C_MUX_PINCTRL=m
CONFIG_I2C_BCM2708=m
CONFIG_I2C_BCM2835=m
CONFIG_I2C_BRCMSTB=m
CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_PCF85063=m
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_DISK=y
CONFIG_LEDS_TRIGGER_ACTIVITY=y
CONFIG_WLAN=y
CONFIG_WLAN_VENDOR_BROADCOM=y
CONFIG_CFG80211=m
CONFIG_MAC80211=m
CONFIG_BRCM_FMAC=m
CONFIG_BT=m
# CONFIG_KSM is not set
CONFIG_IPV6=y
CONFIG_IPV6_SIT=m
CONFIG_IPV6_SIT_6RD=m

4
overlay/etc/fstab Normal file
View File

@ -0,0 +1,4 @@
PARTLABEL=dch-data /var btrfs subvol=var,nosuid,noexec,nodev 0 2
PARTLABEL=dch-data /run/etc btrfs subvol=etc,nosuid,noexec,nodev 0 0
overlay /run/etc/rw overlay lowerdir=/etc,upperdir=/run/etc/rw,workdir=/run/etc/.work 0 0
/run/etc/rw/ssh /etc/ssh none bind 0 0

1
overlay/etc/resolv.conf Symbolic link
View File

@ -0,0 +1 @@
../run/systemd/resolve/resolv.conf

View File

@ -0,0 +1,2 @@
AuthorizedKeysCommand /usr/libexec/ssh-authorized-keys %u %t
AuthorizedKeysCommandUser nobody

View File

@ -0,0 +1,5 @@
[Match]
Type=ether
[Network]
DHCP=yes

135
overlay/usr/bin/system-update Executable file
View File

@ -0,0 +1,135 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
cleanup() {
cd /
if [ -n "${workdir}" ] && [ "${workdir}" != / ]; then
rm -rf "${workdir}"
fi
unset workdir
}
die() {
rc=$?
if [ $rc -eq 0 ]; then
rc=1
fi
error "$@"
exit $rc
}
error() {
if [ $# -eq 1 ]; then
echo "$1" >&2
elif [ $# -gt 1 ]; then
printf "$@" >&2
fi
}
extract_update() {
zstd -dc update.tar.zstd | tar -x \
|| die 'Could not extract update source'
sha256sum -c digests \
|| die 'Invalid update source: checksum mismatch'
}
fetch_update() {
wget -O update.tar.zstd "$1"
}
get_root() {
set -- $(cat /proc/cmdline)
while [ $# -gt 0 ]; do
case "$1" in
root=*)
_root=${1#root=}
;;
esac
shift
done
echo $(findfs "${_root}")
}
get_partlabel() {
blkid -o value -s PARTLABEL "$1"
}
help() {
usage
}
info() {
if [ $# -eq 1 ]; then
echo "$1" >&2
elif [ $# -gt 1 ]; then
printf "$@" >&2
fi
}
usage() {
printf 'usage: %s source_url\n' "${0##*/}"
}
while [ $# -gt 0 ]; do
case "$1" in
--help)
help
exit 0
;;
*)
if [ -z "${source_url}" ]; then
source_url="$1"
else
usage >&2
exit 2
fi
;;
esac
shift
done
if [ -z "${source_url}" ]; then
usage >&2
exit 2
fi
root=$(get_root)
partlabel=$(get_partlabel "${root}")
case "${partlabel}" in
rootfs-a)
newpartlabel=rootfs-b
;;
rootfs-b)
newpartlabel=rootfs-a
;;
*)
die \
'Unsupported system configuration: invalid rootfs partition label: %s\n' \
"${partlabel}" >&2
esac
newroot=$(findfs PARTLABEL="${newpartlabel}")
if [ -z "${newroot}" ]; then
die 'Could not find partition with label %s\n' "${partlabel}"
fi
info 'Current rootfs: %s (%s)\n' "${partlabel}" "${root}"
info 'New rootfs: %s (%s)\n' "${newpartlabel}" "${newroot}"
trap cleanup INT TERM QUIT EXIT
workdir=$(mktemp -d)
cd "${workdir}"
fetch_update "${source_url}" || die 'Failed to fetch update source'
extract_update || die 'Failed to extact update source'
./install "${newroot}" || die 'Error installing system update'
printf 'Do you want to reboot now? [y/N] '
read confirm
case "${confirm}" in
[yY]|[yY][eE][sS])
systemctl reboot
;;
*)
info 'A reboot is required to complete the update'
;;
esac

View File

@ -0,0 +1 @@
../cypress/cyfmac43455-sdio.bin.xz

View File

@ -0,0 +1 @@
brcmfmac43455-sdio.raspberrypi,4-model-b.txt.xz

View File

@ -0,0 +1,15 @@
disable ldconfig.service
disable systemd-userdbd.service
disable systemd-userdbd.socket
enable systemd-networkd-wait-online.service
enable systemd-networkd.service
enable systemd-networkd.socket
#enable systemd-time-wait-sync.service
disable getty@.service
enable sshd.socket
enable ssh-keygen.service

View File

@ -0,0 +1,11 @@
[Unit]
Description=Initialize persistent data storage
DefaultDependencies=no
Before=local-fs-pre.target
[Service]
Type=oneshot
ExecStart=/usr/libexec/init-storage
StandardInput=null
StandardOutput=journal
StandardError=journal

View File

@ -0,0 +1,9 @@
[Unit]
Description=Generate SSH host keys
[Service]
Type=oneshot
ExecStart=/usr/bin/ssh-keygen -A
[Install]
WantedBy=sshd@.service

View File

@ -0,0 +1,2 @@
[Unit]
After=ssh-keygen.service

View File

@ -0,0 +1 @@
../init-storage.service

View File

@ -0,0 +1,57 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
cleanup() {
if [ -n "${tmpdir}" ] && [ "${tmpdir}" != / ]; then
if mountpoint -q "${tmpdir}"; then
umount "${tmpdir}"
fi
rm -rf "${tmpdir}"
unset tmpdir
fi
}
copy_var() {
dev="$1"
echo 'Copying /var contents to data volume'
mount -o subvol=var "${dev}" "${tmpdir}"
cp -auv /var/. "${tmpdir}"
umount "${tmpdir}"
}
format_dev() {
dev="$1"
printf 'Creating BTRFS filesystem on %s\n' "${dev}"
mkfs.btrfs "${dev}" || exit
mount "${dev}" "${tmpdir}" || exit
btrfs subvolume create "${tmpdir}"/etc || exit
mkdir -p "${tmpdir}"/etc/.work "${tmpdir}"/etc/rw || exit
btrfs subvolume create "${tmpdir}"/var || exit
btrfs subvolume create "${tmpdir}"/var/log || exit
umount "${dev}" || exit
}
has_fs() {
dev="$1"
fstype=$(blkid -o value -s TYPE "${dev}")
[ -n "${fstype}" ]
}
datapart=$(findfs PARTLABEL=dch-data)
if [ -b "${datapart}" ]; then
printf 'Found data partition: %s\n' "${datapart}"
else
echo 'Could not identify data partition' >&2
exit 1
fi
trap cleanup INT TERM QUIT EXIT
tmpdir=$(mktemp -d -p /run storinit.XXXXXX)
if ! has_fs "${datapart}"; then
format_dev "${datapart}"
fi
copy_var "${datapart}"

View File

@ -0,0 +1,4 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
exec wget -q -O - https://sshkeys.pyrocufflink.blue/"$1"/"$2".pub

View File

@ -0,0 +1,14 @@
diff -ruN a/grub-2.06-r5.ebuild b/grub-2.06-r5.ebuild
--- a/grub-2.06-r5.ebuild 2023-02-07 10:43:00.106060206 -0600
+++ b/grub-2.06-r5.ebuild 2023-02-07 10:43:21.884298259 -0600
@@ -128,10 +128,6 @@
ppc64? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
"
RDEPEND="${DEPEND}
- kernel_linux? (
- grub_platforms_efi-32? ( sys-boot/efibootmgr )
- grub_platforms_efi-64? ( sys-boot/efibootmgr )
- )
!sys-boot/grub:0
nls? ( sys-devel/gettext )
"

View File

@ -0,0 +1,54 @@
From 85fb54b621c1ca79f1ec8634b0597a038338e51d Mon Sep 17 00:00:00 2001
Message-Id: <85fb54b621c1ca79f1ec8634b0597a038338e51d.1668448114.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 14 Apr 2022 12:15:26 +0200
Subject: [PATCH] drivers: bcm283x: don't explicitly disable init
It seems that the reason why init doesn't succeed is the lack of clock
support in U-Boot. Setting the default clock of 48MHz for the PL011
UARTs makes reinitialization work consistently.
Note that for the first UART the "skip-init" is anyways set in the
device tree. This will only affect probing of UARTs not enabled by
firmware.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
drivers/serial/serial_bcm283x_pl011.c | 6 ------
include/configs/rpi.h | 3 +++
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/serial/serial_bcm283x_pl011.c b/drivers/serial/serial_bcm283x_pl011.c
index 7d172cdac0..fcba07f1c5 100644
--- a/drivers/serial/serial_bcm283x_pl011.c
+++ b/drivers/serial/serial_bcm283x_pl011.c
@@ -51,12 +51,6 @@ static int bcm283x_pl011_serial_probe(struct udevice *dev)
if (ret)
return ret;
- /*
- * TODO: Reinitialization doesn't always work for now, just skip
- * init always - we know we're already initialized
- */
- plat->skip_init = true;
-
return pl01x_serial_probe(dev);
}
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 7257659932..7fdf2a891d 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -33,6 +33,9 @@
*/
#define CONFIG_SYS_SDRAM_SIZE SZ_128M
+/* Define PL011 default clock */
+#define CONFIG_PL011_CLOCK 48000000
+
/* Devices */
/* LCD */
--
2.38.1

View File

@ -0,0 +1,83 @@
From 135d886b4e5077c8fa96a5449a70d81ae9c1c3d0 Mon Sep 17 00:00:00 2001
Message-Id: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Pascal Vizeli <pvizeli@syshack.ch>
Date: Tue, 10 Dec 2019 09:48:46 +0000
Subject: [PATCH] rpi: Use CONFIG_OF_BOARD instead of CONFIG_EMBED
Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
---
configs/rpi_0_w_defconfig | 2 +-
configs/rpi_2_defconfig | 2 +-
configs/rpi_3_32b_defconfig | 2 +-
configs/rpi_3_defconfig | 2 +-
configs/rpi_defconfig | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/configs/rpi_0_w_defconfig b/configs/rpi_0_w_defconfig
index baa8c37810..f20aa164e5 100644
--- a/configs/rpi_0_w_defconfig
+++ b/configs/rpi_0_w_defconfig
@@ -23,7 +23,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/rpi_2_defconfig b/configs/rpi_2_defconfig
index baae6d4871..60987ad91a 100644
--- a/configs/rpi_2_defconfig
+++ b/configs/rpi_2_defconfig
@@ -24,7 +24,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/rpi_3_32b_defconfig b/configs/rpi_3_32b_defconfig
index f51f3de596..e6de8669d0 100644
--- a/configs/rpi_3_32b_defconfig
+++ b/configs/rpi_3_32b_defconfig
@@ -23,7 +23,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/rpi_3_defconfig b/configs/rpi_3_defconfig
index bc1a318db4..70f4f8ed70 100644
--- a/configs/rpi_3_defconfig
+++ b/configs/rpi_3_defconfig
@@ -22,7 +22,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
diff --git a/configs/rpi_defconfig b/configs/rpi_defconfig
index 1d356b4b2e..6f345c790b 100644
--- a/configs/rpi_defconfig
+++ b/configs/rpi_defconfig
@@ -23,7 +23,7 @@ CONFIG_CMD_GPIO=y
CONFIG_CMD_MMC=y
CONFIG_CMD_USB=y
CONFIG_CMD_FS_UUID=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
CONFIG_ENV_FAT_DEVICE_AND_PART="0:1"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
--
2.38.1

View File

@ -0,0 +1,68 @@
From 921f4b6d8cb3b997dd5c54fd436bb8223046421e Mon Sep 17 00:00:00 2001
Message-Id: <921f4b6d8cb3b997dd5c54fd436bb8223046421e.1668448114.git.stefan@agner.ch>
In-Reply-To: <85fb54b621c1ca79f1ec8634b0597a038338e51d.1668448114.git.stefan@agner.ch>
References: <85fb54b621c1ca79f1ec8634b0597a038338e51d.1668448114.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 14 Apr 2022 12:18:41 +0200
Subject: [PATCH] drivers: bcm283x: allow to spawn any PL011 UART
The current code checks pinmux for the first PL011 only. Raspberry Pi 4
has multiple PL011 UARTs. This code prevents probing of other UARTs in
case the first PL011 UART is not active.
Furthermore, U-Boot supports pinmuxing, hence the pins should be muxed
at this point anyway. Drop the check entirly.
This allows to use other UARTs as stdout paths (e.g. stdout-path =
"serial5:115200n8").
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
drivers/serial/serial_bcm283x_pl011.c | 27 ---------------------------
1 file changed, 27 deletions(-)
diff --git a/drivers/serial/serial_bcm283x_pl011.c b/drivers/serial/serial_bcm283x_pl011.c
index fcba07f1c5..98628e1ca4 100644
--- a/drivers/serial/serial_bcm283x_pl011.c
+++ b/drivers/serial/serial_bcm283x_pl011.c
@@ -11,37 +11,10 @@
#include <serial.h>
#include "serial_pl01x_internal.h"
-/*
- * Check if this serial device is muxed
- *
- * The serial device will only work properly if it has been muxed to the serial
- * pins by firmware. Check whether that happened here.
- *
- * Return: true if serial device is muxed, false if not
- */
-static bool bcm283x_is_serial_muxed(void)
-{
- int serial_gpio = 15;
- struct udevice *dev;
-
- if (uclass_first_device_err(UCLASS_PINCTRL, &dev))
- return false;
-
- if (pinctrl_get_gpio_mux(dev, 0, serial_gpio) != BCM2835_GPIO_ALT0)
- return false;
-
- return true;
-}
-
static int bcm283x_pl011_serial_probe(struct udevice *dev)
{
- struct pl01x_serial_plat *plat = dev_get_plat(dev);
int ret;
- /* Don't spawn the device if it's not muxed */
- if (!bcm283x_is_serial_muxed())
- return -ENODEV;
-
/*
* Read the ofdata here rather than in an of_to_plat() method
* since we need the soc simple-bus to be probed so that the 'ranges'
--
2.38.1

View File

@ -0,0 +1,44 @@
From 191b5f4e0408e40f35379fdaab6b37a7ad93e298 Mon Sep 17 00:00:00 2001
Message-Id: <191b5f4e0408e40f35379fdaab6b37a7ad93e298.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Tue, 29 Dec 2020 23:34:52 +0100
Subject: [PATCH] rpi: add NVMe to boot order
The Compute Module 4 I/O Board can support a NVMe. Add NVMe to the boot
order.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
include/configs/rpi.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index cd8fe8b518..7257659932 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -131,6 +131,12 @@
#define BOOT_TARGET_MMC(func)
#endif
+#if CONFIG_IS_ENABLED(CMD_NVME)
+ #define BOOT_TARGET_NVME(func) func(NVME, nvme, 0)
+#else
+ #define BOOT_TARGET_NVME(func)
+#endif
+
#if CONFIG_IS_ENABLED(CMD_USB)
#define BOOT_TARGET_USB(func) func(USB, usb, 0)
#else
@@ -151,6 +157,7 @@
#define BOOT_TARGET_DEVICES(func) \
BOOT_TARGET_MMC(func) \
+ BOOT_TARGET_NVME(func) \
BOOT_TARGET_USB(func) \
BOOT_TARGET_PXE(func) \
BOOT_TARGET_DHCP(func)
--
2.38.1

View File

@ -0,0 +1,43 @@
From 644bd3743aa8771ef7ecb7b7239308d6da2a5b35 Mon Sep 17 00:00:00 2001
Message-Id: <644bd3743aa8771ef7ecb7b7239308d6da2a5b35.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 23 Sep 2021 23:43:31 +0200
Subject: [PATCH] Revert "nvme: Correct the prps per page calculation method"
This reverts commit 859b33c948945f7904f60a2c12a3792d356d51ad.
If there is more than one PRP List the last entry is a pointer to
the next list. From the NVM Express specification:
"The last entry within a memory page, as indicated by the memory page
size in the CC.MPS field, shall be a PRP List pointer if there is more
than a single memory page of data to be transferred."
For the purpose of calculating the number of pages required for PRP
lists we should always assume that the last entry is required for
the next PRP list.
Signed-off-by: Stefan Agner <stefan@agner.ch>
Cc: Wesley Sheng <wesleyshenggit@sina.com>
---
drivers/nvme/nvme.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 6d0d3f3ca2..73db80a294 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -52,7 +52,7 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
u64 *prp_pool;
int length = total_len;
int i, nprps;
- u32 prps_per_page = page_size >> 3;
+ u32 prps_per_page = (page_size >> 3) - 1;
u32 num_pages;
length -= (page_size - offset);
--
2.38.1

View File

@ -0,0 +1,33 @@
From de29ca70117fb2bfafa8b5699b34e9e94560b785 Mon Sep 17 00:00:00 2001
Message-Id: <de29ca70117fb2bfafa8b5699b34e9e94560b785.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 7 Oct 2021 12:02:39 +0200
Subject: [PATCH] usb: xhci-brcm: Make driver compatible with downstream device
tree
The downstream device tree uses just "generic-xhci" as compatible
string. Use this string to make U-Boot work with the downstream Kernel.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
drivers/usb/host/xhci-brcm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-brcm.c b/drivers/usb/host/xhci-brcm.c
index fe17924028..0c6938187b 100644
--- a/drivers/usb/host/xhci-brcm.c
+++ b/drivers/usb/host/xhci-brcm.c
@@ -82,7 +82,7 @@ static int xhci_brcm_deregister(struct udevice *dev)
}
static const struct udevice_id xhci_brcm_ids[] = {
- { .compatible = "brcm,generic-xhci" },
+ { .compatible = "generic-xhci" },
{ }
};
--
2.38.1

View File

@ -0,0 +1,49 @@
From ab2790f8ff78790ea8a9cb0b05cafc55648ebbc4 Mon Sep 17 00:00:00 2001
Message-Id: <ab2790f8ff78790ea8a9cb0b05cafc55648ebbc4.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 23 Sep 2021 23:52:44 +0200
Subject: [PATCH] nvme: improve readability of nvme_setup_prps()
Improve readability by introducing consts, reuse consts where
appropriate and adding variables with discriptive name.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
drivers/nvme/nvme.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 73db80a294..751abc3cd5 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -47,12 +47,12 @@ static int nvme_wait_csts(struct nvme_dev *dev, u32 mask, u32 val)
static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
int total_len, u64 dma_addr)
{
- u32 page_size = dev->page_size;
+ const u32 page_size = dev->page_size;
+ const u32 prps_per_page = (page_size >> 3) - 1;
int offset = dma_addr & (page_size - 1);
u64 *prp_pool;
int length = total_len;
int i, nprps;
- u32 prps_per_page = (page_size >> 3) - 1;
u32 num_pages;
length -= (page_size - offset);
@@ -91,8 +91,8 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
i = 0;
while (nprps) {
if ((i == (prps_per_page - 1)) && nprps > 1) {
- *(prp_pool + i) = cpu_to_le64((ulong)prp_pool +
- page_size);
+ u64 next_prp_list = (u64)prp_pool + page_size;
+ *(prp_pool + i) = cpu_to_le64(next_prp_list);
i = 0;
prp_pool += page_size;
}
--
2.38.1

View File

@ -0,0 +1,264 @@
From 2b508d92673738d837576301866dc234d8b008c4 Mon Sep 17 00:00:00 2001
Message-Id: <2b508d92673738d837576301866dc234d8b008c4.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Thu, 23 Sep 2021 23:58:35 +0200
Subject: [PATCH] nvme: Use pointer for CPU addressed buffers
Pass buffers which use CPU addressing as void pointers. This aligns with
DMA APIs which use void pointers as argument. It will avoid unnecessary
type casts when adding support bus address translations.
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
drivers/nvme/nvme.c | 50 ++++++++++++++++++++--------------------
drivers/nvme/nvme_show.c | 4 ++--
include/nvme.h | 12 +++++-----
3 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 751abc3cd5..352c94ea91 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -45,11 +45,11 @@ static int nvme_wait_csts(struct nvme_dev *dev, u32 mask, u32 val)
}
static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
- int total_len, u64 dma_addr)
+ int total_len, void *buffer)
{
const u32 page_size = dev->page_size;
const u32 prps_per_page = (page_size >> 3) - 1;
- int offset = dma_addr & (page_size - 1);
+ int offset = (uintptr_t)buffer & (page_size - 1);
u64 *prp_pool;
int length = total_len;
int i, nprps;
@@ -63,10 +63,10 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
}
if (length)
- dma_addr += (page_size - offset);
+ buffer += (page_size - offset);
if (length <= page_size) {
- *prp2 = dma_addr;
+ *prp2 = (u64)buffer;
return 0;
}
@@ -96,11 +96,11 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
i = 0;
prp_pool += page_size;
}
- *(prp_pool + i++) = cpu_to_le64(dma_addr);
- dma_addr += page_size;
+ *(prp_pool + i++) = cpu_to_le64((u64)buffer);
+ buffer += page_size;
nprps--;
}
- *prp2 = (ulong)dev->prp_pool;
+ *prp2 = (u64)dev->prp_pool;
flush_dcache_range((ulong)dev->prp_pool, (ulong)dev->prp_pool +
num_pages * page_size);
@@ -447,42 +447,42 @@ static int nvme_alloc_sq(struct nvme_dev *dev, u16 qid,
}
int nvme_identify(struct nvme_dev *dev, unsigned nsid,
- unsigned cns, dma_addr_t dma_addr)
+ unsigned int cns, void *buffer)
{
struct nvme_command c;
u32 page_size = dev->page_size;
- int offset = dma_addr & (page_size - 1);
+ int offset = (uintptr_t)buffer & (page_size - 1);
int length = sizeof(struct nvme_id_ctrl);
int ret;
memset(&c, 0, sizeof(c));
c.identify.opcode = nvme_admin_identify;
c.identify.nsid = cpu_to_le32(nsid);
- c.identify.prp1 = cpu_to_le64(dma_addr);
+ c.identify.prp1 = cpu_to_le64((u64)buffer);
length -= (page_size - offset);
if (length <= 0) {
c.identify.prp2 = 0;
} else {
- dma_addr += (page_size - offset);
- c.identify.prp2 = cpu_to_le64(dma_addr);
+ buffer += (page_size - offset);
+ c.identify.prp2 = cpu_to_le64((u64)buffer);
}
c.identify.cns = cpu_to_le32(cns);
- invalidate_dcache_range(dma_addr,
- dma_addr + sizeof(struct nvme_id_ctrl));
+ invalidate_dcache_range((uintptr_t)buffer,
+ (uintptr_t)buffer + sizeof(struct nvme_id_ctrl));
ret = nvme_submit_admin_cmd(dev, &c, NULL);
if (!ret)
- invalidate_dcache_range(dma_addr,
- dma_addr + sizeof(struct nvme_id_ctrl));
+ invalidate_dcache_range((uintptr_t)buffer,
+ (uintptr_t)buffer + sizeof(struct nvme_id_ctrl));
return ret;
}
int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
- dma_addr_t dma_addr, u32 *result)
+ void *buffer, u32 *result)
{
struct nvme_command c;
int ret;
@@ -490,7 +490,7 @@ int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
memset(&c, 0, sizeof(c));
c.features.opcode = nvme_admin_get_features;
c.features.nsid = cpu_to_le32(nsid);
- c.features.prp1 = cpu_to_le64(dma_addr);
+ c.features.prp1 = cpu_to_le64((u64)buffer);
c.features.fid = cpu_to_le32(fid);
ret = nvme_submit_admin_cmd(dev, &c, result);
@@ -510,13 +510,13 @@ int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
}
int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,
- dma_addr_t dma_addr, u32 *result)
+ void *buffer, u32 *result)
{
struct nvme_command c;
memset(&c, 0, sizeof(c));
c.features.opcode = nvme_admin_set_features;
- c.features.prp1 = cpu_to_le64(dma_addr);
+ c.features.prp1 = cpu_to_le64((u64)buffer);
c.features.fid = cpu_to_le32(fid);
c.features.dword11 = cpu_to_le32(dword11);
@@ -567,7 +567,7 @@ static int nvme_set_queue_count(struct nvme_dev *dev, int count)
u32 q_count = (count - 1) | ((count - 1) << 16);
status = nvme_set_features(dev, NVME_FEAT_NUM_QUEUES,
- q_count, 0, &result);
+ q_count, NULL, &result);
if (status < 0)
return status;
@@ -619,7 +619,7 @@ static int nvme_get_info_from_identify(struct nvme_dev *dev)
if (!ctrl)
return -ENOMEM;
- ret = nvme_identify(dev, 0, 1, (dma_addr_t)(long)ctrl);
+ ret = nvme_identify(dev, 0, 1, ctrl);
if (ret) {
free(ctrl);
return -EIO;
@@ -704,7 +704,7 @@ static int nvme_blk_probe(struct udevice *udev)
ns->dev = ndev;
/* extract the namespace id from the block device name */
ns->ns_id = trailing_strtol(udev->name);
- if (nvme_identify(ndev, ns->ns_id, 0, (dma_addr_t)(long)id)) {
+ if (nvme_identify(ndev, ns->ns_id, 0, id)) {
free(id);
return -EIO;
}
@@ -738,7 +738,7 @@ static ulong nvme_blk_rw(struct udevice *udev, lbaint_t blknr,
u64 prp2;
u64 total_len = blkcnt << desc->log2blksz;
u64 temp_len = total_len;
- uintptr_t temp_buffer = (uintptr_t)buffer;
+ void *temp_buffer = buffer;
u64 slba = blknr;
u16 lbas = 1 << (dev->max_transfer_shift - ns->lba_shift);
@@ -872,7 +872,7 @@ int nvme_init(struct udevice *udev)
char name[20];
memset(id, 0, sizeof(*id));
- if (nvme_identify(ndev, i, 0, (dma_addr_t)(long)id)) {
+ if (nvme_identify(ndev, i, 0, id)) {
ret = -EIO;
goto free_id;
}
diff --git a/drivers/nvme/nvme_show.c b/drivers/nvme/nvme_show.c
index 72cbac82bc..ac9b5cc9bd 100644
--- a/drivers/nvme/nvme_show.c
+++ b/drivers/nvme/nvme_show.c
@@ -114,7 +114,7 @@ int nvme_print_info(struct udevice *udev)
if (!ctrl)
return -ENOMEM;
- if (nvme_identify(dev, 0, 1, (dma_addr_t)(long)ctrl)) {
+ if (nvme_identify(dev, 0, 1, ctrl)) {
ret = -EIO;
goto free_ctrl;
}
@@ -129,7 +129,7 @@ int nvme_print_info(struct udevice *udev)
goto free_ctrl;
}
- if (nvme_identify(dev, ns->ns_id, 0, (dma_addr_t)(long)id)) {
+ if (nvme_identify(dev, ns->ns_id, 0, id)) {
ret = -EIO;
goto free_id;
}
diff --git a/include/nvme.h b/include/nvme.h
index 2cdf8ce320..8ff823cd81 100644
--- a/include/nvme.h
+++ b/include/nvme.h
@@ -18,12 +18,12 @@ struct nvme_dev;
* @dev: NVMe controller device
* @nsid: 0 for controller, namespace id for namespace to identify
* @cns: 1 for controller, 0 for namespace
- * @dma_addr: dma buffer address to store the identify result
+ * @buffer: dma buffer address to store the identify result
* @return: 0 on success, -ETIMEDOUT on command execution timeout,
* -EIO on command execution fails
*/
int nvme_identify(struct nvme_dev *dev, unsigned nsid,
- unsigned cns, dma_addr_t dma_addr);
+ unsigned int cns, void *buffer);
/**
* nvme_get_features - retrieve the attributes of the feature specified
@@ -33,13 +33,13 @@ int nvme_identify(struct nvme_dev *dev, unsigned nsid,
* @dev: NVMe controller device
* @fid: feature id to provide data
* @nsid: namespace id the command applies to
- * @dma_addr: data structure used as part of the specified feature
+ * @buffer: data structure used as part of the specified feature
* @result: command-specific result in the completion queue entry
* @return: 0 on success, -ETIMEDOUT on command execution timeout,
* -EIO on command execution fails
*/
int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
- dma_addr_t dma_addr, u32 *result);
+ void *buffer, u32 *result);
/**
* nvme_set_features - specify the attributes of the feature indicated
@@ -49,13 +49,13 @@ int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
* @dev: NVMe controller device
* @fid: feature id to provide data
* @dword11: command-specific input parameter
- * @dma_addr: data structure used as part of the specified feature
+ * @buffer: data structure used as part of the specified feature
* @result: command-specific result in the completion queue entry
* @return: 0 on success, -ETIMEDOUT on command execution timeout,
* -EIO on command execution fails
*/
int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,
- dma_addr_t dma_addr, u32 *result);
+ void *buffer, u32 *result);
/**
* nvme_scan_namespace - scan all namespaces attached to NVMe controllers
--
2.38.1

View File

@ -0,0 +1,176 @@
From c70926d8b8ad11b8e489e92a8ca9ca93fb201595 Mon Sep 17 00:00:00 2001
Message-Id: <c70926d8b8ad11b8e489e92a8ca9ca93fb201595.1668448794.git.stefan@agner.ch>
In-Reply-To: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
References: <135d886b4e5077c8fa96a5449a70d81ae9c1c3d0.1668448794.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Fri, 24 Sep 2021 00:27:39 +0200
Subject: [PATCH] nvme: translate virtual addresses into the bus's address
space
So far we've been content with passing physical/CPU addresses when
configuring memory addresses into NVMe controllers, but not all
platforms have buses with transparent mappings. Specifically the
Raspberry Pi 4 might introduce an offset to memory accesses incoming
from its PCIe port.
Introduce nvme_virt_to_bus() and nvme_bus_to_virt() to cater with these
limitations, and make sure we don't break non DM users.
For devices where PCIe's view of host memory doesn't match the memory
as seen by the CPU.
A similar change has been introduced for XHCI controller with
commit 1a474559d90a ("xhci: translate virtual addresses into the bus's
address space").
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
drivers/nvme/nvme.c | 31 +++++++++++++++++--------------
drivers/nvme/nvme.h | 8 ++++++++
2 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
index 352c94ea91..fdfc49677b 100644
--- a/drivers/nvme/nvme.c
+++ b/drivers/nvme/nvme.c
@@ -66,7 +66,7 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
buffer += (page_size - offset);
if (length <= page_size) {
- *prp2 = (u64)buffer;
+ *prp2 = nvme_virt_to_bus(dev, buffer);
return 0;
}
@@ -91,16 +91,16 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2,
i = 0;
while (nprps) {
if ((i == (prps_per_page - 1)) && nprps > 1) {
- u64 next_prp_list = (u64)prp_pool + page_size;
- *(prp_pool + i) = cpu_to_le64(next_prp_list);
+ u64 next = nvme_virt_to_bus(dev, prp_pool + page_size);
+ *(prp_pool + i) = cpu_to_le64(next);
i = 0;
prp_pool += page_size;
}
- *(prp_pool + i++) = cpu_to_le64((u64)buffer);
+ *(prp_pool + i++) = cpu_to_le64(nvme_virt_to_bus(dev, buffer));
buffer += page_size;
nprps--;
}
- *prp2 = (u64)dev->prp_pool;
+ *prp2 = nvme_virt_to_bus(dev, dev->prp_pool);
flush_dcache_range((ulong)dev->prp_pool, (ulong)dev->prp_pool +
num_pages * page_size);
@@ -353,6 +353,7 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev)
int result;
u32 aqa;
u64 cap = dev->cap;
+ u64 dma_addr;
struct nvme_queue *nvmeq;
/* most architectures use 4KB as the page size */
unsigned page_shift = 12;
@@ -393,8 +394,10 @@ static int nvme_configure_admin_queue(struct nvme_dev *dev)
dev->ctrl_config |= NVME_CC_IOSQES | NVME_CC_IOCQES;
writel(aqa, &dev->bar->aqa);
- nvme_writeq((ulong)nvmeq->sq_cmds, &dev->bar->asq);
- nvme_writeq((ulong)nvmeq->cqes, &dev->bar->acq);
+ dma_addr = nvme_virt_to_bus(dev, nvmeq->sq_cmds);
+ nvme_writeq(dma_addr, &dev->bar->asq);
+ dma_addr = nvme_virt_to_bus(dev, nvmeq->cqes);
+ nvme_writeq(dma_addr, &dev->bar->acq);
result = nvme_enable_ctrl(dev);
if (result)
@@ -420,7 +423,7 @@ static int nvme_alloc_cq(struct nvme_dev *dev, u16 qid,
memset(&c, 0, sizeof(c));
c.create_cq.opcode = nvme_admin_create_cq;
- c.create_cq.prp1 = cpu_to_le64((ulong)nvmeq->cqes);
+ c.create_cq.prp1 = cpu_to_le64(nvme_virt_to_bus(dev, nvmeq->cqes));
c.create_cq.cqid = cpu_to_le16(qid);
c.create_cq.qsize = cpu_to_le16(nvmeq->q_depth - 1);
c.create_cq.cq_flags = cpu_to_le16(flags);
@@ -437,7 +440,7 @@ static int nvme_alloc_sq(struct nvme_dev *dev, u16 qid,
memset(&c, 0, sizeof(c));
c.create_sq.opcode = nvme_admin_create_sq;
- c.create_sq.prp1 = cpu_to_le64((ulong)nvmeq->sq_cmds);
+ c.create_sq.prp1 = cpu_to_le64(nvme_virt_to_bus(dev, nvmeq->sq_cmds));
c.create_sq.sqid = cpu_to_le16(qid);
c.create_sq.qsize = cpu_to_le16(nvmeq->q_depth - 1);
c.create_sq.sq_flags = cpu_to_le16(flags);
@@ -458,14 +461,14 @@ int nvme_identify(struct nvme_dev *dev, unsigned nsid,
memset(&c, 0, sizeof(c));
c.identify.opcode = nvme_admin_identify;
c.identify.nsid = cpu_to_le32(nsid);
- c.identify.prp1 = cpu_to_le64((u64)buffer);
+ c.identify.prp1 = cpu_to_le64(nvme_virt_to_bus(dev, buffer));
length -= (page_size - offset);
if (length <= 0) {
c.identify.prp2 = 0;
} else {
buffer += (page_size - offset);
- c.identify.prp2 = cpu_to_le64((u64)buffer);
+ c.identify.prp2 = cpu_to_le64(nvme_virt_to_bus(dev, buffer));
}
c.identify.cns = cpu_to_le32(cns);
@@ -490,7 +493,7 @@ int nvme_get_features(struct nvme_dev *dev, unsigned fid, unsigned nsid,
memset(&c, 0, sizeof(c));
c.features.opcode = nvme_admin_get_features;
c.features.nsid = cpu_to_le32(nsid);
- c.features.prp1 = cpu_to_le64((u64)buffer);
+ c.features.prp1 = cpu_to_le64(nvme_virt_to_bus(dev, buffer));
c.features.fid = cpu_to_le32(fid);
ret = nvme_submit_admin_cmd(dev, &c, result);
@@ -516,7 +519,7 @@ int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,
memset(&c, 0, sizeof(c));
c.features.opcode = nvme_admin_set_features;
- c.features.prp1 = cpu_to_le64((u64)buffer);
+ c.features.prp1 = cpu_to_le64(nvme_virt_to_bus(dev, buffer));
c.features.fid = cpu_to_le32(fid);
c.features.dword11 = cpu_to_le32(dword11);
@@ -771,7 +774,7 @@ static ulong nvme_blk_rw(struct udevice *udev, lbaint_t blknr,
c.rw.slba = cpu_to_le64(slba);
slba += lbas;
c.rw.length = cpu_to_le16(lbas - 1);
- c.rw.prp1 = cpu_to_le64(temp_buffer);
+ c.rw.prp1 = cpu_to_le64(nvme_virt_to_bus(dev, temp_buffer));
c.rw.prp2 = cpu_to_le64(prp2);
status = nvme_submit_sync_cmd(dev->queues[NVME_IO_Q],
&c, NULL, IO_TIMEOUT);
diff --git a/drivers/nvme/nvme.h b/drivers/nvme/nvme.h
index bc1d612dde..f52103c009 100644
--- a/drivers/nvme/nvme.h
+++ b/drivers/nvme/nvme.h
@@ -7,8 +7,11 @@
#ifndef __DRIVER_NVME_H__
#define __DRIVER_NVME_H__
+#include <phys2bus.h>
#include <asm/io.h>
+#define nvme_to_dev(_dev) _dev->udev
+
struct nvme_id_power_state {
__le16 max_power; /* centiwatts */
__u8 rsvd2;
@@ -705,4 +708,9 @@ int nvme_init(struct udevice *udev);
*/
int nvme_shutdown(struct udevice *udev);
+static inline dma_addr_t nvme_virt_to_bus(struct nvme_dev *dev, void *addr)
+{
+ return dev_phys_to_bus(nvme_to_dev(dev)->parent, virt_to_phys(addr));
+}
+
#endif /* __DRIVER_NVME_H__ */
--
2.38.1

26
podman-build.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
cid=$(podman run \
--tmpfs /var/tmp \
--tmpfs /usr/${target}/tmp \
-v portage:/var/db/repos/gentoo \
-v packages:/var/cache/binpkgs \
-v distfiles:/var/cache/distfiles \
-v packages:/usr/${target}/var/cache/binpkgs \
-v ${PWD}:/tmp/build:rw,z \
-w /tmp/build \
-d \
-e FEATURES='-ipc-sandbox -network-sandbox -pid-sandbox' \
cross-${target} \
python -c 'from signal import *;signal(SIGTERM, lambda x, y: None);pause()'
)
podman exec -it ${cid} ./build-all.sh "${target}"
podman stop ${cid}
podman rm ${cid}

1
portage/env/nobuildpkg vendored Normal file
View File

@ -0,0 +1 @@
FEATURES=-buildpkg

View File

@ -0,0 +1 @@
ACCEPT_KEYWORDS="${ARCH} ~${ARCH}"

View File

@ -0,0 +1,2 @@
FEATURES="${FEATURES} binpkg-multi-instance buildpkg"
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --usepkg --binpkg-respect-use=y"

View File

@ -0,0 +1 @@
USE='-man -doc minimal pam zstd'

View File

@ -0,0 +1,2 @@
EMERGE_DEFAULT_OPTS="${EMERGE_DEFAULT_OPTS} --quiet-build=y"
FEATURES="${FEATURES} -news"

View File

@ -0,0 +1 @@
sys-kernel/linux-formware nobinpkg

View File

@ -0,0 +1,2 @@
sys-boot/raspberrypi-firmware raspberrypi-videocore-bin
sys-kernel/linux-firmware linux-fw-redistributable

View File

@ -0,0 +1 @@
sys-apps/busybox savedconfig

View File

@ -0,0 +1 @@
sys-kernel/linux-firmware compress savedconfig

1
portage/package.use/grub Normal file
View File

@ -0,0 +1 @@
sys-boot/grub -* GRUB_PLATFORMS: -* efi-64

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
brcm/brcmfmac43455-sdio.AW-CM256SM.txt
brcm/brcmfmac43455-sdio.MINIX-NEO Z83-4.txt
brcm/brcmfmac43455-sdio.Raspberry Pi Foundation-Raspberry Pi 4 Model B.txt
brcm/brcmfmac43455-sdio.Raspberry Pi Foundation-Raspberry Pi Compute Module 4.txt
brcm/brcmfmac43455-sdio.acepc-t8.txt
brcm/brcmfmac43455-sdio.beagle,am5729-beagleboneai.txt
brcm/brcmfmac43455-sdio.bin
brcm/brcmfmac43455-sdio.clm_blob
brcm/brcmfmac43455-sdio.raspberrypi,3-model-a-plus.txt
brcm/brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt
brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt
cypress/cyfmac43455-sdio.bin
cypress/cyfmac43455-sdio.clm_blob

13
post-build.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
cp -auv \
/usr/${target}/boot/*.bin \
/usr/${target}/boot/*.dat \
/usr/${target}/boot/*.elf \
config.txt \
output/efi-part/

38
prepare.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
# Ensure we have a Portage repo
if [ ! -f /var/db/repos/gentoo/metadata/timestamp ]; then
emerge-webrsync
fi
# Migrate to the merged-usr layout
mkdir -p /usr/${target}/bin
emerge -bknv --quiet-build=y merge-usr
merge-usr --root=/usr/${target}
if [ ! -d /usr/${target}/etc/portage/make.conf ]; then
mv /usr/${target}/etc/portage/make.conf \
/usr/${target}/etc/portage/make.conf.orig
mkdir /usr/${target}/etc/portage/make.conf
mv /usr/${target}/etc/portage/make.conf.orig \
/usr/${target}/etc/portage/make.conf/10-base.conf
fi
if [ ! -d /etc/portage/make.conf ]; then
mv /etc/portage/make.conf \
/etc/portage/make.conf.orig
mkdir /etc/portage/make.conf
mv /etc/portage/make.conf.orig \
/etc/portage/make.conf/10-base.conf
fi
# Set the Portage profile
ln -snf \
/var/db/repos/gentoo/profiles/${profile} \
/usr/${target}/etc/portage/make.profile

29
setup-local-repo.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
# vim: set sw=4 ts=4 sts=4 et :
set -e
. ./config
mkdir -p /var/db/repos/x-portage/profiles /var/db/repos/x-portage/metadata
echo x-portage > /var/db/repos/x-portage/profiles/repo_name
echo 'masters = gentoo' > /var/db/repos/x-portage/metadata/layout.conf
mkdir -p /usr/${target}/etc/portage/repos.conf
cat > /usr/${target}/etc/portage/repos.conf/x-portage.conf <<EOF
[x-portage]
location = /var/db/repos/x-portage
auto-sync = no
EOF
for patch in patches/ebuilds/*/*/*.patch; do
[ -f "${patch}" ] || continue
cp=${patch#patches/ebuilds/}
cp=${cp%/*.patch}
printf 'Applying patch %s for %s ...\n' "${patch##*/}" "${cp}"
mkdir -p /var/db/repos/x-portage/${cp}
cp -r /var/db/repos/gentoo/${cp}/. /var/db/repos/x-portage/${cp}
for f in /var/db/repos/x-portage/${cp}/*.ebuild; do
patch "${f}" "${patch}"
ebuild "${f}" digest
done
done

22
squashfs.exclude Normal file
View File

@ -0,0 +1,22 @@
*/*/*/*/.keep_*
*/*/*/.keep_*
*/*/.keep_*
*/.keep_*
bin/bb
etc/X11
etc/conf.d
etc/csh.env
etc/init.d
etc/portage
etc/runlevels
usr/lib*/*.a
usr/lib*/cmake
usr/lib*/pkgconfig
usr/lib/rpm
usr/share/doc
usr/share/info
usr/share/man
var/cache/edb
var/db/Makefile
var/db/pkg
var/lib/portage

1
u-boot Submodule

@ -0,0 +1 @@
Subproject commit 62e2ad1ceafbfdf2c44d3dc1b6efc81e768a96b9

37
u-boot.config Normal file
View File

@ -0,0 +1,37 @@
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_DISTRO_DEFAULTS=y
# CONFIG_EXPERT is not set
# CONFIG_DISPLAY_CPUINFO is not set
# CONFIG_DISPLAY_BOARDINFO is not set
CONFIG_BOOTDELAY=-2
# CONFIG_ISO_PARTITION is not set
CONFIG_EFI_PARTITION=y
CONFIG_FS_EXT4=y
CONFIG_FS_FAT=y
# CONFIG_ENV_IS_IN_FAT is not set
# CONFIG_ENV_IS_IN_EXT4 is not set
CONFIG_ENV_IS_NOWHERE=Y
# CONFIG_EFI_LOADER is not set
CONFIG_CMD_SETEXPR=y
CONFIG_CMD_FILEENV=y
CONFIG_CMD_SQUASHFS=y
CONFIG_LZO=y
# CONFIG_DOS_PARTITION is not set
CONFIG_USB_STORAGE=y
CONFIG_USB_FUNCTION_MASS_STORAGE=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_EHCI_GENERIC=y
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_XHCI_BRCM=y
CONFIG_NVME_PCI=y
CONFIG_CMD_NVME=y
CONFIG_NVME=y
CONFIG_CMD_USB_MASS_STORAGE=y
CONFIG_CMD_BOOTEFI=y
CONFIG_EFI_LOADER=y
CONFIG_LMB_MAX_REGIONS=16