[PATCH] usb: gadget: f_fs: Use config_ep_by_speed()

2018-01-24 Thread Jack Pham
In commit 2bfa0719ac2a ("usb: gadget: function: f_fs: pass
companion descriptor along") there is a pointer arithmetic
bug where the comp_desc is obtained as follows:

 comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds +
   USB_DT_ENDPOINT_SIZE);

Since ds is a pointer to usb_endpoint_descriptor, adding
7 to it ends up going out of bounds (7 * sizeof(struct
usb_endpoint_descriptor), which is actually 7*9 bytes) past
the SS descriptor. As a result the maxburst value will be
read incorrectly, and the UDC driver will also get a garbage
comp_desc (assuming it uses it).

Since Felipe wrote, "Eventually, f_fs.c should be converted
to use config_ep_by_speed() like all other functions, though",
let's finally do it. This allows the other usb_ep fields to
be properly populated, such as maxpacket and mult. It also
eliminates the awkward speed-based descriptor lookup since
config_ep_by_speed() does that already using the ones found
in struct usb_function.

Fixes: 2bfa0719ac2a ("usb: gadget: function: f_fs: pass companion descriptor 
along")
Cc: sta...@vger.kernel.org
Signed-off-by: Jack Pham 
---
 drivers/usb/gadget/function/f_fs.c | 38 +++---
 1 file changed, 7 insertions(+), 31 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index 5f2dafb5..717b2de 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1852,44 +1852,20 @@ static int ffs_func_eps_enable(struct ffs_function 
*func)
 
spin_lock_irqsave(>ffs->eps_lock, flags);
while(count--) {
-   struct usb_endpoint_descriptor *ds;
-   struct usb_ss_ep_comp_descriptor *comp_desc = NULL;
-   int needs_comp_desc = false;
-   int desc_idx;
-
-   if (ffs->gadget->speed == USB_SPEED_SUPER) {
-   desc_idx = 2;
-   needs_comp_desc = true;
-   } else if (ffs->gadget->speed == USB_SPEED_HIGH)
-   desc_idx = 1;
-   else
-   desc_idx = 0;
-
-   /* fall-back to lower speed if desc missing for current speed */
-   do {
-   ds = ep->descs[desc_idx];
-   } while (!ds && --desc_idx >= 0);
-
-   if (!ds) {
-   ret = -EINVAL;
-   break;
-   }
-
ep->ep->driver_data = ep;
-   ep->ep->desc = ds;
 
-   if (needs_comp_desc) {
-   comp_desc = (struct usb_ss_ep_comp_descriptor *)(ds +
-   USB_DT_ENDPOINT_SIZE);
-   ep->ep->maxburst = comp_desc->bMaxBurst + 1;
-   ep->ep->comp_desc = comp_desc;
+   ret = config_ep_by_speed(func->gadget, >function, ep->ep);
+   if (ret) {
+   pr_err("%s: config_ep_by_speed(%s) returned %d\n",
+   __func__, ep->ep->name, ret);
+   break;
}
 
ret = usb_ep_enable(ep->ep);
if (likely(!ret)) {
epfile->ep = ep;
-   epfile->in = usb_endpoint_dir_in(ds);
-   epfile->isoc = usb_endpoint_xfer_isoc(ds);
+   epfile->in = usb_endpoint_dir_in(ep->ep->desc);
+   epfile->isoc = usb_endpoint_xfer_isoc(ep->ep->desc);
} else {
break;
}
-- 
2.9.1.200.gb1ec08f

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: MX25 USB timeout on ID 0951:1665 Kingston Technology Digital DataTraveler SE9 64GB

2018-01-24 Thread Peter Chen

 
> On Mon, Jan 15, 2018 at 2:35 PM, Michael Nazzareno Trimarchi
>  wrote:
> > Hi Peter
> >
> > On Mon, Dec 25, 2017 at 1:56 AM, Peter Chen  wrote:
> >>
> >>> > On Thu, Nov 16, 2017 at 10:20 AM, Peter Chen 
> wrote:
> >>> >>
> >>> >>> >
> >>> >>> > All USB registers, including USB transceiver, USB non-core, and USB
> core.
> >>> >>>
> >>> >>> I need to have some time to go to the platform again. It will be
> >>> >>> possible this
> >>> weekend.
> >>> >>> Have you any idea to restrict the debug apart register dump?
> >>> >>>
> >>> >>
> >>> >> I am afraid I don't have since imx25 is too old, I have little
> >>> >> directly experiences on
> >>> it.
> >>> >>
> >>> >
> >>> > I have done some testing on top. I can not easily dump registers
> >>> > on the 2.6.31. I have recompile the old kernel and re-instrumented it.
> >>> > Well I don't find any important thing.
> >>> >
> >>> > The old kernel was using ehci_fsl.c basecode and the new one use
> >>> > chipidea. Let's say that some changes are in USB_CTRL usbmisc
> >>> > controller initialization but even play with those bits I did not
> >>> > find any failure on that side. I will continue on difference. Hope
> >>> > that some other have some idea ;).
> >>>
> >>> I have used a usb hardware tracer. What I can say that basically
> >>> after the reset the device try to go in HIGH SPEED mode but the
> >>> controller can only manage full speed even is an ehci.
> >>>
> >>> I have tried the errata to set PFSC bit but is even set from the dts
> >>> if we force the FULL SPEED mode.
> >
> > The big difference I found is the way that they schedule request in
> > periodic schedule introduce by
> > 3ca9aebac2ebb8f56d2d097636b8c568320a9f87 from v3.10
> >
> 
> After reading all the code and check every registers. I discovered that 
> problem is
> before kernel start. For now is a magic mistery. I need to check bootloader 
> source
> code. Old kernel and new kernel works in old bootloader. I need to understand 
> what
> is done in the bootloader that make kernel not perfect working
> 
 
I am glad you are close to answer :) 

Peter


Request to add new VID/PID to PL2303 driver

2018-01-24 Thread Chu . Mike [朱堅宜]
Dear Johan / Greg,

We have a new customer who wants to add their VID/PID to the PL2303 driver 
source.
Can you help me?

Customer: Chilitag
VID: 067B
PID: AAA8

{ USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_CHILITAG) },

#define PL2303_VENDOR_ID0x067b
#define PL2303_PRODUCT_ID_CHILITAG0xaaa8

Thanks,

Mike Chu
Prolific Technology Inc.
保密警語: 
本電子郵件內容及其附加檔案均視為機密資料,受保密合約保護或依法不得洩漏。其內容僅供指定收件人按限定範圍或特殊目的合法使用,未經授權者收到此信息均無權閱讀、使用、複製、洩漏或散佈。若您並非本郵件之指定收件人,請即刻回覆郵件並永久刪除此郵件及其附件和銷毀所有複印文件。電子郵件的傳輸可能遭攔截、損毀、遺失、破壞、遲到或不完整、或包含病毒,無法保證其安全或無誤。寄件人不承擔因本電子郵件的錯誤或遺漏所產生的任何損害賠償責任。
 Confidentiality Notice: This e-mail message together with any attachments 
thereto (if any) is confidential, protected under an enforceable non-disclosure 
agreement, intended only for the use of the named recipient(s) above and may 
contain information that is privileged, belonging to professional work products 
or exempt from disclosure under applicable laws. Any unauthorized review, use, 
copying, disclosure, or distribution of any information contained in or 
attached to this transmission is strictly prohibited and may be against the 
laws. If you have received this message in error, or are not the intended 
recipient(s), please immediately notify the sender by e-mail and delete this 
e-mail message, all copies, and any attached documentation from your computer. 
E-mail transmission cannot be guaranteed to be secure or error-free as 
information could be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete, or contain viruses. The sender therefore does not accept liability 
for any damage caused by any errors or omissions in the contents of this email.
N�r��yb�X��ǧv�^�)޺{.n�+{��^n�r���z���h�&���G���h�(�階�ݢj"���m��z�ޖ���f���h���~�m�

Re: [RFC/RFT usb-next v1 1/6] usb: mtu3: remove custom USB PHY handling

2018-01-24 Thread Chunfeng Yun
Hi,

On Thu, 2018-01-25 at 01:16 +0100, Martin Blumenstingl wrote:
> The new PHY wrapper is now wired up in the core HCD code. This means
> that PHYs are now controlled (initialized, enabled, disabled, exited)
> without requiring any host-driver specific code.
> Remove the custom USB PHY handling from the mtu3 driver as the core HCD
> code now handles this.
> 
> Signed-off-by: Martin Blumenstingl 
> ---
>  drivers/usb/mtu3/mtu3_plat.c | 101 
> ---
>  1 file changed, 101 deletions(-)
> 
> diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
> index 628d5ce356ca..a894ddf25bcd 100644
> --- a/drivers/usb/mtu3/mtu3_plat.c
> +++ b/drivers/usb/mtu3/mtu3_plat.c
> @@ -44,62 +44,6 @@ int ssusb_check_clocks(struct ssusb_mtk *ssusb, u32 
> ex_clks)
>   return 0;
>  }
>  
> -static int ssusb_phy_init(struct ssusb_mtk *ssusb)
> -{
> - int i;
> - int ret;
> -
> - for (i = 0; i < ssusb->num_phys; i++) {
> - ret = phy_init(ssusb->phys[i]);
> - if (ret)
> - goto exit_phy;
> - }
> - return 0;
> -
> -exit_phy:
> - for (; i > 0; i--)
> - phy_exit(ssusb->phys[i - 1]);
> -
> - return ret;
> -}
> -
> -static int ssusb_phy_exit(struct ssusb_mtk *ssusb)
> -{
> - int i;
> -
> - for (i = 0; i < ssusb->num_phys; i++)
> - phy_exit(ssusb->phys[i]);
> -
> - return 0;
> -}
> -
> -static int ssusb_phy_power_on(struct ssusb_mtk *ssusb)
> -{
> - int i;
> - int ret;
> -
> - for (i = 0; i < ssusb->num_phys; i++) {
> - ret = phy_power_on(ssusb->phys[i]);
> - if (ret)
> - goto power_off_phy;
> - }
> - return 0;
> -
> -power_off_phy:
> - for (; i > 0; i--)
> - phy_power_off(ssusb->phys[i - 1]);
> -
> - return ret;
> -}
> -
> -static void ssusb_phy_power_off(struct ssusb_mtk *ssusb)
> -{
> - unsigned int i;
> -
> - for (i = 0; i < ssusb->num_phys; i++)
> - phy_power_off(ssusb->phys[i]);
> -}
> -
>  static int ssusb_clks_enable(struct ssusb_mtk *ssusb)
>  {
>   int ret;
> @@ -162,24 +106,8 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb)
>   if (ret)
>   goto clks_err;
>  
> - ret = ssusb_phy_init(ssusb);
> - if (ret) {
> - dev_err(ssusb->dev, "failed to init phy\n");
> - goto phy_init_err;
> - }
> -
> - ret = ssusb_phy_power_on(ssusb);
> - if (ret) {
> - dev_err(ssusb->dev, "failed to power on phy\n");
> - goto phy_err;
> - }
> -
>   return 0;
>  
> -phy_err:
> - ssusb_phy_exit(ssusb);
> -phy_init_err:
> - ssusb_clks_disable(ssusb);
>  clks_err:
>   regulator_disable(ssusb->vusb33);
>  vusb33_err:
> @@ -190,8 +118,6 @@ static void ssusb_rscs_exit(struct ssusb_mtk *ssusb)
>  {
>   ssusb_clks_disable(ssusb);
>   regulator_disable(ssusb->vusb33);
> - ssusb_phy_power_off(ssusb);
> - ssusb_phy_exit(ssusb);
>  }
>  
>  static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
> @@ -222,7 +148,6 @@ static int get_ssusb_rscs(struct platform_device *pdev, 
> struct ssusb_mtk *ssusb)
>   struct device *dev = >dev;
>   struct regulator *vbus;
>   struct resource *res;
> - int i;
>   int ret;
>  
>   ssusb->vusb33 = devm_regulator_get(>dev, "vusb33");
> @@ -249,25 +174,6 @@ static int get_ssusb_rscs(struct platform_device *pdev, 
> struct ssusb_mtk *ssusb)
>   if (IS_ERR(ssusb->dma_clk))
>   return PTR_ERR(ssusb->dma_clk);
>  
> - ssusb->num_phys = of_count_phandle_with_args(node,
> - "phys", "#phy-cells");
> - if (ssusb->num_phys > 0) {
> - ssusb->phys = devm_kcalloc(dev, ssusb->num_phys,
> - sizeof(*ssusb->phys), GFP_KERNEL);
> - if (!ssusb->phys)
> - return -ENOMEM;
> - } else {
> - ssusb->num_phys = 0;
> - }
> -
> - for (i = 0; i < ssusb->num_phys; i++) {
> - ssusb->phys[i] = devm_of_phy_get_by_index(dev, node, i);
> - if (IS_ERR(ssusb->phys[i])) {
> - dev_err(dev, "failed to get phy-%d\n", i);
> - return PTR_ERR(ssusb->phys[i]);
> - }
> - }
> -
>   res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ippc");
>   ssusb->ippc_base = devm_ioremap_resource(dev, res);
>   if (IS_ERR(ssusb->ippc_base))
> @@ -457,7 +363,6 @@ static int __maybe_unused mtu3_suspend(struct device *dev)
>   return 0;
>  
>   ssusb_host_disable(ssusb, true);
> - ssusb_phy_power_off(ssusb);
>   ssusb_clks_disable(ssusb);
>   ssusb_wakeup_set(ssusb, true);
>  
> @@ -480,16 +385,10 @@ static int __maybe_unused mtu3_resume(struct device 
> *dev)
>   if (ret)
>   goto clks_err;
>  
> - ret = ssusb_phy_power_on(ssusb);
> - if (ret)
> -

Re: [PATCH 2/4] usb: dwc3: add dwc3 glue layer for UniPhier SoCs

2018-01-24 Thread Kunihiko Hayashi
Hello Felipe,

On Wed, 24 Jan 2018 14:58:12 +0200  wrote:

> 
> Hi,
> 
> Kunihiko Hayashi  writes:
> > Hello Felipe,
> >
> > Thank you for your comments.
> >
> > On Tue, 23 Jan 2018 15:12:36 +0200  wrote:
> >
> >> 
> >> Hi,
> >> 
> >> Kunihiko Hayashi  writes:
> >> > Add a specific glue layer for UniPhier SoC platform to support
> >> > USB host mode. It manages hardware operating sequences to enable multiple
> >> > clock gates and assert resets, and to prepare to use dwc3 controller
> >> > on the SoC.
> >> >
> >> > This patch also handles the physical layer that has same register space
> >> > as the glue layer, because it needs to integrate initialziation sequence
> >> > between glue and phy.
> >> >
> >> > In case of some SoCs, since some initialization values for PHY are
> >> > included in nvmem, this patch includes the way to get the values from 
> >> > nvmem.
> >> >
> >> > It supports PXs2 and LD20 SoCs.
> >> >
> >> > Signed-off-by: Kunihiko Hayashi 
> >> > Signed-off-by: Motoya Tanigawa 
> >> > Signed-off-by: Masami Hiramatsu 
> >> > ---
> >> >  drivers/usb/dwc3/Kconfig |   9 +
> >> >  drivers/usb/dwc3/Makefile|   1 +
> >> >  drivers/usb/dwc3/dwc3-uniphier.c | 554 
> >> > +++
> >> >  3 files changed, 564 insertions(+)
> >> >  create mode 100644 drivers/usb/dwc3/dwc3-uniphier.c
> >
> > ...snip...
> >
> >> > +
> >> > +static void dwc3u_ssphy_testio_write(struct dwc3u_priv *priv, int port,
> >> > + u32 data)
> >> 
> >> anything with sshphy or hsphy in the name should probably be part of a
> >> PHY driver using drivers/phy/ framework.
> >
> > I can try to separate phy control from this driver.
> > However, phy registers belongs to "dwc3-glue" IO map area (65b0),
> > and this area also contains a reset bit for "dwc3-core" hardware.
> >
> > Although the phy driver is called from dwc3-core driver,
> > we need to deassert the reset bit before probing dwc3-core driver.
> >
> > As shown later, I think that it's difficut to determine the order of
> > initializing the registers in this area.
> >
> >> > +static void dwc3u_vbus_disable(struct dwc3u_priv *priv)
> >> > +{
> >> > +int i;
> >> > +
> >> > +for (i = 0; i < priv->nvbus; i++) {
> >> > +dwc3u_maskwrite(priv, VBUS_CONTROL(i),
> >> > +DRVVBUS_REG_EN | DRVVBUS_REG,
> >> > +DRVVBUS_REG_EN | 0);
> >> > +}
> >> > +}
> >> 
> >> drivers/regulator maybe?
> >
> > VBUS_CONTROL register is used for determing whether "dwc3-glue" hardware
> > enables vbus connected with "regulator" hardware.
> >
> > The regulator driver should manage "regulator" hardware, and
> > I don't think that the driver should manage this register.
> >
> >> > +static void dwc3u_reset_init(struct dwc3u_priv *priv)
> >> > +{
> >> > +dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, 0);
> >> > +usleep_range(1000, 2000);
> >> > +dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, LINK_RESET);
> >> > +}
> >> > +
> >> > +static void dwc3u_reset_clear(struct dwc3u_priv *priv)
> >> > +{
> >> > +dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, 0);
> >> > +}
> >> 
> >> drivers/reset ?
> >
> > The reset driver manages "sysctrl" IO map area in our SoC.
> >
> > RESET_CTL register belongs to "dwc3-glue" IO map area,
> > and the kernel can't access this area until enabling usb clocks and
> > deasserting usb resets in "sysctrl".
> >
> > I think that "dwc3-glue" register control should be separated from
> > "sysctrl".
> 
> Just split your address space and treat your glue as a device with
> several children:
> 
> glue@65b0 {
>   compatible = "foo"

Just to confirm, instead of SoC-specific glue driver, dwc3-of-simple.c
should handle compatible "foo", right?

> 
>   phy@bar {
>   ...
>   };
> 
>   sysctrl@baz {
>   ...
>   };
> 
>   dwc3@foo {
>   compatible = "snps, dwc3";
> ...
>   };
> };
> 
> Then you know that you can let dwc3/core.c handle the PHY for you. If we
> need to teach dwc3/core.c about regulators, we can do that. But we don't
> need SoC-specific hacks ;-)

I also don't think that dwc3/core.c should have any SoC-specific controls.
I've thought the SoC-specific glue driver (dwc3-***.c) calls "clocks",
"resets", and "regulators".

However, although dwc3-of-simple.c can handle "clocks", it can't handle
"resets" and "regulators". Who should call them?

Thank you,

---
Best Regards,
Kunihiko Hayashi

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/RFT usb-next v1 5/6] usb: chipidea: do not set the "phy" field in struct usb_hcd

2018-01-24 Thread Martin Blumenstingl
Now that usb_add_hcd parses all generic PHYs anyways the code which
skips initialization of a single PHY will go away.
Remove the code which sets struct usb_hcd's phy field from the chipidea
driver as this field will go away soon.

Signed-off-by: Martin Blumenstingl 
---
 drivers/usb/chipidea/host.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c
index 19d60ed7e41f..fc324767cb0f 100644
--- a/drivers/usb/chipidea/host.c
+++ b/drivers/usb/chipidea/host.c
@@ -124,9 +124,7 @@ static int host_start(struct ci_hdrc *ci)
 
hcd->power_budget = ci->platdata->power_budget;
hcd->tpl_support = ci->platdata->tpl_support;
-   if (ci->phy)
-   hcd->phy = ci->phy;
-   else
+   if (!ci->phy)
hcd->usb_phy = ci->usb_phy;
 
ehci = hcd_to_ehci(hcd);
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/RFT usb-next v1 6/6] usb: core: hcd: remove support for initializing a single PHY

2018-01-24 Thread Martin Blumenstingl
With the new PHY wrapper in place we can now handle multiple PHYs.
Remove the code which handles only one generic PHY as this is now
covered (with support for multiple PHYs as well as suspend/resume
support) by the new PHY wrapper.

Signed-off-by: Martin Blumenstingl 
---
 drivers/usb/core/hcd.c  | 37 -
 include/linux/usb/hcd.h |  1 -
 2 files changed, 38 deletions(-)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index fc99cddc117e..5d59e0b4d463 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2757,30 +2757,6 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
}
 
