Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset changes from Sebastian Reichel:
"Core:
- Nothing

Drivers:
- at91-reset: cleanups, proper handling for sam9x60
- sc27xx, charger-manager: allow building as module
- sc27xx: add support to read current charge capacity
- axp288: more quirks for weird hardware
- misc fixes"

* tag 'for-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (26 commits)
power: reset: sc27xx: Allow the SC27XX poweroff driver building into a module
power: reset: sc27xx: Change to use cpu_down()
power: reset: sc27xx: Power off the external subsystems' connection
power: twl4030: Use scnprintf() for avoiding potential buffer overflow
power: supply: bq27xxx_battery: Silence deferred-probe error
power: reset: at91-reset: handle nrst async for sam9x60
power: reset: at91-reset: get rid of at91_reset_data
power: reset: at91-reset: keep only one reset function
power: reset: at91-reset: make at91sam9g45_restart() generic
power: reset: at91-reset: introduce ramc_lpr to struct at91_reset
power: reset: at91-reset: use r4 as tmp argument
power: reset: at91-reset: introduce args member in at91_reset_data
power: reset: at91-reset: introduce struct at91_reset_data
power: reset: at91-reset: devm_kzalloc() for at91_reset data structure
power: reset: at91-reset: pass rstc base address to at91_reset_status()
power: reset: at91-reset: convert reset in pointer to struct at91_reset
power: reset: at91-reset: add notifier block to struct at91_reset
power: reset: at91-reset: add sclk to struct at91_reset
power: reset: at91-reset: add ramc_base[] to struct at91_reset
power: reset: at91-reset: introduce struct at91_reset
...

