From patchwork Thu Apr 30 21:45:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1141 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id ADC003F077 for ; Thu, 30 Apr 2020 23:45:56 +0200 (CEST) Received: by mail-pg1-f197.google.com with SMTP id u15sf6679166pgg.14 for ; Thu, 30 Apr 2020 14:45:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588283155; cv=pass; d=google.com; s=arc-20160816; b=XrAh6TCsTnRsJmYRhAyp6K8WeOwGF6fN6/FaOrzes11vST/PyrRR6nkb1/hykbsb8P 48SGpEZeYybjKkj0QydvshSiAfD3VxrPj8LjfsvW9Zmg3zg8LkXu1dAB71AkVMSKvcXl YMG/dsXW1h5LqZHdKkn/un7Tr5CDxwd3MbOOe8lwxtelHIL5qN+rocvuaNnwCR032sqF W73WUCqvKfSihWBCWhDaac6W7Mj0SLTsh310f+kbua5hDK3ShQcBl346YhBJ3nC4uh49 y24GOq1qFVPOqRlIdyeEDplbYYcmm17jdZ3vC8tz6LMo4GjFcycI40JYMAiGx7fkvUeK FaCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=U5Q6b/VnnwfruCaCbQsBPzrlR5c/x3r7UO0II97xenk=; b=YbTKmFxHnK3P3cs62fBwbMdwLEmhoJiqVEahxLaZpIwDWqW82zA7V6nvyB4d8uJqXY AEiQPOge88GIrg3ol1SRYY0PKmOlg9btJjcDF0recQTC801uq29160ZMs7OpROTJHRRw wOZaaDyhgNa+LInmgJ8+pQFAcm7Hceokdr/3x2igBp059utAW6aIdLs19FlZ8JdJZe+R 4X2kg3378Ur3U2g41+/0d91nGGfRjpuev67EKAMcsZG5lAUAYsm8on6iWfA+Ra4sB7VC cxqrugul9kXy+C7qMzuq9oErGG3BR3IUApW+LtMez0lrivbmAJ8o+PV5ZGeYnnSejuPz Tq4w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IEibsAiA; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=U5Q6b/VnnwfruCaCbQsBPzrlR5c/x3r7UO0II97xenk=; b=LvYWj7mx0hPuNULTyk+kQTDWl/8gZl4iGX3GIRZJRSlo91KSewk5NHIg24OUo2uBcx djD44uJwyPrGmDzkAXhaQ01AzrKILQEVCDPK9pKM78gRjl6riZGGtE7rw8Y8AnBxiKw9 nc6BcQbZe63BwqWD+wC8fHs1H+If4qOYenHAU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=U5Q6b/VnnwfruCaCbQsBPzrlR5c/x3r7UO0II97xenk=; b=nwwHj9I6lHn9Da4J/B6dEz4VjHH3gLbotN1VuHJUOAP4VMK1b/tYQrShtKAuIJcDor v6WoSaQ/Q82/RTO0xP/tHeMBUXFpQobZCkfdEgW+gvIysvjkIJ1SIj1YqXdMIhSiFq3i ulAZnaru8k0ReCvHUqhLWB9VgoMA6HnuB2TFYISUGimNw4MkqoSHtZymmZ0+xWjNe+fS tyH73S/5VyedzbHfTB6k2H9Kdxaak+7HReVVDSKK0E//ig6MN/fWD25eoNpUAd7BaiwK HLoo7TF4hIYfXgKuDxySveWIF4hlSDXDOnI0X914UT318yKmjsEfGkgF7IHUwLfLwPxz qowA== X-Gm-Message-State: AGi0PuYp2IeRz1LZagVKurrKnSjwDkx9viXyCeRMW8YFQrHha0dZvoDa H1fSDFUo7qOA9ZN5lHRgoRA/XivV X-Google-Smtp-Source: APiQypIa3l9Q5nY5ni5CkplEINwJH1GgtkgNdYyZ949yeklKthKlpMk5PpWzegvlKVKVIX2l6Pc3uw== X-Received: by 2002:a63:2214:: with SMTP id i20mr1046970pgi.307.1588283154706; Thu, 30 Apr 2020 14:45:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:8a98:: with SMTP id x24ls3913398pjn.0.gmail; Thu, 30 Apr 2020 14:45:54 -0700 (PDT) X-Received: by 2002:a17:90a:2281:: with SMTP id s1mr1032218pjc.68.1588283154210; Thu, 30 Apr 2020 14:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588283154; cv=none; d=google.com; s=arc-20160816; b=R3BWHEK6+ubw70Nx0rNRcJsuQOoKyTKmu/Xgm+hJdBHqGykuUGNuvNabUECKlB17BE mt+gZuvg00X9r2g9Dp9fardz7u+6GS8YAYIMsgpK4hnwo97pY5jnKaluNb6UAyCBo37E G0IsQIflwnnI1Qi3N+Lv4C3Fbv9wTyshiO65kYRDfR5GDVMdWCillFJWRKY4u286oG/7 oAE+w7hX8ZxNcfcU6C7p8CtCOBQx5qzASndz6gq00um+L3w62mdnAZl7ga0aqfSK8bTo U3YI5bKD0VGFATFkHIF7/8GiORKvIyyy6nPm3AInTgTNygbhOnmeMnscHkBzAbNLgNiR zBjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=L+A6rotdTZxuFABPL+Mc8AuyhvfS/Z9BRk0edgcGHN8=; b=EumHu5yuFi7rfsVEQCgKecLmqEixdYlSmFYMoKMpYgm7s+zO4woRGahweUFYhSor9y kV3A7pB6/kuNJU2zA/I0ZhrOYVwuW6u+7+pi1my4QmReyavdPtbO71XY6hAURWiXPc1O vEDjdgnWQBpQ4Uliy9hKFUbd9d3aHFMy6pEkwnFaH6VqdVWbcWTg51uLu9k16IKRN7NB Vx8ufLCEaTBnJfbXjTKP5K6SUGGFlOJ7k6meIJjt9CpEouMuIMFEwbWRu7Tojmkcy1Cp tHMFFI9ZgkmUUhdr3ufdyE4jSEAtn70aHNCqpQcHzpYBiZp6qKVq0FgZgsOvfMkPLX0S SrVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IEibsAiA; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u3sor1129969pjy.8.2020.04.30.14.45.53 for (Google Transport Security); Thu, 30 Apr 2020 14:45:53 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90a:2004:: with SMTP id n4mr1003560pjc.190.1588283153100; Thu, 30 Apr 2020 14:45:53 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:a9f2:11c6:8c6c:2861]) by smtp.gmail.com with ESMTPSA id p64sm615243pjp.7.2020.04.30.14.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:45:52 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich , Tom Rini , Frank Wang , William Wu , Shawn Lin , Heiko Stuebner , Patrice Chotard Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [RFC 1/7] phy: Add Rockchip PCIe PHY driver Date: Fri, 1 May 2020 03:15:23 +0530 Message-Id: <20200430214529.18887-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214529.18887-1-jagan@amarulasolutions.com> References: <20200430214529.18887-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=IEibsAiA; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add the Rockchip PCIe PHY driver as part of Generic PHY framework. Signed-off-by: Jagan Teki --- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/phy/rockchip/Kconfig | 9 + drivers/phy/rockchip/Makefile | 6 + drivers/phy/rockchip/phy-rockchip-pcie.c | 271 +++++++++++++++++++++++ 5 files changed, 289 insertions(+) create mode 100644 drivers/phy/rockchip/Kconfig create mode 100644 drivers/phy/rockchip/Makefile create mode 100644 drivers/phy/rockchip/phy-rockchip-pcie.c diff --git a/drivers/Kconfig b/drivers/Kconfig index e34a22708c..2fe23f953c 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -76,6 +76,8 @@ source "drivers/phy/allwinner/Kconfig" source "drivers/phy/marvell/Kconfig" +source "drivers/phy/rockchip/Kconfig" + source "drivers/pinctrl/Kconfig" source "drivers/power/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 4208750428..94e8c5da17 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -91,6 +91,7 @@ obj-y += dfu/ obj-$(CONFIG_PCH) += pch/ obj-y += phy/allwinner/ obj-y += phy/marvell/ +obj-y += phy/rockchip/ obj-y += rtc/ obj-y += scsi/ obj-y += sound/ diff --git a/drivers/phy/rockchip/Kconfig b/drivers/phy/rockchip/Kconfig new file mode 100644 index 0000000000..477c68920b --- /dev/null +++ b/drivers/phy/rockchip/Kconfig @@ -0,0 +1,9 @@ +# +# Phy drivers for Rockchip platforms +# +config PHY_ROCKCHIP_PCIE + bool "Rockchip PCIe PHY Driver" + depends on ARCH_ROCKCHIP + select PHY + help + Enable this to support the Rockchip PCIe PHY. diff --git a/drivers/phy/rockchip/Makefile b/drivers/phy/rockchip/Makefile new file mode 100644 index 0000000000..4d19ccdfd0 --- /dev/null +++ b/drivers/phy/rockchip/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Amarula Solutions(India) +# + +obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o diff --git a/drivers/phy/rockchip/phy-rockchip-pcie.c b/drivers/phy/rockchip/phy-rockchip-pcie.c new file mode 100644 index 0000000000..83928cffe0 --- /dev/null +++ b/drivers/phy/rockchip/phy-rockchip-pcie.c @@ -0,0 +1,271 @@ +// SPDX-License-Identifier: (GPL-2.0-only) +/* + * Rockchip PCIe PHY driver + * + * Copyright (C) 2020 Amarula Solutions(India) + * Copyright (C) 2016 Shawn Lin + * Copyright (C) 2016 ROCKCHIP, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +/* + * The higher 16-bit of this register is used for write protection + * only if BIT(x + 16) set to 1 the BIT(x) can be written. + */ +#define HIWORD_UPDATE(val, mask, shift) \ + ((val) << (shift) | (mask) << ((shift) + 16)) + +#define PHY_MAX_LANE_NUM 4 +#define PHY_CFG_DATA_SHIFT 7 +#define PHY_CFG_ADDR_SHIFT 1 +#define PHY_CFG_DATA_MASK 0xf +#define PHY_CFG_ADDR_MASK 0x3f +#define PHY_CFG_RD_MASK 0x3ff +#define PHY_CFG_WR_ENABLE 1 +#define PHY_CFG_WR_DISABLE 1 +#define PHY_CFG_WR_SHIFT 0 +#define PHY_CFG_WR_MASK 1 +#define PHY_CFG_PLL_LOCK 0x10 +#define PHY_CFG_CLK_TEST 0x10 +#define PHY_CFG_CLK_SCC 0x12 +#define PHY_CFG_SEPE_RATE BIT(3) +#define PHY_CFG_PLL_100M BIT(3) +#define PHY_PLL_LOCKED BIT(9) +#define PHY_PLL_OUTPUT BIT(10) +#define PHY_LANE_RX_DET_SHIFT 11 +#define PHY_LANE_RX_DET_TH 0x1 +#define PHY_LANE_IDLE_OFF 0x1 +#define PHY_LANE_IDLE_MASK 0x1 +#define PHY_LANE_IDLE_A_SHIFT 3 +#define PHY_LANE_IDLE_B_SHIFT 4 +#define PHY_LANE_IDLE_C_SHIFT 5 +#define PHY_LANE_IDLE_D_SHIFT 6 + +struct rockchip_pcie_phy_data { + unsigned int pcie_conf; + unsigned int pcie_status; + unsigned int pcie_laneoff; +}; + +struct rockchip_pcie_phy { + void *reg_base; + struct clk refclk; + struct reset_ctl phy_rst; + const struct rockchip_pcie_phy_data *data; +}; + +static void phy_wr_cfg(struct rockchip_pcie_phy *priv, u32 addr, u32 data) +{ + u32 reg; + + reg = HIWORD_UPDATE(data, PHY_CFG_DATA_MASK, PHY_CFG_DATA_SHIFT); + reg |= HIWORD_UPDATE(addr, PHY_CFG_ADDR_MASK, PHY_CFG_ADDR_SHIFT); + writel(reg, priv->reg_base + priv->data->pcie_conf); + + udelay(1); + + reg = HIWORD_UPDATE(PHY_CFG_WR_ENABLE, + PHY_CFG_WR_MASK, + PHY_CFG_WR_SHIFT); + writel(reg, priv->reg_base + priv->data->pcie_conf); + + udelay(1); + + reg = HIWORD_UPDATE(PHY_CFG_WR_DISABLE, + PHY_CFG_WR_MASK, + PHY_CFG_WR_SHIFT); + writel(reg, priv->reg_base + priv->data->pcie_conf); +} + +static int rockchip_pcie_phy_power_on(struct phy *phy) +{ + struct rockchip_pcie_phy *priv = dev_get_priv(phy->dev); + int ret = 0; + u32 reg, status; + + ret = reset_deassert(&priv->phy_rst); + if (ret) { + dev_err(dev, "failed to assert phy reset\n"); + return ret; + } + + reg = HIWORD_UPDATE(PHY_CFG_PLL_LOCK, + PHY_CFG_ADDR_MASK, + PHY_CFG_ADDR_SHIFT); + writel(reg, priv->reg_base + priv->data->pcie_conf); + + reg = HIWORD_UPDATE(!PHY_LANE_IDLE_OFF, + PHY_LANE_IDLE_MASK, + PHY_LANE_IDLE_A_SHIFT); + writel(reg, priv->reg_base + priv->data->pcie_laneoff); + + ret = -EINVAL; + ret = readl_poll_sleep_timeout(priv->reg_base + priv->data->pcie_status, + status, + status & PHY_PLL_LOCKED, + 20 * 1000, + 50); + if (ret) { + dev_err(&priv->dev, "pll lock timeout!\n"); + goto err_pll_lock; + } + + phy_wr_cfg(priv, PHY_CFG_CLK_TEST, PHY_CFG_SEPE_RATE); + phy_wr_cfg(priv, PHY_CFG_CLK_SCC, PHY_CFG_PLL_100M); + + ret = -ETIMEDOUT; + ret = readl_poll_sleep_timeout(priv->reg_base + priv->data->pcie_status, + status, + !(status & PHY_PLL_OUTPUT), + 20 * 1000, + 50); + if (ret) { + dev_err(&priv->dev, "pll output enable timeout!\n"); + goto err_pll_lock; + } + + reg = HIWORD_UPDATE(PHY_CFG_PLL_LOCK, + PHY_CFG_ADDR_MASK, + PHY_CFG_ADDR_SHIFT); + writel(reg, priv->reg_base + priv->data->pcie_conf); + + ret = -EINVAL; + ret = readl_poll_sleep_timeout(priv->reg_base + priv->data->pcie_status, + status, + status & PHY_PLL_LOCKED, + 20 * 1000, + 50); + if (ret) { + dev_err(&priv->dev, "pll relock timeout!\n"); + goto err_pll_lock; + } + + return 0; + +err_pll_lock: + reset_assert(&priv->phy_rst); + return ret; +} + +static int rockchip_pcie_phy_power_off(struct phy *phy) +{ + struct rockchip_pcie_phy *priv = dev_get_priv(phy->dev); + int ret; + u32 reg; + + reg = HIWORD_UPDATE(PHY_LANE_IDLE_OFF, + PHY_LANE_IDLE_MASK, + PHY_LANE_IDLE_A_SHIFT); + writel(reg, priv->reg_base + priv->data->pcie_laneoff); + + ret = reset_assert(&priv->phy_rst); + if (ret) { + dev_err(dev, "failed to assert phy reset\n"); + return ret; + } + + return 0; +} + +static int rockchip_pcie_phy_init(struct phy *phy) +{ + struct rockchip_pcie_phy *priv = dev_get_priv(phy->dev); + int ret; + + ret = clk_enable(&priv->refclk); + if (ret) { + dev_err(dev, "failed to enable refclk clock\n"); + return ret; + } + + ret = reset_assert(&priv->phy_rst); + if (ret) { + dev_err(dev, "failed to assert phy reset\n"); + goto err_reset; + } + + return 0; + +err_reset: + clk_disable(&priv->refclk); + return ret; +} + +static int rockchip_pcie_phy_exit(struct phy *phy) +{ + struct rockchip_pcie_phy *priv = dev_get_priv(phy->dev); + + clk_disable(&priv->refclk); + + return 0; +} + +static struct phy_ops rockchip_pcie_phy_ops = { + .init = rockchip_pcie_phy_init, + .power_on = rockchip_pcie_phy_power_on, + .power_off = rockchip_pcie_phy_power_off, + .exit = rockchip_pcie_phy_exit, +}; + +static int rockchip_pcie_phy_probe(struct udevice *dev) +{ + struct rockchip_pcie_phy *priv = dev_get_priv(dev); + int ret; + + priv->data = (const struct rockchip_pcie_phy_data *) + dev_get_driver_data(dev); + if (!priv->data) + return -EINVAL; + + priv->reg_base = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); + + ret = clk_get_by_name(dev, "refclk", &priv->refclk); + if (ret) { + dev_err(dev, "failed to get refclk clock phandle\n"); + return ret; + } + + ret = reset_get_by_name(dev, "phy", &priv->phy_rst); + if (ret) { + dev_err(dev, "failed to get phy reset phandle\n"); + return ret; + } + + return 0; +} + +static const struct rockchip_pcie_phy_data rk3399_pcie_data = { + .pcie_conf = 0xe220, + .pcie_status = 0xe2a4, + .pcie_laneoff = 0xe214, +}; + +static const struct udevice_id rockchip_pcie_phy_ids[] = { + { + .compatible = "rockchip,rk3399-pcie-phy", + .data = (ulong)&rk3399_pcie_data, + }, + { /* sentile */ } +}; + +U_BOOT_DRIVER(rockchip_pcie_phy) = { + .name = "rockchip_pcie_phy", + .id = UCLASS_PHY, + .of_match = rockchip_pcie_phy_ids, + .ops = &rockchip_pcie_phy_ops, + .probe = rockchip_pcie_phy_probe, + .priv_auto_alloc_size = sizeof(struct rockchip_pcie_phy), +}; From patchwork Thu Apr 30 21:45:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1142 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id F2D193F077 for ; Thu, 30 Apr 2020 23:45:59 +0200 (CEST) Received: by mail-pf1-f199.google.com with SMTP id r198sf994170pfc.8 for ; Thu, 30 Apr 2020 14:45:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588283158; cv=pass; d=google.com; s=arc-20160816; b=oU+92tsiJ7USWb2AXRiYivMuSex44cprPPRXVx5VlbQ0vU1Q3rq1mZ134cq/yaYYgk g3epw3YeRMoJcJ7f4GytmNXEFm7p3XJC6TO63rlaQitG3SsozYjz+aHt+6nae4J6ni7M +1NOkHFXhbLNu+jivAKBw1K3bCE0gK3w7EkBoRH4YMzvSATYb6mxDXL2vEQqbTnBg+yz 9CCEL5oybUfmiP4xS88MXA6JsG0CXgwGxZfvsG259g5fUQ2SsR3UHnJlw6MTG9fpn+7P GPFsEEWS/3XTdApPBGhGZ4MOibWTRB4hYI9cB6gkJnAtXfflF5I0XaPPL3G2DDd1lj+p 1udg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=Zef/FZu6hRwggm4bbEBIvfyuF5A6eWCpWNxGK/chYpI=; b=0aM+qvD9rI3zm7UrHLX75aGPT7wCzZgxZiySr46outKpQHQbCLLHxLqE1UL2Zx4l9o 0YaNMEVmV7+cQE5XGc208yBrtkrtizLfwZa0upQzfHGaTB2Gp3tNBhKbZqKfT0RnBSy4 2qFkoyE2BOPGhP6erA9rOCnyIYI223mi/+NVWGEG5RGTlOLL8w0GgQ/NmQdxUyBZXnn7 WohjeIZ2lrPVtJqIT0HrkGAb6LG2teu7mTTzqaZ8nbo8LYnO4YGEnXJ4Z21lys7XwiWP NPjk0/iBiZD37M3s4PhSx42fY+HeveTy70/CwsTbG5kdwma42SuyX8BtGZ3yuguEeE+4 iEXw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=a1u4SNqw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=Zef/FZu6hRwggm4bbEBIvfyuF5A6eWCpWNxGK/chYpI=; b=GmXmK7w7YbqgYNQ3IH3wCHTgNVoLfUZYu7NF40XJceiYTYYRq/FhXTU8b9gRSnVrZd C9FiWylN4Jqyvu6yN4O8m5pP1BuWN/S5GZkqYvP6aMdgdGyVs9bTP7r3BcCqn29KTg1K zo1AAk2Ppla5eruLQ/RhmYJ0LG+CN0lY4PGRE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=Zef/FZu6hRwggm4bbEBIvfyuF5A6eWCpWNxGK/chYpI=; b=H6e6WgpbphXXuRmNl2qm9Lhuo9IDvIAbTxSyGl392SolSdUcpKwFoMnNc7fEhjud2c 7LQ/1yTAzpGbEkFTQo3qWVyZxzvpi3I/8VCanBntV7zqcoavYTwj6Y5ADUYCFpRI6pRm dbSbm1T+aAhY32Y/ub3GI/SAO7fbXz18ZcLP2xR7fLDdQeuMF5iCggBsCGdQYOWBDiZS ipNeXVy0m/9f+QkjTgBUQFtT1/O5qdHXVyCe4+wDFoifZSIqNJnJ5fq4bxfKdp4lPpot roqATTFfz3KNqt7nDPPHZOPN1dqTSJuvI+G6ntkqmgl1XtIm5SiIP4e96qGR7pDq4HrJ wh/g== X-Gm-Message-State: AGi0PubSjQrnR+g+TZvprWuhOm4oiFiZk+969+btVc2jcT5foICBINuU ixqqrolVhpM+jtexbgadpSHKJrKu X-Google-Smtp-Source: APiQypIcnYGvjlPumEg3Fys0TrtRL6byJQo6rLVeHawoMAJxrM497H6e4IalIPfc/E0RGXKzpffsRA== X-Received: by 2002:a63:585a:: with SMTP id i26mr1033984pgm.39.1588283158404; Thu, 30 Apr 2020 14:45:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:ac91:: with SMTP id h17ls5081632plr.3.gmail; Thu, 30 Apr 2020 14:45:58 -0700 (PDT) X-Received: by 2002:a17:902:5a47:: with SMTP id f7mr1120766plm.288.1588283157927; Thu, 30 Apr 2020 14:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588283157; cv=none; d=google.com; s=arc-20160816; b=woXN+GHETmO148qdPXWRJ/nQMdkkuUeJfRo/LTyLvlTFY1nIvwPTxZJLwrvBHR8hvy vmVADY2WNh5u74fc9IPCnBhtPSE+QJR4nsfyxdNMp1XzaH/4L3bnH+Tl0iyF2Eco71Rt Vbj8W9MrlxH99LIoc1DrOn4nekHX4QPo73CFi4mA/HnF9UpRtMlhVMY7TNy4uakG0oAd gQkChp0GakeV08AzHnG+WvrkiNDKBJElsVqwpHYD/JKHg2cnM9owy8434fTNrMjE29Ws U4jIE/N5vQIBaj7PnSrpV8SiDPmkE0ec7KTUCo6Vqf7AVG71m5mWWRXXAcb022D2uQSn gqDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=40olgW3N0Uw63GCK12v84nv1cBBanm0u/AYCKonjKBo=; b=tPF7MdJtVh6Q7mxa0iWziB3xZMtmNwXLvboL1fVrT3JxnZoyzEFqLuArJKQO+l2SFN b36RQZMneM7ts++baEI9Al30mipfnb/PNWUIy/FMKJbyZkr6c3QkMqgR9USxUIQLa9/I YH/Gojy7CV1F43fYMtx7CdIjJ9jVRxPHm2YzOM2krztnfUqHDjerCya82IQ7e4Cc+OVp Ys6aUstkzY27RMtojuP3E3BiSSDmHy1FrGZ+vfufyHi1Pc9BytEgd7447C/+v+WuvT7z LttXnA4tB0yRnagIFyvXcTFJ+9XwFj/0tw93m7Ey2dhIV06BuaAN3O3rWQxSHfPiZ6W+ lGwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=a1u4SNqw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q21sor1712100pgn.46.2020.04.30.14.45.57 for (Google Transport Security); Thu, 30 Apr 2020 14:45:57 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:e210:: with SMTP id q16mr1033945pgh.26.1588283157626; Thu, 30 Apr 2020 14:45:57 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:a9f2:11c6:8c6c:2861]) by smtp.gmail.com with ESMTPSA id p64sm615243pjp.7.2020.04.30.14.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:45:56 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich , Tom Rini , Frank Wang , William Wu , Shawn Lin , Heiko Stuebner , Patrice Chotard Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [RFC 2/7] clk: rk3399: Enable/Disable the USB2PHY clk Date: Fri, 1 May 2020 03:15:24 +0530 Message-Id: <20200430214529.18887-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214529.18887-1-jagan@amarulasolutions.com> References: <20200430214529.18887-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=a1u4SNqw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Enable/Disable the USB2PHY clk for rk3399. CLK is clear in enable and set in disable functionality. Signed-off-by: Jagan Teki --- drivers/clk/rockchip/clk_rk3399.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index 7feba92f9e..b1c89ea127 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -1091,6 +1091,12 @@ static int rk3399_clk_enable(struct clk *clk) case SCLK_MACREF_OUT: rk_clrreg(&priv->cru->clkgate_con[5], BIT(6)); break; + case SCLK_USB2PHY0_REF: + rk_clrreg(&priv->cru->clkgate_con[6], BIT(5)); + break; + case SCLK_USB2PHY1_REF: + rk_clrreg(&priv->cru->clkgate_con[6], BIT(6)); + break; case ACLK_GMAC: rk_clrreg(&priv->cru->clkgate_con[32], BIT(0)); break; @@ -1167,6 +1173,12 @@ static int rk3399_clk_disable(struct clk *clk) case SCLK_MACREF_OUT: rk_setreg(&priv->cru->clkgate_con[5], BIT(6)); break; + case SCLK_USB2PHY0_REF: + rk_setreg(&priv->cru->clkgate_con[6], BIT(5)); + break; + case SCLK_USB2PHY1_REF: + rk_setreg(&priv->cru->clkgate_con[6], BIT(6)); + break; case ACLK_GMAC: rk_setreg(&priv->cru->clkgate_con[32], BIT(0)); break; From patchwork Thu Apr 30 21:45:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1143 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B98EB3F077 for ; Thu, 30 Apr 2020 23:46:04 +0200 (CEST) Received: by mail-pl1-f198.google.com with SMTP id r4sf6185630plo.4 for ; Thu, 30 Apr 2020 14:46:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588283163; cv=pass; d=google.com; s=arc-20160816; b=zKquLZC/WoR6t13/1QAeHXfi3FHyEjcwJTdfdFtiY+BFMeP6+jblNQOxYtAEu/yqyT e3ruDoT1i2ARddff2ne+RTEaNZ7lUa99mLCG5XsFvQwBItL8HOdHfxbUQJv5vubddDV/ LfFx3MNmhnxzhCZOWPXBDvq6yEbHwqvKYhN2zONqCuwWv1auXWtzKO7LhLEFgj5ArX34 NLHpxb8ew+G/uE9So8KUAsgU5i3oUjXK5MhgSwPspzXgyJjxttZk4i8eVib6U+fij56a L4JOcn4KHD4/NJL9Oh84RZPJ2RjErWvMYBZEuF7wFlRqWzizBwSKTZvSXlcFl4C3aoVp Z2JQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=diQcb6IlWhFMXhtiD+eyKJo5yqXsecjEy5G01z2GNoM=; b=PQubHwnaipngZPKkmqXNDCDYSrqQe5RSGadSkE6+X2lkISnDxF/hL6uAsAAzOWJaKm nhTU2CIjlDrecQSwAd9obyhqjK1fNNrBUTVi7HeKMxrcvX+cJ2yVSxCW92oxUY5xaqIy HrUM6QKv736XMtc6ZY8eORe8AUmUmZLWOYN41sswZBYvxPAXaxRJr1zZkpgv9efoHXQk eMKUUeIy2boAF3shdEknKWZzyu391R9e4aBZ5cDPv5OTzutdCZ8N90fH0BOaQvn4KENI SRJaOGZWgNtX0U32VdXfhNu9sF/uGdcjZrWjxf9vm5WPHqkV2zrEAM+W/3UIoeGIHrBj Tp6g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hew9vsu2; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=diQcb6IlWhFMXhtiD+eyKJo5yqXsecjEy5G01z2GNoM=; b=cl1JAulaBnpxKHE1kiL/id0KAXZzoVcB1mVAPkMNqsOsFTkXqdD+8LZTF1dMPdckPH RJYPTrgUVCSr9sLWjHlmgSH4gwsoGTc9vMvKSDId68AfeqsxkbgMrdcV7GiQSb8avxIL 4yfuNqVgRXKI2dYosuhdJejGLJWrYzZWF5zh8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=diQcb6IlWhFMXhtiD+eyKJo5yqXsecjEy5G01z2GNoM=; b=r97E1Fw8dA0IGT5PfLbah5HDITnO68cIZerIwnX2xbbHHloWvUQDXGA7VVLU07yVbE H8TvLY45y3XNJhHGjWO/iqrEZO8PrPGGe5A17WgxdkFw+tsRcx4BQ1bJc9+8m21ywCH0 wKRES+NL8AXauhVZEyPQ0nyBUliSX4FOMwnYRHfxdyfP9Cznyly+/t74eis6AVqNtVs1 8IYZvZfDDEe/OJ1i48N30NgYmGwVuxC2+J0j2wnxtl2hET7r4rYDoNcnetgiy+4UKgsO EaTudcPNM2by702Lf/eSgEIXpVcQHrg2ebu6MFLy6puCexGw/3M1AeJ71jD9OsgNyFvM 5FVg== X-Gm-Message-State: AGi0PuYyj00s4qvkSWdJ3GPtAbxAywcmsUH+IW4bKeQai52563yxck33 8sz9zv4eZt3Q0wX9zo9QL2Wh9/zy X-Google-Smtp-Source: APiQypID390Fchn18LmyWV/PDP9v8ewsIWWcKqHrX4H99RKZVzYEz/5lL+3mQBVaJkhorkg2s9hsuQ== X-Received: by 2002:a17:902:8687:: with SMTP id g7mr1161702plo.59.1588283163477; Thu, 30 Apr 2020 14:46:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:c713:: with SMTP id o19ls3896974pjt.1.gmail; Thu, 30 Apr 2020 14:46:03 -0700 (PDT) X-Received: by 2002:a17:90a:2043:: with SMTP id n61mr989235pjc.126.1588283162937; Thu, 30 Apr 2020 14:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588283162; cv=none; d=google.com; s=arc-20160816; b=y6R4qTAIjXJyKCu4oIzsTCWeid6VXMbmRiiLwS/Cnv9tHBZu3/r2HzK+P8l/5wnjC4 g2yrfM20aupQY9ZZPi+8wodrqhd6M64xxEXmOANkLd2f7WT4QoIBv26XwyNcfWlcjrUq jkgLPxoixKZJmC48HzW3fSI2Lq7plnb9buqH3a4s0dKXXvslbxRsRp7hHzfan3AIC8GI i3KVPqtxVg7jgpc4AGb+tqLndEIEiB6G1NWftoLKxw6NtrUtCEOu97CE4Xnulx95GJEn YY7qT8L3WF4MCbXiMhIr1J3/KY0b8MAPT2DudhW+DkGMd3zWPkjUE3pjnEhDvfL9NFq3 339A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oD5CV2O7MmwLAjEtD/L06xey03PjjQ+hL9rWy48y+08=; b=y34Nbn3iZ657sapiBXxmP4fA8SzA3+OyHN/lYFhdWDHG3C9+hwyyQ11GGQFOplLMJS trOAhkmdGszdnXaiWTY2TOxZAxNDduyJOvFD2iooLMwCEfMTQ9TvTc4WNRTSHtz+b8Zb jzvYtj68ko20PtzhJcp0ncwrJgY7RYlVThxlJSWegjkr1j0m4LkVfw63eo0b7xIROD6a byo4bifEKGV8c9FCXUl+f2TdJXaZoq6aaFaVlEiuRPRwKmKA4cpx24fcWMNMrXTu1i9H 2P7Ms8DQGnoOHuBPW6JuI4QGBZFAhGw0LsRY+p0j4vp3sUun6ZxoA+Ww1qXgnzJDux1b krlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hew9vsu2; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g13sor1255408plm.26.2020.04.30.14.46.02 for (Google Transport Security); Thu, 30 Apr 2020 14:46:02 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:a5c2:: with SMTP id t2mr1074951plq.151.1588283162491; Thu, 30 Apr 2020 14:46:02 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:a9f2:11c6:8c6c:2861]) by smtp.gmail.com with ESMTPSA id p64sm615243pjp.7.2020.04.30.14.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:46:01 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich , Tom Rini , Frank Wang , William Wu , Shawn Lin , Heiko Stuebner , Patrice Chotard Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [RFC 3/7] phy: rockchip: Add Rockchip USB2PHY driver Date: Fri, 1 May 2020 03:15:25 +0530 Message-Id: <20200430214529.18887-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214529.18887-1-jagan@amarulasolutions.com> References: <20200430214529.18887-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=hew9vsu2; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add Rockchip USB2PHY driver with initial support. This will help to use it for EHCI controller in host mode, and USB 3.0 controller in otg mode. More functionality like charge, vbus detection will add it in future changes. Signed-off-by: Jagan Teki --- drivers/phy/rockchip/Kconfig | 7 + drivers/phy/rockchip/Makefile | 1 + drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 312 ++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-usb2.c diff --git a/drivers/phy/rockchip/Kconfig b/drivers/phy/rockchip/Kconfig index 477c68920b..f7ddac4744 100644 --- a/drivers/phy/rockchip/Kconfig +++ b/drivers/phy/rockchip/Kconfig @@ -7,3 +7,10 @@ config PHY_ROCKCHIP_PCIE select PHY help Enable this to support the Rockchip PCIe PHY. + +config PHY_ROCKCHIP_INNO_USB2 + bool "Rockchip INNO USB2PHY Driver" + depends on ARCH_ROCKCHIP + select PHY + help + Support for Rockchip USB2.0 PHY with Innosilicon IP block. diff --git a/drivers/phy/rockchip/Makefile b/drivers/phy/rockchip/Makefile index 4d19ccdfd0..82d771b70b 100644 --- a/drivers/phy/rockchip/Makefile +++ b/drivers/phy/rockchip/Makefile @@ -4,3 +4,4 @@ # obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o +obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c new file mode 100644 index 0000000000..dd4905d834 --- /dev/null +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -0,0 +1,312 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Rockchip USB2.0 PHY with Innosilicon IP block driver + * + * Copyright (C) 2016 Fuzhou Rockchip Electronics Co., Ltd + * Copyright (C) 2020 Amarula Solutions(India) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define usleep_range(a, b) udelay((b)) +#define BIT_WRITEABLE_SHIFT 16 + +enum rockchip_usb2phy_port_id { + USB2PHY_PORT_OTG, + USB2PHY_PORT_HOST, + USB2PHY_NUM_PORTS, +}; + +struct usb2phy_reg { + unsigned int offset; + unsigned int bitend; + unsigned int bitstart; + unsigned int disable; + unsigned int enable; +}; + +struct rockchip_usb2phy_port_cfg { + struct usb2phy_reg phy_sus; + struct usb2phy_reg bvalid_det_en; + struct usb2phy_reg bvalid_det_st; + struct usb2phy_reg bvalid_det_clr; + struct usb2phy_reg ls_det_en; + struct usb2phy_reg ls_det_st; + struct usb2phy_reg ls_det_clr; + struct usb2phy_reg utmi_avalid; + struct usb2phy_reg utmi_bvalid; + struct usb2phy_reg utmi_ls; + struct usb2phy_reg utmi_hstdet; +}; + +struct rockchip_usb2phy_cfg { + unsigned int reg; + const struct rockchip_usb2phy_port_cfg port_cfgs[USB2PHY_NUM_PORTS]; +}; + +struct rockchip_usb2phy { + void *reg_base; + struct clk phyclk; + const struct rockchip_usb2phy_cfg *phy_cfg; +}; + +static inline int property_enable(void *reg_base, + const struct usb2phy_reg *reg, bool en) +{ + unsigned int val, mask, tmp; + + tmp = en ? reg->enable : reg->disable; + mask = GENMASK(reg->bitend, reg->bitstart); + val = (tmp << reg->bitstart) | (mask << BIT_WRITEABLE_SHIFT); + + return writel(val, reg_base + reg->offset); +} + +static const +struct rockchip_usb2phy_port_cfg *us2phy_get_port(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + const struct rockchip_usb2phy_cfg *phy_cfg = priv->phy_cfg; + + return &phy_cfg->port_cfgs[phy->id]; +} + +static int rockchip_usb2phy_power_on(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy); + + property_enable(priv->reg_base, &port_cfg->phy_sus, false); + + /* waiting for the utmi_clk to become stable */ + usleep_range(1500, 2000); + + return 0; +} + +static int rockchip_usb2phy_power_off(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy); + + property_enable(priv->reg_base, &port_cfg->phy_sus, true); + + return 0; +} + +static int rockchip_usb2phy_init(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy); + int ret; + + ret = clk_enable(&priv->phyclk); + if (ret) { + dev_err(phy->dev, "failed to enable phyclk (ret=%d)\n", ret); + return ret; + } + + if (phy->id == USB2PHY_PORT_OTG) { + property_enable(priv->reg_base, &port_cfg->bvalid_det_clr, true); + property_enable(priv->reg_base, &port_cfg->bvalid_det_en, true); + } else if (phy->id == USB2PHY_PORT_HOST) { + property_enable(priv->reg_base, &port_cfg->bvalid_det_clr, true); + property_enable(priv->reg_base, &port_cfg->bvalid_det_en, true); + } + + return 0; +} + +static int rockchip_usb2phy_exit(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + + clk_disable(&priv->phyclk); + + return 0; +} + +static int rockchip_usb2phy_of_xlate(struct phy *phy, + struct ofnode_phandle_args *args) +{ + const char *name = phy->dev->name; + + if (!strcasecmp(name, "host-port")) + phy->id = USB2PHY_PORT_HOST; + else if (!strcasecmp(name, "otg-port")) + phy->id = USB2PHY_PORT_OTG; + else + dev_err(phy->dev, "improper %s device\n", name); + + return 0; +} + +static struct phy_ops rockchip_usb2phy_ops = { + .init = rockchip_usb2phy_init, + .exit = rockchip_usb2phy_exit, + .power_on = rockchip_usb2phy_power_on, + .power_off = rockchip_usb2phy_power_off, + .of_xlate = rockchip_usb2phy_of_xlate, +}; + +static int rockchip_usb2phy_probe(struct udevice *dev) +{ + struct rockchip_usb2phy *priv = dev_get_priv(dev); + const struct rockchip_usb2phy_cfg *phy_cfgs; + unsigned int reg; + int index, ret; + + priv->reg_base = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); + if (IS_ERR(priv->reg_base)) + return PTR_ERR(priv->reg_base); + + ret = dev_read_u32_index(dev, "reg", 1, ®); + if (ret) { + dev_err(dev, "failed to read reg property (ret = %d)\n", ret); + return ret; + } + + phy_cfgs = (const struct rockchip_usb2phy_cfg *) + dev_get_driver_data(dev); + if (!phy_cfgs) + return -EINVAL; + + /* find out a proper config which can be matched with dt. */ + index = 0; + while (phy_cfgs[index].reg) { + if (phy_cfgs[index].reg == reg) { + priv->phy_cfg = &phy_cfgs[index]; + break; + } + + ++index; + } + + if (!priv->phy_cfg) { + dev_err(dev, "failed find proper phy-cfg\n"); + return -EINVAL; + } + + ret = clk_get_by_name(dev, "phyclk", &priv->phyclk); + if (ret) { + dev_err(dev, "failed to get the phyclk (ret=%d)\n", ret); + return ret; + } + + return 0; +} + +static int rockchip_usb2phy_bind(struct udevice *dev) +{ + struct udevice *usb2phy_dev; + ofnode node; + const char *name; + int ret = 0; + + dev_for_each_subnode(node, dev) { + if (!ofnode_valid(node)) { + dev_info(dev, "subnode %s not found\n", dev->name); + return -ENXIO; + } + + name = ofnode_get_name(node); + dev_dbg(dev, "subnode %s\n", name); + + ret = device_bind_driver_to_node(dev, "rockchip_usb2phy_port", + name, node, &usb2phy_dev); + if (ret) { + dev_err(dev, + "'%s' cannot bind 'rockchip_usb2phy_port'\n", name); + return ret; + } + } + + return ret; +} + +static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = { + { + .reg = 0xe450, + .port_cfgs = { + [USB2PHY_PORT_OTG] = { + .phy_sus = { 0xe454, 1, 0, 2, 1 }, + .bvalid_det_en = { 0xe3c0, 3, 3, 0, 1 }, + .bvalid_det_st = { 0xe3e0, 3, 3, 0, 1 }, + .bvalid_det_clr = { 0xe3d0, 3, 3, 0, 1 }, + .utmi_avalid = { 0xe2ac, 7, 7, 0, 1 }, + .utmi_bvalid = { 0xe2ac, 12, 12, 0, 1 }, + }, + [USB2PHY_PORT_HOST] = { + .phy_sus = { 0xe458, 1, 0, 0x2, 0x1 }, + .ls_det_en = { 0xe3c0, 6, 6, 0, 1 }, + .ls_det_st = { 0xe3e0, 6, 6, 0, 1 }, + .ls_det_clr = { 0xe3d0, 6, 6, 0, 1 }, + .utmi_ls = { 0xe2ac, 22, 21, 0, 1 }, + .utmi_hstdet = { 0xe2ac, 23, 23, 0, 1 } + } + }, + }, + { + .reg = 0xe460, + .port_cfgs = { + [USB2PHY_PORT_OTG] = { + .phy_sus = { 0xe464, 1, 0, 2, 1 }, + .bvalid_det_en = { 0xe3c0, 8, 8, 0, 1 }, + .bvalid_det_st = { 0xe3e0, 8, 8, 0, 1 }, + .bvalid_det_clr = { 0xe3d0, 8, 8, 0, 1 }, + .utmi_avalid = { 0xe2ac, 10, 10, 0, 1 }, + .utmi_bvalid = { 0xe2ac, 16, 16, 0, 1 }, + }, + [USB2PHY_PORT_HOST] = { + .phy_sus = { 0xe468, 1, 0, 0x2, 0x1 }, + .ls_det_en = { 0xe3c0, 11, 11, 0, 1 }, + .ls_det_st = { 0xe3e0, 11, 11, 0, 1 }, + .ls_det_clr = { 0xe3d0, 11, 11, 0, 1 }, + .utmi_ls = { 0xe2ac, 26, 25, 0, 1 }, + .utmi_hstdet = { 0xe2ac, 27, 27, 0, 1 } + } + }, + }, + { /* sentinel */ } +}; + +static const struct udevice_id rockchip_usb2phy_ids[] = { + { + .compatible = "rockchip,rk3399-usb2phy", + .data = (ulong)&rk3399_usb2phy_cfgs, + }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(rockchip_usb2phy_port) = { + .name = "rockchip_usb2phy_port", + .id = UCLASS_PHY, + .ops = &rockchip_usb2phy_ops, +}; + +U_BOOT_DRIVER(rockchip_usb2phy) = { + .name = "rockchip_usb2phy", + .id = UCLASS_PHY, + .of_match = rockchip_usb2phy_ids, + .probe = rockchip_usb2phy_probe, + .bind = rockchip_usb2phy_bind, + .priv_auto_alloc_size = sizeof(struct rockchip_usb2phy), +}; From patchwork Thu Apr 30 21:45:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1144 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 437073F077 for ; Thu, 30 Apr 2020 23:46:09 +0200 (CEST) Received: by mail-pf1-f197.google.com with SMTP id f22sf997090pfk.7 for ; Thu, 30 Apr 2020 14:46:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588283168; cv=pass; d=google.com; s=arc-20160816; b=j+AZ0ij8wGvAystug5XQfXr0O1vH7TDPnhNQUGv0RpDfHAXhkl4h653AcAuhkjFJCU Wi7GD0HRhpn8qFkp/8U78380ruWgun1S5a2CoIAk3BBlUXq9mfv8aZPd2fl759/h5Vis 7PoDMaFdF8WwGBIoD8QktRGpOnSBjoedLDdjtzscRiLisdgsXPVTI2qcRJCXFNR5edmc m4rc7i7cWrzfopK4PfLzxgV7l1vMIIBfGk+XBktOqBcvFjB/TuGwmmGoTBsWLdOxhAqB z7dw1JANEq8/9YMAhpo6IupVoUtoNNP6lRJfe9DoB1SDveNkCmfHsxw1lZ72sS4anrPB p79w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=vPgcrp/lsjfpqUBppsBsN9UjHalb+AeDwhma9Egqgqw=; b=uchlTy6Xus11iKbTzt8s+lNUC5RdpSE49jOzN/cb6+72J+Emo10VyGRZl+w9lV3t2s werxWB+1L++Gk7ap7723OqB6bl5qcLRNtEjikIuxbtTf1AqxZfDo2NwXJRtomi9eZaB2 V2K2XmItnRcWjVAj7L1P9cgxyLu5CzdqNQeWyg+1IcVxk7ru2ysk0Qc4szvfSBFO3JQC MegJ0x3DEPdN6lTjd9TGXwnPbKcaMoDQqXQ9REBvcn/dgyfAiBOlP/euXCB6Zd4+kXSw eeq8cqw3iEjmrsvgsmetVRUO4bzdq/9dwh8BafFZfd+lJQMum9HEUaTVoVr7rY8UElvm SMig== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=N+e0TZAA; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=vPgcrp/lsjfpqUBppsBsN9UjHalb+AeDwhma9Egqgqw=; b=Ciql1O9IV+pEkJSfwu0kF3HPW6kEFOB9eYjyDKc1P6TnSi71onHTLdzqX2JYVeyUsd byvLBOB3abQfPT+XjgWt/POykAUCFsnWOwWmqDw+XYG8rLIQtf81QMxi+t8bj99OJYsz t+5qNujRzNpwxtSD63sZSlJdzE0XmwDYkGjlQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=vPgcrp/lsjfpqUBppsBsN9UjHalb+AeDwhma9Egqgqw=; b=bvhVNjYp0ODkOeQBlLF6n0zWZnhNpO8e1KYhTbjiONPm1hfOzZ2kkCXkGehcFMjdQZ CgX9vTctGtXF/YLkQ+bOfYYSnuOdWuuL8RC6WRC4gMrw7kv1aI/2ZgsMiSvD3d4ubaPO PZIFGzkoQpoDAoGNex9x9Srqcb9mqPOXZrYtULAJ6DuPreFXR8jg9gELxgJ1nfx9lqtN sUBP2YFa1dVnE5uAoBJzm25Q9HUZGdxB4s6XIXLXjVGv9GNumV1Esf03jJNIvOGAneOp OaSqSFe2WjBTgI+BWpgd+hRAvExlbDWT2NjJCYRXLB9Em4nHFMg3/9JJdSMKVNZyH+sk pTUw== X-Gm-Message-State: AGi0PuZUpSvCboDX2+1jIosocPaUArbBSMIMy44kZftd4p51rCfI/RbR Zx3PVdtHXgcB2gzEh/u3hJ3tfZEK X-Google-Smtp-Source: APiQypL02qLi9XdICQfobPsclrDnR5Yx+4OcxPnqg9wPNplqHe53zVDU/misHiqzuTFNQsC+N2qgJw== X-Received: by 2002:aa7:9ae5:: with SMTP id y5mr853207pfp.294.1588283167964; Thu, 30 Apr 2020 14:46:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:ac91:: with SMTP id h17ls5082759plr.3.gmail; Thu, 30 Apr 2020 14:46:07 -0700 (PDT) X-Received: by 2002:a17:902:d203:: with SMTP id t3mr1104183ply.136.1588283167537; Thu, 30 Apr 2020 14:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588283167; cv=none; d=google.com; s=arc-20160816; b=RZjCo1L4e1D2EPfNf49cX6boyCWkTPo523C48tnVrJKOegXz4LEL70+CT2mGiqfM8o raf7CCcOMR5PgnrPWwtgvwgkz17HkdQn1FcIcfoy5Y9r4DxaMa/DjTyJ30/beaMc7dCh pY1UUCAo7kqezKPsOs2LDnHfTVVjDtPUurAc1EwMMNcfJYRWpfx4I+kVmr0R+MqVT2Yp ouNSrOARYULnyRFbaJBIxu9KiR29NY9KwBYFY7/z/50dbiOY4sCk3PRUgbbRt1jRcc69 wcqDRAfJUBdVgyKkH6fUDuKas3Sk8VDEy3ZjMaxvvC7hkBV1wEZy4UoL6o3ntYYYZC1r V4mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6+Nlz4K5CVynOeUhqGSCw2yzk9Vj1GohEKvgEtpoNmY=; b=MkiEqt3ZTvp48Ym98nBfp2YOt14uMWB+GGf0snazi4roOvj43rc88xzAhcUGj+3K2W x7U92fIsUoLMY8nktMTJPDRfn34GRh6t8iKWxH2HUdJvjwhPhpxTZS9IlGrQU9zEGAGJ H3Xnnt3u8X8B23jN+Dff1asZSKPPsXyLjocObq1gsFfTfR+R13Y3mbCMkylcQ4CsE4vJ PJZP0wuJGhHanEqdBj58M3p8GzXZ+vJ6DqtgWBOxnU8plOEc94ewnateTEFjQs4ygXG+ WF6eARkKE3Dnmco8TCSg7l+1SCiTjm5EN5z0wSljGcH9mKU9FE8U6uF+diir/mO62Gyx /WrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=N+e0TZAA; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i13sor1111574pjz.9.2020.04.30.14.46.07 for (Google Transport Security); Thu, 30 Apr 2020 14:46:07 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90a:d0c3:: with SMTP id y3mr953589pjw.25.1588283167057; Thu, 30 Apr 2020 14:46:07 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:a9f2:11c6:8c6c:2861]) by smtp.gmail.com with ESMTPSA id p64sm615243pjp.7.2020.04.30.14.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:46:06 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich , Tom Rini , Frank Wang , William Wu , Shawn Lin , Heiko Stuebner , Patrice Chotard Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [RFC 4/7] arm64: dts: rk3399: Move u2phy into root port Date: Fri, 1 May 2020 03:15:26 +0530 Message-Id: <20200430214529.18887-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214529.18887-1-jagan@amarulasolutions.com> References: <20200430214529.18887-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=N+e0TZAA; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Yes, This is changing the actual device tree u2phy structure but the problem with the current Generic PHY subsystem is unable to find PHY if the PHY node is not part of the root structure. This will be reverted once we support the PHY subsystem to get the PHY even though it is not part of the root node or any other relevant solution. Signed-off-by: Jagan Teki --- arch/arm/dts/rk3399.dtsi | 108 +++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/arch/arm/dts/rk3399.dtsi b/arch/arm/dts/rk3399.dtsi index 74f2c3d490..6c77f25f23 100644 --- a/arch/arm/dts/rk3399.dtsi +++ b/arch/arm/dts/rk3399.dtsi @@ -1387,60 +1387,6 @@ status = "disabled"; }; - u2phy0: usb2-phy@e450 { - compatible = "rockchip,rk3399-usb2phy"; - reg = <0xe450 0x10>; - clocks = <&cru SCLK_USB2PHY0_REF>; - clock-names = "phyclk"; - #clock-cells = <0>; - clock-output-names = "clk_usbphy0_480m"; - status = "disabled"; - - u2phy0_host: host-port { - #phy-cells = <0>; - interrupts = ; - interrupt-names = "linestate"; - status = "disabled"; - }; - - u2phy0_otg: otg-port { - #phy-cells = <0>; - interrupts = , - , - ; - interrupt-names = "otg-bvalid", "otg-id", - "linestate"; - status = "disabled"; - }; - }; - - u2phy1: usb2-phy@e460 { - compatible = "rockchip,rk3399-usb2phy"; - reg = <0xe460 0x10>; - clocks = <&cru SCLK_USB2PHY1_REF>; - clock-names = "phyclk"; - #clock-cells = <0>; - clock-output-names = "clk_usbphy1_480m"; - status = "disabled"; - - u2phy1_host: host-port { - #phy-cells = <0>; - interrupts = ; - interrupt-names = "linestate"; - status = "disabled"; - }; - - u2phy1_otg: otg-port { - #phy-cells = <0>; - interrupts = , - , - ; - interrupt-names = "otg-bvalid", "otg-id", - "linestate"; - status = "disabled"; - }; - }; - emmc_phy: phy@f780 { compatible = "rockchip,rk3399-emmc-phy"; reg = <0xf780 0x24>; @@ -1462,6 +1408,60 @@ }; }; + u2phy0: usb2-phy@e450 { + compatible = "rockchip,rk3399-usb2phy"; + reg = <0x0 0xe450 0x0 0x10>; + clocks = <&cru SCLK_USB2PHY0_REF>; + clock-names = "phyclk"; + #clock-cells = <0>; + clock-output-names = "clk_usbphy0_480m"; + status = "disabled"; + + u2phy0_host: host-port { + #phy-cells = <0>; + interrupts = ; + interrupt-names = "linestate"; + status = "disabled"; + }; + + u2phy0_otg: otg-port { + #phy-cells = <0>; + interrupts = , + , + ; + interrupt-names = "otg-bvalid", "otg-id", + "linestate"; + status = "disabled"; + }; + }; + + u2phy1: usb2-phy@e460 { + compatible = "rockchip,rk3399-usb2phy"; + reg = <0x0 0xe460 0x0 0x10>; + clocks = <&cru SCLK_USB2PHY1_REF>; + clock-names = "phyclk"; + #clock-cells = <0>; + clock-output-names = "clk_usbphy1_480m"; + status = "disabled"; + + u2phy1_host: host-port { + #phy-cells = <0>; + interrupts = ; + interrupt-names = "linestate"; + status = "disabled"; + }; + + u2phy1_otg: otg-port { + #phy-cells = <0>; + interrupts = , + , + ; + interrupt-names = "otg-bvalid", "otg-id", + "linestate"; + status = "disabled"; + }; + }; + tcphy0: phy@ff7c0000 { compatible = "rockchip,rk3399-typec-phy"; reg = <0x0 0xff7c0000 0x0 0x40000>; From patchwork Thu Apr 30 21:45:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1145 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 54F393F077 for ; Thu, 30 Apr 2020 23:46:15 +0200 (CEST) Received: by mail-io1-f69.google.com with SMTP id u10sf2762350iog.21 for ; Thu, 30 Apr 2020 14:46:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588283174; cv=pass; d=google.com; s=arc-20160816; b=OaDK9F2StHmqVJo4RpGsUZGUK58aO7st60Z/a/uk7duq8GeDi88zSFQNWmZg1U6Ihu EQRwtg2u3PEDPRH1sWXfwQaUYwWjBg24fXQ5a5+72yj+sLELHYBa20ps/CO/guhUhC+W fVdD8P4QWLNypc893a8ITIGyTGY053NMTvzmJsr/a7Q0vJ+5Fl0PTouBuiQBGF2uApT+ L+KQQFA7rlDB0tGaregEH7wGxSUAVxPHK8LnkVZ/adgwcCornohDLVBigxMA0hBHRgiM l7mKrOcSw42cCBnAgys4oC+Gw+wcgD+LbBhD2lPwcATTtB2Fc8daJBTQ6eWT8R+Ly8wM tFOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RUipvrIupjbJaejHzj7pAFnSE9A3n5Y575Yj6XiOvb0=; b=gN70gNI3jT/OOo/7Wzsa1ZieLw2TOh0jx5AU2xL9TgKASy00B/hOTOV17Z6DrNM90u kNtyabcW3Tlr2uWycN1UeXwQfiu4rp2dKka+zY0kiTq6iFAaAQaBLsdQXHn4YjTkGl9c 1MnqzLL0CELAXyi3trbavP+gJEoGMdsLqPBtQPfHuGrC6YYeAdBthx7qDqsrlKRKnDIC 8/xLhUfRBzodBt07XbuA1UGFql5E4cf43/uyykPcV1iRoKaLkX5xv1nh7QBi3LMA5cL/ in7gJggY60WrTiu73BzSKVUyJ5S2x35eD4EY4rLwqc0XVSAk8dj8IGI8vPwCu4/tk6AJ jw+Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FjlRFlzN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=RUipvrIupjbJaejHzj7pAFnSE9A3n5Y575Yj6XiOvb0=; b=bhWZX6Dlr3Mz+wVOmHrPh4JhLH9znxvgFcyoLcJ/zJ79GgWxiTZggon1lEhT0+BQxu 72JmgOPSYKOSlLYGGfBLRR2xj2l6h/9N81ATGZxkqlbR2KEX5I0YYNV4sVN/JHRySIH+ Rul/NU66oenUIfign9qNg5Sr80WW2u/xlnHq8= 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:mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=RUipvrIupjbJaejHzj7pAFnSE9A3n5Y575Yj6XiOvb0=; b=ulAPhiXDEYLvCgULczTKErYseiNWhockPrscbFfo1Ls/pfIQt8l7upTII6kB9h5rnN QFwrL0O+1gp7y0bJyx4GrFj/hW4/N/hrYzPzodMa3jSThZ0FdeQGpucp+9KNsU20FeYs meHEww8lmmllU90PLFTZ4RGVFMMgM1S7qzv6PTvSL25oGIqfilco/Mq4yLOMxmg/uJgr U47YTDZA8HesL+S4tKmZUA5pIZgvCxOs1pBogGJdNAUBp7XhuNezbtUAY+O82URNYtwx 6TJutUBhuuARG0pGcCt2Ng9J/LOmeO6GW7ibiQyuW8J6tQAE0u0+TBlVyzzdikIE3jGQ 6uVA== X-Gm-Message-State: AGi0PuYDKt/4UmVX9NPKCjE8lCdqeRJ780HXqpQFkduO8spj6LweYofZ 70tm9J0qPheNISRN/f6gb64YZ4+b X-Google-Smtp-Source: APiQypLvYBwqmSJoUsGGcsPeU1XhBBwevJaMywh42VgZQAgh386lHc7YM4cAIr/KAbLxwn4R4W7AEw== X-Received: by 2002:a92:5d0f:: with SMTP id r15mr466794ilb.251.1588283172712; Thu, 30 Apr 2020 14:46:12 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a5d:8ac3:: with SMTP id e3ls1442279iot.10.gmail; Thu, 30 Apr 2020 14:46:12 -0700 (PDT) X-Received: by 2002:a6b:3112:: with SMTP id j18mr914725ioa.127.1588283172141; Thu, 30 Apr 2020 14:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588283172; cv=none; d=google.com; s=arc-20160816; b=JFeK62zInb/8vO9LdnHpGLhf0BoqGqNJaoovz5XcOBmx/7zcLJ6pCrrBvlUvd4E1LW P/Y+nezuvL1hxNXgBr2JKi7JS1uwHaVrsLiRAmiFf28ELUqxRSEZRm0ULl1WP2g9Ita5 J2pD0FH1yzZg0Wemp748vld0QfDjcJLef3IoTTOkadSPIOD4fDOLiSFPjs8VqN5C3CgM /aJCgb+P176OHuFCIpAI/TbBbDUGYPiY5eHhXzZbVPsndkwxuLOcb+syFaXuemjvFJHk brx8PEXNraL6GyHB/GmWhpUJUNhxmXqRkkGp3oKPAfw6FBuAwKGrWmE1UUr7mrMAyXHp pPxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=O57oZmFtIDGFaxieo8Ue9ldC2XvrWM9IRe2TgB3VW1I=; b=q5FWDAI0sHhauV/Qc4DSGS1R8APl+l84T4c+yZnikpfR0fmRLS0lAwkpDpEzm9/tF4 n4XSXOqlhK8gHkGe4HGC76idLS+CiEiBF0qk10dsc2p9wpx65G5B8tuSLg2UA8GFQqXE bpXsPIuZ3ihzWsBdmcqo/WInrhbNXQnd65Yo1WtqkT0U6pi+7pluMIjYsbY68oGXtXjb 1cs/RjV5dezrZ1RKi27mH65oCrPNSnxGIADZFQnmqF4KnjhPAM6NZz26cfbRNbRYv1kT Sv0MrxSUaZCX7cBhxaxn7+8aXX9WJHMkiBHRCqfaeG02fd0iPXDHPz1yWTfDdAlwCH6N Bi1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FjlRFlzN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x9sor1053939ila.97.2020.04.30.14.46.12 for (Google Transport Security); Thu, 30 Apr 2020 14:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:8202:: with SMTP id x2mr1084618pln.287.1588283171707; Thu, 30 Apr 2020 14:46:11 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:a9f2:11c6:8c6c:2861]) by smtp.gmail.com with ESMTPSA id p64sm615243pjp.7.2020.04.30.14.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:46:10 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich , Tom Rini , Frank Wang , William Wu , Shawn Lin , Heiko Stuebner , Patrice Chotard Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [RFC 5/7] arm64: dts: rk3399: Move pcie_phy into root port Date: Fri, 1 May 2020 03:15:27 +0530 Message-Id: <20200430214529.18887-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214529.18887-1-jagan@amarulasolutions.com> References: <20200430214529.18887-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=FjlRFlzN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Yes, This is changing the actual device tree pcie_phy structure but the problem with the current Generic PHY subsystem is unable to find PHY if the PHY node is not part of the root structure and also PHY parent is non-PHY type. This will be reverted once we support the PHY subsystem to get the PHY whose parent has non-PHY type or any other relevant solution.    Signed-off-by: Jagan Teki --- arch/arm/dts/rk3399.dtsi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arch/arm/dts/rk3399.dtsi b/arch/arm/dts/rk3399.dtsi index 6c77f25f23..dea76032bf 100644 --- a/arch/arm/dts/rk3399.dtsi +++ b/arch/arm/dts/rk3399.dtsi @@ -1395,17 +1395,17 @@ #phy-cells = <0>; status = "disabled"; }; + }; - pcie_phy: pcie-phy { - compatible = "rockchip,rk3399-pcie-phy"; - clocks = <&cru SCLK_PCIEPHY_REF>; - clock-names = "refclk"; - #phy-cells = <1>; - resets = <&cru SRST_PCIEPHY>; - drive-impedance-ohm = <50>; - reset-names = "phy"; - status = "disabled"; - }; + pcie_phy: pcie-phy { + compatible = "rockchip,rk3399-pcie-phy"; + clocks = <&cru SCLK_PCIEPHY_REF>; + clock-names = "refclk"; + #phy-cells = <1>; + resets = <&cru SRST_PCIEPHY>; + drive-impedance-ohm = <50>; + reset-names = "phy"; + status = "disabled"; }; u2phy0: usb2-phy@e450 { From patchwork Thu Apr 30 21:45:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1146 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B6DCD3F077 for ; Thu, 30 Apr 2020 23:46:18 +0200 (CEST) Received: by mail-pg1-f200.google.com with SMTP id v6sf6671533pgh.16 for ; Thu, 30 Apr 2020 14:46:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588283177; cv=pass; d=google.com; s=arc-20160816; b=spAa1FQ6wwf6A5tqG9PuNSBZJSqCSMMmtaoP5C/8R4/aX8CuWjkST3kdZ2s/5e1mAr MJx9Pzco8eC8gRunE4imWLI0lkWzo4rCLAoDpquNaD6OKn+PAYliSR5X4Ro58J34krHi yV2xbvrRiOXX2SSoHGddCvooAT+pzZCtPq+z5W3ljbr6Cy/6RE9VU+hmObeNXiMs+ktx XDjRd5AnisnJVTDhmIJym6DBX28jHVsbymV6jJTvpV3f7fHV1iXJxw4djCiuFh8BBiHU t5qoJC9CoU7HitRd5gsOgZCfwmC1p5Rx9XWMtJMPucRwU3OFM78MgfrEt0aExt3Wrxtx 1O6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=Etan7yew2suL62LHucqSABOAvp8wmcLLyYfo1hqLlzs=; b=UPPQxj6jQC3raZ1wQj4lX2KT+eVWGAo+L1LsZl1ClmNEXzIHcRBYmvswZizNylmeNy eNRDGZ73RpPV1Iz1OhF/tBAhWLEnGX+MpxDVeB79uj1WYU4kJI5JHo5ojIT97wwivXur +zOZ0S/zik6en5kKlBEDXl/8UHNNZDq5Qoxy+4mJ9/FLfkid8kT6rFBSVFWD2sgZT980 UHw68xInHrFNj3dZezhBFfh6r30PeSdkky4qzyUHajKq8KUW/hN+rsikmL7mXcdP2Hdw SPcc/B/QcBraueH83SFYpVBmdIFSyHWG6h6JD8q9FTaryZW5jaMCoXOGU6V8ZZz0wL/o HaMA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Amp9dCYN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=Etan7yew2suL62LHucqSABOAvp8wmcLLyYfo1hqLlzs=; b=rHSsL+k9M3gcqX0Lpzho0FXAbVjsSxto2BhZ9eL7uvuAk+2szktRetfpLXdGpxleEk 9ijOt4G3zDH93QHYb0sIyog+7A7FaFtmFz0NHc1K8NzVgOdJ72dqXTZTS6aqAjXmbENY n140XIotLsGulUIvt7cl9tQnYO0+4zn7oaO74= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=Etan7yew2suL62LHucqSABOAvp8wmcLLyYfo1hqLlzs=; b=dF79EMBu1KnH8TVs27kp2E4OG6L9Zxv3+ZFu/Kapm2E5QXpLVwu5stOrkA8wMQkUMZ vtGNfc3klhs0gsB0+ttuYyyFk6L6+oXcHd+Q053VQRvUVHAMgnvMfdGGMifoG6V2sE4F i6cB0CP3p2ULm/6glyuAwTLMpu8RVHRblRQlx2YkPgp/fGClhDB0TxVV9liHxSev55Uz Kpie4OEbLbFRfQ+mushRrpRjo5zhEN4XJwHExmQ8fJhbvqBL8BO5dQhQkinE+tTTC75l baY8nOCDX9ChXoOVu0ih7Oudm0ZqcWbFn0ZTZkVCkUdQsplhIxEdRVsFrSjXJRgmdN16 AyYw== X-Gm-Message-State: AGi0PuZP2NIhXFG2wxcIiQTyBAt2fFOK+jJoJGvjmMCLRSX+BhR0uX+C z3CfQHsP9opBd/o5QGJp/N4kZTwC X-Google-Smtp-Source: APiQypJre+p7tYpetzTZIfrVn4t2xNJMFu8ZFqEG4jD3HF0nsHIlaOKRMGtvoqGTxk1ACwYtI7Dccg== X-Received: by 2002:a63:b606:: with SMTP id j6mr1098199pgf.334.1588283177557; Thu, 30 Apr 2020 14:46:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:4b5c:: with SMTP id k28ls4115109pgl.0.gmail; Thu, 30 Apr 2020 14:46:17 -0700 (PDT) X-Received: by 2002:a63:ce53:: with SMTP id r19mr941052pgi.395.1588283176611; Thu, 30 Apr 2020 14:46:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588283176; cv=none; d=google.com; s=arc-20160816; b=Of/rTREuuD3K+xnT1SC+MyzgUUIr/jDd6VIZGnh5QA3Xefm3YBAxZDSltoApLxu1He AcWg3vMqLBkUwn+zJcOmvCu8vCcbioBZDbASpraJE2e0S36WOwTzS0/FyaHyZe7je9+T DZjfz+ZUZGTToMPj40mP0Ln/ShipiDOMs3iOzHk/QVV+YbqwpFBygTvKfyZO73QAOzMC +31eyRHPdH8d/rzaxxAc/JQ9tDd5FwllbJ3jsnmFmCrZqLj4j45uMKkMQzPd3mkp7YDc L7Y869epkaQ/ufg6DN6NL0qzRNgUPCM8cTdbO9e7WwKSfiNY8FTfPcGHASQZRZMYkNGC hHoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GHqGyS+RUNZNqKAv2qm8I0WbTjNQhsUbrp1rtNyYubk=; b=Ce9aJml3MeSS58GHbVl0PDQHOz6t2q8sNmMnF6ojKqKZTJ87qWiX3JwZ/42MtNwhyr 9yjwC/QQUyeW0FwJSeKABmRk6f0fQXE8B98hDguXD39M1dqljHuZMNV9p4M0MVssjS0D +apJNtiEKfKtjVP0hZe5BEMQSg6rpmubxPk1EcNzGyBy1yziBtgoVLKsZfLTOODqAPHR joIuDO4NcAliJ5pXIqr/btIJtKgZXiQBXBVP4GpCi0oGq0urLdCP6ogaPh3ztsJduvBZ ePmEqAdhBkROKETnETQOmKb5Lg0sQnCPv3br3ZyNM0nJPRf/UCuebFgjX7l3SaYnMZPy TAxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Amp9dCYN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id c8sor1109218pjs.19.2020.04.30.14.46.16 for (Google Transport Security); Thu, 30 Apr 2020 14:46:16 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90a:8c3:: with SMTP id 3mr946549pjn.147.1588283176252; Thu, 30 Apr 2020 14:46:16 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:a9f2:11c6:8c6c:2861]) by smtp.gmail.com with ESMTPSA id p64sm615243pjp.7.2020.04.30.14.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:46:15 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich , Tom Rini , Frank Wang , William Wu , Shawn Lin , Heiko Stuebner , Patrice Chotard Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [RFC 6/7] pci: rockchip: Switch to generic-phy Date: Fri, 1 May 2020 03:15:28 +0530 Message-Id: <20200430214529.18887-7-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214529.18887-1-jagan@amarulasolutions.com> References: <20200430214529.18887-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Amp9dCYN; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Now, we have a PCIe PHY driver as part of the Generic PHY framework. Let's use it instead of legacy PHY driver. Signed-off-by: Jagan Teki --- drivers/pci/pcie_rockchip.c | 20 ++++++++++---------- drivers/pci/pcie_rockchip.h | 5 +++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c index 82a8396e42..3e4ba9635f 100644 --- a/drivers/pci/pcie_rockchip.c +++ b/drivers/pci/pcie_rockchip.c @@ -159,8 +159,6 @@ static int rockchip_pcie_atr_init(struct rockchip_pcie *priv) static int rockchip_pcie_init_port(struct udevice *dev) { struct rockchip_pcie *priv = dev_get_priv(dev); - struct rockchip_pcie_phy *phy = pcie_get_phy(priv); - struct rockchip_pcie_phy_ops *ops = phy_get_ops(phy); u32 cr, val, status; int ret; @@ -185,7 +183,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) return ret; } - ret = ops->init(phy); + ret = generic_phy_init(&priv->pcie_phy); if (ret) { dev_err(dev, "failed to init phy (ret=%d)\n", ret); goto err_exit_phy; @@ -242,7 +240,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) cr |= PCIE_CLIENT_CONF_ENABLE | PCIE_CLIENT_MODE_RC; writel(cr, priv->apb_base + PCIE_CLIENT_CONFIG); - ret = ops->power_on(phy); + ret = generic_phy_power_on(&priv->pcie_phy); if (ret) { dev_err(dev, "failed to power on phy (ret=%d)\n", ret); goto err_power_off_phy; @@ -311,9 +309,9 @@ static int rockchip_pcie_init_port(struct udevice *dev) return 0; err_power_off_phy: - ops->power_off(phy); + generic_phy_power_off(&priv->pcie_phy); err_exit_phy: - ops->exit(phy); + generic_phy_exit(&priv->pcie_phy); return ret; } @@ -436,6 +434,12 @@ static int rockchip_pcie_parse_dt(struct udevice *dev) return ret; } + ret = generic_phy_get_by_index(dev, 0, &priv->pcie_phy); + if (ret) { + dev_err(dev, "failed to get pcie-phy (ret=%d)\n", ret); + return ret; + } + return 0; } @@ -453,10 +457,6 @@ static int rockchip_pcie_probe(struct udevice *dev) if (ret) return ret; - ret = rockchip_pcie_phy_get(dev); - if (ret) - return ret; - ret = rockchip_pcie_set_vpcie(dev); if (ret) return ret; diff --git a/drivers/pci/pcie_rockchip.h b/drivers/pci/pcie_rockchip.h index c3a0a2846d..4b06110bfe 100644 --- a/drivers/pci/pcie_rockchip.h +++ b/drivers/pci/pcie_rockchip.h @@ -9,6 +9,8 @@ * */ +#include + #define HIWORD_UPDATE(mask, val) (((mask) << 16) | (val)) #define HIWORD_UPDATE_BIT(val) HIWORD_UPDATE(val, val) @@ -126,6 +128,9 @@ struct rockchip_pcie { struct udevice *vpcie3v3; struct udevice *vpcie1v8; struct udevice *vpcie0v9; + + /* phy */ + struct phy pcie_phy; }; int rockchip_pcie_phy_get(struct udevice *dev); From patchwork Thu Apr 30 21:45:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1147 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B79B03F077 for ; Thu, 30 Apr 2020 23:46:23 +0200 (CEST) Received: by mail-oi1-f200.google.com with SMTP id w21sf519408oia.14 for ; Thu, 30 Apr 2020 14:46:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588283182; cv=pass; d=google.com; s=arc-20160816; b=S5T96taMrdZVhq4peneUhG7cZ6Lwq9VF42XPKeOqhvr+M0RFPYla80r/RDvGnRT1hC zaBlEExUotmZpfetBnmuWigjnpoCFk+fIBHgo2FAW/KBeFyWlFeeNhzwMcBRTdeYjnmN 90TN88+UL0dUdW9y9wqgo3l7LAKFTdSuDrxuXjnJNDx8+uMuVLARKEyCnUIjNbUhHDIr IoCf66VtGelu4rjS1ZYDdyXcmyKDn/U4E7xnZ2+WNtfsS9XixE+gnagFN+M85wiIxwih XMakIl9Anz8z5X7pxLYSqGJPlFyWnizHPcrKZ6HmngewrEEB/HZBtJUGKWODaV+9S8ff l3Ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=nxIm+7iYqsQfpWEDyZcTHQjlBEnI2LbMgenDQrS/mEQ=; b=zpCRuot5GFh+uoneRrSu0fHizuOD44+RxLGS1GWhq0LZsE6/+VfsDTSCSSmCZ3MRxi EcNBUKX8UJXA0X0DAs9T05vQ59i0TNxd1z+mlYirpVEreHXEuNp5Mw/Pg1uEdVNIyVIw uI6Bebjxfxltcy6/jGU6rA1lSWciK11RvT/ikseKDiTYRnsl3usrXSKEZqKE9deUm5c2 in+Gmoz64IcSoHwDdjDz7Wu/CWjhvj2x2knoEi/M+rn/5oGkWsnjVlHyLgWP2yhdcOxB PibvpnVwxE7CWoVYmGCk1BnSvA4mNU1njNfMtprIrTvWgGfwNtNLaQ/wNdrErbT9v/cS WE+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Af8s7f5o; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=nxIm+7iYqsQfpWEDyZcTHQjlBEnI2LbMgenDQrS/mEQ=; b=Hq/nkdBBt2tqcuTPqVp1UIwKgTmp5+Cnjk2bJlEWM+IA9vh/vtcDMm47Yw1GxdkWMh WqwfoDcXfPlHTfjayupwGG5zIxxTf0hmUPiz9s7EhMEniKipnhsOLJ0/SZI1m4bl11gA VC1himD6JtUu5yW/5IZPCBiC6Jw+DnkoM/Zeg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=nxIm+7iYqsQfpWEDyZcTHQjlBEnI2LbMgenDQrS/mEQ=; b=UYoaOLeUhzw+CL4K/3hRoozp2zFo14NJgsY1pvsGTO5JbRjL28h+BDQbZHpezlI18y UUVnjTtfAh+3Dd+GBpeAfivNtQIpoXmNactgLOwIO2QP9KvlwUCGf3ZXA1srizD/v6HW brwg07XwxqHet1r+g4w/AICjf9d9wTA6hMH2XkWCRpO9pGGtOKQoPwJPyxSrfGS6ACuf bjdSePsAB6DZMvfQccFQDHcH/Y3+h4Y/zHWak+5NAhzaj9XO7kGTbvgKzsbkHislHFMN xYU+wsjhOmjWpBiPO/OchmKRvNpRXUh8d29WA4ZYG3mKesXbc16fVIwy6oLqU8E0lO7E VabQ== X-Gm-Message-State: AGi0PuZ+gf83mKQU0FLPiqhvGRH1ulqMtFu7pliVhY3opkFa+e9OFxeF YNx5YlDgdeZZWDFaijRj5WATyumv X-Google-Smtp-Source: APiQypIhqqKxNaeM/D2AxGBDIvYsk+ww32+ZXkdDQNywiHSJLE6aYolJ6unM1+M1fd+mirNor1QwGQ== X-Received: by 2002:a4a:e0d4:: with SMTP id e20mr1126824oot.35.1588283181910; Thu, 30 Apr 2020 14:46:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aca:c648:: with SMTP id w69ls2128925oif.7.gmail; Thu, 30 Apr 2020 14:46:21 -0700 (PDT) X-Received: by 2002:aca:4a45:: with SMTP id x66mr888213oia.48.1588283181382; Thu, 30 Apr 2020 14:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588283181; cv=none; d=google.com; s=arc-20160816; b=lVlyrzHRhPbIUfGU6SIQ7pexqdxXvG95peXGeDqmsvQsIIpwAystLohr/FMdyhH5CY JBUUC6ovvUdW3Fu7NuOycwMY9uHxYGkPjp2pIblGNIlnV9m9dV3sQ1zi5Utoxpmxdv+L 7ugh7l+6kSTbt+AfVBVeqOYn8O1R8TO7RpVhYUu4LmWYn5M84SvM2bt06mQbVmZuCK4g yEMvN5l7nHpHUOVK0zLeoPubmHyojNDcl7pojOyKEtP7A8lgKPCK6+UcSVgXHVPC731w QyfEf9GwzC600y8o/6G9eNPQAchHGPKAHY1itxL4S1C5qWDrdxPzANIWtRaix5JcNqla ST7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xMV5+war9q+lO4Dguz3Z/0skJPu2J+02fu/fMUfRfPc=; b=lPTDNst5ZzTvHsQzk6LAUz27MdqataJh8JSnFCQ4xL5bJaLzhmran19dFAfQCvd19G StZVaLebupUBttC9ziy2m9k480MqDjw3UhFG7TmZpEJiDX47U7Cea00F9CgNPaGD0KvB q00G5lnA4WxgtrjwWjb7i4IquRIj+URUDzC1v4jbbXmthn8+ZTZU42B+beg+0Sr9pHb8 I5uUzmE0nxke/On6ir6SkIhN8zgpt+FG1HC3AB3bmOm7hMzq+/4vT+aG1kA6S1xo0g82 ggpUuaTF9RBSzhMLaqdTLzrVYjRV2G2Id+alTuVqQB3gScxVquWggWc5Gq0vHyTw7QLY 4nFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Af8s7f5o; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r204sor1009932oie.54.2020.04.30.14.46.21 for (Google Transport Security); Thu, 30 Apr 2020 14:46:21 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:7742:: with SMTP id s63mr1014611pgc.133.1588283180854; Thu, 30 Apr 2020 14:46:20 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:a9f2:11c6:8c6c:2861]) by smtp.gmail.com with ESMTPSA id p64sm615243pjp.7.2020.04.30.14.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 14:46:19 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich , Tom Rini , Frank Wang , William Wu , Shawn Lin , Heiko Stuebner , Patrice Chotard Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [RFC 7/7] pci: rockchip: Drop legacy PHY driver Date: Fri, 1 May 2020 03:15:29 +0530 Message-Id: <20200430214529.18887-8-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430214529.18887-1-jagan@amarulasolutions.com> References: <20200430214529.18887-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Af8s7f5o; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Drop the legacy PHY driver and it's associated code since the PHY handling driver now part of Generic PHY framework. Signed-off-by: Jagan Teki --- drivers/pci/Makefile | 2 +- drivers/pci/pcie_rockchip.c | 75 +++++++++++- drivers/pci/pcie_rockchip.h | 147 ----------------------- drivers/pci/pcie_rockchip_phy.c | 205 -------------------------------- 4 files changed, 74 insertions(+), 355 deletions(-) delete mode 100644 drivers/pci/pcie_rockchip.h delete mode 100644 drivers/pci/pcie_rockchip_phy.c diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 955351c5c2..493e9354dd 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -43,4 +43,4 @@ obj-$(CONFIG_PCI_PHYTIUM) += pcie_phytium.o obj-$(CONFIG_PCIE_INTEL_FPGA) += pcie_intel_fpga.o obj-$(CONFIG_PCI_KEYSTONE) += pcie_dw_ti.o obj-$(CONFIG_PCIE_MEDIATEK) += pcie_mediatek.o -obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o pcie_rockchip_phy.o +obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c index 3e4ba9635f..cf24479f85 100644 --- a/drivers/pci/pcie_rockchip.c +++ b/drivers/pci/pcie_rockchip.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -25,10 +26,80 @@ #include #include -#include "pcie_rockchip.h" - DECLARE_GLOBAL_DATA_PTR; +#define HIWORD_UPDATE(mask, val) (((mask) << 16) | (val)) +#define HIWORD_UPDATE_BIT(val) HIWORD_UPDATE(val, val) + +#define ENCODE_LANES(x) ((((x) >> 1) & 3) << 4) +#define PCIE_CLIENT_BASE 0x0 +#define PCIE_CLIENT_CONFIG (PCIE_CLIENT_BASE + 0x00) +#define PCIE_CLIENT_CONF_ENABLE HIWORD_UPDATE_BIT(0x0001) +#define PCIE_CLIENT_LINK_TRAIN_ENABLE HIWORD_UPDATE_BIT(0x0002) +#define PCIE_CLIENT_MODE_RC HIWORD_UPDATE_BIT(0x0040) +#define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0) +#define PCIE_CLIENT_BASIC_STATUS1 0x0048 +#define PCIE_CLIENT_LINK_STATUS_UP GENMASK(21, 20) +#define PCIE_CLIENT_LINK_STATUS_MASK GENMASK(21, 20) +#define PCIE_LINK_UP(x) \ + (((x) & PCIE_CLIENT_LINK_STATUS_MASK) == PCIE_CLIENT_LINK_STATUS_UP) +#define PCIE_RC_NORMAL_BASE 0x800000 +#define PCIE_LM_BASE 0x900000 +#define PCIE_LM_VENDOR_ID (PCIE_LM_BASE + 0x44) +#define PCIE_LM_VENDOR_ROCKCHIP 0x1d87 +#define PCIE_LM_RCBAR (PCIE_LM_BASE + 0x300) +#define PCIE_LM_RCBARPIE BIT(19) +#define PCIE_LM_RCBARPIS BIT(20) +#define PCIE_RC_BASE 0xa00000 +#define PCIE_RC_CONFIG_DCR (PCIE_RC_BASE + 0x0c4) +#define PCIE_RC_CONFIG_DCR_CSPL_SHIFT 18 +#define PCIE_RC_CONFIG_DCR_CPLS_SHIFT 26 +#define PCIE_RC_PCIE_LCAP (PCIE_RC_BASE + 0x0cc) +#define PCIE_RC_PCIE_LCAP_APMS_L0S BIT(10) +#define PCIE_ATR_BASE 0xc00000 +#define PCIE_ATR_OB_ADDR0(i) (PCIE_ATR_BASE + 0x000 + (i) * 0x20) +#define PCIE_ATR_OB_ADDR1(i) (PCIE_ATR_BASE + 0x004 + (i) * 0x20) +#define PCIE_ATR_OB_DESC0(i) (PCIE_ATR_BASE + 0x008 + (i) * 0x20) +#define PCIE_ATR_OB_DESC1(i) (PCIE_ATR_BASE + 0x00c + (i) * 0x20) +#define PCIE_ATR_IB_ADDR0(i) (PCIE_ATR_BASE + 0x800 + (i) * 0x8) +#define PCIE_ATR_IB_ADDR1(i) (PCIE_ATR_BASE + 0x804 + (i) * 0x8) +#define PCIE_ATR_HDR_MEM 0x2 +#define PCIE_ATR_HDR_IO 0x6 +#define PCIE_ATR_HDR_CFG_TYPE0 0xa +#define PCIE_ATR_HDR_CFG_TYPE1 0xb +#define PCIE_ATR_HDR_RID BIT(23) + +#define PCIE_ATR_OB_REGION0_SIZE (32 * 1024 * 1024) +#define PCIE_ATR_OB_REGION_SIZE (1 * 1024 * 1024) + +struct rockchip_pcie { + fdt_addr_t axi_base; + fdt_addr_t apb_base; + int first_busno; + struct udevice *dev; + + /* resets */ + struct reset_ctl core_rst; + struct reset_ctl mgmt_rst; + struct reset_ctl mgmt_sticky_rst; + struct reset_ctl pipe_rst; + struct reset_ctl pm_rst; + struct reset_ctl pclk_rst; + struct reset_ctl aclk_rst; + + /* gpio */ + struct gpio_desc ep_gpio; + + /* vpcie regulators */ + struct udevice *vpcie12v; + struct udevice *vpcie3v3; + struct udevice *vpcie1v8; + struct udevice *vpcie0v9; + + /* phy */ + struct phy pcie_phy; +}; + static int rockchip_pcie_off_conf(pci_dev_t bdf, uint offset) { unsigned int bus = PCI_BUS(bdf); diff --git a/drivers/pci/pcie_rockchip.h b/drivers/pci/pcie_rockchip.h deleted file mode 100644 index 4b06110bfe..0000000000 --- a/drivers/pci/pcie_rockchip.h +++ /dev/null @@ -1,147 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Rockchip PCIe Headers - * - * Copyright (c) 2016 Rockchip, Inc. - * Copyright (c) 2020 Amarula Solutions(India) - * Copyright (c) 2020 Jagan Teki - * Copyright (c) 2019 Patrick Wildt - * - */ - -#include - -#define HIWORD_UPDATE(mask, val) (((mask) << 16) | (val)) -#define HIWORD_UPDATE_BIT(val) HIWORD_UPDATE(val, val) - -#define ENCODE_LANES(x) ((((x) >> 1) & 3) << 4) -#define PCIE_CLIENT_BASE 0x0 -#define PCIE_CLIENT_CONFIG (PCIE_CLIENT_BASE + 0x00) -#define PCIE_CLIENT_CONF_ENABLE HIWORD_UPDATE_BIT(0x0001) -#define PCIE_CLIENT_LINK_TRAIN_ENABLE HIWORD_UPDATE_BIT(0x0002) -#define PCIE_CLIENT_MODE_RC HIWORD_UPDATE_BIT(0x0040) -#define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0) -#define PCIE_CLIENT_BASIC_STATUS1 0x0048 -#define PCIE_CLIENT_LINK_STATUS_UP GENMASK(21, 20) -#define PCIE_CLIENT_LINK_STATUS_MASK GENMASK(21, 20) -#define PCIE_LINK_UP(x) \ - (((x) & PCIE_CLIENT_LINK_STATUS_MASK) == PCIE_CLIENT_LINK_STATUS_UP) -#define PCIE_RC_NORMAL_BASE 0x800000 -#define PCIE_LM_BASE 0x900000 -#define PCIE_LM_VENDOR_ID (PCIE_LM_BASE + 0x44) -#define PCIE_LM_VENDOR_ROCKCHIP 0x1d87 -#define PCIE_LM_RCBAR (PCIE_LM_BASE + 0x300) -#define PCIE_LM_RCBARPIE BIT(19) -#define PCIE_LM_RCBARPIS BIT(20) -#define PCIE_RC_BASE 0xa00000 -#define PCIE_RC_CONFIG_DCR (PCIE_RC_BASE + 0x0c4) -#define PCIE_RC_CONFIG_DCR_CSPL_SHIFT 18 -#define PCIE_RC_CONFIG_DCR_CPLS_SHIFT 26 -#define PCIE_RC_PCIE_LCAP (PCIE_RC_BASE + 0x0cc) -#define PCIE_RC_PCIE_LCAP_APMS_L0S BIT(10) -#define PCIE_ATR_BASE 0xc00000 -#define PCIE_ATR_OB_ADDR0(i) (PCIE_ATR_BASE + 0x000 + (i) * 0x20) -#define PCIE_ATR_OB_ADDR1(i) (PCIE_ATR_BASE + 0x004 + (i) * 0x20) -#define PCIE_ATR_OB_DESC0(i) (PCIE_ATR_BASE + 0x008 + (i) * 0x20) -#define PCIE_ATR_OB_DESC1(i) (PCIE_ATR_BASE + 0x00c + (i) * 0x20) -#define PCIE_ATR_IB_ADDR0(i) (PCIE_ATR_BASE + 0x800 + (i) * 0x8) -#define PCIE_ATR_IB_ADDR1(i) (PCIE_ATR_BASE + 0x804 + (i) * 0x8) -#define PCIE_ATR_HDR_MEM 0x2 -#define PCIE_ATR_HDR_IO 0x6 -#define PCIE_ATR_HDR_CFG_TYPE0 0xa -#define PCIE_ATR_HDR_CFG_TYPE1 0xb -#define PCIE_ATR_HDR_RID BIT(23) - -#define PCIE_ATR_OB_REGION0_SIZE (32 * 1024 * 1024) -#define PCIE_ATR_OB_REGION_SIZE (1 * 1024 * 1024) - -/* - * The higher 16-bit of this register is used for write protection - * only if BIT(x + 16) set to 1 the BIT(x) can be written. - */ -#define HIWORD_UPDATE_MASK(val, mask, shift) \ - ((val) << (shift) | (mask) << ((shift) + 16)) - -#define PHY_CFG_DATA_SHIFT 7 -#define PHY_CFG_ADDR_SHIFT 1 -#define PHY_CFG_DATA_MASK 0xf -#define PHY_CFG_ADDR_MASK 0x3f -#define PHY_CFG_RD_MASK 0x3ff -#define PHY_CFG_WR_ENABLE 1 -#define PHY_CFG_WR_DISABLE 1 -#define PHY_CFG_WR_SHIFT 0 -#define PHY_CFG_WR_MASK 1 -#define PHY_CFG_PLL_LOCK 0x10 -#define PHY_CFG_CLK_TEST 0x10 -#define PHY_CFG_CLK_SCC 0x12 -#define PHY_CFG_SEPE_RATE BIT(3) -#define PHY_CFG_PLL_100M BIT(3) -#define PHY_PLL_LOCKED BIT(9) -#define PHY_PLL_OUTPUT BIT(10) -#define PHY_LANE_IDLE_OFF 0x1 -#define PHY_LANE_IDLE_MASK 0x1 -#define PHY_LANE_IDLE_A_SHIFT 3 -#define PHY_LANE_IDLE_B_SHIFT 4 -#define PHY_LANE_IDLE_C_SHIFT 5 -#define PHY_LANE_IDLE_D_SHIFT 6 - -#define PCIE_PHY_CONF 0xe220 -#define PCIE_PHY_STATUS 0xe2a4 -#define PCIE_PHY_LANEOFF 0xe214 - -struct rockchip_pcie_phy { - void *reg_base; - struct clk refclk; - struct reset_ctl phy_rst; - struct rockchip_pcie_phy_ops *ops; -}; - -struct rockchip_pcie_phy_ops { - int (*init)(struct rockchip_pcie_phy *phy); - int (*exit)(struct rockchip_pcie_phy *phy); - int (*power_on)(struct rockchip_pcie_phy *phy); - int (*power_off)(struct rockchip_pcie_phy *phy); -}; - -struct rockchip_pcie { - fdt_addr_t axi_base; - fdt_addr_t apb_base; - int first_busno; - struct udevice *dev; - struct rockchip_pcie_phy rk_phy; - struct rockchip_pcie_phy *phy; - - /* resets */ - struct reset_ctl core_rst; - struct reset_ctl mgmt_rst; - struct reset_ctl mgmt_sticky_rst; - struct reset_ctl pipe_rst; - struct reset_ctl pm_rst; - struct reset_ctl pclk_rst; - struct reset_ctl aclk_rst; - - /* gpio */ - struct gpio_desc ep_gpio; - - /* vpcie regulators */ - struct udevice *vpcie12v; - struct udevice *vpcie3v3; - struct udevice *vpcie1v8; - struct udevice *vpcie0v9; - - /* phy */ - struct phy pcie_phy; -}; - -int rockchip_pcie_phy_get(struct udevice *dev); - -inline struct rockchip_pcie_phy *pcie_get_phy(struct rockchip_pcie *pcie) -{ - return pcie->phy; -} - -inline -struct rockchip_pcie_phy_ops *phy_get_ops(struct rockchip_pcie_phy *phy) -{ - return (struct rockchip_pcie_phy_ops *)phy->ops; -} diff --git a/drivers/pci/pcie_rockchip_phy.c b/drivers/pci/pcie_rockchip_phy.c deleted file mode 100644 index 47f5d6c7e3..0000000000 --- a/drivers/pci/pcie_rockchip_phy.c +++ /dev/null @@ -1,205 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Rockchip PCIe PHY driver - * - * Copyright (c) 2016 Rockchip, Inc. - * Copyright (c) 2020 Amarula Solutions(India) - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pcie_rockchip.h" - -DECLARE_GLOBAL_DATA_PTR; - -static void phy_wr_cfg(struct rockchip_pcie_phy *phy, u32 addr, u32 data) -{ - u32 reg; - - reg = HIWORD_UPDATE_MASK(data, PHY_CFG_DATA_MASK, PHY_CFG_DATA_SHIFT); - reg |= HIWORD_UPDATE_MASK(addr, PHY_CFG_ADDR_MASK, PHY_CFG_ADDR_SHIFT); - writel(reg, phy->reg_base + PCIE_PHY_CONF); - - udelay(1); - - reg = HIWORD_UPDATE_MASK(PHY_CFG_WR_ENABLE, - PHY_CFG_WR_MASK, - PHY_CFG_WR_SHIFT); - writel(reg, phy->reg_base + PCIE_PHY_CONF); - - udelay(1); - - reg = HIWORD_UPDATE_MASK(PHY_CFG_WR_DISABLE, - PHY_CFG_WR_MASK, - PHY_CFG_WR_SHIFT); - writel(reg, phy->reg_base + PCIE_PHY_CONF); -} - -static int rockchip_pcie_phy_power_on(struct rockchip_pcie_phy *phy) -{ - int ret = 0; - u32 reg, status; - - ret = reset_deassert(&phy->phy_rst); - if (ret) { - dev_err(dev, "failed to assert phy reset\n"); - return ret; - } - - reg = HIWORD_UPDATE_MASK(PHY_CFG_PLL_LOCK, - PHY_CFG_ADDR_MASK, - PHY_CFG_ADDR_SHIFT); - writel(reg, phy->reg_base + PCIE_PHY_CONF); - - reg = HIWORD_UPDATE_MASK(!PHY_LANE_IDLE_OFF, - PHY_LANE_IDLE_MASK, - PHY_LANE_IDLE_A_SHIFT); - writel(reg, phy->reg_base + PCIE_PHY_LANEOFF); - - ret = -EINVAL; - ret = readl_poll_sleep_timeout(phy->reg_base + PCIE_PHY_STATUS, - status, - status & PHY_PLL_LOCKED, - 20 * 1000, - 50); - if (ret) { - dev_err(&phy->dev, "pll lock timeout!\n"); - goto err_pll_lock; - } - - phy_wr_cfg(phy, PHY_CFG_CLK_TEST, PHY_CFG_SEPE_RATE); - phy_wr_cfg(phy, PHY_CFG_CLK_SCC, PHY_CFG_PLL_100M); - - ret = -ETIMEDOUT; - ret = readl_poll_sleep_timeout(phy->reg_base + PCIE_PHY_STATUS, - status, - !(status & PHY_PLL_OUTPUT), - 20 * 1000, - 50); - if (ret) { - dev_err(&phy->dev, "pll output enable timeout!\n"); - goto err_pll_lock; - } - - reg = HIWORD_UPDATE_MASK(PHY_CFG_PLL_LOCK, - PHY_CFG_ADDR_MASK, - PHY_CFG_ADDR_SHIFT); - writel(reg, phy->reg_base + PCIE_PHY_CONF); - - ret = -EINVAL; - ret = readl_poll_sleep_timeout(phy->reg_base + PCIE_PHY_STATUS, - status, - status & PHY_PLL_LOCKED, - 20 * 1000, - 50); - if (ret) { - dev_err(&phy->dev, "pll relock timeout!\n"); - goto err_pll_lock; - } - - return 0; - -err_pll_lock: - reset_assert(&phy->phy_rst); - return ret; -} - -static int rockchip_pcie_phy_power_off(struct rockchip_pcie_phy *phy) -{ - int ret; - u32 reg; - - reg = HIWORD_UPDATE_MASK(PHY_LANE_IDLE_OFF, - PHY_LANE_IDLE_MASK, - PHY_LANE_IDLE_A_SHIFT); - writel(reg, phy->reg_base + PCIE_PHY_LANEOFF); - - ret = reset_assert(&phy->phy_rst); - if (ret) { - dev_err(dev, "failed to assert phy reset\n"); - return ret; - } - - return 0; -} - -static int rockchip_pcie_phy_init(struct rockchip_pcie_phy *phy) -{ - int ret; - - ret = clk_enable(&phy->refclk); - if (ret) { - dev_err(dev, "failed to enable refclk clock\n"); - return ret; - } - - ret = reset_assert(&phy->phy_rst); - if (ret) { - dev_err(dev, "failed to assert phy reset\n"); - goto err_reset; - } - - return 0; - -err_reset: - clk_disable(&phy->refclk); - return ret; -} - -static int rockchip_pcie_phy_exit(struct rockchip_pcie_phy *phy) -{ - clk_disable(&phy->refclk); - - return 0; -} - -static struct rockchip_pcie_phy_ops pcie_phy_ops = { - .init = rockchip_pcie_phy_init, - .power_on = rockchip_pcie_phy_power_on, - .power_off = rockchip_pcie_phy_power_off, - .exit = rockchip_pcie_phy_exit, -}; - -int rockchip_pcie_phy_get(struct udevice *dev) -{ - struct rockchip_pcie *priv = dev_get_priv(dev); - struct rockchip_pcie_phy *phy_priv = &priv->rk_phy; - ofnode phy_node; - u32 phandle; - int ret; - - phandle = dev_read_u32_default(dev, "phys", 0); - phy_node = ofnode_get_by_phandle(phandle); - if (!ofnode_valid(phy_node)) { - dev_err(dev, "failed to found pcie-phy\n"); - return -ENODEV; - } - - phy_priv->reg_base = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); - - ret = clk_get_by_index_nodev(phy_node, 0, &phy_priv->refclk); - if (ret) { - dev_err(dev, "failed to get refclk clock phandle\n"); - return ret; - } - - ret = reset_get_by_index_nodev(phy_node, 0, &phy_priv->phy_rst); - if (ret) { - dev_err(dev, "failed to get phy reset phandle\n"); - return ret; - } - - phy_priv->ops = &pcie_phy_ops; - priv->phy = phy_priv; - - return 0; -}