From patchwork Sun Mar 24 15:36:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 2326811 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id CBB63DFB79 for ; Sun, 24 Mar 2013 15:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754064Ab3CXPhH (ORCPT ); Sun, 24 Mar 2013 11:37:07 -0400 Received: from mail-ea0-f169.google.com ([209.85.215.169]:65141 "EHLO mail-ea0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754049Ab3CXPhF (ORCPT ); Sun, 24 Mar 2013 11:37:05 -0400 Received: by mail-ea0-f169.google.com with SMTP id n15so364801ead.14 for ; Sun, 24 Mar 2013 08:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=YBW86UQDMN45rn6tWNdXYXSsHMmgJvWVaz0kYamKOCA=; b=AApMuo0RaWiN2RUaMfHsw2ISaZVp1ngVpA6FpcWwJZaxqHVMSIvdnJFQIbCyTtPI6b ZrwZ5XasRQgim+Mcpt98I39uB74QzM6fqFifJzZFUF5wRsWBlXtwOBDebsojg3OAz9uT SUMBaH6ZdXq5HF3CmNO/Ezh7HKEuM6OHuLLQ+VNHTHb4MjF8WN8KVqaXLTahv3Rxt6Ou qpVf+snhJOMCdhQwvG3aRW1wBurEzOs5oOvNbo96UZ7ijpiwxGwnQqG6Hd2YTdzp7JG2 /emlZaM17KNV1YuWwWwpnF1f53qJeUU2FWWzPe6oyhHBebxpSLRrTLe9KOyMOaH4yb+D HaGA== X-Received: by 10.14.110.68 with SMTP id t44mr24783783eeg.25.1364139424098; Sun, 24 Mar 2013 08:37:04 -0700 (PDT) Received: from localhost.localdomain (ip-88-119-226-136.static.b4net.lt. [88.119.226.136]) by mx.google.com with ESMTPS id bc1sm2560964eeb.11.2013.03.24.08.37.02 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 Mar 2013 08:37:03 -0700 (PDT) From: Grazvydas Ignotas To: linux-usb@vger.kernel.org Cc: linux-omap@vger.kernel.org, Felipe Balbi , kishon , Grazvydas Ignotas Subject: [PATCHv3 1/3] usb: phy: twl4030-usb: check if vbus is driven by twl itself Date: Sun, 24 Mar 2013 17:36:53 +0200 Message-Id: <1364139415-16695-2-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1364139415-16695-1-git-send-email-notasas@gmail.com> References: <1364139415-16695-1-git-send-email-notasas@gmail.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org At least on pandora, STS_VBUS gets set even when VBUS is driven by twl itself. Reporting VBUS in this case confuses OMAP musb glue and charger driver, so check if OTG VBUS charge pump is on before reporting VBUS event to avoid this problem. Signed-off-by: Grazvydas Ignotas --- drivers/usb/phy/phy-twl4030-usb.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/usb/phy/phy-twl4030-usb.c b/drivers/usb/phy/phy-twl4030-usb.c index 61fe7e2..3f9858f 100644 --- a/drivers/usb/phy/phy-twl4030-usb.c +++ b/drivers/usb/phy/phy-twl4030-usb.c @@ -248,6 +248,25 @@ twl4030_usb_clear_bits(struct twl4030_usb *twl, u8 reg, u8 bits) /*-------------------------------------------------------------------------*/ +static bool twl4030_is_driving_vbus(struct twl4030_usb *twl) +{ + int ret; + + ret = twl4030_usb_read(twl, PHY_CLK_CTRL_STS); + if (ret < 0 || !(ret & PHY_DPLL_CLK)) + /* + * if clocks are off, registers are not updated, + * but we can assume we don't drive VBUS in this case + */ + return false; + + ret = twl4030_usb_read(twl, ULPI_OTG_CTRL); + if (ret < 0) + return false; + + return (ret & (ULPI_OTG_DRVVBUS | ULPI_OTG_CHRGVBUS)) ? true : false; +} + static enum omap_musb_vbus_id_status twl4030_usb_linkstat(struct twl4030_usb *twl) { @@ -270,13 +289,19 @@ static enum omap_musb_vbus_id_status if (status < 0) dev_err(twl->dev, "USB link status err %d\n", status); else if (status & (BIT(7) | BIT(2))) { - if (status & (BIT(7))) - twl->vbus_supplied = true; + if (status & BIT(7)) { + if (twl4030_is_driving_vbus(twl)) + status &= ~BIT(7); + else + twl->vbus_supplied = true; + } if (status & BIT(2)) linkstat = OMAP_MUSB_ID_GROUND; - else + else if (status & BIT(7)) linkstat = OMAP_MUSB_VBUS_VALID; + else + linkstat = OMAP_MUSB_VBUS_OFF; } else { if (twl->linkstat != OMAP_MUSB_UNKNOWN) linkstat = OMAP_MUSB_VBUS_OFF;