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; -}