Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7851047ybi; Mon, 22 Jul 2019 22:10:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqw60XuXRC/cnO0orsZIy1IoU/bZUEyQO+x+abVv+lRAYSxI+rYxr2yNl0ySfHclBn2EVsnE X-Received: by 2002:a62:14c4:: with SMTP id 187mr3760669pfu.241.1563858616380; Mon, 22 Jul 2019 22:10:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563858616; cv=none; d=google.com; s=arc-20160816; b=m7ORwEluopqkvyUuAERZpWGcxiBvvbbBonRb+9z5uTqiBlLrR8eOLHMWOQHVtkeiCm 5i2v/Sx1a//ENe/6dfTSVW8NgvSjA9AQltkY6QH5EGWR0j1NU5mlllYQIJGJARDokj3J yQtAcFBeKF8HkLGVDL6j//pP2uqbUF/EElfZrsdh2z+1BKhru+L/bGI6HcxEtW+V85L+ eIED1tWoH98TvTrROBDnSVR7zZCTgLW0wOwiAdL9Bpu4PD+I3BXZ+toDOvW8m1E/GbZ9 t4DUQrhkBtxkf+xQnFBrXidGniIhOIfMzz2d2qXHamkHdfw/dFrL7JDOhC/HvP5DoDgo FuMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RBH9NIjlTcz6w4LQP6KUauPzdnEDTuEqG8uCadh2V7Y=; b=OIeZTy1UY2chkdWwSROS//u9V9MapuYpz28C3WY64BDsBam1joT3xtsCY44O7d5w2r c8IxlT5aPnT4wHDmDFja3xCgCBlBEiN4NqOxvjKe3yOmER2zqiKalm4yymrSsjri95Xl 0ihba7t3jx/IZd2stVjjqOzOuiyUpaNwcJjVJpR86JkhsVlpMEZkd9GdlAY4QQsuGFrn QptaAU4EEA5VW8Pu+gcZyftS3c2e0MaKcc3os4NKtIhwuThY3Ovh00+2US+EUsd+ibgD uVSxYn5V1cB7ouHdJ+Zq+gKUpvtKDLO0CtSwOG59OhGkka9kI+OYxMZ6UlAVT6POHpW8 TuNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Thqb/v9o"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k133si10539140pgc.425.2019.07.22.22.09.59; Mon, 22 Jul 2019 22:10:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Thqb/v9o"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728564AbfGVTAt (ORCPT + 99 others); Mon, 22 Jul 2019 15:00:49 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:35002 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbfGVTAt (ORCPT ); Mon, 22 Jul 2019 15:00:49 -0400 Received: by mail-io1-f67.google.com with SMTP id m24so76367816ioo.2; Mon, 22 Jul 2019 12:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RBH9NIjlTcz6w4LQP6KUauPzdnEDTuEqG8uCadh2V7Y=; b=Thqb/v9opT4RgtSlBn8G7N0zOcK1ag8GBp6HPcrEvHcGc825fInQRAIbtEyY6TOyQX OjwvkJJH3hMBlWe2Q4luG2wAvSZSeAC868gukwHrydSCqGXgN8XnBcW/Na1NulFslp6U C7VPDptL8vEv95huLfZmv0Kq73HXmz2C/3ixLVx+tQHXrOI9YLTbUHjd+ZO+jn7Uo50T yA885eWYoCUP/J7IuSeiWKLF3O1zVPVTjqHqUWMR0YlnDe70o/JQDkjZlBg3hjWva58J 3+AC2lMMZkERGNFgv9t90jr9E9Xor1A9g378FxeRbRlZTqWLNvGoXDRLlrvlHR2WhRwG f0mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RBH9NIjlTcz6w4LQP6KUauPzdnEDTuEqG8uCadh2V7Y=; b=hQ8Xfeot23yyGTGw0Es1htsru7QSnAg00GGIkhlm9Byoe0BGPYgHo5OzTKcmMwW/lr 29m6QEIvwNdlI0ziv+LtZ+4oKE8uYcDTJ4a77JKjPWHczfBtBCQh4UZd/qNSgnpf2wXR LtXOxvrsepbYDP2VDbWd7VbebvaJUaSyZYa3fTZ8pNji4qJ8dUoc0r4wmq6L0ciA1Wu3 rfMa7jFtFP56T5Fc3Ca+Gzfg5u/YH/J35x97RzBoEIQ2+ZWj3sRjTmAnm04RT40waAOe 3gPTUy1VGBGWZVGEQ7DVrMIq5MZEqaRbZG6UEd6SeNgvdCCkHZOcp0LcbeHR61791HS8 46Kg== X-Gm-Message-State: APjAAAXWm1VIYRjxi2ixl/u/kgm/4CGoQnLPX4+P7paqDfKoLew56zC8 pKIx4llIiRfCXYcpEYzZRWe1unwEI65XM1/t5IA= X-Received: by 2002:a6b:b3c1:: with SMTP id c184mr20876106iof.222.1563822047914; Mon, 22 Jul 2019 12:00:47 -0700 (PDT) MIME-Version: 1.0 References: <20190719081212.9249-1-m.szyprowski@samsung.com> <20190719081316.9298-1-m.szyprowski@samsung.com> In-Reply-To: <20190719081316.9298-1-m.szyprowski@samsung.com> From: Anand Moon Date: Tue, 23 Jul 2019 00:30:37 +0530 Message-ID: Subject: Re: [PATCH v2 1/2] usb: core: phy: add support for PHY calibration To: Marek Szyprowski Cc: Linux USB Mailing List , linux-samsung-soc@vger.kernel.org, Linux Kernel , Greg Kroah-Hartman , Mathias Nyman , Felipe Balbi , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Jochen Sprickerhof Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marek, On Fri, 19 Jul 2019 at 13:43, Marek Szyprowski wrote: > > Some PHYs (for example Exynos5 USB3.0 DRD PHY) require calibration to be > done after every USB HCD reset. Generic PHY framework has been already > extended with phy_calibrate() function in commit 36914111e682 ("drivers: > phy: add calibrate method"). This patch adds support for it to generic > PHY handling code in USB HCD core. > Tested on my XU3 / XU4 / HC1 Tested-by: Anand Moon > Signed-off-by: Marek Szyprowski > --- > drivers/usb/core/hcd.c | 7 +++++++ > drivers/usb/core/phy.c | 21 +++++++++++++++++++++ > drivers/usb/core/phy.h | 1 + > 3 files changed, 29 insertions(+) > > diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c > index 88533938ce19..b89936c1df23 100644 > --- a/drivers/usb/core/hcd.c > +++ b/drivers/usb/core/hcd.c > @@ -2291,6 +2291,9 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg) > hcd->state = HC_STATE_RESUMING; > status = hcd->driver->bus_resume(hcd); > clear_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags); > + if (status == 0) > + status = usb_phy_roothub_calibrate(hcd->phy_roothub); > + > if (status == 0) { > struct usb_device *udev; > int port1; > @@ -2864,6 +2867,10 @@ int usb_add_hcd(struct usb_hcd *hcd, > } > hcd->rh_pollable = 1; > > + retval = usb_phy_roothub_calibrate(hcd->phy_roothub); > + if (retval) > + goto err_hcd_driver_setup; > + > /* NOTE: root hub and controller capabilities may not be the same */ > if (device_can_wakeup(hcd->self.controller) > && device_can_wakeup(&hcd->self.root_hub->dev)) > diff --git a/drivers/usb/core/phy.c b/drivers/usb/core/phy.c > index 7580493b867a..fb1588e7c282 100644 > --- a/drivers/usb/core/phy.c > +++ b/drivers/usb/core/phy.c > @@ -151,6 +151,27 @@ int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, > } > EXPORT_SYMBOL_GPL(usb_phy_roothub_set_mode); > > +int usb_phy_roothub_calibrate(struct usb_phy_roothub *phy_roothub) > +{ > + struct usb_phy_roothub *roothub_entry; > + struct list_head *head; > + int err; > + > + if (!phy_roothub) > + return 0; > + > + head = &phy_roothub->list; > + > + list_for_each_entry(roothub_entry, head, list) { > + err = phy_calibrate(roothub_entry->phy); > + if (err) > + return err; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(usb_phy_roothub_calibrate); > + > int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub) > { > struct usb_phy_roothub *roothub_entry; > diff --git a/drivers/usb/core/phy.h b/drivers/usb/core/phy.h > index dad564e2d2d4..20a267cd986b 100644 > --- a/drivers/usb/core/phy.h > +++ b/drivers/usb/core/phy.h > @@ -18,6 +18,7 @@ int usb_phy_roothub_exit(struct usb_phy_roothub *phy_roothub); > > int usb_phy_roothub_set_mode(struct usb_phy_roothub *phy_roothub, > enum phy_mode mode); > +int usb_phy_roothub_calibrate(struct usb_phy_roothub *phy_roothub); > int usb_phy_roothub_power_on(struct usb_phy_roothub *phy_roothub); > void usb_phy_roothub_power_off(struct usb_phy_roothub *phy_roothub); > > -- > 2.17.1 >