Re: Support additional SD/MMC controller on Raspberry Pi 4

2020-04-20 Thread Stuart Henderson
On 2020/04/20 23:43, Mark Kettenis wrote:
> > bwfm(4) is working for me, but when in device tree mode (wherever the
> > uSD is routed) bse(4) is flaky - ethernet link doesn't come up at boot,
> > if I leave it for a little while with a ping running to the bse from
> > another machine I get the occasional packet through but that's all.
> > Do you see that too?
> 
> I don't see that, but I suspect this is because the device tree has
> phy-mode set to "rgmii" instead of "rgmii-rxid".
> 
> A workaround is to take the bcm2711-rpi-4-b.dtb, fixup4.dat and
> start4.elf files from
> 
>   https://github.com/raspberrypi/firmware/tree/next/boot
> 
> and put them on the MS-DOS partition of your uSD card.

Thanks, confirmed it's working for me with the newer files.



Re: Support additional SD/MMC controller on Raspberry Pi 4

2020-04-20 Thread Mark Kettenis
> Date: Mon, 20 Apr 2020 22:18:06 +0100
> From: Stuart Henderson 
> 
> On 2020/04/19 21:44, Mark Kettenis wrote:
> > The Raspberry Pi 4 has an additional SD/MMC controller.  This
> > controller is almost completely standard and just needs one tiny
> > quirk.  So the diff is really simple.
> > 
> > By default, if you use the EDK2-base UEFI firmware this controller
> > isn't actually connected to anything.  So you'll see
> > 
> >   sdmmc0: can't enable card
> > 
> > in your dmesg.  If you change the "Raspberry Pi Configuration" ->
> > "SD/MMC Configuration" -> "uSD routing" setting in the "Device
> > Manager" firmware configuration screen to "eMMC2 SDHCI".  The uSD card
> > will show up behind this controller and WiFi will show up on the other
> > controller.  Note that after you've made that configuration change and
> > reset the machine, any further change you make won't stick.  You can
> > fix this by replacing the RPI_EFI.fd file on the MS-DOS partition of
> > your uSD card.
> > 
> > For now the SDHC controllers are only supported in device tree mode
> > which can be enabled using the "Raspberry Pi Configuration" ->
> > "Advanced Configuration" -> "Device Tree" option in the "Device
> > Manager".
> 
> bwfm(4) is working for me, but when in device tree mode (wherever the
> uSD is routed) bse(4) is flaky - ethernet link doesn't come up at boot,
> if I leave it for a little while with a ping running to the bse from
> another machine I get the occasional packet through but that's all.
> Do you see that too?

I don't see that, but I suspect this is because the device tree has
phy-mode set to "rgmii" instead of "rgmii-rxid".

A workaround is to take the bcm2711-rpi-4-b.dtb, fixup4.dat and
start4.elf files from

  https://github.com/raspberrypi/firmware/tree/next/boot

and put them on the MS-DOS partition of your uSD card.



Re: Support additional SD/MMC controller on Raspberry Pi 4

2020-04-20 Thread Stuart Henderson
On 2020/04/19 21:44, Mark Kettenis wrote:
> The Raspberry Pi 4 has an additional SD/MMC controller.  This
> controller is almost completely standard and just needs one tiny
> quirk.  So the diff is really simple.
> 
> By default, if you use the EDK2-base UEFI firmware this controller
> isn't actually connected to anything.  So you'll see
> 
>   sdmmc0: can't enable card
> 
> in your dmesg.  If you change the "Raspberry Pi Configuration" ->
> "SD/MMC Configuration" -> "uSD routing" setting in the "Device
> Manager" firmware configuration screen to "eMMC2 SDHCI".  The uSD card
> will show up behind this controller and WiFi will show up on the other
> controller.  Note that after you've made that configuration change and
> reset the machine, any further change you make won't stick.  You can
> fix this by replacing the RPI_EFI.fd file on the MS-DOS partition of
> your uSD card.
> 
> For now the SDHC controllers are only supported in device tree mode
> which can be enabled using the "Raspberry Pi Configuration" ->
> "Advanced Configuration" -> "Device Tree" option in the "Device
> Manager".

