| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Driver for the TI bq24190 battery charger. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Author: Mark A. Greer <mgreer@animalcreek.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | 6 | */ |
|---|
| 10 | 7 | |
|---|
| 11 | 8 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 21 | 18 | #include <linux/workqueue.h> |
|---|
| 22 | 19 | #include <linux/gpio.h> |
|---|
| 23 | 20 | #include <linux/i2c.h> |
|---|
| 21 | +#include <linux/extcon-provider.h> |
|---|
| 24 | 22 | |
|---|
| 25 | 23 | #define BQ24190_MANUFACTURER "Texas Instruments" |
|---|
| 26 | 24 | |
|---|
| .. | .. |
|---|
| 43 | 41 | #define BQ24190_REG_POC_CHG_CONFIG_DISABLE 0x0 |
|---|
| 44 | 42 | #define BQ24190_REG_POC_CHG_CONFIG_CHARGE 0x1 |
|---|
| 45 | 43 | #define BQ24190_REG_POC_CHG_CONFIG_OTG 0x2 |
|---|
| 44 | +#define BQ24190_REG_POC_CHG_CONFIG_OTG_ALT 0x3 |
|---|
| 46 | 45 | #define BQ24190_REG_POC_SYS_MIN_MASK (BIT(3) | BIT(2) | BIT(1)) |
|---|
| 47 | 46 | #define BQ24190_REG_POC_SYS_MIN_SHIFT 1 |
|---|
| 48 | 47 | #define BQ24190_REG_POC_SYS_MIN_MIN 3000 |
|---|
| .. | .. |
|---|
| 142 | 141 | #define BQ24190_REG_VPRS_PN_MASK (BIT(5) | BIT(4) | BIT(3)) |
|---|
| 143 | 142 | #define BQ24190_REG_VPRS_PN_SHIFT 3 |
|---|
| 144 | 143 | #define BQ24190_REG_VPRS_PN_24190 0x4 |
|---|
| 145 | | -#define BQ24190_REG_VPRS_PN_24192 0x5 /* Also 24193 */ |
|---|
| 144 | +#define BQ24190_REG_VPRS_PN_24192 0x5 /* Also 24193, 24196 */ |
|---|
| 146 | 145 | #define BQ24190_REG_VPRS_PN_24192I 0x3 |
|---|
| 147 | 146 | #define BQ24190_REG_VPRS_TS_PROFILE_MASK BIT(2) |
|---|
| 148 | 147 | #define BQ24190_REG_VPRS_TS_PROFILE_SHIFT 2 |
|---|
| .. | .. |
|---|
| 159 | 158 | struct bq24190_dev_info { |
|---|
| 160 | 159 | struct i2c_client *client; |
|---|
| 161 | 160 | struct device *dev; |
|---|
| 161 | + struct extcon_dev *edev; |
|---|
| 162 | 162 | struct power_supply *charger; |
|---|
| 163 | 163 | struct power_supply *battery; |
|---|
| 164 | 164 | struct delayed_work input_current_limit_work; |
|---|
| .. | .. |
|---|
| 172 | 172 | u8 f_reg; |
|---|
| 173 | 173 | u8 ss_reg; |
|---|
| 174 | 174 | u8 watchdog; |
|---|
| 175 | +}; |
|---|
| 176 | + |
|---|
| 177 | +static const unsigned int bq24190_usb_extcon_cable[] = { |
|---|
| 178 | + EXTCON_USB, |
|---|
| 179 | + EXTCON_NONE, |
|---|
| 175 | 180 | }; |
|---|
| 176 | 181 | |
|---|
| 177 | 182 | /* |
|---|
| .. | .. |
|---|
| 402 | 407 | static struct attribute * |
|---|
| 403 | 408 | bq24190_sysfs_attrs[ARRAY_SIZE(bq24190_sysfs_field_tbl) + 1]; |
|---|
| 404 | 409 | |
|---|
| 405 | | -static const struct attribute_group bq24190_sysfs_attr_group = { |
|---|
| 406 | | - .attrs = bq24190_sysfs_attrs, |
|---|
| 407 | | -}; |
|---|
| 410 | +ATTRIBUTE_GROUPS(bq24190_sysfs); |
|---|
| 408 | 411 | |
|---|
| 409 | 412 | static void bq24190_sysfs_init_attrs(void) |
|---|
| 410 | 413 | { |
|---|
| .. | .. |
|---|
| 445 | 448 | if (!info) |
|---|
| 446 | 449 | return -EINVAL; |
|---|
| 447 | 450 | |
|---|
| 448 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 449 | | - if (ret < 0) { |
|---|
| 450 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 451 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 452 | + if (ret < 0) |
|---|
| 451 | 453 | return ret; |
|---|
| 452 | | - } |
|---|
| 453 | 454 | |
|---|
| 454 | 455 | ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v); |
|---|
| 455 | 456 | if (ret) |
|---|
| .. | .. |
|---|
| 480 | 481 | if (ret < 0) |
|---|
| 481 | 482 | return ret; |
|---|
| 482 | 483 | |
|---|
| 483 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 484 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 484 | 485 | if (ret < 0) |
|---|
| 485 | 486 | return ret; |
|---|
| 486 | 487 | |
|---|
| .. | .. |
|---|
| 493 | 494 | |
|---|
| 494 | 495 | return count; |
|---|
| 495 | 496 | } |
|---|
| 496 | | - |
|---|
| 497 | | -static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi) |
|---|
| 498 | | -{ |
|---|
| 499 | | - bq24190_sysfs_init_attrs(); |
|---|
| 500 | | - |
|---|
| 501 | | - return sysfs_create_group(&bdi->charger->dev.kobj, |
|---|
| 502 | | - &bq24190_sysfs_attr_group); |
|---|
| 503 | | -} |
|---|
| 504 | | - |
|---|
| 505 | | -static void bq24190_sysfs_remove_group(struct bq24190_dev_info *bdi) |
|---|
| 506 | | -{ |
|---|
| 507 | | - sysfs_remove_group(&bdi->charger->dev.kobj, &bq24190_sysfs_attr_group); |
|---|
| 508 | | -} |
|---|
| 509 | | -#else |
|---|
| 510 | | -static int bq24190_sysfs_create_group(struct bq24190_dev_info *bdi) |
|---|
| 511 | | -{ |
|---|
| 512 | | - return 0; |
|---|
| 513 | | -} |
|---|
| 514 | | - |
|---|
| 515 | | -static inline void bq24190_sysfs_remove_group(struct bq24190_dev_info *bdi) {} |
|---|
| 516 | 497 | #endif |
|---|
| 517 | 498 | |
|---|
| 518 | 499 | #ifdef CONFIG_REGULATOR |
|---|
| .. | .. |
|---|
| 521 | 502 | struct bq24190_dev_info *bdi = rdev_get_drvdata(dev); |
|---|
| 522 | 503 | int ret; |
|---|
| 523 | 504 | |
|---|
| 524 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 505 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 525 | 506 | if (ret < 0) { |
|---|
| 526 | 507 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret); |
|---|
| 527 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 528 | 508 | return ret; |
|---|
| 529 | 509 | } |
|---|
| 530 | 510 | |
|---|
| .. | .. |
|---|
| 554 | 534 | int ret; |
|---|
| 555 | 535 | u8 val; |
|---|
| 556 | 536 | |
|---|
| 557 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 537 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 558 | 538 | if (ret < 0) { |
|---|
| 559 | 539 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret); |
|---|
| 560 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 561 | 540 | return ret; |
|---|
| 562 | 541 | } |
|---|
| 563 | 542 | |
|---|
| .. | .. |
|---|
| 568 | 547 | pm_runtime_mark_last_busy(bdi->dev); |
|---|
| 569 | 548 | pm_runtime_put_autosuspend(bdi->dev); |
|---|
| 570 | 549 | |
|---|
| 571 | | - return ret ? ret : val == BQ24190_REG_POC_CHG_CONFIG_OTG; |
|---|
| 550 | + if (ret) |
|---|
| 551 | + return ret; |
|---|
| 552 | + |
|---|
| 553 | + return (val == BQ24190_REG_POC_CHG_CONFIG_OTG || |
|---|
| 554 | + val == BQ24190_REG_POC_CHG_CONFIG_OTG_ALT); |
|---|
| 572 | 555 | } |
|---|
| 573 | 556 | |
|---|
| 574 | 557 | static const struct regulator_ops bq24190_vbus_ops = { |
|---|
| .. | .. |
|---|
| 579 | 562 | |
|---|
| 580 | 563 | static const struct regulator_desc bq24190_vbus_desc = { |
|---|
| 581 | 564 | .name = "usb_otg_vbus", |
|---|
| 565 | + .of_match = "usb-otg-vbus", |
|---|
| 582 | 566 | .type = REGULATOR_VOLTAGE, |
|---|
| 583 | 567 | .owner = THIS_MODULE, |
|---|
| 584 | 568 | .ops = &bq24190_vbus_ops, |
|---|
| .. | .. |
|---|
| 692 | 676 | * { .type = "bq24190", .addr = 0x6b, .properties = pe, .irq = irq }; |
|---|
| 693 | 677 | * struct i2c_adapter ad = { ... }; |
|---|
| 694 | 678 | * i2c_add_adapter(&ad); |
|---|
| 695 | | - * i2c_new_device(&ad, &bi); |
|---|
| 679 | + * i2c_new_client_device(&ad, &bi); |
|---|
| 696 | 680 | */ |
|---|
| 697 | 681 | if (device_property_read_bool(bdi->dev, "disable-reset")) |
|---|
| 698 | 682 | return 0; |
|---|
| .. | .. |
|---|
| 1093 | 1077 | |
|---|
| 1094 | 1078 | dev_dbg(bdi->dev, "prop: %d\n", psp); |
|---|
| 1095 | 1079 | |
|---|
| 1096 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 1097 | | - if (ret < 0) { |
|---|
| 1098 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1080 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1081 | + if (ret < 0) |
|---|
| 1099 | 1082 | return ret; |
|---|
| 1100 | | - } |
|---|
| 1101 | 1083 | |
|---|
| 1102 | 1084 | switch (psp) { |
|---|
| 1103 | 1085 | case POWER_SUPPLY_PROP_CHARGE_TYPE: |
|---|
| .. | .. |
|---|
| 1167 | 1149 | |
|---|
| 1168 | 1150 | dev_dbg(bdi->dev, "prop: %d\n", psp); |
|---|
| 1169 | 1151 | |
|---|
| 1170 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 1171 | | - if (ret < 0) { |
|---|
| 1172 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1152 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1153 | + if (ret < 0) |
|---|
| 1173 | 1154 | return ret; |
|---|
| 1174 | | - } |
|---|
| 1175 | 1155 | |
|---|
| 1176 | 1156 | switch (psp) { |
|---|
| 1177 | 1157 | case POWER_SUPPLY_PROP_ONLINE: |
|---|
| .. | .. |
|---|
| 1223 | 1203 | struct bq24190_dev_info *bdi = |
|---|
| 1224 | 1204 | container_of(work, struct bq24190_dev_info, |
|---|
| 1225 | 1205 | input_current_limit_work.work); |
|---|
| 1206 | + union power_supply_propval val; |
|---|
| 1207 | + int ret; |
|---|
| 1226 | 1208 | |
|---|
| 1227 | | - power_supply_set_input_current_limit_from_supplier(bdi->charger); |
|---|
| 1209 | + ret = power_supply_get_property_from_supplier(bdi->charger, |
|---|
| 1210 | + POWER_SUPPLY_PROP_CURRENT_MAX, |
|---|
| 1211 | + &val); |
|---|
| 1212 | + if (ret) |
|---|
| 1213 | + return; |
|---|
| 1214 | + |
|---|
| 1215 | + bq24190_charger_set_property(bdi->charger, |
|---|
| 1216 | + POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, |
|---|
| 1217 | + &val); |
|---|
| 1218 | + power_supply_changed(bdi->charger); |
|---|
| 1228 | 1219 | } |
|---|
| 1229 | 1220 | |
|---|
| 1230 | 1221 | /* Sync the input-current-limit with our parent supply (if we have one) */ |
|---|
| .. | .. |
|---|
| 1430 | 1421 | dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n"); |
|---|
| 1431 | 1422 | dev_dbg(bdi->dev, "prop: %d\n", psp); |
|---|
| 1432 | 1423 | |
|---|
| 1433 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 1434 | | - if (ret < 0) { |
|---|
| 1435 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1424 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1425 | + if (ret < 0) |
|---|
| 1436 | 1426 | return ret; |
|---|
| 1437 | | - } |
|---|
| 1438 | 1427 | |
|---|
| 1439 | 1428 | switch (psp) { |
|---|
| 1440 | 1429 | case POWER_SUPPLY_PROP_STATUS: |
|---|
| .. | .. |
|---|
| 1478 | 1467 | dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n"); |
|---|
| 1479 | 1468 | dev_dbg(bdi->dev, "prop: %d\n", psp); |
|---|
| 1480 | 1469 | |
|---|
| 1481 | | - ret = pm_runtime_get_sync(bdi->dev); |
|---|
| 1482 | | - if (ret < 0) { |
|---|
| 1483 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1470 | + ret = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1471 | + if (ret < 0) |
|---|
| 1484 | 1472 | return ret; |
|---|
| 1485 | | - } |
|---|
| 1486 | 1473 | |
|---|
| 1487 | 1474 | switch (psp) { |
|---|
| 1488 | 1475 | case POWER_SUPPLY_PROP_ONLINE: |
|---|
| .. | .. |
|---|
| 1536 | 1523 | .set_property = bq24190_battery_set_property, |
|---|
| 1537 | 1524 | .property_is_writeable = bq24190_battery_property_is_writeable, |
|---|
| 1538 | 1525 | }; |
|---|
| 1526 | + |
|---|
| 1527 | +static int bq24190_configure_usb_otg(struct bq24190_dev_info *bdi, u8 ss_reg) |
|---|
| 1528 | +{ |
|---|
| 1529 | + bool otg_enabled; |
|---|
| 1530 | + int ret; |
|---|
| 1531 | + |
|---|
| 1532 | + otg_enabled = !!(ss_reg & BQ24190_REG_SS_VBUS_STAT_MASK); |
|---|
| 1533 | + ret = extcon_set_state_sync(bdi->edev, EXTCON_USB, otg_enabled); |
|---|
| 1534 | + if (ret < 0) |
|---|
| 1535 | + dev_err(bdi->dev, "Can't set extcon state to %d: %d\n", |
|---|
| 1536 | + otg_enabled, ret); |
|---|
| 1537 | + |
|---|
| 1538 | + return ret; |
|---|
| 1539 | +} |
|---|
| 1539 | 1540 | |
|---|
| 1540 | 1541 | static void bq24190_check_status(struct bq24190_dev_info *bdi) |
|---|
| 1541 | 1542 | { |
|---|
| .. | .. |
|---|
| 1606 | 1607 | bdi->ss_reg = ss_reg; |
|---|
| 1607 | 1608 | } |
|---|
| 1608 | 1609 | |
|---|
| 1609 | | - if (alert_charger || alert_battery) |
|---|
| 1610 | + if (alert_charger || alert_battery) { |
|---|
| 1610 | 1611 | power_supply_changed(bdi->charger); |
|---|
| 1612 | + bq24190_configure_usb_otg(bdi, ss_reg); |
|---|
| 1613 | + } |
|---|
| 1611 | 1614 | if (alert_battery && bdi->battery) |
|---|
| 1612 | 1615 | power_supply_changed(bdi->battery); |
|---|
| 1613 | 1616 | |
|---|
| .. | .. |
|---|
| 1620 | 1623 | int error; |
|---|
| 1621 | 1624 | |
|---|
| 1622 | 1625 | bdi->irq_event = true; |
|---|
| 1623 | | - error = pm_runtime_get_sync(bdi->dev); |
|---|
| 1626 | + error = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1624 | 1627 | if (error < 0) { |
|---|
| 1625 | 1628 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); |
|---|
| 1626 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1627 | 1629 | return IRQ_NONE; |
|---|
| 1628 | 1630 | } |
|---|
| 1629 | 1631 | bq24190_check_status(bdi); |
|---|
| .. | .. |
|---|
| 1647 | 1649 | if (ret < 0) |
|---|
| 1648 | 1650 | return ret; |
|---|
| 1649 | 1651 | |
|---|
| 1650 | | - if (v != BQ24190_REG_VPRS_PN_24190 && |
|---|
| 1651 | | - v != BQ24190_REG_VPRS_PN_24192I) { |
|---|
| 1652 | + switch (v) { |
|---|
| 1653 | + case BQ24190_REG_VPRS_PN_24190: |
|---|
| 1654 | + case BQ24190_REG_VPRS_PN_24192: |
|---|
| 1655 | + case BQ24190_REG_VPRS_PN_24192I: |
|---|
| 1656 | + break; |
|---|
| 1657 | + default: |
|---|
| 1652 | 1658 | dev_err(bdi->dev, "Error unknown model: 0x%02x\n", v); |
|---|
| 1653 | 1659 | return -ENODEV; |
|---|
| 1654 | 1660 | } |
|---|
| .. | .. |
|---|
| 1704 | 1710 | static int bq24190_probe(struct i2c_client *client, |
|---|
| 1705 | 1711 | const struct i2c_device_id *id) |
|---|
| 1706 | 1712 | { |
|---|
| 1707 | | - struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); |
|---|
| 1713 | + struct i2c_adapter *adapter = client->adapter; |
|---|
| 1708 | 1714 | struct device *dev = &client->dev; |
|---|
| 1709 | 1715 | struct power_supply_config charger_cfg = {}, battery_cfg = {}; |
|---|
| 1710 | 1716 | struct bq24190_dev_info *bdi; |
|---|
| .. | .. |
|---|
| 1737 | 1743 | return -EINVAL; |
|---|
| 1738 | 1744 | } |
|---|
| 1739 | 1745 | |
|---|
| 1746 | + bdi->edev = devm_extcon_dev_allocate(dev, bq24190_usb_extcon_cable); |
|---|
| 1747 | + if (IS_ERR(bdi->edev)) |
|---|
| 1748 | + return PTR_ERR(bdi->edev); |
|---|
| 1749 | + |
|---|
| 1750 | + ret = devm_extcon_dev_register(dev, bdi->edev); |
|---|
| 1751 | + if (ret < 0) |
|---|
| 1752 | + return ret; |
|---|
| 1753 | + |
|---|
| 1740 | 1754 | pm_runtime_enable(dev); |
|---|
| 1741 | 1755 | pm_runtime_use_autosuspend(dev); |
|---|
| 1742 | 1756 | pm_runtime_set_autosuspend_delay(dev, 600); |
|---|
| .. | .. |
|---|
| 1745 | 1759 | dev_err(dev, "pm_runtime_get failed: %i\n", ret); |
|---|
| 1746 | 1760 | goto out_pmrt; |
|---|
| 1747 | 1761 | } |
|---|
| 1762 | + |
|---|
| 1763 | +#ifdef CONFIG_SYSFS |
|---|
| 1764 | + bq24190_sysfs_init_attrs(); |
|---|
| 1765 | + charger_cfg.attr_grp = bq24190_sysfs_groups; |
|---|
| 1766 | +#endif |
|---|
| 1748 | 1767 | |
|---|
| 1749 | 1768 | charger_cfg.drv_data = bdi; |
|---|
| 1750 | 1769 | charger_cfg.of_node = dev->of_node; |
|---|
| .. | .. |
|---|
| 1783 | 1802 | goto out_charger; |
|---|
| 1784 | 1803 | } |
|---|
| 1785 | 1804 | |
|---|
| 1786 | | - ret = bq24190_sysfs_create_group(bdi); |
|---|
| 1787 | | - if (ret < 0) { |
|---|
| 1788 | | - dev_err(dev, "Can't create sysfs entries\n"); |
|---|
| 1805 | + ret = bq24190_configure_usb_otg(bdi, bdi->ss_reg); |
|---|
| 1806 | + if (ret < 0) |
|---|
| 1789 | 1807 | goto out_charger; |
|---|
| 1790 | | - } |
|---|
| 1791 | 1808 | |
|---|
| 1792 | 1809 | bdi->initialized = true; |
|---|
| 1793 | 1810 | |
|---|
| .. | .. |
|---|
| 1797 | 1814 | "bq24190-charger", bdi); |
|---|
| 1798 | 1815 | if (ret < 0) { |
|---|
| 1799 | 1816 | dev_err(dev, "Can't set up irq handler\n"); |
|---|
| 1800 | | - goto out_sysfs; |
|---|
| 1817 | + goto out_charger; |
|---|
| 1801 | 1818 | } |
|---|
| 1802 | 1819 | |
|---|
| 1803 | 1820 | ret = bq24190_register_vbus_regulator(bdi); |
|---|
| 1804 | 1821 | if (ret < 0) |
|---|
| 1805 | | - goto out_sysfs; |
|---|
| 1822 | + goto out_charger; |
|---|
| 1806 | 1823 | |
|---|
| 1807 | 1824 | enable_irq_wake(client->irq); |
|---|
| 1808 | 1825 | |
|---|
| .. | .. |
|---|
| 1810 | 1827 | pm_runtime_put_autosuspend(dev); |
|---|
| 1811 | 1828 | |
|---|
| 1812 | 1829 | return 0; |
|---|
| 1813 | | - |
|---|
| 1814 | | -out_sysfs: |
|---|
| 1815 | | - bq24190_sysfs_remove_group(bdi); |
|---|
| 1816 | 1830 | |
|---|
| 1817 | 1831 | out_charger: |
|---|
| 1818 | 1832 | if (!IS_ERR_OR_NULL(bdi->battery)) |
|---|
| .. | .. |
|---|
| 1831 | 1845 | struct bq24190_dev_info *bdi = i2c_get_clientdata(client); |
|---|
| 1832 | 1846 | int error; |
|---|
| 1833 | 1847 | |
|---|
| 1834 | | - error = pm_runtime_get_sync(bdi->dev); |
|---|
| 1835 | | - if (error < 0) { |
|---|
| 1848 | + cancel_delayed_work_sync(&bdi->input_current_limit_work); |
|---|
| 1849 | + error = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1850 | + if (error < 0) |
|---|
| 1836 | 1851 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); |
|---|
| 1837 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1838 | | - } |
|---|
| 1839 | 1852 | |
|---|
| 1840 | 1853 | bq24190_register_reset(bdi); |
|---|
| 1841 | | - bq24190_sysfs_remove_group(bdi); |
|---|
| 1842 | 1854 | if (bdi->battery) |
|---|
| 1843 | 1855 | power_supply_unregister(bdi->battery); |
|---|
| 1844 | 1856 | power_supply_unregister(bdi->charger); |
|---|
| .. | .. |
|---|
| 1885 | 1897 | struct bq24190_dev_info *bdi = i2c_get_clientdata(client); |
|---|
| 1886 | 1898 | int error; |
|---|
| 1887 | 1899 | |
|---|
| 1888 | | - error = pm_runtime_get_sync(bdi->dev); |
|---|
| 1889 | | - if (error < 0) { |
|---|
| 1900 | + error = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1901 | + if (error < 0) |
|---|
| 1890 | 1902 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); |
|---|
| 1891 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1892 | | - } |
|---|
| 1893 | 1903 | |
|---|
| 1894 | 1904 | bq24190_register_reset(bdi); |
|---|
| 1895 | 1905 | |
|---|
| .. | .. |
|---|
| 1910 | 1920 | bdi->f_reg = 0; |
|---|
| 1911 | 1921 | bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */ |
|---|
| 1912 | 1922 | |
|---|
| 1913 | | - error = pm_runtime_get_sync(bdi->dev); |
|---|
| 1914 | | - if (error < 0) { |
|---|
| 1923 | + error = pm_runtime_resume_and_get(bdi->dev); |
|---|
| 1924 | + if (error < 0) |
|---|
| 1915 | 1925 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); |
|---|
| 1916 | | - pm_runtime_put_noidle(bdi->dev); |
|---|
| 1917 | | - } |
|---|
| 1918 | 1926 | |
|---|
| 1919 | 1927 | bq24190_register_reset(bdi); |
|---|
| 1920 | 1928 | bq24190_set_config(bdi); |
|---|
| .. | .. |
|---|
| 1941 | 1949 | |
|---|
| 1942 | 1950 | static const struct i2c_device_id bq24190_i2c_ids[] = { |
|---|
| 1943 | 1951 | { "bq24190" }, |
|---|
| 1952 | + { "bq24192" }, |
|---|
| 1944 | 1953 | { "bq24192i" }, |
|---|
| 1954 | + { "bq24196" }, |
|---|
| 1945 | 1955 | { }, |
|---|
| 1946 | 1956 | }; |
|---|
| 1947 | 1957 | MODULE_DEVICE_TABLE(i2c, bq24190_i2c_ids); |
|---|
| .. | .. |
|---|
| 1949 | 1959 | #ifdef CONFIG_OF |
|---|
| 1950 | 1960 | static const struct of_device_id bq24190_of_match[] = { |
|---|
| 1951 | 1961 | { .compatible = "ti,bq24190", }, |
|---|
| 1962 | + { .compatible = "ti,bq24192", }, |
|---|
| 1952 | 1963 | { .compatible = "ti,bq24192i", }, |
|---|
| 1964 | + { .compatible = "ti,bq24196", }, |
|---|
| 1953 | 1965 | { }, |
|---|
| 1954 | 1966 | }; |
|---|
| 1955 | 1967 | MODULE_DEVICE_TABLE(of, bq24190_of_match); |
|---|