From patchwork Fri Jan 20 18:50:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 92108 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp199272obz; Fri, 20 Jan 2017 10:51:57 -0800 (PST) X-Received: by 10.99.232.5 with SMTP id s5mr17766684pgh.66.1484938317896; Fri, 20 Jan 2017 10:51:57 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b88si7569320pli.222.2017.01.20.10.51.57; Fri, 20 Jan 2017 10:51:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753292AbdATSv4 (ORCPT + 25 others); Fri, 20 Jan 2017 13:51:56 -0500 Received: from mail-pg0-f42.google.com ([74.125.83.42]:33041 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752630AbdATSvC (ORCPT ); Fri, 20 Jan 2017 13:51:02 -0500 Received: by mail-pg0-f42.google.com with SMTP id 204so25654737pge.0 for ; Fri, 20 Jan 2017 10:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LSF8wmYZeZ1EtDEzeK0K+D7OAW9TSjZGln9gDKva/TY=; b=Eom+w7RQgzkoNNqrHansobhnDAaVP27Z685+ZiHYGEl6W7lLOqyUpUi804CIeNbnZV hceMkFaxRd1iq1FenvnBZiXrg+dJQ2jA9xjljIScZ07IKLHWh56dKVaf11pCofb8PEkx k+n4NSodbIUmbR8Db4WGs3usFRpdDQ4BGXmlY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LSF8wmYZeZ1EtDEzeK0K+D7OAW9TSjZGln9gDKva/TY=; b=QQ9CZHLx9C9g5xF2vH3CWQlUZGfU13SRlseajugAJOf0NrVcy5FezQ1lx6eYlUB2ZG F9r5fS+PP0DmhVJdO3ALXzTuJUUNAyKTNGgflgkF+dEQk0QH+7ttLO3O4oOpVoIzj1Ze 8HJoiv9tW0dEwCl8wNdKxy0igrdYALHS4LnNzAhCj2K2zqjKaHHtQpo3DCmr2QqiY7JW FDYzmp1sDTZhOa+PobRyZQjkqg+yhKTBWhy3d/fbO916UKP3F//Yg0XN7BJQ3tDa5RSZ Dnd6JsX6OC4mJXnLtO0goaDzC63Ern712micD4bIQAUamLwkoB0Pu5CyzvyxTv/Y2T4E l4Fw== X-Gm-Message-State: AIkVDXLmpllrpthODikuyyUUHNVW+Z2xLtGHmA8R8X+WVHKdNbzT/TCK3OZ9EzIkCNJP21Gu X-Received: by 10.99.170.70 with SMTP id x6mr18423389pgo.14.1484938261867; Fri, 20 Jan 2017 10:51:01 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id j78sm18574274pfk.39.2017.01.20.10.51.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Jan 2017 10:51:01 -0800 (PST) From: Stephen Boyd To: Peter Chen , Kishon Vijay Abraham I Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , linux-usb@vger.kernel.org, Greg Kroah-Hartman Subject: [PATCH v7 2/5] usb: chipidea: msm: Configure phy for appropriate mode Date: Fri, 20 Jan 2017 10:50:54 -0800 Message-Id: <20170120185057.16206-3-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 In-Reply-To: <20170120185057.16206-1-stephen.boyd@linaro.org> References: <20170120185057.16206-1-stephen.boyd@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the qcom chipidea controller is used with an extcon, we need to signal device mode or host mode to the phy so it can configure itself for the correct mode. This should be done after the phy is powered up, so that the register writes work correctly. Add in the appropriate phy_set_mode() call here. To signal the correct state to the qcom glue driver we need to change the ci->role before we do the role switch. Make sure to undo the change if the role switch fails, but otherwise update the state before calling the role start function so that the glue driver knows what state to configure for. Cc: Greg Kroah-Hartman Signed-off-by: Stephen Boyd --- Made this msm specific because of how msm handles phy powerup. drivers/usb/chipidea/ci.h | 7 +++++-- drivers/usb/chipidea/ci_hdrc_msm.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.10.0.297.gf6727b0 diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 59e22389c10b..18348b0529af 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -268,6 +268,7 @@ static inline struct ci_role_driver *ci_role(struct ci_hdrc *ci) static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role) { int ret; + enum ci_role prev_role; if (role >= CI_ROLE_END) return -EINVAL; @@ -275,9 +276,11 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role) if (!ci->roles[role]) return -ENXIO; + prev_role = ci->role; + ci->role = role; ret = ci->roles[role]->start(ci); - if (!ret) - ci->role = role; + if (ret) + ci->role = prev_role; return ret; } diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index f1ede7909f54..9c58d13970ca 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -125,6 +125,10 @@ static int ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) hw_write(ci, OP_USBCMD, HSPHY_SESS_VLD_CTRL, HSPHY_SESS_VLD_CTRL); + if (ci->role == CI_ROLE_GADGET) + phy_set_mode(ci->phy, PHY_MODE_USB_DEVICE); + else if (ci->role == CI_ROLE_HOST) + phy_set_mode(ci->phy, PHY_MODE_USB_HOST); } break; case CI_HDRC_CONTROLLER_STOPPED_EVENT: