diff options
| author | Ray Jui <rjui@broadcom.com> | 2015-04-08 14:21:35 -0400 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2015-04-08 15:19:36 -0400 |
| commit | 1fb37a8178da007cad75f48e2355b9dcb0711e06 (patch) | |
| tree | 640deb8a0d9d13626eecc58cdc83329d0c5b466a | |
| parent | 1b55d62259187fe77ade87dccc33522d51f113ee (diff) | |
PCI: iproc: Add Broadcom iProc PCIe support
Add support for the Broadcom iProc PCIe controller.
pcie-iproc.c is the common core driver, and a front-end bus interface needs
to be added to support different bus interfaces.
pcie-iproc-platform.c contains the support for the platform bus interface.
Signed-off-by: Ray Jui <rjui@broadcom.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Scott Branden <sbranden@broadcom.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
| -rw-r--r-- | drivers/pci/host/Kconfig | 19 | ||||
| -rw-r--r-- | drivers/pci/host/Makefile | 2 | ||||
| -rw-r--r-- | drivers/pci/host/pcie-iproc-platform.c | 108 | ||||
| -rw-r--r-- | drivers/pci/host/pcie-iproc.c | 268 | ||||
| -rw-r--r-- | drivers/pci/host/pcie-iproc.h | 42 |
5 files changed, 439 insertions, 0 deletions
diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index 7b892a9cc4fc..1dfb567b3522 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig | |||
| @@ -106,4 +106,23 @@ config PCI_VERSATILE | |||
| 106 | bool "ARM Versatile PB PCI controller" | 106 | bool "ARM Versatile PB PCI controller" |
| 107 | depends on ARCH_VERSATILE | 107 | depends on ARCH_VERSATILE |
| 108 | 108 | ||
| 109 | config PCIE_IPROC | ||
| 110 | tristate "Broadcom iProc PCIe controller" | ||
| 111 | depends on OF && ARM | ||
| 112 | default n | ||
| 113 | help | ||
| 114 | This enables the iProc PCIe core controller support for Broadcom's | ||
| 115 | iProc family of SoCs. An appropriate bus interface driver also needs | ||
| 116 | to be enabled | ||
| 117 | |||
| 118 | config PCIE_IPROC_PLATFORM | ||
| 119 | tristate "Broadcom iProc PCIe platform bus driver" | ||
| 120 | depends on ARCH_BCM_IPROC || (ARM && COMPILE_TEST) | ||
| 121 | depends on OF | ||
| 122 | select PCIE_IPROC | ||
| 123 | default ARCH_BCM_IPROC | ||
| 124 | help | ||
| 125 | Say Y here if you want to use the Broadcom iProc PCIe controller | ||
| 126 | through the generic platform bus interface | ||
| 127 | |||
| 109 | endmenu | 128 | endmenu |
diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile index e61d91c92bf1..f733b4e27642 100644 --- a/drivers/pci/host/Makefile +++ b/drivers/pci/host/Makefile | |||
| @@ -13,3 +13,5 @@ obj-$(CONFIG_PCIE_XILINX) += pcie-xilinx.o | |||
| 13 | obj-$(CONFIG_PCI_XGENE) += pci-xgene.o | 13 | obj-$(CONFIG_PCI_XGENE) += pci-xgene.o |
| 14 | obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o | 14 | obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o |
| 15 | obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o | 15 | obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o |
| 16 | obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o | ||
| 17 | obj-$(CONFIG_PCIE_IPROC_PLATFORM) += pcie-iproc-platform.o | ||
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c new file mode 100644 index 000000000000..afad6c21fcfa --- /dev/null +++ b/drivers/pci/host/pcie-iproc-platform.c | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2015 Broadcom Corporation | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU General Public License as | ||
| 6 | * published by the Free Software Foundation version 2. | ||
| 7 | * | ||
| 8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 9 | * kind, whether express or implied; without even the implied warranty | ||
| 10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/kernel.h> | ||
| 15 | #include <linux/pci.h> | ||
| 16 | #include <linux/clk.h> | ||
| 17 | #include <linux/module.h> | ||
| 18 | #include <linux/slab.h> | ||
| 19 | #include <linux/interrupt.h> | ||
| 20 | #include <linux/platform_device.h> | ||
| 21 | #include <linux/of_address.h> | ||
| 22 | #include <linux/of_pci.h> | ||
| 23 | #include <linux/of_irq.h> | ||
| 24 | #include <linux/of_platform.h> | ||
| 25 | #include <linux/phy/phy.h> | ||
| 26 | |||
| 27 | #include "pcie-iproc.h" | ||
| 28 | |||
| 29 | static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | ||
| 30 | { | ||
| 31 | struct iproc_pcie *pcie; | ||
| 32 | struct device_node *np = pdev->dev.of_node; | ||
| 33 | struct resource reg; | ||
| 34 | resource_size_t iobase = 0; | ||
| 35 | LIST_HEAD(res); | ||
| 36 | int ret; | ||
| 37 | |||
| 38 | pcie = devm_kzalloc(&pdev->dev, sizeof(struct iproc_pcie), GFP_KERNEL); | ||
| 39 | if (!pcie) | ||
| 40 | return -ENOMEM; | ||
| 41 | |||
| 42 | pcie->dev = &pdev->dev; | ||
| 43 | platform_set_drvdata(pdev, pcie); | ||
| 44 | |||
| 45 | ret = of_address_to_resource(np, 0, ®); | ||
| 46 | if (ret < 0) { | ||
| 47 | dev_err(pcie->dev, "unable to obtain controller resources\n"); | ||
| 48 | return ret; | ||
| 49 | } | ||
| 50 | |||
| 51 | pcie->base = devm_ioremap(pcie->dev, reg.start, resource_size(®)); | ||
| 52 | if (!pcie->base) { | ||
| 53 | dev_err(pcie->dev, "unable to map controller registers\n"); | ||
| 54 | return -ENOMEM; | ||
| 55 | } | ||
| 56 | |||
| 57 | /* PHY use is optional */ | ||
| 58 | pcie->phy = devm_phy_get(&pdev->dev, "pcie-phy"); | ||
| 59 | if (IS_ERR(pcie->phy)) { | ||
| 60 | if (PTR_ERR(pcie->phy) == -EPROBE_DEFER) | ||
| 61 | return -EPROBE_DEFER; | ||
| 62 | pcie->phy = NULL; | ||
| 63 | } | ||
| 64 | |||
| 65 | ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase); | ||
| 66 | if (ret) { | ||
| 67 | dev_err(pcie->dev, | ||
| 68 | "unable to get PCI host bridge resources\n"); | ||
| 69 | return ret; | ||
| 70 | } | ||
| 71 | |||
| 72 | pcie->resources = &res; | ||
| 73 | |||
| 74 | ret = iproc_pcie_setup(pcie); | ||
| 75 | if (ret) { | ||
| 76 | dev_err(pcie->dev, "PCIe controller setup failed\n"); | ||
| 77 | return ret; | ||
| 78 | } | ||
| 79 | |||
| 80 | return 0; | ||
| 81 | } | ||
| 82 | |||
| 83 | static int iproc_pcie_pltfm_remove(struct platform_device *pdev) | ||
| 84 | { | ||
| 85 | struct iproc_pcie *pcie = platform_get_drvdata(pdev); | ||
| 86 | |||
| 87 | return iproc_pcie_remove(pcie); | ||
| 88 | } | ||
| 89 | |||
| 90 | static const struct of_device_id iproc_pcie_of_match_table[] = { | ||
| 91 | { .compatible = "brcm,iproc-pcie", }, | ||
| 92 | { /* sentinel */ } | ||
| 93 | }; | ||
| 94 | MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table); | ||
| 95 | |||
| 96 | static struct platform_driver iproc_pcie_pltfm_driver = { | ||
| 97 | .driver = { | ||
| 98 | .name = "iproc-pcie", | ||
| 99 | .of_match_table = of_match_ptr(iproc_pcie_of_match_table), | ||
| 100 | }, | ||
| 101 | .probe = iproc_pcie_pltfm_probe, | ||
| 102 | .remove = iproc_pcie_pltfm_remove, | ||
| 103 | }; | ||
| 104 | module_platform_driver(iproc_pcie_pltfm_driver); | ||
| 105 | |||
| 106 | MODULE_AUTHOR("Ray Jui <rjui@broadcom.com>"); | ||
| 107 | MODULE_DESCRIPTION("Broadcom iPROC PCIe platform driver"); | ||
| 108 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c new file mode 100644 index 000000000000..329e1b54528b --- /dev/null +++ b/drivers/pci/host/pcie-iproc.c | |||
| @@ -0,0 +1,268 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014 Hauke Mehrtens <hauke@hauke-m.de> | ||
| 3 | * Copyright (C) 2015 Broadcom Corporatcommon ion | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU General Public License as | ||
| 7 | * published by the Free Software Foundation version 2. | ||
| 8 | * | ||
| 9 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
| 10 | * kind, whether express or implied; without even the implied warranty | ||
| 11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #include <linux/kernel.h> | ||
| 16 | #include <linux/pci.h> | ||
| 17 | #include <linux/msi.h> | ||
| 18 | #include <linux/clk.h> | ||
| 19 | #include <linux/module.h> | ||
| 20 | #include <linux/mbus.h> | ||
| 21 | #include <linux/slab.h> | ||
| 22 | #include <linux/delay.h> | ||
| 23 | #include <linux/interrupt.h> | ||
| 24 | #include <linux/platform_device.h> | ||
| 25 | #include <linux/of_address.h> | ||
| 26 | #include <linux/of_pci.h> | ||
| 27 | #include <linux/of_irq.h> | ||
| 28 | #include <linux/of_platform.h> | ||
| 29 | #include <linux/phy/phy.h> | ||
| 30 | |||
| 31 | #include "pcie-iproc.h" | ||
| 32 | |||
| 33 | #define CLK_CONTROL_OFFSET 0x000 | ||
| 34 | #define EP_MODE_SURVIVE_PERST_SHIFT 1 | ||
| 35 | #define EP_MODE_SURVIVE_PERST BIT(EP_MODE_SURVIVE_PERST_SHIFT) | ||
| 36 | #define RC_PCIE_RST_OUTPUT_SHIFT 0 | ||
| 37 | #define RC_PCIE_RST_OUTPUT BIT(RC_PCIE_RST_OUTPUT_SHIFT) | ||
| 38 | |||
| 39 | #define CFG_IND_ADDR_OFFSET 0x120 | ||
| 40 | #define CFG_IND_ADDR_MASK 0x00001ffc | ||
| 41 | |||
| 42 | #define CFG_IND_DATA_OFFSET 0x124 | ||
| 43 | |||
| 44 | #define CFG_ADDR_OFFSET 0x1f8 | ||
| 45 | #define CFG_ADDR_BUS_NUM_SHIFT 20 | ||
| 46 | #define CFG_ADDR_BUS_NUM_MASK 0x0ff00000 | ||
| 47 | #define CFG_ADDR_DEV_NUM_SHIFT 15 | ||
| 48 | #define CFG_ADDR_DEV_NUM_MASK 0x000f8000 | ||
| 49 | #define CFG_ADDR_FUNC_NUM_SHIFT 12 | ||
| 50 | #define CFG_ADDR_FUNC_NUM_MASK 0x00007000 | ||
| 51 | #define CFG_ADDR_REG_NUM_SHIFT 2 | ||
| 52 | #define CFG_ADDR_REG_NUM_MASK 0x00000ffc | ||
| 53 | #define CFG_ADDR_CFG_TYPE_SHIFT 0 | ||
