bq2415x_charger.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * bq2415x charger driver
  3. *
  4. * Copyright (C) 2011-2012 Pali Rohár <pali.rohar@gmail.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #ifndef BQ2415X_CHARGER_H
  21. #define BQ2415X_CHARGER_H
  22. /*
  23. * This is platform data for bq2415x chip. It contains default board
  24. * voltages and currents which can be also later configured via sysfs. If
  25. * value is -1 then default chip value (specified in datasheet) will be
  26. * used.
  27. *
  28. * Value resistor_sense is needed for for configuring charge and
  29. * termination current. It it is less or equal to zero, configuring charge
  30. * and termination current will not be possible.
  31. *
  32. * Function set_mode_hook is needed for automode (setting correct current
  33. * limit when charger is connected/disconnected or setting boost mode).
  34. * When is NULL, automode function is disabled. When is not NULL, it must
  35. * have this prototype:
  36. *
  37. * int (*set_mode_hook)(
  38. * void (*hook)(enum bq2415x_mode mode, void *data),
  39. * void *data)
  40. *
  41. * hook is hook function (see below) and data is pointer to driver private
  42. * data
  43. *
  44. * bq2415x driver will call it as:
  45. *
  46. * platform_data->set_mode_hook(bq2415x_hook_function, bq2415x_device);
  47. *
  48. * Board/platform function set_mode_hook return non zero value when hook
  49. * function was successful registered. Platform code should call that hook
  50. * function (which get from pointer, with data) every time when charger
  51. * was connected/disconnected or require to enable boost mode. bq2415x
  52. * driver then will set correct current limit, enable/disable charger or
  53. * boost mode.
  54. *
  55. * Hook function has this prototype:
  56. *
  57. * void hook(enum bq2415x_mode mode, void *data);
  58. *
  59. * mode is bq2415x mode (charger or boost)
  60. * data is pointer to driver private data (which get from
  61. * set_charger_type_hook)
  62. *
  63. * When bq driver is being unloaded, it call function:
  64. *
  65. * platform_data->set_mode_hook(NULL, NULL);
  66. *
  67. * (hook function and driver private data are NULL)
  68. *
  69. * After that board/platform code must not call driver hook function! It
  70. * is possible that pointer to hook function will not be valid and calling
  71. * will cause undefined result.
  72. */
  73. /* Supported modes with maximal current limit */
  74. enum bq2415x_mode {
  75. BQ2415X_MODE_NONE, /* unknown or no charger (100mA) */
  76. BQ2415X_MODE_HOST_CHARGER, /* usb host/hub charger (500mA) */
  77. BQ2415X_MODE_DEDICATED_CHARGER, /* dedicated charger (unlimited) */
  78. BQ2415X_MODE_BOOST, /* boost mode (charging disabled) */
  79. };
  80. struct bq2415x_platform_data {
  81. int current_limit; /* mA */
  82. int weak_battery_voltage; /* mV */
  83. int battery_regulation_voltage; /* mV */
  84. int charge_current; /* mA */
  85. int termination_current; /* mA */
  86. int resistor_sense; /* m ohm */
  87. int (*set_mode_hook)(void (*hook)(enum bq2415x_mode mode, void *data),
  88. void *data);
  89. };
  90. #endif