Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1398816pxj; Fri, 18 Jun 2021 06:20:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzprJMio+1Ygi4XbGpr8+a2aqvRly2+RFDaz64drRRo6K82pEFSk30AS4zg9SR6X3TBLa1g X-Received: by 2002:a02:ccf2:: with SMTP id l18mr3315298jaq.128.1624022419909; Fri, 18 Jun 2021 06:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624022419; cv=none; d=google.com; s=arc-20160816; b=U1sXKt+17uX8DE2+xeb299vTwTUQY4RwfShWEUq2K6576xqjEhMRrRO9uRmFHwIjRc LT1y/rYAzkpU4GmEUBu4X5f4sgyWawnenyl+l3lsbd4pEzHXkYbRLGeryKn009qw2wZN loCiKdHq4GOFz/qiKA6V4npiACEz1y70qinjFTs3DdN0fSsERa8b2lHcZ6N9LQU1Z4rL 7wHLTXrUvyVQ4Sia9gVlJoOyfQwb5uGIijHEzbErzaWMSl3lwtUmdvgjPAK1Ra8QdXfS 1WLYvDtPjRFDN6hMnh6JtaZTVqyn1YnquLArMnXNEqWMzqGwNr9VK7FhK+mgYA2Mn0F2 le6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=P8V4PPjDC1gz6JriGuuoHP1QKqxpavt/zsBJP5m9gcE=; b=1EhErS78Dz0X1XM18JBljTixa+3Ku83UkpXbVwpEJ/f8gh1r0e4P1gGf4bldHqjkPM PwDzhMHZaPMN5Ti2haNMV9PrbV4OEe+bj0TZGkl7wwA5u3WL6mntSMO/SoVzAxaaDQqT oaf2E2YP2tsd4nSYFkILGixrznh3HX9Y/+YblkhgBzF30ByOTG/Pkq0TD4ULDtccRCb0 hNSvfZs3pBbQdgg9HepifmkD51CZGI+AhEgvb1qaUzI2UTX6qJdookeMVNw69nLOFV3x Tr0pSJU3Gw2Jfr6G0UNvi4Qdatfagr9CWeyjfXhZwM7zfEVxv0CQ4TPr7jD6lpiFVYIK Huqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e2Cic6Cb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id k6si1953493iow.10.2021.06.18.06.20.07; Fri, 18 Jun 2021 06:20:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=e2Cic6Cb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S232298AbhFRNV3 (ORCPT + 99 others); Fri, 18 Jun 2021 09:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229877AbhFRNV2 (ORCPT ); Fri, 18 Jun 2021 09:21:28 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96E7AC061574 for ; Fri, 18 Jun 2021 06:19:18 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id ji1so9783436ejc.4 for ; Fri, 18 Jun 2021 06:19:18 -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=P8V4PPjDC1gz6JriGuuoHP1QKqxpavt/zsBJP5m9gcE=; b=e2Cic6CbgHhdrBDz14ZdYtzulhyV+7dKvI09WXaTR0dOvZ5PLsNABW3otQIIncHt1J gO1LWIfD2zc2qKiF/HubchlTc6kC2PEV7FHsWhO+5zL0y/0c8EOsIUtZTfE/4wReDKZf t6czmTxN9sU1EgNvlESX6xVb/wGfM4VDXD8KMkTOnIiXJGqPaGetbyWordY1KAkyhbj6 pC+7CGaUmLEeS/bnJFapglFMEoG+xTPbcKz0PaZBGQEiItiXF2wtUmPlfV6jCSNx3D/j LQ4ZNDBIzH1ojYb7mNzFMlGjU4sEADW7/IDd1oZ/Y2AeX8YclE0ZZjhbCcYmsDG7xFbz cc7A== 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=P8V4PPjDC1gz6JriGuuoHP1QKqxpavt/zsBJP5m9gcE=; b=fbG0XhcWA/MzCPibyJkUNPDXyoqvb3fUqUZn5LmiPNTTOPcGlHKuhAjw660PlWCgEt d3dqSNhU5jdfbIQfsqMB1h60iP6y6pY/IulHEOOMRSlCpVTItpxhk/x5yEj5MQs8cCGZ S1zPZX/dcnQa7HVIauFk1ZX/4A3j7BM2btMSfiZ9u8SOmG0R5lHoFXok/yKRaR7fAC/s HTV+S5BpFKi2mlFGYM9dld8mohR3+yte1DKPrzInpFLhGhZGLVAlYGFvq66JSlTYVwmo PUwNojCnTlq7ZolPu9xKkkp5FbjDPyVQv642cIuC8XbMZgdTSZJn/PPBRmlS7Na2ptuj moJg== X-Gm-Message-State: AOAM533e0rm0Ry5V/0XQqu1MnqEmDJEWKSwLj0kQGnxZZ7LYKTJ98Dth F+Qh/0yA4c2ic7bTuY3UGGeVXQIct1jJIvnSJQM= X-Received: by 2002:a17:907:7848:: with SMTP id lb8mr11322909ejc.494.1624022357121; Fri, 18 Jun 2021 06:19:17 -0700 (PDT) MIME-Version: 1.0 References: <20210617194154.2397-1-linux.amoon@gmail.com> <20210617194154.2397-5-linux.amoon@gmail.com> In-Reply-To: From: Anand Moon Date: Fri, 18 Jun 2021 18:49:05 +0530 Message-ID: Subject: Re: [RFCv1 4/8] phy: amlogic: meson8b-usb2: Use phy set_mode callback function To: Martin Blumenstingl Cc: Kishon Vijay Abraham I , Vinod Koul , Neil Armstrong , Kevin Hilman , Jerome Brunet , Philipp Zabel , linux-phy@lists.infradead.org, linux-arm-kernel , linux-amlogic@lists.infradead.org, Linux Kernel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi Martin. Thanks for your review comments. On Fri, 18 Jun 2021 at 03:46, Martin Blumenstingl wrote: > > Hi Anand, > > On Thu, Jun 17, 2021 at 9:43 PM Anand Moon wrote: > > > > Reorder the code for phy set_mode in .set_mode callback function. > > For now configure the phy in host mode. > as mentioned in the cover-letter: to my knowledge these register bits > are "static" > The settings for dr_mode == USB_DR_MODE_HOST mainly apply to the > second PHY (usb1_phy) > > [...] > > +static int phy_meson8b_usb2_setmode(struct phy *phy, enum phy_mode mode, > > + int submode) > > { > > struct phy_meson8b_usb2_priv *priv = phy_get_drvdata(phy); > > u32 reg; > > > > + switch (mode) { > > + case PHY_MODE_USB_HOST: > > + if (priv->match->host_enable_aca) { > > + regmap_update_bits(priv->regmap, REG_ADP_BC, > > + REG_ADP_BC_ACA_ENABLE, > > + REG_ADP_BC_ACA_ENABLE); > > + > > + udelay(ACA_ENABLE_COMPLETE_TIME); > > + > > + regmap_read(priv->regmap, REG_ADP_BC, ®); > > + if (reg & REG_ADP_BC_ACA_PIN_FLOAT) { > > + dev_warn(&phy->dev, "USB ID detect failed!\n"); > > + return -EINVAL; > > + } > > + } > > + break; > > + default: > > + dev_warn(&phy->dev, "USB ID detect failed to setnode! %d\n", mode); > > + return -EINVAL; > I have tested this driver already with PHY_MODE_USB_DEVICE (on my > Odroid-C1) so I don't see why we should drop support for this > Also if we want runtime mode switching in this driver then we would > need to undo the changes from "case PHY_MODE_USB_HOST" above > > I suggest dropping this patch until we know for sure if and which > registers need to be updated based on the DR mode. Yes, I have observed this, Can you give these small changes a try? With the below changes, I got the PHY_MODE_USB_DEVICE support working. Here is the boot log of odroid c1+ [0] https://pastebin.com/pCXLS5Vu $ lsusb -t /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M |__ Port 3: Dev 4, If 0, Class=Mass Storage, Driver=usb-storage, 480M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc2/1p, 480M |__ Port 1: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 12M |__ Port 1: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 12M git diff drivers/phy/amlogic/phy-meson8b-usb2.c diff --git a/drivers/phy/amlogic/phy-meson8b-usb2.c b/drivers/phy/amlogic/phy-meson8b-usb2.c index bd624781d914..9b79e86d7a0d 100644 --- a/drivers/phy/amlogic/phy-meson8b-usb2.c +++ b/drivers/phy/amlogic/phy-meson8b-usb2.c @@ -204,6 +204,22 @@ static int phy_meson8b_usb2_setmode(struct phy *phy, enum phy_mode mode, } } break; + case PHY_MODE_USB_DEVICE: + case PHY_MODE_USB_OTG: + regmap_update_bits(priv->regmap, REG_ADP_BC, + REG_ADP_BC_DCD_ENABLE, + REG_ADP_BC_DCD_ENABLE); + + udelay(ACA_ENABLE_COMPLETE_TIME); + + regmap_read(priv->regmap, REG_ADP_BC, ®); + if (reg & REG_ADP_BC_ACA_PIN_FLOAT) { + dev_warn(&phy->dev, "USB ID detect failed!\n"); + return -EINVAL; + } + regmap_update_bits(priv->regmap, REG_ADP_BC, + REG_ADP_BC_ID_PULLUP, REG_ADP_BC_ID_PULLUP); + break; default: dev_warn(&phy->dev, "USB ID detect failed to setnode! %d\n", mode); return -EINVAL; > > > Best regards, > Martin Thanks -Anand