pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS


MAARAUCH-53 patch #001
Posted by Anonymous on Thu 27th Sep 2018 10:29
raw | new post

  1. diff --git a/ptxdist/local_src/common/hw/tle82353sa.cpp b/ptxdist/local_src/common/hw/tle82353sa.cpp
  2. index 08d2537..e3c5dc0 100644
  3. --- a/ptxdist/local_src/common/hw/tle82353sa.cpp
  4. +++ b/ptxdist/local_src/common/hw/tle82353sa.cpp
  5. @@ -29,6 +29,7 @@
  6.  #include <sys/ioctl.h>
  7.  #include <linux/spi/spidev.h>
  8.  #include <string.h>
  9. +#include <stdio.h>
  10.  #include <unistd.h>
  11.  #include "pca9505.h"
  12.  #include "tle82353sa.h"
  13. @@ -82,8 +83,8 @@ bool TLE82353SA::writeRegister(int hdl, unsigned char adr, unsigned long value)
  14.                 bRet = false;
  15.              }
  16.              else{
  17. -               /* on error the chip responses with TLE82353SA_ICVID_CONTENT */
  18. -               if( value == TLE82353SA_ICVID_CONTENT ){
  19. +               /* on error the chip responses with its "Reset Value" */
  20. +               if(TLE82353SA_RESET_VALUE_OK(value)){
  21.                    bRet = false;
  22.                 }
  23.                 else{
  24. @@ -127,7 +128,7 @@ bool TLE82353SA::readRegister(int hdl, unsigned char adr, unsigned long &value)
  25.               * and Manufacturer ID register (ICVID).
  26.               */
  27.              if( adr == REGISTER_ICVID ){
  28. -               if( value == TLE82353SA_ICVID_CONTENT ){
  29. +               if(TLE82353SA_RESET_VALUE_OK(value)){
  30.                    bRet = true;
  31.                 }
  32.                 else{
  33. @@ -136,8 +137,8 @@ bool TLE82353SA::readRegister(int hdl, unsigned char adr, unsigned long &value)
  34.                 }
  35.              }
  36.              else{
  37. -               /* on error the chip responses with TLE82353SA_ICVID_CONTENT */
  38. -               if( value == TLE82353SA_ICVID_CONTENT ){
  39. +               /* on error the chip responses with its "Reset Value" */
  40. +               if(TLE82353SA_RESET_VALUE_OK(value)){
  41.                    bRet = false;
  42.                 }
  43.                 else{
  44. @@ -153,29 +154,42 @@ bool TLE82353SA::readRegister(int hdl, unsigned char adr, unsigned long &value)
  45.  
  46.  bool TLE82353SA::initTLE( int hdl, unsigned long clkDividervalue, bool includeClkDivider, bool resetDiagRegister )
  47.  {
  48. -  
  49. -   bool bRet(false);
  50. -   unsigned long registerValue(0);
  51. +
  52. +   bool bRet;
  53. +   unsigned long registerValue;
  54.    
  55.     /* try to read a register from the chip
  56.      * Use the ICVID register here
  57.      */
  58. +   registerValue = 0UL;
  59.     bRet = TLE82353SA::readRegister( hdl, REGISTER_ICVID, registerValue );
  60. -   if( !bRet || registerValue !=  TLE82353SA_ICVID_CONTENT ){
  61. +(void)fprintf(stderr, "TLE82353SA::initTLE() try1, bRet=%d, registerValue=%lx\n",
  62. +       (int)bRet, (unsigned long)registerValue);
  63. +   if( !bRet || TLE82353SA_RESET_VALUE_OK(registerValue) ){
  64.        
  65.        //I2CFeature
  66.        /* the chip did not respond, maybe its in reset state.
  67.         * release the reset pin */
  68.        PCA9505::getInst().setOutput(PCA9505::RESET_HS_PWM, true, true);
  69. +
  70.        /* wait 3ms */
  71.        //TODO: minimal granularity of system timers, CONFIG_HZ=200Hz => 5ms
  72. -      usleep( 3000) ;
  73. +      (void)usleep(3000) ;
  74. +
  75.        /* try again reading register */
  76. +      registerValue = 0UL;
  77.        bRet = TLE82353SA::readRegister( hdl, REGISTER_ICVID, registerValue );
  78. -      if( bRet && registerValue == TLE82353SA_ICVID_CONTENT ){
  79. +(void)fprintf(stderr, "TLE82353SA::initTLE() try2, bRet=%d, registerValue=%lx\n",
  80. +       (int)bRet, (unsigned long)registerValue);
  81. +
  82. +      if( bRet && TLE82353SA_RESET_VALUE_OK(registerValue) ){
  83.              /* chip alive and responding! */
  84.              bRet = true;
  85.        }
  86. +      else
  87. +      {
  88. +            bRet = false;
  89. +      }
  90.     }
  91.    
  92.     if( resetDiagRegister ){
  93. diff --git a/ptxdist/local_src/common/hw/tle82353sa.h b/ptxdist/local_src/common/hw/tle82353sa.h
  94. index db1e950..1c09f78 100644
  95. --- a/ptxdist/local_src/common/hw/tle82353sa.h
  96. +++ b/ptxdist/local_src/common/hw/tle82353sa.h
  97. @@ -49,7 +49,19 @@ TLE82353SA
  98.  #define CHANNEL_LOAD1 0x01
  99.  #define CHANNEL_LOAD2 0x02
  100.  
  101. -#define TLE82353SA_ICVID_CONTENT 0x00C10400
  102. +/*
  103. + * TLE82453 Data Sheet (Rev 1.0, 2015-03-27) defines a "Reset Value" on
  104. + * page 53 as hex 00C1xx00) where "xx" is the version field.
  105. + * If you read the chip register use |TLE82353SA_IC_VERSION_MASK| to remove
  106. + * the IC version bit (15:8) contents from the value and then compare this
  107. + * to |TLE82353SA_MASKED_RESET_VALUE| to see whether the chip reset has been
  108. + * successful.
  109. + */
  110. +#define TLE82353SA_MASKED_RESET_VALUE  0x00C10000
  111. +#define TLE82353SA_IC_VERSION_MASK     0x0000FF00
  112. +#define TLE82353SA_RESET_VALUE_OK(regval) \
  113. +       (((regval) & ~TLE82353SA_IC_VERSION_MASK) == TLE82353SA_MASKED_RESET_VALUE)
  114. +
  115.  
  116.  /* global registers */
  117.  #define REGISTER_ICVID         0x00

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at