the banana pi r2 pro has a usable sata port, but ahci wasnt finding anything attached to it.
the fdt glue looked like it assumed the boot loader did a lot of work to get things going. however, i havent figured out how to configure u-boot to do ahci, and quartz_uefi doesn't have ahci/sata working yet. the boot loaders arent quite there yet, so i tried to make the driver better. the obvious tweak was to enable clocks and the phy, but that wasnt enough to get it working. jared mcneill showed me the code he's been trying to get ahci working in quartz_uefi with, and it showed setting the ports implemented register. the sata nodes in the rk356x device tree populates a ports-implemented property, which the yaml doco says can be provided if the platform/ firmware doesnt init the register itself. i tried using that value instead of a PI read, and that didnt work. having the fdt glue set the register (like jmcneill does) before calling the bus independent code does work though. so i see this now: ahci0 at mainbus0: AHCI 1.3 ahci0: port 0: 3.0Gb/s scsibus0 at ahci0: 32 targets sd0 at scsibus0 targ 0 lun 0: <ATA, MZ-5EA1000-0D3, AXM1> naa.5002538250006f47 sd0: 95396MB, 512 bytes/sector, 195371568 sectors, thin ok? Index: ahci_fdt.c =================================================================== RCS file: /cvs/src/sys/dev/fdt/ahci_fdt.c,v retrieving revision 1.7 diff -u -p -r1.7 ahci_fdt.c --- ahci_fdt.c 25 May 2022 03:03:58 -0000 1.7 +++ ahci_fdt.c 6 Apr 2023 21:30:31 -0000 @@ -30,6 +30,8 @@ #include <dev/ic/ahcivar.h> #include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_clock.h> +#include <dev/ofw/ofw_misc.h> #include <dev/ofw/fdt.h> int ahci_fdt_match(struct device *, void *, void *); @@ -63,6 +65,7 @@ ahci_fdt_attach(struct device *parent, s { struct ahci_softc *sc = (struct ahci_softc *) self; struct fdt_attach_args *faa = aux; + uint32_t pi; if (faa->fa_nreg < 1) return; @@ -82,11 +85,19 @@ ahci_fdt_attach(struct device *parent, s goto unmap; } + clock_set_assigned(faa->fa_node); + clock_enable_all(faa->fa_node); + phy_enable(faa->fa_node, "sata-phy"); + + pi = OF_getpropint(faa->fa_node, "ports-implemented", 0x0); + if (pi != 0) + bus_space_write_4(sc->sc_iot, sc->sc_ioh, AHCI_REG_PI, pi); + printf(":"); if (ahci_attach(sc) != 0) { /* error printed by ahci_attach */ - goto irq; + goto irq; /* disable phy and clocks? */ } return;