x86/topology: Fix function name in documentation
[cris-mirror.git] / drivers / usb / gadget / udc / bdc / bdc_pci.c
blob1e940f054cb8c41cb2150cd621eae1580f256bec
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * bdc_pci.c - BRCM BDC USB3.0 device controller PCI interface file.
5 * Copyright (C) 2014 Broadcom Corporation
7 * Author: Ashwini Pahuja
9 * Based on drivers under drivers/usb/
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/slab.h>
15 #include <linux/pci.h>
16 #include <linux/pci_ids.h>
17 #include <linux/platform_device.h>
19 #include "bdc.h"
21 #define BDC_PCI_PID 0x1570
23 struct bdc_pci {
24 struct device *dev;
25 struct platform_device *bdc;
28 static int bdc_setup_msi(struct pci_dev *pci)
30 int ret;
32 ret = pci_enable_msi(pci);
33 if (ret) {
34 pr_err("failed to allocate MSI entry\n");
35 return ret;
38 return ret;
41 static int bdc_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
43 struct resource res[2];
44 struct platform_device *bdc;
45 struct bdc_pci *glue;
46 int ret = -ENOMEM;
48 glue = devm_kzalloc(&pci->dev, sizeof(*glue), GFP_KERNEL);
49 if (!glue)
50 return -ENOMEM;
52 glue->dev = &pci->dev;
53 ret = pci_enable_device(pci);
54 if (ret) {
55 dev_err(&pci->dev, "failed to enable pci device\n");
56 return -ENODEV;
58 pci_set_master(pci);
60 bdc = platform_device_alloc(BRCM_BDC_NAME, PLATFORM_DEVID_AUTO);
61 if (!bdc)
62 return -ENOMEM;
64 memset(res, 0x00, sizeof(struct resource) * ARRAY_SIZE(res));
65 bdc_setup_msi(pci);
67 res[0].start = pci_resource_start(pci, 0);
68 res[0].end = pci_resource_end(pci, 0);
69 res[0].name = BRCM_BDC_NAME;
70 res[0].flags = IORESOURCE_MEM;
72 res[1].start = pci->irq;
73 res[1].name = BRCM_BDC_NAME;
74 res[1].flags = IORESOURCE_IRQ;
76 ret = platform_device_add_resources(bdc, res, ARRAY_SIZE(res));
77 if (ret) {
78 dev_err(&pci->dev,
79 "couldn't add resources to bdc device\n");
80 return ret;
83 pci_set_drvdata(pci, glue);
85 dma_set_coherent_mask(&bdc->dev, pci->dev.coherent_dma_mask);
87 bdc->dev.dma_mask = pci->dev.dma_mask;
88 bdc->dev.dma_parms = pci->dev.dma_parms;
89 bdc->dev.parent = &pci->dev;
90 glue->bdc = bdc;
92 ret = platform_device_add(bdc);
93 if (ret) {
94 dev_err(&pci->dev, "failed to register bdc device\n");
95 platform_device_put(bdc);
96 return ret;
99 return 0;
102 static void bdc_pci_remove(struct pci_dev *pci)
104 struct bdc_pci *glue = pci_get_drvdata(pci);
106 platform_device_unregister(glue->bdc);
107 pci_disable_msi(pci);
110 static struct pci_device_id bdc_pci_id_table[] = {
111 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, BDC_PCI_PID), },
112 {} /* Terminating Entry */
115 MODULE_DEVICE_TABLE(pci, bdc_pci_id_table);
117 static struct pci_driver bdc_pci_driver = {
118 .name = "bdc-pci",
119 .id_table = bdc_pci_id_table,
120 .probe = bdc_pci_probe,
121 .remove = bdc_pci_remove,
124 MODULE_AUTHOR("Ashwini Pahuja <ashwini.linux@gmail.com>");
125 MODULE_LICENSE("GPL");
126 MODULE_DESCRIPTION("BRCM BDC USB3 PCI Glue layer");
127 module_pci_driver(bdc_pci_driver);