-   if (IS_ENABLED(CONFIG_GENERIC_PHY) && !hcd->phy) {
-   struct phy *phy = phy_get(hcd->self.sysdev, "usb");
-
-   if (IS_ERR(phy)) {
-   retval = PTR_ERR(phy);
-   if (retval == -EPROBE_DEFER)
-   goto err_phy;
-   } else {
-   retval = phy_init(phy);
-   if (retval) {
-   phy_put(phy);
-   goto err_phy;
-   }
-   retval = phy_power_on(phy);
-   if (retval) {
-   phy_exit(phy);
-   phy_put(phy);
-   goto err_phy;
-   }
-   hcd->phy = phy;
-   hcd->remove_phy = 1;
-   }
-   }
-
hcd->phy_roothub = usb_phy_roothub_init(hcd->self.sysdev);
if (IS_ERR(hcd->phy_roothub)) {
retval = PTR_ERR(hcd->phy_roothub);
@@ -2959,13 +2935,6 @@ int usb_add_hcd(struct usb_hcd *hcd,
 err_usb_phy_roothub_power_on:
usb_phy_roothub_exit(hcd->phy_roothub);
 err_phy_roothub_init:
-   if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
-   phy_power_off(hcd->phy);
-   phy_exit(hcd->phy);
-   phy_put(hcd->phy);
-   hcd->phy = NULL;
-   }
-err_phy:
if (hcd->remove_phy && hcd->usb_phy) {
usb_phy_shutdown(hcd->usb_phy);
usb_put_phy(hcd->usb_phy);
@@ -3046,12 +3015,6 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_phy_roothub_power_off(hcd->phy_roothub);
usb_phy_roothub_exit(hcd->phy_roothub);
 
-   if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
-   phy_power_off(hcd->phy);
-   phy_exit(hcd->phy);
-   phy_put(hcd->phy);
-   hcd->phy = NULL;
-   }
if (hcd->remove_phy && hcd->usb_phy) {
usb_phy_shutdown(hcd->usb_phy);
usb_put_phy(hcd->usb_phy);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 9e8fc9c5f394..e464c7384bd5 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -103,7 +103,6 @@ struct usb_hcd {
 * other external phys should be software-transparent
 */
struct usb_phy  *usb_phy;
-   struct phy  *phy;
struct usb_phy_roothub  *phy_roothub;
 
/* Flags that need to be manipulated atomically because they can
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/RFT usb-next v1 4/6] usb: host: ohci-platform: remove custom USB PHY handling

2018-01-24 Thread Martin Blumenstingl
The new PHY wrapper is now wired up in the core HCD code. This means
that PHYs are now controlled (initialized, enabled, disabled, exited)
without requiring any host-driver specific code.
Remove the custom USB PHY handling from the ohci-platform driver as the
core HCD code now handles this.

Signed-off-by: Martin Blumenstingl 
---
 drivers/usb/host/ohci-platform.c | 56 
 1 file changed, 5 insertions(+), 51 deletions(-)

diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c
index 1e6c954f4b3f..65a1c3fdc88c 100644
--- a/drivers/usb/host/ohci-platform.c
+++ b/drivers/usb/host/ohci-platform.c
@@ -21,7 +21,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -38,8 +38,6 @@
 struct ohci_platform_priv {
struct clk *clks[OHCI_MAX_CLKS];
struct reset_control *resets;
-   struct phy **phys;
-   int num_phys;
 };
 
 static const char hcd_name[] = "ohci-platform";
@@ -48,7 +46,7 @@ static int ohci_platform_power_on(struct platform_device *dev)
 {
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
-   int clk, ret, phy_num;
+   int clk, ret;
 
for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) {
ret = clk_prepare_enable(priv->clks[clk]);
@@ -56,24 +54,8 @@ static int ohci_platform_power_on(struct platform_device 
*dev)
goto err_disable_clks;
}
 
-   for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
-   ret = phy_init(priv->phys[phy_num]);
-   if (ret)
-   goto err_exit_phy;
-   ret = phy_power_on(priv->phys[phy_num]);
-   if (ret) {
-   phy_exit(priv->phys[phy_num]);
-   goto err_exit_phy;
-   }
-   }
-
return 0;
 
-err_exit_phy:
-   while (--phy_num >= 0) {
-   phy_power_off(priv->phys[phy_num]);
-   phy_exit(priv->phys[phy_num]);
-   }
 err_disable_clks:
while (--clk >= 0)
clk_disable_unprepare(priv->clks[clk]);
@@ -85,12 +67,7 @@ static void ohci_platform_power_off(struct platform_device 
*dev)
 {
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd);
-   int clk, phy_num;
-
-   for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
-   phy_power_off(priv->phys[phy_num]);
-   phy_exit(priv->phys[phy_num]);
-   }
+   int clk;
 
for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--)
if (priv->clks[clk])
@@ -117,7 +94,7 @@ static int ohci_platform_probe(struct platform_device *dev)
struct usb_ohci_pdata *pdata = dev_get_platdata(>dev);
struct ohci_platform_priv *priv;
struct ohci_hcd *ohci;
-   int err, irq, phy_num, clk = 0;
+   int err, irq, clk = 0;
 
if (usb_disabled())
return -ENODEV;
@@ -169,29 +146,6 @@ static int ohci_platform_probe(struct platform_device *dev)
of_property_read_u32(dev->dev.of_node, "num-ports",
 >num_ports);
 
-   priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
-   "phys", "#phy-cells");
-
-   if (priv->num_phys > 0) {
-   priv->phys = devm_kcalloc(>dev, priv->num_phys,
-   sizeof(struct phy *), GFP_KERNEL);
-   if (!priv->phys)
-   return -ENOMEM;
-   } else
-   priv->num_phys = 0;
-
-   for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
-   priv->phys[phy_num] = devm_of_phy_get_by_index(
-   >dev, dev->dev.of_node, phy_num);
-   if (IS_ERR(priv->phys[phy_num])) {
-   err = PTR_ERR(priv->phys[phy_num]);
-   goto err_put_hcd;
-   } else if (!hcd->phy) {
-   /* Avoiding phy_get() in usb_add_hcd() */
-   hcd->phy = priv->phys[phy_num];
-   }
-   }
-
for (clk = 0; clk < OHCI_MAX_CLKS; clk++) {
priv->clks[clk] = of_clk_get(dev->dev.of_node, clk);
if (IS_ERR(priv->clks[clk])) {
@@ -277,7 +231,7 @@ static int ohci_platform_probe(struct platform_device *dev)
 err_put_clks:
while (--clk >= 0)
clk_put(priv->clks[clk]);
-err_put_hcd:
+
if (pdata == _platform_defaults)
dev->dev.platform_data = NULL;
 
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a 

[RFC/RFT usb-next v1 0/6] remove driver-specific "multiple PHY" handling

2018-01-24 Thread Martin Blumenstingl
(this is the follow-up to my "initialize (multiple) PHYs for a HCD"
series from [0])

Various USB controller drivers parse the "phys" device-tree property and
grab all listed PHYs.
There is a lot of duplicate code around this in the various drivers:
- parse the "phys" property during .probe and save all PHYs in an array
- call phy_init and phy_power_on on all PHYs
- (where supported by the driver) call phy_power_off during .suspend and
  phy_power_on during .resume
- call phy_power_off and phy_exit during .remove

With [0] this functionality was moved to the core HCD driver, meaning
that all USB controller drivers now support this without having to
implement custom code for it.

Thus this series removes this code duplication.

The last two patches are a bit special:
- after patches #1-4 the chipidea driver is the last driver which sets
  the "phy" field of struct usb_hcd. remove this logic as the PHY
  wrapper (which is now part of the core HCD driver) manages the state
  of all PHYs anyways.
- the last patch removes the "phy" field from struct usb_hcd because
  nothing uses it anymore after the previous patches. it also removes
  the parsing and managing of a single PHY with the name "usb" as the
  new PHY wrapper parses all PHYs from the device-tree "phys" property
  anyways (so the PHY wrapper has the same functionality, except that it
  doesn't need the phy-name "usb" and it can manage more than one PHY)

preconditions for testing this series: all patches from [0] need to be
applied.
disclaimer: I don't have any hardware that uses any of the affected
drivers!


[0] http://lists.infradead.org/pipermail/linux-amlogic/2018-January/006274.html

Martin Blumenstingl (6):
  usb: mtu3: remove custom USB PHY handling
  usb: host: xhci-mtk: remove custom USB PHY handling
  usb: host: ehci-platform: remove custom USB PHY handling
  usb: host: ohci-platform: remove custom USB PHY handling
  usb: chipidea: do not set the "phy" field in struct usb_hcd
  usb: core: hcd: remove support for initializing a single PHY

 drivers/usb/chipidea/host.c  |   4 +-
 drivers/usb/core/hcd.c   |  37 --
 drivers/usb/host/ehci-platform.c |  55 ++---
 drivers/usb/host/ohci-platform.c |  56 ++
 drivers/usb/host/xhci-mtk.c  |  98 +
 drivers/usb/mtu3/mtu3_plat.c | 101 ---
 include/linux/usb/hcd.h  |   1 -
 7 files changed, 12 insertions(+), 340 deletions(-)

-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/RFT usb-next v1 3/6] usb: host: ehci-platform: remove custom USB PHY handling

2018-01-24 Thread Martin Blumenstingl
The new PHY wrapper is now wired up in the core HCD code. This means
that PHYs are now controlled (initialized, enabled, disabled, exited)
without requiring any host-driver specific code.
Remove the custom USB PHY handling from the ehci-platform driver as the
core HCD code now handles this.

Signed-off-by: Martin Blumenstingl 
---
 drivers/usb/host/ehci-platform.c | 55 +++-
 1 file changed, 4 insertions(+), 51 deletions(-)

diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c
index b065a960adc2..4c306fb6b069 100644
--- a/drivers/usb/host/ehci-platform.c
+++ b/drivers/usb/host/ehci-platform.c
@@ -27,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -44,8 +43,6 @@
 struct ehci_platform_priv {
struct clk *clks[EHCI_MAX_CLKS];
struct reset_control *rsts;
-   struct phy **phys;
-   int num_phys;
bool reset_on_resume;
 };
 
@@ -80,7 +77,7 @@ static int ehci_platform_power_on(struct platform_device *dev)
 {
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
-   int clk, ret, phy_num;
+   int clk, ret;
 
for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) {
ret = clk_prepare_enable(priv->clks[clk]);
@@ -88,24 +85,8 @@ static int ehci_platform_power_on(struct platform_device 
*dev)
goto err_disable_clks;
}
 
-   for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
-   ret = phy_init(priv->phys[phy_num]);
-   if (ret)
-   goto err_exit_phy;
-   ret = phy_power_on(priv->phys[phy_num]);
-   if (ret) {
-   phy_exit(priv->phys[phy_num]);
-   goto err_exit_phy;
-   }
-   }
-
return 0;
 
-err_exit_phy:
-   while (--phy_num >= 0) {
-   phy_power_off(priv->phys[phy_num]);
-   phy_exit(priv->phys[phy_num]);
-   }
 err_disable_clks:
while (--clk >= 0)
clk_disable_unprepare(priv->clks[clk]);
@@ -117,12 +98,7 @@ static void ehci_platform_power_off(struct platform_device 
*dev)
 {
struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd);
-   int clk, phy_num;
-
-   for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
-   phy_power_off(priv->phys[phy_num]);
-   phy_exit(priv->phys[phy_num]);
-   }
+   int clk;
 
for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--)
if (priv->clks[clk])
@@ -149,7 +125,7 @@ static int ehci_platform_probe(struct platform_device *dev)
struct usb_ehci_pdata *pdata = dev_get_platdata(>dev);
struct ehci_platform_priv *priv;
struct ehci_hcd *ehci;
-   int err, irq, phy_num, clk = 0;
+   int err, irq, clk = 0;
 
if (usb_disabled())
return -ENODEV;
@@ -202,29 +178,6 @@ static int ehci_platform_probe(struct platform_device *dev)
  "has-transaction-translator"))
hcd->has_tt = 1;
 
-   priv->num_phys = of_count_phandle_with_args(dev->dev.of_node,
-   "phys", "#phy-cells");
-
-   if (priv->num_phys > 0) {
-   priv->phys = devm_kcalloc(>dev, priv->num_phys,
-   sizeof(struct phy *), GFP_KERNEL);
-   if (!priv->phys)
-   return -ENOMEM;
-   } else
-   priv->num_phys = 0;
-
-   for (phy_num = 0; phy_num < priv->num_phys; phy_num++) {
-   priv->phys[phy_num] = devm_of_phy_get_by_index(
-   >dev, dev->dev.of_node, phy_num);
-   if (IS_ERR(priv->phys[phy_num])) {
-   err = PTR_ERR(priv->phys[phy_num]);
-   goto err_put_hcd;
-   } else if (!hcd->phy) {
-   /* Avoiding phy_get() in usb_add_hcd() */
-   hcd->phy = priv->phys[phy_num];
-   }
-   }
-
for (clk = 0; clk < EHCI_MAX_CLKS; clk++) {
priv->clks[clk] = of_clk_get(dev->dev.of_node, clk);
if (IS_ERR(priv->clks[clk])) {
@@ -306,7 +259,7 @@ static int ehci_platform_probe(struct platform_device *dev)
 err_put_clks:
while (--clk >= 0)
clk_put(priv->clks[clk]);
-err_put_hcd:
+
if (pdata == _platform_defaults)
dev->dev.platform_data = NULL;
 
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to 

[RFC/RFT usb-next v1 1/6] usb: mtu3: remove custom USB PHY handling

2018-01-24 Thread Martin Blumenstingl
The new PHY wrapper is now wired up in the core HCD code. This means
that PHYs are now controlled (initialized, enabled, disabled, exited)
without requiring any host-driver specific code.
Remove the custom USB PHY handling from the mtu3 driver as the core HCD
code now handles this.

Signed-off-by: Martin Blumenstingl 
---
 drivers/usb/mtu3/mtu3_plat.c | 101 ---
 1 file changed, 101 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_plat.c b/drivers/usb/mtu3/mtu3_plat.c
index 628d5ce356ca..a894ddf25bcd 100644
--- a/drivers/usb/mtu3/mtu3_plat.c
+++ b/drivers/usb/mtu3/mtu3_plat.c
@@ -44,62 +44,6 @@ int ssusb_check_clocks(struct ssusb_mtk *ssusb, u32 ex_clks)
return 0;
 }
 
-static int ssusb_phy_init(struct ssusb_mtk *ssusb)
-{
-   int i;
-   int ret;
-
-   for (i = 0; i < ssusb->num_phys; i++) {
-   ret = phy_init(ssusb->phys[i]);
-   if (ret)
-   goto exit_phy;
-   }
-   return 0;
-
-exit_phy:
-   for (; i > 0; i--)
-   phy_exit(ssusb->phys[i - 1]);
-
-   return ret;
-}
-
-static int ssusb_phy_exit(struct ssusb_mtk *ssusb)
-{
-   int i;
-
-   for (i = 0; i < ssusb->num_phys; i++)
-   phy_exit(ssusb->phys[i]);
-
-   return 0;
-}
-
-static int ssusb_phy_power_on(struct ssusb_mtk *ssusb)
-{
-   int i;
-   int ret;
-
-   for (i = 0; i < ssusb->num_phys; i++) {
-   ret = phy_power_on(ssusb->phys[i]);
-   if (ret)
-   goto power_off_phy;
-   }
-   return 0;
-
-power_off_phy:
-   for (; i > 0; i--)
-   phy_power_off(ssusb->phys[i - 1]);
-
-   return ret;
-}
-
-static void ssusb_phy_power_off(struct ssusb_mtk *ssusb)
-{
-   unsigned int i;
-
-   for (i = 0; i < ssusb->num_phys; i++)
-   phy_power_off(ssusb->phys[i]);
-}
-
 static int ssusb_clks_enable(struct ssusb_mtk *ssusb)
 {
int ret;
@@ -162,24 +106,8 @@ static int ssusb_rscs_init(struct ssusb_mtk *ssusb)
if (ret)
goto clks_err;
 
-   ret = ssusb_phy_init(ssusb);
-   if (ret) {
-   dev_err(ssusb->dev, "failed to init phy\n");
-   goto phy_init_err;
-   }
-
-   ret = ssusb_phy_power_on(ssusb);
-   if (ret) {
-   dev_err(ssusb->dev, "failed to power on phy\n");
-   goto phy_err;
-   }
-
return 0;
 
-phy_err:
-   ssusb_phy_exit(ssusb);
-phy_init_err:
-   ssusb_clks_disable(ssusb);
 clks_err:
regulator_disable(ssusb->vusb33);
 vusb33_err:
@@ -190,8 +118,6 @@ static void ssusb_rscs_exit(struct ssusb_mtk *ssusb)
 {
ssusb_clks_disable(ssusb);
regulator_disable(ssusb->vusb33);
-   ssusb_phy_power_off(ssusb);
-   ssusb_phy_exit(ssusb);
 }
 
 static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
@@ -222,7 +148,6 @@ static int get_ssusb_rscs(struct platform_device *pdev, 
struct ssusb_mtk *ssusb)
struct device *dev = >dev;
struct regulator *vbus;
struct resource *res;
-   int i;
int ret;
 
ssusb->vusb33 = devm_regulator_get(>dev, "vusb33");
@@ -249,25 +174,6 @@ static int get_ssusb_rscs(struct platform_device *pdev, 
struct ssusb_mtk *ssusb)
if (IS_ERR(ssusb->dma_clk))
return PTR_ERR(ssusb->dma_clk);
 
-   ssusb->num_phys = of_count_phandle_with_args(node,
-   "phys", "#phy-cells");
-   if (ssusb->num_phys > 0) {
-   ssusb->phys = devm_kcalloc(dev, ssusb->num_phys,
-   sizeof(*ssusb->phys), GFP_KERNEL);
-   if (!ssusb->phys)
-   return -ENOMEM;
-   } else {
-   ssusb->num_phys = 0;
-   }
-
-   for (i = 0; i < ssusb->num_phys; i++) {
-   ssusb->phys[i] = devm_of_phy_get_by_index(dev, node, i);
-   if (IS_ERR(ssusb->phys[i])) {
-   dev_err(dev, "failed to get phy-%d\n", i);
-   return PTR_ERR(ssusb->phys[i]);
-   }
-   }
-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ippc");
ssusb->ippc_base = devm_ioremap_resource(dev, res);
if (IS_ERR(ssusb->ippc_base))
@@ -457,7 +363,6 @@ static int __maybe_unused mtu3_suspend(struct device *dev)
return 0;
 
ssusb_host_disable(ssusb, true);
-   ssusb_phy_power_off(ssusb);
ssusb_clks_disable(ssusb);
ssusb_wakeup_set(ssusb, true);
 
@@ -480,16 +385,10 @@ static int __maybe_unused mtu3_resume(struct device *dev)
if (ret)
goto clks_err;
 
-   ret = ssusb_phy_power_on(ssusb);
-   if (ret)
-   goto phy_err;
-
ssusb_host_enable(ssusb);
 
return 0;
 
-phy_err:
-   ssusb_clks_disable(ssusb);
 clks_err:
return ret;
 }
-- 
2.16.1

--
To unsubscribe from this list: send the line 

[RFC/RFT usb-next v1 2/6] usb: host: xhci-mtk: remove custom USB PHY handling

2018-01-24 Thread Martin Blumenstingl
The new PHY wrapper is now wired up in the core HCD code. This means
that PHYs are now controlled (initialized, enabled, disabled, exited)
without requiring any host-driver specific code.
Remove the custom USB PHY handling from the xhci-mtk driver as the core
HCD code now handles this.

Signed-off-by: Martin Blumenstingl 
---
 drivers/usb/host/xhci-mtk.c | 98 +
 1 file changed, 2 insertions(+), 96 deletions(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index b0ab4d5e2751..7334da9e9779 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -352,62 +351,6 @@ static const struct xhci_driver_overrides 
xhci_mtk_overrides __initconst = {
 
 static struct hc_driver __read_mostly xhci_mtk_hc_driver;
 
-static int xhci_mtk_phy_init(struct xhci_hcd_mtk *mtk)
-{
-   int i;
-   int ret;
-
-   for (i = 0; i < mtk->num_phys; i++) {
-   ret = phy_init(mtk->phys[i]);
-   if (ret)
-   goto exit_phy;
-   }
-   return 0;
-
-exit_phy:
-   for (; i > 0; i--)
-   phy_exit(mtk->phys[i - 1]);
-
-   return ret;
-}
-
-static int xhci_mtk_phy_exit(struct xhci_hcd_mtk *mtk)
-{
-   int i;
-
-   for (i = 0; i < mtk->num_phys; i++)
-   phy_exit(mtk->phys[i]);
-
-   return 0;
-}
-
-static int xhci_mtk_phy_power_on(struct xhci_hcd_mtk *mtk)
-{
-   int i;
-   int ret;
-
-   for (i = 0; i < mtk->num_phys; i++) {
-   ret = phy_power_on(mtk->phys[i]);
-   if (ret)
-   goto power_off_phy;
-   }
-   return 0;
-
-power_off_phy:
-   for (; i > 0; i--)
-   phy_power_off(mtk->phys[i - 1]);
-
-   return ret;
-}
-
-static void xhci_mtk_phy_power_off(struct xhci_hcd_mtk *mtk)
-{
-   unsigned int i;
-
-   for (i = 0; i < mtk->num_phys; i++)
-   phy_power_off(mtk->phys[i]);
-}
-
 static int xhci_mtk_ldos_enable(struct xhci_hcd_mtk *mtk)
 {
int ret;
@@ -488,8 +431,6 @@ static int xhci_mtk_probe(struct platform_device *pdev)
struct xhci_hcd *xhci;
struct resource *res;
struct usb_hcd *hcd;
-   struct phy *phy;
-   int phy_num;
int ret = -ENODEV;
int irq;
 
@@ -529,16 +470,6 @@ static int xhci_mtk_probe(struct platform_device *pdev)
return ret;
}
 
-   mtk->num_phys = of_count_phandle_with_args(node,
-   "phys", "#phy-cells");
-   if (mtk->num_phys > 0) {
-   mtk->phys = devm_kcalloc(dev, mtk->num_phys,
-   sizeof(*mtk->phys), GFP_KERNEL);
-   if (!mtk->phys)
-   return -ENOMEM;
-   } else {
-   mtk->num_phys = 0;
-   }
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
device_enable_async_suspend(dev);
@@ -596,23 +527,6 @@ static int xhci_mtk_probe(struct platform_device *pdev)
mtk->has_ippc = false;
}
 
-   for (phy_num = 0; phy_num < mtk->num_phys; phy_num++) {
-   phy = devm_of_phy_get_by_index(dev, node, phy_num);
-   if (IS_ERR(phy)) {
-   ret = PTR_ERR(phy);
-   goto put_usb2_hcd;
-   }
-   mtk->phys[phy_num] = phy;
-   }
-
-   ret = xhci_mtk_phy_init(mtk);
-   if (ret)
-   goto put_usb2_hcd;
-
-   ret = xhci_mtk_phy_power_on(mtk);
-   if (ret)
-   goto exit_phys;
-
device_init_wakeup(dev, true);
 
xhci = hcd_to_xhci(hcd);
@@ -630,7 +544,7 @@ static int xhci_mtk_probe(struct platform_device *pdev)
dev_name(dev), hcd);
if (!xhci->shared_hcd) {
ret = -ENOMEM;
-   goto power_off_phys;
+   goto disable_device_wakeup;
}
 
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
@@ -653,13 +567,9 @@ static int xhci_mtk_probe(struct platform_device *pdev)
xhci_mtk_sch_exit(mtk);
usb_put_hcd(xhci->shared_hcd);
 
-power_off_phys:
-   xhci_mtk_phy_power_off(mtk);
+disable_device_wakeup:
device_init_wakeup(dev, false);
 
-exit_phys:
-   xhci_mtk_phy_exit(mtk);
-
 put_usb2_hcd:
usb_put_hcd(hcd);
 
@@ -682,8 +592,6 @@ static int xhci_mtk_remove(struct platform_device *dev)
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
usb_remove_hcd(xhci->shared_hcd);
-   xhci_mtk_phy_power_off(mtk);
-   xhci_mtk_phy_exit(mtk);
device_init_wakeup(>dev, false);
 
usb_remove_hcd(hcd);
@@ -718,7 +626,6 @@ static int __maybe_unused xhci_mtk_suspend(struct device 
*dev)
del_timer_sync(>shared_hcd->rh_timer);
 
xhci_mtk_host_disable(mtk);
-   xhci_mtk_phy_power_off(mtk);

[RFC usb-next v8 3/3] usb: core: hcd: integrate the PHY wrapper into the HCD core

2018-01-24 Thread Martin Blumenstingl
This integrates the PHY wrapper into the core hcd infrastructure.
Multiple PHYs which are part of the HCD's device tree node are now
managed (= powered on/off when needed), by the new usb_phy_roothub code.

Suspend and resume is also supported, however not for
runtime/auto-suspend (which is triggered for example when no devices are
connected to the USB bus). This is needed on some SoCs (for example
Amlogic Meson GXL) because if the PHYs are disabled during auto-suspend
then devices which are plugged in afterwards are not seen by the host.

One example where this is required is the Amlogic GXL and GXM SoCs:
They are using a dwc3 USB controller with up to three ports enabled on
the internal roothub. Each port has it's own PHY which must be enabled
(if one of the PHYs is left disabled then none of the USB ports works at
all).
The new logic works on the Amlogic GXL and GXM SoCs because the dwc3
driver internally creates a xhci-hcd which then registers a HCD which
then triggers our new PHY wrapper.

Signed-off-by: Martin Blumenstingl 
Acked-by: Alan Stern 
Acked-by: Chunfeng Yun 
---
 drivers/usb/core/hcd.c  | 29 +
 include/linux/usb/hcd.h |  1 +
 2 files changed, 30 insertions(+)

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index fc32391a34d5..fc99cddc117e 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -37,6 +37,7 @@
 #include 
 
 #include "usb.h"
+#include "phy.h"
 
 
 /*-*/
@@ -2260,6 +2261,9 @@ int hcd_bus_suspend(struct usb_device *rhdev, 
pm_message_t msg)
usb_set_device_state(rhdev, USB_STATE_SUSPENDED);
hcd->state = HC_STATE_SUSPENDED;
 
+   if (!PMSG_IS_AUTO(msg))
+   usb_phy_roothub_power_off(hcd->phy_roothub);
+
/* Did we race with a root-hub wakeup event? */
if (rhdev->do_remote_wakeup) {
charbuffer[6];
@@ -2296,6 +2300,13 @@ int hcd_bus_resume(struct usb_device *rhdev, 
pm_message_t msg)
dev_dbg(>dev, "skipped %s of dead bus\n", "resume");
return 0;
}
+
+   if (!PMSG_IS_AUTO(msg)) {
+   status = usb_phy_roothub_power_on(hcd->phy_roothub);
+   if (status)
+   return status;
+   }
+
if (!hcd->driver->bus_resume)
return -ENOENT;
if (HCD_RH_RUNNING(hcd))
@@ -2333,6 +2344,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t 
msg)
}
} else {
hcd->state = old_state;
+   usb_phy_roothub_power_off(hcd->phy_roothub);
dev_dbg(>dev, "bus %s fail, err %d\n",
"resume", status);
if (status != -ESHUTDOWN)
@@ -2769,6 +2781,16 @@ int usb_add_hcd(struct usb_hcd *hcd,
}
}
 
