schgm-flash.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018, 2020 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __SCHGM_FLASH_H__
  7. #define __SCHGM_FLASH_H__
  8. #include <linux/bitops.h>
  9. #define SCHGM_FLASH_BASE 0xA600
  10. #define SCHGM_FLASH_STATUS_2_REG (SCHGM_FLASH_BASE + 0x07)
  11. #define VREG_OK_BIT BIT(4)
  12. #define SCHGM_FLASH_STATUS_3_REG (SCHGM_FLASH_BASE + 0x08)
  13. #define FLASH_STATE_MASK GENMASK(2, 0)
  14. #define FLASH_ERROR_VAL 0x7
  15. #define SCHGM_FLASH_INT_RT_STS_REG (SCHGM_FLASH_BASE + 0x10)
  16. #define SCHGM_FLASH_STATUS_5_REG (SCHGM_FLASH_BASE + 0x0B)
  17. #define SCHGM_FORCE_BOOST_CONTROL (SCHGM_FLASH_BASE + 0x41)
  18. #define FORCE_FLASH_BOOST_5V_BIT BIT(0)
  19. #define SCHGM_FLASH_S2_LATCH_RESET_CMD_REG (SCHGM_FLASH_BASE + 0x44)
  20. #define FLASH_S2_LATCH_RESET_BIT BIT(0)
  21. #define SCHGM_FLASH_CONTROL_REG (SCHGM_FLASH_BASE + 0x60)
  22. #define SOC_LOW_FOR_FLASH_EN_BIT BIT(7)
  23. #define SCHGM_TORCH_PRIORITY_CONTROL_REG (SCHGM_FLASH_BASE + 0x63)
  24. #define TORCH_PRIORITY_CONTROL_BIT BIT(0)
  25. #define SCHGM_SOC_BASED_FLASH_DERATE_TH_CFG_REG (SCHGM_FLASH_BASE + 0x67)
  26. #define SCHGM_SOC_BASED_FLASH_DISABLE_TH_CFG_REG \
  27. (SCHGM_FLASH_BASE + 0x68)
  28. enum torch_mode {
  29. TORCH_BUCK_MODE = 0,
  30. TORCH_BOOST_MODE,
  31. };
  32. int schgm_flash_get_vreg_ok(struct smb_charger *chg, int *val);
  33. void schgm_flash_torch_priority(struct smb_charger *chg, enum torch_mode mode);
  34. int schgm_flash_init(struct smb_charger *chg);
  35. bool is_flash_active(struct smb_charger *chg);
  36. irqreturn_t smb5_schgm_flash_default_irq_handler(int irq, void *data);
  37. irqreturn_t smb5_schgm_flash_ilim2_irq_handler(int irq, void *data);
  38. irqreturn_t smb5_schgm_flash_state_change_irq_handler(int irq, void *data);
  39. #endif /* __SCHGM_FLASH_H__ */