Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1381302ybl; Mon, 2 Dec 2019 02:37:32 -0800 (PST) X-Google-Smtp-Source: APXvYqxFcv3wIPNstGLU8EtiZq/mLP45qD1gUv8hRC9H1VrnHh45jZ7wBt5r229n+fq5WWNhAjks X-Received: by 2002:a17:906:6c8:: with SMTP id v8mr9430433ejb.260.1575283052819; Mon, 02 Dec 2019 02:37:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575283052; cv=none; d=google.com; s=arc-20160816; b=n1BYt4I95HNjynYew3bxvG2iPGywCLtNQvfT4rLJUXrmpIUqDUCEOm8992XLdTh7os h+a5WkLELdcCPhX3d202vPbE3UcuofYEdlklvReT4Cypf4RMGh7HRe3ExoEuT4VH+kTp Zqk03H0GqNUQzKLCSRyjbHvi7E50Ufk2nzDkZJO334kjMnxMDr4xAQ5hftoAFIzMaGBK iA4EHdC9Ar59o/3dXxhaVYzHIIe7C4rNXiJkjZrO8KCrUtPZf/1dY19rogQfK9J1ivka 0ANBJVMHZfJ32D2cQm7gZLgdXQjlqjcdtQ2YguzVtuxJuddcEA4SG66vRyFk+PYqsMwf Gt4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=mJKajnqhtQ4VFh36m+UlyF2xEEUhH3v2ORgay45sbSA=; b=J7eTxDW2SnOWwS+Gh9xPOLr0E5G3RDf5rUXgcXsPsfX+N2j5R8uK9+S+OTalSrnwKj Kps6XFblf5/o82djM2kFhXa33TDpOr0gXOtGxKaXeQGPsVr/PoLnYwHB5cOOxZpExk2g vXh1nBhLep0jsJTLHOjs6H1dKHMTH6tdYK7dPFzKH+uHANh3thfx09azEzNnYhHmnBaC P0gX8EwGVMITSV1RIbdyCAx9d1DGEKxpZfSuArQzTlnNG6pd1wjybUai4b84uyTO8EBH spDSUNR8l7egsRomH1ZYDedF1y/nCiGoN3qU7C8U6o+kK9NHWwCpL0lAmGOD88y4inWT VBrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x5BjUOZh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay9si20787419edb.44.2019.12.02.02.37.08; Mon, 02 Dec 2019 02:37:32 -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 header.s=google header.b=x5BjUOZh; 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 S1727488AbfLBKeE (ORCPT + 99 others); Mon, 2 Dec 2019 05:34:04 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:34386 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727408AbfLBKeE (ORCPT ); Mon, 2 Dec 2019 05:34:04 -0500 Received: by mail-wm1-f65.google.com with SMTP id f4so5547924wmj.1 for ; Mon, 02 Dec 2019 02:34:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mJKajnqhtQ4VFh36m+UlyF2xEEUhH3v2ORgay45sbSA=; b=x5BjUOZhdFg4RDmgImDZXRwNVl4P4SSu7T+Bm2IUeYoTtGneyEkFfatl8waIvczgdo 2RzioLi2De7ExBSouFPlvaeAhd1oBeiHid2yJiArQXQIxKzq9IxDdO7x3eAFpK1ayInt QcarC0MHurT6CCuY3ShBDdo3f44QnvQLCpJjmD1O0dcpc9aENIRp+N2hwxJyKSdDkEdm EjJLebsg672C6b2VcfNOE7c8ibDoIXXNn7xnP8u0Jgj9wV3syeuD+8XupVcxpy7MiLVz 5xNm4gaMTpuyXNgPy1mGzADszjpoRds+4X8w6LuUmubh2x1zl87pbWx6c0Ld1nlK33GG KApw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mJKajnqhtQ4VFh36m+UlyF2xEEUhH3v2ORgay45sbSA=; b=BUUh20s2AJTc7Aj8oqsBdVZSwM46Pat4V2wmOzP5sFv3jevE5NMpdNpoMXDn8iR/em y+DaZsmAkviudUQaKdcCX9FWKKf0/xdlQnCXKmQH7cznFuyz8HURhcrBM8YK2rIvPIrG WBrbmPOWU0JZNLDTrJ4ki9A9rDjONsmH9vRtNaz7d+PbsvMmEy12TDxm8KZd1Np5Y9Tc X+ecI/vlW+mTXV2PW1ybVUHL2DcjJY/9YMrOSiBDTmJCTWhUbYk7FST6/EPpX3iO7+SP bZEXtEJK8zeSyVvCfMfmZ7SQKwohEdpZsDOPMcvnO9PXUVCSNLVXYfRHZ4JG5zQuDJ5g TGBQ== X-Gm-Message-State: APjAAAXsCbh9SrrowOaWyCw44dk5MwN8n+RxE9JoSeW54CMr6OwfsnAy OM5x4YXFEgD+kjLlratj9RZsvQ== X-Received: by 2002:a7b:cb4a:: with SMTP id v10mr26464570wmj.106.1575282842250; Mon, 02 Dec 2019 02:34:02 -0800 (PST) Received: from [192.168.0.38] ([176.61.57.127]) by smtp.gmail.com with ESMTPSA id k20sm22134737wmj.10.2019.12.02.02.34.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 02 Dec 2019 02:34:01 -0800 (PST) Subject: Re: [PATCH v6 3/8] usb: dwc3: Add support for role-switch-default-mode binding To: John Stultz , lkml Cc: Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org References: <20191128051001.18995-1-john.stultz@linaro.org> <20191128051001.18995-4-john.stultz@linaro.org> From: Bryan O'Donoghue Message-ID: Date: Mon, 2 Dec 2019 10:34:17 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191128051001.18995-4-john.stultz@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/11/2019 05:09, John Stultz wrote: > Support the new role-switch-default-mode binding for configuring > the default role the controller assumes as when the usb role is > USB_ROLE_NONE > > This patch was split out from a larger patch originally by > Yu Chen > > Cc: Greg Kroah-Hartman > Cc: Rob Herring > Cc: Mark Rutland > CC: ShuFan Lee > Cc: Heikki Krogerus > Cc: Suzuki K Poulose > Cc: Chunfeng Yun > Cc: Yu Chen > Cc: Felipe Balbi > Cc: Hans de Goede > Cc: Andy Shevchenko > Cc: Jun Li > Cc: Valentin Schneider > Cc: Jack Pham > Cc: linux-usb@vger.kernel.org > Cc: devicetree@vger.kernel.org > Signed-off-by: John Stultz > Change-Id: Ic6e4df1109b350deaecdc69f667d49ce91d599f3 > --- > v3: Split this patch out from addition of usb-role-switch > handling > v5: Reworked to use string based role-switch-default-mode > --- > drivers/usb/dwc3/core.h | 3 +++ > drivers/usb/dwc3/drd.c | 25 ++++++++++++++++++++++--- > 2 files changed, 25 insertions(+), 3 deletions(-) > > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h > index 6f19e9891767..3c879c9ab1aa 100644 > --- a/drivers/usb/dwc3/core.h > +++ b/drivers/usb/dwc3/core.h > @@ -953,6 +953,8 @@ struct dwc3_scratchpad_array { > * - USBPHY_INTERFACE_MODE_UTMI > * - USBPHY_INTERFACE_MODE_UTMIW > * @role_sw: usb_role_switch handle > + * @role_switch_default_mode: default operation mode of controller while > + * usb role is USB_ROLE_NONE. > * @usb2_phy: pointer to USB2 PHY > * @usb3_phy: pointer to USB3 PHY > * @usb2_generic_phy: pointer to USB2 PHY > @@ -1087,6 +1089,7 @@ struct dwc3 { > struct notifier_block edev_nb; > enum usb_phy_interface hsphy_mode; > struct usb_role_switch *role_sw; > + enum usb_dr_mode role_switch_default_mode; > > u32 fladj; > u32 irq_gadget; > diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c > index 3b57d2ddda93..865341facece 100644 > --- a/drivers/usb/dwc3/drd.c > +++ b/drivers/usb/dwc3/drd.c > @@ -491,7 +491,10 @@ static int dwc3_usb_role_switch_set(struct device *dev, enum usb_role role) > mode = DWC3_GCTL_PRTCAP_DEVICE; > break; > default: > - mode = DWC3_GCTL_PRTCAP_DEVICE; > + if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) > + mode = DWC3_GCTL_PRTCAP_HOST; > + else > + mode = DWC3_GCTL_PRTCAP_DEVICE; > break; > } > > @@ -517,7 +520,10 @@ static enum usb_role dwc3_usb_role_switch_get(struct device *dev) > role = dwc->current_otg_role; > break; > default: > - role = USB_ROLE_DEVICE; > + if (dwc->role_switch_default_mode == USB_DR_MODE_HOST) > + role = USB_ROLE_HOST; > + else > + role = USB_ROLE_DEVICE; > break; > } > spin_unlock_irqrestore(&dwc->lock, flags); > @@ -527,6 +533,19 @@ static enum usb_role dwc3_usb_role_switch_get(struct device *dev) > static int dwc3_setup_role_switch(struct dwc3 *dwc) > { > struct usb_role_switch_desc dwc3_role_switch = {NULL}; > + const char *str; > + u32 mode; > + int ret; > + > + ret = device_property_read_string(dwc->dev, "role-switch-default-mode", > + &str); > + if (ret >= 0 && !strncmp(str, "host", strlen("host"))) { > + dwc->role_switch_default_mode = USB_DR_MODE_HOST; > + mode = DWC3_GCTL_PRTCAP_HOST; > + } else { > + dwc->role_switch_default_mode = USB_DR_MODE_PERIPHERAL; > + mode = DWC3_GCTL_PRTCAP_DEVICE; > + } > > dwc3_role_switch.fwnode = dev_fwnode(dwc->dev); > dwc3_role_switch.set = dwc3_usb_role_switch_set; > @@ -535,7 +554,7 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc) > if (IS_ERR(dwc->role_sw)) > return PTR_ERR(dwc->role_sw); > > - dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); > + dwc3_set_mode(dwc, mode); > return 0; > } > #else > Tested-by: Bryan O'Donoghue