+   hcd->phy_roothub = usb_phy_roothub_init(hcd->self.sysdev);
+   if (IS_ERR(hcd->phy_roothub)) {
+   retval = PTR_ERR(hcd->phy_roothub);
+   goto err_phy_roothub_init;
+   }
+
+   retval = usb_phy_roothub_power_on(hcd->phy_roothub);
+   if (retval)
+   goto err_usb_phy_roothub_power_on;
+
dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
 
/* Keep old behaviour if authorized_default is not in [0, 1]. */
@@ -2933,6 +2955,10 @@ int usb_add_hcd(struct usb_hcd *hcd,
 err_register_bus:
hcd_buffer_destroy(hcd);
 err_create_buf:
+   usb_phy_roothub_power_off(hcd->phy_roothub);
+err_usb_phy_roothub_power_on:
+   usb_phy_roothub_exit(hcd->phy_roothub);
+err_phy_roothub_init:
if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
phy_power_off(hcd->phy);
phy_exit(hcd->phy);
@@ -3017,6 +3043,9 @@ void usb_remove_hcd(struct usb_hcd *hcd)
usb_deregister_bus(>self);
hcd_buffer_destroy(hcd);
 
+   usb_phy_roothub_power_off(hcd->phy_roothub);
+   usb_phy_roothub_exit(hcd->phy_roothub);
+
if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
phy_power_off(hcd->phy);
phy_exit(hcd->phy);
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index 176900528822..9e8fc9c5f394 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -104,6 +104,7 @@ struct usb_hcd {
 */
struct usb_phy  *usb_phy;
struct phy  *phy;
+   struct usb_phy_roothub  *phy_roothub;
 
/* Flags that need to be manipulated atomically because they can
 * change while the host controller is running.  Always use
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  

[RFC usb-next v8 0/3] initialize (multiple) PHYs for a HCD

2018-01-24 Thread Martin Blumenstingl
The goal of this series is to initialize multiple PHYs on a USB host
controller, which is needed on Amlogic Meson GXL and GXM SoCs.
- Amlogic Meson GXL and GXM SoCs come with a dwc3 IP block which has two
  or three USB2 ports enabled on the internal root-hub. The SoCs also
  provide separate USB2 PHYs, one per port. All USB2 PHYs (which are
  internally "connected" to the dwc3 roothub) need to be powered on,
  otherwise USB devices cannot be enumerated (even if just one PHY is
  disabled and if the device is plugged into another, enabled port)
- dwc3 already takes one USB2 and one USB3 PHY and initializes these
  correctly
- some other HCI platform drivers (like ehci-platform.c, xhci-mtk.c and
  ohci-platform.c) do not have a limitation on the number of PHYs - they
  support any number of USB PHYs (typically one PHY per actual port)

This series adds a new "PHY wrapper". This can be configured through
devicetree by passing a "phys" property (with any number of PHY handles)
to the USB controller.
Additionally it this integrates this new PHY wrapper into hcd.c which
automatically enables it for all USB controller drivers (tested on an
Amlogic Meson GXL SoC which uses a dwc3 controller).

Changes since v7 at [8]:
- updated the description in the cover-letter
- wrapped the only call usb_phy_roothub_power_{on,off} in
  hcd_bus_{resume,suspend} during system-suspend (excluding it from
  being called during runtime/auto suspend). this also fixes a problem
  on Meson GXL which does not detect that a new device has been
  connected if the PHYs are powered off. Thanks to Manu Gautam for
  suggesting this! (affects patch #3)
- after a discussion about the dt-bindings of this patch I went back to
  simply specifying a "phys" property (without a corresponding phy-names
  property) to pass all PHYs directly in the node of the USB controller.
  From my understanding the root hub node was "artificial" and we should
  describe it's properties as part of the controller, rather than
  introducing a sub-node. see also the discussion with Arnd in [9]
  (this affects patch #1 and #2)
- dropped patch #4 ("dt-bindings: usb: xhci: include the roothub and a
  device in the example") because we're back to just specifying a "phys"
  property directly within the controller.
  NOTE: some HCI platform drivers are using the "phys" property as well.
  With this series phy_{init,power_on,power_off,exit} will be called
  twice for each PHY when using a ehci-platform.c or xhci-mtk.c USB
  controller (because the controller driver and our new, generic code
  now manage the PHYs). the PHY framework handles this gracefully (by
  ref-counting all operations). a follow-up series will be sent which
  removes the custom handling from the affected drivers (so only the
  new PHY wrapper will manage the PHYs state after that follow-up
  series).
- fixed an unnecessary whitespace change spotted by Alan Stern (thanks!)
  in patch #3
- removed all Tested-by's since we're changing code again

Changes since v6 at [6]:
- fixed unnecessary whitespace change (noticed by Alan Stern - thanks)
- added PATCH #4 to clarify (with an example) how I understood how Rob
  wanted the dt-binding to look like (see [0]). please wait for an ACK
  from Rob on this one to make sure that we're not introducing some
  broken binding (as discussed with Arnd: [7])
- added Alan Stern's ACK on PATCH #3
- added Neil's Tested-by on PATCH #2 and #3

Changes since RfC v5 at [5]:
- dropped RfC prefix
- removed noisy dev_err if no roothub node was found (spotted by
  Xiaolong Ye's kbuild test robot - thank you for that!)
- moved the call to usb_phy_roothub_power_off() within
  hcd_bus_suspend() to make sure that the PHYs are turned off
  if the "race with a root-hub wakeup event" condition is met (in
  this case the PHYs are turned on again, with the old code we did
  break the PHYs internal ref-counting because we never turned the
  PHYs off before turning them on again in case of that special
  "race with a root-hub wakeup event").
  additionally we're not handling the status returned by
  usb_phy_roothub_power_off() anymore (the bus is already turned off
  and we tried to turn off all PHYs as well - only the PHYs which
  failed to power off will stay in the current state).
  thanks to Alan Stern for the suggestion
- removed return value from usb_phy_roothub_power_off() because none
  of my code uses it anymore. thanks to Alan Stern for the suggestion

Changes since v4 at [4]:
- renamed the subject of the cover-letter (old name was:
  "initialize (multiple) PHYs in xhci-plat")
- back into RFC status (see below for the reasons)
- dropped Tested-by from Chunfeng Yun (same reasons as RFC status)
- reworded cover-letter and commit messages from "platform-roothub"
  to "roothub PHY wrapper"
- moved code from drivers/usb/host/platform-roothub.* to
  drivers/usb/core/phy.* and the changes to
  drivers/usb/host/xhci-plat.c to drivers/usb/core/hcd.c as suggested
  by Mathias Nyman (as a 

[RFC usb-next v8 1/3] dt-bindings: usb: add the documentation for USB HCDs

2018-01-24 Thread Martin Blumenstingl
A USB HCD may have several PHYs which need to be configured before the
the HCD starts working.
This adds the documentation for such a USB HCD as well as a reference to
the new "usb-hcd.txt" from all bindings that implement a USB HCD which
support one USB PHY per port.

Signed-off-by: Martin Blumenstingl 
---
 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt | 5 -
 Documentation/devicetree/bindings/usb/mediatek,mtu3.txt | 5 -
 Documentation/devicetree/bindings/usb/usb-ehci.txt  | 6 --
 Documentation/devicetree/bindings/usb/usb-hcd.txt   | 9 +
 Documentation/devicetree/bindings/usb/usb-ohci.txt  | 6 --
 Documentation/devicetree/bindings/usb/usb-uhci.txt  | 3 +++
 Documentation/devicetree/bindings/usb/usb-xhci.txt  | 5 +
 7 files changed, 33 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/usb/usb-hcd.txt

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt 
b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
index 88d9f4a4b280..266c2d917a28 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
@@ -32,7 +32,7 @@ Required properties:
"mcu_ck": mcu_bus clock for register access,
"dma_ck": dma_bus clock for data transfer by DMA
 
- - phys : a list of phandle + phy specifier pairs
+ - phys : see usb-hcd.txt in the current directory
 
 Optional properties:
  - wakeup-source : enable USB remote wakeup;
@@ -52,6 +52,9 @@ Optional properties:
See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
  - imod-interval-ns: default interrupt moderation interval is 5000ns
 
+additionally the properties from usb-hcd.txt (in the current directory) are
+supported.
+
 Example:
 usb30: usb@1127 {
compatible = "mediatek,mt8173-xhci";
diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt 
b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
index d589a1ef96a1..3382b5cb471d 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
@@ -17,7 +17,7 @@ Required properties:
  - clock-names : must contain "sys_ck" for clock of controller,
the following clocks are optional:
"ref_ck", "mcu_ck" and "dam_ck";
- - phys : a list of phandle + phy specifier pairs
+ - phys : see usb-hcd.txt in the current directory
  - dr_mode : should be one of "host", "peripheral" or "otg",
refer to usb/generic.txt
 
@@ -53,6 +53,9 @@ Optional properties:
  - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
bit1 for u3port1, ... etc;
 
+additionally the properties from usb-hcd.txt (in the current directory) are
+supported.
+
 Sub-nodes:
 The xhci should be added as subnode to mtu3 as shown in the following example
 if host mode is enabled. The DT binding details of xhci can be found in:
diff --git a/Documentation/devicetree/bindings/usb/usb-ehci.txt 
b/Documentation/devicetree/bindings/usb/usb-ehci.txt
index 3efde12b5d68..0f1b75386207 100644
--- a/Documentation/devicetree/bindings/usb/usb-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-ehci.txt
@@ -16,10 +16,12 @@ Optional properties:
  - has-transaction-translator : boolean, set this if EHCI have a Transaction
Translator built into the root hub.
  - clocks : a list of phandle + clock specifier pairs
- - phys : phandle + phy specifier pair
- - phy-names : "usb"
+ - phys : see usb-hcd.txt in the current directory
  - resets : phandle + reset specifier pair
 
+additionally the properties from usb-hcd.txt (in the current directory) are
+supported.
+
 Example (Sequoia 440EPx):
 ehci@e300 {
   compatible = "ibm,usb-ehci-440epx", "usb-ehci";
diff --git a/Documentation/devicetree/bindings/usb/usb-hcd.txt 
b/Documentation/devicetree/bindings/usb/usb-hcd.txt
new file mode 100644
index ..50529b838c9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/usb/usb-hcd.txt
@@ -0,0 +1,9 @@
+Generic USB HCD (Host Controller Device) Properties
+
+Optional properties:
+- phys: a list of all USB PHYs on this HCD
+
+Example:
+{
+   phys = <_phy1>, <_phy1>;
+   };
diff --git a/Documentation/devicetree/bindings/usb/usb-ohci.txt 
b/Documentation/devicetree/bindings/usb/usb-ohci.txt
index 09e70c875bc6..a8d2103d1f3d 100644
--- a/Documentation/devicetree/bindings/usb/usb-ohci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-ohci.txt
@@ -13,10 +13,12 @@ Optional properties:
 - remote-wakeup-connected: remote wakeup is wired on the platform
 - num-ports : u32, to override the detected port count
 - clocks : a list of phandle + clock specifier pairs
-- phys : phandle + phy specifier pair
-- phy-names : "usb"
+- phys : see usb-hcd.txt in the current directory
 - resets : a list of phandle + 

[RFC usb-next v8 2/3] usb: core: add a wrapper for the USB PHYs on the HCD

2018-01-24 Thread Martin Blumenstingl
Many SoC platforms have separate devices for the USB PHY which are
registered through the generic PHY framework. These PHYs have to be
enabled to make the USB controller actually work. They also have to be
disabled again on shutdown/suspend.

Currently (at least) the following HCI platform drivers are using custom
code to obtain all PHYs via devicetree for the roothub/controller and
disable/enable them when required:
- ehci-platform.c has ehci_platform_power_{on,off}
- xhci-mtk.c has xhci_mtk_phy_{init,exit,power_on,power_off}
- ohci-platform.c has ohci_platform_power_{on,off}

With this new wrapper the USB PHYs can be specified directly in the
USB controller's devicetree node (just like on the drivers listed
above). This allows SoCs like the Amlogic Meson GXL family to operate
correctly once this is wired up correctly. These SoCs use a dwc3
controller and require all USB PHYs to be initialized (if one of the USB
PHYs it not initialized then none of USB port works at all).

Signed-off-by: Martin Blumenstingl 
Cc: Neil Armstrong 
Cc: Chunfeng Yun 
---
 drivers/usb/core/Makefile |   2 +-
 drivers/usb/core/phy.c| 158 ++
 drivers/usb/core/phy.h|   7 ++
 3 files changed, 166 insertions(+), 1 deletion(-)
 create mode 100644 drivers/usb/core/phy.c
 create mode 100644 drivers/usb/core/phy.h

diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index 92c9cefb4317..18e874b0441e 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -6,7 +6,7 @@
 usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o
 usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o
 usbcore-y += devio.o notify.o generic.o quirks.o devices.o
-usbcore-y += port.o
+usbcore-y += phy.o port.o
 
 usbcore-$(CONFIG_OF)   += of.o
 usbcore-$(CONFIG_USB_PCI)  += hcd-pci.o
diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c
new file mode 100644
index ..09b7c43c0ea4
--- /dev/null
+++ b/drivers/usb/core/phy.c
@@ -0,0 +1,158 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * A wrapper for multiple PHYs which passes all phy_* function calls to
+ * multiple (actual) PHY devices. This is comes handy when initializing
+ * all PHYs on a HCD and to keep them all in the same state.
+ *
+ * Copyright (C) 2018 Martin Blumenstingl 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "phy.h"
+
+struct usb_phy_roothub {
+   struct phy  *phy;
+   struct list_headlist;
+};
+
+static struct usb_phy_roothub *usb_phy_roothub_alloc(struct device *dev)
+{
+   struct usb_phy_roothub *roothub_entry;
+
+   roothub_entry = devm_kzalloc(dev, sizeof(*roothub_entry), GFP_KERNEL);
+   if (!roothub_entry)
+   return ERR_PTR(-ENOMEM);
+
+   INIT_LIST_HEAD(_entry->list);
+
+   return roothub_entry;
+}
+
+static int usb_phy_roothub_add_phy(struct device *dev, int index,
+  struct list_head *list)
+{
+   struct usb_phy_roothub *roothub_entry;
+   struct phy *phy = devm_of_phy_get_by_index(dev, dev->of_node, index);
+
+   if (IS_ERR_OR_NULL(phy)) {
+   if (!phy || PTR_ERR(phy) == -ENODEV)
+   return 0;
+   else
+   return PTR_ERR(phy);
+   }
+
+   roothub_entry = usb_phy_roothub_alloc(dev);
+   if (IS_ERR(roothub_entry))
+   return PTR_ERR(roothub_entry);
+
+   roothub_entry->phy = phy;
+
+   list_add_tail(_entry->list, list);
+
+   return 0;
+}
+
+struct usb_phy_roothub *usb_phy_roothub_init(struct device *dev)
+{
+   struct usb_phy_roothub *phy_roothub;
+   struct usb_phy_roothub *roothub_entry;
+   struct list_head *head;
+   int i, num_phys, err;
+
+   num_phys = of_count_phandle_with_args(dev->of_node, "phys",
+ "#phy-cells");
+   if (num_phys <= 0)
+   return NULL;
+
+   phy_roothub = usb_phy_roothub_alloc(dev);
+   if (IS_ERR(phy_roothub))
+   return phy_roothub;
+
+   for (i = 0; i < num_phys; i++) {
+   err = usb_phy_roothub_add_phy(dev, i, _roothub->list);
+   if (err)
+   goto err_out;
+   }
+
+   head = _roothub->list;
+
+   list_for_each_entry(roothub_entry, head, list) {
+   err = phy_init(roothub_entry->phy);
+   if (err)
+   goto err_exit_phys;
+   }
+
+   return phy_roothub;
+
+err_exit_phys:
+   list_for_each_entry_continue_reverse(roothub_entry, head, list)
+   phy_exit(roothub_entry->phy);
+
+err_out:
+   return ERR_PTR(err);
+}
+EXPORT_SYMBOL_GPL(usb_phy_roothub_init);
+
+int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub)
+{
+   struct usb_phy_roothub *roothub_entry;
+  

Re: [PATCH v3 2/2] usb/gadget: Add driver for Aspeed SoC virtual hub (fwd)

2018-01-24 Thread Benjamin Herrenschmidt
On Wed, 2018-01-24 at 11:38 +0100, Julia Lawall wrote:
> Hello,
> 
> I can't tell from looking at the code whether the missing unlock when
> !d->wakeup_en is intentional.

It's a bug. I'll fix it. Thanks.

> It may also be worth checking the report on line 359 about the comparison
> with the unsigned value.

Ah right, fixed that too.

Thanks !

Ben.
> 

> julia
> 
> -- Forwarded message --
> Date: Wed, 24 Jan 2018 09:09:59 +0800
> From: kbuild test robot <fengguang...@intel.com>
> To: kbu...@01.org
> Cc: Julia Lawall <julia.law...@lip6.fr>
> Subject: Re: [PATCH v3 2/2] usb/gadget: Add driver for Aspeed SoC virtual hub
> 
> CC: kbuild-...@01.org
> In-Reply-To: <2018012716.7039-2-b...@kernel.crashing.org>
> References: <2018012716.7039-2-b...@kernel.crashing.org>
> TO: Benjamin Herrenschmidt <b...@kernel.crashing.org>
> CC: linux-usb@vger.kernel.org
> CC: Greg KH <g...@kroah.com>, Joel Stanley <joel.stan...@au1.ibm.com>, Andrew 
> Jeffery <and...@aj.id.au>, Felipe Balbi <ba...@kernel.org>, Benjamin 
> Herrenschmidt <b...@kernel.crashing.org>
> 
> Hi Benjamin,
> 
> I love your patch! Perhaps something to improve:
> 
> [auto build test WARNING on balbi-usb/next]
> [also build test WARNING on v4.15-rc9 next-20180119]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Benjamin-Herrenschmidt/usb-gadget-Add-an-EP-dispose-callback-for-EP-lifetime-tracking/20180124-065635
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
> :: branch date: 2 hours ago
> :: commit date: 2 hours ago
> 
> > > drivers/usb/gadget/udc/aspeed-vhub/dev.c:269:1-7: preceding lock on line 
> > > 257
> 
> --
> > > drivers/usb/gadget/udc/aspeed-vhub/core.c:359:5-14: WARNING: Unsigned 
> > > expression compared with zero: vhub -> irq < 0
> 
> # 
> https://github.com/0day-ci/linux/commit/7d6ae8cb6c74a0113a1d122c34158d782d0edb59
> git remote add linux-review https://github.com/0day-ci/linux
> git remote update linux-review
> git checkout 7d6ae8cb6c74a0113a1d122c34158d782d0edb59
> vim +269 drivers/usb/gadget/udc/aspeed-vhub/dev.c
> 
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  250
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  251  static int 
> ast_vhub_udc_wakeup(struct usb_gadget* gadget)
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  252  {
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  253   struct ast_vhub_dev *d 
> = to_ast_dev(gadget);
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  254   unsigned long flags;
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  255   int rc = -EINVAL;
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  256
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23 @257   
> spin_lock_irqsave(>vhub->lock, flags);
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  258   if (!d->wakeup_en)
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  259   goto err;
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  260
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  261   DDBG(d, "Device 
> initiated wakeup\n");
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  262
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  263   /* Wakeup the host */
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  264   
> ast_vhub_hub_wake_all(d->vhub);
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  265
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  266   
> spin_unlock_irqrestore(>vhub->lock, flags);
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  267   rc = 0;
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  268   err:
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23 @269   return rc;
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  270  }
> 7d6ae8cb Benjamin Herrenschmidt 2018-01-23  271
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] usb: chipidea: imx: Cleanup ci_hdrc_imx_platform_flag

