From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9292BC07E96 for ; Tue, 6 Jul 2021 09:01:55 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD7B861995 for ; Tue, 6 Jul 2021 09:01:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD7B861995 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 226D382C06; Tue, 6 Jul 2021 11:01:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gerhold.net header.i=@gerhold.net header.b="A1BWM/G0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D598082C50; Tue, 6 Jul 2021 11:01:51 +0200 (CEST) Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [81.169.146.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8FC9182C06 for ; Tue, 6 Jul 2021 11:01:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=gerhold.net Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=stephan@gerhold.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1625562101; s=strato-dkim-0002; d=gerhold.net; h=In-Reply-To:References:Message-ID:Subject:Cc:To:From:Date:Cc:Date: From:Subject:Sender; bh=HUJ22EisyH47GfSzIMkpltUzZBO95YPPcL+dSQho0hs=; b=A1BWM/G0/HQ/XkyNFJe65bZljB1lfcPCCvRrPpAZY6Xq9PdnQvqn82JkibsAaMybky vDY//o15oMtJPLKCFgGUU3Zus5MgPCnNq+L22O77WLKxh1rfBduhiszLn5quYvgt8C91 ZbxQVC3dpfyk6EjDRhHSJVPlToW2SQQjJvaKRe1sOV832ogmNu1frmm+nPWLYxy8xkLt W1Nwsjot98bnqUaPR1EP26Ckg3y1U1dC/oVJRmJMalct7ePcImc57kJ7E8o1e7h4mBT2 mjkzhUu/ZPwBj2/4uIGzERTjsDusSBHhFAbMy+r8+jZ/MqAiKAvctzRuk6kbOzUGb/3D 7iWA== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVOQ/OcYgojyw4j34+u26zEodhPgRDZ8nxIc/ABg==" X-RZG-CLASS-ID: mo00 Received: from gerhold.net by smtp.strato.de (RZmta 47.28.1 DYNA|AUTH) with ESMTPSA id Y070ccx6691eYPr (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 6 Jul 2021 11:01:40 +0200 (CEST) Date: Tue, 6 Jul 2021 11:01:36 +0200 From: Stephan Gerhold To: Jaehoon Chung Cc: u-boot@lists.denx.de, Marek Vasut , Linus Walleij , Joe Hershberger Subject: Re: [PATCH 2/3] phy: Add driver for ST-Ericsson AB8500 USB PHY Message-ID: References: <20210705162809.144862-1-stephan@gerhold.net> <20210705162809.144862-3-stephan@gerhold.net> <2ac4b628-3d93-7fd6-efa6-bbac212778c9@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2ac4b628-3d93-7fd6-efa6-bbac212778c9@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Tue, Jul 06, 2021 at 10:10:54AM +0900, Jaehoon Chung wrote: > Hi Stephan, > > On 7/6/21 1:28 AM, Stephan Gerhold wrote: > > The AB8500 PMIC contains an USB PHY that needs to be set up in > > device or host mode to make USB work properly. Add a simple driver > > for the generic PHY uclass that allows enabling it. > > > > The if (CONFIG_IS_ENABLED(USB_MUSB_HOST)) might be a bit strange. > > The USB PHY must be configured in either host or device mode and > > somehow the USB PHY driver must be made aware of the mode. > > > > Actually, the MUSB driver used together with this PHY does not > > support dynamic selection of host/device mode in U-Boot at the moment. > > Therefore, one very simple approach that works fine is to select > > the mode to configure at compile time. When the MUSB driver is > > configured in host mode the PHY is configured in host mode, and > > similarly when the MUSB driver is configured in device/gadget mode. > > > > Cc: Linus Walleij > > Signed-off-by: Stephan Gerhold > > --- > > > > Better suggestions to make the USB PHY driver aware of the mode > > are very welcome. :) I'm not sure it's worth it though, the compile > > time selection is not ideal but it does the job just fine for now. > > --- > > drivers/phy/Kconfig | 6 ++++ > > drivers/phy/Makefile | 1 + > > drivers/phy/phy-ab8500-usb.c | 54 ++++++++++++++++++++++++++++++++++++ > > 3 files changed, 61 insertions(+) > > create mode 100644 drivers/phy/phy-ab8500-usb.c > > > > diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig > > index 008186a10d..92c74b9d0b 100644 > > --- a/drivers/phy/Kconfig > > +++ b/drivers/phy/Kconfig > > @@ -64,6 +64,12 @@ config MIPI_DPHY_HELPERS > > help > > Provides a number of helpers a core functions for MIPI D-PHY drivers. > > > > +config AB8500_USB_PHY > > + bool "AB8500 USB PHY Driver" > > + depends on PHY && PMIC_AB8500 > > + help > > + Support for the USB OTG PHY in ST-Ericsson AB8500. > > + > > config BCM6318_USBH_PHY > > bool "BCM6318 USBH PHY support" > > depends on PHY && ARCH_BMIPS > > diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile > > index 3c4a673a83..bf03d05d9b 100644 > > --- a/drivers/phy/Makefile > > +++ b/drivers/phy/Makefile > > @@ -6,6 +6,7 @@ > > obj-$(CONFIG_$(SPL_)PHY) += phy-uclass.o > > obj-$(CONFIG_$(SPL_)NOP_PHY) += nop-phy.o > > obj-$(CONFIG_MIPI_DPHY_HELPERS) += phy-core-mipi-dphy.o > > +obj-$(CONFIG_AB8500_USB_PHY) += phy-ab8500-usb.o > > obj-$(CONFIG_BCM6318_USBH_PHY) += bcm6318-usbh-phy.o > > obj-$(CONFIG_BCM6348_USBH_PHY) += bcm6348-usbh-phy.o > > obj-$(CONFIG_BCM6358_USBH_PHY) += bcm6358-usbh-phy.o > > diff --git a/drivers/phy/phy-ab8500-usb.c b/drivers/phy/phy-ab8500-usb.c > > new file mode 100644 > > index 0000000000..4ecb03a9cb > > --- /dev/null > > +++ b/drivers/phy/phy-ab8500-usb.c > > @@ -0,0 +1,54 @@ > > +// SPDX-License-Identifier: GPL-2.0+ > > +/* Copyright (C) 2019 Stephan Gerhold */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define AB8500_USB_PHY_CTRL_REG AB8500_USB(0x8A) > > +#define AB8500_BIT_PHY_CTRL_HOST_EN BIT(0) > > +#define AB8500_BIT_PHY_CTRL_DEVICE_EN BIT(1) > > +#define AB8500_USB_PHY_CTRL_MASK (AB8500_BIT_PHY_CTRL_HOST_EN |\ > > + AB8500_BIT_PHY_CTRL_DEVICE_EN) > > + > > +static int ab8500_usb_phy_power_on(struct phy *phy) > > +{ > > + struct udevice *dev = phy->dev; > > + uint set; > > + > > unit set = AB8500_BIT_PHY_CTRL_DEVICE_EN; > > if (CONFIG_IS_ENABLED(USB)MUSB_HOST)) > set = ...; > > how about that? > Both looks fine to me, I can change it in v2. > > + if (CONFIG_IS_ENABLED(USB_MUSB_HOST)) > > + set = AB8500_BIT_PHY_CTRL_HOST_EN; > > + else > > + set = AB8500_BIT_PHY_CTRL_DEVICE_EN; > > + > > + return pmic_clrsetbits(dev->parent, AB8500_USB_PHY_CTRL_REG, > > + AB8500_USB_PHY_CTRL_MASK, set); > > +} Thanks for the review! Stephan