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=-16.6 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,SPF_PASS,USER_AGENT_GIT 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 EC28CC07E99 for ; Mon, 5 Jul 2021 16:29:09 +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 68EF66135D for ; Mon, 5 Jul 2021 16:29:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68EF66135D 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 0EDDE82C22; Mon, 5 Jul 2021 18:28:44 +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="DefYD4or"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E957782C09; Mon, 5 Jul 2021 18:28:41 +0200 (CEST) Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.53]) (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 AB74982BF3 for ; Mon, 5 Jul 2021 18:28:38 +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=1625502502; s=strato-dkim-0002; d=gerhold.net; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=+2fkfC/WfOUQIVSDFdsWc/juxQBOxerAQJTarYjZhuo=; b=DefYD4orECb5N8wfDlK4JlpW6WF5gBXTYAgdR7sRKRviagvLcL2aXG20rhbNiIa6yZ WlJrxZ3y2nxK0Dqa6Vw4XIH56OOBb+Gpj4uQYfgjiAis7T7gr0Ax5oeE8GCGbHzTHrLM PD5Rk9LCwMbYQKuwF0dIiFTaXsyb7aMabkfuyD/kd9W3dm+qqEhxbs338DX6W9aix8bD un0JRQeoWS5RY1LS4Git0xh6E+MZG9k7xh0aj4iohnpZHrtm6mkYDbXpTXubmGYsNmIe dGTQggJTa6ddMz2ijFW2y7CX3iBd/uq7wB40hPkjhslGPtR9XOtz5kW/8sgKdkwkbX8G KUEw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P3gBZUipdd93FF5ZZvYFPugejmSTVR2nRPhVORvLd4SsytBXS7IYBkLahKxB4m6E7qA=" X-RZG-CLASS-ID: mo00 Received: from droid.. by smtp.strato.de (RZmta 47.28.1 DYNA|AUTH) with ESMTPSA id Y070ccx65GSMUz2 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Mon, 5 Jul 2021 18:28:22 +0200 (CEST) From: Stephan Gerhold To: u-boot@lists.denx.de Cc: Marek Vasut , Linus Walleij , Joe Hershberger , Jaehoon Chung , Stephan Gerhold Subject: [PATCH 2/3] phy: Add driver for ST-Ericsson AB8500 USB PHY Date: Mon, 5 Jul 2021 18:28:08 +0200 Message-Id: <20210705162809.144862-3-stephan@gerhold.net> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210705162809.144862-1-stephan@gerhold.net> References: <20210705162809.144862-1-stephan@gerhold.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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; + + 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); +} + +static int ab8500_usb_phy_power_off(struct phy *phy) +{ + struct udevice *dev = phy->dev; + + return pmic_clrsetbits(dev->parent, AB8500_USB_PHY_CTRL_REG, + AB8500_USB_PHY_CTRL_MASK, 0); +} + +struct phy_ops ab8500_usb_phy_ops = { + .power_on = ab8500_usb_phy_power_on, + .power_off = ab8500_usb_phy_power_off, +}; + +static const struct udevice_id ab8500_usb_phy_ids[] = { + { .compatible = "stericsson,ab8500-usb" }, + { } +}; + +U_BOOT_DRIVER(ab8500_usb_phy) = { + .name = "ab8500_usb_phy", + .id = UCLASS_PHY, + .of_match = ab8500_usb_phy_ids, + .ops = &ab8500_usb_phy_ops, +}; -- 2.32.0