2018-01-24 Thread Sebastian Reichel
Some trivial cleanups, that do not change functionality.

Signed-off-by: Sebastian Reichel 
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index 3b45c25f296e..de155c80eb70 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -20,7 +20,6 @@
 
 struct ci_hdrc_imx_platform_flag {
unsigned int flags;
-   bool runtime_pm;
 };
 
 static const struct ci_hdrc_imx_platform_flag imx23_usb_data = {
@@ -29,7 +28,7 @@ static const struct ci_hdrc_imx_platform_flag imx23_usb_data 
= {
 };
 
 static const struct ci_hdrc_imx_platform_flag imx27_usb_data = {
-   CI_HDRC_DISABLE_STREAMING,
+   .flags = CI_HDRC_DISABLE_STREAMING,
 };
 
 static const struct ci_hdrc_imx_platform_flag imx28_usb_data = {
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] usb: chipidea: imx: Fix ULPI on imx53

2018-01-24 Thread Sebastian Reichel
Traditionally, PORTSC should be set before initializing ULPI phys. But
setting PORTSC before powering on the phy results in a kernel freeze
on imx53 based GE PPD. As a workaround this initializes the phy early
in the imx platform code and disables phy power management from the
core.

Signed-off-by: Fabien Lahoudere 
Signed-off-by: Sebastian Reichel 
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c 
b/drivers/usb/chipidea/ci_hdrc_imx.c
index de155c80eb70..e431c5aafe35 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -83,6 +83,7 @@ struct ci_hdrc_imx_data {
struct clk *clk;
struct imx_usbmisc_data *usbmisc_data;
bool supports_runtime_pm;
+   bool override_phy_control;
bool in_lpm;
/* SoC before i.mx6 (except imx23/imx28) needs three clks */
bool need_three_clks;
@@ -254,6 +255,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
int ret;
const struct of_device_id *of_id;
const struct ci_hdrc_imx_platform_flag *imx_platform_flag;
+   struct device_node *np = pdev->dev.of_node;
 
of_id = of_match_device(ci_hdrc_imx_dt_ids, >dev);
if (!of_id)
@@ -288,6 +290,14 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
}
 
pdata.usb_phy = data->phy;
+
+   if (of_device_is_compatible(np, "fsl,imx53-usb") && pdata.usb_phy &&
+   of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI) {
+   pdata.flags |= CI_HDRC_OVERRIDE_PHY_CONTROL;
+   data->override_phy_control = true;
+   usb_phy_init(pdata.usb_phy);
+   }
+
pdata.flags |= imx_platform_flag->flags;
if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM)
data->supports_runtime_pm = true;
@@ -341,6 +351,8 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev)
pm_runtime_put_noidle(>dev);
}
ci_hdrc_remove_device(data->ci_pdev);
+   if (data->override_phy_control)
+   usb_phy_shutdown(data->phy);
imx_disable_unprepare_clks(>dev);
 
return 0;
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Benoît Thébaudeau
Hi,

On 24/01/2018 at 17:17, Michael Nazzareno Trimarchi wrote:
> On Wed, Jan 24, 2018 at 5:03 PM, Benoît Thébaudeau  wrote:
>> On 24/01/2018 at 16:43, Michael Nazzareno Trimarchi wrote:
>>> On Wed, Jan 24, 2018 at 4:39 PM, Benoît Thébaudeau  
>>> wrote:
 On 24/01/2018 at 16:34, Benoît Thébaudeau wrote:
> On 24/01/2018 at 16:26, Michael Nazzareno Trimarchi wrote:
>> On Wed, Jan 24, 2018 at 4:14 PM, Fabio Estevam  
>> wrote:
>>> On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
>>>  wrote:
 SION bit should be used in the situation that we need
 to read back the value of a pin and should be set by
 default.
>
> You remove this bit because it should be set by default? This sentence is
> confusing.
>>>
>>> English is wrong ;)
>>>
>>> SION bit as a specific purpose to read back value that is set in
>>> output. You don't need
>>> and it's not set in any freescale board. If you need to set you need
>>> to add to your peripheral.
>>
>> Unless there is a NEW_PAD_CTRL()-like mechanism for SION, all these 
>> definitions
>> should be kept in iomux-mx25.h in order not to redefine the register offsets
>> everywhere. AFAIK, all the Freescale boards use the definitions from
>> iomux-mx25.h too.
>>
>>> The only case you need maybe is the data[0] of sdcard.
>>
>> And eSDHC CMD, and I²C probably too. Yet, you are also removing SION in these
>> cases. I have 3 i.M25-based boards working fine with SION. ;) Can you explain
>> the precise issue that you are trying to fix (which pin)?
>>
> 
> Let me summarize for you:
> - was having a board with linux 2.6.x and uboot from 2009 working fine
> on a usb pen driver (look on thread in linux-usb)
> - was having the same board with any version of linux from 3.18 to
> 4.15 and fail with this pen drive
> - check back all the changes from linux 2.6.x  to linux 4.15.x and
> compare every single register and all the usb code and was just
> confirm a better implementation of new kernel.
>   but with a result of a usb stuck on the host port
> - swap the boot-loader and having a working board
> - go in deep in boot-loader and compare everything
> - Understand the difference was the SION bit that was enable on all the mux
> 
> In general when a board start from reset it has default pin muxing.
> Each peripheral need to setup the pin muxing according to the real
> usage.
> SION by default is not the right way to do it. What is the concept of
> working board in your side? Just pass your testcase? Ok even this
> board
> was passing all test cases apart this usb pen drive. We was having in
> the field some customer with usb issue time to time and only this
> proof that somenthing was not real ok.

Thanks for these details. All the test cases should of course work. I'm just
trying to figure out the root cause of your issue, and maybe it's not SION
itself but a power issue triggered by SION, or maybe it's SION only for some
specific pads and not for all the pads, or something else. So what I'm saying is
that this change might be too large, and care should be taken.

Some Freescale boards actually do use SION. E.g., see
MX25_PAD_FEC_MDIO__FEC_MDIO in
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/imx25-pdk.dts?h=v4.15-rc9
 . SION is required to read back the actual state of a GPIO
in output mode. It is also required for some bidirectional alternate functions
(such as I²C SDA/SCL, SD CMD/DATn, etc.) on some i.MXs (not all i.MXs behave in
the same way for the same peripheral), but which ones are affected is not always
documented, so please double check and test all these cases.

Best regards,
Benoît
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Michael Nazzareno Trimarchi
Hi Fabio

On Wed, Jan 24, 2018 at 4:26 PM, Michael Nazzareno Trimarchi
 wrote:
> Hi Fabio
>
> On Wed, Jan 24, 2018 at 4:14 PM, Fabio Estevam  wrote:
>> Hi Michael,
>>

Can you check where SION bit is mandatory for mx25? I have on IMX51
some PINMUX where sion is enabled.
I can clean up a bit the patch to just minimize the change. We have for example:

arch/arm/include/asm/arch-mx5/iomux-mx51.h: MX51_PAD_SD1_CMD__SD1_CMD
= IOMUX_PAD(0x79c, 0x394, 0x10, __NA_, 0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h: MX51_PAD_SD1_CLK__SD1_CLK
= IOMUX_PAD(0x7a0, 0x398, 0x10, __NA_, 0, MX51_SDHCI_PAD_CTRL |
PAD_CTL_HYS),
arch/arm/include/asm/arch-mx5/iomux-mx51.h:
MX51_PAD_SD1_DATA0__SD1_DATA0 = IOMUX_PAD(0x7a4, 0x39c, 0x10, __NA_,
0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h:
MX51_PAD_SD1_DATA1__SD1_DATA1 = IOMUX_PAD(0x7a8, 0x3a0, 0x10, __NA_,
0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h:
MX51_PAD_SD1_DATA2__SD1_DATA2 = IOMUX_PAD(0x7ac, 0x3a4, 0x10, __NA_,
0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h:
MX51_PAD_SD1_DATA3__SD1_DATA3 = IOMUX_PAD(0x7b0, 0x3a8, 0x10, __NA_,
0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h: MX51_PAD_SD2_CMD__SD2_CMD
= IOMUX_PAD(0x7bc, 0x3b4, 0x10, __NA_, 0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h: MX51_PAD_SD2_CLK__SD2_CLK
= IOMUX_PAD(0x7c0, 0x3b8, 0x10, __NA_, 0, MX51_SDHCI_PAD_CTRL |
PAD_CTL_HYS),
arch/arm/include/asm/arch-mx5/iomux-mx51.h:
MX51_PAD_SD2_DATA0__SD2_DATA0 = IOMUX_PAD(0x7c4, 0x3bc, 0x10, __NA_,
0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h:
MX51_PAD_SD2_DATA1__SD2_DATA1 = IOMUX_PAD(0x7c8, 0x3c0, 0x10, __NA_,
0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h:
MX51_PAD_SD2_DATA2__SD2_DATA2 = IOMUX_PAD(0x7cc, 0x3c4, 0x10, __NA_,
0, MX51_SDHCI_PAD_CTRL),
arch/arm/include/asm/arch-mx5/iomux-mx51.h:
MX51_PAD_SD2_DATA3__SD2_DATA3 = IOMUX_PAD(0x7d0, 0x3c8, 0x10, __NA_,
0, MX51_SDHCI_PAD_CTRL),

In this way we can be sure that we have done in proper way

Michael

>> On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
>>  wrote:
>>> SION bit should be used in the situation that we need
>>> to read back the value of a pin and should be set by
>>> default. This can generate any kind of random malfunction
>>> as described in this thread.
>>>
>>> According to this thread:
>>> https://www.spinics.net/lists/linux-usb/msg162574.html
>>>
>>> We consider this an early bug so all the boards running imx25
>>> with a minimimal set of functionalities can be affected.
>>>
>>> As reported by this application note:
>>> https://www.nxp.com/docs/en/application-note/AN5078.pdf
>>>
>>> The software input on (SION) bit is an option to force an input
>>> path to be active regardless of the value driven by the
>>> corresponding module. It is used when the nature direction
>>> of a pin depending on selected alternative function is an output,
>>> but it is needed to read the real logic value on a pin.
>>>
>>> The SION bit can be used in:
>>> • Loopback: the module of a selected alternative function drives
>>> the pad and also receives the pad value as an input
>>> • GPIO capture: the module of a selected alternative function
>>> drives the pin and the value is captured by the GPIO
>>>
>>> Signed-off-by: Michael Trimarchi 
>>> ---
>>> Refer-to:
>>> MX25 USB timeout on ID 0951:1665 Kingston Technology Digital
>>> DataTraveler SE9 64GB
>>
>> Glad you found a fix for the issue!
>>
>
> The idea was to align to the other freescale architecture. I can
> create two patches on it
>
> Michael
>
>>
>>> ---
>>>  arch/arm/include/asm/arch-mx25/iomux-mx25.h | 680 
>>> ++--
>>>  1 file changed, 340 insertions(+), 340 deletions(-)
>>>
>>> diff --git a/arch/arm/include/asm/arch-mx25/iomux-mx25.h 
>>> b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>>> index 5b2863e..2fcaf60 100644
>>> --- a/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>>> +++ b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>>> @@ -30,481 +30,481 @@
>>>
>>>  /* PADMUX
>>> ALT INPSE PATH PADCTRL */
>>>  enum {
>>> -   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
>>> 0x00, 0, 0, NO_PAD_CTRL),
>>> -   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
>>> 0x05, 0, 0, NO_PAD_CTRL),
>>> +   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
>>> 0, 0, 0, NO_PAD_CTRL),
>>> +   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
>>> 5, 0, 0, NO_PAD_CTRL),
>>
>> In many places in this patch you are only changing things like 0x00
>> --> 0 or 0x05--> 5, which just makes it harder to review.
>>
>> Please send a new version that only removes the SION bit.
>
>
>
> --
> | Michael Nazzareno Trimarchi   

Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Michael Nazzareno Trimarchi
Hi

On Wed, Jan 24, 2018 at 5:03 PM, Benoît Thébaudeau  wrote:
> On 24/01/2018 at 16:43, Michael Nazzareno Trimarchi wrote:
>> On Wed, Jan 24, 2018 at 4:39 PM, Benoît Thébaudeau  
>> wrote:
>>> On 24/01/2018 at 16:34, Benoît Thébaudeau wrote:
 On 24/01/2018 at 16:26, Michael Nazzareno Trimarchi wrote:
> On Wed, Jan 24, 2018 at 4:14 PM, Fabio Estevam  wrote:
>> On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
>>  wrote:
>>> SION bit should be used in the situation that we need
>>> to read back the value of a pin and should be set by
>>> default.

 You remove this bit because it should be set by default? This sentence is
 confusing.
>>
>> English is wrong ;)
>>
>> SION bit as a specific purpose to read back value that is set in
>> output. You don't need
>> and it's not set in any freescale board. If you need to set you need
>> to add to your peripheral.
>
> Unless there is a NEW_PAD_CTRL()-like mechanism for SION, all these 
> definitions
> should be kept in iomux-mx25.h in order not to redefine the register offsets
> everywhere. AFAIK, all the Freescale boards use the definitions from
> iomux-mx25.h too.
>
>> The only case you need maybe is the data[0] of sdcard.
>
> And eSDHC CMD, and I²C probably too. Yet, you are also removing SION in these
> cases. I have 3 i.M25-based boards working fine with SION. ;) Can you explain
> the precise issue that you are trying to fix (which pin)?
>

Let me summarize for you:
- was having a board with linux 2.6.x and uboot from 2009 working fine
on a usb pen driver (look on thread in linux-usb)
- was having the same board with any version of linux from 3.18 to
4.15 and fail with this pen drive
- check back all the changes from linux 2.6.x  to linux 4.15.x and
compare every single register and all the usb code and was just
confirm a better implementation of new kernel.
  but with a result of a usb stuck on the host port
- swap the boot-loader and having a working board
- go in deep in boot-loader and compare everything
- Understand the difference was the SION bit that was enable on all the mux

In general when a board start from reset it has default pin muxing.
Each peripheral need to setup the pin muxing according to the real
usage.
SION by default is not the right way to do it. What is the concept of
working board in your side? Just pass your testcase? Ok even this
board
was passing all test cases apart this usb pen drive. We was having in
the field some customer with usb issue time to time and only this
proof that somenthing was not real ok.

Michael



> Best regards,
> Benoît



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Benoît Thébaudeau
On 24/01/2018 at 16:43, Michael Nazzareno Trimarchi wrote:
> On Wed, Jan 24, 2018 at 4:39 PM, Benoît Thébaudeau  wrote:
>> On 24/01/2018 at 16:34, Benoît Thébaudeau wrote:
>>> On 24/01/2018 at 16:26, Michael Nazzareno Trimarchi wrote:
 On Wed, Jan 24, 2018 at 4:14 PM, Fabio Estevam  wrote:
> On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
>  wrote:
>> SION bit should be used in the situation that we need
>> to read back the value of a pin and should be set by
>> default.
>>>
>>> You remove this bit because it should be set by default? This sentence is
>>> confusing.
> 
> English is wrong ;)
> 
> SION bit as a specific purpose to read back value that is set in
> output. You don't need
> and it's not set in any freescale board. If you need to set you need
> to add to your peripheral.

Unless there is a NEW_PAD_CTRL()-like mechanism for SION, all these definitions
should be kept in iomux-mx25.h in order not to redefine the register offsets
everywhere. AFAIK, all the Freescale boards use the definitions from
iomux-mx25.h too.

> The only case you need maybe is the data[0] of sdcard.

And eSDHC CMD, and I²C probably too. Yet, you are also removing SION in these
cases. I have 3 i.M25-based boards working fine with SION. ;) Can you explain
the precise issue that you are trying to fix (which pin)?

Best regards,
Benoît
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Benoît Thébaudeau
Hi Michael,

On 24/01/2018 at 16:26, Michael Nazzareno Trimarchi wrote:
> On Wed, Jan 24, 2018 at 4:14 PM, Fabio Estevam  wrote:
>> On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
>>  wrote:
>>> SION bit should be used in the situation that we need
>>> to read back the value of a pin and should be set by
>>> default.

You remove this bit because it should be set by default? This sentence is
confusing.

>>> This can generate any kind of random malfunction
>>> as described in this thread.
>>>
>>> According to this thread:
>>> https://www.spinics.net/lists/linux-usb/msg162574.html

I can't find details about SION on a specific pin in this thread. Please
elaborate.

>>> We consider this an early bug so all the boards running imx25
>>> with a minimimal set of functionalities can be affected.
>>>
>>> As reported by this application note:
>>> https://www.nxp.com/docs/en/application-note/AN5078.pdf
>>>
>>> The software input on (SION) bit is an option to force an input
>>> path to be active regardless of the value driven by the
>>> corresponding module. It is used when the nature direction
>>> of a pin depending on selected alternative function is an output,
>>> but it is needed to read the real logic value on a pin.
>>>
>>> The SION bit can be used in:
>>> • Loopback: the module of a selected alternative function drives
>>> the pad and also receives the pad value as an input
>>> • GPIO capture: the module of a selected alternative function
>>> drives the pin and the value is captured by the GPIO
>>>
>>> Signed-off-by: Michael Trimarchi 
>>> ---
>>> Refer-to:
>>> MX25 USB timeout on ID 0951:1665 Kingston Technology Digital
>>> DataTraveler SE9 64GB
>>
>> Glad you found a fix for the issue!
>>
> 
> The idea was to align to the other freescale architecture. I can
> create two patches on it
> 
> Michael
> 
>>
>>> ---
>>>  arch/arm/include/asm/arch-mx25/iomux-mx25.h | 680 
>>> ++--
>>>  1 file changed, 340 insertions(+), 340 deletions(-)
>>>
>>> diff --git a/arch/arm/include/asm/arch-mx25/iomux-mx25.h 
>>> b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>>> index 5b2863e..2fcaf60 100644
>>> --- a/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>>> +++ b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>>> @@ -30,481 +30,481 @@
>>>
>>>  /* PADMUX
>>> ALT INPSE PATH PADCTRL */
>>>  enum {
>>> -   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
>>> 0x00, 0, 0, NO_PAD_CTRL),
>>> -   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
>>> 0x05, 0, 0, NO_PAD_CTRL),
>>> +   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
>>> 0, 0, 0, NO_PAD_CTRL),
>>> +   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
>>> 5, 0, 0, NO_PAD_CTRL),
>>
>> In many places in this patch you are only changing things like 0x00
>> --> 0 or 0x05--> 5, which just makes it harder to review.
>>
>> Please send a new version that only removes the SION bit.

