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

Merge tag 'for-v6.8-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
"New features:
- bq24190: Add support for BQ24296 charger

Cleanups:
- all reset drivers: Stop using module_platform_driver_probe()
- gpio-restart: use devm_register_sys_off_handler
- pwr-mlxbf: support graceful reboot
- cw2015: correct time_to_empty units
- qcom-battmgr: Fix driver initialization sequence
- bq27xxx: Start/Stop delayed work in suspend/resume
- minor cleanups and fixes"

* tag 'for-v6.8-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (33 commits)
power: supply: bq24190_charger: Fix "initializer element is not constant" error
power: supply: bq24190_charger: Add support for BQ24296
dt-bindings: power: supply: bq24190: Add BQ24296 compatible
dt-bindings: power: reset: xilinx: Rename node names in examples
power: supply: qcom_battmgr: Register the power supplies after PDR is up
dt-bindings: power: reset: qcom-pon: fix inconsistent example
power: supply: Fix null pointer dereference in smb2_probe
power: reset: at91: Drop '__init' from at91_wakeup_status()
power: supply: Use multiple MODULE_AUTHOR statements
power: supply: Fix indentation and some other warnings
power: reset: gpio-restart: Use devm_register_sys_off_handler()
power: supply: bq256xx: fix some problem in bq256xx_hw_init
power: supply: cw2015: correct time_to_empty units in sysfs
power: reset: at91-sama5d2_shdwc: Convert to platform remove callback returning void
power: reset: at91-reset: Convert to platform remove callback returning void
power: reset: tps65086-restart: Convert to platform remove callback returning void
power: reset: syscon-poweroff: Convert to platform remove callback returning void
power: reset: rmobile-reset: Convert to platform remove callback returning void
power: reset: restart-poweroff: Convert to platform remove callback returning void
power: reset: regulator-poweroff: Convert to platform remove callback returning void
...

