sec_charging_modprobe.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * sec_charging_modprobe.c
  3. * Samsung Mobile Battery Driver
  4. *
  5. * Copyright (C) 2021 Samsung Electronics
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include "sec_charging_modprobe.h"
  13. #define MODPROB_TIMEOUT 20000
  14. #if IS_MODULE(CONFIG_BATTERY_SAMSUNG)
  15. static struct dev_init_info gdev_init;
  16. void sec_chg_init_gdev(void)
  17. {
  18. gdev_init.dev = 0;
  19. init_waitqueue_head(&gdev_init.dev_wait);
  20. }
  21. int sec_chg_set_dev_init(unsigned int dev)
  22. {
  23. gdev_init.dev |= dev;
  24. wake_up(&gdev_init.dev_wait);
  25. return 0;
  26. }
  27. EXPORT_SYMBOL(sec_chg_set_dev_init);
  28. void sec_chg_check_modprobe(void)
  29. {
  30. unsigned int check_dev = 0;
  31. check_dev |= SC_DEV_FG | SC_DEV_MAIN_CHG;
  32. #if IS_ENABLED(CONFIG_DUAL_BATTERY)
  33. check_dev |= SC_DEV_MAIN_LIM | SC_DEV_SUB_LIM;
  34. #endif
  35. #if IS_ENABLED(CONFIG_DIRECT_CHARGING)
  36. check_dev |= SC_DEV_DIR_CHG | SC_DEV_SEC_DIR_CHG;
  37. #endif
  38. #if IS_ENABLED(CONFIG_WIRELESS_CHARGING)
  39. check_dev |= SC_DEV_WRL_CHG;
  40. #if IS_ENABLED(CONFIG_SB_MFC)
  41. check_dev |= SC_DEV_SB_MFC;
  42. #endif
  43. #endif
  44. if (!wait_event_timeout(gdev_init.dev_wait,
  45. gdev_init.dev == check_dev, msecs_to_jiffies(MODPROB_TIMEOUT)))
  46. pr_info("%s: dev_init timeout(0x%x)\n", __func__, gdev_init.dev);
  47. else
  48. pr_info("%s: takes time to wait(0x%x)\n", __func__, gdev_init.dev);
  49. }
  50. EXPORT_SYMBOL(sec_chg_check_modprobe);
  51. void sec_chg_check_dev_modprobe(unsigned int dev)
  52. {
  53. if (!wait_event_timeout(gdev_init.dev_wait,
  54. gdev_init.dev & dev, msecs_to_jiffies(MODPROB_TIMEOUT)))
  55. pr_info("%s: dev_init timeout(0x%x)\n", __func__, dev);
  56. else
  57. pr_info("%s: takes time to wait(0x%x)\n", __func__, dev);
  58. }
  59. EXPORT_SYMBOL(sec_chg_check_dev_modprobe);
  60. #else
  61. void sec_chg_init_gdev(void) { }
  62. int sec_chg_set_dev_init(unsigned int dev) { return 0; }
  63. void sec_chg_check_modprobe(void) { }
  64. void sec_chg_check_dev_modprobe(unsigned int dev) { }
  65. #endif