6 Replies Latest reply on Jun 7, 2020 10:59 PM by PrRe_3492461

    USB3.0 / USB2.0 PHY Register Runtime Configuration

    PrRe_3492461

      Hello Cypress Community,

      Need little help here.

       

      I'm Using Fx3 for my development.

      My requirement is to configure USB3.0,2.0 Swing and Emphasis

      for which I need to Configure PHY_CONF and LNK_PHY_TX_TRIM_REG in runtime

      but After I writing a Value 0xb5a501a to LNK_PHY_TX_TRIM_REG and 0x14a480 to PHY_CONF and

      Performing an Re-enumeration process by using CyU3PConnectState();

      In Both USB2.0 and USB3.0 Case whatever the value I'm writing into these registers are not being retrieved after re-enumeration process

      which means configured values are not taKing affect.

       

      Am I wrong anywhere or Am I missing anything that needs to be added while writing values to the register directly ??

      Can I know on what condition will these registers set back to default ??

       

      This is my code snippet for configuring register :

       

      aRegAddr : Address of the register in which value needs to be writtern

      aRegValue : Value that needs to be written.

      void ConfigReg(uint32_t aRegAddr , uint32_t aRegValue)

      {

          uint32_t LNK_PHY_REG_VAL = (uint32_t*) (aRegAddr);

          *LNK_PHY_REG_VAL = aRegValue;

      }

       

      Thanks in Advance.

       

      Regards,

      Pranay.

        • 1. Re: USB3.0 / USB2.0 PHY Register Runtime Configuration
          RashiV_61

          Hello Pranay,

           

          Please try calling CyU3PUsbSetTxSwing API to set the TX Swing.

          This API sets the Tx amplitude used by FX3 on the USB 3.0 interface. Please use this API with caution. The device has only been tested to work properly under the default swing setting of 0.9V (swing value set to 90). This API is expected to be called before calling the CyU3PConnectState() API to enable USB connections.

           

          I have modified the UsbBulksrcsink example of the SDK to set the txswing to 120 and reading the USB3LNK->lnk_phy_tx_trim register using vendor command 0x83.

           

          The results and the firmware are in the attachment

           

          You can also go through the source code of the CyU3PUsbSetTxSwing API in the SDK to implement custom API

           

           

          Regards,

          Rashi

          • 2. Re: USB3.0 / USB2.0 PHY Register Runtime Configuration
            PrRe_3492461

            Hello Rashi,

             

            Thanks for your reply.

             

            I've gone through the API sheet and already using CyU3PUsbSetTxSwing API for configuring TX swing in3.0 mode.

            But How do I Configure swing by access Register directly without using API ?

            and How do I Configure swing for USB2.0 mode ?

             

            Regards,

            Pranay.

            • 3. Re: USB3.0 / USB2.0 PHY Register Runtime Configuration
              RashiV_61

              Hello Pranay,

               

              Please refer to the FX3 TRM section 10.15.10, which mentions the address of the LNK_PHY_TX_TRIM register which is being written in CyU3PUsbSetTxSwing API.

               

              You can use this to write the tx swing value to the register. Call this after calling CyU3PConnectState API.

               

              uvint32_t *tx_swing      = (uvint32_t*) 0xE003303C; //global var

              uint32_t swing  = 120; //global  var

              ........

              ....

              apiRetStatus = CyU3PConnectState(CyTrue, CyTrue);

                      if (apiRetStatus != CY_U3P_SUCCESS)

                      {

                          CyU3PDebugPrint (4, "USB Connect failed, Error code = %d\n", apiRetStatus);

                          CyFxAppErrorHandler(apiRetStatus);

                      }

              *tx_swing           =  ((*tx_swing & ~(0x001fc000)) | (swing << 14));

               

               

              Please refer to section 10.10 of FX3 TRM for USB 2.0 registers that are supported.

               

              Regards,

              Rashi

              • 4. Re: USB3.0 / USB2.0 PHY Register Runtime Configuration
                PrRe_3492461

                Hello Rashi,

                 

                As I've already mentioned in above query, I'm Accessing the registers using the respective addresses as mentioned in TRM.

                 

                And As per my understanding of TRM ,

                LNK_PHY_TX_TRIM and PHY_CONF are Read and Writeable from user space.

                So we should be able to read and write these registers. correct ?

                I'm using below method to write :

                uvint32_t *tx_swing_Reg      = (uvint32_t*) RegAddress; //As per TRM Respective Register Address

                *tx_swing_Reg =  ConfigVal; //Config Value which I want to write into a Register.

                 

                After Wrtiting I'm able to read data back,

                But These values are being over writtern by library after a Re-enumeration process.(CyU3PConnectState disconnect and connect)

                 

                Is this behavior expected ?

                If yes.If I wan't keep my custom values to those registers, In which sequence I need to write to retain those values even after re-enumeration?

                 

                What could be the reason for theses values being overwritten by library after a re-enumeration process ??

                 

                 

                 

                 

                 

                 

                Regards,

                Pranay.

                • 5. Re: USB3.0 / USB2.0 PHY Register Runtime Configuration
                  RashiV_61

                  Hello Pranay,

                   

                  So we should be able to read and write these registers. correct ?

                  >> Yes, your understanding is correct.

                   

                  What could be the reason for theses values being overwritten by library after a re-enumeration process ?? Is this behavior expected ?

                  >> Yes, this is expected.

                  If the register is written (*tx_swing_Reg =  ConfigVal; ) before calling  CyU3PConnectState  the register will be overwritten as  CyU3PConnectState API enables the USB PHY and writes the default value (stored in a global variable glUsb3TxTrimVal) to LNK_PHY_TX_TRIM  register.

                   

                  When the CyU3PUsbSetTxSwing API is used the global variable (in which the value to be written to the register is stored) is modified. So, when CyU3PConnectState API is called after the CyU3PUsbSetTxSwing API, the updated value of the global variable (glUsb3TxTrimVal) is written to the LNK_PHY_TX_TRIM register.

                   

                   

                  If yes. If I want to keep my custom values to those registers, In which sequence I need to write to retain those values even after re-enumeration?

                  >>  As mentioned in my previous response either you can set the value of the register after calling CyU3PConnectState API

                  apiRetStatus = CyU3PConnectState(CyTrue, CyTrue);

                          if (apiRetStatus != CY_U3P_SUCCESS)

                          {

                              CyU3PDebugPrint (4, "USB Connect failed, Error code = %d\n", apiRetStatus);

                              CyFxAppErrorHandler(apiRetStatus);

                          }

                  *tx_swing           =  ((*tx_swing & ~(0x001fc000)) | (swing << 14));

                   

                  or

                   

                  You can use custom API , similar to CyU3PUsbSetTxSwing API, which will update the global variable which is used to write LNK_PHY_TX_TRIM register in the CyU3PConnectState API.

                   

                  You can also refer to RESPONSE 13 or the answer of this thread Force Link Training where I have shared the firmware and modified the second stage bootloader to set the LNK_PHY_TX_TRIM register without using the API.

                   

                  You can refer to the source code of the CyU3PUsbSetTxSwing API in the SDK.

                  Path: SDK installation path\Cypress\EZ-USB FX3 SDK\1.3\firmware

                   

                  Regards,

                  Rashi

                   

                   

                   

                  1 of 1 people found this helpful
                  • 6. Re: USB3.0 / USB2.0 PHY Register Runtime Configuration
                    PrRe_3492461

                    Hi RashiV_61,

                     

                    Thanks for the input.

                    Now I'm able to successfully retain the custom values after re-enumeration by following above suggested sequence.

                     

                    But I don't have a setup right now to verify whether the value whatever I'm configuring to the register is taking effect or not.

                    I've only read the register after writing,I'm able to retain.

                     

                    I'll get back to you on this.

                     

                    Thanks and regards,

                    Pranay