> Date: Mon, 11 Jul 2022 18:28:22 +0200
> From: Anton Lindqvist <an...@basename.se>
> 
> On Mon, Jul 11, 2022 at 12:13:38PM +0200, Mark Kettenis wrote:
> > > Date: Wed, 06 Jul 2022 15:45:05 -0500
> > > From: j...@entropicblur.com
> > > 
> > > Hi all,
> > > 
> > > I had an unused Le Potato SBC lying around, so I took a crack at 
> > > installing OpenBSD/arm64 on it. The board is similar to the supported 
> > > ODROID-C4 and can boot the install kernel successfully, but there are 
> > > many unconfigured devices. I was not able to complete an install because 
> > > neither USB nor microSD storage was available. The dwge network 
> > > interface is detected but nonfunctional because the PHY is not 
> > > configured.
> > > 
> > > I understand that this is an unsupported board and I had no expectation 
> > > of success or support, but I'm passing this info along in case there is 
> > > any developer interest.
> > > 
> > > For reference, this is the board:
> > > 
> > > https://libre.computer/products/s905x/
> > > 
> > > I used the meson-gxl-s905x-libretech-cc.dtb file from OpenBSD's dtb 
> > > package and the u-boot-2020-07-r1.sd.bin from here:
> > > 
> > > http://share.loverpi.com/board/libre-computer-project/libre-computer-board/aml-s905x-cc/firmware/
> > > 
> > > I used the latest snap miniroot71.img, dated July 06.
> > > 
> > > Dmesg from the install kernel:
> > > 
> > > Copyright (c) 1982, 1986, 1989, 1991, 1993
> > >          The Regents of the University of California.  All rights 
> > > reserved.
> > > Copyright (c) 1995-2022 OpenBSD. All rights reserved.  
> > > https://www.OpenBSD.org
> > > 
> > > OpenBSD 7.1-current (RAMDISK) #1616: Tue Jul  5 10:44:45 MDT 2022
> > >      dera...@arm64.openbsd.org:/usr/src/sys/arch/arm64/compile/RAMDISK
> > > real mem  = 2039029760 (1944MB)
> > > avail mem = 1939697664 (1849MB)
> > > random: good seed from bootblocks
> > > mainbus0 at root: Libre Computer AML-S905X-CC
> > > psci0 at mainbus0: PSCI 0.2
> > > cpu0 at mainbus0 mpidr 0: ARM Cortex-A53 r0p4
> > > cpu0: 32KB 64b/line 2-way L1 VIPT I-cache, 32KB 64b/line 4-way L1 
> > > D-cache
> > > cpu0: 256KB 64b/line 16-way L2 cache
> > > cpu0: CRC32,SHA2,SHA1,AES+PMULL,ASID16
> > > efi0 at mainbus0: UEFI 2.8
> > > efi0: Das U-Boot rev 0x20200700
> > > "arm-pmu" at mainbus0 not configured
> > > agtimer0 at mainbus0: 24000 kHz
> > > "xtal-clk" at mainbus0 not configured
> > > "firmware" at mainbus0 not configured
> > > "efuse" at mainbus0 not configured
> > > "scpi" at mainbus0 not configured
> > > simplebus0 at mainbus0: "soc"
> > > ampintc0 at simplebus0 nirq 256, ncpu 4: "interrupt-controller"
> > > simplebus1 at simplebus0: "bus"
> > > "interrupt-controller" at simplebus1 not configured
> > > "reset-controller" at simplebus1 not configured
> > > "adc" at simplebus1 not configured
> > > "clock-measure" at simplebus1 not configured
> > > "spi" at simplebus1 not configured
> > > "watchdog" at simplebus1 not configured
> > > "sram" at simplebus0 not configured
> > > simplebus2 at simplebus0: "bus"
> > > syscon0 at simplebus2: "sys-ctrl"
> > > "power-controller-vpu" at syscon0 not configured
> > > "clock-controller" at syscon0 not configured
> > > syscon1 at simplebus2: "ao-secure"
> > > "cec" at simplebus2 not configured
> > > amluart0 at simplebus2: console
> > > "ir" at simplebus2 not configured
> > > "pinctrl" at simplebus2 not configured
> > > "video-codec" at simplebus0 not configured
> > > simplebus3 at simplebus0: "bus"
> > > amlrng0 at simplebus3
> > > "pinctrl" at simplebus3 not configured
> > > "eth-phy-mux" at simplebus3 not configured
> > > simplebus4 at simplebus0: "bus"
> > > "video-lut" at simplebus4 not configured
> > > simplebus5 at simplebus0: "bus"
> > > syscon2 at simplebus5: "system-controller"
> > > "clock-controller" at syscon2 not configured
> > > "mailbox" at simplebus5 not configured
> > > dwge0 at simplebus0: rev 0x37, address ea:b1:7f:b1:44:67
> > > dwge0: no PHY found!
> > > simplebus6 at simplebus0: "apb"
> > > "mmc" at simplebus6 not configured
> > > "mmc" at simplebus6 not configured
> > > "phy" at simplebus6 not configured
> > > "phy" at simplebus6 not configured
> > > "phy" at simplebus6 not configured
> > > "gpu" at simplebus6 not configured
> > > "vpu" at simplebus0 not configured
> > > "hdmi-tx" at simplebus0 not configured
> > > "usb" at simplebus0 not configured
> > > "crypto" at simplebus0 not configured
> > > "cvbs-connector" at mainbus0 not configured
> > > "emmc-pwrseq" at mainbus0 not configured
> > > "hdmi-connector" at mainbus0 not configured
> > > "leds" at mainbus0 not configured
> > > "regulator-hdmi-5v" at mainbus0 not configured
> > > "regulator-vcc_3v3" at mainbus0 not configured
> > > "regulator-vcc-card" at mainbus0 not configured
> > > "regulator-vddio_ao18" at mainbus0 not configured
> > > "regulator-vddio_boot" at mainbus0 not configured
> > > simplefb0 at mainbus0: 720x576, 32bpp
> > > wsdisplay0 at simplefb0
> > > wsdisplay0: screen 0 added (std, vt100 emulation)
> > > softraid0 at root
> > > scsibus0 at softraid0: 256 targets
> > > root on rd0a swap on rd0b dump on rd0b
> > > WARNING: CHECK AND RESET THE DATE!
> > > 
> > > If there is any developer interest, I'm happy to do what I can to help.
> > 
> > Hi Joe,
> > 
> > This board is based on a different SoC than the ODROID-C4.  We'll need
> > to add support for this SoC to the amlclock(4), amlreset(4),
> > amplpinctrl(4) and amldwusb(4) drivers.  Shouldn't be too difficult
> > but it is a bit of work.  If you're willing to test diffs with a
> > relatively quick tunraround I can give it a go.  Otherwise somebody
> > would need to send me a board with that SoC.
> 
> I also took a look a this and decided to order a device. One thing I did
> notice is that we lack a driver for the phy supply referenced from the
> node that hopefully can attach as amlusbphy(4):
> 
>       phy@78000 {
>               compatible = "amlogic,meson-gxl-usb2-phy";
>               #phy-cells = <0x00>;
>               reg = <0x00 0x78000 0x00 0x20>;
>               clocks = <0x03 0x37>;
>               clock-names = "phy";
>               resets = <0x11 0x22>;
>               reset-names = "phy";
>               status = "okay";
>               phy-supply = <0x2b>;
>               phandle = <0x33>;
>       };
> 
>       ...
> 
>       regulator-hdmi-5v {
>               compatible = "regulator-fixed";
>               regulator-name = "HDMI_5V";
>               regulator-min-microvolt = <0x4c4b40>;
>               regulator-max-microvolt = <0x4c4b40>;
>               gpio = <0x23 0x13 0x00>;
>               enable-active-high;
>               regulator-always-on;
>               phandle = <0x2b>;
>       };
> 
> Being able to enable this regulator looks crucial based on this commit
> from Linux:
> 
>       
> https://github.com/torvalds/linux/commit/b83687f359d9b4128073f06ab7a06489eb04aa7c
> 
> I wrote a quick driver that attaches to all regulator-fixed nodes,
> making all of them available through the regulator(9) API. This should
> make the regulator_enable() call in amlusbphy(4) work. I'm wondering if
> this approach makes sense or if a driver with more "restrictive" match
> semantics is desirable?

