]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - drivers/pci/host/pcie-iproc-bcma.c
block/sd: Return -EREMOTEIO when WRITE SAME and DISCARD are disabled
[mirror_ubuntu-zesty-kernel.git] / drivers / pci / host / pcie-iproc-bcma.c
1 /*
2 * Copyright (C) 2015 Broadcom Corporation
3 * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de>
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/module.h>
18 #include <linux/slab.h>
19 #include <linux/phy/phy.h>
20 #include <linux/bcma/bcma.h>
21 #include <linux/ioport.h>
22
23 #include "pcie-iproc.h"
24
25
26 /* NS: CLASS field is R/O, and set to wrong 0x200 value */
27 static void bcma_pcie2_fixup_class(struct pci_dev *dev)
28 {
29 dev->class = PCI_CLASS_BRIDGE_PCI << 8;
30 }
31 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x8011, bcma_pcie2_fixup_class);
32 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_BROADCOM, 0x8012, bcma_pcie2_fixup_class);
33
34 static int iproc_pcie_bcma_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
35 {
36 struct pci_sys_data *sys = dev->sysdata;
37 struct iproc_pcie *pcie = sys->private_data;
38 struct bcma_device *bdev = container_of(pcie->dev, struct bcma_device, dev);
39
40 return bcma_core_irq(bdev, 5);
41 }
42
43 static int iproc_pcie_bcma_probe(struct bcma_device *bdev)
44 {
45 struct iproc_pcie *pcie;
46 LIST_HEAD(res);
47 struct resource res_mem;
48 int ret;
49
50 pcie = devm_kzalloc(&bdev->dev, sizeof(*pcie), GFP_KERNEL);
51 if (!pcie)
52 return -ENOMEM;
53
54 pcie->dev = &bdev->dev;
55 bcma_set_drvdata(bdev, pcie);
56
57 pcie->base = bdev->io_addr;
58
59 res_mem.start = bdev->addr_s[0];
60 res_mem.end = bdev->addr_s[0] + SZ_128M - 1;
61 res_mem.name = "PCIe MEM space";
62 res_mem.flags = IORESOURCE_MEM;
63 pci_add_resource(&res, &res_mem);
64
65 pcie->map_irq = iproc_pcie_bcma_map_irq;
66
67 ret = iproc_pcie_setup(pcie, &res);
68 if (ret)
69 dev_err(pcie->dev, "PCIe controller setup failed\n");
70
71 pci_free_resource_list(&res);
72
73 return ret;
74 }
75
76 static void iproc_pcie_bcma_remove(struct bcma_device *bdev)
77 {
78 struct iproc_pcie *pcie = bcma_get_drvdata(bdev);
79
80 iproc_pcie_remove(pcie);
81 }
82
83 static const struct bcma_device_id iproc_pcie_bcma_table[] = {
84 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_PCIEG2, BCMA_ANY_REV, BCMA_ANY_CLASS),
85 {},
86 };
87 MODULE_DEVICE_TABLE(bcma, iproc_pcie_bcma_table);
88
89 static struct bcma_driver iproc_pcie_bcma_driver = {
90 .name = KBUILD_MODNAME,
91 .id_table = iproc_pcie_bcma_table,
92 .probe = iproc_pcie_bcma_probe,
93 .remove = iproc_pcie_bcma_remove,
94 };
95
96 static int __init iproc_pcie_bcma_init(void)
97 {
98 return bcma_driver_register(&iproc_pcie_bcma_driver);
99 }
100 module_init(iproc_pcie_bcma_init);
101
102 static void __exit iproc_pcie_bcma_exit(void)
103 {
104 bcma_driver_unregister(&iproc_pcie_bcma_driver);
105 }
106 module_exit(iproc_pcie_bcma_exit);
107
108 MODULE_AUTHOR("Hauke Mehrtens");
109 MODULE_DESCRIPTION("Broadcom iProc PCIe BCMA driver");
110 MODULE_LICENSE("GPL v2");