Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4253347ybp; Mon, 7 Oct 2019 05:49:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcCGqUhabVtTQ7nW/Vz5P/BsI+3tBs+B4648tgki9Hc5AhP0+A22RUD3R9Sh/lQSDJoLBS X-Received: by 2002:a50:e79b:: with SMTP id b27mr28960519edn.186.1570452591353; Mon, 07 Oct 2019 05:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570452591; cv=none; d=google.com; s=arc-20160816; b=vnUkNtbO4XwZQ4tjA3Q4cgyjzZSe74qnHsq9RU3WQJ/LsUxkv34ToxZP9OaxGonEr/ WY8MvMr9mc34cc+CkkHhceEaUp9xZoQrBHzi+xjiQhIzvZfpc5wlruu21U4aQpTDaZaF IAjPIfwuO6F9pWDqWBYoN6y6vR0Z4TVtXIHe+Hdq1t4AdKXqRsDdGMjh2jv4nf5RsmHk B7i3pAStewXjG3W9Nk9y8W6EKzG4tDKa+FStVAXPxhH90Lk0o8z5mH95wct4f8pXUshj zCEOwwA15wAzenyU97g4JYpGcoSSYhrr4ZmRuMAOPw0LCiC7O3AnMNUmJsRNuqa4SfVX Noxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=AT90Kg/zRUtjsdvlXig6kf61Re1a9yGlOxg7dRhOahY=; b=nBXe+1DEy9uzwQMctFiYyujaIZgqVlnpY4BKjijo4ZQM1wpgp7AR5rmYPbiYqEHtkT qsZU+T1OYQks45o1PfB6FgjReP9fd3OziAsuVlkwQSM176SsPm05qgxY34dNJ8uuGe8w ORhd0eDZRLjgGOKUSVabaIAvdoIRjaLdWM3Q+bYg7964Jk6AiG/gbwVPTL/CfpVtgpk0 vmoXCrO0NtcIYjDVaWzEiZkPfzYt8YGLpfM8AFS1zZrKKLTlMk9u3vED9yh4eKLhJxEa +nKbK5knULgteE81ECHvoTQrUfJmqaoIVmI0AxfQROPXh6NYafx+2WtcAdmi3dnbOBMP Yljw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dy8coq+B; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si5867352ejc.404.2019.10.07.05.49.27; Mon, 07 Oct 2019 05:49:51 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=dy8coq+B; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbfJGMrg (ORCPT + 99 others); Mon, 7 Oct 2019 08:47:36 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37452 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727490AbfJGMrf (ORCPT ); Mon, 7 Oct 2019 08:47:35 -0400 Received: by mail-wm1-f66.google.com with SMTP id f22so12199786wmc.2; Mon, 07 Oct 2019 05:47:33 -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; bh=AT90Kg/zRUtjsdvlXig6kf61Re1a9yGlOxg7dRhOahY=; b=dy8coq+B4djgG7XoW0kM31x7L8/pkrlMXAm4QcJzT3GxJGdjcRPIG8+AJd8nECgQ+m pSv6qL03Ct01Prjfha2nrDm+//O/Xxuu2wWq4ThMnWXx1Fcsb/tsCr+qHJJ73ciHlxeL miOXgGdtx3D/f0d/2vDBi7g7Z5EwX8EJF13O1BbGy0q5pBYKp3qbnQVc/HQ8tGBhJC79 y2loQusNna46w9WS6FdAPFLne8ruSPAa7iegJZibz1rftSxs3Dgo0amkY1/6q0krKuCx 3KO/NMJkdjfk02iNAo82YI38MYqQIPbEBwq9CTrMTCEL3dT+ykzJWXGBfR1lfDu0tFXP chIQ== 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; bh=AT90Kg/zRUtjsdvlXig6kf61Re1a9yGlOxg7dRhOahY=; b=EXmJvk/WT0w+b9ZvWGzb4agDLRSMFCi/dUKQxmlbQH/N4KTF8BEH3v702qlpkTeWKa hSh0QmvR6aO7hCFT2Ph1z03AsgSyZ09bZwg3VYWcBd3HyyXqGP74UKjv1DNKCcOtuSOW /BdrRAVDMNONNq6nI947AkbjSiQz9uyaWqfxTIQLj8lefs74BaaiWovlQ710ULbMVI9X I24G/EJ6m36QIzzzeXkL8Fv8XamMG+I2CA3TbIx3yi7KfxbvWuL/XWPKpiPx6IcEYfPl OPsKxKUb++czYAOrIWl2q1Fwe1AXrscE+mcYjwLTR4CHR36FgQIVY4sH4/+6GXYf38tI dscw== X-Gm-Message-State: APjAAAW5OCfFceF2nLVxNSTkQemhr+9oa5StTAE4SgCq92dwbaXFqaEa z0OKjSKFKIySiVF+SxE90db8Qau2S+U= X-Received: by 2002:a7b:cbc5:: with SMTP id n5mr21592790wmi.31.1570452452161; Mon, 07 Oct 2019 05:47:32 -0700 (PDT) Received: from localhost ([194.105.145.90]) by smtp.gmail.com with ESMTPSA id w5sm15870495wrs.34.2019.10.07.05.47.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 05:47:31 -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 , linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 1/3] usb: phy: add usb mode for usb_phy Date: Mon, 7 Oct 2019 15:46:05 +0300 Message-Id: <20191007124607.20618-1-igor.opaniuk@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Igor Opaniuk USB phy driver may need to know the current working mode of the controller, and can provide different settings according to host mode or device mode. Signed-off-by: Li Jun Signed-off-by: Igor Opaniuk --- include/linux/usb/phy.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index e4de6bc1f69b..774941be77d7 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -63,6 +63,13 @@ enum usb_otg_state { OTG_STATE_A_VBUS_ERR, }; +/* The usb role of phy to be working with */ +enum usb_current_mode { + USB_MODE_NONE, + USB_MODE_HOST, + USB_MODE_DEVICE, +}; + struct usb_phy; struct usb_otg; @@ -155,6 +162,13 @@ struct usb_phy { * manually detect the charger type. */ enum usb_charger_type (*charger_detect)(struct usb_phy *x); + + /* + * Set current working mode of the USB controller + * (device, host) + */ + int (*set_mode)(struct usb_phy *x, + enum usb_current_mode mode); }; /* for board-specific init logic */ @@ -213,6 +227,15 @@ usb_phy_vbus_off(struct usb_phy *x) return x->set_vbus(x, false); } +static inline int +usb_phy_set_mode(struct usb_phy *x, enum usb_current_mode mode) +{ + if (!x || !x->set_mode) + return 0; + + return x->set_mode(x, mode); +} + /* for usb host and peripheral controller drivers */ #if IS_ENABLED(CONFIG_USB_PHY) extern struct usb_phy *usb_get_phy(enum usb_phy_type type); -- 2.17.1