shithub: riscv

Download patch

ref: 9eb192f586316361a78cf399b410716ee20ed132
parent: 80268af29eb1dfc1ca4fc528f70c5af17286dd2c
author: cinap_lenrek <[email protected]>
date: Sun Nov 7 12:51:12 EST 2021

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 = <GIC_SPI 126 IRQ_TYPE_LEVEL_HIGH>;
 clocks = <&clocks BCM2711_CLOCK_EMMC2>;
 status = "disabled";
 };
 };

--- a/sys/src/9/bcm/bootargs.c
+++ b/sys/src/9/bcm/bootargs.c
@@ -12,6 +12,7 @@
 static char *confval[MAXCONF];
 static int nconf;
 static char maxmem[256];
+static char emmc2bus[38];
 static char pciwin[38], pcidmawin[38];
 
 static int
@@ -111,6 +112,16 @@
 				len -= 3*4;
 			}
 			addconf("*maxmem", maxmem);
+		}
+		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;
 	}