diff options
| -rw-r--r-- | drivers/power/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/power/qcom_smbb.c | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 421770ddafa3..6bff735c632d 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig | |||
| @@ -393,6 +393,7 @@ config CHARGER_QCOM_SMBB | |||
| 393 | tristate "Qualcomm Switch-Mode Battery Charger and Boost" | 393 | tristate "Qualcomm Switch-Mode Battery Charger and Boost" |
| 394 | depends on MFD_SPMI_PMIC || COMPILE_TEST | 394 | depends on MFD_SPMI_PMIC || COMPILE_TEST |
| 395 | depends on OF | 395 | depends on OF |
| 396 | depends on EXTCON | ||
| 396 | help | 397 | help |
| 397 | Say Y to include support for the Switch-Mode Battery Charger and | 398 | Say Y to include support for the Switch-Mode Battery Charger and |
| 398 | Boost (SMBB) hardware found in Qualcomm PM8941 PMICs. The charger | 399 | Boost (SMBB) hardware found in Qualcomm PM8941 PMICs. The charger |
diff --git a/drivers/power/qcom_smbb.c b/drivers/power/qcom_smbb.c index 5eb1e9e543e2..b5896ba2a602 100644 --- a/drivers/power/qcom_smbb.c +++ b/drivers/power/qcom_smbb.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include <linux/power_supply.h> | 34 | #include <linux/power_supply.h> |
| 35 | #include <linux/regmap.h> | 35 | #include <linux/regmap.h> |
| 36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
| 37 | #include <linux/extcon.h> | ||
| 37 | 38 | ||
| 38 | #define SMBB_CHG_VMAX 0x040 | 39 | #define SMBB_CHG_VMAX 0x040 |
| 39 | #define SMBB_CHG_VSAFE 0x041 | 40 | #define SMBB_CHG_VSAFE 0x041 |
| @@ -111,6 +112,7 @@ struct smbb_charger { | |||
| 111 | unsigned int revision; | 112 | unsigned int revision; |
| 112 | unsigned int addr; | 113 | unsigned int addr; |
| 113 | struct device *dev; | 114 | struct device *dev; |
| 115 | struct extcon_dev *edev; | ||
| 114 | 116 | ||
| 115 | bool dc_disabled; | 117 | bool dc_disabled; |
| 116 | bool jeita_ext_temp; | 118 | bool jeita_ext_temp; |
| @@ -125,6 +127,11 @@ struct smbb_charger { | |||
| 125 | struct regmap *regmap; | 127 | struct regmap *regmap; |
| 126 | }; | 128 | }; |
| 127 | 129 | ||
| 130 | static const unsigned int smbb_usb_extcon_cable[] = { | ||
| 131 | EXTCON_USB, | ||
| 132 | EXTCON_NONE, | ||
| 133 | }; | ||
| 134 | |||
| 128 | static int smbb_vbat_weak_fn(unsigned int index) | 135 | static int smbb_vbat_weak_fn(unsigned int index) |
| 129 | { | 136 | { |
| 130 | return 2100000 + index * 100000; | 137 | return 2100000 + index * 100000; |
| @@ -371,6 +378,8 @@ static irqreturn_t smbb_usb_valid_handler(int irq, void *_data) | |||
| 371 | struct smbb_charger *chg = _data; | 378 | struct smbb_charger *chg = _data; |
| 372 | 379 | ||
| 373 | smbb_set_line_flag(chg, irq, STATUS_USBIN_VALID); | 380 | smbb_set_line_flag(chg, irq, STATUS_USBIN_VALID); |
| 381 | extcon_set_cable_state_(chg->edev, EXTCON_USB, | ||
| 382 | chg->status & STATUS_USBIN_VALID); | ||
| 374 | power_supply_changed(chg->usb_psy); | 383 | power_supply_changed(chg->usb_psy); |
| 375 | 384 | ||
| 376 | return IRQ_HANDLED; | 385 | return IRQ_HANDLED; |
| @@ -849,6 +858,18 @@ static int smbb_charger_probe(struct platform_device *pdev) | |||
| 849 | return PTR_ERR(chg->usb_psy); | 858 | return PTR_ERR(chg->usb_psy); |
| 850 | } | 859 | } |
| 851 | 860 | ||
| 861 | chg->edev = devm_extcon_dev_allocate(&pdev->dev, smbb_usb_extcon_cable); | ||
| 862 | if (IS_ERR(chg->edev)) { | ||
| 863 | dev_err(&pdev->dev, "failed to allocate extcon device\n"); | ||
| 864 | return -ENOMEM; | ||
| 865 | } | ||
| 866 | |||
| 867 | rc = devm_extcon_dev_register(&pdev->dev, chg->edev); | ||
| 868 | if (rc < 0) { | ||
| 869 | dev_err(&pdev->dev, "failed to register extcon device\n"); | ||
| 870 | return rc; | ||
| 871 | } | ||
| 872 | |||
| 852 | if (!chg->dc_disabled) { | 873 | if (!chg->dc_disabled) { |
| 853 | dc_cfg.drv_data = chg; | 874 | dc_cfg.drv_data = chg; |
| 854 | dc_cfg.supplied_to = smbb_bif; | 875 | dc_cfg.supplied_to = smbb_bif; |