+212 -127
+1 -1
drivers/power/reset/Kconfig
··· 248 248 action according to the mode. 249 249 250 250 config POWER_RESET_SC27XX 251 - bool "Spreadtrum SC27xx PMIC power-off driver" 251 + tristate "Spreadtrum SC27xx PMIC power-off driver" 252 252 depends on MFD_SC27XX_PMIC || COMPILE_TEST 253 253 help 254 254 This driver supports powering off a system through
+95 -97
drivers/power/reset/at91-reset.c
··· 35 35 36 36 #define AT91_RSTC_MR 0x08 /* Reset Controller Mode Register */ 37 37 #define AT91_RSTC_URSTEN BIT(0) /* User Reset Enable */ 38 + #define AT91_RSTC_URSTASYNC BIT(2) /* User Reset Asynchronous Control */ 38 39 #define AT91_RSTC_URSTIEN BIT(4) /* User Reset Interrupt Enable */ 39 40 #define AT91_RSTC_ERSTL GENMASK(11, 8) /* External Reset Length */ 40 41 ··· 50 49 RESET_TYPE_ULP2 = 8, 51 50 }; 52 51 53 - static void __iomem *at91_ramc_base[2], *at91_rstc_base; 54 - static struct clk *sclk; 52 + struct at91_reset { 53 + void __iomem *rstc_base; 54 + void __iomem *ramc_base[2]; 55 + struct clk *sclk; 56 + struct notifier_block nb; 57 + u32 args; 58 + u32 ramc_lpr; 59 + }; 55 60 56 61 /* 57 62 * unless the SDRAM is cleanly shutdown before we hit the 58 63 * reset register it can be left driving the data bus and 59 64 * killing the chance of a subsequent boot from NAND 60 65 */ 61 - static int at91sam9260_restart(struct notifier_block *this, unsigned long mode, 62 - void *cmd) 66 + static int at91_reset(struct notifier_block *this, unsigned long mode, 67 + void *cmd) 63 68 { 69 + struct at91_reset *reset = container_of(this, struct at91_reset, nb); 70 + 64 71 asm volatile( 65 - /* Align to cache lines */ 66 - ".balign 32\n\t" 67 - 68 - /* Disable SDRAM accesses */ 69 - "str %2, [%0, #" __stringify(AT91_SDRAMC_TR) "]\n\t" 70 - 71 - /* Power down SDRAM */ 72 - "str %3, [%0, #" __stringify(AT91_SDRAMC_LPR) "]\n\t" 73 - 74 - /* Reset CPU */ 75 - "str %4, [%1, #" __stringify(AT91_RSTC_CR) "]\n\t" 76 - 77 - "b .\n\t" 78 - : 79 - : "r" (at91_ramc_base[0]), 80 - "r" (at91_rstc_base), 81 - "r" (1), 82 - "r" cpu_to_le32(AT91_SDRAMC_LPCB_POWER_DOWN), 83 - "r" cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST)); 84 - 85 - return NOTIFY_DONE; 86 - } 87 - 88 - static int at91sam9g45_restart(struct notifier_block *this, unsigned long mode, 89 - void *cmd) 90 - { 91 - asm volatile( 92 - /* 93 - * Test wether we have a second RAM controller to care 94 - * about. 95 - * 96 - * First, test that we can dereference the virtual address. 97 - */ 98 - "cmp %1, #0\n\t" 99 - "beq 1f\n\t" 100 - 101 - /* Then, test that the RAM controller is enabled */ 102 - "ldr r0, [%1]\n\t" 103 - "cmp r0, #0\n\t" 104 - 105 72 /* Align to cache lines */ 106 73 ".balign 32\n\t" 107 74 108 75 /* Disable SDRAM0 accesses */ 109 - "1: str %3, [%0, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t" 76 + " tst %0, #0\n\t" 77 + " beq 1f\n\t" 78 + " str %3, [%0, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t" 110 79 /* Power down SDRAM0 */ 111 - " str %4, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t" 80 + " str %4, [%0, %6]\n\t" 112 81 /* Disable SDRAM1 accesses */ 82 + "1: tst %1, #0\n\t" 83 + " beq 2f\n\t" 113 84 " strne %3, [%1, #" __stringify(AT91_DDRSDRC_RTR) "]\n\t" 114 85 /* Power down SDRAM1 */ 115 - " strne %4, [%1, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t" 86 + " strne %4, [%1, %6]\n\t" 116 87 /* Reset CPU */ 117 - " str %5, [%2, #" __stringify(AT91_RSTC_CR) "]\n\t" 88 + "2: str %5, [%2, #" __stringify(AT91_RSTC_CR) "]\n\t" 118 89 119 90 " b .\n\t" 120 91 : 121 - : "r" (at91_ramc_base[0]), 122 - "r" (at91_ramc_base[1]), 123 - "r" (at91_rstc_base), 92 + : "r" (reset->ramc_base[0]), 93 + "r" (reset->ramc_base[1]), 94 + "r" (reset->rstc_base), 124 95 "r" (1), 125 96 "r" cpu_to_le32(AT91_DDRSDRC_LPCB_POWER_DOWN), 126 - "r" cpu_to_le32(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST) 127 - : "r0"); 97 + "r" (reset->args), 98 + "r" (reset->ramc_lpr) 99 + : "r4"); 128 100 129 101 return NOTIFY_DONE; 130 102 } 131 103 132 - static int sama5d3_restart(struct notifier_block *this, unsigned long mode, 133 - void *cmd) 134 - { 135 - writel(AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST, 136 - at91_rstc_base); 137 - 138 - return NOTIFY_DONE; 139 - } 140 - 141 - static int samx7_restart(struct notifier_block *this, unsigned long mode, 142 - void *cmd) 143 - { 144 - writel(AT91_RSTC_KEY | AT91_RSTC_PROCRST, at91_rstc_base); 145 - return NOTIFY_DONE; 146 - } 147 - 148 - static void __init at91_reset_status(struct platform_device *pdev) 104 + static void __init at91_reset_status(struct platform_device *pdev, 105 + void __iomem *base) 149 106 { 150 107 const char *reason; 151 - u32 reg = readl(at91_rstc_base + AT91_RSTC_SR); 108 + u32 reg = readl(base + AT91_RSTC_SR); 152 109 153 110 switch ((reg & AT91_RSTC_RSTTYP) >> 8) { 154 111 case RESET_TYPE_GENERAL: ··· 142 183 } 143 184 144 185 static const struct of_device_id at91_ramc_of_match[] = { 145 - { .compatible = "atmel,at91sam9260-sdramc", }, 146 - { .compatible = "atmel,at91sam9g45-ddramc", }, 186 + { 187 + .compatible = "atmel,at91sam9260-sdramc", 188 + .data = (void *)AT91_SDRAMC_LPR, 189 + }, 190 + { 191 + .compatible = "atmel,at91sam9g45-ddramc", 192 + .data = (void *)AT91_DDRSDRC_LPR, 193 + }, 147 194 { /* sentinel */ } 148 195 }; 149 196 150 197 static const struct of_device_id at91_reset_of_match[] = { 151 - { .compatible = "atmel,at91sam9260-rstc", .data = at91sam9260_restart }, 152 - { .compatible = "atmel,at91sam9g45-rstc", .data = at91sam9g45_restart }, 153 - { .compatible = "atmel,sama5d3-rstc", .data = sama5d3_restart }, 154 - { .compatible = "atmel,samx7-rstc", .data = samx7_restart }, 155 - { .compatible = "microchip,sam9x60-rstc", .data = samx7_restart }, 198 + { 199 + .compatible = "atmel,at91sam9260-rstc", 200 + .data = (void *)(AT91_RSTC_KEY | AT91_RSTC_PERRST | 201 + AT91_RSTC_PROCRST), 202 + }, 203 + { 204 + .compatible = "atmel,at91sam9g45-rstc", 205 + .data = (void *)(AT91_RSTC_KEY | AT91_RSTC_PERRST | 206 + AT91_RSTC_PROCRST) 207 + }, 208 + { 209 + .compatible = "atmel,sama5d3-rstc", 210 + .data = (void *)(AT91_RSTC_KEY | AT91_RSTC_PERRST | 211 + AT91_RSTC_PROCRST) 212 + }, 213 + { 214 + .compatible = "atmel,samx7-rstc", 215 + .data = (void *)(AT91_RSTC_KEY | AT91_RSTC_PROCRST) 216 + }, 217 + { 218 + .compatible = "microchip,sam9x60-rstc", 219 + .data = (void *)(AT91_RSTC_KEY | AT91_RSTC_PROCRST) 220 + }, 156 221 { /* sentinel */ } 157 222 }; 158 223 MODULE_DEVICE_TABLE(of, at91_reset_of_match); 159 224 160 - static struct notifier_block at91_restart_nb = { 161 - .priority = 192, 162 - }; 163 - 164 225 static int __init at91_reset_probe(struct platform_device *pdev) 165 226 { 166 227 const struct of_device_id *match; 228 + struct at91_reset *reset; 167 229 struct device_node *np; 168 230 int ret, idx = 0; 169 231 170 - at91_rstc_base = of_iomap(pdev->dev.of_node, 0); 171 - if (!at91_rstc_base) { 232 + reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL); 233 + if (!reset) 234 + return -ENOMEM; 235 + 236 + reset->rstc_base = of_iomap(pdev->dev.of_node, 0); 237 + if (!reset->rstc_base) { 172 238 dev_err(&pdev->dev, "Could not map reset controller address\n"); 173 239 return -ENODEV; 174 240 } 175 241 176 242 if (!of_device_is_compatible(pdev->dev.of_node, "atmel,sama5d3-rstc")) { 177 243 /* we need to shutdown the ddr controller, so get ramc base */ 178 - for_each_matching_node(np, at91_ramc_of_match) { 179 - at91_ramc_base[idx] = of_iomap(np, 0); 180 - if (!at91_ramc_base[idx]) { 244 + for_each_matching_node_and_match(np, at91_ramc_of_match, &match) { 245 + reset->ramc_lpr = (u32)match->data; 246 + reset->ramc_base[idx] = of_iomap(np, 0); 247 + if (!reset->ramc_base[idx]) { 181 248 dev_err(&pdev->dev, "Could not map ram controller address\n"); 182 249 of_node_put(np); 183 250 return -ENODEV; ··· 213 228 } 214 229 215 230 match = of_match_node(at91_reset_of_match, pdev->dev.of_node); 216 - at91_restart_nb.notifier_call = match->data; 231 + reset->nb.notifier_call = at91_reset; 232 + reset->nb.priority = 192; 233 + reset->args = (u32)match->data; 217 234 218 - sclk = devm_clk_get(&pdev->dev, NULL); 219 - if (IS_ERR(sclk)) 220 - return PTR_ERR(sclk); 235 + reset->sclk = devm_clk_get(&pdev->dev, NULL); 236 + if (IS_ERR(reset->sclk)) 237 + return PTR_ERR(reset->sclk); 221 238 222 - ret = clk_prepare_enable(sclk); 239 + ret = clk_prepare_enable(reset->sclk); 223 240 if (ret) { 224 241 dev_err(&pdev->dev, "Could not enable slow clock\n"); 225 242 return ret; 226 243 } 227 244 228 - ret = register_restart_handler(&at91_restart_nb); 245 + platform_set_drvdata(pdev, reset); 246 + 247 + if (of_device_is_compatible(pdev->dev.of_node, "microchip,sam9x60-rstc")) { 248 + u32 val = readl(reset->rstc_base + AT91_RSTC_MR); 249 + 250 + writel(AT91_RSTC_KEY | AT91_RSTC_URSTASYNC | val, 251 + reset->rstc_base + AT91_RSTC_MR); 252 + } 253 + 254 + ret = register_restart_handler(&reset->nb); 229 255 if (ret) { 230 - clk_disable_unprepare(sclk); 256 + clk_disable_unprepare(reset->sclk); 231 257 return ret; 232 258 } 233 259 234 - at91_reset_status(pdev); 260 + at91_reset_status(pdev, reset->rstc_base); 235 261 236 262 return 0; 237 263 } 238 264 239 265 static int __exit at91_reset_remove(struct platform_device *pdev) 240 266 { 241 - unregister_restart_handler(&at91_restart_nb); 242 - clk_disable_unprepare(sclk); 267 + struct at91_reset *reset = platform_get_drvdata(pdev); 268 + 269 + unregister_restart_handler(&reset->nb); 270 + clk_disable_unprepare(reset->sclk); 243 271 244 272 return 0; 245 273 }
+17 -4
drivers/power/reset/sc27xx-poweroff.c
··· 6 6 7 7 #include <linux/cpu.h> 8 8 #include <linux/kernel.h> 9 + #include <linux/module.h> 9 10 #include <linux/platform_device.h> 10 11 #include <linux/pm.h> 11 12 #include <linux/regmap.h> ··· 14 13 15 14 #define SC27XX_PWR_PD_HW 0xc2c 16 15 #define SC27XX_PWR_OFF_EN BIT(0) 16 + #define SC27XX_SLP_CTRL 0xdf0 17 + #define SC27XX_LDO_XTL_EN BIT(3) 17 18 18 19 static struct regmap *regmap; 19 20 ··· 30 27 */ 31 28 static void sc27xx_poweroff_shutdown(void) 32 29 { 33 - #ifdef CONFIG_PM_SLEEP_SMP 34 - int cpu = smp_processor_id(); 30 + #ifdef CONFIG_HOTPLUG_CPU 31 + int cpu; 35 32 36 - freeze_secondary_cpus(cpu); 33 + for_each_online_cpu(cpu) { 34 + if (cpu != smp_processor_id()) 35 + remove_cpu(cpu); 36 + } 37 37 #endif 38 38 } 39 39 ··· 46 40 47 41 static void sc27xx_poweroff_do_poweroff(void) 48 42 { 43 + /* Disable the external subsys connection's power firstly */ 44 + regmap_write(regmap, SC27XX_SLP_CTRL, SC27XX_LDO_XTL_EN); 45 + 49 46 regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN); 50 47 } 51 48 ··· 72 63 .name = "sc27xx-poweroff", 73 64 }, 74 65 }; 75 - builtin_platform_driver(sc27xx_poweroff_driver); 66 + module_platform_driver(sc27xx_poweroff_driver); 67 + 68 + MODULE_DESCRIPTION("Power off driver for SC27XX PMIC Device"); 69 + MODULE_AUTHOR("Baolin Wang <baolin.wang@unisoc.com>"); 70 + MODULE_LICENSE("GPL v2");
+1 -1
drivers/power/supply/Kconfig
··· 480 480 called gpio-charger. 481 481 482 482 config CHARGER_MANAGER 483 - bool "Battery charger manager for multiple chargers" 483 + tristate "Battery charger manager for multiple chargers" 484 484 depends on REGULATOR 485 485 select EXTCON 486 486 help
+19 -16
drivers/power/supply/ab8500_charger.c
··· 404 404 } 405 405 406 406 /** 407 - * ab8500_power_supply_changed - a wrapper with local extentions for 407 + * ab8500_power_supply_changed - a wrapper with local extensions for 408 408 * power_supply_changed 409 409 * @di: pointer to the ab8500_charger structure 410 410 * @psy: pointer to power_supply_that have changed. ··· 683 683 /* 684 684 * Platform only supports USB 2.0. 685 685 * This means that charging current from USB source 686 - * is maximum 500 mA. Every occurence of USB_STAT_*_HOST_* 686 + * is maximum 500 mA. Every occurrence of USB_STAT_*_HOST_* 687 687 * should set USB_CH_IP_CUR_LVL_0P5. 688 688 */ 689 689 ··· 1379 1379 1380 1380 /* 1381 1381 * Due to a bug in AB8500, BTEMP_HIGH/LOW interrupts 1382 - * will be triggered everytime we enable the VDD ADC supply. 1382 + * will be triggered every time we enable the VDD ADC supply. 1383 1383 * This will turn off charging for a short while. 1384 1384 * It can be avoided by having the supply on when 1385 1385 * there is a charger enabled. Normally the VDD ADC supply 1386 - * is enabled everytime a GPADC conversion is triggered. We will 1387 - * force it to be enabled from this driver to have 1388 - * the GPADC module independant of the AB8500 chargers 1386 + * is enabled every time a GPADC conversion is triggered. 1387 + * We will force it to be enabled from this driver to have 1388 + * the GPADC module independent of the AB8500 chargers 1389 1389 */ 1390 1390 if (!di->vddadc_en_ac) { 1391 1391 ret = regulator_enable(di->regu); ··· 1455 1455 if (is_ab8500_1p1_or_earlier(di->parent)) { 1456 1456 /* 1457 1457 * For ABB revision 1.0 and 1.1 there is a bug in the 1458 - * watchdog logic. That means we have to continously 1458 + * watchdog logic. That means we have to continuously 1459 1459 * kick the charger watchdog even when no charger is 1460 1460 * connected. This is only valid once the AC charger 1461 1461 * has been enabled. This is a bug that is not handled ··· 1552 1552 1553 1553 /* 1554 1554 * Due to a bug in AB8500, BTEMP_HIGH/LOW interrupts 1555 - * will be triggered everytime we enable the VDD ADC supply. 1555 + * will be triggered every time we enable the VDD ADC supply. 1556 1556 * This will turn off charging for a short while. 1557 1557 * It can be avoided by having the supply on when 1558 1558 * there is a charger enabled. Normally the VDD ADC supply 1559 - * is enabled everytime a GPADC conversion is triggered. We will 1560 - * force it to be enabled from this driver to have 1561 - * the GPADC module independant of the AB8500 chargers 1559 + * is enabled every time a GPADC conversion is triggered. 1560 + * We will force it to be enabled from this driver to have 1561 + * the GPADC module independent of the AB8500 chargers 1562 1562 */ 1563 1563 if (!di->vddadc_en_usb) { 1564 1564 ret = regulator_enable(di->regu); ··· 1582 1582 return -ENXIO; 1583 1583 } 1584 1584 1585 - /* ChVoltLevel: max voltage upto which battery can be charged */ 1585 + /* 1586 + * ChVoltLevel: max voltage up to which battery can be 1587 + * charged 1588 + */ 1586 1589 ret = abx500_set_register_interruptible(di->dev, AB8500_CHARGER, 1587 1590 AB8500_CH_VOLT_LVL_REG, (u8) volt_index); 1588 1591 if (ret) { ··· 2017 2014 * Work queue function for kicking the charger watchdog. 2018 2015 * 2019 2016 * For ABB revision 1.0 and 1.1 there is a bug in the watchdog 2020 - * logic. That means we have to continously kick the charger 2017 + * logic. That means we have to continuously kick the charger 2021 2018 * watchdog even when no charger is connected. This is only 2022 2019 * valid once the AC charger has been enabled. This is 2023 2020 * a bug that is not handled by the algorithm and the ··· 2265 2262 * Some chargers that breaks the USB spec is 2266 2263 * identified as invalid by AB8500 and it refuse 2267 2264 * to start the charging process. but by jumping 2268 - * thru a few hoops it can be forced to start. 2265 + * through a few hoops it can be forced to start. 2269 2266 */ 2270 2267 if (is_ab8500(di->parent)) 2271 2268 ret = abx500_get_register_interruptible(di->dev, AB8500_USB, ··· 3217 3214 3218 3215 /* 3219 3216 * For ABB revision 1.0 and 1.1 there is a bug in the watchdog 3220 - * logic. That means we have to continously kick the charger 3217 + * logic. That means we have to continuously kick the charger 3221 3218 * watchdog even when no charger is connected. This is only 3222 3219 * valid once the AC charger has been enabled. This is 3223 3220 * a bug that is not handled by the algorithm and the ··· 3486 3483 3487 3484 /* 3488 3485 * For ABB revision 1.0 and 1.1 there is a bug in the watchdog 3489 - * logic. That means we have to continously kick the charger 3486 + * logic. That means we have to continuously kick the charger 3490 3487 * watchdog even when no charger is connected. This is only 3491 3488 * valid once the AC charger has been enabled. This is 3492 3489 * a bug that is not handled by the algorithm and the
+56 -1
drivers/power/supply/axp288_charger.c
··· 21 21 #include <linux/property.h> 22 22 #include <linux/mfd/axp20x.h> 23 23 #include <linux/extcon.h> 24 + #include <linux/dmi.h> 24 25 25 26 #define PS_STAT_VBUS_TRIGGER BIT(0) 26 27 #define PS_STAT_BAT_CHRG_DIR BIT(2) ··· 546 545 return IRQ_HANDLED; 547 546 } 548 547 548 + /* 549 + * The HP Pavilion x2 10 series comes in a number of variants: 550 + * Bay Trail SoC + AXP288 PMIC, DMI_BOARD_NAME: "815D" 551 + * Cherry Trail SoC + AXP288 PMIC, DMI_BOARD_NAME: "813E" 552 + * Cherry Trail SoC + TI PMIC, DMI_BOARD_NAME: "827C" or "82F4" 553 + * 554 + * The variants with the AXP288 PMIC are all kinds of special: 555 + * 556 + * 1. All variants use a Type-C connector which the AXP288 does not support, so 557 + * when using a Type-C charger it is not recognized. Unlike most AXP288 devices, 558 + * this model actually has mostly working ACPI AC / Battery code, the ACPI code 559 + * "solves" this by simply setting the input_current_limit to 3A. 560 + * There are still some issues with the ACPI code, so we use this native driver, 561 + * and to solve the charging not working (500mA is not enough) issue we hardcode 562 + * the 3A input_current_limit like the ACPI code does. 563 + * 564 + * 2. If no charger is connected the machine boots with the vbus-path disabled. 565 + * Normally this is done when a 5V boost converter is active to avoid the PMIC 566 + * trying to charge from the 5V boost converter's output. This is done when 567 + * an OTG host cable is inserted and the ID pin on the micro-B receptacle is 568 + * pulled low and the ID pin has an ACPI event handler associated with it 569 + * which re-enables the vbus-path when the ID pin is pulled high when the 570 + * OTG host cable is removed. The Type-C connector has no ID pin, there is 571 + * no ID pin handler and there appears to be no 5V boost converter, so we 572 + * end up not charging because the vbus-path is disabled, until we unplug 573 + * the charger which automatically clears the vbus-path disable bit and then 574 + * on the second plug-in of the adapter we start charging. To solve the not 575 + * charging on first charger plugin we unconditionally enable the vbus-path at 576 + * probe on this model, which is safe since there is no 5V boost converter. 577 + */ 578 + static const struct dmi_system_id axp288_hp_x2_dmi_ids[] = { 579 + { 580 + /* 581 + * Bay Trail model has "Hewlett-Packard" as sys_vendor, Cherry 582 + * Trail model has "HP", so we only match on product_name. 583 + */ 584 + .matches = { 585 + DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion x2 Detachable"), 586 + }, 587 + }, 588 + {} /* Terminating entry */ 589 + }; 590 + 549 591 static void axp288_charger_extcon_evt_worker(struct work_struct *work) 550 592 { 551 593 struct axp288_chrg_info *info = ··· 612 568 } 613 569 614 570 /* Determine cable/charger type */ 615 - if (extcon_get_state(edev, EXTCON_CHG_USB_SDP) > 0) { 571 + if (dmi_check_system(axp288_hp_x2_dmi_ids)) { 572 + /* See comment above axp288_hp_x2_dmi_ids declaration */ 573 + dev_dbg(&info->pdev->dev, "HP X2 with Type-C, setting inlmt to 3A\n"); 574 + current_limit = 3000000; 575 + } else if (extcon_get_state(edev, EXTCON_CHG_USB_SDP) > 0) { 616 576 dev_dbg(&info->pdev->dev, "USB SDP charger is connected\n"); 617 577 current_limit = 500000; 618 578 } else if (extcon_get_state(edev, EXTCON_CHG_USB_CDP) > 0) { ··· 731 683 dev_err(&info->pdev->dev, "register(%x) write error(%d)\n", 732 684 AXP20X_CC_CTRL, ret); 733 685 return ret; 686 + } 687 + 688 + if (dmi_check_system(axp288_hp_x2_dmi_ids)) { 689 + /* See comment above axp288_hp_x2_dmi_ids declaration */ 690 + ret = axp288_charger_vbus_path_select(info, true); 691 + if (ret < 0) 692 + return ret; 734 693 } 735 694 736 695 /* Read current charge voltage and current limit */
+2 -2
drivers/power/supply/axp288_fuel_gauge.c
··· 706 706 { 707 707 /* Intel Cherry Trail Compute Stick, Windows version */ 708 708 .matches = { 709 - DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), 709 + DMI_MATCH(DMI_SYS_VENDOR, "Intel"), 710 710 DMI_MATCH(DMI_PRODUCT_NAME, "STK1AW32SC"), 711 711 }, 712 712 }, 713 713 { 714 714 /* Intel Cherry Trail Compute Stick, version without an OS */ 715 715 .matches = { 716 - DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), 716 + DMI_MATCH(DMI_SYS_VENDOR, "Intel"), 717 717 DMI_MATCH(DMI_PRODUCT_NAME, "STK1A32SC"), 718 718 }, 719 719 },
+4 -1
drivers/power/supply/bq27xxx_battery.c
··· 1885 1885 1886 1886 di->bat = power_supply_register_no_ws(di->dev, psy_desc, &psy_cfg); 1887 1887 if (IS_ERR(di->bat)) { 1888 - dev_err(di->dev, "failed to register battery\n"); 1888 + if (PTR_ERR(di->bat) == -EPROBE_DEFER) 1889 + dev_dbg(di->dev, "failed to register battery, deferring probe\n"); 1890 + else 1891 + dev_err(di->dev, "failed to register battery\n"); 1889 1892 return PTR_ERR(di->bat); 1890 1893 } 1891 1894
+2 -1
drivers/power/supply/ingenic-battery.c
··· 148 148 149 149 bat->battery = devm_power_supply_register(dev, desc, &psy_cfg); 150 150 if (IS_ERR(bat->battery)) { 151 - dev_err(dev, "Unable to register battery\n"); 151 + if (PTR_ERR(bat->battery) != -EPROBE_DEFER) 152 + dev_err(dev, "Unable to register battery\n"); 152 153 return PTR_ERR(bat->battery); 153 154 } 154 155
+12
drivers/power/supply/sc27xx_fuel_gauge.c
··· 614 614 val->intval = data->total_cap * 1000; 615 615 break; 616 616 617 + case POWER_SUPPLY_PROP_CHARGE_NOW: 618 + ret = sc27xx_fgu_get_clbcnt(data, &value); 619 + if (ret) 620 + goto error; 621 + 622 + value = DIV_ROUND_CLOSEST(value * 10, 623 + 36 * SC27XX_FGU_SAMPLE_HZ); 624 + val->intval = sc27xx_fgu_adc_to_current(data, value); 625 + 626 + break; 627 + 617 628 default: 618 629 ret = -EINVAL; 619 630 break; ··· 693 682 POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE, 694 683 POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, 695 684 POWER_SUPPLY_PROP_CALIBRATE, 685 + POWER_SUPPLY_PROP_CHARGE_NOW 696 686 }; 697 687 698 688 static const struct power_supply_desc sc27xx_fgu_desc = {
+2 -2
drivers/power/supply/twl4030_charger.c
··· 726 726 727 727 for (i = 0; i < ARRAY_SIZE(modes); i++) 728 728 if (mode == i) 729 - len += snprintf(buf+len, PAGE_SIZE-len, 729 + len += scnprintf(buf+len, PAGE_SIZE-len, 730 730 "[%s] ", modes[i]); 731 731 else 732 - len += snprintf(buf+len, PAGE_SIZE-len, 732 + len += scnprintf(buf+len, PAGE_SIZE-len, 733 733 "%s ", modes[i]); 734 734 buf[len-1] = '\n'; 735 735 return len;
+1 -1
include/linux/power/charger-manager.h
··· 248 248 u64 charging_end_time; 249 249 }; 250 250 251 - #ifdef CONFIG_CHARGER_MANAGER 251 + #if IS_ENABLED(CONFIG_CHARGER_MANAGER) 252 252 extern void cm_notify_event(struct power_supply *psy, 253 253 enum cm_event_types type, char *msg); 254 254 #else