From 9eb192f586316361a78cf399b410716ee20ed132 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 7 Nov 2021 17:51:12 +0000 Subject: [PATCH] bcm64: parse the emmc2bus/dma-ranges device-tree property and provide *emmc2bus kernel parameter /* * emmc2 has different DMA constraints based on SoC revisions. It was * moved into its own bus, so as for RPi4's firmware to update them. * The firmware will find whether the emmc2bus alias is defined, and if * so, it'll edit the dma-ranges property below accordingly. */ emmc2bus: emmc2bus { compatible = "simple-bus"; ranges = <0x0 0x7e000000 0x0 0xfe000000 0x01800000>; dma-ranges = <0x0 0xc0000000 0x0 0x00000000 0x40000000>; emmc2: mmc@7e340000 { compatible = "brcm,bcm2711-emmc2"; reg = <0x0 0x7e340000 0x100>; interrupts = ; clocks = <&clocks BCM2711_CLOCK_EMMC2>; status = "disabled"; }; }; --- sys/src/9/bcm/bootargs.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/src/9/bcm/bootargs.c b/sys/src/9/bcm/bootargs.c index 445e0baef..9b6c13a83 100644 --- a/sys/src/9/bcm/bootargs.c +++ b/sys/src/9/bcm/bootargs.c @@ -12,6 +12,7 @@ static char *confname[MAXCONF]; static char *confval[MAXCONF]; static int nconf; static char maxmem[256]; +static char emmc2bus[38]; static char pciwin[38], pcidmawin[38]; static int @@ -114,6 +115,16 @@ devtreeprop(char *path, char *key, void *val, int len) } return; } + if(strcmp(path, "/emmc2bus") == 0 && strcmp(key, "dma-ranges") == 0 && len == (2*4 + 2*4 + 1*4)){ + if(findconf("*emmc2bus") < 0){ + addr = (uvlong)beget4(p+0*4)<<32 | beget4(p+1*4); + addr -= (uvlong)beget4(p+2*4)<<32 | beget4(p+3*4); + size = beget4(p+4*4); + snprint(emmc2bus, sizeof(emmc2bus), "%#llux %#llux", addr, addr+size); + addconf("*emmc2bus", emmc2bus); + } + return; + } if(strncmp(path, "/scb/pcie@", 10) == 0 && len == (3*4 + 4*4)){ if((beget4(p) & 0x3000000) == 0x2000000){ size = (uvlong)beget4(p+5*4)<<32 | beget4(p+5*4+4);