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.

usb to uart

Dear TI E2e community,

Am following the below link inorder to convert the existing USB1 to UART3, as am new to dts, I hope the usb_ctrl1 register ie., USB_CTRL1 register i.e, bit 12 GPIO MODE(UART1) needs to be set to 1 in dts as am using TI SDK 7,

e2e.ti.com/.../1423544

Could anybody please let me know how this configuration can be done in dts as the above link doesn't explain about how to do it in dts

Kindly do the needful as early as possible,

Awaiting for your replies,

Many Many Thanks in advance,

  • Hi Srini,

    If you read the TRM well you will find the solution of your question. Please see the:
    Figure 16-2. USB GPIO Integration
    0: USB
    1: GPIO Mode (UART Mode)
    also
    9.2.4.4.1 USB Control and Status
    The USB_STS1 register gives the status of the USB PHY module. Read this register to see if your setting is correct.

    BR
    ivan
  • Dear Ivan,

    1) Could you please just first confirm what are all the changes that needs to be done in the source code, ie., Does the below changes is sufficient inorder to convert USB1 to UART3?.. or any other changes needs to be done in the source code apart from this??? does it require whether it requires uboot changes also??? as am using UART3 for only transmission & reception of data purposes only & not for debugging purpose

    diff --git a/code/linux-3.12.10-ti2013.12.01/drivers/usb/phy/phy-am335x-control.c b/code/linux-3.12.10-ti2013.12.01/drivers/usb/phy/phy-am335x-control.c

    index 634f49a..578d561 100644

    --- a/code/linux-3.12.10-ti2013.12.01/drivers/usb/phy/phy-am335x-control.c

    +++ b/code/linux-3.12.10-ti2013.12.01/drivers/usb/phy/phy-am335x-control.c

    @@ -26,6 +26,13 @@ struct am335x_control_usb {

    #define USBPHY_OTGVDET_EN      (1 << 19)

    #define USBPHY_OTGSESSEND_EN   (1 << 20)

    +#define USBPHY_CHGDET_DIS              (1 << 2)

    +#define USBPHY_GPIO_MODE               (1 << 12)

    +#define USBPHY_GPIO_SIG_INV            (1 << 13)

    +#define USBPHY_GPIO_SIG_CROSS          (1 << 14)

    +#define USBPHY_DPGPIO_PD               (1 << 17)

    +#define USBPHY_DMGPIO_PD               (1 << 18)

    +

    #define AM335X_PHY0_WK_EN      (1 << 0)

    #define AM335X_PHY1_WK_EN      (1 << 8)

    @@ -72,24 +79,36 @@ static void am335x_phy_power(struct phy_control *phy_ctrl, u32 id, bool on)

           switch (id) {

           case 0:

                   reg = AM335X_USB0_CTRL;

    +               val = readl(usb_ctrl->phy_reg + reg);

    +               if (on) {

    +                               val &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN);

    +                               val |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN;

    +                       }

    +               else

    +                       {

    +                               val |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;

    +                       }

    +

    +               writel(val, usb_ctrl->phy_reg + reg);

                   break;

           case 1:

                   reg = AM335X_USB1_CTRL;

    +               val = readl(usb_ctrl->phy_reg + reg);

    +               if (on) {

    +                               val &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN | USBPHY_CHGDET_DIS | USBPHY_GPIO_SIG_INV | USBPHY_GPIO_SIG_CROSS | USBPHY_DPGPIO_PD | USBPHY_DMGPIO_PD);

    +                               val |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN | USBPHY_GPIO_MODE;

    +                       }

    +               else

    +                       {

    +                               val |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;

    +                       }

    +

    +               writel(val, usb_ctrl->phy_reg + reg);

                   break;

           default:

                   WARN_ON(1);

                   return;

           }

    -

    -       val = readl(usb_ctrl->phy_reg + reg);

    -       if (on) {

    -               val &= ~(USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN);

    -               val |= USBPHY_OTGVDET_EN | USBPHY_OTGSESSEND_EN;

    -       } else {

    -               val |= USBPHY_CM_PWRDN | USBPHY_OTG_PWRDN;

    -       }

    -

    -       writel(val, usb_ctrl->phy_reg + reg);

    }

    static const struct phy_control ctrl_am335x = {

    4. In dts,

    uart3: serial@481a6000 {

                         status = "okay";

                    };

    5.  usb-phy@47401b00 {

    status = "okay";

    };

    usb@47401800 {

    status = "okay";

    };

    2) Once USB1 to UART3 is converted , could you please let me know how UART3 can be verified, as am using UART3 for only transmission & reception of data purposes only

    Kindly do the needful as early as possible

    Awaiting for your replies,

    Many Thanks in advance

     

  • Thanks a lot for your support Ivan,

    With the above changes, I got my USB1 to UART3 up & working, & verified the transmission & reception

    Once again many Thanks Ivan
  • Hi Srini,

    It seems that this code is correct. But in dts file you have to add (I get this tx/rx pins for example - you can use other and pinmux will the other):

    am33xx_pinmux: pinmux@44e10800 {
    ...
    uart3_pins: pinmux_uart3_pins {
    pinctrl-single,pins = <
    0x160 (PIN_INPUT | MUX_MODE1) /* SPI0_CS1.uart3_rxd (PIN_INPUT_PULLUP/PULLDOWN ) */
    0x164 (PIN_OUTPUT | MUX_MODE1) /* ECAP0_IN_PWM0_OUT.uart3_txd (PIN_OUTPUT_PULLUP/PULLDOWN) */
    >;
    };


    ocp {
    ...
    uart3: serial@481A6000 {
    pinctrl-names = "default";
    pinctrl-0 = <&uart3_pins>;

    status = "okay";
    };


    You can verified if UART3 works from user space with commands:
    echo 'xxxxxxx' > /dev/ttyO1 - send data out
    cat /dev/ttyO1 - receive data from ...
    and if you connect this UART3 to PC with application as microcom you have to see communication (if uart3 works)

    BR
    Ivan
  • Thanks a lot Ivan for your inputs & I will take care this inputs as well,

    Many Many Thanks a lot Ivan once again