diff options
author | Hans de Goede <hdegoede@redhat.com> | 2017-11-28 04:08:30 -0500 |
---|---|---|
committer | Sebastian Reichel <sebastian.reichel@collabora.co.uk> | 2017-12-01 10:43:21 -0500 |
commit | d16002755dc8169d080d23f6df04ba165df66586 (patch) | |
tree | d9ad6b3617d1738f58c580e3bd8b2d5bf027a962 | |
parent | 5f2f0d610578d380123d5c5906bbfa1ec5542b1a (diff) |
power: supply: bq24190_charger: Remove extcon handling
Now that drivers/i2c/busses/i2c-cht-wc.c uses
"input-current-limit-from-supplier" instead of "extcon-name" the last
user of the bq24190 extcon code is gone, remove it.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
-rw-r--r-- | drivers/power/supply/bq24190_charger.c | 117 |
1 files changed, 10 insertions, 107 deletions
diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c index 35ff406aca48..c4335ff70232 100644 --- a/drivers/power/supply/bq24190_charger.c +++ b/drivers/power/supply/bq24190_charger.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
12 | #include <linux/interrupt.h> | 12 | #include <linux/interrupt.h> |
13 | #include <linux/delay.h> | 13 | #include <linux/delay.h> |
14 | #include <linux/extcon.h> | ||
15 | #include <linux/of_irq.h> | 14 | #include <linux/of_irq.h> |
16 | #include <linux/of_device.h> | 15 | #include <linux/of_device.h> |
17 | #include <linux/pm_runtime.h> | 16 | #include <linux/pm_runtime.h> |
@@ -162,9 +161,6 @@ struct bq24190_dev_info { | |||
162 | struct device *dev; | 161 | struct device *dev; |
163 | struct power_supply *charger; | 162 | struct power_supply *charger; |
164 | struct power_supply *battery; | 163 | struct power_supply *battery; |
165 | struct extcon_dev *extcon; | ||
166 | struct notifier_block extcon_nb; | ||
167 | struct delayed_work extcon_work; | ||
168 | struct delayed_work input_current_limit_work; | 164 | struct delayed_work input_current_limit_work; |
169 | char model_name[I2C_NAME_SIZE]; | 165 | char model_name[I2C_NAME_SIZE]; |
170 | bool initialized; | 166 | bool initialized; |
@@ -686,6 +682,16 @@ static int bq24190_register_reset(struct bq24190_dev_info *bdi) | |||
686 | int ret, limit = 100; | 682 | int ret, limit = 100; |
687 | u8 v; | 683 | u8 v; |
688 | 684 | ||
685 | /* | ||
686 | * This prop. can be passed on device instantiation from platform code: | ||
687 | * struct property_entry pe[] = | ||
688 | * { PROPERTY_ENTRY_BOOL("disable-reset"), ... }; | ||
689 | * struct i2c_board_info bi = | ||
690 | * { .type = "bq24190", .addr = 0x6b, .properties = pe, .irq = irq }; | ||
691 | * struct i2c_adapter ad = { ... }; | ||
692 | * i2c_add_adapter(&ad); | ||
693 | * i2c_new_device(&ad, &bi); | ||
694 | */ | ||
689 | if (device_property_read_bool(bdi->dev, "disable-reset")) | 695 | if (device_property_read_bool(bdi->dev, "disable-reset")) |
690 | return 0; | 696 | return 0; |
691 | 697 | ||
@@ -1623,75 +1629,6 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data) | |||
1623 | return IRQ_HANDLED; | 1629 | return IRQ_HANDLED; |
1624 | } | 1630 | } |
1625 | 1631 | ||
1626 | static void bq24190_extcon_work(struct work_struct *work) | ||
1627 | { | ||
1628 | struct bq24190_dev_info *bdi = | ||
1629 | container_of(work, struct bq24190_dev_info, extcon_work.work); | ||
1630 | int error, iinlim = 0; | ||
1631 | u8 v; | ||
1632 | |||
1633 | error = pm_runtime_get_sync(bdi->dev); | ||
1634 | if (error < 0) { | ||
1635 | dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error); | ||
1636 | pm_runtime_put_noidle(bdi->dev); | ||
1637 | return; | ||
1638 | } | ||
1639 | |||
1640 | if (extcon_get_state(bdi->extcon, EXTCON_CHG_USB_SDP) == 1) | ||
1641 | iinlim = 500000; | ||
1642 | else if (extcon_get_state(bdi->extcon, EXTCON_CHG_USB_CDP) == 1 || | ||
1643 | extcon_get_state(bdi->extcon, EXTCON_CHG_USB_ACA) == 1) | ||
1644 | iinlim = 1500000; | ||
1645 | else if (extcon_get_state(bdi->extcon, EXTCON_CHG_USB_DCP) == 1) | ||
1646 | iinlim = 2000000; | ||
1647 | |||
1648 | if (iinlim) { | ||
1649 | error = bq24190_set_field_val(bdi, BQ24190_REG_ISC, | ||
1650 | BQ24190_REG_ISC_IINLIM_MASK, | ||
1651 | BQ24190_REG_ISC_IINLIM_SHIFT, | ||
1652 | bq24190_isc_iinlim_values, | ||
1653 | ARRAY_SIZE(bq24190_isc_iinlim_values), | ||
1654 | iinlim); | ||
1655 | if (error < 0) | ||
1656 | dev_err(bdi->dev, "Can't set IINLIM: %d\n", error); | ||
1657 | } | ||
1658 | |||
1659 | /* if no charger found and in USB host mode, set OTG 5V boost, else normal */ | ||
1660 | if (!iinlim && extcon_get_state(bdi->extcon, EXTCON_USB_HOST) == 1) | ||
1661 | v = BQ24190_REG_POC_CHG_CONFIG_OTG; | ||
1662 | else | ||
1663 | v = BQ24190_REG_POC_CHG_CONFIG_CHARGE; | ||
1664 | |||
1665 | error = bq24190_write_mask(bdi, BQ24190_REG_POC, | ||
1666 | BQ24190_REG_POC_CHG_CONFIG_MASK, | ||
1667 | BQ24190_REG_POC_CHG_CONFIG_SHIFT, | ||
1668 | v); | ||
1669 | if (error < 0) | ||
1670 | dev_err(bdi->dev, "Can't set CHG_CONFIG: %d\n", error); | ||
1671 | |||
1672 | pm_runtime_mark_last_busy(bdi->dev); | ||
1673 | pm_runtime_put_autosuspend(bdi->dev); | ||
1674 | } | ||
1675 | |||
1676 | static int bq24190_extcon_event(struct notifier_block *nb, unsigned long event, | ||
1677 | void *param) | ||
1678 | { | ||
1679 | struct bq24190_dev_info *bdi = | ||
1680 | container_of(nb, struct bq24190_dev_info, extcon_nb); | ||
1681 | |||
1682 | /* | ||
1683 | * The Power-Good detection may take up to 220ms, sometimes | ||
1684 | * the external charger detection is quicker, and the bq24190 will | ||
1685 | * reset to iinlim based on its own charger detection (which is not | ||
1686 | * hooked up when using external charger detection) resulting in | ||
1687 | * a too low default 500mA iinlim. Delay applying the extcon value | ||
1688 | * for 300ms to avoid this. | ||
1689 | */ | ||
1690 | queue_delayed_work(system_wq, &bdi->extcon_work, msecs_to_jiffies(300)); | ||
1691 | |||
1692 | return NOTIFY_OK; | ||
1693 | } | ||
1694 | |||
1695 | static int bq24190_hw_init(struct bq24190_dev_info *bdi) | 1632 | static int bq24190_hw_init(struct bq24190_dev_info *bdi) |
1696 | { | 1633 | { |
1697 | u8 v; | 1634 | u8 v; |
@@ -1766,7 +1703,6 @@ static int bq24190_probe(struct i2c_client *client, | |||
1766 | struct device *dev = &client->dev; | 1703 | struct device *dev = &client->dev; |
1767 | struct power_supply_config charger_cfg = {}, battery_cfg = {}; | 1704 | struct power_supply_config charger_cfg = {}, battery_cfg = {}; |
1768 | struct bq24190_dev_info *bdi; | 1705 | struct bq24190_dev_info *bdi; |
1769 | const char *name; | ||
1770 | int ret; | 1706 | int ret; |
1771 | 1707 | ||
1772 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { | 1708 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { |
@@ -1796,25 +1732,6 @@ static int bq24190_probe(struct i2c_client *client, | |||
1796 | return -EINVAL; | 1732 | return -EINVAL; |
1797 | } | 1733 | } |
1798 | 1734 | ||
1799 | /* | ||
1800 | * Devicetree platforms should get extcon via phandle (not yet supported). | ||
1801 | * On ACPI platforms, extcon clients may invoke us with: | ||
1802 | * struct property_entry pe[] = | ||
1803 | * { PROPERTY_ENTRY_STRING("extcon-name", client_name), ... }; | ||
1804 | * struct i2c_board_info bi = | ||
1805 | * { .type = "bq24190", .addr = 0x6b, .properties = pe, .irq = irq }; | ||
1806 | * struct i2c_adapter ad = { ... }; | ||
1807 | * i2c_add_adapter(&ad); | ||
1808 | * i2c_new_device(&ad, &bi); | ||
1809 | */ | ||
1810 | if (device_property_read_string(dev, "extcon-name", &name) == 0) { | ||
1811 | bdi->extcon = extcon_get_extcon_dev(name); | ||
1812 | if (!bdi->extcon) | ||
1813 | return -EPROBE_DEFER; | ||
1814 | |||
1815 | dev_info(bdi->dev, "using extcon device %s\n", name); | ||
1816 | } | ||
1817 | |||
1818 | pm_runtime_enable(dev); | 1735 | pm_runtime_enable(dev); |
1819 | pm_runtime_use_autosuspend(dev); | 1736 | pm_runtime_use_autosuspend(dev); |
1820 | pm_runtime_set_autosuspend_delay(dev, 600); | 1737 | pm_runtime_set_autosuspend_delay(dev, 600); |
@@ -1882,20 +1799,6 @@ static int bq24190_probe(struct i2c_client *client, | |||
1882 | if (ret < 0) | 1799 | if (ret < 0) |
1883 | goto out_sysfs; | 1800 | goto out_sysfs; |
1884 | 1801 | ||
1885 | if (bdi->extcon) { | ||
1886 | INIT_DELAYED_WORK(&bdi->extcon_work, bq24190_extcon_work); | ||
1887 | bdi->extcon_nb.notifier_call = bq24190_extcon_event; | ||
1888 | ret = devm_extcon_register_notifier_all(dev, bdi->extcon, | ||
1889 | &bdi->extcon_nb); | ||
1890 | if (ret) { | ||
1891 | dev_err(dev, "Can't register extcon\n"); | ||
1892 | goto out_sysfs; | ||
1893 | } | ||
1894 | |||
1895 | /* Sync initial cable state */ | ||
1896 | queue_delayed_work(system_wq, &bdi->extcon_work, 0); | ||
1897 | } | ||
1898 | |||
1899 | enable_irq_wake(client->irq); | 1802 | enable_irq_wake(client->irq); |
1900 | 1803 | ||
1901 | pm_runtime_mark_last_busy(dev); | 1804 | pm_runtime_mark_last_busy(dev); |