+615 -343
+3 -5
Documentation/devicetree/bindings/power/reset/nvmem-reboot-mode.yaml
··· 28 28 items: 29 29 - const: reboot-mode 30 30 31 - patternProperties: 32 - "^mode-.+": 33 - $ref: /schemas/types.yaml#/definitions/uint32 34 - description: Vendor-specific mode value written to the mode register 31 + allOf: 32 + - $ref: reboot-mode.yaml# 35 33 36 34 required: 37 35 - compatible 38 36 - nvmem-cells 39 37 - nvmem-cell-names 40 38 41 - additionalProperties: false 39 + unevaluatedProperties: false 42 40 43 41 examples: 44 42 - |
+8 -5
Documentation/devicetree/bindings/power/reset/qcom,pon.yaml
··· 111 111 #include <dt-bindings/interrupt-controller/irq.h> 112 112 #include <dt-bindings/input/linux-event-codes.h> 113 113 #include <dt-bindings/spmi/spmi.h> 114 - spmi_bus: spmi@c440000 { 114 + 115 + spmi@c440000 { 115 116 reg = <0x0c440000 0x1100>; 116 117 #address-cells = <2>; 117 118 #size-cells = <0>; 118 - pmk8350: pmic@0 { 119 + 120 + pmic@0 { 119 121 reg = <0x0 SPMI_USID>; 120 122 #address-cells = <1>; 121 123 #size-cells = <0>; 122 - pmk8350_pon: pon_hlos@1300 { 123 - reg = <0x1300>; 124 + 125 + pon@800 { 124 126 compatible = "qcom,pm8998-pon"; 127 + reg = <0x800>; 125 128 126 129 pwrkey { 127 130 compatible = "qcom,pm8941-pwrkey"; 128 - interrupts = < 0x0 0x8 0 IRQ_TYPE_EDGE_BOTH >; 131 + interrupts = <0x0 0x8 0 IRQ_TYPE_EDGE_BOTH>; 129 132 debounce = <15625>; 130 133 bias-pull-up; 131 134 linux,code = <KEY_POWER>;
+3 -5
Documentation/devicetree/bindings/power/reset/syscon-reboot-mode.yaml
··· 29 29 $ref: /schemas/types.yaml#/definitions/uint32 30 30 description: Offset in the register map for the mode register (in bytes) 31 31 32 - patternProperties: 33 - "^mode-.+": 34 - $ref: /schemas/types.yaml#/definitions/uint32 35 - description: Vendor-specific mode value written to the mode register 32 + allOf: 33 + - $ref: reboot-mode.yaml# 36 34 37 - additionalProperties: false 35 + unevaluatedProperties: false 38 36 39 37 required: 40 38 - compatible
+2 -2
Documentation/devicetree/bindings/power/reset/xlnx,zynqmp-power.yaml
··· 57 57 58 58 firmware { 59 59 zynqmp-firmware { 60 - zynqmp-power { 60 + power-management { 61 61 compatible = "xlnx,zynqmp-power"; 62 62 interrupts = <0 35 4>; 63 63 }; ··· 70 70 71 71 firmware { 72 72 zynqmp-firmware { 73 - zynqmp-power { 73 + power-management { 74 74 compatible = "xlnx,zynqmp-power"; 75 75 interrupt-parent = <&gic>; 76 76 interrupts = <0 35 4>;
+1
Documentation/devicetree/bindings/power/supply/bq24190.yaml
··· 20 20 - ti,bq24192 21 21 - ti,bq24192i 22 22 - ti,bq24196 23 + - ti,bq24296 23 24 24 25 reg: 25 26 maxItems: 1
+2 -4
drivers/power/reset/as3722-poweroff.c
··· 61 61 return 0; 62 62 } 63 63 64 - static int as3722_poweroff_remove(struct platform_device *pdev) 64 + static void as3722_poweroff_remove(struct platform_device *pdev) 65 65 { 66 66 if (pm_power_off == as3722_pm_power_off) 67 67 pm_power_off = NULL; 68 68 as3722_pm_poweroff = NULL; 69 - 70 - return 0; 71 69 } 72 70 73 71 static struct platform_driver as3722_poweroff_driver = { ··· 73 75 .name = "as3722-power-off", 74 76 }, 75 77 .probe = as3722_poweroff_probe, 76 - .remove = as3722_poweroff_remove, 78 + .remove_new = as3722_poweroff_remove, 77 79 }; 78 80 79 81 module_platform_driver(as3722_poweroff_driver);
+6 -7
drivers/power/reset/at91-poweroff.c
··· 57 57 void __iomem *mpddrc_base; 58 58 } at91_shdwc; 59 59 60 - static void __init at91_wakeup_status(struct platform_device *pdev) 60 + static void at91_wakeup_status(struct platform_device *pdev) 61 61 { 62 62 const char *reason; 63 63 u32 reg = readl(at91_shdwc.shdwc_base + AT91_SHDW_SR); ··· 149 149 writel(wakeup_mode | mode, at91_shdwc.shdwc_base + AT91_SHDW_MR); 150 150 } 151 151 152 - static int __init at91_poweroff_probe(struct platform_device *pdev) 152 + static int at91_poweroff_probe(struct platform_device *pdev) 153 153 { 154 154 struct device_node *np; 155 155 u32 ddr_type; ··· 202 202 return ret; 203 203 } 204 204 205 - static int __exit at91_poweroff_remove(struct platform_device *pdev) 205 + static void at91_poweroff_remove(struct platform_device *pdev) 206 206 { 207 207 if (pm_power_off == at91_poweroff) 208 208 pm_power_off = NULL; ··· 211 211 iounmap(at91_shdwc.mpddrc_base); 212 212 213 213 clk_disable_unprepare(at91_shdwc.sclk); 214 - 215 - return 0; 216 214 } 217 215 218 216 static const struct of_device_id at91_poweroff_of_match[] = { ··· 222 224 MODULE_DEVICE_TABLE(of, at91_poweroff_of_match); 223 225 224 226 static struct platform_driver at91_poweroff_driver = { 225 - .remove = __exit_p(at91_poweroff_remove), 227 + .probe = at91_poweroff_probe, 228 + .remove_new = at91_poweroff_remove, 226 229 .driver = { 227 230 .name = "at91-poweroff", 228 231 .of_match_table = at91_poweroff_of_match, 229 232 }, 230 233 }; 231 - module_platform_driver_probe(at91_poweroff_driver, at91_poweroff_probe); 234 + module_platform_driver(at91_poweroff_driver); 232 235 233 236 MODULE_AUTHOR("Atmel Corporation"); 234 237 MODULE_DESCRIPTION("Shutdown driver for Atmel SoCs");
+5 -6
drivers/power/reset/at91-reset.c
··· 337 337 return devm_reset_controller_register(&pdev->dev, &reset->rcdev); 338 338 } 339 339 340 - static int __init at91_reset_probe(struct platform_device *pdev) 340 + static int at91_reset_probe(struct platform_device *pdev) 341 341 { 342 342 const struct of_device_id *match; 343 343 struct at91_reset *reset; ··· 417 417 return ret; 418 418 } 419 419 420 - static int __exit at91_reset_remove(struct platform_device *pdev) 420 + static void at91_reset_remove(struct platform_device *pdev) 421 421 { 422 422 struct at91_reset *reset = platform_get_drvdata(pdev); 423 423 424 424 unregister_restart_handler(&reset->nb); 425 425 clk_disable_unprepare(reset->sclk); 426 - 427 - return 0; 428 426 } 429 427 430 428 static struct platform_driver at91_reset_driver = { 431 - .remove = __exit_p(at91_reset_remove), 429 + .probe = at91_reset_probe, 430 + .remove_new = at91_reset_remove, 432 431 .driver = { 433 432 .name = "at91-reset", 434 433 .of_match_table = at91_reset_of_match, 435 434 }, 436 435 }; 437 - module_platform_driver_probe(at91_reset_driver, at91_reset_probe); 436 + module_platform_driver(at91_reset_driver); 438 437 439 438 MODULE_AUTHOR("Atmel Corporation"); 440 439 MODULE_DESCRIPTION("Reset driver for Atmel SoCs");
+6 -7
drivers/power/reset/at91-sama5d2_shdwc.c
··· 107 107 0, 3, 32, 512, 4096, 32768, 108 108 }; 109 109 110 - static void __init at91_wakeup_status(struct platform_device *pdev) 110 + static void at91_wakeup_status(struct platform_device *pdev) 111 111 { 112 112 struct shdwc *shdw = platform_get_drvdata(pdev); 113 113 const struct reg_config *rcfg = shdw->rcfg; ··· 329 329 { /* Sentinel. */ } 330 330 }; 331 331 332 - static int __init at91_shdwc_probe(struct platform_device *pdev) 332 + static int at91_shdwc_probe(struct platform_device *pdev) 333 333 { 334 334 const struct of_device_id *match; 335 335 struct device_node *np; ··· 421 421 return ret; 422 422 } 423 423 424 - static int __exit at91_shdwc_remove(struct platform_device *pdev) 424 + static void at91_shdwc_remove(struct platform_device *pdev) 425 425 { 426 426 struct shdwc *shdw = platform_get_drvdata(pdev); 427 427 ··· 437 437 iounmap(shdw->pmc_base); 438 438 439 439 clk_disable_unprepare(shdw->sclk); 440 - 441 - return 0; 442 440 } 443 441 444 442 static struct platform_driver at91_shdwc_driver = { 445 - .remove = __exit_p(at91_shdwc_remove), 443 + .probe = at91_shdwc_probe, 444 + .remove_new = at91_shdwc_remove, 446 445 .driver = { 447 446 .name = "at91-shdwc", 448 447 .of_match_table = at91_shdwc_of_match, 449 448 }, 450 449 }; 451 - module_platform_driver_probe(at91_shdwc_driver, at91_shdwc_probe); 450 + module_platform_driver(at91_shdwc_driver); 452 451 453 452 MODULE_AUTHOR("Nicolas Ferre <nicolas.ferre@atmel.com>"); 454 453 MODULE_DESCRIPTION("Atmel shutdown controller driver");
+2 -4
drivers/power/reset/atc260x-poweroff.c
··· 233 233 return ret; 234 234 } 235 235 236 - static int atc260x_pwrc_remove(struct platform_device *pdev) 236 + static void atc260x_pwrc_remove(struct platform_device *pdev) 237 237 { 238 238 struct atc260x_pwrc *priv = platform_get_drvdata(pdev); 239 239 ··· 243 243 } 244 244 245 245 unregister_restart_handler(&priv->restart_nb); 246 - 247 - return 0; 248 246 } 249 247 250 248 static struct platform_driver atc260x_pwrc_driver = { 251 249 .probe = atc260x_pwrc_probe, 252 - .remove = atc260x_pwrc_remove, 250 + .remove_new = atc260x_pwrc_remove, 253 251 .driver = { 254 252 .name = "atc260x-pwrc", 255 253 },
+9 -25
drivers/power/reset/gpio-restart.c
··· 17 17 18 18 struct gpio_restart { 19 19 struct gpio_desc *reset_gpio; 20 - struct notifier_block restart_handler; 21 20 u32 active_delay_ms; 22 21 u32 inactive_delay_ms; 23 22 u32 wait_delay_ms; 24 23 }; 25 24 26 - static int gpio_restart_notify(struct notifier_block *this, 27 - unsigned long mode, void *cmd) 25 + static int gpio_restart_notify(struct sys_off_data *data) 28 26 { 29 - struct gpio_restart *gpio_restart = 30 - container_of(this, struct gpio_restart, restart_handler); 27 + struct gpio_restart *gpio_restart = data->cb_data; 31 28 32 29 /* drive it active, also inactive->active edge */ 33 30 gpiod_direction_output(gpio_restart->reset_gpio, 1); ··· 49 52 { 50 53 struct gpio_restart *gpio_restart; 51 54 bool open_source = false; 55 + int priority = 129; 52 56 u32 property; 53 57 int ret; 54 58 ··· 69 71 return ret; 70 72 } 71 73 72 - gpio_restart->restart_handler.notifier_call = gpio_restart_notify; 73 - gpio_restart->restart_handler.priority = 129; 74 74 gpio_restart->active_delay_ms = 100; 75 75 gpio_restart->inactive_delay_ms = 100; 76 76 gpio_restart->wait_delay_ms = 3000; ··· 79 83 dev_err(&pdev->dev, "Invalid priority property: %u\n", 80 84 property); 81 85 else 82 - gpio_restart->restart_handler.priority = property; 86 + priority = property; 83 87 } 84 88 85 89 of_property_read_u32(pdev->dev.of_node, "active-delay", ··· 89 93 of_property_read_u32(pdev->dev.of_node, "wait-delay", 90 94 &gpio_restart->wait_delay_ms); 91 95 92 - platform_set_drvdata(pdev, gpio_restart); 93 - 94 - ret = register_restart_handler(&gpio_restart->restart_handler); 96 + ret = devm_register_sys_off_handler(&pdev->dev, 97 + SYS_OFF_MODE_RESTART, 98 + priority, 99 + gpio_restart_notify, 100 + gpio_restart); 95 101 if (ret) { 96 102 dev_err(&pdev->dev, "%s: cannot register restart handler, %d\n", 97 103 __func__, ret); ··· 103 105 return 0; 104 106 } 105 107 106 - static void gpio_restart_remove(struct platform_device *pdev) 107 - { 108 - struct gpio_restart *gpio_restart = platform_get_drvdata(pdev); 109 - int ret; 110 - 111 - ret = unregister_restart_handler(&gpio_restart->restart_handler); 112 - if (ret) { 113 - dev_err(&pdev->dev, 114 - "%s: cannot unregister restart handler, %d\n", 115 - __func__, ret); 116 - } 117 - } 118 - 119 108 static const struct of_device_id of_gpio_restart_match[] = { 120 109 { .compatible = "gpio-restart", }, 121 110 {}, ··· 110 125 111 126 static struct platform_driver gpio_restart_driver = { 112 127 .probe = gpio_restart_probe, 113 - .remove_new = gpio_restart_remove, 114 128 .driver = { 115 129 .name = "restart-gpio", 116 130 .of_match_table = of_gpio_restart_match,
+2 -3
drivers/power/reset/ltc2952-poweroff.c
··· 286 286 return 0; 287 287 } 288 288 289 - static int ltc2952_poweroff_remove(struct platform_device *pdev) 289 + static void ltc2952_poweroff_remove(struct platform_device *pdev) 290 290 { 291 291 struct ltc2952_poweroff *data = platform_get_drvdata(pdev); 292 292 ··· 295 295 hrtimer_cancel(&data->timer_wde); 296 296 atomic_notifier_chain_unregister(&panic_notifier_list, 297 297 &data->panic_notifier); 298 - return 0; 299 298 } 300 299 301 300 static const struct of_device_id of_ltc2952_poweroff_match[] = { ··· 305 306 306 307 static struct platform_driver ltc2952_poweroff_driver = { 307 308 .probe = ltc2952_poweroff_probe, 308 - .remove = ltc2952_poweroff_remove, 309 + .remove_new = ltc2952_poweroff_remove, 309 310 .driver = { 310 311 .name = "ltc2952-poweroff", 311 312 .of_match_table = of_ltc2952_poweroff_match,
+2 -4
drivers/power/reset/mt6323-poweroff.c
··· 70 70 return 0; 71 71 } 72 72 73 - static int mt6323_pwrc_remove(struct platform_device *pdev) 73 + static void mt6323_pwrc_remove(struct platform_device *pdev) 74 74 { 75 75 if (pm_power_off == &mt6323_do_pwroff) 76 76 pm_power_off = NULL; 77 - 78 - return 0; 79 77 } 80 78 81 79 static const struct of_device_id mt6323_pwrc_dt_match[] = { ··· 84 86 85 87 static struct platform_driver mt6323_pwrc_driver = { 86 88 .probe = mt6323_pwrc_probe, 87 - .remove = mt6323_pwrc_remove, 89 + .remove_new = mt6323_pwrc_remove, 88 90 .driver = { 89 91 .name = "mt6323-pwrc", 90 92 .of_match_table = mt6323_pwrc_dt_match,
+15 -5
drivers/power/reset/pwr-mlxbf.c
··· 17 17 #include <linux/types.h> 18 18 19 19 struct pwr_mlxbf { 20 - struct work_struct send_work; 20 + struct work_struct reboot_work; 21 + struct work_struct shutdown_work; 21 22 const char *hid; 22 23 }; 23 24 24 - static void pwr_mlxbf_send_work(struct work_struct *work) 25 + static void pwr_mlxbf_reboot_work(struct work_struct *work) 26 + { 27 + acpi_bus_generate_netlink_event("button/reboot.*", "Reboot Button", 0x80, 1); 28 + } 29 + 30 + static void pwr_mlxbf_shutdown_work(struct work_struct *work) 25 31 { 26 32 acpi_bus_generate_netlink_event("button/power.*", "Power Button", 0x80, 1); 27 33 } ··· 39 33 struct pwr_mlxbf *priv = ptr; 40 34 41 35 if (!strncmp(priv->hid, rst_pwr_hid, 8)) 42 - emergency_restart(); 36 + schedule_work(&priv->reboot_work); 43 37 44 38 if (!strncmp(priv->hid, low_pwr_hid, 8)) 45 - schedule_work(&priv->send_work); 39 + schedule_work(&priv->shutdown_work); 46 40 47 41 return IRQ_HANDLED; 48 42 } ··· 70 64 if (irq < 0) 71 65 return dev_err_probe(dev, irq, "Error getting %s irq.\n", priv->hid); 72 66 73 - err = devm_work_autocancel(dev, &priv->send_work, pwr_mlxbf_send_work); 67 + err = devm_work_autocancel(dev, &priv->shutdown_work, pwr_mlxbf_shutdown_work); 68 + if (err) 69 + return err; 70 + 71 + err = devm_work_autocancel(dev, &priv->reboot_work, pwr_mlxbf_reboot_work); 74 72 if (err) 75 73 return err; 76 74
+2 -3
drivers/power/reset/qnap-poweroff.c
··· 111 111 return 0; 112 112 } 113 113 114 - static int qnap_power_off_remove(struct platform_device *pdev) 114 + static void qnap_power_off_remove(struct platform_device *pdev) 115 115 { 116 116 pm_power_off = NULL; 117 - return 0; 118 117 } 119 118 120 119 static struct platform_driver qnap_power_off_driver = { 121 120 .probe = qnap_power_off_probe, 122 - .remove = qnap_power_off_remove, 121 + .remove_new = qnap_power_off_remove, 123 122 .driver = { 124 123 .name = "qnap_power_off", 125 124 .of_match_table = of_match_ptr(qnap_power_off_of_match_table),
+2 -4
drivers/power/reset/regulator-poweroff.c
··· 52 52 return 0; 53 53 } 54 54 55 - static int regulator_poweroff_remove(__maybe_unused struct platform_device *pdev) 55 + static void regulator_poweroff_remove(struct platform_device *pdev) 56 56 { 57 57 if (pm_power_off == &regulator_poweroff_do_poweroff) 58 58 pm_power_off = NULL; 59 - 60 - return 0; 61 59 } 62 60 63 61 static const struct of_device_id of_regulator_poweroff_match[] = { ··· 66 68 67 69 static struct platform_driver regulator_poweroff_driver = { 68 70 .probe = regulator_poweroff_probe, 69 - .remove = regulator_poweroff_remove, 71 + .remove_new = regulator_poweroff_remove, 70 72 .driver = { 71 73 .name = "poweroff-regulator", 72 74 .of_match_table = of_regulator_poweroff_match,
+2 -4
drivers/power/reset/restart-poweroff.c
··· 33 33 return 0; 34 34 } 35 35 36 - static int restart_poweroff_remove(struct platform_device *pdev) 36 + static void restart_poweroff_remove(struct platform_device *pdev) 37 37 { 38 38 if (pm_power_off == &restart_poweroff_do_poweroff) 39 39 pm_power_off = NULL; 40 - 41 - return 0; 42 40 } 43 41 44 42 static const struct of_device_id of_restart_poweroff_match[] = { ··· 47 49 48 50 static struct platform_driver restart_poweroff_driver = { 49 51 .probe = restart_poweroff_probe, 50 - .remove = restart_poweroff_remove, 52 + .remove_new = restart_poweroff_remove, 51 53 .driver = { 52 54 .name = "poweroff-restart", 53 55 .of_match_table = of_restart_poweroff_match,
+2 -3
drivers/power/reset/rmobile-reset.c
··· 59 59 return error; 60 60 } 61 61 62 - static int rmobile_reset_remove(struct platform_device *pdev) 62 + static void rmobile_reset_remove(struct platform_device *pdev) 63 63 { 64 64 unregister_restart_handler(&rmobile_reset_nb); 65 65 iounmap(sysc_base2); 66 - return 0; 67 66 } 68 67 69 68 static const struct of_device_id rmobile_reset_of_match[] = { ··· 73 74 74 75 static struct platform_driver rmobile_reset_driver = { 75 76 .probe = rmobile_reset_probe, 76 - .remove = rmobile_reset_remove, 77 + .remove_new = rmobile_reset_remove, 77 78 .driver = { 78 79 .name = "rmobile_reset", 79 80 .of_match_table = rmobile_reset_of_match,
+2 -4
drivers/power/reset/syscon-poweroff.c
··· 76 76 return 0; 77 77 } 78 78 79 - static int syscon_poweroff_remove(struct platform_device *pdev) 79 + static void syscon_poweroff_remove(struct platform_device *pdev) 80 80 { 81 81 if (pm_power_off == syscon_poweroff) 82 82 pm_power_off = NULL; 83 - 84 - return 0; 85 83 } 86 84 87 85 static const struct of_device_id syscon_poweroff_of_match[] = { ··· 89 91 90 92 static struct platform_driver syscon_poweroff_driver = { 91 93 .probe = syscon_poweroff_probe, 92 - .remove = syscon_poweroff_remove, 94 + .remove_new = syscon_poweroff_remove, 93 95 .driver = { 94 96 .name = "syscon-poweroff", 95 97 .of_match_table = syscon_poweroff_of_match,
+7 -5
drivers/power/reset/tps65086-restart.c
··· 62 62 return 0; 63 63 } 64 64 65 - static int tps65086_restart_remove(struct platform_device *pdev) 65 + static void tps65086_restart_remove(struct platform_device *pdev) 66 66 { 67 67 struct tps65086_restart *tps65086_restart = platform_get_drvdata(pdev); 68 68 int ret; 69 69 70 70 ret = unregister_restart_handler(&tps65086_restart->handler); 71 71 if (ret) { 72 + /* 73 + * tps65086_restart_probe() registered the restart handler. So 74 + * unregistering should work fine. Checking the error code 75 + * shouldn't be needed, still doing it for completeness. 76 + */ 72 77 dev_err(&pdev->dev, "%s: cannot unregister restart handler: %d\n", 73 78 __func__, ret); 74 - return -ENODEV; 75 79 } 76 - 77 - return 0; 78 80 } 79 81 80 82 static const struct platform_device_id tps65086_restart_id_table[] = { ··· 90 88 .name = "tps65086-restart", 91 89 }, 92 90 .probe = tps65086_restart_probe, 93 - .remove = tps65086_restart_remove, 91 + .remove_new = tps65086_restart_remove, 94 92 .id_table = tps65086_restart_id_table, 95 93 }; 96 94 module_platform_driver(tps65086_restart_driver);
+355 -104
drivers/power/supply/bq24190_charger.c
··· 36 36 #define BQ24190_REG_POC_WDT_RESET_SHIFT 6 37 37 #define BQ24190_REG_POC_CHG_CONFIG_MASK (BIT(5) | BIT(4)) 38 38 #define BQ24190_REG_POC_CHG_CONFIG_SHIFT 4 39 - #define BQ24190_REG_POC_CHG_CONFIG_DISABLE 0x0 40 - #define BQ24190_REG_POC_CHG_CONFIG_CHARGE 0x1 41 - #define BQ24190_REG_POC_CHG_CONFIG_OTG 0x2 42 - #define BQ24190_REG_POC_CHG_CONFIG_OTG_ALT 0x3 39 + #define BQ24190_REG_POC_CHG_CONFIG_DISABLE 0x0 40 + #define BQ24190_REG_POC_CHG_CONFIG_CHARGE 0x1 41 + #define BQ24190_REG_POC_CHG_CONFIG_OTG 0x2 42 + #define BQ24190_REG_POC_CHG_CONFIG_OTG_ALT 0x3 43 + #define BQ24296_REG_POC_OTG_CONFIG_MASK BIT(5) 44 + #define BQ24296_REG_POC_OTG_CONFIG_SHIFT 5 45 + #define BQ24296_REG_POC_CHG_CONFIG_MASK BIT(4) 46 + #define BQ24296_REG_POC_CHG_CONFIG_SHIFT 4 47 + #define BQ24296_REG_POC_OTG_CONFIG_DISABLE 0x0 48 + #define BQ24296_REG_POC_OTG_CONFIG_OTG 0x1 43 49 #define BQ24190_REG_POC_SYS_MIN_MASK (BIT(3) | BIT(2) | BIT(1)) 44 50 #define BQ24190_REG_POC_SYS_MIN_SHIFT 1 45 51 #define BQ24190_REG_POC_SYS_MIN_MIN 3000 ··· 140 134 #define BQ24190_REG_F_BAT_FAULT_SHIFT 3 141 135 #define BQ24190_REG_F_NTC_FAULT_MASK (BIT(2) | BIT(1) | BIT(0)) 142 136 #define BQ24190_REG_F_NTC_FAULT_SHIFT 0 137 + #define BQ24296_REG_F_NTC_FAULT_MASK (BIT(1) | BIT(0)) 138 + #define BQ24296_REG_F_NTC_FAULT_SHIFT 0 143 139 144 140 #define BQ24190_REG_VPRS 0x0A /* Vendor/Part/Revision Status */ 145 141 #define BQ24190_REG_VPRS_PN_MASK (BIT(5) | BIT(4) | BIT(3)) 146 142 #define BQ24190_REG_VPRS_PN_SHIFT 3 147 - #define BQ24190_REG_VPRS_PN_24190 0x4 148 - #define BQ24190_REG_VPRS_PN_24192 0x5 /* Also 24193, 24196 */ 149 - #define BQ24190_REG_VPRS_PN_24192I 0x3 143 + #define BQ24190_REG_VPRS_PN_24190 0x4 144 + #define BQ24190_REG_VPRS_PN_24192 0x5 /* Also 24193, 24196 */ 145 + #define BQ24190_REG_VPRS_PN_24192I 0x3 146 + #define BQ24296_REG_VPRS_PN_MASK (BIT(7) | BIT(6) | BIT(5)) 147 + #define BQ24296_REG_VPRS_PN_SHIFT 5 148 + #define BQ24296_REG_VPRS_PN_24296 0x1 150 149 #define BQ24190_REG_VPRS_TS_PROFILE_MASK BIT(2) 151 150 #define BQ24190_REG_VPRS_TS_PROFILE_SHIFT 2 152 151 #define BQ24190_REG_VPRS_DEV_REG_MASK (BIT(1) | BIT(0)) 153 152 #define BQ24190_REG_VPRS_DEV_REG_SHIFT 0 153 + 154 + /* 155 + * The tables below provide a 2-way mapping for the value that goes in 156 + * the register field and the real-world value that it represents. 157 + * The index of the array is the value that goes in the register; the 158 + * number at that index in the array is the real-world value that it 159 + * represents. 160 + */ 161 + 162 + /* REG00[2:0] (IINLIM) in uAh */ 163 + static const int bq24190_isc_iinlim_values[] = { 164 + 100000, 150000, 500000, 900000, 1200000, 1500000, 2000000, 3000000 165 + }; 166 + 167 + /* REG02[7:2] (ICHG) in uAh */ 168 + static const int bq24190_ccc_ichg_values[] = { 169 + 512000, 576000, 640000, 704000, 768000, 832000, 896000, 960000, 170 + 1024000, 1088000, 1152000, 1216000, 1280000, 1344000, 1408000, 1472000, 171 + 1536000, 1600000, 1664000, 1728000, 1792000, 1856000, 1920000, 1984000, 172 + 2048000, 2112000, 2176000, 2240000, 2304000, 2368000, 2432000, 2496000, 173 + 2560000, 2624000, 2688000, 2752000, 2816000, 2880000, 2944000, 3008000, 174 + 3072000, 3136000, 3200000, 3264000, 3328000, 3392000, 3456000, 3520000, 175 + 3584000, 3648000, 3712000, 3776000, 3840000, 3904000, 3968000, 4032000, 176 + 4096000, 4160000, 4224000, 4288000, 4352000, 4416000, 4480000, 4544000 177 + }; 178 + 179 + /* ICHG higher than 3008mA is not supported in BQ24296 */ 180 + #define BQ24296_CCC_ICHG_VALUES_LEN 40 181 + 182 + /* REG04[7:2] (VREG) in uV */ 183 + static const int bq24190_cvc_vreg_values[] = { 184 + 3504000, 3520000, 3536000, 3552000, 3568000, 3584000, 3600000, 3616000, 185 + 3632000, 3648000, 3664000, 3680000, 3696000, 3712000, 3728000, 3744000, 186 + 3760000, 3776000, 3792000, 3808000, 3824000, 3840000, 3856000, 3872000, 187 + 3888000, 3904000, 3920000, 3936000, 3952000, 3968000, 3984000, 4000000, 188 + 4016000, 4032000, 4048000, 4064000, 4080000, 4096000, 4112000, 4128000, 189 + 4144000, 4160000, 4176000, 4192000, 4208000, 4224000, 4240000, 4256000, 190 + 4272000, 4288000, 4304000, 4320000, 4336000, 4352000, 4368000, 4384000, 191 + 4400000 192 + }; 193 + 194 + /* REG06[1:0] (TREG) in tenths of degrees Celsius */ 195 + static const int bq24190_ictrc_treg_values[] = { 196 + 600, 800, 1000, 1200 197 + }; 198 + 199 + enum bq24190_chip { 200 + BQ24190, 201 + BQ24192, 202 + BQ24192i, 203 + BQ24196, 204 + BQ24296, 205 + }; 154 206 155 207 /* 156 208 * The FAULT register is latched by the bq24190 (except for NTC_FAULT) ··· 240 176 u8 f_reg; 241 177 u8 ss_reg; 242 178 u8 watchdog; 179 + const struct bq24190_chip_info *info; 180 + }; 181 + 182 + struct bq24190_chip_info { 183 + int ichg_array_size; 184 + #ifdef CONFIG_REGULATOR 185 + const struct regulator_desc *vbus_desc; 186 + #endif 187 + int (*check_chip)(struct bq24190_dev_info *bdi); 188 + int (*set_chg_config)(struct bq24190_dev_info *bdi, const u8 chg_config); 189 + int (*set_otg_vbus)(struct bq24190_dev_info *bdi, bool enable); 190 + u8 ntc_fault_mask; 191 + int (*get_ntc_status)(const u8 value); 243 192 }; 244 193 245 194 static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi, ··· 263 186 EXTCON_NONE, 264 187 }; 265 188 266 - /* 267 - * The tables below provide a 2-way mapping for the value that goes in 268 - * the register field and the real-world value that it represents. 269 - * The index of the array is the value that goes in the register; the 270 - * number at that index in the array is the real-world value that it 271 - * represents. 272 - */ 273 - 274 - /* REG00[2:0] (IINLIM) in uAh */ 275 - static const int bq24190_isc_iinlim_values[] = { 276 - 100000, 150000, 500000, 900000, 1200000, 1500000, 2000000, 3000000 277 - }; 278 - 279 - /* REG02[7:2] (ICHG) in uAh */ 280 - static const int bq24190_ccc_ichg_values[] = { 281 - 512000, 576000, 640000, 704000, 768000, 832000, 896000, 960000, 282 - 1024000, 1088000, 1152000, 1216000, 1280000, 1344000, 1408000, 1472000, 283 - 1536000, 1600000, 1664000, 1728000, 1792000, 1856000, 1920000, 1984000, 284 - 2048000, 2112000, 2176000, 2240000, 2304000, 2368000, 2432000, 2496000, 285 - 2560000, 2624000, 2688000, 2752000, 2816000, 2880000, 2944000, 3008000, 286 - 3072000, 3136000, 3200000, 3264000, 3328000, 3392000, 3456000, 3520000, 287 - 3584000, 3648000, 3712000, 3776000, 3840000, 3904000, 3968000, 4032000, 288 - 4096000, 4160000, 4224000, 4288000, 4352000, 4416000, 4480000, 4544000 289 - }; 290 - 291 - /* REG04[7:2] (VREG) in uV */ 292 - static const int bq24190_cvc_vreg_values[] = { 293 - 3504000, 3520000, 3536000, 3552000, 3568000, 3584000, 3600000, 3616000, 294 - 3632000, 3648000, 3664000, 3680000, 3696000, 3712000, 3728000, 3744000, 295 - 3760000, 3776000, 3792000, 3808000, 3824000, 3840000, 3856000, 3872000, 296 - 3888000, 3904000, 3920000, 3936000, 3952000, 3968000, 3984000, 4000000, 297 - 4016000, 4032000, 4048000, 4064000, 4080000, 4096000, 4112000, 4128000, 298 - 4144000, 4160000, 4176000, 4192000, 4208000, 4224000, 4240000, 4256000, 299 - 4272000, 4288000, 4304000, 4320000, 4336000, 4352000, 4368000, 4384000, 300 - 4400000 301 - }; 302 - 303 - /* REG06[1:0] (TREG) in tenths of degrees Celsius */ 304 - static const int bq24190_ictrc_treg_values[] = { 305 - 600, 800, 1000, 1200 306 - }; 307 189 308 190 /* 309 191 * Return the index in 'tbl' of greatest value that is less than or equal to ··· 565 529 return ret; 566 530 } 567 531 532 + static int bq24296_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable) 533 + { 534 + int ret; 535 + 536 + ret = pm_runtime_resume_and_get(bdi->dev); 537 + if (ret < 0) { 538 + dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret); 539 + return ret; 540 + } 541 + 542 + bdi->otg_vbus_enabled = enable; 543 + if (enable) { 544 + ret = bq24190_write_mask(bdi, BQ24190_REG_POC, 545 + BQ24296_REG_POC_CHG_CONFIG_MASK, 546 + BQ24296_REG_POC_CHG_CONFIG_SHIFT, 547 + BQ24190_REG_POC_CHG_CONFIG_DISABLE); 548 + 549 + if (ret < 0) 550 + goto out; 551 + 552 + ret = bq24190_write_mask(bdi, BQ24190_REG_POC, 553 + BQ24296_REG_POC_OTG_CONFIG_MASK, 554 + BQ24296_REG_POC_CHG_CONFIG_SHIFT, 555 + BQ24296_REG_POC_OTG_CONFIG_OTG); 556 + } else 557 + ret = bq24190_write_mask(bdi, BQ24190_REG_POC, 558 + BQ24296_REG_POC_OTG_CONFIG_MASK, 559 + BQ24296_REG_POC_CHG_CONFIG_SHIFT, 560 + BQ24296_REG_POC_OTG_CONFIG_DISABLE); 561 + 562 + out: 563 + pm_runtime_mark_last_busy(bdi->dev); 564 + pm_runtime_put_autosuspend(bdi->dev); 565 + 566 + return ret; 567 + } 568 + 568 569 #ifdef CONFIG_REGULATOR 569 570 static int bq24190_vbus_enable(struct regulator_dev *dev) 570 571 { ··· 640 567 return bdi->otg_vbus_enabled; 641 568 } 642 569 570 + static int bq24296_vbus_enable(struct regulator_dev *dev) 571 + { 572 + return bq24296_set_otg_vbus(rdev_get_drvdata(dev), true); 573 + } 574 + 575 + static int bq24296_vbus_disable(struct regulator_dev *dev) 576 + { 577 + return bq24296_set_otg_vbus(rdev_get_drvdata(dev), false); 578 + } 579 + 580 + static int bq24296_vbus_is_enabled(struct regulator_dev *dev) 581 + { 582 + struct bq24190_dev_info *bdi = rdev_get_drvdata(dev); 583 + int ret; 584 + u8 val; 585 + 586 + ret = pm_runtime_resume_and_get(bdi->dev); 587 + if (ret < 0) { 588 + dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret); 589 + return ret; 590 + } 591 + 592 + ret = bq24190_read_mask(bdi, BQ24190_REG_POC, 593 + BQ24296_REG_POC_OTG_CONFIG_MASK, 594 + BQ24296_REG_POC_OTG_CONFIG_SHIFT, &val); 595 + 596 + pm_runtime_mark_last_busy(bdi->dev); 597 + pm_runtime_put_autosuspend(bdi->dev); 598 + 599 + if (ret) 600 + return ret; 601 + 602 + bdi->otg_vbus_enabled = (val == BQ24296_REG_POC_OTG_CONFIG_OTG); 603 + 604 + return bdi->otg_vbus_enabled; 605 + } 606 + 643 607 static const struct regulator_ops bq24190_vbus_ops = { 644 608 .enable = bq24190_vbus_enable, 645 609 .disable = bq24190_vbus_disable, ··· 689 579 .type = REGULATOR_VOLTAGE, 690 580 .owner = THIS_MODULE, 691 581 .ops = &bq24190_vbus_ops, 582 + .fixed_uV = 5000000, 583 + .n_voltages = 1, 584 + }; 585 + 586 + static const struct regulator_ops bq24296_vbus_ops = { 587 + .enable = bq24296_vbus_enable, 588 + .disable = bq24296_vbus_disable, 589 + .is_enabled = bq24296_vbus_is_enabled, 590 + }; 591 + 592 + static const struct regulator_desc bq24296_vbus_desc = { 593 + .name = "usb_otg_vbus", 594 + .of_match = "usb-otg-vbus", 595 + .type = REGULATOR_VOLTAGE, 596 + .owner = THIS_MODULE, 597 + .ops = &bq24296_vbus_ops, 692 598 .fixed_uV = 5000000, 693 599 .n_voltages = 1, 694 600 }; ··· 728 602 else 729 603 cfg.init_data = &bq24190_vbus_init_data; 730 604 cfg.driver_data = bdi; 731 - reg = devm_regulator_register(bdi->dev, &bq24190_vbus_desc, &cfg); 605 + reg = devm_regulator_register(bdi->dev, bdi->info->vbus_desc, &cfg); 732 606 if (IS_ERR(reg)) { 733 607 ret = PTR_ERR(reg); 734 608 dev_err(bdi->dev, "Can't register regulator: %d\n", ret); ··· 804 678 BQ24190_REG_CCC_ICHG_MASK, 805 679 BQ24190_REG_CCC_ICHG_SHIFT, 806 680 bq24190_ccc_ichg_values, 807 - ARRAY_SIZE(bq24190_ccc_ichg_values), 681 + bdi->info->ichg_array_size, 808 682 bdi->ichg); 809 683 if (ret < 0) 810 684 return ret; ··· 903 777 return 0; 904 778 } 905 779 780 + static int bq24190_battery_set_chg_config(struct bq24190_dev_info *bdi, 781 + const u8 chg_config) 782 + { 783 + return bq24190_write_mask(bdi, BQ24190_REG_POC, 784 + BQ24190_REG_POC_CHG_CONFIG_MASK, 785 + BQ24190_REG_POC_CHG_CONFIG_SHIFT, 786 + chg_config); 787 + } 788 + 789 + static int bq24296_battery_set_chg_config(struct bq24190_dev_info *bdi, 790 + const u8 chg_config) 791 + { 792 + return bq24190_write_mask(bdi, BQ24190_REG_POC, 793 + BQ24296_REG_POC_CHG_CONFIG_MASK, 794 + BQ24296_REG_POC_CHG_CONFIG_SHIFT, 795 + chg_config); 796 + } 797 + 906 798 static int bq24190_charger_set_charge_type(struct bq24190_dev_info *bdi, 907 799 const union power_supply_propval *val) 908 800 { ··· 979 835 return ret; 980 836 } 981 837 982 - return bq24190_write_mask(bdi, BQ24190_REG_POC, 983 - BQ24190_REG_POC_CHG_CONFIG_MASK, 984 - BQ24190_REG_POC_CHG_CONFIG_SHIFT, chg_config); 838 + return bdi->info->set_chg_config(bdi, chg_config); 839 + } 840 + 841 + static int bq24190_charger_get_ntc_status(u8 value) 842 + { 843 + int health; 844 + 845 + switch (value >> BQ24190_REG_F_NTC_FAULT_SHIFT & 0x7) { 846 + case 0x1: /* TS1 Cold */ 847 + case 0x3: /* TS2 Cold */ 848 + case 0x5: /* Both Cold */ 849 + health = POWER_SUPPLY_HEALTH_COLD; 850 + break; 851 + case 0x2: /* TS1 Hot */ 852 + case 0x4: /* TS2 Hot */ 853 + case 0x6: /* Both Hot */ 854 + health = POWER_SUPPLY_HEALTH_OVERHEAT; 855 + break; 856 + default: 857 + health = POWER_SUPPLY_HEALTH_UNKNOWN; 858 + } 859 + 860 + return health; 861 + } 862 + 863 + static int bq24296_charger_get_ntc_status(u8 value) 864 + { 865 + int health; 866 + 867 + switch (value >> BQ24296_REG_F_NTC_FAULT_SHIFT & 0x3) { 868 + case 0x0: /* Normal */ 869 + health = POWER_SUPPLY_HEALTH_GOOD; 870 + break; 871 + case 0x1: /* Hot */ 872 + health = POWER_SUPPLY_HEALTH_OVERHEAT; 873 + break; 874 + case 0x2: /* Cold */ 875 + health = POWER_SUPPLY_HEALTH_COLD; 876 + break; 877 + default: 878 + health = POWER_SUPPLY_HEALTH_UNKNOWN; 879 + } 880 + 881 + return health; 985 882 } 986 883 987 884 static int bq24190_charger_get_health(struct bq24190_dev_info *bdi, ··· 1035 850 v = bdi->f_reg; 1036 851 mutex_unlock(&bdi->f_reg_lock); 1037 852 1038 - if (v & BQ24190_REG_F_NTC_FAULT_MASK) { 1039 - switch (v >> BQ24190_REG_F_NTC_FAULT_SHIFT & 0x7) { 1040 - case 0x1: /* TS1 Cold */ 1041 - case 0x3: /* TS2 Cold */ 1042 - case 0x5: /* Both Cold */ 1043 - health = POWER_SUPPLY_HEALTH_COLD; 1044 - break; 1045 - case 0x2: /* TS1 Hot */ 1046 - case 0x4: /* TS2 Hot */ 1047 - case 0x6: /* Both Hot */ 1048 - health = POWER_SUPPLY_HEALTH_OVERHEAT; 1049 - break; 1050 - default: 1051 - health = POWER_SUPPLY_HEALTH_UNKNOWN; 1052 - } 853 + if (v & bdi->info->ntc_fault_mask) { 854 + health = bdi->info->get_ntc_status(v); 1053 855 } else if (v & BQ24190_REG_F_BAT_FAULT_MASK) { 1054 856 health = POWER_SUPPLY_HEALTH_OVERVOLTAGE; 1055 857 } else if (v & BQ24190_REG_F_CHRG_FAULT_MASK) { ··· 1187 1015 ret = bq24190_get_field_val(bdi, BQ24190_REG_CCC, 1188 1016 BQ24190_REG_CCC_ICHG_MASK, BQ24190_REG_CCC_ICHG_SHIFT, 1189 1017 bq24190_ccc_ichg_values, 1190 - ARRAY_SIZE(bq24190_ccc_ichg_values), &curr); 1018 + bdi->info->ichg_array_size, &curr); 1191 1019 if (ret < 0) 1192 1020 return ret; 1193 1021 ··· 1227 1055 ret = bq24190_set_field_val(bdi, BQ24190_REG_CCC, 1228 1056 BQ24190_REG_CCC_ICHG_MASK, BQ24190_REG_CCC_ICHG_SHIFT, 1229 1057 bq24190_ccc_ichg_values, 1230 - ARRAY_SIZE(bq24190_ccc_ichg_values), curr); 1058 + bdi->info->ichg_array_size, curr); 1231 1059 if (ret < 0) 1232 1060 return ret; 1233 1061 ··· 1567 1395 if (v & BQ24190_REG_F_BAT_FAULT_MASK) { 1568 1396 health = POWER_SUPPLY_HEALTH_OVERVOLTAGE; 1569 1397 } else { 1570 - v &= BQ24190_REG_F_NTC_FAULT_MASK; 1571 - v >>= BQ24190_REG_F_NTC_FAULT_SHIFT; 1398 + v &= bdi->info->ntc_fault_mask; 1572 1399 1573 - switch (v) { 1574 - case 0x0: /* Normal */ 1575 - health = POWER_SUPPLY_HEALTH_GOOD; 1576 - break; 1577 - case 0x1: /* TS1 Cold */ 1578 - case 0x3: /* TS2 Cold */ 1579 - case 0x5: /* Both Cold */ 1580 - health = POWER_SUPPLY_HEALTH_COLD; 1581 - break; 1582 - case 0x2: /* TS1 Hot */ 1583 - case 0x4: /* TS2 Hot */ 1584 - case 0x6: /* Both Hot */ 1585 - health = POWER_SUPPLY_HEALTH_OVERHEAT; 1586 - break; 1587 - default: 1588 - health = POWER_SUPPLY_HEALTH_UNKNOWN; 1589 - } 1400 + health = v ? bdi->info->get_ntc_status(v) : POWER_SUPPLY_HEALTH_GOOD; 1590 1401 } 1591 1402 1592 1403 val->intval = health; ··· 1756 1601 static void bq24190_check_status(struct bq24190_dev_info *bdi) 1757 1602 { 1758 1603 const u8 battery_mask_ss = BQ24190_REG_SS_CHRG_STAT_MASK; 1759 - const u8 battery_mask_f = BQ24190_REG_F_BAT_FAULT_MASK 1760 - | BQ24190_REG_F_NTC_FAULT_MASK; 1604 + u8 battery_mask_f = BQ24190_REG_F_BAT_FAULT_MASK; 1761 1605 bool alert_charger = false, alert_battery = false; 1762 1606 u8 ss_reg = 0, f_reg = 0; 1763 1607 int i, ret; 1608 + 1609 + battery_mask_f |= bdi->info->ntc_fault_mask; 1764 1610 1765 1611 ret = bq24190_read(bdi, BQ24190_REG_SS, &ss_reg); 1766 1612 if (ret < 0) { ··· 1789 1633 !!(f_reg & BQ24190_REG_F_BOOST_FAULT_MASK), 1790 1634 !!(f_reg & BQ24190_REG_F_CHRG_FAULT_MASK), 1791 1635 !!(f_reg & BQ24190_REG_F_BAT_FAULT_MASK), 1792 - !!(f_reg & BQ24190_REG_F_NTC_FAULT_MASK)); 1636 + !!(f_reg & bdi->info->ntc_fault_mask)); 1793 1637 1794 1638 mutex_lock(&bdi->f_reg_lock); 1795 1639 if ((bdi->f_reg & battery_mask_f) != (f_reg & battery_mask_f)) ··· 1852 1696 return IRQ_HANDLED; 1853 1697 } 1854 1698 1855 - static int bq24190_hw_init(struct bq24190_dev_info *bdi) 1699 + static int bq24190_check_chip(struct bq24190_dev_info *bdi) 1856 1700 { 1857 1701 u8 v; 1858 1702 int ret; 1859 1703 1860 - /* First check that the device really is what its supposed to be */ 1861 1704 ret = bq24190_read_mask(bdi, BQ24190_REG_VPRS, 1862 1705 BQ24190_REG_VPRS_PN_MASK, 1863 1706 BQ24190_REG_VPRS_PN_SHIFT, ··· 1873 1718 dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v); 1874 1719 return -ENODEV; 1875 1720 } 1721 + 1722 + return 0; 1723 + } 1724 + 1725 + static int bq24296_check_chip(struct bq24190_dev_info *bdi) 1726 + { 1727 + u8 v; 1728 + int ret; 1729 + 1730 + ret = bq24190_read_mask(bdi, BQ24190_REG_VPRS, 1731 + BQ24296_REG_VPRS_PN_MASK, 1732 + BQ24296_REG_VPRS_PN_SHIFT, 1733 + &v); 1734 + if (ret < 0) 1735 + return ret; 1736 + 1737 + switch (v) { 1738 + case BQ24296_REG_VPRS_PN_24296: 1739 + break; 1740 + default: 1741 + dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v); 1742 + return -ENODEV; 1743 + } 1744 + 1745 + return 0; 1746 + } 1747 + 1748 + static int bq24190_hw_init(struct bq24190_dev_info *bdi) 1749 + { 1750 + int ret; 1751 + 1752 + ret = bdi->info->check_chip(bdi); 1753 + if (ret < 0) 1754 + return ret; 1876 1755 1877 1756 ret = bq24190_register_reset(bdi); 1878 1757 if (ret < 0) ··· 1925 1736 struct power_supply_battery_info *info; 1926 1737 int v, idx; 1927 1738 1928 - idx = ARRAY_SIZE(bq24190_ccc_ichg_values) - 1; 1739 + idx = bdi->info->ichg_array_size - 1; 1740 + 1929 1741 bdi->ichg_max = bq24190_ccc_ichg_values[idx]; 1930 1742 1931 1743 idx = ARRAY_SIZE(bq24190_cvc_vreg_values) - 1; ··· 1971 1781 return 0; 1972 1782 } 1973 1783 1784 + static const struct bq24190_chip_info bq24190_chip_info_tbl[] = { 1785 + [BQ24190] = { 1786 + .ichg_array_size = ARRAY_SIZE(bq24190_ccc_ichg_values), 1787 + #ifdef CONFIG_REGULATOR 1788 + .vbus_desc = &bq24190_vbus_desc, 1789 + #endif 1790 + .check_chip = bq24190_check_chip, 1791 + .set_chg_config = bq24190_battery_set_chg_config, 1792 + .ntc_fault_mask = BQ24190_REG_F_NTC_FAULT_MASK, 1793 + .get_ntc_status = bq24190_charger_get_ntc_status, 1794 + .set_otg_vbus = bq24190_set_otg_vbus, 1795 + }, 1796 + [BQ24192] = { 1797 + .ichg_array_size = ARRAY_SIZE(bq24190_ccc_ichg_values), 1798 + #ifdef CONFIG_REGULATOR 1799 + .vbus_desc = &bq24190_vbus_desc, 1800 + #endif 1801 + .check_chip = bq24190_check_chip, 1802 + .set_chg_config = bq24190_battery_set_chg_config, 1803 + .ntc_fault_mask = BQ24190_REG_F_NTC_FAULT_MASK, 1804 + .get_ntc_status = bq24190_charger_get_ntc_status, 1805 + .set_otg_vbus = bq24190_set_otg_vbus, 1806 + }, 1807 + [BQ24192i] = { 1808 + .ichg_array_size = ARRAY_SIZE(bq24190_ccc_ichg_values), 1809 + #ifdef CONFIG_REGULATOR 1810 + .vbus_desc = &bq24190_vbus_desc, 1811 + #endif 1812 + .check_chip = bq24190_check_chip, 1813 + .set_chg_config = bq24190_battery_set_chg_config, 1814 + .ntc_fault_mask = BQ24190_REG_F_NTC_FAULT_MASK, 1815 + .get_ntc_status = bq24190_charger_get_ntc_status, 1816 + .set_otg_vbus = bq24190_set_otg_vbus, 1817 + }, 1818 + [BQ24196] = { 1819 + .ichg_array_size = ARRAY_SIZE(bq24190_ccc_ichg_values), 1820 + #ifdef CONFIG_REGULATOR 1821 + .vbus_desc = &bq24190_vbus_desc, 1822 + #endif 1823 + .check_chip = bq24190_check_chip, 1824 + .set_chg_config = bq24190_battery_set_chg_config, 1825 + .ntc_fault_mask = BQ24190_REG_F_NTC_FAULT_MASK, 1826 + .get_ntc_status = bq24190_charger_get_ntc_status, 1827 + .set_otg_vbus = bq24190_set_otg_vbus, 1828 + }, 1829 + [BQ24296] = { 1830 + .ichg_array_size = BQ24296_CCC_ICHG_VALUES_LEN, 1831 + #ifdef CONFIG_REGULATOR 1832 + .vbus_desc = &bq24296_vbus_desc, 1833 + #endif 1834 + .check_chip = bq24296_check_chip, 1835 + .set_chg_config = bq24296_battery_set_chg_config, 1836 + .ntc_fault_mask = BQ24296_REG_F_NTC_FAULT_MASK, 1837 + .get_ntc_status = bq24296_charger_get_ntc_status, 1838 + .set_otg_vbus = bq24296_set_otg_vbus, 1839 + }, 1840 + }; 1841 + 1974 1842 static int bq24190_probe(struct i2c_client *client) 1975 1843 { 1976 1844 const struct i2c_device_id *id = i2c_client_get_device_id(client); ··· 2052 1804 bdi->client = client; 2053 1805 bdi->dev = dev; 2054 1806 strscpy(bdi->model_name, id->name, sizeof(bdi->model_name)); 1807 + bdi->info = i2c_get_match_data(client); 2055 1808 mutex_init(&bdi->f_reg_lock); 2056 1809 bdi->charge_type = POWER_SUPPLY_CHARGE_TYPE_FAST; 2057 1810 bdi->f_reg = 0; ··· 2189 1940 struct bq24190_dev_info *bdi = i2c_get_clientdata(client); 2190 1941 2191 1942 /* Turn off 5V boost regulator on shutdown */ 2192 - bq24190_set_otg_vbus(bdi, false); 1943 + bdi->info->set_otg_vbus(bdi, false); 2193 1944 } 2194 1945 2195 1946 static __maybe_unused int bq24190_runtime_suspend(struct device *dev) ··· 2278 2029 }; 2279 2030 2280 2031 static const struct i2c_device_id bq24190_i2c_ids[] = { 2281 - { "bq24190" }, 2282 - { "bq24192" }, 2283 - { "bq24192i" }, 2284 - { "bq24196" }, 2032 + { "bq24190", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24190] }, 2033 + { "bq24192", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24192] }, 2034 + { "bq24192i", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24192i] }, 2035 + { "bq24196", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24196] }, 2036 + { "bq24296", (kernel_ulong_t)&bq24190_chip_info_tbl[BQ24296] }, 2285 2037 { }, 2286 2038 }; 2287 2039 MODULE_DEVICE_TABLE(i2c, bq24190_i2c_ids); 2288 2040 2289 2041 static const struct of_device_id bq24190_of_match[] = { 2290 - { .compatible = "ti,bq24190", }, 2291 - { .compatible = "ti,bq24192", }, 2292 - { .compatible = "ti,bq24192i", }, 2293 - { .compatible = "ti,bq24196", }, 2042 + { .compatible = "ti,bq24190", .data = &bq24190_chip_info_tbl[BQ24190] }, 2043 + { .compatible = "ti,bq24192", .data = &bq24190_chip_info_tbl[BQ24192] }, 2044 + { .compatible = "ti,bq24192i", .data = &bq24190_chip_info_tbl[BQ24192i] }, 2045 + { .compatible = "ti,bq24196", .data = &bq24190_chip_info_tbl[BQ24196] }, 2046 + { .compatible = "ti,bq24296", .data = &bq24190_chip_info_tbl[BQ24296] }, 2294 2047 { }, 2295 2048 }; 2296 2049 MODULE_DEVICE_TABLE(of, bq24190_of_match);
+4 -1
drivers/power/supply/bq256xx_charger.c
··· 1574 1574 wd_reg_val = i; 1575 1575 break; 1576 1576 } 1577 - if (bq->watchdog_timer > bq256xx_watchdog_time[i] && 1577 + if (i + 1 < BQ256XX_NUM_WD_VAL && 1578 + bq->watchdog_timer > bq256xx_watchdog_time[i] && 1578 1579 bq->watchdog_timer < bq256xx_watchdog_time[i + 1]) 1579 1580 wd_reg_val = i; 1580 1581 } 1581 1582 ret = regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_1, 1582 1583 BQ256XX_WATCHDOG_MASK, wd_reg_val << 1583 1584 BQ256XX_WDT_BIT_SHIFT); 1585 + if (ret) 1586 + return ret; 1584 1587 1585 1588 ret = power_supply_get_battery_info(bq->charger, &bat_info); 1586 1589 if (ret == -ENOMEM)
+22
drivers/power/supply/bq27xxx_battery.c
··· 2162 2162 } 2163 2163 EXPORT_SYMBOL_GPL(bq27xxx_battery_teardown); 2164 2164 2165 + #ifdef CONFIG_PM_SLEEP 2166 + static int bq27xxx_battery_suspend(struct device *dev) 2167 + { 2168 + struct bq27xxx_device_info *di = dev_get_drvdata(dev); 2169 + 2170 + cancel_delayed_work(&di->work); 2171 + return 0; 2172 + } 2173 + 2174 + static int bq27xxx_battery_resume(struct device *dev) 2175 + { 2176 + struct bq27xxx_device_info *di = dev_get_drvdata(dev); 2177 + 2178 + schedule_delayed_work(&di->work, 0); 2179 + return 0; 2180 + } 2181 + #endif /* CONFIG_PM_SLEEP */ 2182 + 2183 + SIMPLE_DEV_PM_OPS(bq27xxx_battery_battery_pm_ops, 2184 + bq27xxx_battery_suspend, bq27xxx_battery_resume); 2185 + EXPORT_SYMBOL_GPL(bq27xxx_battery_battery_pm_ops); 2186 + 2165 2187 MODULE_AUTHOR("Rodolfo Giometti <giometti@linux.it>"); 2166 2188 MODULE_DESCRIPTION("BQ27xxx battery monitor driver"); 2167 2189 MODULE_LICENSE("GPL");
+1
drivers/power/supply/bq27xxx_battery_i2c.c
··· 295 295 .driver = { 296 296 .name = "bq27xxx-battery", 297 297 .of_match_table = of_match_ptr(bq27xxx_battery_i2c_of_match_table), 298 + .pm = &bq27xxx_battery_battery_pm_ops, 298 299 }, 299 300 .probe = bq27xxx_battery_i2c_probe, 300 301 .remove = bq27xxx_battery_i2c_remove,
+1 -1
drivers/power/supply/cw2015_battery.c
··· 491 491 492 492 case POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW: 493 493 if (cw_battery_valid_time_to_empty(cw_bat)) 494 - val->intval = cw_bat->time_to_empty; 494 + val->intval = cw_bat->time_to_empty * 60; 495 495 else 496 496 val->intval = 0; 497 497 break;
+84 -83
drivers/power/supply/power_supply_core.c
··· 861 861 EXPORT_SYMBOL_GPL(power_supply_battery_info_properties_size); 862 862 863 863 bool power_supply_battery_info_has_prop(struct power_supply_battery_info *info, 864 - enum power_supply_property psp) 864 + enum power_supply_property psp) 865 865 { 866 866 if (!info) 867 867 return false; 868 868 869 869 switch (psp) { 870 - case POWER_SUPPLY_PROP_TECHNOLOGY: 871 - return info->technology != POWER_SUPPLY_TECHNOLOGY_UNKNOWN; 872 - case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: 873 - return info->energy_full_design_uwh >= 0; 874 - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 875 - return info->charge_full_design_uah >= 0; 876 - case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 877 - return info->voltage_min_design_uv >= 0; 878 - case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: 879 - return info->voltage_max_design_uv >= 0; 880 - case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: 881 - return info->precharge_current_ua >= 0; 882 - case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: 883 - return info->charge_term_current_ua >= 0; 884 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: 885 - return info->constant_charge_current_max_ua >= 0; 886 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: 887 - return info->constant_charge_voltage_max_uv >= 0; 888 - case POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN: 889 - return info->temp_ambient_alert_min > INT_MIN; 890 - case POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX: 891 - return info->temp_ambient_alert_max < INT_MAX; 892 - case POWER_SUPPLY_PROP_TEMP_ALERT_MIN: 893 - return info->temp_alert_min > INT_MIN; 894 - case POWER_SUPPLY_PROP_TEMP_ALERT_MAX: 895 - return info->temp_alert_max < INT_MAX; 896 - case POWER_SUPPLY_PROP_TEMP_MIN: 897 - return info->temp_min > INT_MIN; 898 - case POWER_SUPPLY_PROP_TEMP_MAX: 899 - return info->temp_max < INT_MAX; 900 - default: 901 - return false; 870 + case POWER_SUPPLY_PROP_TECHNOLOGY: 871 + return info->technology != POWER_SUPPLY_TECHNOLOGY_UNKNOWN; 872 + case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: 873 + return info->energy_full_design_uwh >= 0; 874 + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 875 + return info->charge_full_design_uah >= 0; 876 + case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 877 + return info->voltage_min_design_uv >= 0; 878 + case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: 879 + return info->voltage_max_design_uv >= 0; 880 + case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: 881 + return info->precharge_current_ua >= 0; 882 + case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: 883 + return info->charge_term_current_ua >= 0; 884 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: 885 + return info->constant_charge_current_max_ua >= 0; 886 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: 887 + return info->constant_charge_voltage_max_uv >= 0; 888 + case POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN: 889 + return info->temp_ambient_alert_min > INT_MIN; 890 + case POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX: 891 + return info->temp_ambient_alert_max < INT_MAX; 892 + case POWER_SUPPLY_PROP_TEMP_ALERT_MIN: 893 + return info->temp_alert_min > INT_MIN; 894 + case POWER_SUPPLY_PROP_TEMP_ALERT_MAX: 895 + return info->temp_alert_max < INT_MAX; 896 + case POWER_SUPPLY_PROP_TEMP_MIN: 897 + return info->temp_min > INT_MIN; 898 + case POWER_SUPPLY_PROP_TEMP_MAX: 899 + return info->temp_max < INT_MAX; 900 + default: 901 + return false; 902 902 } 903 903 } 904 904 EXPORT_SYMBOL_GPL(power_supply_battery_info_has_prop); ··· 914 914 return -EINVAL; 915 915 916 916 switch (psp) { 917 - case POWER_SUPPLY_PROP_TECHNOLOGY: 918 - val->intval = info->technology; 919 - return 0; 920 - case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: 921 - val->intval = info->energy_full_design_uwh; 922 - return 0; 923 - case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 924 - val->intval = info->charge_full_design_uah; 925 - return 0; 926 - case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 927 - val->intval = info->voltage_min_design_uv; 928 - return 0; 929 - case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: 930 - val->intval = info->voltage_max_design_uv; 931 - return 0; 932 - case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: 933 - val->intval = info->precharge_current_ua; 934 - return 0; 935 - case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: 936 - val->intval = info->charge_term_current_ua; 937 - return 0; 938 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: 939 - val->intval = info->constant_charge_current_max_ua; 940 - return 0; 941 - case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: 942 - val->intval = info->constant_charge_voltage_max_uv; 943 - return 0; 944 - case POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN: 945 - val->intval = info->temp_ambient_alert_min; 946 - return 0; 947 - case POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX: 948 - val->intval = info->temp_ambient_alert_max; 949 - return 0; 950 - case POWER_SUPPLY_PROP_TEMP_ALERT_MIN: 951 - val->intval = info->temp_alert_min; 952 - return 0; 953 - case POWER_SUPPLY_PROP_TEMP_ALERT_MAX: 954 - val->intval = info->temp_alert_max; 955 - return 0; 956 - case POWER_SUPPLY_PROP_TEMP_MIN: 957 - val->intval = info->temp_min; 958 - return 0; 959 - case POWER_SUPPLY_PROP_TEMP_MAX: 960 - val->intval = info->temp_max; 961 - return 0; 962 - default: 963 - return -EINVAL; 917 + case POWER_SUPPLY_PROP_TECHNOLOGY: 918 + val->intval = info->technology; 919 + return 0; 920 + case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: 921 + val->intval = info->energy_full_design_uwh; 922 + return 0; 923 + case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: 924 + val->intval = info->charge_full_design_uah; 925 + return 0; 926 + case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 927 + val->intval = info->voltage_min_design_uv; 928 + return 0; 929 + case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: 930 + val->intval = info->voltage_max_design_uv; 931 + return 0; 932 + case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: 933 + val->intval = info->precharge_current_ua; 934 + return 0; 935 + case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: 936 + val->intval = info->charge_term_current_ua; 937 + return 0; 938 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX: 939 + val->intval = info->constant_charge_current_max_ua; 940 + return 0; 941 + case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: 942 + val->intval = info->constant_charge_voltage_max_uv; 943 + return 0; 944 + case POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN: 945 + val->intval = info->temp_ambient_alert_min; 946 + return 0; 947 + case POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX: 948 + val->intval = info->temp_ambient_alert_max; 949 + return 0; 950 + case POWER_SUPPLY_PROP_TEMP_ALERT_MIN: 951 + val->intval = info->temp_alert_min; 952 + return 0; 953 + case POWER_SUPPLY_PROP_TEMP_ALERT_MAX: 954 + val->intval = info->temp_alert_max; 955 + return 0; 956 + case POWER_SUPPLY_PROP_TEMP_MIN: 957 + val->intval = info->temp_min; 958 + return 0; 959 + case POWER_SUPPLY_PROP_TEMP_MAX: 960 + val->intval = info->temp_max; 961 + return 0; 962 + default: 963 + return -EINVAL; 964 964 } 965 965 } 966 966 EXPORT_SYMBOL_GPL(power_supply_battery_info_get_prop); ··· 1255 1255 static void power_supply_dev_release(struct device *dev) 1256 1256 { 1257 1257 struct power_supply *psy = to_power_supply(dev); 1258 + 1258 1259 dev_dbg(dev, "%s\n", __func__); 1259 1260 kfree(psy); 1260 1261 } ··· 1637 1636 module_exit(power_supply_class_exit); 1638 1637 1639 1638 MODULE_DESCRIPTION("Universal power supply monitor class"); 1640 - MODULE_AUTHOR("Ian Molton <spyro@f2s.com>, " 1641 - "Szabolcs Gyurko, " 1642 - "Anton Vorontsov <cbou@mail.ru>"); 1639 + MODULE_AUTHOR("Ian Molton <spyro@f2s.com>"); 1640 + MODULE_AUTHOR("Szabolcs Gyurko"); 1641 + MODULE_AUTHOR("Anton Vorontsov <cbou@mail.ru>");
+60 -49
drivers/power/supply/qcom_battmgr.c
··· 282 282 283 283 struct qcom_battmgr { 284 284 struct device *dev; 285 + struct auxiliary_device *adev; 285 286 struct pmic_glink_client *client; 286 287 287 288 enum qcom_battmgr_variant variant; ··· 1294 1293 dev_err(battmgr->dev, "failed to request power notifications\n"); 1295 1294 } 1296 1295 1296 + static char *qcom_battmgr_battery[] = { "battery" }; 1297 + 1298 + static void qcom_battmgr_register_psy(struct qcom_battmgr *battmgr) 1299 + { 1300 + struct power_supply_config psy_cfg_supply = {}; 1301 + struct auxiliary_device *adev = battmgr->adev; 1302 + struct power_supply_config psy_cfg = {}; 1303 + struct device *dev = &adev->dev; 1304 + 1305 + psy_cfg.drv_data = battmgr; 1306 + psy_cfg.of_node = adev->dev.of_node; 1307 + 1308 + psy_cfg_supply.drv_data = battmgr; 1309 + psy_cfg_supply.of_node = adev->dev.of_node; 1310 + psy_cfg_supply.supplied_to = qcom_battmgr_battery; 1311 + psy_cfg_supply.num_supplicants = 1; 1312 + 1313 + if (battmgr->variant == QCOM_BATTMGR_SC8280XP) { 1314 + battmgr->bat_psy = devm_power_supply_register(dev, &sc8280xp_bat_psy_desc, &psy_cfg); 1315 + if (IS_ERR(battmgr->bat_psy)) 1316 + dev_err(dev, "failed to register battery power supply (%ld)\n", 1317 + PTR_ERR(battmgr->bat_psy)); 1318 + 1319 + battmgr->ac_psy = devm_power_supply_register(dev, &sc8280xp_ac_psy_desc, &psy_cfg_supply); 1320 + if (IS_ERR(battmgr->ac_psy)) 1321 + dev_err(dev, "failed to register AC power supply (%ld)\n", 1322 + PTR_ERR(battmgr->ac_psy)); 1323 + 1324 + battmgr->usb_psy = devm_power_supply_register(dev, &sc8280xp_usb_psy_desc, &psy_cfg_supply); 1325 + if (IS_ERR(battmgr->usb_psy)) 1326 + dev_err(dev, "failed to register USB power supply (%ld)\n", 1327 + PTR_ERR(battmgr->usb_psy)); 1328 + 1329 + battmgr->wls_psy = devm_power_supply_register(dev, &sc8280xp_wls_psy_desc, &psy_cfg_supply); 1330 + if (IS_ERR(battmgr->wls_psy)) 1331 + dev_err(dev, "failed to register wireless charing power supply (%ld)\n", 1332 + PTR_ERR(battmgr->wls_psy)); 1333 + } else { 1334 + battmgr->bat_psy = devm_power_supply_register(dev, &sm8350_bat_psy_desc, &psy_cfg); 1335 + if (IS_ERR(battmgr->bat_psy)) 1336 + dev_err(dev, "failed to register battery power supply (%ld)\n", 1337 + PTR_ERR(battmgr->bat_psy)); 1338 + 1339 + battmgr->usb_psy = devm_power_supply_register(dev, &sm8350_usb_psy_desc, &psy_cfg_supply); 1340 + if (IS_ERR(battmgr->usb_psy)) 1341 + dev_err(dev, "failed to register USB power supply (%ld)\n", 1342 + PTR_ERR(battmgr->usb_psy)); 1343 + 1344 + battmgr->wls_psy = devm_power_supply_register(dev, &sm8350_wls_psy_desc, &psy_cfg_supply); 1345 + if (IS_ERR(battmgr->wls_psy)) 1346 + dev_err(dev, "failed to register wireless charing power supply (%ld)\n", 1347 + PTR_ERR(battmgr->wls_psy)); 1348 + } 1349 + } 1350 + 1297 1351 static void qcom_battmgr_pdr_notify(void *priv, int state) 1298 1352 { 1299 1353 struct qcom_battmgr *battmgr = priv; 1300 1354 1301 1355 if (state == SERVREG_SERVICE_STATE_UP) { 1356 + if (!battmgr->bat_psy) 1357 + qcom_battmgr_register_psy(battmgr); 1358 + 1302 1359 battmgr->service_up = true; 1303 1360 schedule_work(&battmgr->enable_work); 1304 1361 } else { ··· 1371 1312 {} 1372 1313 }; 1373 1314 1374 - static char *qcom_battmgr_battery[] = { "battery" }; 1375 - 1376 1315 static int qcom_battmgr_probe(struct auxiliary_device *adev, 1377 1316 const struct auxiliary_device_id *id) 1378 1317 { 1379 - struct power_supply_config psy_cfg_supply = {}; 1380 - struct power_supply_config psy_cfg = {}; 1381 1318 const struct of_device_id *match; 1382 1319 struct qcom_battmgr *battmgr; 1383 1320 struct device *dev = &adev->dev; ··· 1383 1328 return -ENOMEM; 1384 1329 1385 1330 battmgr->dev = dev; 1386 - 1387 - psy_cfg.drv_data = battmgr; 1388 - psy_cfg.of_node = adev->dev.of_node; 1389 - 1390 - psy_cfg_supply.drv_data = battmgr; 1391 - psy_cfg_supply.of_node = adev->dev.of_node; 1392 - psy_cfg_supply.supplied_to = qcom_battmgr_battery; 1393 - psy_cfg_supply.num_supplicants = 1; 1331 + battmgr->adev = adev; 1394 1332 1395 1333 INIT_WORK(&battmgr->enable_work, qcom_battmgr_enable_worker); 1396 1334 mutex_init(&battmgr->lock); ··· 1394 1346 battmgr->variant = (unsigned long)match->data; 1395 1347 else 1396 1348 battmgr->variant = QCOM_BATTMGR_SM8350; 1397 - 1398 - if (battmgr->variant == QCOM_BATTMGR_SC8280XP) { 1399 - battmgr->bat_psy = devm_power_supply_register(dev, &sc8280xp_bat_psy_desc, &psy_cfg); 1400 - if (IS_ERR(battmgr->bat_psy)) 1401 - return dev_err_probe(dev, PTR_ERR(battmgr->bat_psy), 1402 - "failed to register battery power supply\n"); 1403 - 1404 - battmgr->ac_psy = devm_power_supply_register(dev, &sc8280xp_ac_psy_desc, &psy_cfg_supply); 1405 - if (IS_ERR(battmgr->ac_psy)) 1406 - return dev_err_probe(dev, PTR_ERR(battmgr->ac_psy), 1407 - "failed to register AC power supply\n"); 1408 - 1409 - battmgr->usb_psy = devm_power_supply_register(dev, &sc8280xp_usb_psy_desc, &psy_cfg_supply); 1410 - if (IS_ERR(battmgr->usb_psy)) 1411 - return dev_err_probe(dev, PTR_ERR(battmgr->usb_psy), 1412 - "failed to register USB power supply\n"); 1413 - 1414 - battmgr->wls_psy = devm_power_supply_register(dev, &sc8280xp_wls_psy_desc, &psy_cfg_supply); 1415 - if (IS_ERR(battmgr->wls_psy)) 1416 - return dev_err_probe(dev, PTR_ERR(battmgr->wls_psy), 1417 - "failed to register wireless charing power supply\n"); 1418 - } else { 1419 - battmgr->bat_psy = devm_power_supply_register(dev, &sm8350_bat_psy_desc, &psy_cfg); 1420 - if (IS_ERR(battmgr->bat_psy)) 1421 - return dev_err_probe(dev, PTR_ERR(battmgr->bat_psy), 1422 - "failed to register battery power supply\n"); 1423 - 1424 - battmgr->usb_psy = devm_power_supply_register(dev, &sm8350_usb_psy_desc, &psy_cfg_supply); 1425 - if (IS_ERR(battmgr->usb_psy)) 1426 - return dev_err_probe(dev, PTR_ERR(battmgr->usb_psy), 1427 - "failed to register USB power supply\n"); 1428 - 1429 - battmgr->wls_psy = devm_power_supply_register(dev, &sm8350_wls_psy_desc, &psy_cfg_supply); 1430 - if (IS_ERR(battmgr->wls_psy)) 1431 - return dev_err_probe(dev, PTR_ERR(battmgr->wls_psy), 1432 - "failed to register wireless charing power supply\n"); 1433 - } 1434 1349 1435 1350 battmgr->client = devm_pmic_glink_register_client(dev, 1436 1351 PMIC_GLINK_OWNER_BATTMGR,
+4
drivers/power/supply/qcom_pmi8998_charger.c
··· 972 972 supply_config.of_node = pdev->dev.of_node; 973 973 974 974 desc = devm_kzalloc(chip->dev, sizeof(smb2_psy_desc), GFP_KERNEL); 975 + if (!desc) 976 + return -ENOMEM; 975 977 memcpy(desc, &smb2_psy_desc, sizeof(smb2_psy_desc)); 976 978 desc->name = 977 979 devm_kasprintf(chip->dev, GFP_KERNEL, "%s-charger", 978 980 (const char *)device_get_match_data(chip->dev)); 981 + if (!desc->name) 982 + return -ENOMEM; 979 983 980 984 chip->chg_psy = 981 985 devm_power_supply_register(chip->dev, desc, &supply_config);
+1
include/linux/power/bq27xxx_battery.h
··· 83 83 void bq27xxx_battery_update(struct bq27xxx_device_info *di); 84 84 int bq27xxx_battery_setup(struct bq27xxx_device_info *di); 85 85 void bq27xxx_battery_teardown(struct bq27xxx_device_info *di); 86 + extern const struct dev_pm_ops bq27xxx_battery_battery_pm_ops; 86 87 87 88 #endif