bwfm(4) is working for me, but when in device tree mode (wherever the
uSD is routed) bse(4) is flaky - ethernet link doesn't come up at boot,
if I leave it for a little while with a ping running to the bse from
another machine I get the occasional packet through but that's all.
Do you see that too?

64 bytes from 10.15.5.53: icmp_seq=1977 ttl=255 time=0.590 ms
64 bytes from 10.15.5.53: icmp_seq=1987 ttl=255 time=0.531 ms
64 bytes from 10.15.5.53: icmp_seq=1992 ttl=255 time=0.537 ms
64 bytes from 10.15.5.53: icmp_seq=2024 ttl=255 time=0.543 ms
64 bytes from 10.15.5.53: icmp_seq=2027 ttl=255 time=0.406 ms

Watching interrupt rates whilst flood pinging it, none of them move.

$ vmstat -i 
interrupt   total rate
irq1023/spur   470
irq0/ipinop214576  197
irq153/pluart0  43887   40
irq158/sdhc033516   30
irq175/xhci0   305805  281
irq189/bse0  74136
irq27/tick 867628  797
Total 1472872 1353


ESC (setup), F1 (shell), ENTER (boot).disks: sd0*
>> OpenBSD/arm64 BOOTAA64 0.22
boot>
booting sd0a:/bsd: 7737056+1498096+541152+848472 [509436+109+962448+543543]=0xd3
f930
type 0x0 pa 0x0 va 0x0 pages 0x1d0 attr 0xe
type 0x6 pa 0x1d va 0x97a96c000 pages 0x20 attr 0x800e
type 0x0 pa 0x1f va 0x0 pages 0x10 attr 0xe
type 0x2 pa 0x20 va 0x0 pages 0x4000 attr 0xe
type 0x7 pa 0x420 va 0x0 pages 0x2e8fb attr 0xe
type 0x2 pa 0x32afb000 va 0x0 pages 0xc82 attr 0xe
type 0x1 pa 0x3377d000 va 0x0 pages 0x2a attr 0xe
type 0x0 pa 0x337a7000 va 0x0 pages 0xf9 attr 0xe
type 0x6 pa 0x338a va 0x9ae03c000 pages 0xa0 attr 0x800e
type 0x5 pa 0x3394 va 0x9ae0dc000 pages 0x50 attr 0x800e
type 0x9 pa 0x3399 va 0x0 pages 0x80 attr 0xe
type 0x5 pa 0x33a1 va 0x9ae1ac000 pages 0x80 attr 0x800e
type 0x9 pa 0x33a9 va 0x0 pages 0x20 attr 0xe
type 0x5 pa 0x33ab va 0x9ae24c000 pages 0x80 attr 0x800e
type 0x7 pa 0x33b3 va 0x0 pages 0x19e7 attr 0xe
type 0x4 pa 0x35517000 va 0x0 pages 0x481 attr 0xe
type 0x7 pa 0x35998000 va 0x0 pages 0x5f attr 0xe
type 0x4 pa 0x359f7000 va 0x0 pages 0x1 attr 0xe
type 0x7 pa 0x359f8000 va 0x0 pages 0xd7 attr 0xe
type 0x4 pa 0x35acf000 va 0x0 pages 0xf55 attr 0xe
type 0x7 pa 0x36a24000 va 0x0 pages 0x19e attr 0xe
type 0x3 pa 0x36bc2000 va 0x0 pages 0x43e attr 0xe
type 0x5 pa 0x3700 va 0x9b179c000 pages 0x190 attr 0x800e
type 0x6 pa 0x3719 va 0x9b192c000 pages 0x250 attr 0x800e
type 0x7 pa 0x373e va 0x0 pages 0x1f attr 0xe
type 0x4 pa 0x373ff000 va 0x0 pages 0x1 attr 0xe
type 0x7 pa 0x3740 va 0x0 pages 0x302b attr 0xe
type 0x3 pa 0x3a42b000 va 0x0 pages 0x36 attr 0xe
type 0x4 pa 0x3a461000 va 0x0 pages 0xf9f attr 0xe
type 0x7 pa 0x4000 va 0x0 pages 0x8 attr 0xe
[ using 2016504 bytes of bsd ELF symbol table ]
Copyright (c) 1982, 1986, 1989, 1991, 1993
The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2020 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 6.7-beta (GENERIC.MP) #2: Mon Apr 20 21:13:03 BST 2020
st...@moo.spacehopper.org:/sys/arch/arm64/compile/GENERIC.MP
real mem  = 3076521984 (2934MB)
avail mem = 2951929856 (2815MB)
mainbus0 at root: Raspberry Pi 4 Model B Rev 1.2
cpu0 at mainbus0 mpidr 0: ARM Cortex-A72 r0p3
cpu0: 48KB 64b/line 3-way L1 PIPT I-cache, 32KB 64b/line 2-way L1 D-cache
cpu0: 1024KB 64b/line 16-way L2 cache
efi0 at mainbus0: UEFI 2.7
efi0: https://github.com/pftf/RPi4 rev 0x1
smbios0 at efi0: SMBIOS 3.3.0
smbios0: vendor https://github.com/pftf/RPi4 version "UEFI Firmware v1.8" date 
Apr 14 2020 21:24:48
smbios0: Sony UK Raspberry Pi 4 Model B
apm0 at mainbus0
psci0 at mainbus0: PSCI 1.1, 

