linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Brian Masney <masneyb@onstation.org>
Cc: robh+dt@kernel.org, mark.rutland@arm.com, andy.gross@linaro.org,
	david.brown@linaro.org, bjorn.andersson@linaro.org,
	linus.walleij@linaro.org, linux-pm@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org,
	linux-gpio@vger.kernel.org, jonathan@marek.ca
Subject: Re: [PATCH v2 4/7] power: supply: bq24190_charger: add extcon support for USB OTG
Date: Wed, 5 Dec 2018 22:56:44 +0100	[thread overview]
Message-ID: <20181205215644.icx7jpisfhpd2edb@earth.universe> (raw)
In-Reply-To: <20181101001149.13453-5-masneyb@onstation.org>

[-- Attachment #1: Type: text/plain, Size: 3457 bytes --]

Hi,

On Wed, Oct 31, 2018 at 08:11:46PM -0400, Brian Masney wrote:
> Add extcon support so that we can notify USB drivers of cable state
> changes. Based on work from Jonathan Marek. USB OTG was tested on a LG
> Nexus 5 (hammerhead) phone.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/bq24190_charger.c | 37 +++++++++++++++++++++++++-
>  1 file changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> index 9e7f3e33458a..4e64e6ac95c5 100644
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -21,6 +21,7 @@
>  #include <linux/workqueue.h>
>  #include <linux/gpio.h>
>  #include <linux/i2c.h>
> +#include <linux/extcon-provider.h>
>  
>  #define	BQ24190_MANUFACTURER	"Texas Instruments"
>  
> @@ -159,6 +160,7 @@
>  struct bq24190_dev_info {
>  	struct i2c_client		*client;
>  	struct device			*dev;
> +	struct extcon_dev		*edev;
>  	struct power_supply		*charger;
>  	struct power_supply		*battery;
>  	struct delayed_work		input_current_limit_work;
> @@ -174,6 +176,11 @@ struct bq24190_dev_info {
>  	u8				watchdog;
>  };
>  
> +static const unsigned int bq24190_usb_extcon_cable[] = {
> +	EXTCON_USB,
> +	EXTCON_NONE,
> +};
> +
>  /*
>   * The tables below provide a 2-way mapping for the value that goes in
>   * the register field and the real-world value that it represents.
> @@ -1528,6 +1535,20 @@ static const struct power_supply_desc bq24190_battery_desc = {
>  	.property_is_writeable	= bq24190_battery_property_is_writeable,
>  };
>  
> +static int bq24190_configure_usb_otg(struct bq24190_dev_info *bdi, u8 ss_reg)
> +{
> +	bool otg_enabled;
> +	int ret;
> +
> +	otg_enabled = !!(ss_reg & BQ24190_REG_SS_VBUS_STAT_MASK);
> +	ret = extcon_set_state_sync(bdi->edev, EXTCON_USB, otg_enabled);
> +	if (ret < 0)
> +		dev_err(bdi->dev, "Can't set extcon state to %d: %d\n",
> +			otg_enabled, ret);
> +
> +	return ret;
> +}
> +
>  static void bq24190_check_status(struct bq24190_dev_info *bdi)
>  {
>  	const u8 battery_mask_ss = BQ24190_REG_SS_CHRG_STAT_MASK;
> @@ -1597,8 +1618,10 @@ static void bq24190_check_status(struct bq24190_dev_info *bdi)
>  		bdi->ss_reg = ss_reg;
>  	}
>  
> -	if (alert_charger || alert_battery)
> +	if (alert_charger || alert_battery) {
>  		power_supply_changed(bdi->charger);
> +		bq24190_configure_usb_otg(bdi, ss_reg);
> +	}
>  	if (alert_battery && bdi->battery)
>  		power_supply_changed(bdi->battery);
>  
> @@ -1732,6 +1755,14 @@ static int bq24190_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> +	bdi->edev = devm_extcon_dev_allocate(dev, bq24190_usb_extcon_cable);
> +	if (IS_ERR(bdi->edev))
> +		return PTR_ERR(bdi->edev);
> +
> +	ret = devm_extcon_dev_register(dev, bdi->edev);
> +	if (ret < 0)
> +		return ret;
> +
>  	pm_runtime_enable(dev);
>  	pm_runtime_use_autosuspend(dev);
>  	pm_runtime_set_autosuspend_delay(dev, 600);
> @@ -1778,6 +1809,10 @@ static int bq24190_probe(struct i2c_client *client,
>  		goto out_charger;
>  	}
>  
> +	ret = bq24190_configure_usb_otg(bdi, bdi->ss_reg);
> +	if (ret < 0)
> +		goto out_charger;
> +
>  	ret = bq24190_sysfs_create_group(bdi);
>  	if (ret < 0) {
>  		dev_err(dev, "Can't create sysfs entries\n");
> -- 
> 2.17.2
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-12-05 21:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-01  0:11 [PATCH v2 0/7] ARM: qcom: msm8974-hammerhead: add USB OTG support Brian Masney
2018-11-01  0:11 ` [PATCH v2 1/7] dt-bindings: power: supply: bq24190_charger: add bq24192 and usb-otg-vbus Brian Masney
2018-11-05 21:59   ` Rob Herring
2018-12-05 21:55   ` Sebastian Reichel
2018-11-01  0:11 ` [PATCH v2 2/7] power: supply: bq24190_charger: add support for bq24192 variant Brian Masney
2018-12-05 21:56   ` Sebastian Reichel
2018-11-01  0:11 ` [PATCH v2 3/7] power: supply: bq24190_charger: add of_match for usb-otg-vbus regulator Brian Masney
2018-12-05 21:56   ` Sebastian Reichel
2018-11-01  0:11 ` [PATCH v2 4/7] power: supply: bq24190_charger: add extcon support for USB OTG Brian Masney
2018-12-05 21:56   ` Sebastian Reichel [this message]
2018-11-01  0:11 ` [PATCH v2 5/7] pinctrl: qcom: spmi-gpio: fix gpio-hog related boot issues Brian Masney
2018-11-09  8:59   ` Linus Walleij
2018-11-09 10:22     ` Brian Masney
2018-11-01  0:11 ` [PATCH v2 6/7] ARM: dts: qcom: msm8974: add gpio-ranges Brian Masney
2018-12-07 11:41   ` Brian Masney
2018-11-01  0:11 ` [PATCH v2 7/7] ARM: dts: qcom: msm8974-hammerhead: add USB OTG support Brian Masney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181205215644.icx7jpisfhpd2edb@earth.universe \
    --to=sebastian.reichel@collabora.com \
    --cc=andy.gross@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=david.brown@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathan@marek.ca \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=masneyb@onstation.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).