Please make sure that these changes are not breaking anything for any board
(NEW_PAD_CTRL() can be used for these boards to restore SION if it really has to
be removed by default). SION is required in some cases, and it's unlikely to be
harmful, its main side effect being an increased power consumption.

Best regards,
Benoît
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Benoît Thébaudeau
On 24/01/2018 at 16:34, Benoît Thébaudeau wrote:
> On 24/01/2018 at 16:26, Michael Nazzareno Trimarchi wrote:
>> On Wed, Jan 24, 2018 at 4:14 PM, Fabio Estevam  wrote:
>>> On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
>>>  wrote:
 SION bit should be used in the situation that we need
 to read back the value of a pin and should be set by
 default.
> 
> You remove this bit because it should be set by default? This sentence is
> confusing.
> 
 This can generate any kind of random malfunction
 as described in this thread.

 According to this thread:
 https://www.spinics.net/lists/linux-usb/msg162574.html
> 
> I can't find details about SION on a specific pin in this thread. Please
> elaborate.
> 
 We consider this an early bug so all the boards running imx25
 with a minimimal set of functionalities can be affected.

 As reported by this application note:
 https://www.nxp.com/docs/en/application-note/AN5078.pdf

 The software input on (SION) bit is an option to force an input
 path to be active regardless of the value driven by the
 corresponding module. It is used when the nature direction
 of a pin depending on selected alternative function is an output,
 but it is needed to read the real logic value on a pin.

 The SION bit can be used in:
 • Loopback: the module of a selected alternative function drives
 the pad and also receives the pad value as an input
 • GPIO capture: the module of a selected alternative function
 drives the pin and the value is captured by the GPIO

 Signed-off-by: Michael Trimarchi 
 ---
 Refer-to:
 MX25 USB timeout on ID 0951:1665 Kingston Technology Digital
 DataTraveler SE9 64GB
>>>
>>> Glad you found a fix for the issue!
>>>
>>
>> The idea was to align to the other freescale architecture. I can
>> create two patches on it
>>
>> Michael
>>
>>>
 ---
  arch/arm/include/asm/arch-mx25/iomux-mx25.h | 680 
 ++--
  1 file changed, 340 insertions(+), 340 deletions(-)

 diff --git a/arch/arm/include/asm/arch-mx25/iomux-mx25.h 
 b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
 index 5b2863e..2fcaf60 100644
 --- a/arch/arm/include/asm/arch-mx25/iomux-mx25.h
 +++ b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
 @@ -30,481 +30,481 @@

  /* PADMUX
 ALT INPSE PATH PADCTRL */
  enum {
 -   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
 0x00, 0, 0, NO_PAD_CTRL),
 -   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
 0x05, 0, 0, NO_PAD_CTRL),
 +   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
 0, 0, 0, NO_PAD_CTRL),
 +   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
 5, 0, 0, NO_PAD_CTRL),
>>>
>>> In many places in this patch you are only changing things like 0x00
>>> --> 0 or 0x05--> 5, which just makes it harder to review.
>>>
>>> Please send a new version that only removes the SION bit.
> 
> Please make sure that these changes are not breaking anything for any board
> (NEW_PAD_CTRL() can be used for these boards to restore SION if it really has 
> to
> be removed by default). SION is required in some cases, and it's unlikely to 
> be
> harmful, its main side effect being an increased power consumption.

Actually, NEW_PAD_CTRL() cannot act upon SION, so removing it by default is all
the more risky.

Benoît
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Michael Nazzareno Trimarchi
Hi

On Wed, Jan 24, 2018 at 4:39 PM, Benoît Thébaudeau  wrote:
> On 24/01/2018 at 16:34, Benoît Thébaudeau wrote:
>> On 24/01/2018 at 16:26, Michael Nazzareno Trimarchi wrote:
>>> On Wed, Jan 24, 2018 at 4:14 PM, Fabio Estevam  wrote:
 On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
  wrote:
> SION bit should be used in the situation that we need
> to read back the value of a pin and should be set by
> default.
>>
>> You remove this bit because it should be set by default? This sentence is
>> confusing.

English is wrong ;)

SION bit as a specific purpose to read back value that is set in
output. You don't need
and it's not set in any freescale board. If you need to set you need
to add to your peripheral.
The only case you need maybe is the data[0] of sdcard.

Tihs is the reason that in this thread we have NXP people. We have 2
board with mx25 right now
so this will not an high risk break.

Michael

>>
> This can generate any kind of random malfunction
> as described in this thread.
>
> According to this thread:
> https://www.spinics.net/lists/linux-usb/msg162574.html
>>
>> I can't find details about SION on a specific pin in this thread. Please
>> elaborate.
>>
> We consider this an early bug so all the boards running imx25
> with a minimimal set of functionalities can be affected.
>
> As reported by this application note:
> https://www.nxp.com/docs/en/application-note/AN5078.pdf
>
> The software input on (SION) bit is an option to force an input
> path to be active regardless of the value driven by the
> corresponding module. It is used when the nature direction
> of a pin depending on selected alternative function is an output,
> but it is needed to read the real logic value on a pin.
>
> The SION bit can be used in:
> • Loopback: the module of a selected alternative function drives
> the pad and also receives the pad value as an input
> • GPIO capture: the module of a selected alternative function
> drives the pin and the value is captured by the GPIO
>
> Signed-off-by: Michael Trimarchi 
> ---
> Refer-to:
> MX25 USB timeout on ID 0951:1665 Kingston Technology Digital
> DataTraveler SE9 64GB

 Glad you found a fix for the issue!

>>>
>>> The idea was to align to the other freescale architecture. I can
>>> create two patches on it
>>>
>>> Michael
>>>

> ---
>  arch/arm/include/asm/arch-mx25/iomux-mx25.h | 680 
> ++--
>  1 file changed, 340 insertions(+), 340 deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-mx25/iomux-mx25.h 
> b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
> index 5b2863e..2fcaf60 100644
> --- a/arch/arm/include/asm/arch-mx25/iomux-mx25.h
> +++ b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
> @@ -30,481 +30,481 @@
>
>  /* PADMUX
> ALT INPSE PATH PADCTRL */
>  enum {
> -   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
> 0x00, 0, 0, NO_PAD_CTRL),
> -   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
> 0x05, 0, 0, NO_PAD_CTRL),
> +   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
> 0, 0, 0, NO_PAD_CTRL),
> +   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
> 5, 0, 0, NO_PAD_CTRL),

 In many places in this patch you are only changing things like 0x00
 --> 0 or 0x05--> 5, which just makes it harder to review.

 Please send a new version that only removes the SION bit.
>>
>> Please make sure that these changes are not breaking anything for any board
>> (NEW_PAD_CTRL() can be used for these boards to restore SION if it really 
>> has to
>> be removed by default). SION is required in some cases, and it's unlikely to 
>> be
>> harmful, its main side effect being an increased power consumption.
>
> Actually, NEW_PAD_CTRL() cannot act upon SION, so removing it by default is 
> all
> the more risky.
>
> Benoît



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Michael Nazzareno Trimarchi
Hi Fabio

On Wed, Jan 24, 2018 at 4:14 PM, Fabio Estevam  wrote:
> Hi Michael,
>
> On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
>  wrote:
>> SION bit should be used in the situation that we need
>> to read back the value of a pin and should be set by
>> default. This can generate any kind of random malfunction
>> as described in this thread.
>>
>> According to this thread:
>> https://www.spinics.net/lists/linux-usb/msg162574.html
>>
>> We consider this an early bug so all the boards running imx25
>> with a minimimal set of functionalities can be affected.
>>
>> As reported by this application note:
>> https://www.nxp.com/docs/en/application-note/AN5078.pdf
>>
>> The software input on (SION) bit is an option to force an input
>> path to be active regardless of the value driven by the
>> corresponding module. It is used when the nature direction
>> of a pin depending on selected alternative function is an output,
>> but it is needed to read the real logic value on a pin.
>>
>> The SION bit can be used in:
>> • Loopback: the module of a selected alternative function drives
>> the pad and also receives the pad value as an input
>> • GPIO capture: the module of a selected alternative function
>> drives the pin and the value is captured by the GPIO
>>
>> Signed-off-by: Michael Trimarchi 
>> ---
>> Refer-to:
>> MX25 USB timeout on ID 0951:1665 Kingston Technology Digital
>> DataTraveler SE9 64GB
>
> Glad you found a fix for the issue!
>

The idea was to align to the other freescale architecture. I can
create two patches on it

Michael

>
>> ---
>>  arch/arm/include/asm/arch-mx25/iomux-mx25.h | 680 
>> ++--
>>  1 file changed, 340 insertions(+), 340 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/arch-mx25/iomux-mx25.h 
>> b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>> index 5b2863e..2fcaf60 100644
>> --- a/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>> +++ b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
>> @@ -30,481 +30,481 @@
>>
>>  /* PADMUX
>> ALT INPSE PATH PADCTRL */
>>  enum {
>> -   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
>> 0x00, 0, 0, NO_PAD_CTRL),
>> -   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
>> 0x05, 0, 0, NO_PAD_CTRL),
>> +   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 0, 
>> 0, 0, NO_PAD_CTRL),
>> +   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 5, 
>> 0, 0, NO_PAD_CTRL),
>
> In many places in this patch you are only changing things like 0x00
> --> 0 or 0x05--> 5, which just makes it harder to review.
>
> Please send a new version that only removes the SION bit.



