mt_power_gs-v1.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include <linux/init.h>
  2. #include <linux/kernel.h>
  3. #include <linux/module.h>
  4. #include <linux/proc_fs.h>
  5. #include <mt-plat/aee.h>
  6. #include <mt-plat/upmu_common.h>
  7. #include "mt_power_gs_array.h"
  8. #define gs_read(addr) (*(volatile u32 *)(addr))
  9. struct proc_dir_entry *mt_power_gs_dir = NULL;
  10. #define DEBUG_BUF_SIZE 200
  11. static char dbg_buf[DEBUG_BUF_SIZE] = { 0 };
  12. static u16 gs_pmic_read(u16 reg)
  13. {
  14. u32 ret = 0;
  15. u32 reg_val = 0;
  16. ret = pmic_read_interface_nolock(reg, &reg_val, 0xFFFF, 0x0);
  17. return (u16)reg_val;
  18. }
  19. static void mt_power_gs_compare(char *scenario, char *pmic_name,
  20. const unsigned int *pmic_gs, unsigned int pmic_gs_len)
  21. {
  22. unsigned int i, k, val1, val2, diff;
  23. char *p;
  24. pr_warn("Scenario - PMIC - Addr - Value - Mask - Golden - Wrong Bit\n");
  25. for (i = 0; i < pmic_gs_len; i += 3) {
  26. aee_sram_printk("%d\n", i);
  27. val1 = gs_pmic_read(pmic_gs[i]) & pmic_gs[i + 1];
  28. val2 = pmic_gs[i + 2] & pmic_gs[i + 1];
  29. if (val1 != val2) {
  30. p = dbg_buf;
  31. p += sprintf(p, "%s - %s - 0x%x - 0x%04x - 0x%04x - 0x%04x -",
  32. scenario, pmic_name, pmic_gs[i], gs_pmic_read(pmic_gs[i]),
  33. pmic_gs[i + 1], pmic_gs[i + 2]);
  34. for (k = 0, diff = val1 ^ val2; diff != 0; k++, diff >>= 1) {
  35. if ((diff % 2) != 0)
  36. p += sprintf(p, " %d", k);
  37. }
  38. pr_warn("%s\n", dbg_buf);
  39. }
  40. }
  41. }
  42. void mt_power_gs_dump_suspend(void)
  43. {
  44. #ifdef CONFIG_ARCH_MT6580
  45. mt_power_gs_compare("Suspend ", "6325",
  46. MT6325_PMIC_REG_gs_flightmode_suspend_mode,
  47. MT6325_PMIC_REG_gs_flightmode_suspend_mode_len);
  48. #elif defined CONFIG_ARCH_MT6735 || defined CONFIG_ARCH_MT6735M || defined CONFIG_ARCH_MT6753
  49. mt_power_gs_compare("Suspend ", "6328",
  50. MT6328_PMIC_REG_gs_flightmode_suspend_mode,
  51. MT6328_PMIC_REG_gs_flightmode_suspend_mode_len);
  52. #elif defined CONFIG_ARCH_MT6755 || defined CONFIG_ARCH_MT6797
  53. mt_power_gs_compare("Suspend ", "6351",
  54. MT6351_PMIC_REG_gs_flightmode_suspend_mode,
  55. MT6351_PMIC_REG_gs_flightmode_suspend_mode_len);
  56. #endif
  57. }
  58. EXPORT_SYMBOL(mt_power_gs_dump_suspend);
  59. void mt_power_gs_dump_dpidle(void)
  60. {
  61. #if defined CONFIG_ARCH_MT6755 || defined CONFIG_ARCH_MT6797
  62. mt_power_gs_compare("DPIdle ", "6351",
  63. MT6351_PMIC_REG_gs_early_suspend_deep_idle__mode,
  64. MT6351_PMIC_REG_gs_early_suspend_deep_idle__mode_len);
  65. #endif
  66. }
  67. EXPORT_SYMBOL(mt_power_gs_dump_dpidle);
  68. static void __exit mt_power_gs_exit(void)
  69. {
  70. }
  71. static int __init mt_power_gs_init(void)
  72. {
  73. mt_power_gs_dir = proc_mkdir("mt_power_gs", NULL);
  74. if (!mt_power_gs_dir)
  75. pr_err("[%s]: mkdir /proc/mt_power_gs failed\n", __func__);
  76. return 0;
  77. }
  78. module_init(mt_power_gs_init);
  79. module_exit(mt_power_gs_exit);
  80. MODULE_DESCRIPTION("MT Low Power Golden Setting");