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 11 #include <linux/gpio/machine.h> 12 #include <linux/platform_device.h> 13 #include <linux/power/bq24190_charger.h> 14 #include <linux/property.h> 15 #include <linux/regulator/machine.h> 16 17 #include "shared-psy-info.h" 18 19 /* Generic / shared charger / battery settings */ 20 const char * const tusb1211_chg_det_psy[] = { "tusb1211-charger-detect" }; 21 const char * const bq24190_psy[] = { "bq24190-charger" }; 22 const char * const bq25890_psy[] = { "bq25890-charger-0" }; 23 24 static const struct property_entry fg_bq24190_supply_props[] = { 25 PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_psy), 26 { } 27 }; 28 29 const struct software_node fg_bq24190_supply_node = { 30 .properties = fg_bq24190_supply_props, 31 }; 32 33 static const struct property_entry fg_bq25890_supply_props[] = { 34 PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq25890_psy), 35 { } 36 }; 37 38 const struct software_node fg_bq25890_supply_node = { 39 .properties = fg_bq25890_supply_props, 40 }; 41 42 static const u32 generic_lipo_battery_ovc_cap_celcius[] = { 25 }; 43 44 static const u32 generic_lipo_4v2_battery_ovc_cap_table0[] = { 45 4200000, 100, 46 4150000, 95, 47 4110000, 90, 48 4075000, 85, 49 4020000, 80, 50 3982500, 75, 51 3945000, 70, 52 3907500, 65, 53 3870000, 60, 54 3853333, 55, 55 3836667, 50, 56 3820000, 45, 57 3803333, 40, 58 3786667, 35, 59 3770000, 30, 60 3750000, 25, 61 3730000, 20, 62 3710000, 15, 63 3690000, 10, 64 3610000, 5, 65 3350000, 0 66 }; 67 68 static const u32 generic_lipo_hv_4v35_battery_ovc_cap_table0[] = { 69 4300000, 100, 70 4250000, 96, 71 4200000, 91, 72 4150000, 86, 73 4110000, 82, 74 4075000, 77, 75 4020000, 73, 76 3982500, 68, 77 3945000, 64, 78 3907500, 59, 79 3870000, 55, 80 3853333, 50, 81 3836667, 45, 82 3820000, 41, 83 3803333, 36, 84 3786667, 32, 85 3770000, 27, 86 3750000, 23, 87 3730000, 18, 88 3710000, 14, 89 3690000, 9, 90 3610000, 5, 91 3350000, 0 92 }; 93 94 /* Standard LiPo (max 4.2V) settings used by most devs with a LiPo battery */ 95 static const struct property_entry generic_lipo_4v2_battery_props[] = { 96 PROPERTY_ENTRY_STRING("compatible", "simple-battery"), 97 PROPERTY_ENTRY_STRING("device-chemistry", "lithium-ion-polymer"), 98 PROPERTY_ENTRY_U32("precharge-current-microamp", 256000), 99 PROPERTY_ENTRY_U32("charge-term-current-microamp", 128000), 100 PROPERTY_ENTRY_U32("constant-charge-current-max-microamp", 2048000), 101 PROPERTY_ENTRY_U32("constant-charge-voltage-max-microvolt", 4208000), 102 PROPERTY_ENTRY_U32("factory-internal-resistance-micro-ohms", 150000), 103 PROPERTY_ENTRY_U32_ARRAY("ocv-capacity-celsius", 104 generic_lipo_battery_ovc_cap_celcius), 105 PROPERTY_ENTRY_U32_ARRAY("ocv-capacity-table-0", 106 generic_lipo_4v2_battery_ovc_cap_table0), 107 { } 108 }; 109 110 const struct software_node generic_lipo_4v2_battery_node = { 111 .properties = generic_lipo_4v2_battery_props, 112 }; 113 114 /* LiPo HighVoltage (max 4.35V) settings used by most devs with a HV battery */ 115 static const struct property_entry generic_lipo_hv_4v35_battery_props[] = { 116 PROPERTY_ENTRY_STRING("compatible", "simple-battery"), 117 PROPERTY_ENTRY_STRING("device-chemistry", "lithium-ion"), 118 PROPERTY_ENTRY_U32("precharge-current-microamp", 256000), 119 PROPERTY_ENTRY_U32("charge-term-current-microamp", 128000), 120 PROPERTY_ENTRY_U32("constant-charge-current-max-microamp", 1856000), 121 PROPERTY_ENTRY_U32("constant-charge-voltage-max-microvolt", 4352000), 122 PROPERTY_ENTRY_U32("factory-internal-resistance-micro-ohms", 150000), 123 PROPERTY_ENTRY_U32_ARRAY("ocv-capacity-celsius", 124 generic_lipo_battery_ovc_cap_celcius), 125 PROPERTY_ENTRY_U32_ARRAY("ocv-capacity-table-0", 126 generic_lipo_hv_4v35_battery_ovc_cap_table0), 127 { } 128 }; 129 130 const struct software_node generic_lipo_hv_4v35_battery_node = { 131 .properties = generic_lipo_hv_4v35_battery_props, 132 }; 133 134 /* For enabling the bq24190 5V boost based on id-pin */ 135 static struct regulator_consumer_supply intel_int3496_consumer = { 136 .supply = "vbus", 137 .dev_name = "intel-int3496", 138 }; 139 140 static const struct regulator_init_data bq24190_vbus_init_data = { 141 .constraints = { 142 .name = "bq24190_vbus", 143 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 144 }, 145 .consumer_supplies = &intel_int3496_consumer, 146 .num_consumer_supplies = 1, 147 }; 148 149 struct bq24190_platform_data bq24190_pdata = { 150 .regulator_init_data = &bq24190_vbus_init_data, 151 }; 152 153 const char * const bq24190_modules[] __initconst = { 154 "intel_crystal_cove_charger", /* For the bq24190 IRQ */ 155 "bq24190_charger", /* For the Vbus regulator for intel-int3496 */ 156 NULL 157 }; 158 159 /* Generic platform device array and GPIO lookup table for micro USB ID pin handling */ 160 const struct platform_device_info int3496_pdevs[] __initconst = { 161 { 162 /* For micro USB ID pin handling */ 163 .name = "intel-int3496", 164 .id = PLATFORM_DEVID_NONE, 165 }, 166 }; 167 168 struct gpiod_lookup_table int3496_reference_gpios = { 169 .dev_id = "intel-int3496", 170 .table = { 171 GPIO_LOOKUP("INT33FC:01", 15, "vbus", GPIO_ACTIVE_HIGH), 172 GPIO_LOOKUP("INT33FC:02", 1, "mux", GPIO_ACTIVE_HIGH), 173 GPIO_LOOKUP("INT33FC:02", 18, "id", GPIO_ACTIVE_HIGH), 174 { } 175 }, 176 }; 177