-- 
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO  -  Founder  Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
|  [`as] http://www.amarulasolutions.com   |
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [U-Boot] [PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Fabio Estevam
Hi Michael,

On Wed, Jan 24, 2018 at 12:56 PM, Michael Trimarchi
 wrote:
> SION bit should be used in the situation that we need
> to read back the value of a pin and should be set by
> default. This can generate any kind of random malfunction
> as described in this thread.
>
> According to this thread:
> https://www.spinics.net/lists/linux-usb/msg162574.html
>
> We consider this an early bug so all the boards running imx25
> with a minimimal set of functionalities can be affected.
>
> As reported by this application note:
> https://www.nxp.com/docs/en/application-note/AN5078.pdf
>
> The software input on (SION) bit is an option to force an input
> path to be active regardless of the value driven by the
> corresponding module. It is used when the nature direction
> of a pin depending on selected alternative function is an output,
> but it is needed to read the real logic value on a pin.
>
> The SION bit can be used in:
> • Loopback: the module of a selected alternative function drives
> the pad and also receives the pad value as an input
> • GPIO capture: the module of a selected alternative function
> drives the pin and the value is captured by the GPIO
>
> Signed-off-by: Michael Trimarchi 
> ---
> Refer-to:
> MX25 USB timeout on ID 0951:1665 Kingston Technology Digital
> DataTraveler SE9 64GB

Glad you found a fix for the issue!


> ---
>  arch/arm/include/asm/arch-mx25/iomux-mx25.h | 680 
> ++--
>  1 file changed, 340 insertions(+), 340 deletions(-)
>
> diff --git a/arch/arm/include/asm/arch-mx25/iomux-mx25.h 
> b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
> index 5b2863e..2fcaf60 100644
> --- a/arch/arm/include/asm/arch-mx25/iomux-mx25.h
> +++ b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
> @@ -30,481 +30,481 @@
>
>  /* PADMUXALT 
> INPSE PATH PADCTRL */
>  enum {
> -   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 
> 0x00, 0, 0, NO_PAD_CTRL),
> -   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 
> 0x05, 0, 0, NO_PAD_CTRL),
> +   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 0, 
> 0, 0, NO_PAD_CTRL),
> +   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 5, 
> 0, 0, NO_PAD_CTRL),

In many places in this patch you are only changing things like 0x00
--> 0 or 0x05--> 5, which just makes it harder to review.

Please send a new version that only removes the SION bit.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] imx: mx25: Remove SION bit in all pin-mux

2018-01-24 Thread Michael Trimarchi
SION bit should be used in the situation that we need
to read back the value of a pin and should be set by
default. This can generate any kind of random malfunction
as described in this thread.

According to this thread:
https://www.spinics.net/lists/linux-usb/msg162574.html

We consider this an early bug so all the boards running imx25
with a minimimal set of functionalities can be affected.

As reported by this application note:
https://www.nxp.com/docs/en/application-note/AN5078.pdf

The software input on (SION) bit is an option to force an input
path to be active regardless of the value driven by the
corresponding module. It is used when the nature direction
of a pin depending on selected alternative function is an output,
but it is needed to read the real logic value on a pin.

The SION bit can be used in:
• Loopback: the module of a selected alternative function drives
the pad and also receives the pad value as an input
• GPIO capture: the module of a selected alternative function
drives the pin and the value is captured by the GPIO

Signed-off-by: Michael Trimarchi 
---
Refer-to:
MX25 USB timeout on ID 0951:1665 Kingston Technology Digital
DataTraveler SE9 64GB

---
 arch/arm/include/asm/arch-mx25/iomux-mx25.h | 680 ++--
 1 file changed, 340 insertions(+), 340 deletions(-)

diff --git a/arch/arm/include/asm/arch-mx25/iomux-mx25.h 
b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
index 5b2863e..2fcaf60 100644
--- a/arch/arm/include/asm/arch-mx25/iomux-mx25.h
+++ b/arch/arm/include/asm/arch-mx25/iomux-mx25.h
@@ -30,481 +30,481 @@
 
 /* PADMUXALT 
INPSE PATH PADCTRL */
 enum {
-   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 0x00, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 0x05, 
0, 0, NO_PAD_CTRL),
+   MX25_PAD_A10__A10   = IOMUX_PAD(0x000, 0x008, 0, 0, 
0, NO_PAD_CTRL),
+   MX25_PAD_A10__GPIO_4_0  = IOMUX_PAD(0x000, 0x008, 5, 0, 
0, NO_PAD_CTRL),
 
-   MX25_PAD_A13__A13   = IOMUX_PAD(0x22C, 0x00c, 0x00, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A13__GPIO_4_1  = IOMUX_PAD(0x22C, 0x00c, 0x05, 
0, 0, NO_PAD_CTRL),
+   MX25_PAD_A13__A13   = IOMUX_PAD(0x22C, 0x00c, 0, 0, 
0, NO_PAD_CTRL),
+   MX25_PAD_A13__GPIO_4_1  = IOMUX_PAD(0x22C, 0x00c, 5, 0, 
0, NO_PAD_CTRL),
 
-   MX25_PAD_A14__A14   = IOMUX_PAD(0x230, 0x010, 0x10, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A14__GPIO_2_0  = IOMUX_PAD(0x230, 0x010, 0x15, 
0, 0, NO_PAD_CTRL),
+   MX25_PAD_A14__A14   = IOMUX_PAD(0x230, 0x010, 0, 0, 
0, NO_PAD_CTRL),
+   MX25_PAD_A14__GPIO_2_0  = IOMUX_PAD(0x230, 0x010, 5, 0, 
0, NO_PAD_CTRL),
 
-   MX25_PAD_A15__A15   = IOMUX_PAD(0x234, 0x014, 0x10, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A15__GPIO_2_1  = IOMUX_PAD(0x234, 0x014, 0x15, 
0, 0, NO_PAD_CTRL),
+   MX25_PAD_A15__A15   = IOMUX_PAD(0x234, 0x014, 0, 0, 
0, NO_PAD_CTRL),
+   MX25_PAD_A15__GPIO_2_1  = IOMUX_PAD(0x234, 0x014, 5, 0, 
0, NO_PAD_CTRL),
 
-   MX25_PAD_A16__A16   = IOMUX_PAD(0x000, 0x018, 0x10, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A16__GPIO_2_2  = IOMUX_PAD(0x000, 0x018, 0x15, 
0, 0, NO_PAD_CTRL),
+   MX25_PAD_A16__A16   = IOMUX_PAD(0x000, 0x018, 0, 0, 
0, NO_PAD_CTRL),
+   MX25_PAD_A16__GPIO_2_2  = IOMUX_PAD(0x000, 0x018, 5, 0, 
0, NO_PAD_CTRL),
 
-   MX25_PAD_A17__A17   = IOMUX_PAD(0x238, 0x01c, 0x10, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A17__GPIO_2_3  = IOMUX_PAD(0x238, 0x01c, 0x15, 
0, 0, NO_PAD_CTRL),
+   MX25_PAD_A17__A17   = IOMUX_PAD(0x238, 0x01c, 0, 0, 
0, NO_PAD_CTRL),
+   MX25_PAD_A17__GPIO_2_3  = IOMUX_PAD(0x238, 0x01c, 5, 0, 
0, NO_PAD_CTRL),
 
-   MX25_PAD_A18__A18   = IOMUX_PAD(0x23c, 0x020, 0x10, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A18__GPIO_2_4  = IOMUX_PAD(0x23c, 0x020, 0x15, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A18__FEC_COL   = IOMUX_PAD(0x23c, 0x020, 0x17, 
0x504, 0, NO_PAD_CTRL),
+   MX25_PAD_A18__A18   = IOMUX_PAD(0x23c, 0x020, 0, 0, 
0, NO_PAD_CTRL),
+   MX25_PAD_A18__GPIO_2_4  = IOMUX_PAD(0x23c, 0x020, 5, 0, 
0, NO_PAD_CTRL),
+   MX25_PAD_A18__FEC_COL   = IOMUX_PAD(0x23c, 0x020, 7, 
0x504, 0, NO_PAD_CTRL),
 
-   MX25_PAD_A19__A19   = IOMUX_PAD(0x240, 0x024, 0x10, 
0, 0, NO_PAD_CTRL),
-   MX25_PAD_A19__FEC_RX_ER = IOMUX_PAD(0x240, 0x024, 0x17, 
0x518, 0, NO_PAD_CTRL),
-   MX25_PAD_A19__GPIO_2_5 

[PATCH 11/11] usb: dwc2: Enable LPM

2018-01-24 Thread Grigor Tovmasyan
From: John Youn 

Set 'lpm_capable' flag in the gadget structure so
indicating that LPM is supported.

Signed-off-by: Sevak Arakelyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/gadget.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 223a0a10de0d..d017400caa6f 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4662,6 +4662,10 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
hsotg->gadget.max_speed = USB_SPEED_HIGH;
hsotg->gadget.ops = _hsotg_gadget_ops;
hsotg->gadget.name = dev_name(dev);
+
+   if (hsotg->params.lpm)
+   hsotg->gadget.lpm_capable = true;
+
if (hsotg->dr_mode == USB_DR_MODE_OTG)
hsotg->gadget.is_otg = 1;
else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/11] usb: dwc2: Add core state checking

2018-01-24 Thread Grigor Tovmasyan
Added core state checking in dwc2_hsotg_ep_queue() function
to make sure that application will submit requests only in L0 state.

Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/gadget.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 9dfb6e59fe83..223a0a10de0d 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1335,8 +1335,8 @@ static int dwc2_hsotg_ep_queue(struct usb_ep *ep, struct 
usb_request *req,
req->zero, req->short_not_ok);
 
/* Prevent new request submission when controller is suspended */
-   if (hs->lx_state == DWC2_L2) {
-   dev_dbg(hs->dev, "%s: don't submit request while suspended\n",
+   if (hs->lx_state != DWC2_L0) {
+   dev_dbg(hs->dev, "%s: submit request only in active state\n",
__func__);
return -EAGAIN;
}
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/11] usb: dwc2: Add call_gadget() function call

2018-01-24 Thread Grigor Tovmasyan
Added call_gadget() function call when entering to L1 state
to inform gadget that core is in L1 state.

Did the same thing when exiting from L1 state
to inform gadget that core is in L0 state.

Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/core_intr.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index a8e43948f807..46b32ec7d343 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -381,6 +381,9 @@ static void dwc2_wakeup_from_lpm_l1(struct dwc2_hsotg 
*hsotg)
 
/* Change to L0 state */
hsotg->lx_state = DWC2_L0;
+
+   /* Inform gadget to exit from L1 */
+   call_gadget(hsotg, resume);
 }
 
 /*
@@ -589,6 +592,9 @@ static void dwc2_handle_lpm_intr(struct dwc2_hsotg *hsotg)
hsotg->lx_state = DWC2_L1;
dev_dbg(hsotg->dev,
"Core is in L1 sleep glpmcfg=%08x\n", glpmcfg);
+
+   /* Inform gadget that we are in L1 state */
+   call_gadget(hsotg, suspend);
}
}
 }
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/11] usb: dwc2: gadget: Configure the core to enable LPM

2018-01-24 Thread Grigor Tovmasyan
From: Sevak Arakelyan 

Configure core in device mode to support LPM according to
programming guide.
Device will start giving valid responses for LPM tokens.
After this patch device side LPM will start working.

Signed-off-by: Sevak Arakelyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/core.h  |  2 ++
 drivers/usb/dwc2/core_intr.c |  1 +
 drivers/usb/dwc2/gadget.c| 26 ++
 3 files changed, 29 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index c4774d901c95..5c17cf0482b9 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1201,6 +1201,7 @@ int dwc2_restore_device_registers(struct dwc2_hsotg 
*hsotg);
 int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg);
 int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg);
 int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg);
+void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg);
 #else
 static inline int dwc2_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
@@ -1228,6 +1229,7 @@ static inline int dwc2_hsotg_tx_fifo_total_depth(struct 
dwc2_hsotg *hsotg)
 { return 0; }
 static inline int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg)
 { return 0; }
+static inline void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) {}
 #endif
 
 #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 23599e798e24..a8e43948f807 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -372,6 +372,7 @@ static void dwc2_wakeup_from_lpm_l1(struct dwc2_hsotg 
*hsotg)
dev_err(hsotg->dev, "Failed to exit L1 sleep state in 
200us.\n");
return;
}
+   dwc2_gadget_init_lpm(hsotg);
} else {
/* TODO */
dev_err(hsotg->dev, "Host side LPM is not supported.\n");
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index bb5eee5ba04f..9dfb6e59fe83 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3410,6 +3410,9 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
val |= DCTL_SFTDISCON;
dwc2_set_bit(hsotg->regs + DCTL, val);
 
+   /* configure the core to support LPM */
+   dwc2_gadget_init_lpm(hsotg);
+
/* must be at-least 3ms to allow bus to see disconnect */
mdelay(3);
 
@@ -4900,3 +4903,26 @@ int dwc2_restore_device_registers(struct dwc2_hsotg 
*hsotg)
 
return 0;
 }
+
+/**
+ * dwc2_gadget_init_lpm - Configure the core to support LPM in device mode
+ *
+ * @hsotg: Programming view of DWC_otg controller
+ *
+ */
+void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg)
+{
+   u32 val;
+
+   if (!hsotg->params.lpm)
+   return;
+
+   val = GLPMCFG_LPMCAP | GLPMCFG_APPL1RES;
+   val |= hsotg->params.hird_threshold_en ? GLPMCFG_HIRD_THRES_EN : 0;
+   val |= hsotg->params.lpm_clock_gating ? GLPMCFG_ENBLSLPM : 0;
+   val |= hsotg->params.hird_threshold << GLPMCFG_HIRD_THRES_SHIFT;
+   val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0;
+   dwc2_writel(val, hsotg->regs + GLPMCFG);
+   dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg->regs
+   + GLPMCFG));
+}
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/11] usb: dwc2: Enable LPM Transaction Received interrupt

2018-01-24 Thread Grigor Tovmasyan
From: Sevak Arakelyan 

Enable "LPM Transaction Received" interrupt for receive an
interrupt when host will send LPM token.

Signed-off-by: Sevak Arakelyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/core_intr.c | 5 +++--
 drivers/usb/dwc2/gadget.c| 3 ++-
 drivers/usb/dwc2/hcd.c   | 3 +++
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 5ad3c9df85f5..23599e798e24 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -560,7 +560,7 @@ static void dwc2_handle_lpm_intr(struct dwc2_hsotg *hsotg)
hird_thres = (glpmcfg & GLPMCFG_HIRD_THRES_MASK &
~GLPMCFG_HIRD_THRES_EN) >> GLPMCFG_HIRD_THRES_SHIFT;
hird_thres_en = glpmcfg & GLPMCFG_HIRD_THRES_EN;
-   enslpm = glpmcfg & GLPMCFG_SNDLPM;
+   enslpm = glpmcfg & GLPMCFG_ENBLSLPM;
 
if (dwc2_is_device_mode(hsotg)) {
dev_dbg(hsotg->dev, "HIRD_THRES_EN = %d\n", hird_thres_en);
@@ -595,7 +595,8 @@ static void dwc2_handle_lpm_intr(struct dwc2_hsotg *hsotg)
 #define GINTMSK_COMMON (GINTSTS_WKUPINT | GINTSTS_SESSREQINT | \
 GINTSTS_CONIDSTSCHNG | GINTSTS_OTGINT |\
 GINTSTS_MODEMIS | GINTSTS_DISCONNINT | \
-GINTSTS_USBSUSP | GINTSTS_PRTINT)
+GINTSTS_USBSUSP | GINTSTS_PRTINT | \
+GINTSTS_LPMTRANRCVD)
 
 /*
  * This function returns the Core Interrupt register
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 0c10eff8a3df..bb5eee5ba04f 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -3304,7 +3304,8 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg 
*hsotg,
GINTSTS_GOUTNAKEFF | GINTSTS_GINNAKEFF |
GINTSTS_USBRST | GINTSTS_RESETDET |
GINTSTS_ENUMDONE | GINTSTS_OTGINT |
-   GINTSTS_USBSUSP | GINTSTS_WKUPINT;
+   GINTSTS_USBSUSP | GINTSTS_WKUPINT |
+   GINTSTS_LPMTRANRCVD;
 
if (!using_desc_dma(hsotg))
intmsk |= GINTSTS_INCOMPL_SOIN | GINTSTS_INCOMPL_SOOUT;
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 5f044df6026c..ea8f87f813aa 100644
--- a/drivers/usb/dwc2/hcd.c
+++ b/drivers/usb/dwc2/hcd.c
@@ -91,6 +91,9 @@ static void dwc2_enable_common_interrupts(struct dwc2_hsotg 
*hsotg)
intmsk |= GINTSTS_WKUPINT | GINTSTS_USBSUSP |
  GINTSTS_SESSREQINT;
 
+   if (dwc2_is_device_mode(hsotg) && hsotg->params.lpm)
+   intmsk |= GINTSTS_LPMTRANRCVD;
+
dwc2_writel(intmsk, hsotg->regs + GINTMSK);
 }
 
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/11] usb: dwc2: gadget: LPM interrupt handler

2018-01-24 Thread Grigor Tovmasyan
From: Sevak Arakelyan 

This interrupt indicates that an LPM transaction
was received on the USB bus. After getting this
interrupt we are going from L0 state to L1 state.

Signed-off-by: Sevak Arakelyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/core_intr.c | 63 
 1 file changed, 63 insertions(+)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index 6baa0c937bff..5ad3c9df85f5 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -531,6 +531,67 @@ static void dwc2_handle_usb_suspend_intr(struct dwc2_hsotg 
*hsotg)
}
 }
 
+/**
+ * dwc2_handle_lpm_intr - GINTSTS_LPMTRANRCVD Interrupt handler
+ *
+ * @hsotg: Programming view of DWC_otg controller
+ *
+ */
+static void dwc2_handle_lpm_intr(struct dwc2_hsotg *hsotg)
+{
+   u32 glpmcfg;
+   u32 pcgcctl;
+   u32 hird;
+   u32 hird_thres;
+   u32 hird_thres_en;
+   u32 enslpm;
+
+   /* Clear interrupt */
+   dwc2_writel(GINTSTS_LPMTRANRCVD, hsotg->regs + GINTSTS);
+
+   glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+
+   if (!(glpmcfg & GLPMCFG_LPMCAP)) {
+   dev_err(hsotg->dev, "Unexpected LPM interrupt\n");
+   return;
+   }
+
+   hird = (glpmcfg & GLPMCFG_HIRD_MASK) >> GLPMCFG_HIRD_SHIFT;
+   hird_thres = (glpmcfg & GLPMCFG_HIRD_THRES_MASK &
+   ~GLPMCFG_HIRD_THRES_EN) >> GLPMCFG_HIRD_THRES_SHIFT;
+   hird_thres_en = glpmcfg & GLPMCFG_HIRD_THRES_EN;
+   enslpm = glpmcfg & GLPMCFG_SNDLPM;
+
+   if (dwc2_is_device_mode(hsotg)) {
+   dev_dbg(hsotg->dev, "HIRD_THRES_EN = %d\n", hird_thres_en);
+
+   if (hird_thres_en && hird >= hird_thres) {
+   dev_dbg(hsotg->dev, "L1 with utmi_l1_suspend_n\n");
+   } else if (enslpm) {
+   dev_dbg(hsotg->dev, "L1 with utmi_sleep_n\n");
+   } else {
+   dev_dbg(hsotg->dev, "Entering Sleep with L1 Gating\n");
+
+   pcgcctl = dwc2_readl(hsotg->regs + PCGCTL);
+   pcgcctl |= PCGCTL_ENBL_SLEEP_GATING;
+   dwc2_writel(pcgcctl, hsotg->regs + PCGCTL);
+   }
+   /**
+* Examine prt_sleep_sts after TL1TokenTetry period max (10 us)
+*/
+   udelay(10);
+
+   glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+
+   if (glpmcfg & GLPMCFG_SLPSTS) {
+   /* Save the current state */
+   hsotg->lx_state = DWC2_L1;
+   dev_dbg(hsotg->dev,
+   "Core is in L1 sleep glpmcfg=%08x\n", glpmcfg);
+   }
+   }
+}
+
 #define GINTMSK_COMMON (GINTSTS_WKUPINT | GINTSTS_SESSREQINT | \
 GINTSTS_CONIDSTSCHNG | GINTSTS_OTGINT |\
 GINTSTS_MODEMIS | GINTSTS_DISCONNINT | \
@@ -605,6 +666,8 @@ irqreturn_t dwc2_handle_common_intr(int irq, void *dev)
dwc2_handle_wakeup_detected_intr(hsotg);
if (gintsts & GINTSTS_USBSUSP)
dwc2_handle_usb_suspend_intr(hsotg);
+   if (gintsts & GINTSTS_LPMTRANRCVD)
+   dwc2_handle_lpm_intr(hsotg);
 
if (gintsts & GINTSTS_PRTINT) {
/*
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/11] usb: dwc2: gadget: Add functionality to exit from LPM L1 state

2018-01-24 Thread Grigor Tovmasyan
From: Sevak Arakelyan 

Add a function which will be called if device is in L1 sleep state
and Resume/Remote Wakeup Detected interrupt is asserted.

Signed-off-by: Sevak Arakelyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/core_intr.c | 52 
 1 file changed, 52 insertions(+)

diff --git a/drivers/usb/dwc2/core_intr.c b/drivers/usb/dwc2/core_intr.c
index ab3fa1630853..6baa0c937bff 100644
--- a/drivers/usb/dwc2/core_intr.c
+++ b/drivers/usb/dwc2/core_intr.c
@@ -335,6 +335,53 @@ static void dwc2_handle_session_req_intr(struct dwc2_hsotg 
*hsotg)
}
 }
 
+/**
+ * dwc2_wakeup_from_lpm_l1 - Exit the device from LPM L1 state
+ *
+ * @hsotg: Programming view of DWC_otg controller
+ *
+ */
+static void dwc2_wakeup_from_lpm_l1(struct dwc2_hsotg *hsotg)
+{
+   u32 glpmcfg;
+   u32 i = 0;
+
+   if (hsotg->lx_state != DWC2_L1) {
+   dev_err(hsotg->dev, "Core isn't in DWC2_L1 state\n");
+   return;
+   }
+
+   glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+   if (dwc2_is_device_mode(hsotg)) {
+   dev_dbg(hsotg->dev, "Exit from L1 state\n");
+   glpmcfg &= ~GLPMCFG_ENBLSLPM;
+   glpmcfg &= ~GLPMCFG_HIRD_THRES_EN;
+   dwc2_writel(glpmcfg, hsotg->regs + GLPMCFG);
+
+   do {
+   glpmcfg = dwc2_readl(hsotg->regs + GLPMCFG);
+
+   if (!(glpmcfg & (GLPMCFG_COREL1RES_MASK |
+GLPMCFG_L1RESUMEOK | GLPMCFG_SLPSTS)))
+   break;
+
+   udelay(1);
+   } while (++i < 200);
+
+   if (i == 200) {
+   dev_err(hsotg->dev, "Failed to exit L1 sleep state in 
200us.\n");
+   return;
+   }
+   } else {
+   /* TODO */
+   dev_err(hsotg->dev, "Host side LPM is not supported.\n");
+   return;
+   }
+
+   /* Change to L0 state */
+   hsotg->lx_state = DWC2_L0;
+}
+
 /*
  * This interrupt indicates that the DWC_otg controller has detected a
  * resume or remote wakeup sequence. If the DWC_otg controller is in
@@ -352,6 +399,11 @@ static void dwc2_handle_wakeup_detected_intr(struct 
dwc2_hsotg *hsotg)
dev_dbg(hsotg->dev, "++Resume or Remote Wakeup Detected Interrupt++\n");
dev_dbg(hsotg->dev, "%s lxstate = %d\n", __func__, hsotg->lx_state);
 
+   if (hsotg->lx_state == DWC2_L1) {
+   dwc2_wakeup_from_lpm_l1(hsotg);
+   return;
+   }
+
if (dwc2_is_device_mode(hsotg)) {
dev_dbg(hsotg->dev, "DSTS=0x%0x\n",
dwc2_readl(hsotg->regs + DSTS));
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/11] usb: dwc2: Add core parameters for LPM support

2018-01-24 Thread Grigor Tovmasyan
From: Sevak Arakelyan 

Add lpm, lpm_clock_gating, besl, hird_threshold_en and hird_threshold
core parameters. These will indicate LPM and LPM Errata support
as well as chosen L1 sleeping mode for the core and PHY.

Signed-off-by: Sevak Arakelyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/core.h| 20 
 drivers/usb/dwc2/debugfs.c |  5 +
 drivers/usb/dwc2/params.c  | 13 +
 3 files changed, 38 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 1ec0dd4d5c95..c4774d901c95 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -427,6 +427,19 @@ enum dwc2_ep0_state {
  * needed.
  * 0 - No (default)
  * 1 - Yes
+ * @lpm:   Enable LPM support.
+ * 0 - No
+ * 1 - Yes
+ * @lpm_clock_gating:  Enable core PHY clock gating.
+ * 0 - No
+ * 1 - Yes
+ * @besl:  Enable LPM Errata support.
+ * 0 - No
+ * 1 - Yes
+ * @hird_threshold_en: HIRD or HIRD Threshold enable.
+ * 0 - No
+ * 1 - Yes
+ * @hird_threshold:Value of BESL or HIRD Threshold.
  * @activate_stm_fs_transceiver: Activate internal transceiver using GGPIO
  * register.
  * 0 - Deactivate the transceiver (default)
@@ -486,6 +499,11 @@ struct dwc2_core_params {
bool uframe_sched;
bool external_id_pin_ctl;
bool hibernation;
+   bool lpm;
+   bool lpm_clock_gating;
+   bool besl;
+   bool hird_threshold_en;
+   u8 hird_threshold;
bool activate_stm_fs_transceiver;
u16 max_packet_count;
u32 max_transfer_size;
@@ -592,6 +610,7 @@ struct dwc2_hw_params {
unsigned total_fifo_size:16;
unsigned power_optimized:1;
unsigned utmi_phy_data_width:2;
+   unsigned lpm_mode:1;
u32 snpsid;
u32 dev_ep_dirs;
 };
@@ -945,6 +964,7 @@ struct dwc2_hsotg {
 
/* DWC OTG HW Release versions */
 #define DWC2_CORE_REV_2_71a0x4f54271a
+#define DWC2_CORE_REV_2_80a0x4f54280a
 #define DWC2_CORE_REV_2_90a0x4f54290a
 #define DWC2_CORE_REV_2_91a0x4f54291a
 #define DWC2_CORE_REV_2_92a0x4f54292a
diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c
index f4650a88be78..bd9cd8829094 100644
--- a/drivers/usb/dwc2/debugfs.c
+++ b/drivers/usb/dwc2/debugfs.c
@@ -755,6 +755,11 @@ static int params_show(struct seq_file *seq, void *v)
print_param(seq, p, uframe_sched);
print_param(seq, p, external_id_pin_ctl);
print_param(seq, p, hibernation);
+   print_param(seq, p, lpm);
+   print_param(seq, p, lpm_clock_gating);
+   print_param(seq, p, besl);
+   print_param(seq, p, hird_threshold_en);
+   print_param(seq, p, hird_threshold);
print_param(seq, p, host_dma);
print_param(seq, p, g_dma);
print_param(seq, p, g_dma_desc);
diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c
index 32831d56c5c4..48790f2dc483 100644
--- a/drivers/usb/dwc2/params.c
+++ b/drivers/usb/dwc2/params.c
@@ -279,6 +279,11 @@ static void dwc2_set_default_params(struct dwc2_hsotg 
*hsotg)
p->uframe_sched = true;
p->external_id_pin_ctl = false;
p->hibernation = false;
+   p->lpm = true;
+   p->lpm_clock_gating = true;
+   p->besl = true;
+   p->hird_threshold_en = true;
+   p->hird_threshold = 4;
p->max_packet_count = hw->max_packet_count;
p->max_transfer_size = hw->max_transfer_size;
p->ahbcfg = GAHBCFG_HBSTLEN_INCR << GAHBCFG_HBSTLEN_SHIFT;
@@ -530,6 +535,13 @@ static void dwc2_check_params(struct dwc2_hsotg *hsotg)
CHECK_BOOL(i2c_enable, hw->i2c_enable);
CHECK_BOOL(acg_enable, hw->acg_enable);
CHECK_BOOL(reload_ctl, (hsotg->hw_params.snpsid > DWC2_CORE_REV_2_92a));
+   CHECK_BOOL(lpm, (hsotg->hw_params.snpsid >= DWC2_CORE_REV_2_80a));
+   CHECK_BOOL(lpm, hw->lpm_mode);
+   CHECK_BOOL(lpm_clock_gating, hsotg->params.lpm);
+   CHECK_BOOL(besl, hsotg->params.lpm);
+   CHECK_BOOL(besl, (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a));
+   CHECK_BOOL(hird_threshold_en, hsotg->params.lpm);
+   CHECK_RANGE(hird_threshold, 0, hsotg->params.besl ? 12 : 7, 0);
CHECK_RANGE(max_packet_count,
15, hw->max_packet_count,
hw->max_packet_count);
@@ -699,6 +711,7 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg)
hw->i2c_enable = !!(hwcfg3 & GHWCFG3_I2C);
hw->total_fifo_size = (hwcfg3 & GHWCFG3_DFIFO_DEPTH_MASK) >>
  GHWCFG3_DFIFO_DEPTH_SHIFT;
+   hw->lpm_mode = !!(hwcfg3 & GHWCFG3_OTG_LPM_EN);
 
/* hwcfg4 */
hw->en_multiple_tx_fifo = !!(hwcfg4 & 

[PATCH 03/11] usb: dwc2: Rename GLPMCFG... definitions

2018-01-24 Thread Grigor Tovmasyan
From: Sevak Arakelyan 

Make field names of GLPMCFG register in definitions to be
the same with the databook.

Signed-off-by: Sevak Arakelyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/hw.h | 38 --
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h
index bfb85519af32..38391e48351f 100644
--- a/drivers/usb/dwc2/hw.h
+++ b/drivers/usb/dwc2/hw.h
@@ -322,28 +322,30 @@
 #define GHWCFG4_NUM_DEV_PERIO_IN_EP_SHIFT  0
 
 #define GLPMCFGHSOTG_REG(0x0054)
-#define GLPMCFG_INV_SEL_HSIC   BIT(31)
-#define GLPMCFG_HSIC_CONNECT   BIT(30)
-#define GLPMCFG_RETRY_COUNT_STS_MASK   (0x7 << 25)
-#define GLPMCFG_RETRY_COUNT_STS_SHIFT  25
-#define GLPMCFG_SEND_LPM   BIT(24)
-#define GLPMCFG_RETRY_COUNT_MASK   (0x7 << 21)
-#define GLPMCFG_RETRY_COUNT_SHIFT  21
-#define GLPMCFG_LPM_CHAN_INDEX_MASK(0xf << 17)
-#define GLPMCFG_LPM_CHAN_INDEX_SHIFT   17
-#define GLPMCFG_SLEEP_STATE_RESUMEOK   BIT(16)
-#define GLPMCFG_PRT_SLEEP_STS  BIT(15)
-#define GLPMCFG_LPM_RESP_MASK  (0x3 << 13)
-#define GLPMCFG_LPM_RESP_SHIFT 13
+#define GLPMCFG_INVSELHSIC BIT(31)
+#define GLPMCFG_HSICCONBIT(30)
+#define GLPMCFG_RSTRSLPSTS BIT(29)
+#define GLPMCFG_ENBESL BIT(28)
+#define GLPMCFG_LPM_RETRYCNT_STS_MASK  (0x7 << 25)
+#define GLPMCFG_LPM_RETRYCNT_STS_SHIFT 25
+#define GLPMCFG_SNDLPM BIT(24)
+#define GLPMCFG_RETRY_CNT_MASK (0x7 << 21)
+#define GLPMCFG_RETRY_CNT_SHIFT21
+#define GLPMCFG_LPM_CHNL_INDX_MASK (0xf << 17)
+#define GLPMCFG_LPM_CHNL_INDX_SHIFT17
+#define GLPMCFG_L1RESUMEOK BIT(16)
+#define GLPMCFG_SLPSTS BIT(15)
+#define GLPMCFG_COREL1RES_MASK (0x3 << 13)
+#define GLPMCFG_COREL1RES_SHIFT13
 #define GLPMCFG_HIRD_THRES_MASK(0x1f << 8)
 #define GLPMCFG_HIRD_THRES_SHIFT   8
-#define GLPMCFG_HIRD_THRES_EN  (0x10 << 8)
-#define GLPMCFG_EN_UTMI_SLEEP  BIT(7)
-#define GLPMCFG_REM_WKUP_ENBIT(6)
+#define GLPMCFG_HIRD_THRES_EN  (0x10 << 8)
+#define GLPMCFG_ENBLSLPM   BIT(7)
+#define GLPMCFG_BREMOTEWAKEBIT(6)
 #define GLPMCFG_HIRD_MASK  (0xf << 2)
 #define GLPMCFG_HIRD_SHIFT 2
-#define GLPMCFG_APPL_RESP  BIT(1)
-#define GLPMCFG_LPM_CAP_EN BIT(0)
+#define GLPMCFG_APPL1RES   BIT(1)
+#define GLPMCFG_LPMCAP BIT(0)
 
 #define GPWRDN HSOTG_REG(0x0058)
 #define GPWRDN_MULT_VAL_ID_BC_MASK (0x1f << 24)
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/11] usb: dwc2: Backup and restore PCGCCTL1 register

2018-01-24 Thread Grigor Tovmasyan
From: Razmik Karapetyan 

Backup PCGCCTL1 register when entering hibernation mode and
restore it after exiting from hibernation, to keep active ACG
feature.

Signed-off-by: Razmik Karapetyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/core.c | 2 ++
 drivers/usb/dwc2/core.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 8d9ffde6b68a..7a236e61e2e2 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -80,6 +80,7 @@ static int dwc2_backup_global_registers(struct dwc2_hsotg 
*hsotg)
gr->gnptxfsiz = dwc2_readl(hsotg->regs + GNPTXFSIZ);
gr->hptxfsiz = dwc2_readl(hsotg->regs + HPTXFSIZ);
gr->gdfifocfg = dwc2_readl(hsotg->regs + GDFIFOCFG);
+   gr->pcgcctl1 = dwc2_readl(hsotg->regs + PCGCCTL1);
for (i = 0; i < MAX_EPS_CHANNELS; i++)
gr->dtxfsiz[i] = dwc2_readl(hsotg->regs + DPTXFSIZN(i));
 
@@ -119,6 +120,7 @@ static int dwc2_restore_global_registers(struct dwc2_hsotg 
*hsotg)
dwc2_writel(gr->gnptxfsiz, hsotg->regs + GNPTXFSIZ);
dwc2_writel(gr->hptxfsiz, hsotg->regs + HPTXFSIZ);
dwc2_writel(gr->gdfifocfg, hsotg->regs + GDFIFOCFG);
+   dwc2_writel(gr->pcgcctl1, hsotg->regs + PCGCCTL1);
for (i = 0; i < MAX_EPS_CHANNELS; i++)
dwc2_writel(gr->dtxfsiz[i], hsotg->regs + DPTXFSIZN(i));
 
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 35a971436c71..1ec0dd4d5c95 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -624,6 +624,7 @@ struct dwc2_gregs_backup {
u32 gi2cctl;
u32 hptxfsiz;
u32 pcgcctl;
+   u32 pcgcctl1;
u32 gdfifocfg;
u32 dtxfsiz[MAX_EPS_CHANNELS];
u32 gpwrdn;
-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/11] usb: dwc2: Add ACG support to the driver

2018-01-24 Thread Grigor Tovmasyan
From: Razmik Karapetyan 

Added function for supporting Active Clock Gating functionality
in the driver.

PCGCCTL1 (Power and Clock Control) register will be used
for controlling the core`s active clock gating feature, and
the previously reserved 12th bit in GHWCFG4 now indicates that the
controller supports the Dynamic Power Reduction (Active Clock Gating)
during no traffic scenarios such as L0, idle, resume and suspend
states.

dwc2_enable_acg() function sets GATEEN bit in PCGCCTL1 register
and enables ACG, if it supported.

According to ACG functional specification, enabling of ACG feature
in host mode done in host initialization, before turning Vbus on,
specifically in dwc2_core_host_init function.

Enabling of ACG feature in device mode done in device initialization,
before clearing the SftDiscon bit in DCTL.
This bit was cleared in dwc2_hsotg_core_connect() function.So
dwc2_enable_acg() called before dwc2_core_connect() calls.

Signed-off-by: Razmik Karapetyan 
Signed-off-by: Grigor Tovmasyan 
---
 drivers/usb/dwc2/core.c   | 14 ++
 drivers/usb/dwc2/core.h   |  4 
 drivers/usb/dwc2/gadget.c | 12 ++--
 drivers/usb/dwc2/hcd.c|  5 +
 drivers/usb/dwc2/hw.h |  5 +
 drivers/usb/dwc2/params.c |  3 +++
 6 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 64a0b2068b14..8d9ffde6b68a 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -481,6 +481,20 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
}
 }
 
