Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1431339 > unrolled thread
| Started by | Stephen Boyd <stephen.boyd@linaro.org> |
|---|---|
| First post | 2016-06-26 08:00 +0200 |
| Last post | 2016-06-29 01:50 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] power: qcom_smbb: Make an extcon for usb cable detection Stephen Boyd <stephen.boyd@linaro.org> - 2016-06-26 08:00 +0200
Re: [PATCH] power: qcom_smbb: Make an extcon for usb cable detection Chanwoo Choi <cwchoi00@gmail.com> - 2016-06-26 13:20 +0200
Re: [PATCH] power: qcom_smbb: Make an extcon for usb cable detection Sebastian Reichel <sre@kernel.org> - 2016-06-29 01:50 +0200
| From | Stephen Boyd <stephen.boyd@linaro.org> |
|---|---|
| Date | 2016-06-26 08:00 +0200 |
| Subject | [PATCH] power: qcom_smbb: Make an extcon for usb cable detection |
| Message-ID | <rObgS-7hv-1@gated-at.bofh.it> |
On these PMICs the usb cable connection/disconnection is
indicated by the usb-valid interrupt being high or low
respectively. Let's make an extcon for that, so we can notify usb
drivers of the cable state.
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
---
drivers/power/qcom_smbb.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
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 @@
#include <linux/power_supply.h>
#include <linux/regmap.h>
#include <linux/slab.h>
+#include <linux/extcon.h>
#define SMBB_CHG_VMAX 0x040
#define SMBB_CHG_VSAFE 0x041
@@ -111,6 +112,7 @@ struct smbb_charger {
unsigned int revision;
unsigned int addr;
struct device *dev;
+ struct extcon_dev *edev;
bool dc_disabled;
bool jeita_ext_temp;
@@ -125,6 +127,11 @@ struct smbb_charger {
struct regmap *regmap;
};
+static const unsigned int smbb_usb_extcon_cable[] = {
+ EXTCON_USB,
+ EXTCON_NONE,
+};
+
static int smbb_vbat_weak_fn(unsigned int index)
{
return 2100000 + index * 100000;
@@ -371,6 +378,8 @@ static irqreturn_t smbb_usb_valid_handler(int irq, void *_data)
struct smbb_charger *chg = _data;
smbb_set_line_flag(chg, irq, STATUS_USBIN_VALID);
+ extcon_set_cable_state_(chg->edev, EXTCON_USB,
+ chg->status & STATUS_USBIN_VALID);
power_supply_changed(chg->usb_psy);
return IRQ_HANDLED;
@@ -849,6 +858,18 @@ static int smbb_charger_probe(struct platform_device *pdev)
return PTR_ERR(chg->usb_psy);
}
+ chg->edev = devm_extcon_dev_allocate(&pdev->dev, smbb_usb_extcon_cable);
+ if (IS_ERR(chg->edev)) {
+ dev_err(&pdev->dev, "failed to allocate extcon device\n");
+ return -ENOMEM;
+ }
+
+ rc = devm_extcon_dev_register(&pdev->dev, chg->edev);
+ if (rc < 0) {
+ dev_err(&pdev->dev, "failed to register extcon device\n");
+ return rc;
+ }
+
if (!chg->dc_disabled) {
dc_cfg.drv_data = chg;
dc_cfg.supplied_to = smbb_bif;
--
2.9.0.rc2.8.ga28705d
[toc] | [next] | [standalone]
| From | Chanwoo Choi <cwchoi00@gmail.com> |
|---|---|
| Date | 2016-06-26 13:20 +0200 |
| Message-ID | <rOggy-2gs-11@gated-at.bofh.it> |
| In reply to | #1431339 |
Hi,
Looks good to me.
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Thanks,
Chanwoo Choi
2016-06-26 14:54 GMT+09:00 Stephen Boyd <stephen.boyd@linaro.org>:
> On these PMICs the usb cable connection/disconnection is
> indicated by the usb-valid interrupt being high or low
> respectively. Let's make an extcon for that, so we can notify usb
> drivers of the cable state.
>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: Chanwoo Choi <cw00.choi@samsung.com>
> Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
> ---
> drivers/power/qcom_smbb.c | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> 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 @@
> #include <linux/power_supply.h>
> #include <linux/regmap.h>
> #include <linux/slab.h>
> +#include <linux/extcon.h>
>
> #define SMBB_CHG_VMAX 0x040
> #define SMBB_CHG_VSAFE 0x041
> @@ -111,6 +112,7 @@ struct smbb_charger {
> unsigned int revision;
> unsigned int addr;
> struct device *dev;
> + struct extcon_dev *edev;
>
> bool dc_disabled;
> bool jeita_ext_temp;
> @@ -125,6 +127,11 @@ struct smbb_charger {
> struct regmap *regmap;
> };
>
> +static const unsigned int smbb_usb_extcon_cable[] = {
> + EXTCON_USB,
> + EXTCON_NONE,
> +};
> +
> static int smbb_vbat_weak_fn(unsigned int index)
> {
> return 2100000 + index * 100000;
> @@ -371,6 +378,8 @@ static irqreturn_t smbb_usb_valid_handler(int irq, void *_data)
> struct smbb_charger *chg = _data;
>
> smbb_set_line_flag(chg, irq, STATUS_USBIN_VALID);
> + extcon_set_cable_state_(chg->edev, EXTCON_USB,
> + chg->status & STATUS_USBIN_VALID);
> power_supply_changed(chg->usb_psy);
>
> return IRQ_HANDLED;
> @@ -849,6 +858,18 @@ static int smbb_charger_probe(struct platform_device *pdev)
> return PTR_ERR(chg->usb_psy);
> }
>
> + chg->edev = devm_extcon_dev_allocate(&pdev->dev, smbb_usb_extcon_cable);
> + if (IS_ERR(chg->edev)) {
> + dev_err(&pdev->dev, "failed to allocate extcon device\n");
> + return -ENOMEM;
> + }
> +
> + rc = devm_extcon_dev_register(&pdev->dev, chg->edev);
> + if (rc < 0) {
> + dev_err(&pdev->dev, "failed to register extcon device\n");
> + return rc;
> + }
> +
> if (!chg->dc_disabled) {
> dc_cfg.drv_data = chg;
> dc_cfg.supplied_to = smbb_bif;
> --
> 2.9.0.rc2.8.ga28705d
>
[toc] | [prev] | [next] | [standalone]
| From | Sebastian Reichel <sre@kernel.org> |
|---|---|
| Date | 2016-06-29 01:50 +0200 |
| Message-ID | <rPaVs-54x-3@gated-at.bofh.it> |
| In reply to | #1431339 |
[Multipart message — attachments visible in raw view] — view raw
Hi, On Sat, Jun 25, 2016 at 10:54:37PM -0700, Stephen Boyd wrote: > On these PMICs the usb cable connection/disconnection is > indicated by the usb-valid interrupt being high or low > respectively. Let's make an extcon for that, so we can notify usb > drivers of the cable state. > > Cc: Bjorn Andersson <bjorn.andersson@linaro.org> > Cc: Chanwoo Choi <cw00.choi@samsung.com> > Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org> Thanks, queued. -- Sebastian
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web