mtk_cooler_sysrst.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include <linux/version.h>
  2. #include <linux/kernel.h>
  3. #include <linux/module.h>
  4. #include <linux/thermal.h>
  5. #include <linux/platform_device.h>
  6. #include <mt-plat/aee.h>
  7. #include <linux/types.h>
  8. #include <linux/proc_fs.h>
  9. #include "mt-plat/mtk_thermal_monitor.h"
  10. #include "mtk_thermal_typedefs.h"
  11. #include "mach/mt_thermal.h"
  12. #include <mach/mt_clkmgr.h>
  13. #include <mt_ptp.h>
  14. #include <mach/wd_api.h>
  15. #include <linux/slab.h>
  16. #include <linux/seq_file.h>
  17. #include <tscpu_settings.h>
  18. /*=============================================================
  19. *Local variable definition
  20. *=============================================================*/
  21. static unsigned int cl_dev_sysrst_state;
  22. static struct thermal_cooling_device *cl_dev_sysrst;
  23. /*=============================================================*/
  24. /*
  25. * cooling device callback functions (tscpu_cooling_sysrst_ops)
  26. * 1 : ON and 0 : OFF
  27. */
  28. static int sysrst_cpu_get_max_state(struct thermal_cooling_device *cdev, unsigned long *state)
  29. {
  30. /* tscpu_dprintk("sysrst_cpu_get_max_state\n"); */
  31. *state = 1;
  32. return 0;
  33. }
  34. static int sysrst_cpu_get_cur_state(struct thermal_cooling_device *cdev, unsigned long *state)
  35. {
  36. /* tscpu_dprintk("sysrst_cpu_get_cur_state\n"); */
  37. *state = cl_dev_sysrst_state;
  38. return 0;
  39. }
  40. static int sysrst_cpu_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
  41. {
  42. cl_dev_sysrst_state = state;
  43. if (cl_dev_sysrst_state == 1) {
  44. tscpu_printk("sysrst_cpu_set_cur_state = 1\n");
  45. tscpu_printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
  46. tscpu_printk("*****************************************\n");
  47. tscpu_printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
  48. #ifndef CONFIG_ARM64
  49. BUG();
  50. #else
  51. *(unsigned int *)0x0 = 0xdead; /* To trigger data abort to reset the system for thermal protection. */
  52. #endif
  53. }
  54. return 0;
  55. }
  56. static struct thermal_cooling_device_ops mtktscpu_cooling_sysrst_ops = {
  57. .get_max_state = sysrst_cpu_get_max_state,
  58. .get_cur_state = sysrst_cpu_get_cur_state,
  59. .set_cur_state = sysrst_cpu_set_cur_state,
  60. };
  61. static int __init mtk_cooler_sysrst_init(void)
  62. {
  63. int err = 0;
  64. tscpu_dprintk("mtk_cooler_sysrst_init: Start\n");
  65. cl_dev_sysrst = mtk_thermal_cooling_device_register("mtktscpu-sysrst", NULL,
  66. &mtktscpu_cooling_sysrst_ops);
  67. if (err) {
  68. tscpu_printk("tscpu_register_DVFS_hotplug_cooler fail\n");
  69. return err;
  70. }
  71. tscpu_dprintk("mtk_cooler_sysrst_init: End\n");
  72. return 0;
  73. }
  74. static void __exit mtk_cooler_sysrst_exit(void)
  75. {
  76. tscpu_dprintk("mtk_cooler_sysrst_exit\n");
  77. if (cl_dev_sysrst) {
  78. mtk_thermal_cooling_device_unregister(cl_dev_sysrst);
  79. cl_dev_sysrst = NULL;
  80. }
  81. }
  82. module_init(mtk_cooler_sysrst_init);
  83. module_exit(mtk_cooler_sysrst_exit);