From patchwork Wed Sep 19 18:28:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 971864 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="htnTaOpL"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42FpVS3Hcrz9s4V for ; Thu, 20 Sep 2018 04:36:48 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1473CC21E1E; Wed, 19 Sep 2018 18:30:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E0E24C21DA2; Wed, 19 Sep 2018 18:29:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7BA3BC21E0D; Wed, 19 Sep 2018 18:28:57 +0000 (UTC) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by lists.denx.de (Postfix) with ESMTPS id F05ABC21E1E for ; Wed, 19 Sep 2018 18:28:53 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id r1-v6so10115256wmh.0 for ; Wed, 19 Sep 2018 11:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n//gUPgoZe4R8jVae9PgxMSulbZsFJDBMPmPrBfwD7E=; b=htnTaOpLkHf/49jzJ13ypuj8b7BU6SHvgogBKPm4aT+2N2udI0FlgRQmm0JCzJec/d +DaIxbND9gGFJj1o7cEslk+JRRp7lbk1ZwPqKEW9HpWFcjgTQk+bHUdHFdiH+YseFh/j EUkyiLqNEfxmwoGqXmnvlb9TI92xCxLtgSplSlaMtR34e248hcycXDNx9HRCm9rLLbb+ ypwW4EDABGrvYWueesKKQedadPKtC3SdXmmxDMvUz7e4ZDZHYuwrH9qtrlglrtPHjsz+ mOaDPMkmTihZV8qbtn/nQheiASPyxVrzyCDdQlSwYj8HZg6MIXbc/AY0SKCvOz14lZ8p 2BeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n//gUPgoZe4R8jVae9PgxMSulbZsFJDBMPmPrBfwD7E=; b=MBmp/qrLi6nCgSkJkEf4cGl+wtPEsuDnm9e2n8Grre2NOD/Baci3sEp0JTTv/pCajb Ie0F6N+kNoWVb5BTy/e5QixoggUAFUhLk4FGfuGv3jv8gUp7D4Q0+eHwRkuZpEbnAmaY z6OeE9QOoPjvH+drD7kHymSwddtRitEayiGhKUQQjVTsywWglYMveRi5xfVANc9njDth IDXISvMZHgTTJk++3ZZKoOhWWjMmCWVVxIPNqG3B1Zil8o+W5npf9MxjjPZQi4MXeQMz ARgGvueoM40ocdwYDkW99YiKaRWLGg432H+RF9dQhKdi2jGer7VnY6h5mw6foHUliNTz yRwQ== X-Gm-Message-State: APzg51C7mXgW1Q5WaVzHeREsO3l89weoZ45jVlqs2c2eiXLWI5C9Jnoz NQ1aiXxdxKpAteBdn+kogzNF6W/Of7mVUw== X-Google-Smtp-Source: ANB0VdasPlx9ip55scAiApaEiavzs4Jx6bnf6Ibdc/IEEFeU7C+uN0uHcUFwSxWHt7ytGx/WdvWz7g== X-Received: by 2002:a1c:1f92:: with SMTP id f140-v6mr20568447wmf.152.1537381733360; Wed, 19 Sep 2018 11:28:53 -0700 (PDT) Received: from localhost.localdomain ([5.102.238.49]) by smtp.gmail.com with ESMTPSA id r1-v6sm7790204wmg.9.2018.09.19.11.28.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 11:28:52 -0700 (PDT) From: Ramon Fried To: u-boot@lists.denx.de Date: Wed, 19 Sep 2018 21:28:13 +0300 Message-Id: <20180919182821.19575-6-ramon.fried@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180919182821.19575-1-ramon.fried@gmail.com> References: <20180919182821.19575-1-ramon.fried@gmail.com> Cc: Heinrich Schuchardt , Alexey Brodkin , Michal Simek , Alexander Graf , Joe Hershberger , Stefan Roese , Eugeniy Paltsev , Marek Vasut Subject: [U-Boot] [PATCH v1 05/13] phy: db410c: Add MSM USB PHY driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add a PHY driver for the Qualcomm dragonboard 410c which allows switching on/off and resetting the phy connected to the EHCI controllers and USBHS controller. Signed-off-by: Ramon Fried --- MAINTAINERS | 1 + drivers/phy/Kconfig | 8 +++ drivers/phy/Makefile | 1 + drivers/phy/msm8916-usbh-phy.c | 109 +++++++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 drivers/phy/msm8916-usbh-phy.c diff --git a/MAINTAINERS b/MAINTAINERS index 39d28e5d45..1a5b543dc7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -209,6 +209,7 @@ S: Maintained F: arch/arm/mach-snapdragon/ F: drivers/gpio/msm_gpio.c F: drivers/mmc/msm_sdhci.c +F: drivers/phy/msm8916-usbh-phy.c F: drivers/serial/serial_msm.c F: drivers/smem/msm_smem.c F: drivers/usb/host/ehci-msm.c diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index e0822bb775..bcc8e22795 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -139,4 +139,12 @@ config MESON_GXL_USB_PHY This is the generic phy driver for the Amlogic Meson GXL USB2 and USB3 PHYS. +config MSM8916_USB_PHY + bool "Qualcomm MSM8916 USB PHY support" + depends on PHY + help + Support the USB PHY in msm8916 + + This PHY is found on qualcomm dragonboard410c development board. + endmenu diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile index 178fb4530e..1e1e4ca11e 100644 --- a/drivers/phy/Makefile +++ b/drivers/phy/Makefile @@ -15,3 +15,4 @@ obj-$(CONFIG_STI_USB_PHY) += sti_usb_phy.o obj-$(CONFIG_PHY_RCAR_GEN2) += phy-rcar-gen2.o obj-$(CONFIG_PHY_STM32_USBPHYC) += phy-stm32-usbphyc.o obj-$(CONFIG_MESON_GXL_USB_PHY) += meson-gxl-usb2.o meson-gxl-usb3.o +obj-$(CONFIG_MSM8916_USB_PHY) += msm8916-usbh-phy.o diff --git a/drivers/phy/msm8916-usbh-phy.c b/drivers/phy/msm8916-usbh-phy.c new file mode 100644 index 0000000000..2c90738fca --- /dev/null +++ b/drivers/phy/msm8916-usbh-phy.c @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2018 Ramon Fried + */ + +#include +#include +#include +#include +#include +#include + +/* PHY viewport regs */ +#define ULPI_MISC_A_READ 0x96 +#define ULPI_MISC_A_SET 0x97 +#define ULPI_MISC_A_CLEAR 0x98 +#define ULPI_MISC_A_VBUSVLDEXT BIT(0) +#define ULPI_MISC_A_VBUSVLDEXTSEL BIT(1) +#define GEN2_SESS_VLD_CTRL_EN BIT(7) +#define SESS_VLD_CTRL BIT(25) + +struct msm_phy_priv { + void __iomem *regs; + struct usb_ehci *ehci; /* Start of IP core*/ + struct ulpi_viewport ulpi_vp; /* ULPI Viewport */ +}; + +static int msm_phy_power_on(struct phy *phy) +{ + struct msm_phy_priv *priv = dev_get_priv(phy->dev); + + /* Select and enable external configuration with USB PHY */ + ulpi_write(&priv->ulpi_vp, (u8 *)ULPI_MISC_A_SET, + ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT); + + return 0; +} + +static int msm_phy_power_off(struct phy *phy) +{ + struct msm_phy_priv *priv = dev_get_priv(phy->dev); + + /* Disable VBUS mimicing in the controller. */ + ulpi_write(&priv->ulpi_vp, (u8 *)ULPI_MISC_A_CLEAR, + ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT); + return 0; +} + +static int msm_phy_reset(struct phy *phy) +{ + struct msm_phy_priv *p = dev_get_priv(phy->dev); + + /* select ULPI phy */ + writel(PORT_PTS_ULPI, &p->ehci->portsc); + + /* Enable sess_vld */ + setbits_le32(&p->ehci->genconfig2, GEN2_SESS_VLD_CTRL_EN); + + /* Enable external vbus configuration in the LINK */ + setbits_le32(&p->ehci->usbcmd, SESS_VLD_CTRL); + + /* USB_OTG_HS_AHB_BURST */ + writel(0x0, &p->ehci->sbuscfg); + + /* USB_OTG_HS_AHB_MODE: HPROT_MODE */ + /* Bus access related config. */ + writel(0x08, &p->ehci->sbusmode); + + return 0; +} + +static int msm_phy_probe(struct udevice *dev) +{ + struct msm_phy_priv *priv = dev_get_priv(dev); + + priv->regs = dev_remap_addr(dev); + if (!priv->regs) + return -EINVAL; + + priv->ehci = (struct usb_ehci *)priv->regs; + priv->ulpi_vp.port_num = 0; + + /* Warning: this will not work if viewport address is > 64 bit due to + * ULPI design. + */ + priv->ulpi_vp.viewport_addr = (phys_addr_t)&priv->ehci->ulpi_viewpoint; + + return 0; +} + +static struct phy_ops msm_phy_ops = { + .power_on = msm_phy_power_on, + .power_off = msm_phy_power_off, + .reset = msm_phy_reset, +}; + +static const struct udevice_id msm_phy_ids[] = { + { .compatible = "qcom,apq8016-usbphy" }, + { } +}; + +U_BOOT_DRIVER(msm8916_usbphy) = { + .name = "msm8916_usbphy", + .id = UCLASS_PHY, + .of_match = msm_phy_ids, + .ops = &msm_phy_ops, + .probe = msm_phy_probe, + .priv_auto_alloc_size = sizeof(struct msm_phy_priv), +};