+/*
+ * dwc2_enable_acg - enable active clock gating feature
+ */
+void dwc2_enable_acg(struct dwc2_hsotg *hsotg)
+{
+   if (hsotg->params.acg_enable) {
+   u32 pcgcctl1 = dwc2_readl(hsotg->regs + PCGCCTL1);
+
+   dev_dbg(hsotg->dev, "Enabling Active Clock Gating\n");
+   pcgcctl1 |= PCGCCTL1_GATEEN;
+   dwc2_writel(pcgcctl1, hsotg->regs + PCGCCTL1);
+   }
+}
+
 /**
  * dwc2_dump_host_registers() - Prints the host registers
  *
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 5d8bca9eaccc..35a971436c71 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -479,6 +479,7 @@ struct dwc2_core_params {
bool enable_dynamic_fifo;
bool en_multiple_tx_fifo;
bool i2c_enable;
+   bool acg_enable;
bool ulpi_fs_ls;
bool ts_dline;
bool reload_ctl;
@@ -585,6 +586,7 @@ struct dwc2_hw_params {
unsigned hs_phy_type:2;
unsigned fs_phy_type:2;
unsigned i2c_enable:1;
+   unsigned acg_enable:1;
unsigned num_dev_ep:4;
unsigned num_dev_perio_in_ep:4;
unsigned total_fifo_size:16;
@@ -1107,6 +1109,8 @@ void dwc2_flush_rx_fifo(struct dwc2_hsotg *hsotg);
 void dwc2_enable_global_interrupts(struct dwc2_hsotg *hcd);
 void dwc2_disable_global_interrupts(struct dwc2_hsotg *hcd);
 
+void dwc2_enable_acg(struct dwc2_hsotg *hsotg);
+
 /* This function should be called on every hardware interrupt. */
 irqreturn_t dwc2_handle_common_intr(int irq, void *dev);
 
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 842a7664961e..0c10eff8a3df 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -4384,6 +4384,8 @@ static int dwc2_hsotg_pullup(struct usb_gadget *gadget, 
int is_on)
if (is_on) {
hsotg->enabled = 1;
dwc2_hsotg_core_init_disconnected(hsotg, false);
+   /* Enable ACG feature in device mode,if supported */
+   dwc2_enable_acg(hsotg);
dwc2_hsotg_core_connect(hsotg);
} else {
dwc2_hsotg_core_disconnect(hsotg);
@@ -4416,8 +4418,11 @@ static int dwc2_hsotg_vbus_session(struct usb_gadget 
*gadget, int is_active)
hsotg->op_state = OTG_STATE_B_PERIPHERAL;
 
dwc2_hsotg_core_init_disconnected(hsotg, false);
-   if (hsotg->enabled)
+   if (hsotg->enabled) {
+   /* Enable ACG feature in device mode,if supported */
+   dwc2_enable_acg(hsotg);
dwc2_hsotg_core_connect(hsotg);
+   }
} else {
dwc2_hsotg_core_disconnect(hsotg);
dwc2_hsotg_disconnect(hsotg);
@@ -4782,8 +4787,11 @@ int dwc2_hsotg_resume(struct dwc2_hsotg *hsotg)
 
spin_lock_irqsave(>lock, flags);
dwc2_hsotg_core_init_disconnected(hsotg, false);
-   if (hsotg->enabled)
+   if (hsotg->enabled) {
+   /* Enable ACG feature in device mode,if supported */
+   dwc2_enable_acg(hsotg);
dwc2_hsotg_core_connect(hsotg);
+   }
spin_unlock_irqrestore(>lock, flags);
}
 
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
index 

[PATCH 00/11] usb: dwc2: gadget: Add ACG and LPM support

2018-01-24 Thread Grigor Tovmasyan

This series contains patches which are already have been sent in
"usb: dwc2: fixes, enhancements and new features" series.

That patch series was too large, and based on community feedbacks decided to 
split that series into small pieces. This is a third part.

In this series we included Active Clock Gating (ACG) and LPM features. 

All patches were tested on HAPS-DX7 platform.

Patches from 1-2  related to ACG and logically linked.
Patches from 3-11 related to LPM and logically linked.

Changes after first submission:

usb: dwc2: gadget: Add LPM functionality (LPM):

- "usb: gadget: Allow a non-SuperSpeed gadget to support LPM" 
  and "usb: gadget: composite: Exclude SS Dev Cap Desc" patches were 
  removed, because they were already merged to kernel. 
- "usb: dwc2: Add core state checking" and "usb: dwc2: Add call_gadget() 
function call" 
  patches were added.
- Fixed GLPMCFG initialization. Now hird and besl values also writes into 
GLPMCFG.
- Replaced shift operator with BIT() macro. 

ACG support for dwc2 driver (ACG):
   
   - Previous 4 commits were squashed into 2 ones.
   - Added new acg_enable filed in dwc2_hw_params checks ACG support from 
hardware side.
   - Similar acg_enable field in dwc2_core_params used for dynamically 
disabling/enabling.
 ACG functionality from driver. 



Grigor Tovmasyan (2):
  usb: dwc2: Add call_gadget() function call
  usb: dwc2: Add core state checking

John Youn (1):
  usb: dwc2: Enable LPM

Razmik Karapetyan (2):
  usb: dwc2: Add ACG support to the driver
  usb: dwc2: Backup and restore PCGCCTL1 register

Sevak Arakelyan (6):
  usb: dwc2: Rename GLPMCFG... definitions
  usb: dwc2: Add core parameters for LPM support
  usb: dwc2: gadget: Add functionality to exit from LPM L1 state
  usb: dwc2: gadget: LPM interrupt handler
  usb: dwc2: Enable LPM Transaction Received interrupt
  usb: dwc2: gadget: Configure the core to enable LPM

 drivers/usb/dwc2/core.c  |  16 ++
 drivers/usb/dwc2/core.h  |  27 ++
 drivers/usb/dwc2/core_intr.c | 125 ++-
 drivers/usb/dwc2/debugfs.c   |   5 ++
 drivers/usb/dwc2/gadget.c|  49 +++--
 drivers/usb/dwc2/hcd.c   |   8 +++
 drivers/usb/dwc2/hw.h|  43 ---
 drivers/usb/dwc2/params.c|  16 ++
 8 files changed, 265 insertions(+), 24 deletions(-)

-- 
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] usb: dwc3: add dwc3 glue layer for UniPhier SoCs

2018-01-24 Thread Felipe Balbi

Hi,

Kunihiko Hayashi  writes:
> Hello Felipe,
>
> Thank you for your comments.
>
> On Tue, 23 Jan 2018 15:12:36 +0200  wrote:
>
>> 
>> Hi,
>> 
>> Kunihiko Hayashi  writes:
>> > Add a specific glue layer for UniPhier SoC platform to support
>> > USB host mode. It manages hardware operating sequences to enable multiple
>> > clock gates and assert resets, and to prepare to use dwc3 controller
>> > on the SoC.
>> >
>> > This patch also handles the physical layer that has same register space
>> > as the glue layer, because it needs to integrate initialziation sequence
>> > between glue and phy.
>> >
>> > In case of some SoCs, since some initialization values for PHY are
>> > included in nvmem, this patch includes the way to get the values from 
>> > nvmem.
>> >
>> > It supports PXs2 and LD20 SoCs.
>> >
>> > Signed-off-by: Kunihiko Hayashi 
>> > Signed-off-by: Motoya Tanigawa 
>> > Signed-off-by: Masami Hiramatsu 
>> > ---
>> >  drivers/usb/dwc3/Kconfig |   9 +
>> >  drivers/usb/dwc3/Makefile|   1 +
>> >  drivers/usb/dwc3/dwc3-uniphier.c | 554 
>> > +++
>> >  3 files changed, 564 insertions(+)
>> >  create mode 100644 drivers/usb/dwc3/dwc3-uniphier.c
>
> ...snip...
>
>> > +
>> > +static void dwc3u_ssphy_testio_write(struct dwc3u_priv *priv, int port,
>> > +   u32 data)
>> 
>> anything with sshphy or hsphy in the name should probably be part of a
>> PHY driver using drivers/phy/ framework.
>
> I can try to separate phy control from this driver.
> However, phy registers belongs to "dwc3-glue" IO map area (65b0),
> and this area also contains a reset bit for "dwc3-core" hardware.
>
> Although the phy driver is called from dwc3-core driver,
> we need to deassert the reset bit before probing dwc3-core driver.
>
> As shown later, I think that it's difficut to determine the order of
> initializing the registers in this area.
>
>> > +static void dwc3u_vbus_disable(struct dwc3u_priv *priv)
>> > +{
>> > +  int i;
>> > +
>> > +  for (i = 0; i < priv->nvbus; i++) {
>> > +  dwc3u_maskwrite(priv, VBUS_CONTROL(i),
>> > +  DRVVBUS_REG_EN | DRVVBUS_REG,
>> > +  DRVVBUS_REG_EN | 0);
>> > +  }
>> > +}
>> 
>> drivers/regulator maybe?
>
> VBUS_CONTROL register is used for determing whether "dwc3-glue" hardware
> enables vbus connected with "regulator" hardware.
>
> The regulator driver should manage "regulator" hardware, and
> I don't think that the driver should manage this register.
>
>> > +static void dwc3u_reset_init(struct dwc3u_priv *priv)
>> > +{
>> > +  dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, 0);
>> > +  usleep_range(1000, 2000);
>> > +  dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, LINK_RESET);
>> > +}
>> > +
>> > +static void dwc3u_reset_clear(struct dwc3u_priv *priv)
>> > +{
>> > +  dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, 0);
>> > +}
>> 
>> drivers/reset ?
>
> The reset driver manages "sysctrl" IO map area in our SoC.
>
> RESET_CTL register belongs to "dwc3-glue" IO map area,
> and the kernel can't access this area until enabling usb clocks and
> deasserting usb resets in "sysctrl".
>
> I think that "dwc3-glue" register control should be separated from
> "sysctrl".

Just split your address space and treat your glue as a device with
several children:

glue@65b0 {
compatible = "foo"

phy@bar {
...
};

sysctrl@baz {
...
};

dwc3@foo {
compatible = "snps, dwc3";
...
};
};

Then you know that you can let dwc3/core.c handle the PHY for you. If we
need to teach dwc3/core.c about regulators, we can do that. But we don't
need SoC-specific hacks ;-)

-- 
balbi


signature.asc
Description: PGP signature


Re: [PATCH 2/4] usb: dwc3: add dwc3 glue layer for UniPhier SoCs

2018-01-24 Thread Kunihiko Hayashi
Hello Felipe,

Thank you for your comments.

On Tue, 23 Jan 2018 15:12:36 +0200  wrote:

> 
> Hi,
> 
> Kunihiko Hayashi  writes:
> > Add a specific glue layer for UniPhier SoC platform to support
> > USB host mode. It manages hardware operating sequences to enable multiple
> > clock gates and assert resets, and to prepare to use dwc3 controller
> > on the SoC.
> >
> > This patch also handles the physical layer that has same register space
> > as the glue layer, because it needs to integrate initialziation sequence
> > between glue and phy.
> >
> > In case of some SoCs, since some initialization values for PHY are
> > included in nvmem, this patch includes the way to get the values from nvmem.
> >
> > It supports PXs2 and LD20 SoCs.
> >
> > Signed-off-by: Kunihiko Hayashi 
> > Signed-off-by: Motoya Tanigawa 
> > Signed-off-by: Masami Hiramatsu 
> > ---
> >  drivers/usb/dwc3/Kconfig |   9 +
> >  drivers/usb/dwc3/Makefile|   1 +
> >  drivers/usb/dwc3/dwc3-uniphier.c | 554 
> > +++
> >  3 files changed, 564 insertions(+)
> >  create mode 100644 drivers/usb/dwc3/dwc3-uniphier.c

...snip...

> > +
> > +static void dwc3u_ssphy_testio_write(struct dwc3u_priv *priv, int port,
> > +u32 data)
> 
> anything with sshphy or hsphy in the name should probably be part of a
> PHY driver using drivers/phy/ framework.

I can try to separate phy control from this driver.
However, phy registers belongs to "dwc3-glue" IO map area (65b0),
and this area also contains a reset bit for "dwc3-core" hardware.

Although the phy driver is called from dwc3-core driver,
we need to deassert the reset bit before probing dwc3-core driver.

As shown later, I think that it's difficut to determine the order of
initializing the registers in this area.

> > +static void dwc3u_vbus_disable(struct dwc3u_priv *priv)
> > +{
> > +   int i;
> > +
> > +   for (i = 0; i < priv->nvbus; i++) {
> > +   dwc3u_maskwrite(priv, VBUS_CONTROL(i),
> > +   DRVVBUS_REG_EN | DRVVBUS_REG,
> > +   DRVVBUS_REG_EN | 0);
> > +   }
> > +}
> 
> drivers/regulator maybe?

VBUS_CONTROL register is used for determing whether "dwc3-glue" hardware
enables vbus connected with "regulator" hardware.

The regulator driver should manage "regulator" hardware, and
I don't think that the driver should manage this register.

> > +static void dwc3u_reset_init(struct dwc3u_priv *priv)
> > +{
> > +   dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, 0);
> > +   usleep_range(1000, 2000);
> > +   dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, LINK_RESET);
> > +}
> > +
> > +static void dwc3u_reset_clear(struct dwc3u_priv *priv)
> > +{
> > +   dwc3u_maskwrite(priv, RESET_CTL, LINK_RESET, 0);
> > +}
> 
> drivers/reset ?

The reset driver manages "sysctrl" IO map area in our SoC.

RESET_CTL register belongs to "dwc3-glue" IO map area,
and the kernel can't access this area until enabling usb clocks and
deasserting usb resets in "sysctrl".

I think that "dwc3-glue" register control should be separated from
"sysctrl".

> > +static int dwc3u_probe(struct platform_device *pdev)
> > +{
> > +   struct device *dev = >dev;
> > +   struct device_node *node;
> > +   struct dwc3u_priv *priv;
> > +   struct resource *res;
> > +   struct clk *clk;
> > +   int i, nr_clks;
> > +   int ret = 0;
> > +
> > +   priv = devm_kzalloc(>dev, sizeof(*priv), GFP_KERNEL);
> > +   if (!priv)
> > +   return -ENOMEM;
> > +
> > +   priv->data = of_device_get_match_data(dev);
> > +   if (WARN_ON(!priv->data))
> > +   return -EINVAL;
> > +
> > +   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +   priv->base = devm_ioremap_resource(dev, res);
> > +   if (IS_ERR(priv->base))
> > +   return PTR_ERR(priv->base);
> > +
> > +   priv->dev = dev;
> > +
> > +   node = dev->of_node;
> > +   nr_clks = of_clk_get_parent_count(node);
> > +   if (!nr_clks) {
> > +   dev_err(dev, "failed to get clock property\n");
> > +   return -ENODEV;
> > +   }
> > +
> > +   priv->clks = devm_kcalloc(priv->dev, nr_clks, sizeof(struct clk *),
> > + GFP_KERNEL);
> > +   if (!priv->clks)
> > +   return -ENOMEM;
> > +
> > +   for (i = 0; i < nr_clks; i++) {
> > +   clk = of_clk_get(node, i);
> > +   if (IS_ERR(clk)) {
> > +   ret = PTR_ERR(clk);
> > +   goto out_clk_disable;
> > +   }
> > +   ret = clk_prepare_enable(clk);
> > +   if (ret < 0) {
> > +   clk_put(clk);
> > +   goto out_clk_disable;
> > +   }
> > +   priv->clks[i] = clk;
> > +   priv->nclks = i;
> > +   }
> > +
> > +   priv->rst = devm_reset_control_array_get_optional_shared(priv->dev);
> > +   if 

Re: [PATCH 2/2] usb: dwc3: drd: Fix lock-up on ID change during system suspend/resume

2018-01-24 Thread Roger Quadros
On 23/01/18 14:41, Roger Quadros wrote:
> Hi Manu,
> 
> On 23/01/18 05:45, Manu Gautam wrote:
>> Hi,
>>
>>
>> On 1/22/2018 6:31 PM, Roger Quadros wrote:
>>> Adding/removing host/gadget controller before .pm_complete()
>>> causes a lock-up. Let's prevent any dual-role state change
>>> between .pm_prepare() and .pm_complete() to fix this.
>>
>> What kind of lock-up are you seeing? Some hardware lockup or software 
>> deadlock?
>> IMO using a freezable_wq for drd_work should address that?
>>
> 
> I was seeing a software deadlock. freezable_wq is a good idea. I'll try it 
> out.

using freezable_wq doesn't get rid of the deadlock.
If I use freezable_wq plus add some delay before I do a dwc3_host_init()
in the work function then it starts to work.

As dependence on delay looks fragile so I'll stick to the current implementation
based on .pm_prepare/complete().

-- 
cheers,
-roger

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. 
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB-C Devices only show up if connected at boot

2018-01-24 Thread Mike Lothian
On 24 January 2018 at 10:42, Oliver Neukum  wrote:
> Am Mittwoch, den 24.01.2018, 10:30 + schrieb Mike Lothian:
>
> echo "file $NAMEOFKERNELSOURCEFILEYOUWANT +mfp" > 
> /sys/kernel/debug/dynamic_debug/control
>
> HTH
> Oliver
>

OK so I'm enabling dynamic debugging in the kernel (DYNAMIC_DEBUG)

Which files would you like me to monitor?
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/6] USB: move many drivers to use DEVICE_ATTR_RW

