axp2101.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2020 allwinnertech Ltd.
  3. */
  4. #include <sunxi_hal_regulator.h>
  5. #include <sunxi_hal_regulator_private.h>
  6. #include <type.h>
  7. #define AXP2101_DCDC_CFG0 (0x80)
  8. #define AXP2101_DCDC1_CFG (0x82)
  9. #define AXP2101_DCDC2_CFG (0x83)
  10. #define AXP2101_DCDC3_CFG (0x84)
  11. #define AXP2101_DCDC4_CFG (0x85)
  12. #define AXP2101_DCDC5_CFG (0x86)
  13. #define AXP2101_LDO_EN_CFG0 (0x90)
  14. #define AXP2101_LDO_EN_CFG1 (0x91)
  15. #define AXP2101_ALDO1_CFG (0x92)
  16. #define AXP2101_ALDO2_CFG (0x93)
  17. #define AXP2101_ALDO3_CFG (0x94)
  18. #define AXP2101_ALDO4_CFG (0x95)
  19. #define AXP2101_BLDO1_CFG (0x96)
  20. #define AXP2101_BLDO2_CFG (0x97)
  21. #define AXP2101_CPUSLD_CFG (0x98)
  22. #define AXP2101_DLDO1_CFG (0x99)
  23. #define AXP2101_DLDO2_CFG (0x9A)
  24. static const struct regulator_linear_range axp2101_dcdc2_ranges[] = {
  25. REGULATOR_LINEAR_RANGE(500000, 0x0, 0x46, 10000),
  26. REGULATOR_LINEAR_RANGE(1220000, 0x47, 0x57, 20000),
  27. };
  28. static const struct regulator_linear_range axp2101_dcdc3_ranges[] = {
  29. REGULATOR_LINEAR_RANGE(500000, 0x0, 0x46, 10000),
  30. REGULATOR_LINEAR_RANGE(1220000, 0x47, 0x57, 20000),
  31. REGULATOR_LINEAR_RANGE(1600000, 0x58, 0x6a, 100000),
  32. };
  33. static const struct regulator_linear_range axp2101_dcdc4_ranges[] = {
  34. REGULATOR_LINEAR_RANGE(500000, 0x0, 0x46, 10000),
  35. REGULATOR_LINEAR_RANGE(1220000, 0x47, 0x66, 20000),
  36. };
  37. static const struct regulator_linear_range axp2101_dcdc5_ranges[] = {
  38. REGULATOR_LINEAR_RANGE(1400000, 0x0, 0x17, 100000),
  39. REGULATOR_LINEAR_RANGE(1200000, 0x19, 0x19, 0),
  40. };
  41. const struct regulator_desc axp2101_regulators[] = {
  42. AXP_DESC(1500, 3400, 100, AXP2101_DCDC1_CFG, 0x1f,
  43. AXP2101_DCDC_CFG0, BIT(0)),
  44. AXP_DESC_RANGES(axp2101_dcdc2_ranges, AXP2101_DCDC2_CFG, 0x7f,
  45. AXP2101_DCDC_CFG0, BIT(1)),
  46. AXP_DESC_RANGES(axp2101_dcdc3_ranges, AXP2101_DCDC3_CFG, 0x7f,
  47. AXP2101_DCDC_CFG0, BIT(2)),
  48. AXP_DESC_RANGES(axp2101_dcdc4_ranges, AXP2101_DCDC4_CFG, 0x7f,
  49. AXP2101_DCDC_CFG0, BIT(3)),
  50. AXP_DESC_RANGES(axp2101_dcdc5_ranges, AXP2101_DCDC5_CFG, 0x1f,
  51. AXP2101_DCDC_CFG0, BIT(4)),
  52. AXP_DESC(500, 3500, 100, AXP2101_ALDO1_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
  53. BIT(0)),
  54. AXP_DESC(500, 3500, 100, AXP2101_ALDO2_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
  55. BIT(1)),
  56. AXP_DESC(500, 3500, 100, AXP2101_ALDO3_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
  57. BIT(2)),
  58. AXP_DESC(500, 3500, 100, AXP2101_ALDO4_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
  59. BIT(3)),
  60. AXP_DESC(500, 3500, 100, AXP2101_BLDO1_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
  61. BIT(4)),
  62. AXP_DESC(500, 3500, 100, AXP2101_BLDO2_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
  63. BIT(5)),
  64. AXP_DESC(500, 3500, 100, AXP2101_DLDO1_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
  65. BIT(7)),
  66. AXP_DESC(500, 1400, 50, AXP2101_DLDO2_CFG, 0x1f, AXP2101_LDO_EN_CFG1,
  67. BIT(0)),
  68. AXP_DESC(500, 1400, 50, AXP2101_CPUSLD_CFG, 0x1f, AXP2101_LDO_EN_CFG0,
  69. BIT(6)),
  70. };