kernel_002_power.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c
  2. index 17fecb156..2409b5ee1 100644
  3. --- a/drivers/mfd/axp20x.c
  4. +++ b/drivers/mfd/axp20x.c
  5. @@ -1644,6 +1644,7 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
  6. return ret;
  7. }
  8. + pm_power_off = 0;
  9. if (!pm_power_off) {
  10. axp20x_pm_power_off = axp20x;
  11. pm_power_off = axp20x_power_off;
  12. diff --git a/drivers/power/supply/axp20x_ac_power.c b/drivers/power/supply/axp20x_ac_power.c
  13. index ac360016b..c11024f3c 100644
  14. --- a/drivers/power/supply/axp20x_ac_power.c
  15. +++ b/drivers/power/supply/axp20x_ac_power.c
  16. @@ -53,6 +53,9 @@ static irqreturn_t axp20x_ac_power_irq(int irq, void *devid)
  17. {
  18. struct axp20x_ac_power *power = devid;
  19. + regmap_update_bits(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, 0x03, 0x00);
  20. + regmap_update_bits(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, 0x03, 0x03);
  21. +
  22. power_supply_changed(power->supply);
  23. return IRQ_HANDLED;
  24. diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c
  25. index f6c849bd1..f203ebc6e 100644
  26. --- a/drivers/power/supply/axp20x_battery.c
  27. +++ b/drivers/power/supply/axp20x_battery.c
  28. @@ -378,6 +378,42 @@ static int axp20x_battery_get_prop(struct power_supply *psy,
  29. val->intval *= 1000;
  30. break;
  31. + case POWER_SUPPLY_PROP_ENERGY_FULL:
  32. + case POWER_SUPPLY_PROP_ENERGY_NOW:
  33. + /* When no battery is present, return 0 */
  34. + ret = regmap_read(axp20x_batt->regmap, AXP20X_PWR_OP_MODE,
  35. + &reg);
  36. + if (ret)
  37. + return ret;
  38. +
  39. + if (!(reg & AXP20X_PWR_OP_BATT_PRESENT)) {
  40. + val->intval = 0;
  41. + return 0;
  42. + }
  43. +
  44. + if(psp == POWER_SUPPLY_PROP_ENERGY_FULL) {
  45. + val->intval = 8000000;
  46. + return 0;
  47. + }
  48. +
  49. + ret = regmap_read(axp20x_batt->regmap, AXP20X_FG_RES, &reg);
  50. + if (ret)
  51. + return ret;
  52. +
  53. + if (axp20x_batt->data->has_fg_valid && !(reg & AXP22X_FG_VALID))
  54. + return -EINVAL;
  55. +
  56. + val1 = reg & AXP209_FG_PERCENT;
  57. + if (val1 > 90)
  58. + val1= 80;
  59. + else if (val1 < 10)
  60. + val1 = 0;
  61. + else
  62. + val1 -= 10;
  63. +
  64. + val->intval = val1 * 100000;
  65. + break;
  66. +
  67. default:
  68. return -EINVAL;
  69. }
  70. @@ -544,6 +580,8 @@ static enum power_supply_property axp20x_battery_props[] = {
  71. POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
  72. POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
  73. POWER_SUPPLY_PROP_CAPACITY,
  74. + POWER_SUPPLY_PROP_ENERGY_FULL,
  75. + POWER_SUPPLY_PROP_ENERGY_NOW,
  76. };
  77. static int axp20x_battery_prop_writeable(struct power_supply *psy,
  78. @@ -857,6 +895,12 @@ static int axp20x_power_probe(struct platform_device *pdev)
  79. goto warn_bat;
  80. }
  81. + regmap_update_bits(axp20x_batt->regmap, AXP20X_VBUS_IPSOUT_MGMT, 0x03, 0x03);
  82. + regmap_update_bits(axp20x_batt->regmap, AXP20X_OFF_CTRL, 0x08, 0x08);
  83. + regmap_update_bits(axp20x_batt->regmap, AXP20X_CHRG_CTRL2, 0x30, 0x20);
  84. + regmap_update_bits(axp20x_batt->regmap, AXP20X_PEK_KEY, 0x0f, 0x0b);
  85. + regmap_update_bits(axp20x_batt->regmap, AXP20X_GPIO0_CTRL, 0x07, 0x00);
  86. +
  87. return 0;
  88. warn_bat: