From patchwork Mon Oct 7 12:46:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Opaniuk X-Patchwork-Id: 11177393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FB5F112B for ; Mon, 7 Oct 2019 12:47:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E85D21BE5 for ; Mon, 7 Oct 2019 12:47:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BArA0duk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727958AbfJGMrj (ORCPT ); Mon, 7 Oct 2019 08:47:39 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33688 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727904AbfJGMrj (ORCPT ); Mon, 7 Oct 2019 08:47:39 -0400 Received: by mail-wr1-f66.google.com with SMTP id b9so15174324wrs.0; Mon, 07 Oct 2019 05:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3+0xNKANMoqD2LM7Jb0KxrBIYqLeJsaQlJrD1LYqzho=; b=BArA0dukyOOQG0I91sTg+fEwZnhirpCntvT3S6t7//3e8XVIJPzesiuad/8zoZ9Myb BEvJFtw6zOUSdgz5WMyYito5s9Az/NqjCIRTp+dicUAyEKaJk2uxnD+sAcaN8L65nd0P iF6GD/vKVquAZcBNyStWpWjkhxEWykw0/WJCW2hoO+uUEWVvPbmhHvtby0pA9SJmNtjj 81xsfkn2lnxP73Vjd2ZqVXmuHugrrpnHsEwjmgRdFLDXawGhcin1bN/hpEdfOjCBkJyt DOkuekKS8VGEKl4z/e+V51A/r99OBNtBOJctwPp2lFx4jU31ffrFUc59tD5UCR9MWQbo KZmw== 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=3+0xNKANMoqD2LM7Jb0KxrBIYqLeJsaQlJrD1LYqzho=; b=RfkK66wgNfRgRLtLchOu5i1LVTMvo3DsTGVm/i4E6ZhCLkICgK1Uo4d6JXVDGRQjxl 8nZE0zRcr3w3WPKVKKs4xtYGTElzbeeD8raP7aYTZHRuTbe9sStKRRQ43SPylNwCafvk VuSfRlGdyRoBE1GGTSFtQpLh0uQjn7Ho/sThYQE84O9ftBHUiSG2s5AO6V27kgkWLDF/ czDjHV7iCGs3TRAmZGKt99f+kjYnkiHxESxghMIPo57tKh7y2Xo3VRRVXjhKqLtpAU2a R5LIfp6hyxxWbTZteqJLvWD16VFtJXfBpv1khBiR21tGJDwpwDlHwOyVAH5CRT4mRGwP kFsQ== X-Gm-Message-State: APjAAAWJdAzU1xOXRsy/MbrO5rxX1hzrlasX6IO1j3hyMp7RitWLHuZw SOnGgUDoZXJtiOw4yeTmUtoyH2Zf2Ec= X-Google-Smtp-Source: APXvYqwN3wNI0EhseuwoKQOqFG95vCPzBQL45WawolPwUaIlN31vWOdiUKmK1TZFmZ9zOpePr8lPFg== X-Received: by 2002:adf:f7c3:: with SMTP id a3mr9788540wrq.275.1570452456841; Mon, 07 Oct 2019 05:47:36 -0700 (PDT) Received: from localhost ([194.105.145.90]) by smtp.gmail.com with ESMTPSA id b15sm18454390wmb.28.2019.10.07.05.47.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 05:47:36 -0700 (PDT) From: Igor Opaniuk To: linux-usb@vger.kernel.org Cc: Marcel Ziswiler , Philippe Schenker , Stefan Agner , Max Krummenacher , Oleksandr Suvorov , Igor Opaniuk , Li Jun , Greg Kroah-Hartman , Peter Chen , linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 2/3] usb: chipidea: set mode for usb phy driver Date: Mon, 7 Oct 2019 15:46:06 +0300 Message-Id: <20191007124607.20618-2-igor.opaniuk@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007124607.20618-1-igor.opaniuk@gmail.com> References: <20191007124607.20618-1-igor.opaniuk@gmail.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org From: Igor Opaniuk After enters one specific role, notify usb phy driver. Signed-off-by: Li Jun Signed-off-by: Igor Opaniuk --- drivers/usb/chipidea/ci.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index 6911aef500e9..a11d23910b12 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -275,9 +275,21 @@ static inline int ci_role_start(struct ci_hdrc *ci, enum ci_role role) return -ENXIO; ret = ci->roles[role]->start(ci); - if (!ret) - ci->role = role; - return ret; + if (ret) + return ret; + + ci->role = role; + + if (ci->usb_phy) { + if (role == CI_ROLE_HOST) + usb_phy_set_mode(ci->usb_phy, + USB_MODE_HOST); + else + usb_phy_set_mode(ci->usb_phy, + USB_MODE_DEVICE); + } + + return 0; } static inline void ci_role_stop(struct ci_hdrc *ci) @@ -290,6 +302,9 @@ static inline void ci_role_stop(struct ci_hdrc *ci) ci->role = CI_ROLE_END; ci->roles[role]->stop(ci); + + if (ci->usb_phy) + usb_phy_set_mode(ci->usb_phy, USB_MODE_NONE); } static inline enum usb_role ci_role_to_usb_role(struct ci_hdrc *ci)