This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3358: USB force to Host/Device mode

Part Number: AM3358


Tool/software: Linux

Hi,Now you have a problem with beagleboneblack board development .

I would like to read the usb0 register to determine whether the p4 port is connected to the usb line during the spl or uboot phase.

Excuse me, should I check if the usb line is inserted by reading the change in the bit of the register of the usb0?thank you!

  • Hi,

    Can you please explain your use case to help me understand why you want to know if the P4 port is connected to the USB host port?

    The usb drivers in uboot already handles such low level functions, typically you shouldn't need to modify the code. If you can help me understanding your use case, I might give you better comments to archive your goal.
  • Hi,

    Hi, I haven’t heard back from you, I’m assuming you were able to resolve your issue. If not, just post a reply below (or create a new thread if the thread has locked due to time-out). thanks.
  • I'm sorry, but we didn't reply in time for our vacation last week.I want to read the usb0 register to see if the usb line is inserted into the beagleboneblack board.Now, I need to check in uboot for usb line inserts on the usb0 port of the beagleboneblack board .Can you tell me which bit of the register that reads the usb0 to determine if there is an usb cable insertion on the port of usb0? Or, can you tell me which function can be called in a uboot program to achieve my purpose? Thank you!
  • To add, I want to use usb to upgrade the system, but I don't want to modify the beagleboneblack hardware circuit. I would like to detect the usb line insert, in uboot, automatically erase the boot program on the emmc, you can start from ubs0.
  • Hi,

    So in your use case, AM335x USB0 port (on BeagleboneBlack) is in device mode, and you want to know during U-Boot execution if the USB0 port is connected to a USB host or not. If yes, you will use USB0 to upgrade the system. Is my understanding correct?
  • Hi,
    Yes, In the uboot or spl phase , read the usb0 register to determine whether the usb0 port is inserted into the usb line, I can determine if I need to upgrade the system through usb0 based on the changes in the read registers .Can you tell me, read the register of usb0?

  • Hi,

    There is indeed an USB register which reports the VBUS voltage level, it can be used to determine if the AM335x USB port, when it is configured to device mode, is attached to an USB host port. The register is call DevCtl, offset 0x60 from the MUSB core base address. Its bit[3,4]=11b means the VBUS is above 4.4v.

    However, if you know the USB driver stack in U-Boot very well, you know you cannot directly read any USB register without some extra work, because by default the USB module clock is disabled, until any USB related command is issued in U-Boot prompt. We don't provide support for U-Boot customization, so I only gave the register information as above, but any further query during your U-Boot customization to implement your system upgrading use case is not supported in this forum.
  • Hi,Can you tell me the value of the specific physical address of the register devctl? That's all I found “The USB Controller corresponding to the unbonded PHY must be placed in Host Mode by setting Bit2 of the USB Core DEVCTL register.”But I don't know where to offset 0x60?
  • The base address of DevCtl register is 0x47401400 for USB0.
  • Hi,

    I read the 0x47401400 value in a way.
    "printf("[%s]:<%s>:<%d> DevCtl bit[3,4] = 0x%lx\n", __FILE__, __FUNCTION__, __LINE__, __raw_readl(0x47401400));"

    Plug in the udb and off the usb line, and the result is both 0x2000 .
    "[/home/ycc/easylinkin/eli_project_01/bootstrap/u-boot_dg/arch/arm/cpu/armv7/am33xx/board.c]:<am33xx_usb_get_phy_power>:<180> DevCtl bit[3,4] = 0x2000"

    Is the register 0x47401400 offset 0x60 from the MUSB core base address? Do I directly read the register 0x47401400 bit [3Q4] bit?

  • Hi,
    I read the 0x47401400 value in a way.
    printf("[%s]:<%s>:<%d> DevCtl bit[3,4] = 0x%lx\n", __FILE__, __FUNCTION__, __LINE__, __raw_readl(0x47401400));

    Plug in the udb and off the usb line, and the result is both 0x2000 .
    [/home/ycc/easylinkin/eli_project_01/bootstrap/u-boot_dg/arch/arm/cpu/armv7/am33xx/board.c]:<am33xx_usb_get_phy_power>:<180> DevCtl bit[3,4] = 0x2000
  • Hi,

    The USB0 core register base address is 0x47401400, DevCtl register is at offset 0x60, so you need to read 0x47401460. DevCtl is 8bit.

    For example, at U-Boot prompt:

    (before connect to USB host port)
    =>  md.b 0x47401460 1
    47401460: 80
    
    (after connected to USB host port)
    =>  md.b 0x47401460 1
    47401460: 98
    

    BTY, this register address is physical address, you cannot directly use it with raw_read*(), which uses virtual address.

  • Thank you very much for your help. I can use raw_readl to manipulate the physical address directly during the uboot phase. I'll test it against the 0x47401460 address you gave me。

  • Hi, thank you for your help. This problem has been solved.