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

Mark Millard markmi at dsl-only.net
Mon Oct 23 22:49:18 UTC 2017


[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) != 0) {
/usr/src/sys/arm/allwinner/aw_usbphy.c: sc->phy_ctrl = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
/usr/src/sys/arm/allwinner/aw_usbphy.c: if (sc->phy_ctrl == 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 = device_get_softc(dev);
        node = ofw_bus_get_node(dev);

        sc->phy_conf = (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) != 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 = "/soc/phy at 01c19400:clocks:0";
		fixup = "/soc/phy at 01c19400:clocks:8";
		fixup = "/soc/phy at 01c19400:clocks:16";
		fixup = "/soc/phy at 01c19400:clocks:24";
		fixup = "/soc/phy at 01c19400:resets:0";
		fixup = "/soc/phy at 01c19400:resets:8";
		fixup = "/soc/phy at 01c19400:resets:16";
		fixup = "/soc/phy at 01c19400:usb1_vbus-supply:0";
		fixup = "/soc/usb at 01c1a000:phys:0";
		fixup = "/soc/usb at 01c1b000:phys:0";
		fixup = "/soc/ethernet at 01c30000:phy:0";
		mii_phy_tx_clk = "/clocks/clk at 1";
		phy1 = "/soc/ethernet at 01c30000/ethernet-phy at 1";
		usbphy = "/soc/phy at 01c19400";
			clock-output-names = "usb_phy0", "usb_phy1", "usb_hsic_pll", "usb_hsic_12m", "usb_ohci0";
			clock-output-names = "mii_phy_tx";
			phy = <0x30>;
			phy-mode = "rgmii";
			ethernet-phy at 1 {
		phy at 01c19400 {
			#phy-cells = <0x1>;
			clock-names = "usb0_phy", "usb1_phy", "hsic_pll", "hsic_12m";
			compatible = "allwinner,sun8i-a83t-usb-phy";
			phy-names = "usb";
			phys = <0x2d 0x1>;
			phy-names = "usb";
			phys = <0x2d 0x2>;

(No phy_ctrl examples above.)

# grep pmu ~/bpi-m3-sorted-324743.dts
	pmu {
		compatible = "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 = "phy_ctrl", "pmu1";
/usr/src/sys/gnu/dts/arm/sun8i-a23.dtsi:        reg-names = "phy_ctrl", "pmu1";
/usr/src/sys/gnu/dts/arm/sunxi-h3-h5.dtsi:                      reg-names = "phy_ctrl",
/usr/src/sys/gnu/dts/arm/sun4i-a10.dtsi:                        reg-names = "phy_ctrl", "pmu1", "pmu2";
/usr/src/sys/gnu/dts/arm/sun6i-a31.dtsi:                        reg-names = "phy_ctrl",
/usr/src/sys/gnu/dts/arm/am33xx.dtsi:                           reg-names = "phy_ctrl", "wakeup";
/usr/src/sys/gnu/dts/arm/dm814x.dtsi:                                   reg-names = "phy_ctrl", "wakeup";
/usr/src/sys/gnu/dts/arm/sun8i-v3s.dtsi:                        reg-names = "phy_ctrl",
/usr/src/sys/gnu/dts/arm/sun5i.dtsi:                    reg-names = "phy_ctrl", "pmu1";
/usr/src/sys/gnu/dts/arm/sun7i-a20.dtsi:                        reg-names = "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 = "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: 

# 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 = "rtc", "rtc-soc";
/usr/src/sys/boot/fdt/dts/arm/armada-38x.dtsi:                          reg-names = "sdhci", "mbus", "conf-sdio3";
/usr/src/sys/boot/fdt/dts/arm/h3.dtsi:                  reg-names = "emac", "syscon";
/usr/src/sys/boot/fdt/dts/arm/h3.dtsi:          /*      reg-names = "codec", "pr"; */
/usr/src/sys/boot/fdt/dts/arm64/sun50i-a64.dtsi:                        reg-names = "emac", "syscon";
/usr/src/sys/boot/fdt/dts/arm64/a64.dtsi:                       reg-names = "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 = "usb_phy0", "usb_phy1",
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:		mii_phy_tx_clk: clk at 1 {
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			clock-output-names = "mii_phy_tx";
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			clocks = <&mii_phy_tx_clk>, <&emac_int_tx_clk>;
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:		usbphy: phy at 01c19400 {
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			compatible = "allwinner,sun8i-a83t-usb-phy";
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			clock-names = "usb0_phy",
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:				      "usb1_phy",
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			#phy-cells = <1>;
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			phys = <&usbphy 1>;
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			phy-names = "usb";
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			phys = <&usbphy 2>;
/usr/src/sys/boot/fdt/dts/arm/a83t.dtsi:			phy-names = "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 at 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 = "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 = <&phy1>;
/usr/src/sys/boot/fdt/dts/arm/sinovoip-bpi-m3.dts:	phy-mode = "rgmii";
/usr/src/sys/boot/fdt/dts/arm/sinovoip-bpi-m3.dts:	phy1: ethernet-phy at 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 = "arm,cortex-a7-pmu", "arm,cortex-a15-pmu";


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

> On 2017-Oct-22, at 11:42 PM, Mark Millard <markmi at dsl-only.net> wrote:
> 
> [The notes here presume that mp_ncpu <= cpuid is
> considered valid for the BPI-M3. Otherwise what
> I'm running is a workaround allowing other aspects
> of things to be explored.]
> 
> [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/ .]
> 
> I was able to buildkernel for -r323640 and install
> and boot it on the BPI-M3. Basic operation seems
> okay so far.
> 
> 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.)
> 
> 
> FYI for what I've tried in order to show some
> context:
> 
> 
> Revision 320834 - Directory Listing 
> Modified Sun Jul 9 13:53:32 2017 UTC (3 months, 2 weeks ago) by manu
> Update DTS files from Linux 4.12
> 
> Notable changes:
> 
> 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
> 
> 
> . . .
> 
> 
> Revision 323640 - Directory Listing 
> 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
> 
> Reported by:	jmcneill
> Pointy Hat:	manu
> 
> 
> Then the very next update changes some things
> about interpreting the .dtb greatly . . .
> 
> 
> Revision 323641 - Directory Listing 
> Modified Sat Sep 16 15:58:20 2017 UTC (5 weeks, 1 day ago) by manu
> Allwinner usb phy: Rework resource allocation
> 
> 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 ...).
> 
> While here remove A83T code as upstream and FreeBSD dts don't have
> nodes for USB.
> 
> 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.
> 
> EHCI is still buggy on Pine64 (hang the board) so do not enable it for now.
> 
> Tested On:	Bananapi (A20), BananapiM2 (A31S), OrangePi One (H3) Pine64 (A64)
> 
> 
> . . .
> 
> 
> Revision 324820 - Directory Listing 
> 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
> 
> 
> 
> (I have not tried a .dtb partially based on -r324820
> *.dts* material from sys/gnu/dts/ used with a
> -r323640 kernel.)


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




More information about the freebsd-arm mailing list