The "regulator-fixed" nodes are already handled by the regulator
"framework".  So no driver is needed.

> diff --git sys/arch/arm64/conf/GENERIC sys/arch/arm64/conf/GENERIC
> index 752643e8ce0..adc7459c9ab 100644
> --- sys/arch/arm64/conf/GENERIC
> +++ sys/arch/arm64/conf/GENERIC
> @@ -94,6 +94,7 @@ ipmi*               at fdt?
>  com*         at fdt?
>  
>  # Generic devices
> +fxpwr*               at fdt? early 1
>  iicmux*              at fdt?
>  iic*         at iicmux?
>  pinctrl*     at fdt? early 1
> diff --git sys/arch/arm64/conf/RAMDISK sys/arch/arm64/conf/RAMDISK
> index 94977fdff7d..ce030639992 100644
> --- sys/arch/arm64/conf/RAMDISK
> +++ sys/arch/arm64/conf/RAMDISK
> @@ -82,6 +82,7 @@ ccp*                at fdt?         # AMD Cryptographic 
> Co-processor
>  com*         at fdt?
>  
>  # Generic devices
> +fxpwr*               at fdt? early 1
>  iicmux*              at fdt?
>  iic*         at iicmux?
>  pinctrl*     at fdt? early 1
> diff --git sys/dev/fdt/files.fdt sys/dev/fdt/files.fdt
> index ca24869c0f1..fb2216b3118 100644
> --- sys/dev/fdt/files.fdt
> +++ sys/dev/fdt/files.fdt
> @@ -616,3 +616,7 @@ file      dev/fdt/gpiorestart.c           gpiorestart
>  device       tascodec
>  attach       tascodec at i2c
>  file dev/fdt/tascodec.c              tascodec
> +
> +device       fxpwr
> +attach       fxpwr at fdt
> +file dev/fdt/fxpwr.c                 fxpwr
> diff --git sys/dev/fdt/fxpwr.c sys/dev/fdt/fxpwr.c
> new file mode 100644
> index 00000000000..38fa7b94d72
> --- /dev/null
> +++ sys/dev/fdt/fxpwr.c
> @@ -0,0 +1,67 @@
> +/*   $OpenBSD$       */
> +/*
> + * Copyright (c) 2022 Anton Lindqvist <an...@openbsd.org>
> + *
> + * Permission to use, copy, modify, and distribute this software for any
> + * purpose with or without fee is hereby granted, provided that the above
> + * copyright notice and this permission notice appear in all copies.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
> + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
> + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
> + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
> + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
> + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
> + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
> + */
> +
> +#include <sys/param.h>
> +#include <sys/systm.h>
> +#include <sys/device.h>
> +
> +#include <machine/fdt.h>
> +
> +#include <dev/ofw/openfirm.h>
> +#include <dev/ofw/ofw_regulator.h>
> +
> +struct fxpwr_softc {
> +     struct device           sc_dev;
> +     struct regulator_device sc_rd;
> +};
> +
> +int  fxpwr_match(struct device *, void *, void *);
> +void fxpwr_attach(struct device *, struct device *, void *);
> +
> +const struct cfattach fxpwr_ca = {
> +     sizeof(struct fxpwr_softc), fxpwr_match, fxpwr_attach,
> +     NULL, NULL,
> +};
> +
> +struct cfdriver fxpwr_cd = {
> +     NULL, "fxpwr", DV_DULL
> +};
> +
> +int
> +fxpwr_match(struct device *parent, void *match, void *aux)
> +{
> +     struct fdt_attach_args *fa = aux;
> +
> +     return OF_is_compatible(fa->fa_node, "regulator-fixed");
> +}
> +
> +void
> +fxpwr_attach(struct device *parent, struct device *self, void *aux)
> +{
> +     struct fxpwr_softc *sc = (struct fxpwr_softc *)self;
> +     struct fdt_attach_args *fa = aux;
> +     char name[32];
> +
> +     if (OF_getprop(fa->fa_node, "regulator-name", name, sizeof(name)) > 0) {
> +             name[sizeof(name) - 1] = 0;
> +             printf(": \"%s\"", name);
> +     }
> +     printf("\n");
> +
> +     sc->sc_rd.rd_node = fa->fa_node;
> +     regulator_register(&sc->sc_rd);
> +}
> 

Reply via email to