All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neil@brown.name>
To: Sebastian Reichel <sre@kernel.org>
Cc: NeilBrown <neilb@suse.de>,
	linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
	GTA04 owners <gta04-owner@goldelico.com>,
	inux-pm@vger.kernel.org, Pavel Machek <pavel@ucw.cz>,
	linux-omap@vger.kernel.org, Lee Jones <lee.jones@linaro.org>
Subject: [PATCH 04/14] twl4030_charger: trust phy to determine when USB power is available.
Date: Mon, 23 Mar 2015 10:20:28 +1100	[thread overview]
Message-ID: <20150322232028.23789.91362.stgit@notabene.brown> (raw)
In-Reply-To: <20150322231635.23789.70149.stgit@notabene.brown>

From: NeilBrown <neilb@suse.de>

The usb phy driver already determines when VBUS is available,
so repeating the test in the charger driver is pointless duplication.

On probe, process the last event from the phy, and from then on,
do whatever the phy tells us without double-checking.

Signed-off-by: NeilBrown <neilb@suse.de>
---
 drivers/power/twl4030_charger.c |   33 ++++++---------------------------
 1 file changed, 6 insertions(+), 27 deletions(-)

diff --git a/drivers/power/twl4030_charger.c b/drivers/power/twl4030_charger.c
index 94c7a4d9400a..0e62a5ae56a3 100644
--- a/drivers/power/twl4030_charger.c
+++ b/drivers/power/twl4030_charger.c
@@ -178,28 +178,6 @@ static int twl4030_is_battery_present(struct twl4030_bci *bci)
 }
 
 /*
- * Check if VBUS power is present
- */
-static int twl4030_bci_have_vbus(struct twl4030_bci *bci)
-{
-	int ret;
-	u8 hwsts;
-
-	ret = twl_i2c_read_u8(TWL_MODULE_PM_MASTER, &hwsts,
-			      TWL4030_PM_MASTER_STS_HW_CONDITIONS);
-	if (ret < 0)
-		return 0;
-
-	dev_dbg(bci->dev, "check_vbus: HW_CONDITIONS %02x\n", hwsts);
-
-	/* in case we also have STS_USB_ID, VBUS is driven by TWL itself */
-	if ((hwsts & TWL4030_STS_VBUS) && !(hwsts & TWL4030_STS_USB_ID))
-		return 1;
-
-	return 0;
-}
-
-/*
  * Enable/Disable USB Charge functionality.
  */
 static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable)
@@ -207,10 +185,6 @@ static int twl4030_charger_enable_usb(struct twl4030_bci *bci, bool enable)
 	int ret;
 
 	if (enable && !IS_ERR_OR_NULL(bci->transceiver)) {
-		/* Check for USB charger connected */
-		if (!twl4030_bci_have_vbus(bci))
-			return -ENODEV;
-
 		/*
 		 * Until we can find out what current the device can provide,
 		 * require a module param to enable USB charging.
@@ -649,7 +623,12 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
 		dev_warn(&pdev->dev, "failed to unmask interrupts: %d\n", ret);
 
 	twl4030_charger_enable_ac(true);
-	twl4030_charger_enable_usb(bci, true);
+	if (!IS_ERR_OR_NULL(bci->transceiver))
+		twl4030_bci_usb_ncb(&bci->usb_nb,
+				    bci->transceiver->last_event,
+				    NULL);
+	else
+		twl4030_charger_enable_usb(bci, false);
 	if (pdata)
 		twl4030_charger_enable_backup(pdata->bb_uvolt,
 					      pdata->bb_uamp);



  parent reply	other threads:[~2015-03-22 23:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-22 23:20 [PATCH 00/14] Enhance twl4030_charger functionality. - V2 NeilBrown
2015-03-22 23:20 ` [PATCH 05/14] twl4030_charger: split uA calculation into a function NeilBrown
2015-03-22 23:20 ` [PATCH 03/14] twl4030_charger: use runtime_pm to keep usb phy active while charging NeilBrown
2015-03-22 23:20 ` [PATCH 02/14] twl4030_charger: use devres for power_supply_register and kzalloc NeilBrown
2015-03-23 21:25   ` Pavel Machek
2015-07-24 14:35   ` Sebastian Reichel
2015-07-24 14:35     ` Sebastian Reichel
2015-03-22 23:20 ` [PATCH 01/14] twl4030_charger: use devm_request_threaded_irq NeilBrown
2015-07-24 14:34   ` Sebastian Reichel
2015-03-22 23:20 ` NeilBrown [this message]
2015-03-22 23:20 ` [PATCH 14/14] twl4030_charger: assume a 'charger' can supply maximum current NeilBrown
2015-03-22 23:20 ` [PATCH 06/14] twl4030_charger: allow fine control of charger current NeilBrown
2015-03-22 23:20 ` [PATCH 10/14] twl4030_charger: enable manual enable/disable of usb charging NeilBrown
2015-03-22 23:20 ` [PATCH 13/14] twl4030_charger: Increase current carefully while watching voltage NeilBrown
2015-03-23 21:25   ` Pavel Machek
2015-03-29 21:26     ` NeilBrown
2015-03-29 21:26       ` NeilBrown
2015-04-04  7:48       ` Pavel Machek
2015-04-04  7:48         ` Pavel Machek
2015-03-22 23:20 ` [PATCH 08/14] twl4030_charger: allow max_current to be managed via sysfs NeilBrown
2015-03-23 12:14   ` [Gta04-owner] " jake42
2015-03-23 12:14     ` jake42
2015-07-29 22:10     ` NeilBrown
2015-07-29 22:10       ` NeilBrown
2015-03-22 23:20 ` [PATCH 11/14] twl4030_charger: add software controlled linear charging mode NeilBrown
2015-03-22 23:20   ` NeilBrown
2015-03-22 23:20 ` [PATCH 09/14] twl4030_charger: only draw USB current as negotiated with host NeilBrown
2015-03-22 23:20 ` [PATCH 07/14] twl4030_charger: distinguish between USB current and 'AC' current NeilBrown
2015-03-22 23:20 ` [PATCH 12/14] twl4030_charger: add ac/mode to match usb/mode NeilBrown
2015-07-24 14:44 ` [PATCH 00/14] Enhance twl4030_charger functionality. - V2 Sebastian Reichel
2015-07-24 14:44   ` Sebastian Reichel

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=20150322232028.23789.91362.stgit@notabene.brown \
    --to=neil@brown.name \
    --cc=gta04-owner@goldelico.com \
    --cc=inux-pm@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=pavel@ucw.cz \
    --cc=sre@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.