axp.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef AXP_H
  7. #define AXP_H
  8. #include <stdint.h>
  9. #define AXP20X_MODE_REG 0x3e
  10. #define AXP20X_MODE_I2C 0x00
  11. #define AXP20X_MODE_RSB 0x7c
  12. #define NA 0xff
  13. enum {
  14. AXP803_CHIP_ID = 0x41,
  15. AXP805_CHIP_ID = 0x40,
  16. };
  17. struct axp_regulator {
  18. const char *dt_name;
  19. uint16_t min_volt;
  20. uint16_t max_volt;
  21. uint16_t step;
  22. unsigned char split;
  23. unsigned char volt_reg;
  24. unsigned char switch_reg;
  25. unsigned char switch_bit;
  26. };
  27. extern const uint8_t axp_chip_id;
  28. extern const char *const axp_compatible;
  29. extern const struct axp_regulator axp_regulators[];
  30. /*
  31. * Since the PMIC can be connected to multiple bus types,
  32. * low-level read/write functions must be provided by the platform
  33. */
  34. int axp_read(uint8_t reg);
  35. int axp_write(uint8_t reg, uint8_t val);
  36. int axp_clrsetbits(uint8_t reg, uint8_t clr_mask, uint8_t set_mask);
  37. #define axp_clrbits(reg, clr_mask) axp_clrsetbits(reg, clr_mask, 0)
  38. #define axp_setbits(reg, set_mask) axp_clrsetbits(reg, 0, set_mask)
  39. int axp_check_id(void);
  40. void axp_power_off(void);
  41. #if SUNXI_SETUP_REGULATORS == 1
  42. void axp_setup_regulators(const void *fdt);
  43. #else
  44. static inline void axp_setup_regulators(const void *fdt)
  45. {
  46. }
  47. #endif
  48. #endif /* AXP_H */