Home Forum Software discussion How to enable USB Device mode on Macchiato board

This topic contains 2 replies, has 2 voices, and was last updated by  cpwrunner 1 week, 3 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #522

    songzhao831
    Participant

    Hi Guys,

    I have a Macchiato board in my hand, i am working on enable USB device mode on SB0 USB3 device, there is what i did:
    1. Enable “u3d”and “udc” in kernel DTS, Disable “usb3h0″and “usb3h1”
    2. connect the USB port out and connect to WINDOWS PC USB.
    3. Set “USB configuration Register” bit[0] =1: that is set USB3 device connect to USB UTMI 0 in u-boot.
    4. build kernel / bootloader, every thing works well. but PC can’t detect USB device.
    5. Check USB signal, no any Signal on the DM/DP.

    More:
    i install these .so, still don’t work.
    # insmod libcomposite.ko;
    # insmod usb_f_mass_storage.ko;
    # insmod g_mass_storage.ko file=/dev/sda1

    My code base is: armada-17.06. Could you tell me how to enable the USB device mode?

    #6792

    cpwrunner
    Participant

    Hey were you ever able to get the macchiatobin to work as an usb3 device? If so what did you do? I am trying to do the same thing. One really strange thing that I noticed is that in the dts files the usb device controllers are defined for the master cp110, but they are not defined for the slave. Those are u3d@.. and udc@… . The actual usb3 host ports usb3h0, and usb3h0_1 are defined in cp110 and cp110-1 for the master and slave respectively. Though in the armada-8040-mcbin.dts, it only enables the usb3hx_1 usb ports which are defined in the slave cp110-1 files. Does it matter that u3d@.. and udc@.. devices are defined only in the master context? Does cp110-1 even have access to the udc@.. and u3d@… hardware? Sorry I don’t have much of an electrical engineering background, nor do I completely understand how usb works. Also, there appears to be a flag that permits the usb3h0_1 device to run in device mode, that is changing COMPHY_USB3H0 to COMPHY_USB3DO here:

    usb3h0_1: usb3@500000 {
    usb-phy = <&usb3h0_phy>;
    separated-phys-for-usb2-usb3;
    phys = <&utmi0_1>,
    <&comphy1 2 COMPHY_USB3D0>; <—- Changed from H0 to D0 per /Documentation/devicetree/bindings/phy/phy-comphy-mvebu.txt
    phy-names = “usb2”, “usb3”;
    status = “okay”;
    };

    Also, besides the changes to the dts file, what did you need to change in u-boot, I have not even begun to look at how u-boot affects the usb host/device configuration.

    Thanks

    #6827

    cpwrunner
    Participant

    To respond to my own post,

    This has been much more difficult to get working than I anticipated. It still is not working, but I think I am getting closer. I have been able to enable the device controllers mvebu.u3d and mv-udc it looks like and create a gadget using the usb device framework, but there is still no sign of a usb host recognizing the device I have created when I plug in a usb cable to a macchiatobin and a host machine. I have been using a usb cable with two usb type A ends as well as a type c cable to with a type-c end and a type-A end.

    I am poking around in the dark so to speak, because I do not quite understand how the usb device controller u3d is able to determine when a usb host has been plugged in. Looking through the kernel and device tree documentation, I suspect that vbus and gpio is involved?

    Anyway, to get to the point where I am I needed to flash the latest version of u-boot with a modified device tree which configured lane 1 as a usb device on the slave cp110 chip. This was extremely frustrating because the directions in the wiki, though while fairly accurate, fail to include the vital piece of information that your compiler needs to have the pie flag disabled. Otherwise u-boot will not boot and will just hang on COLDBOOT:…. -then nothing.

    The other gotcha is that there is no documentation explaining which serdes configuations are permitted. In the file drivers/phy/marvell/comphy_cp110.c there is some description of which pipe and data selection options are available on a per lane basis, but it is not clear how this layout corresponds to the architecture of the 8k with respect to its dual cp110’s. Anyway using this documentation I was able to enable serdes lane 1 on the slave cp110 as a usb3-device, see the u-boot patch below.

    With respect to configuring the kernel I made the following changes to the device tree. Until I enabled one of the serdes lanes as usb device and moved the udc and u3d definitions into the cp110 slave configuration space, the kernel crashed with some sort of “Bad mode… ” error. I am using the linux-4.4.52-armada-17.10 version.

    diff –git a/arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts b/arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts
    index 648bab408dd2..29391e62757c 100644
    — a/arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts
    +++ b/arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts
    @@ -197,13 +197,23 @@
    comphy1: comphy {
    status = “okay”;
    };
    + u3d@520000 {
    + status = “okay”;
    + phys = <&comphy1 1 COMPHY_USB3D0>;
    + phy-names = “usb”;
    + };
    + udc@524100 {
    + status = “okay”;
    + phys = <&utmi0_1>;
    + phy-names = “usb”;
    + };
    usb3h0_1: usb3@500000 {
    usb-phy = <&usb3h0_phy>;
    separated-phys-for-usb2-usb3;
    phys = <&utmi0_1>,
    <&comphy1 2 COMPHY_USB3H0>;
    phy-names = “usb2”, “usb3”;
    – status = “okay”;
    + status = “disabled”;
    };
    usb3h0_phy: usb3_phy0 {
    compatible = “usb-nop-xceiv”;
    @@ -213,7 +223,7 @@
    status = “okay”;

    sata-port@0 {
    – phys = <&comphy1 1 COMPHY_SATA0>;
    + phys = <&comphy1 2 COMPHY_SATA0>;
    phy-names = “comphy”;
    status = “okay”;
    };
    diff –git a/arch/arm64/boot/dts/marvell/armada-cp110-1.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110-1.dtsi
    index 88fc93f39e7b..11ed174ef4c2 100644
    — a/arch/arm64/boot/dts/marvell/armada-cp110-1.dtsi
    +++ b/arch/arm64/boot/dts/marvell/armada-cp110-1.dtsi
    @@ -95,6 +95,26 @@ usb3h0_1: usb3@500000 {
    needs-reset-on-resume;
    status = “disabled”;
    };
    +u3d@520000 {
    + compatible = “marvell,mvebu-u3d”;
    + /* 0: 0x520000: USB 3.0 Device port 0: DEV_INFO_REG(0:15 – version_id)
    + * 1: 0x121F10: Clock Source High reg: VBUS present indication in PHY SerDes lane#1
    + */
    + reg = <0x520000 0x2000>, <0x121f10 0x40>;
    + interrupts = <ICU_GRP_NSR 102 IRQ_TYPE_LEVEL_HIGH>;
    + clocks = <&cps_syscon0 1 24>;
    + dma-coherent;
    + status = “disabled”;
    +};
    +
    +udc@524100 {
    + compatible = “marvell,mv-udc”;
    + reg = <0x524100 0x2000>;
    + interrupts = <ICU_GRP_NSR 102 IRQ_TYPE_LEVEL_HIGH>;
    + clocks = <&cps_syscon0 1 24>;
    + dma-coherent;
    + status = “disabled”;
    +};

    usb3h1_1: usb3@510000 {
    compatible = “generic-xhci”;
    @@ -112,7 +132,7 @@ utmi0_1: utmi@580000 {
    <0x440420 0x4>,
    <0x440440 0x4>;
    reg-names = “utmi”, “usb-cfg-reg”, “utmi-cfg-reg”;
    – utmi-port = <UTMI_PHY_TO_USB3_HOST0>;
    + utmi-port = <UTMI_PHY_TO_USB3_DEVICE0>;
    utmi-index = <0>;
    #phy-cells = <0>;
    status = “disabled”;
    diff –git a/arch/arm64/boot/dts/marvell/armada-cp110.dtsi b/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
    index 8daa36f7c3f7..6d5512ae3658 100644
    — a/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
    +++ b/arch/arm64/boot/dts/marvell/armada-cp110.dtsi
    @@ -189,26 +189,6 @@ usb3h1: usb3@510000 {
    status = “disabled”;
    };

    -u3d@520000 {
    – compatible = “marvell,mvebu-u3d”;
    – /* 0: 0x520000: USB 3.0 Device port 0: DEV_INFO_REG(0:15 – version_id)
    – * 1: 0x121F10: Clock Source High reg: VBUS present indication in PHY SerDes lane#1
    – */
    – reg = <0x520000 0x2000>, <0x121f10 0x40>;
    – interrupts = <ICU_GRP_NSR 102 IRQ_TYPE_LEVEL_HIGH>;
    – clocks = <&cpm_syscon0 1 24>;
    – dma-coherent;
    – status = “disabled”;
    -};

    -udc@524100 {
    – compatible = “marvell,mv-udc”;
    – reg = <0x524100 0x2000>;
    – interrupts = <ICU_GRP_NSR 102 IRQ_TYPE_LEVEL_HIGH>;
    – clocks = <&cpm_syscon0 1 24>;
    – dma-coherent;
    – status = “disabled”;
    -};

    utmi0: utmi@580000 {
    compatible = “marvell,cp110-utmi-phy”;
    @@ -216,7 +196,7 @@ utmi0: utmi@580000 {
    <0x440420 0x4>,
    <0x440440 0x4>;
    reg-names = “utmi”, “usb-cfg-reg”, “utmi-cfg-reg”; :
    <0x440440 0x4>;
    reg-names = “utmi”, “usb-cfg-reg”, “utmi-cfg-reg”;
    – utmi-port = <UTMI_PHY_TO_USB3_HOST0>;
    + utmi-port = <UTMI_PHY_TO_USB3_DEVICE0>;
    utmi-index = <0>;
    #phy-cells = <0>;
    status = “disabled”;

    With respect to u-boot, I made the following changes to the u-boot-2017.03-armada-17.10 device tree:

    diff –git a/arch/arm/dts/armada-8040-mcbin.dts b/arch/arm/dts/armada-8040-mcbin.dts
    index f0924e6575..c5d869381a 100644
    — a/arch/arm/dts/armada-8040-mcbin.dts
    +++ b/arch/arm/dts/armada-8040-mcbin.dts
    @@ -307,10 +307,10 @@
    phy-speed = <COMPHY_SPEED_1_25G>;
    };
    phy1 {
    – phy-type = <COMPHY_TYPE_SATA0>;
    + phy-type = <COMPHY_TYPE_USB3_DEVICE>;
    };
    phy2 {
    – phy-type = <COMPHY_TYPE_USB3_HOST0>;
    + phy-type = <COMPHY_TYPE_SATA0>;
    };
    phy3 {
    phy-type = <COMPHY_TYPE_SATA1>;
    @@ -321,6 +321,8 @@
    phy5 {
    phy-type = <COMPHY_TYPE_SGMII2>;
    phy-speed = <COMPHY_SPEED_3_125G>;
    +
    + /*phy-type = <COMPHY_TYPE_USB3_HOST0>;*/
    };
    };

    diff –git a/arch/arm/dts/armada-cp110-master.dtsi b/arch/arm/dts/armada-cp110-master.dtsi
    index 6b42901f78..6a9d60e2f4 100644
    — a/arch/arm/dts/armada-cp110-master.dtsi
    +++ b/arch/arm/dts/armada-cp110-master.dtsi
    @@ -286,7 +286,7 @@
    reg = <0x580000 0x1000>, /* utmi-unit */
    <0x440420 0x4>, /* usb-cfg */
    <0x440440 0x4>; /* utmi-cfg */
    – utmi-port = <UTMI_PHY_TO_USB3_HOST0>;
    + utmi-port = <UTMI_PHY_TO_USB3_DEVICE0>;
    status = “disabled”;
    };

    diff –git a/arch/arm/dts/armada-cp110-slave.dtsi b/arch/arm/dts/armada-cp110-slave.dtsi
    index 1ed252ca9d..bedb78664c 100644
    — a/arch/arm/dts/armada-cp110-slave.dtsi
    +++ b/arch/arm/dts/armada-cp110-slave.dtsi
    @@ -272,7 +272,7 @@
    reg = <0x580000 0x1000>, /* utmi-unit */
    <0x440420 0x4>, /* usb-cfg */
    <0x440440 0x4>; /* utmi-cfg */
    – utmi-port = <UTMI_PHY_TO_USB3_HOST0>;
    + utmi-port = <UTMI_PHY_TO_USB3_DEVICE0>;
    status = “disabled”;
    };

    With these changes, a linux usb device can be created and enabled using a method such as echo “….u3d@… > UDC” , but nothing is detected when I make a physical connection with the macchiatobin usb type A port and the usb type A or C port on another computer. What am I missing?

    Thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Technical specification tables can not be displayed on mobile. Please view on desktop