axp209.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2012 Henrik Nordstrom <henrik@henriknordstrom.net>
  4. */
  5. #include <linux/bitops.h>
  6. enum axp209_reg {
  7. AXP209_POWER_STATUS = 0x00,
  8. AXP209_CHIP_VERSION = 0x03,
  9. AXP209_OUTPUT_CTRL = 0x12,
  10. AXP209_DCDC2_VOLTAGE = 0x23,
  11. AXP209_VRC_DCDC2_LDO3 = 0x25,
  12. AXP209_DCDC3_VOLTAGE = 0x27,
  13. AXP209_LDO24_VOLTAGE = 0x28,
  14. AXP209_LDO3_VOLTAGE = 0x29,
  15. AXP209_IRQ_ENABLE1 = 0x40,
  16. AXP209_IRQ_ENABLE2 = 0x41,
  17. AXP209_IRQ_ENABLE3 = 0x42,
  18. AXP209_IRQ_ENABLE4 = 0x43,
  19. AXP209_IRQ_ENABLE5 = 0x44,
  20. AXP209_IRQ_STATUS5 = 0x4c,
  21. AXP209_SHUTDOWN = 0x32,
  22. };
  23. #define AXP209_POWER_STATUS_ON_BY_DC BIT(0)
  24. #define AXP209_POWER_STATUS_VBUS_USABLE BIT(4)
  25. #define AXP209_CHIP_VERSION_MASK 0x0f
  26. #define AXP209_OUTPUT_CTRL_EXTEN BIT(0)
  27. #define AXP209_OUTPUT_CTRL_DCDC3 BIT(1)
  28. #define AXP209_OUTPUT_CTRL_LDO2 BIT(2)
  29. #define AXP209_OUTPUT_CTRL_LDO4 BIT(3)
  30. #define AXP209_OUTPUT_CTRL_DCDC2 BIT(4)
  31. #define AXP209_OUTPUT_CTRL_LDO3 BIT(6)
  32. /*
  33. * AXP209 datasheet contains wrong information about LDO3 VRC:
  34. * - VRC is actually enabled when BIT(1) is True
  35. * - VRC is actually not enabled by default (BIT(3) = 0 after reset)
  36. */
  37. #define AXP209_VRC_LDO3_EN BIT(3)
  38. #define AXP209_VRC_DCDC2_EN BIT(2)
  39. #define AXP209_VRC_LDO3_800uV_uS (BIT(1) | AXP209_VRC_LDO3_EN)
  40. #define AXP209_VRC_LDO3_1600uV_uS AXP209_VRC_LDO3_EN
  41. #define AXP209_VRC_DCDC2_800uV_uS (BIT(0) | AXP209_VRC_DCDC2_EN)
  42. #define AXP209_VRC_DCDC2_1600uV_uS AXP209_VRC_DCDC2_EN
  43. #define AXP209_VRC_LDO3_MASK 0xa
  44. #define AXP209_VRC_DCDC2_MASK 0x5
  45. #define AXP209_VRC_DCDC2_SLOPE_SET(reg, cfg) \
  46. (((reg) & ~AXP209_VRC_DCDC2_MASK) | \
  47. ((cfg) & AXP209_VRC_DCDC2_MASK))
  48. #define AXP209_VRC_LDO3_SLOPE_SET(reg, cfg) \
  49. (((reg) & ~AXP209_VRC_LDO3_MASK) | \
  50. ((cfg) & AXP209_VRC_LDO3_MASK))
  51. #define AXP209_LDO24_LDO2_MASK 0xf0
  52. #define AXP209_LDO24_LDO4_MASK 0x0f
  53. #define AXP209_LDO24_LDO2_SET(reg, cfg) \
  54. (((reg) & ~AXP209_LDO24_LDO2_MASK) | \
  55. (((cfg) << 4) & AXP209_LDO24_LDO2_MASK))
  56. #define AXP209_LDO24_LDO4_SET(reg, cfg) \
  57. (((reg) & ~AXP209_LDO24_LDO4_MASK) | \
  58. (((cfg) << 0) & AXP209_LDO24_LDO4_MASK))
  59. #define AXP209_LDO3_VOLTAGE_FROM_LDO3IN BIT(7)
  60. #define AXP209_LDO3_VOLTAGE_MASK 0x7f
  61. #define AXP209_LDO3_VOLTAGE_SET(x) ((x) & AXP209_LDO3_VOLTAGE_MASK)
  62. #define AXP209_IRQ5_PEK_UP BIT(6)
  63. #define AXP209_IRQ5_PEK_DOWN BIT(5)
  64. #define AXP209_POWEROFF BIT(7)
  65. /* For axp_gpio.c */
  66. #define AXP_POWER_STATUS 0x00
  67. #define AXP_POWER_STATUS_VBUS_PRESENT BIT(5)
  68. #define AXP_GPIO0_CTRL 0x90
  69. #define AXP_GPIO1_CTRL 0x92
  70. #define AXP_GPIO2_CTRL 0x93
  71. #define AXP_GPIO_CTRL_OUTPUT_LOW 0x00 /* Drive pin low */
  72. #define AXP_GPIO_CTRL_OUTPUT_HIGH 0x01 /* Drive pin high */
  73. #define AXP_GPIO_CTRL_INPUT 0x02 /* Input */
  74. #define AXP_GPIO_STATE 0x94
  75. #define AXP_GPIO_STATE_OFFSET 4