Go to previous topic
Go to next topic
Last Post 02 Nov 2018 04:19 PM by  Charlie Hamilton
Linux USB - Configuring the USB host (musb-hdrc?) to only allow connections in full-speed mode (disable high-speed)?
 7 Replies
Author Messages
steven.eckhoff
Basic Member
Basic Member
Posts:192


--
17 Oct 2013 09:07 AM
    Hi,

    Do you know how to configure the USB host (musb-hdrc?) to only allow connections in full-speed mode (disable high-speed)? We are having issues with some USB devices and would like to force the bus to run slower.

    Thanks for your help

    Matt
    steven.eckhoff
    Basic Member
    Basic Member
    Posts:192


    --
    18 Oct 2013 10:03 AM

    You can try using the following:

     echo "force full-speed" > /debug/musb/testmode

    If you do not see the debug filesystem, then you can add it by doing the following in the kernel config

          Menuconfig->kernel hacking -->
                [ ] Enable unused/obsolete exported symbols                                            
                [*] Debug Filesystem                                                                   
                [ ] Run 'make headers_check' when building vmlinux      
                [*] Kernel debugging 

     

    Matt Sacker
    New Member
    New Member
    Posts:4


    --
    18 Oct 2013 10:51 AM
    Hi Steven,

    I have tried waht you suggested but the USB device still connects at high speed. I have managed to force full speed by recompiling the kernel, following the instructions here: http://www.spinics.net/li...ux-usb/msg93739.html

    diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
    index daec6e0..8bbe1a9 100644
    --- a/drivers/usb/musb/musb_core.c
    +++ b/drivers/usb/musb/musb_core.c
    @@ -928,7 +928,7 @@ void musb_start(struct musb *musb)

    /* put into basic highspeed mode and start session */
    musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE
    - | MUSB_POWER_HSENAB
    + /* | MUSB_POWER_HSENAB */
    /* ENSUSPEND wedges tusb */
    /* | MUSB_POWER_ENSUSPEND */
    );



    However, I would prefer a solution that does not require a kernel re-compile. Do you have any other suggestions?

    Thanks for your help

    Matt
    steven.eckhoff
    Basic Member
    Basic Member
    Posts:192


    --
    18 Oct 2013 05:56 PM

    Matt,

     That method should work. If it is not working I will need to look into what is going on. 

     I will also look for an alternative.

    Matt Sacker
    New Member
    New Member
    Posts:4


    --
    21 Oct 2013 11:38 AM
    Hi Steven,

    I have tried your method a couple of times, but it seems the device still appears as a high speed device. Is there anyway to confirm the command has been received?

    Thanks for your help

    Matt
    steven.eckhoff
    Basic Member
    Basic Member
    Posts:192


    --
    21 Oct 2013 11:56 AM

    Matt,

    I will need to spend some time digging into this issue.

    Charlie Hamilton
    New Member
    New Member
    Posts:2


    --
    02 Nov 2018 04:17 PM
    Note that Steven's method only applies to running the controller in host mode. Note also that it will not work, per the OMAP TRM, you can't just set the full-speed bit. I added code to check for two more strings to set the controller into full speed test mode and kick off a test packet sequence into the debugfs in the function must_test_mode_write:

    
         if (!strncmp(buf, "host full", 9)) {
            // Per TEST_MODE reg documentation, host and fullspeed mode are
            // enabled when the session mode bit is set to 1. Clear it,
            // Configure the test mode register with host and fs set, then
            // write a 1 to the session bit.
            devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
            devctl &= ~MUSB_DEVCTL_SESSION;
            musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
    
    	test = MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_FS;
            musb_writeb(musb->mregs, MUSB_TESTMODE, test);
    
            musb_writeb(musb->mregs, MUSB_DEVCTL, devctl | MUSB_DEVCTL_SESSION);
            test = 0xFF;
        }
    
    	if (!strncmp(buf, "test packet full", 16)) {
    		test = MUSB_TEST_PACKET | MUSB_TEST_FORCE_HOST | MUSB_TEST_FORCE_FS;
    		musb_load_testpacket(musb);
    	}
    


    Note that test mode does not affect normal operation, and you should use Matt's brute force method of rebuilding the kernel.
    Charlie Hamilton
    New Member
    New Member
    Posts:2


    --
    02 Nov 2018 04:19 PM

    Note that I meant "running the controller in test mode" in the first sentence, not "host mode"



    ---