2018-01-24 Thread Matthieu CASTET
Hi,

Le Tue, 23 Jan 2018 11:24:05 +0100,
Greg Kroah-Hartman  a écrit :

> Instead of "open coding" a DEVICE_ATTR() define, use the
> DEVICE_ATTR_RW() macro instead, which does everything properly instead.
> 
> This does require a few static functions to be renamed to work properly,
> but thanks to a script from Joe Perches, this was easily done.
> 
> Reported-by: Joe Perches 
> Cc: Matthieu CASTET 
> Cc: Stanislaw Gruszka 
> Cc: Peter Chen 
> Cc: Alan Stern 
> Cc: Mathias Nyman 
> Cc: Bin Liu 
> Cc: Felipe Balbi 
> Signed-off-by: Greg Kroah-Hartman 

For ueagle-atm.c part of 1/6 2/6 4/6 :

Acked-by: Matthieu CASTET 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB-C Devices only show up if connected at boot

2018-01-24 Thread Oliver Neukum
Am Mittwoch, den 24.01.2018, 10:30 + schrieb Mike Lothian:
> On 24 January 2018 at 10:04, Oliver Neukum  wrote:
> > 
> > Am Mittwoch, den 24.01.2018, 09:36 + schrieb Mike Lothian:
> > > 
> > > 
> > > I've played around with this some more, if the device is connected
> > > after boot nothing shows when it's plugged in
> > > 
> > > I did however get more messages out when I disconnected the device
> > > after booting with it (see attached)
> > > 
> > 
> > That is the normal case of PCI disconnect of XHCI and Thunderbolt
> > stuff. It confirms that you have the Intel chipsets that does
> > a PCI disconnect while nothing is plugged in.
> > 
> > This really needs PCI hotplugging to work.
> > Could you activate dynamic debugging for PCI and ACPI?
> > 
> > You might, if your BIOS is crap, try only native hotplug
> > with ACPI hotplug disabled.
> > 
> > Regards
> > Oliver
> > 
> 
> Still nothing if I connect the device with PCI Hotplugging with no
> ACPI Hotplugging
> 
> What do I need to do to activate dynamic debugging?

echo "file $NAMEOFKERNELSOURCEFILEYOUWANT +mfp" > 
/sys/kernel/debug/dynamic_debug/control

HTH
Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/2] usb/gadget: Add driver for Aspeed SoC virtual hub (fwd)

2018-01-24 Thread Julia Lawall
Hello,

I can't tell from looking at the code whether the missing unlock when
!d->wakeup_en is intentional.

It may also be worth checking the report on line 359 about the comparison
with the unsigned value.

julia

-- Forwarded message --
Date: Wed, 24 Jan 2018 09:09:59 +0800
From: kbuild test robot <fengguang...@intel.com>
To: kbu...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
Subject: Re: [PATCH v3 2/2] usb/gadget: Add driver for Aspeed SoC virtual hub

CC: kbuild-...@01.org
In-Reply-To: <2018012716.7039-2-b...@kernel.crashing.org>
References: <2018012716.7039-2-b...@kernel.crashing.org>
TO: Benjamin Herrenschmidt <b...@kernel.crashing.org>
CC: linux-usb@vger.kernel.org
CC: Greg KH <g...@kroah.com>, Joel Stanley <joel.stan...@au1.ibm.com>, Andrew 
Jeffery <and...@aj.id.au>, Felipe Balbi <ba...@kernel.org>, Benjamin 
Herrenschmidt <b...@kernel.crashing.org>

Hi Benjamin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on balbi-usb/next]
[also build test WARNING on v4.15-rc9 next-20180119]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Benjamin-Herrenschmidt/usb-gadget-Add-an-EP-dispose-callback-for-EP-lifetime-tracking/20180124-065635
base:   https://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git next
:: branch date: 2 hours ago
:: commit date: 2 hours ago

>> drivers/usb/gadget/udc/aspeed-vhub/dev.c:269:1-7: preceding lock on line 257
--
>> drivers/usb/gadget/udc/aspeed-vhub/core.c:359:5-14: WARNING: Unsigned 
>> expression compared with zero: vhub -> irq < 0

# 
https://github.com/0day-ci/linux/commit/7d6ae8cb6c74a0113a1d122c34158d782d0edb59
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 7d6ae8cb6c74a0113a1d122c34158d782d0edb59
vim +269 drivers/usb/gadget/udc/aspeed-vhub/dev.c

7d6ae8cb Benjamin Herrenschmidt 2018-01-23  250
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  251  static int 
ast_vhub_udc_wakeup(struct usb_gadget* gadget)
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  252  {
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  253 struct ast_vhub_dev *d 
= to_ast_dev(gadget);
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  254 unsigned long flags;
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  255 int rc = -EINVAL;
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  256
7d6ae8cb Benjamin Herrenschmidt 2018-01-23 @257 
spin_lock_irqsave(>vhub->lock, flags);
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  258 if (!d->wakeup_en)
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  259 goto err;
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  260
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  261 DDBG(d, "Device 
initiated wakeup\n");
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  262
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  263 /* Wakeup the host */
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  264 
ast_vhub_hub_wake_all(d->vhub);
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  265
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  266 
spin_unlock_irqrestore(>vhub->lock, flags);
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  267 rc = 0;
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  268   err:
7d6ae8cb Benjamin Herrenschmidt 2018-01-23 @269 return rc;
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  270  }
7d6ae8cb Benjamin Herrenschmidt 2018-01-23  271

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB-C Devices only show up if connected at boot

2018-01-24 Thread Mike Lothian
On 24 January 2018 at 10:04, Oliver Neukum  wrote:
> Am Mittwoch, den 24.01.2018, 09:36 + schrieb Mike Lothian:
>>
>> I've played around with this some more, if the device is connected
>> after boot nothing shows when it's plugged in
>>
>> I did however get more messages out when I disconnected the device
>> after booting with it (see attached)
>>
>
> That is the normal case of PCI disconnect of XHCI and Thunderbolt
> stuff. It confirms that you have the Intel chipsets that does
> a PCI disconnect while nothing is plugged in.
>
> This really needs PCI hotplugging to work.
> Could you activate dynamic debugging for PCI and ACPI?
>
> You might, if your BIOS is crap, try only native hotplug
> with ACPI hotplug disabled.
>
> Regards
> Oliver
>

Still nothing if I connect the device with PCI Hotplugging with no
ACPI Hotplugging

What do I need to do to activate dynamic debugging?
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[no subject]

2018-01-24 Thread Davidson Sally
-- 
Guten Tag:
Sind Sie in finanziellen Schwierigkeiten? Benötigen Sie ein Darlehen
mit niedrigem Zinssatz? Wenn ja, kontaktieren Sie uns jetzt mit
Ihr Name:
Land:
Darlehensbetrag:
Telefonnummer:
Darlehens Dauer:
Staat:
Sex:
Beruf:
Monatliches Einkommen:
Alter:
Privatadresse:
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB-C Devices only show up if connected at boot

2018-01-24 Thread Oliver Neukum
Am Mittwoch, den 24.01.2018, 09:36 + schrieb Mike Lothian:
> 
> I've played around with this some more, if the device is connected
> after boot nothing shows when it's plugged in
> 
> I did however get more messages out when I disconnected the device
> after booting with it (see attached)
> 

That is the normal case of PCI disconnect of XHCI and Thunderbolt
stuff. It confirms that you have the Intel chipsets that does
a PCI disconnect while nothing is plugged in.

This really needs PCI hotplugging to work.
Could you activate dynamic debugging for PCI and ACPI?

You might, if your BIOS is crap, try only native hotplug
with ACPI hotplug disabled.

Regards
Oliver

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB-C Devices only show up if connected at boot

2018-01-24 Thread Mike Lothian
On Wed, 24 Jan 2018 at 08:46 Greg KH  wrote:
>
> >
> > Hi
> >
> > PCI Hotplug and ACPI Hotplug are disabled on my system due to bug
> > https://bugzilla.kernel.org/show_bug.cgi?id=112121 where by my NVMe
> > drive would disappear from the system after suspend making my system
> > inoperable
>
> Ah, well that explains why this doesn't work, you need that in order to
> have the PCI device show back up again when you plug a device in.
>
> > I tried enabling PCI Hotplug, PCIE Hotplug and ACPI Hotplug - the
> > USB-C device still didn't appear when plugged in
>
> Really?  No kernel messages at all when you plug a device in?
>
> > The suspend bug still remained and when trying with
> > CONFIG_ACPI_PCI_SLOT the whole system refused to boot (unable to find
> > systemd), I'm guessing the hard drive didn't enumerate
>
> It sounds like your machine has a lot of ACPI issues :(
>
> greg k-h


Hi

I've played around with this some more, if the device is connected
after boot nothing shows when it's plugged in

I did however get more messages out when I disconnected the device
after booting with it (see attached)

Regards

Mike


dmesg.extra.info.xz
Description: application/xz


Re: [PATCH 4.9] usbip: Fix implicit fallthrough warning

2018-01-24 Thread Greg KH
On Tue, Jan 23, 2018 at 07:32:11PM -0700, Shuah Khan wrote:
> From: Jonathan Dieter 
> 
> Upstream commit cfd6ed4537a9 ("usbip: Fix implicit fallthrough warning")
> 
> GCC 7 now warns when switch statements fall through implicitly, and with
> -Werror enabled in configure.ac, that makes these tools unbuildable.
> 
> We fix this by notifying the compiler that this particular case statement
> is meant to fall through.
> 
> Reviewed-by: Peter Senna Tschudin 
> Signed-off-by: Jonathan Dieter 
> Signed-off-by: Greg Kroah-Hartman 
> Signed-off-by: Shuah Khan 
> ---
>  tools/usb/usbip/src/usbip.c | 2 ++
>  1 file changed, 2 insertions(+)

All of these usbip tools patches are now queued up, thanks!

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4.9] usbip: prevent vhci_hcd driver from leaking a socket pointer address

2018-01-24 Thread Greg KH
On Tue, Jan 23, 2018 at 07:30:06PM -0700, Shuah Khan wrote:
> commit 2f2d0088eb93 ("usbip: prevent vhci_hcd driver from leaking a
> socket pointer address")

Now queued up for 4.4 and 4.9, thanks.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB-C Devices only show up if connected at boot

2018-01-24 Thread Greg KH
On Wed, Jan 24, 2018 at 08:39:10AM +, Mike Lothian wrote:
> On Wed, 24 Jan 2018 at 04:07 Greg KH  wrote:
> >
> > On Tue, Jan 23, 2018 at 05:43:27PM +, Mike Lothian wrote:
> > > On Tue, 23 Jan 2018 at 17:30 Greg KH  wrote:
> > > >
> > > > On Tue, Jan 23, 2018 at 05:12:03PM +, Mike Lothian wrote:
> > > > > Hi
> > > > >
> > > > > I raised https://bugzilla.kernel.org/show_bug.cgi?id=198557 but was
> > > > > informed by Greg bugs should be raised on the mailing list not in
> > > > > bugzilla
> > > > >
> > > > > So USB-C devices only show up in dmesg or for use if they are
> > > > > connected during boot
> > > > >
> > > > > Once booted and the device is disconnected the following message
> > > > > appears in the dmesg:
> > > > >
> > > > > [  100.814687] usb 3-1: USB disconnect, device number 3
> > > > > [  100.882840] xhci_hcd :39:00.0: xHCI host controller not
> > > > > responding, assume dead
> > > > > [  100.882843] xhci_hcd :39:00.0: HC died; cleaning up
> > > > >
> > > > > No further connections or disconnections display anything further in
> > > > > the dmesg, the device works fine if connected via USB-A
> > > > >
> > > > > I've witnessed this behaviour since getting the laptop at the end of
> > > > > 2015 so this isn't a regression
> > > >
> > > > Is there a BIOS update for the laptop?  This has been seen a lot in the
> > > > past on lots of different laptops but was always resolved by the BIOS
> > > > update (the latest one for mine also updates the xhci controller as
> > > > well.)
> > > >
> > > > thanks,
> > > >
> > > > greg k-h
> > >
> > >
> > > Hi
> > >
> > > I've applied all BIOS updates for my laptop including the pulled one
> > > for Spectre/Meltdown & ME bugs the other week
> > > http://www.dell.com/support/home/uk/en/ukdhs1/product-support/servicetag/8k5w662/drivers
> > >
> > > If it helps, I don't have this issue in Windows but I rarely have it 
> > > booted
> > >
> > > I thought it might have something to do with an ACPI failure (see bug
> > > https://bugzilla.kernel.org/show_bug.cgi?id=198051)
> >
> > I can't see web links at the moment, but are you sure you have PCI
> > hotplug enabled in your kernel?  Same for ACPI PCI hotplug?  That's how
> > the controller usually shows up in the system, and that's a PCI issue,
> > not a USB issue.
> >
> > thanks,
> >
> > greg k-h
> 
> Hi
> 
> PCI Hotplug and ACPI Hotplug are disabled on my system due to bug
> https://bugzilla.kernel.org/show_bug.cgi?id=112121 where by my NVMe
> drive would disappear from the system after suspend making my system
> inoperable

Ah, well that explains why this doesn't work, you need that in order to
have the PCI device show back up again when you plug a device in.

> I tried enabling PCI Hotplug, PCIE Hotplug and ACPI Hotplug - the
> USB-C device still didn't appear when plugged in

Really?  No kernel messages at all when you plug a device in?

> The suspend bug still remained and when trying with
> CONFIG_ACPI_PCI_SLOT the whole system refused to boot (unable to find
> systemd), I'm guessing the hard drive didn't enumerate

It sounds like your machine has a lot of ACPI issues :(

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 05/99] xarray: Add definition of struct xarray

2018-01-24 Thread Paul Bolle
Mathhew,

Just a minor question.

On Wed, 2018-01-17 at 12:20 -0800, Matthew Wilcox wrote:
> This is a direct replacement for struct radix_tree_root.  Some of the
> struct members have changed name; convert those, and use a #define so
> that radix_tree users continue to work without change.
> 
> Signed-off-by: Matthew Wilcox 

> --- a/include/linux/xarray.h
> +++ b/include/linux/xarray.h
> @@ -10,6 +10,8 @@
>   */
>  
>  #include 
> +#include 
> +#include 

The top Makefile includes linux/kconfig.h globally. (See the odd USERINCLUDE
variable, which is actually part of the LINUXINCLUDE variable, but split off
to make things confusing.)

Why do you need to include linux/kconfig.h here?

>  #include 
>  #include 

Thanks,


Paul Bolle
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: USB-C Devices only show up if connected at boot

2018-01-24 Thread Mike Lothian
On Wed, 24 Jan 2018 at 04:07 Greg KH  wrote:
>
> On Tue, Jan 23, 2018 at 05:43:27PM +, Mike Lothian wrote:
> > On Tue, 23 Jan 2018 at 17:30 Greg KH  wrote:
> > >
> > > On Tue, Jan 23, 2018 at 05:12:03PM +, Mike Lothian wrote:
> > > > Hi
> > > >
> > > > I raised https://bugzilla.kernel.org/show_bug.cgi?id=198557 but was
> > > > informed by Greg bugs should be raised on the mailing list not in
> > > > bugzilla
> > > >
> > > > So USB-C devices only show up in dmesg or for use if they are
> > > > connected during boot
> > > >
> > > > Once booted and the device is disconnected the following message
> > > > appears in the dmesg:
> > > >
> > > > [  100.814687] usb 3-1: USB disconnect, device number 3
> > > > [  100.882840] xhci_hcd :39:00.0: xHCI host controller not
> > > > responding, assume dead
> > > > [  100.882843] xhci_hcd :39:00.0: HC died; cleaning up
> > > >
> > > > No further connections or disconnections display anything further in
> > > > the dmesg, the device works fine if connected via USB-A
> > > >
> > > > I've witnessed this behaviour since getting the laptop at the end of
> > > > 2015 so this isn't a regression
> > >
> > > Is there a BIOS update for the laptop?  This has been seen a lot in the
> > > past on lots of different laptops but was always resolved by the BIOS
> > > update (the latest one for mine also updates the xhci controller as
> > > well.)
> > >
> > > thanks,
> > >
> > > greg k-h
> >
> >
> > Hi
> >
> > I've applied all BIOS updates for my laptop including the pulled one
> > for Spectre/Meltdown & ME bugs the other week
> > http://www.dell.com/support/home/uk/en/ukdhs1/product-support/servicetag/8k5w662/drivers
> >
> > If it helps, I don't have this issue in Windows but I rarely have it booted
> >
> > I thought it might have something to do with an ACPI failure (see bug
> > https://bugzilla.kernel.org/show_bug.cgi?id=198051)
>
> I can't see web links at the moment, but are you sure you have PCI
> hotplug enabled in your kernel?  Same for ACPI PCI hotplug?  That's how
> the controller usually shows up in the system, and that's a PCI issue,
> not a USB issue.
>
> thanks,
>
> greg k-h

Hi

PCI Hotplug and ACPI Hotplug are disabled on my system due to bug
https://bugzilla.kernel.org/show_bug.cgi?id=112121 where by my NVMe
drive would disappear from the system after suspend making my system
inoperable

I tried enabling PCI Hotplug, PCIE Hotplug and ACPI Hotplug - the
USB-C device still didn't appear when plugged in

The suspend bug still remained and when trying with
CONFIG_ACPI_PCI_SLOT the whole system refused to boot (unable to find
systemd), I'm guessing the hard drive didn't enumerate

Regards

Mike
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: gadget: f_fs: Process all descriptors during bind

2018-01-24 Thread Jack Pham
During _ffs_func_bind(), the received descriptors are evaluated
to prepare for binding with the gadget in order to allocate
endpoints and optionally set up OS descriptors. However, the
high- and super-speed descriptors are only parsed based on
whether the gadget_is_dualspeed() and gadget_is_superspeed()
calls are true, respectively.

This is a problem in case a userspace program always provides
all of the {full,high,super,OS} descriptors when configuring a
function. Then, for example if a gadget device is not capable
of SuperSpeed, the call to ffs_do_descs() for the SS descriptors
is skipped, resulting in an incorrect offset calculation for
the vla_ptr when moving on to the OS descriptors that follow.
This causes ffs_do_os_descs() to fail as it is now looking at
the SS descriptors' offset within the raw_descs buffer instead.

_ffs_func_bind() should evaluate the descriptors unconditionally,
so remove the checks for gadget speed.

Fixes: f0175ab51993 ("usb: gadget: f_fs: OS descriptors support")
Cc: sta...@vger.kernel.org
Co-Developed-by: Mayank Rana 
Signed-off-by: Mayank Rana 
Signed-off-by: Jack Pham 
---
 drivers/usb/gadget/function/f_fs.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/gadget/function/f_fs.c 
b/drivers/usb/gadget/function/f_fs.c
index b6cf5ab..5f2dafb5 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -2976,10 +2976,8 @@ static int _ffs_func_bind(struct usb_configuration *c,
struct ffs_data *ffs = func->ffs;
 
const int full = !!func->ffs->fs_descs_count;
-   const int high = gadget_is_dualspeed(func->gadget) &&
-   func->ffs->hs_descs_count;
-   const int super = gadget_is_superspeed(func->gadget) &&
-   func->ffs->ss_descs_count;
+   const int high = !!func->ffs->hs_descs_count;
+   const int super = !!func->ffs->ss_descs_count;
 
int fs_len, hs_len, ss_len, ret, i;
struct ffs_ep *eps_ptr;
-- 
2.9.1.200.gb1ec08f

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html