Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Oct 2017 15:49:14 -0700
From:      Mark Millard <markmi@dsl-only.net>
To:        Emmanuel Vadot <manu@bidouilliste.com>, freebsd-arm <freebsd-arm@freebsd.org>
Subject:   Re: head -r323640 kernel+.dtb works on BPI-M3; later code requires finding "reg-names" and "phy_ctrl" in .dtb but bpi-m3 has never had them
Message-ID:  <EC0D967B-B466-4CE2-83E6-4BAA7724A07D@dsl-only.net>
In-Reply-To: <68CB464E-6FC6-4CB9-963B-9E7A683041EB@dsl-only.net>
References:  <3AD6B1F8-512C-43BB-AC76-7721454AD02F@dsl-only.net> <20171021195812.5bdb902401b8e756b6abfe40@bidouilliste.com> <C9F6BF5E-28DB-4569-B71E-EDE2A042FC78@dsl-only.net> <20171021204356.47e3cd6066144bcd07f46699@bidouilliste.com> <50728566-11C2-45EB-8367-00CAF38D4548@dsl-only.net> <B3F39A7C-339B-4072-9E41-A3F9DA1F590B@dsl-only.net> <8696CCFA-AE7D-4324-90A8-BB73402FA124@dsl-only.net> <BF09EA6D-6DE8-4138-AD92-8836DFF28620@dsl-only.net> <06B9A4AD-EA28-41A8-91B9-FE368EF622FE@dsl-only.net> <68CB464E-6FC6-4CB9-963B-9E7A683041EB@dsl-only.net>

next in thread | previous in thread | raw e-mail | index | archive | help
[Top post of some material that does not fit
sequentially with prior material.]

I think I've identified one aspect of "legacy"
allwinner .dtb's that is not covered by modern
FreeBSD kernel code, at least for the bpi-m3
.dtb that FreeBSD builds (which FreeBSD builds
in a legacy form with old sources for all but
some include files).

I guess the overall BPI-M3 question comes down
to a choice for BPI-M3 (and possibily other
ALLWINNERS?):

A) The BPI-M3 support being dropped, including its
   u-boot port.

B) The head kernel supporting the legacy .dtb that
   it produces for the BPI-M3 (or similar ones).

C) FreeBSD building a modern .dtb that is structured
   to match what the head kernel supports in .dtb's.
   (The implication being use of updated *.dt* source
   code for the BPI-M3.)

D) Some mix of (B) and (C).


As for the aspect identified (for me the material
is unfamiliar, for others this may be obvious):

It looks like modern .dtb's (and the *.dt* source
files) use the string phy_ctrl and the string
reg-names and that the modern kernel requires
that for allwinner's:

# grep -r "\<phy_ctrl\>" /usr/src/sys/arm/ | less
/usr/src/sys/arm/allwinner/aw_usbphy.c: struct resource *       =
phy_ctrl;
/usr/src/sys/arm/allwinner/aw_usbphy.c: /* Get phy_ctrl region */
/usr/src/sys/arm/allwinner/aw_usbphy.c: if =
(ofw_bus_find_string_index(node, "reg-names", "phy_ctrl", &rid) !=3D 0) =
{
/usr/src/sys/arm/allwinner/aw_usbphy.c: sc->phy_ctrl =3D =
bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
/usr/src/sys/arm/allwinner/aw_usbphy.c: if (sc->phy_ctrl =3D=3D NULL) {
/usr/src/sys/arm/allwinner/aw_usbphy.c:                                 =
CLR4(sc->phy_ctrl, OTG_PHY_CFG,
/usr/src/sys/arm/allwinner/aw_usbphy.c:                                 =
SET4(sc->phy_ctrl, OTG_PHY_CFG,

static int
awusbphy_init(device_t dev)
{
. . .
        sc =3D device_get_softc(dev);
        node =3D ofw_bus_get_node(dev);

        sc->phy_conf =3D (struct aw_usbphy_conf =
*)ofw_bus_search_compatible(dev, compat_data)->ocd_data;

        /* Get phy_ctrl region */
        if (ofw_bus_find_string_index(node, "reg-names", "phy_ctrl", =
&rid) !=3D 0) {
                device_printf(dev, "Cannot locate phy control =
resource\n");
                return (ENXIO);
        }
. . .

That "if" is new as of -r323641 and it rejects the BPI-M3 .dtb
that FreeBSD generates (the same one by content that works with
-r323640). This is because there are no reg-names or phy_ctrl
string involved at all.

Using the sorted output of dtc on the BPI-M3 .dtb
from -r324743 :

# grep reg-names ~/bpi-m3-sorted-324743.dts

(Nothing found above.)

# grep phy ~/bpi-m3-sorted-324743.dts
		fixup =3D "/soc/phy@01c19400:clocks:0";
		fixup =3D "/soc/phy@01c19400:clocks:8";
		fixup =3D "/soc/phy@01c19400:clocks:16";
		fixup =3D "/soc/phy@01c19400:clocks:24";
		fixup =3D "/soc/phy@01c19400:resets:0";
		fixup =3D "/soc/phy@01c19400:resets:8";
		fixup =3D "/soc/phy@01c19400:resets:16";
		fixup =3D "/soc/phy@01c19400:usb1_vbus-supply:0";
		fixup =3D "/soc/usb@01c1a000:phys:0";
		fixup =3D "/soc/usb@01c1b000:phys:0";
		fixup =3D "/soc/ethernet@01c30000:phy:0";
		mii_phy_tx_clk =3D "/clocks/clk@1";
		phy1 =3D "/soc/ethernet@01c30000/ethernet-phy@1";
		usbphy =3D "/soc/phy@01c19400";
			clock-output-names =3D "usb_phy0", "usb_phy1", =
"usb_hsic_pll", "usb_hsic_12m", "usb_ohci0";
			clock-output-names =3D "mii_phy_tx";
			phy =3D <0x30>;
			phy-mode =3D "rgmii";
			ethernet-phy@1 {
		phy@01c19400 {
			#phy-cells =3D <0x1>;
			clock-names =3D "usb0_phy", "usb1_phy", =
"hsic_pll", "hsic_12m";
			compatible =3D "allwinner,sun8i-a83t-usb-phy";
			phy-names =3D "usb";
			phys =3D <0x2d 0x1>;
			phy-names =3D "usb";
			phys =3D <0x2d 0x2>;

(No phy_ctrl examples above.)

# grep pmu ~/bpi-m3-sorted-324743.dts
	pmu {
		compatible =3D "arm,cortex-a7-pmu", =
"arm,cortex-a15-pmu";


Supporting detail (skip unless you care). . .

As for the FreeBSD *.dt* source code in use in this
ALLWINNER area:

# grep -r phy_ctrl /usr/src/sys/gnu/dts/ | less
/usr/src/sys/gnu/dts/arm/sun8i-a33.dtsi:        reg-names =3D =
"phy_ctrl", "pmu1";
/usr/src/sys/gnu/dts/arm/sun8i-a23.dtsi:        reg-names =3D =
"phy_ctrl", "pmu1";
/usr/src/sys/gnu/dts/arm/sunxi-h3-h5.dtsi:                      =
reg-names =3D "phy_ctrl",
/usr/src/sys/gnu/dts/arm/sun4i-a10.dtsi:                        =
reg-names =3D "phy_ctrl", "pmu1", "pmu2";
/usr/src/sys/gnu/dts/arm/sun6i-a31.dtsi:                        =
reg-names =3D "phy_ctrl",
/usr/src/sys/gnu/dts/arm/am33xx.dtsi:                           =
reg-names =3D "phy_ctrl", "wakeup";
/usr/src/sys/gnu/dts/arm/dm814x.dtsi:                                   =
reg-names =3D "phy_ctrl", "wakeup";
/usr/src/sys/gnu/dts/arm/sun8i-v3s.dtsi:                        =
reg-names =3D "phy_ctrl",
/usr/src/sys/gnu/dts/arm/sun5i.dtsi:                    reg-names =3D =
"phy_ctrl", "pmu1";
/usr/src/sys/gnu/dts/arm/sun7i-a20.dtsi:                        =
reg-names =3D "phy_ctrl", "pmu1", "pmu2";

# grep -r phy_ctrl /usr/src/sys/boot/fdt/dts/ | less
/usr/src/sys/boot/fdt/dts/arm64/a64.dtsi:                       =
reg-names =3D "phy_ctrl", "pmu1", "pmu2";

(Note the lack of a83t and bpi-m3 material above.)

But the area with the BPI-M3 materials (other than some
of the include files) does not have such in those
materials:=20

# egrep -r "(reg-names|phy_ctrl)" /usr/src/sys/boot/fdt/dts/ | more
/usr/src/sys/boot/fdt/dts/arm/armada-38x.dtsi:                          =
reg-names =3D "rtc", "rtc-soc";
/usr/src/sys/boot/fdt/dts/arm/armada-38x.dtsi:                          =
reg-names =3D "sdhci", "mbus", "conf-sdio3";
/usr/src/sys/boot/fdt/dts/arm/h3.dtsi:                  reg-names =3D =
"emac", "syscon";
/usr/src/sys/boot/fdt/dts/arm/h3.dtsi:          /*      reg-names =3D =
"codec", "pr"; */
/usr/src/sys/boot/fdt/dts/arm64/sun50i-a64.dtsi:                        =
reg-names =3D "emac", "syscon";
/usr/src/sys/boot/fdt/dts/arm64/a64.dtsi:                       =
reg-names =3D "phy_ctrl", "pmu1", "pmu2";

(Note again the lack of a83t and bpi-m3 material above.)

vs.

# ls -lt /usr/src/sys/boot/fdt/dts/arm | egrep -i "(a83t|m3)"
-rw-r--r--  1 root  wheel   7985 Jan  2  2017 a83t.dtsi
-rw-r--r--  1 root  wheel   3601 Nov  3  2016 sinovoip-bpi-m3.dts
-rw-r--r--  1 root  wheel   2750 Nov  3  2016 =
sun8i-a83t-sinovoip-bpi-m3.dts
-rw-r--r--  1 root  wheel  13293 Nov  3  2016 sun8i-a83t.dtsi
-rw-r--r--  1 root  wheel   6205 Nov  3  2016 yyhd18-m3.dts

(That last is an amlogic associated file and does not apply
here.)

# grep -r phy /usr/src/sys/boot/fdt/dts/ |  egrep -i "(a83t|m3)"
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			=
clock-output-names =3D "usb_phy0", "usb_phy1",
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:		mii_phy_tx_clk: =
clk@1 {
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			=
clock-output-names =3D "mii_phy_tx";
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			clocks =3D=
 <&mii_phy_tx_clk>, <&emac_int_tx_clk>;
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:		usbphy: =
phy@01c19400 {
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			=
compatible =3D "allwinner,sun8i-a83t-usb-phy";
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			=
clock-names =3D "usb0_phy",
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:				 =
     "usb1_phy",
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			=
#phy-cells =3D <1>;
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			phys =3D =
<&usbphy 1>;
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			=
phy-names =3D "usb";
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			phys =3D =
<&usbphy 2>;
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			=
phy-names =3D "usb";
/usr/src/sys/boot/fdt/dts/arm/yyhd18-m3.dts: * usb-phy which depends on =
gpio, also the timer should appear early on
/usr/src/sys/boot/fdt/dts/arm/yyhd18-m3.dts:		usb-phy@c1108400 =
{
/usr/src/sys/boot/fdt/dts/arm/yyhd18-m3.dts:			/* usb-a =
and usb-b phy */
/usr/src/sys/boot/fdt/dts/arm/yyhd18-m3.dts:			=
compatible =3D "amlogic,aml8726-m3-usb-phy";
/usr/src/sys/boot/fdt/dts/arm/sinovoip-bpi-m3.dts:&usbphy {
/usr/src/sys/boot/fdt/dts/arm/sinovoip-bpi-m3.dts:	phy =3D <&phy1>;
/usr/src/sys/boot/fdt/dts/arm/sinovoip-bpi-m3.dts:	phy-mode =3D =
"rgmii";
/usr/src/sys/boot/fdt/dts/arm/sinovoip-bpi-m3.dts:	phy1: =
ethernet-phy@1 {

# grep -r pmu /usr/src/sys/boot/fdt/dts/ |  egrep -i "(a83t|m3)"
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:	pmu {
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:		compatible =3D =
"arm,cortex-a7-pmu", "arm,cortex-a15-pmu";


=3D=3D=3D
Mark Millard
markmi at dsl-only.net

> On 2017-Oct-22, at 11:42 PM, Mark Millard <markmi@dsl-only.net> wrote:
>=20
> [The notes here presume that mp_ncpu <=3D cpuid is
> considered valid for the BPI-M3. Otherwise what
> I'm running is a workaround allowing other aspects
> of things to be explored.]
>=20
> [Reminder: Most of the BPI-M3 *.dt* material
> is not from sys/gnu/dts/ at all but from
> sys/boot/fdt/dts/ instead: not updated
> with LINUX 4.?? updates. But some included
> *.dt* files are from sys/gnu/dts/ .]
>=20
> I was able to buildkernel for -r323640 and install
> and boot it on the BPI-M3. Basic operation seems
> okay so far.
>=20
> It appears to me that -r323641 and later can
> not interpret the same .dtb that -r323640 uses
> correctly. My guess is some legacy support has
> been (implicitly?) removed. (This may well be
> deliberate and more important than having the
> BPI-M3 working from an overall point of view.)
>=20
>=20
> FYI for what I've tried in order to show some
> context:
>=20
>=20
> Revision 320834 - Directory Listing=20
> Modified Sun Jul 9 13:53:32 2017 UTC (3 months, 2 weeks ago) by manu
> Update DTS files from Linux 4.12
>=20
> Notable changes:
>=20
> Allwinner:
>  * H3/H5 were merged into a common dtsi file
>  * include/dt-bindings/sun4i-a10.h is not included anymore
>  in a lot of dts files
>  * Add sun8i-h3-nanopi-neo-air board DTS file
>=20
>=20
> . . .
>=20
>=20
> Revision 323640 - Directory Listing=20
> Modified Sat Sep 16 15:50:31 2017 UTC (5 weeks, 1 day ago) by manu
> A64 CCUNG: Correct gate and reset for OHCI0/1
>=20
> Reported by:	jmcneill
> Pointy Hat:	manu
>=20
>=20
> Then the very next update changes some things
> about interpreting the .dtb greatly . . .
>=20
>=20
> Revision 323641 - Directory Listing=20
> Modified Sat Sep 16 15:58:20 2017 UTC (5 weeks, 1 day ago) by manu
> Allwinner usb phy: Rework resource allocation
>=20
> The usbphy node for allwinner have two kind of resources, one for the
> phy_ctrl and one per phy. Instead of blindy allocating resources, =
alloc
> the phy_ctrl and pmu ones separately.
> Also add a configuration struct for all different phy that hold the =
difference
> between them (number of phys, unknow needed register write etc ...).
>=20
> While here remove A83T code as upstream and FreeBSD dts don't have
> nodes for USB.
>=20
> This (plus 323640) re-enable OHCI on Pine64 on the bottom USB port.
> The top USB port is routed to the OHCI0/EHCI0 which is by default in =
OTG mode.
> While the phy code can handle the re-route to standard OHCI/EHCI we =
still need
> a driver for musb to probe and configure it in host mode.
>=20
> EHCI is still buggy on Pine64 (hang the board) so do not enable it for =
now.
>=20
> Tested On:	Bananapi (A20), BananapiM2 (A31S), OrangePi One (H3) =
Pine64 (A64)
>=20
>=20
> . . .
>=20
>=20
> Revision 324820 - Directory Listing=20
> Modified Sat Oct 21 15:47:40 2017 UTC (38 hours, 31 minutes ago) by =
manu
> dts: Update our device tree sources file fomr Linux 4.13
>=20
>=20
>=20
> (I have not tried a .dtb partially based on -r324820
> *.dts* material from sys/gnu/dts/ used with a
> -r323640 kernel.)


=3D=3D=3D
Mark Millard
markmi at dsl-only.net





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?EC0D967B-B466-4CE2-83E6-4BAA7724A07D>