From patchwork Thu Mar 15 10:57:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinh Nguyen Huu Tuong X-Patchwork-Id: 146873 X-Patchwork-Delegate: jwboyer@gmail.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id A2C8DB6FA9 for ; Thu, 15 Mar 2012 21:58:50 +1100 (EST) Received: from exprod5og111.obsmtp.com (exprod5og111.obsmtp.com [64.18.0.22]) by ozlabs.org (Postfix) with SMTP id DD5C8B6FAF for ; Thu, 15 Mar 2012 21:57:29 +1100 (EST) Received: from mail-yx0-f172.google.com ([209.85.213.172]) (using TLSv1) by exprod5ob111.postini.com ([64.18.4.12]) with SMTP ID DSNKT2HLF/snubM71bXcL6WxoI3RiYWNETLG@postini.com; Thu, 15 Mar 2012 03:57:30 PDT Received: by yenm5 with SMTP id m5so3847606yen.17 for ; Thu, 15 Mar 2012 03:57:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=mTq4Zk7HesDseYm5zoT8hV3RC4BuEKFuE5EhgFn/DmM=; b=ckccbGa33Dv/HNNpXjVp9D6tILBG1T8HO0xvxKe/zB269AWaKxeOuapeEijU6tdBSy rkhHq2+dEjIBHXluoqxwYSEIapznarbPZTWyfWoUbXPXTV/VGEIoE7zotFOtpbrzcnC+ YEDIB+gm0OFIVPzzsPtLpLSgiX8dKoAAnU49+Ve8XLYCOrltzUfagBrqbrcEHyjpLpp4 3R0ZssYnZkFmHv0eATdhnpc7HS35ZaFUHw7RSFjpBPF3t0SciFj+c13ODBa0WmUwC9/T +vygucRYU3DtObMgA/zquDP6Ghq+F5GBqSk9OCMvEQsd7qAtsTivNfxyp+R+MJamvXhq R0/A== Received: by 10.68.135.74 with SMTP id pq10mr4510713pbb.24.1331809047305; Thu, 15 Mar 2012 03:57:27 -0700 (PDT) Received: from localhost.localdomain ([118.69.219.194]) by mx.google.com with ESMTPS id d6sm1660669pbi.23.2012.03.15.03.57.22 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Mar 2012 03:57:26 -0700 (PDT) From: Vinh Nguyen Huu Tuong To: Benjamin Herrenschmidt , Paul Mackerras , Josh Boyer , Matt Porter , Tirumala R Marri , Grant Likely , Michael Neuling , Kumar Gala , Anton Blanchard , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] powerpc/44x: Add support PCI-E for APM821xx SoC and Bluestone board Date: Thu, 15 Mar 2012 17:57:19 +0700 Message-Id: <1331809039-15405-1-git-send-email-vhtnguyen@apm.com> X-Mailer: git-send-email 1.7.2.5 X-Gm-Message-State: ALoCoQnSayZOu0I2YMp3oMdcWWfKwVfoX6VZlTkVNTKgBNunlqO7+F+YlRK6MZ4Qx7Kh1XA4ref4 Cc: Vinh Nguyen Huu Tuong , open-source-review@apm.com, Phong Vo , Duc Dang , Thang Nguyen , Mai La , Sang Pham X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org This patch extends PCI-E driver to support PCI-E for APM821xx SoC on Bluestone board. Notes: this patch includes the fix base on Duc comment. Signed-off-by: Vinh Nguyen Huu Tuong --- arch/powerpc/platforms/44x/Kconfig | 1 + arch/powerpc/sysdev/ppc4xx_pci.c | 70 ++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/platforms/44x/Kconfig b/arch/powerpc/platforms/44x/Kconfig index 5d5aaf6..c1e9896 100644 --- a/arch/powerpc/platforms/44x/Kconfig +++ b/arch/powerpc/platforms/44x/Kconfig @@ -23,6 +23,7 @@ config BLUESTONE default n select PPC44x_SIMPLE select APM821xx + select PPC4xx_PCI_EXPRESS select IBM_EMAC_RGMII help This option enables support for the APM APM821xx Evaluation board. diff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/sysdev/ppc4xx_pci.c index 4f05f75..ed3ca9e 100644 --- a/arch/powerpc/sysdev/ppc4xx_pci.c +++ b/arch/powerpc/sysdev/ppc4xx_pci.c @@ -1050,6 +1050,74 @@ static struct ppc4xx_pciex_hwops ppc460ex_pcie_hwops __initdata = .check_link = ppc4xx_pciex_check_link_sdr, }; +static int __init apm821xx_pciex_core_init(struct device_node *np) +{ + /* Return the number of pcie port */ + return 1; +} + +static int apm821xx_pciex_init_port_hw(struct ppc4xx_pciex_port *port) +{ + u32 val; + + /* + * Do a software reset on PCIe ports. + * This code is to fix the issue that pci drivers doesn't re-assign + * bus number for PCIE devices after Uboot + * scanned and configured all the buses (eg. PCIE NIC IntelPro/1000 + * PT quad port, SAS LSI 1064E) + */ + + mtdcri(SDR0, PESDR0_460EX_PHY_CTL_RST, 0x0); + mdelay(10); + + if (port->endpoint) + val = PTYPE_LEGACY_ENDPOINT << 20; + else + val = PTYPE_ROOT_PORT << 20; + + val |= LNKW_X1 << 12; + + mtdcri(SDR0, port->sdr_base + PESDRn_DLPSET, val); + mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET1, 0x00000000); + mtdcri(SDR0, port->sdr_base + PESDRn_UTLSET2, 0x01010000); + + mtdcri(SDR0, PESDR0_460EX_L0CDRCTL, 0x00003230); + mtdcri(SDR0, PESDR0_460EX_L0DRV, 0x00000130); + mtdcri(SDR0, PESDR0_460EX_L0CLK, 0x00000006); + + mtdcri(SDR0, PESDR0_460EX_PHY_CTL_RST, 0x10000000); + mdelay(50); + mtdcri(SDR0, PESDR0_460EX_PHY_CTL_RST, 0x30000000); + + mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, + mfdcri(SDR0, port->sdr_base + PESDRn_RCSSET) | + (PESDRx_RCSSET_RSTGU | PESDRx_RCSSET_RSTPYN)); + + /* Poll for PHY reset */ + val = PESDR0_460EX_RSTSTA - port->sdr_base; + if (ppc4xx_pciex_wait_on_sdr(port, val, 0x1, 1, 100)) { + printk(KERN_WARNING "PCIE: Can't reset PHY\n"); + return -EBUSY; + } else { + mtdcri(SDR0, port->sdr_base + PESDRn_RCSSET, + (mfdcri(SDR0, port->sdr_base + PESDRn_RCSSET) & + ~(PESDRx_RCSSET_RSTGU | PESDRx_RCSSET_RSTDL)) | + PESDRx_RCSSET_RSTPYN); + + port->has_ibpre = 1; + return 0; + } +} + +static struct ppc4xx_pciex_hwops apm821xx_pcie_hwops __initdata = { + .want_sdr = true, + .core_init = apm821xx_pciex_core_init, + .port_init_hw = apm821xx_pciex_init_port_hw, + .setup_utl = ppc460ex_pciex_init_utl, + .check_link = ppc4xx_pciex_check_link_sdr, +}; + static int __init ppc460sx_pciex_core_init(struct device_node *np) { /* HSS drive amplitude */ @@ -1362,6 +1430,8 @@ static int __init ppc4xx_pciex_check_core_init(struct device_node *np) ppc4xx_pciex_hwops = &ppc460ex_pcie_hwops; if (of_device_is_compatible(np, "ibm,plb-pciex-460sx")) ppc4xx_pciex_hwops = &ppc460sx_pcie_hwops; + if (of_device_is_compatible(np, "ibm,plb-pciex-apm821xx")) + ppc4xx_pciex_hwops = &apm821xx_pcie_hwops; #endif /* CONFIG_44x */ #ifdef CONFIG_40x if (of_device_is_compatible(np, "ibm,plb-pciex-405ex"))