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