Guest User

459_x1000_Debug_SocID.diff

a guest
Aug 25th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.65 KB | Source Code | 0 0
  1. Debug_SocID.diff
  2.  
  3. optional Show CPU X1000 SocID stored in EFUSE  (under Debug->View HW Info->Audio)
  4. copied and coding style transformed for Rockbox from Original Mess at
  5. github FiiO_Kernel_M3K/arch/mips/xburst/soc-x1000/common/socid.c
  6.  
  7. (Credit) ZappBranigan2972 on forums / F. Jacobsen on the Theme Site
  8.  
  9. ---
  10.  
  11. --- a/firmware/target/mips/ingenic_x1000/debug-x1000.c.orig 2024-08-01 12:25:50.731598530 +0200
  12. +++ b/firmware/target/mips/ingenic_x1000/debug-x1000.c  2024-08-01 12:18:41.223494647 +0200
  13. @@ -32,6 +32,66 @@
  14.  #include "gpio-x1000.h"
  15.  #include "lcd-x1000.h"
  16.  
  17. +/* X1000 SocID, copied and coding style transformed for Rockbox      *
  18. + * From github FiiO_Kernel_M3K/arch/mips/xburst/soc-x1000/common/socid.c */
  19. +
  20. +#include <x1000/cpm.h>
  21. +#include <x1000/efuse.h>
  22. +
  23. +static int32_t x1000_socid;
  24. +
  25. +enum socid {
  26. +    ID_X1000 = 0xff00,
  27. +    ID_X1000E = 0xff01,
  28. +    ID_X1500 = 0xff02,
  29. +    ID_X1000_NEW = 0xff08,
  30. +    ID_X1000E_NEW = 0xff09,
  31. +    ID_X1500_NEW = 0xff0a,
  32. +};
  33. +
  34. +uint32_t read_socid(void) {
  35. +    uint32_t val = 0, timeout = 100;
  36. +    int ret = 0;
  37. +
  38. +    jz_writef(CPM_CLKGR, EFUSE(0)); // EFUSE Clk on
  39. +    jz_write(EFUSE_STATE, 0);
  40. +
  41. +    val = 0x3c << 21 | 1 << 16 | 1; // Addr 0x3c | Length 0x01 | READ
  42. +    jz_write(EFUSE_CTRL, val);
  43. +
  44. +    while(!jz_readf(EFUSE_STATE, RD_DONE)) {
  45. +        if(!timeout--) {
  46. +            ret = -1;
  47. +            goto efuse_fail;
  48. +        }
  49. +    }
  50. +    ret = REG_EFUSE_DATA(0); // Read one Entry
  51. +
  52. +efuse_fail:
  53. +    jz_writef(CPM_CLKGR, EFUSE(1));  // EFUSE Clk off
  54. +    return ret;
  55. +}
  56. +
  57. +void debug_socid(void) {
  58. +    char str[12];
  59. +    if (x1000_socid < 0) {
  60. +        lcd_puts(0, 17, "socid: efuse busy !\n");
  61. +        return;
  62. +    }
  63. +#define ID(_ID) snprintf(str, sizeof(str), "%s", _ID); break
  64. +    switch(x1000_socid) {
  65. +        case ID_X1000:      ID("X1000");
  66. +        case ID_X1000E:     ID("X1000E");
  67. +        case ID_X1500:      ID("X1500");
  68. +        case ID_X1000_NEW:  ID("X1000_NEW");
  69. +        case ID_X1000E_NEW: ID("X1000E_NEW");
  70. +        case ID_X1500_NEW:  ID("X1500_NEW");
  71. +        default:            ID("unknown");
  72. +    }
  73. +    lcd_putsf(0, 17, "SocID: %0x, %s", x1000_socid, str);
  74. +#undef ID
  75. +}
  76. +
  77.  static bool dbg_clocks(void)
  78.  {
  79.      do {
  80. @@ -145,6 +205,7 @@
  81.          }
  82.  #endif
  83.          debug_x1000_lcd();
  84. +        debug_socid();
  85.          lcd_update();
  86.      } while(get_action(CONTEXT_STD, HZ) != ACTION_STD_CANCEL);
  87.  
  88. @@ -241,6 +302,7 @@
  89.  
  90.  bool dbg_hw_info(void)
  91.  {
  92. +    x1000_socid = read_socid();
  93.      struct simplelist_info info;
  94.      simplelist_info_init(&info, MODEL_NAME " debug menu",
  95.                           ARRAYLEN(menuitems), NULL);
  96.  
Tags: debug rockbox
Advertisement
Add Comment
Please, Sign In to add comment