From patchwork Mon Jun 30 21:45:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 32793 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1F8A1203C0 for ; Mon, 30 Jun 2014 21:46:34 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf47173505pab.7 for ; Mon, 30 Jun 2014 14:46:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=GPIqP/b0pUB0GfGj3VDVpHXOmxujsp31tJ11XVA1CAY=; b=gAFj96ncy1naS5fL4j5ZAfUOlEjwcuFEr/bp1t0SRN0dzlj6Hy0bSY+FrjGQnMgi3n 4/Jbqg5eUpZ62a8vqO8qodhY0QDCoNqc6zwnCXghx0CGFRlZvfd34PObv/pyH3UA/cxc wdaAas6mfvYbnq2WC7MKiL0rbQ9T/Rs1VNMj/Wa5R9N2oynAVEeZ+bCzyuz9XQgl7R1H 1UqNpmFJ2f1PhgbSI7sDKVbE4+jpJIOpbvm+sH1rCfnWkws6lkHDFAsY85/WvVLPPZDF xIi/L4gfGNIYZHBEr5AT0fZ2bmhmo0og3D9Z1OMc8GRNd56/hkmA50akjQj7PSUpGCId WVpA== X-Gm-Message-State: ALoCoQmcqXffjTw3wwDjfH5dQ7/JovC8TzztbldVuwtxBI7qU2hJzVXJy/8hTw70mpS0hyduQydp X-Received: by 10.66.160.34 with SMTP id xh2mr22781854pab.6.1404164794049; Mon, 30 Jun 2014 14:46:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.107 with SMTP id h98ls1035934qge.68.gmail; Mon, 30 Jun 2014 14:46:33 -0700 (PDT) X-Received: by 10.58.208.170 with SMTP id mf10mr22745357vec.22.1404164793867; Mon, 30 Jun 2014 14:46:33 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id gv1si10622395vdb.27.2014.06.30.14.46.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 14:46:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.182 as permitted sender) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id oy12so8792758veb.13 for ; Mon, 30 Jun 2014 14:46:33 -0700 (PDT) X-Received: by 10.58.188.199 with SMTP id gc7mr36614152vec.4.1404164793745; Mon, 30 Jun 2014 14:46:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp170795vcb; Mon, 30 Jun 2014 14:46:33 -0700 (PDT) X-Received: by 10.68.254.70 with SMTP id ag6mr55024287pbd.33.1404164792991; Mon, 30 Jun 2014 14:46:32 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zi2si24594948pbb.138.2014.06.30.14.46.32; Mon, 30 Jun 2014 14:46:32 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751671AbaF3Vqa (ORCPT + 8 others); Mon, 30 Jun 2014 17:46:30 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:47200 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751224AbaF3Vq1 (ORCPT ); Mon, 30 Jun 2014 17:46:27 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id s5ULjQ9n012192; Mon, 30 Jun 2014 16:45:26 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5ULjQh2029415; Mon, 30 Jun 2014 16:45:26 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.174.1; Mon, 30 Jun 2014 16:45:26 -0500 Received: from localhost.localdomain (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id s5ULjKaY001990; Mon, 30 Jun 2014 16:45:25 -0500 From: Murali Karicheri To: , , CC: Murali Karicheri , Santosh Shilimkar , Russell King , Grant Likely , Rob Herring , Mohit Kumar , Jingoo Han , Bjorn Helgaas , Pratyush Anand , Richard Zhu , Kishon Vijay Abraham I , Marek Vasut , Arnd Bergmann , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Randy Dunlap Subject: [PATCH v3 4/5] PCI: designware: enhance dw core driver to support Keystone PCI host controller Date: Mon, 30 Jun 2014 17:45:19 -0400 Message-ID: <1404164720-11066-5-git-send-email-m-karicheri2@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1404164720-11066-1-git-send-email-m-karicheri2@ti.com> References: <1404164720-11066-1-git-send-email-m-karicheri2@ti.com> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m-karicheri2@ti.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add API dw_pcie_v3_65_host_init() to support host controller initialization for Keystone PCI driver. The Keystone PCI uses v3.65 version of the DW hardware identified by compatibility string "dw,snps-pcie-v3.65". This allow for different treatment for this version of the h/w during host initialization. Key differences in v3.65 DW h/w are 1. No ATU support 2. Legacy and MSI irq functions are implemented in application register space 3. MSI interrupts are multiplexed over 8 IRQ lines to the Host side. So a msi irq chip is needed and the irq domain ops ptr is passed in dw_pcie_v3_65_host_init() to allow re-use of common MSI code in dw core. The Keystone PCI host controller requires a modified pci scan function to allow setup BAR0 for EP's access to MSI_IRQ register in application register to raise MSI irq. So a ptr to pci hw ops struct is passed to the host init code. Keystone PCI controller re-uses the DW Core driver code wherever there is common functionality. So this patch makes these functions global and added their prototypes in pcie-designware.h to allow re-use on Keystone. Signed-off-by: Murali Karicheri CC: Santosh Shilimkar CC: Russell King CC: Grant Likely CC: Rob Herring CC: Mohit Kumar CC: Jingoo Han CC: Bjorn Helgaas CC: Pratyush Anand CC: Richard Zhu CC: Kishon Vijay Abraham I CC: Marek Vasut CC: Arnd Bergmann CC: Pawel Moll CC: Mark Rutland CC: Ian Campbell CC: Kumar Gala CC: Randy Dunlap CC: Grant Likely --- .../devicetree/bindings/pci/designware-pcie.txt | 2 + drivers/pci/host/pcie-designware.c | 39 ++++++++++++++++++-- drivers/pci/host/pcie-designware.h | 7 ++++ 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/designware-pcie.txt b/Documentation/devicetree/bindings/pci/designware-pcie.txt index d0d15ee..0cb10c0 100644 --- a/Documentation/devicetree/bindings/pci/designware-pcie.txt +++ b/Documentation/devicetree/bindings/pci/designware-pcie.txt @@ -2,6 +2,8 @@ Required properties: - compatible: should contain "snps,dw-pcie" to identify the core. + Additionally contains "dw,snps-pcie-v3.65" to identify v3.65 version of the DW + hardware. - #address-cells: set to <3> - #size-cells: set to <2> - device_type: set to "pci" diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c index c11e4de..4dcbebe 100644 --- a/drivers/pci/host/pcie-designware.c +++ b/drivers/pci/host/pcie-designware.c @@ -556,6 +556,37 @@ static int dw_pcie_msi_host_init(struct pcie_port *pp, return 0; } +int __init dw_pcie_v3_65_host_init(struct pcie_port *pp, struct hw_pci *hw, + struct device_node *msi_irqc_np, + const struct irq_domain_ops *msi_irq_ops) +{ + int ret = -EINVAL; + + /* check if compatible with v3.65 DW h/w */ + if (!of_device_is_compatible(pp->dev->of_node, "dw,snps-pcie-v3.65")) { + dev_err(pp->dev, + "PCI Controller not compatible with v3.65 DW h/w\n"); + goto out; + } + pp->version = DW_HW_V3_65; + + /* v3.65 PCI controller is expected to provide its own PCI h/w ops */ + if (!hw || !msi_irq_ops) { + dev_err(pp->dev, + "v3.65 PCI Controllers doesn't provide %s\n", + (hw == NULL) ? "PCI hw ops" : "PCI MSI irq domain ops"); + goto out; + } + + ret = dw_pcie_msi_host_init(pp, msi_irqc_np, msi_irq_ops); + if (ret) + goto out; + + ret = dw_pcie_common_host_init(pp, hw); +out: + return ret; +} + int __init dw_pcie_host_init(struct pcie_port *pp) { int ret; @@ -763,7 +794,7 @@ static struct pci_ops dw_pcie_ops = { .write = dw_pcie_wr_conf, }; -static int dw_pcie_setup(int nr, struct pci_sys_data *sys) +int dw_pcie_setup(int nr, struct pci_sys_data *sys) { struct pcie_port *pp; @@ -786,7 +817,7 @@ static int dw_pcie_setup(int nr, struct pci_sys_data *sys) return 1; } -static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys) +struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys) { struct pci_bus *bus; struct pcie_port *pp = sys_to_pcie(sys); @@ -803,7 +834,7 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys) return bus; } -static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) +int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) { struct pcie_port *pp = sys_to_pcie(dev->bus->sysdata); int irq; @@ -815,7 +846,7 @@ static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) return irq; } -static void dw_pcie_add_bus(struct pci_bus *bus) +void dw_pcie_add_bus(struct pci_bus *bus) { if (IS_ENABLED(CONFIG_PCI_MSI)) { struct pcie_port *pp = sys_to_pcie(bus->sysdata); diff --git a/drivers/pci/host/pcie-designware.h b/drivers/pci/host/pcie-designware.h index db0260f..2681826 100644 --- a/drivers/pci/host/pcie-designware.h +++ b/drivers/pci/host/pcie-designware.h @@ -81,4 +81,11 @@ void dw_pcie_msi_init(struct pcie_port *pp); int dw_pcie_link_up(struct pcie_port *pp); void dw_pcie_setup_rc(struct pcie_port *pp); int dw_pcie_host_init(struct pcie_port *pp); +int dw_pcie_v3_65_host_init(struct pcie_port *pp, struct hw_pci *hw, + struct device_node *msi_irqc_np, + const struct irq_domain_ops *msi_irq_ops); +int dw_pcie_setup(int nr, struct pci_sys_data *sys); +struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys); +void dw_pcie_add_bus(struct pci_bus *bus); +int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin); #endif /* _PCIE_DESIGNWARE_H */