Support additional SD/MMC controller on Raspberry Pi 4

2020-04-19 Thread Mark Kettenis
The Raspberry Pi 4 has an additional SD/MMC controller.  This
controller is almost completely standard and just needs one tiny
quirk.  So the diff is really simple.

By default, if you use the EDK2-base UEFI firmware this controller
isn't actually connected to anything.  So you'll see

  sdmmc0: can't enable card

in your dmesg.  If you change the "Raspberry Pi Configuration" ->
"SD/MMC Configuration" -> "uSD routing" setting in the "Device
Manager" firmware configuration screen to "eMMC2 SDHCI".  The uSD card
will show up behind this controller and WiFi will show up on the other
controller.  Note that after you've made that configuration change and
reset the machine, any further change you make won't stick.  You can
fix this by replacing the RPI_EFI.fd file on the MS-DOS partition of
your uSD card.

For now the SDHC controllers are only supported in device tree mode
which can be enabled using the "Raspberry Pi Configuration" ->
"Advanced Configuration" -> "Device Tree" option in the "Device
Manager".

Anyway, ok?


Index: dev/fdt/sdhc_fdt.c
===
RCS file: /cvs/src/sys/dev/fdt/sdhc_fdt.c,v
retrieving revision 1.6
diff -u -p -r1.6 sdhc_fdt.c
--- dev/fdt/sdhc_fdt.c  19 Apr 2020 16:17:03 -  1.6
+++ dev/fdt/sdhc_fdt.c  19 Apr 2020 19:28:28 -
@@ -68,6 +68,7 @@ sdhc_fdt_match(struct device *parent, vo
struct fdt_attach_args *faa = aux;
 
return (OF_is_compatible(faa->fa_node, "arasan,sdhci-5.1") ||
+   OF_is_compatible(faa->fa_node, "brcm,bcm2711-emmc2") ||
OF_is_compatible(faa->fa_node, "brcm,bcm2835-sdhci"));
 }
 
@@ -157,6 +158,9 @@ sdhc_fdt_attach(struct device *parent, s
/* XXX Doesn't work on Rockchip RK3399. */
sc->sc.sc_flags |= SDHC_F_NODDR50;
}
+
+   if (OF_is_compatible(faa->fa_node, "brcm,bcm2711-emmc2"))
+   sc->sc.sc_flags |= SDHC_F_NOPWR0;
 
if (OF_is_compatible(faa->fa_node, "brcm,bcm2835-sdhci")) {
cap = SDHC_VOLTAGE_SUPP_3_3V | SDHC_HIGH_SPEED_SUPP;