shared-psy-info.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Shared psy info for X86 tablets which ship with Android as the factory image
  4. * and which have broken DSDT tables. The factory kernels shipped on these
  5. * devices typically have a bunch of things hardcoded, rather than specified
  6. * in their DSDT.
  7. *
  8. * Copyright (C) 2021-2023 Hans de Goede <hdegoede@redhat.com>
  9. */
  10. #include <linux/gpio/machine.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/power/bq24190_charger.h>
  13. #include <linux/property.h>
  14. #include <linux/regulator/machine.h>
  15. #include "shared-psy-info.h"
  16. /* Generic / shared charger / battery settings */
  17. const char * const tusb1211_chg_det_psy[] = { "tusb1211-charger-detect" };
  18. const char * const bq24190_psy[] = { "bq24190-charger" };
  19. const char * const bq25890_psy[] = { "bq25890-charger-0" };
  20. static const struct property_entry fg_bq24190_supply_props[] = {
  21. PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_psy),
  22. { }
  23. };
  24. const struct software_node fg_bq24190_supply_node = {
  25. .properties = fg_bq24190_supply_props,
  26. };
  27. static const struct property_entry fg_bq25890_supply_props[] = {
  28. PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq25890_psy),
  29. { }
  30. };
  31. const struct software_node fg_bq25890_supply_node = {
  32. .properties = fg_bq25890_supply_props,
  33. };
  34. /* LiPo HighVoltage (max 4.35V) settings used by most devs with a HV battery */
  35. static const struct property_entry generic_lipo_hv_4v35_battery_props[] = {
  36. PROPERTY_ENTRY_STRING("compatible", "simple-battery"),
  37. PROPERTY_ENTRY_STRING("device-chemistry", "lithium-ion"),
  38. PROPERTY_ENTRY_U32("precharge-current-microamp", 256000),
  39. PROPERTY_ENTRY_U32("charge-term-current-microamp", 128000),
  40. PROPERTY_ENTRY_U32("constant-charge-current-max-microamp", 1856000),
  41. PROPERTY_ENTRY_U32("constant-charge-voltage-max-microvolt", 4352000),
  42. PROPERTY_ENTRY_U32("factory-internal-resistance-micro-ohms", 150000),
  43. { }
  44. };
  45. const struct software_node generic_lipo_hv_4v35_battery_node = {
  46. .properties = generic_lipo_hv_4v35_battery_props,
  47. };
  48. /* For enabling the bq24190 5V boost based on id-pin */
  49. static struct regulator_consumer_supply intel_int3496_consumer = {
  50. .supply = "vbus",
  51. .dev_name = "intel-int3496",
  52. };
  53. static const struct regulator_init_data bq24190_vbus_init_data = {
  54. .constraints = {
  55. .name = "bq24190_vbus",
  56. .valid_ops_mask = REGULATOR_CHANGE_STATUS,
  57. },
  58. .consumer_supplies = &intel_int3496_consumer,
  59. .num_consumer_supplies = 1,
  60. };
  61. struct bq24190_platform_data bq24190_pdata = {
  62. .regulator_init_data = &bq24190_vbus_init_data,
  63. };
  64. const char * const bq24190_modules[] __initconst = {
  65. "intel_crystal_cove_charger", /* For the bq24190 IRQ */
  66. "bq24190_charger", /* For the Vbus regulator for intel-int3496 */
  67. NULL
  68. };
  69. /* Generic platform device array and GPIO lookup table for micro USB ID pin handling */
  70. const struct platform_device_info int3496_pdevs[] __initconst = {
  71. {
  72. /* For micro USB ID pin handling */
  73. .name = "intel-int3496",
  74. .id = PLATFORM_DEVID_NONE,
  75. },
  76. };
  77. struct gpiod_lookup_table int3496_reference_gpios = {
  78. .dev_id = "intel-int3496",
  79. .table = {
  80. GPIO_LOOKUP("INT33FC:01", 15, "vbus", GPIO_ACTIVE_HIGH),
  81. GPIO_LOOKUP("INT33FC:02", 1, "mux", GPIO_ACTIVE_HIGH),
  82. GPIO_LOOKUP("INT33FC:02", 18, "id", GPIO_ACTIVE_HIGH),
  83. { }
  84. },
  85. };