From patchwork Wed Jan 11 19:22:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 9511071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9C3156075C for ; Wed, 11 Jan 2017 19:22:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9193C2867D for ; Wed, 11 Jan 2017 19:22:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83EFD2867A; Wed, 11 Jan 2017 19:22:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 128242867A for ; Wed, 11 Jan 2017 19:22:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cROTp-0000Qm-Cd; Wed, 11 Jan 2017 19:22:41 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cROTm-0000NZ-75 for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2017 19:22:39 +0000 Received: by mail-pg0-x242.google.com with SMTP id 75so16242693pgf.3 for ; Wed, 11 Jan 2017 11:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=757eejJxgCxtzd6e+leUDBRRdDEblE1srGmFb1R+ZJc=; b=HBB28cr2O/9TAqgZdtOqXty2sp8IBdSJ1vuLiA9VI2kbPc7hokYzuurN6YNTFh5WsW 4QMtKL0BjmQw2Yc86U5li4JsSIbmOI1Qc/aa6YW99Lhnc9iS6c2zlBELP8hht803rtln n2/nBWNhsa6zQ7Wp/Djhv5juhExe1XgoCBINMIZZiACKzcM6ELFtk3M9vyb0g+CeXt08 mV4vFlamohF+djCUQ4dICNqdph5xist6fvSMISxIYOqn/3PqmV8s6q8C5mOTQyqzzVM8 dR6AbnvDa/sfx1YS280ZcG/kYwIL3rRUdOHpJ+wNRwoJdxddyNO0nwwHIYcYA9A8SV8U Uovg== 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; bh=757eejJxgCxtzd6e+leUDBRRdDEblE1srGmFb1R+ZJc=; b=jgdvtw1otvUXGDKqZqtYB6qdKU1KY87NPPzi7tRPoYbSDeTOidrdsELdqkcj12Bwvm kjHQKpL/C0m3ODBckm7NC8GbfhYfS7HZ2DPs7GCnD69FqgsWwf68IWPfYZ4JmDRc1Kn9 +0h4qMMmanLz4Rs7oe75xayKuqHxV8xDIvT2WPhVy8lAuCVfMCPInyxg0faZIk11xCU0 0utRenU8WPGrSb3TG8i5VgYTkLr8PyRSu+Tz6k4wQ9txmU6TslABM9IfoXqYrUR0Ydfz PjjGpXpIiQHdsZbAVZG6aL5bdjmGtdIxxmcvL21T1DfYPNiPiYzFcQbbJVRI8/YGsJpx nsVA== X-Gm-Message-State: AIkVDXJEr+28dVtX/rTMvbmAH2g9d2rrdZdEgKRTb3Nfp61l/wvVmM8FMBBHRT862bP7jQ== X-Received: by 10.98.35.25 with SMTP id j25mr5334096pfj.35.1484162535299; Wed, 11 Jan 2017 11:22:15 -0800 (PST) Received: from ddl.caveonetworks.com (50-233-148-156-static.hfc.comcastbusiness.net. [50.233.148.156]) by smtp.gmail.com with ESMTPSA id t129sm15733143pgc.32.2017.01.11.11.22.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jan 2017 11:22:14 -0800 (PST) From: David Daney To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Bjorn Helgaas , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] PCI: thunder-pem: Add support for cn81xx and cn83xx SoCs. Date: Wed, 11 Jan 2017 11:22:11 -0800 Message-Id: <20170111192211.29049-1-ddaney.cavm@gmail.com> X-Mailer: git-send-email 2.9.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170111_112238_309327_445AC8C3 X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Daney MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: David Daney The pci-thunder-pem driver was initially developed for cn88xx SoCs. The cn81xx and cn83xx members of the same family of SoCs has a slightly different configuration of interrupt resources in the PEM hardware, which prevents the INTA legacy interrupt source from functioning with the current driver. There are two fixes required: 1) Don't fixup the PME interrupt on the newer SoCs as it already has the proper value. 2) Report MSI-X Capability Table Size of 2 for the newer SoCs, so the core MSI-X code doesn't inadvertently clobber the INTA machinery that happens to reside immediately following the table. Signed-off-by: David Daney --- Changes from v1: Fixed comment typo. drivers/pci/host/pci-thunder-pem.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/pci/host/pci-thunder-pem.c b/drivers/pci/host/pci-thunder-pem.c index af722eb..52b5bdc 100644 --- a/drivers/pci/host/pci-thunder-pem.c +++ b/drivers/pci/host/pci-thunder-pem.c @@ -36,7 +36,7 @@ struct thunder_pem_pci { static int thunder_pem_bridge_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { - u64 read_val; + u64 read_val, tmp_val; struct pci_config_window *cfg = bus->sysdata; struct thunder_pem_pci *pem_pci = (struct thunder_pem_pci *)cfg->priv; @@ -65,13 +65,28 @@ static int thunder_pem_bridge_read(struct pci_bus *bus, unsigned int devfn, read_val |= 0x00007000; /* Skip MSI CAP */ break; case 0x70: /* Express Cap */ - /* PME interrupt on vector 2*/ - read_val |= (2u << 25); + /* + * Change PME interrupt to vector 2 on T88 where it + * reads as 0, else leave it alone. + */ + if (!(read_val & (0x1f << 25))) + read_val |= (2u << 25); break; case 0xb0: /* MSI-X Cap */ - /* TableSize=4, Next Cap is EA */ + /* TableSize=2 or 4, Next Cap is EA */ read_val &= 0xc00000ff; - read_val |= 0x0003bc00; + /* + * If Express Cap(0x70) raw PME vector reads as 0 we are on + * T88 and TableSize is reported as 4, else TableSize + * is 2. + */ + writeq(0x70, pem_pci->pem_reg_base + PEM_CFG_RD); + tmp_val = readq(pem_pci->pem_reg_base + PEM_CFG_RD); + tmp_val >>= 32; + if (!(tmp_val & (0x1f << 25))) + read_val |= 0x0003bc00; + else + read_val |= 0x0001bc00; break; case 0xb4: /* Table offset=0, BIR=0 */