Merge tag 'io_uring-5.11-2021-01-16' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / vme / boards / vme_vmivme7805.c
blob51e056bae943e0d0610370c753645d590f986314
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Support for the VMIVME-7805 board access to the Universe II bridge.
5 * Author: Arthur Benilov <arthur.benilov@iba-group.com>
6 * Copyright 2010 Ion Beam Application, Inc.
7 */
9 #include <linux/module.h>
10 #include <linux/types.h>
11 #include <linux/errno.h>
12 #include <linux/pci.h>
13 #include <linux/poll.h>
14 #include <linux/io.h>
16 #include "vme_vmivme7805.h"
18 static int vmic_probe(struct pci_dev *, const struct pci_device_id *);
19 static void vmic_remove(struct pci_dev *);
21 /** Base address to access FPGA register */
22 static void __iomem *vmic_base;
24 static const char driver_name[] = "vmivme_7805";
26 static const struct pci_device_id vmic_ids[] = {
27 { PCI_DEVICE(PCI_VENDOR_ID_VMIC, PCI_DEVICE_ID_VTIMR) },
28 { },
31 static struct pci_driver vmic_driver = {
32 .name = driver_name,
33 .id_table = vmic_ids,
34 .probe = vmic_probe,
35 .remove = vmic_remove,
38 static int vmic_probe(struct pci_dev *pdev, const struct pci_device_id *id)
40 int retval;
41 u32 data;
43 /* Enable the device */
44 retval = pci_enable_device(pdev);
45 if (retval) {
46 dev_err(&pdev->dev, "Unable to enable device\n");
47 goto err;
50 /* Map Registers */
51 retval = pci_request_regions(pdev, driver_name);
52 if (retval) {
53 dev_err(&pdev->dev, "Unable to reserve resources\n");
54 goto err_resource;
57 /* Map registers in BAR 0 */
58 vmic_base = ioremap(pci_resource_start(pdev, 0), 16);
59 if (!vmic_base) {
60 dev_err(&pdev->dev, "Unable to remap CRG region\n");
61 retval = -EIO;
62 goto err_remap;
65 /* Clear the FPGA VME IF contents */
66 iowrite32(0, vmic_base + VME_CONTROL);
68 /* Clear any initial BERR */
69 data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
70 data |= BM_VME_CONTROL_BERRST;
71 iowrite32(data, vmic_base + VME_CONTROL);
73 /* Enable the vme interface and byte swapping */
74 data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
75 data = data | BM_VME_CONTROL_MASTER_ENDIAN |
76 BM_VME_CONTROL_SLAVE_ENDIAN |
77 BM_VME_CONTROL_ABLE |
78 BM_VME_CONTROL_BERRI |
79 BM_VME_CONTROL_BPENA |
80 BM_VME_CONTROL_VBENA;
81 iowrite32(data, vmic_base + VME_CONTROL);
83 return 0;
85 err_remap:
86 pci_release_regions(pdev);
87 err_resource:
88 pci_disable_device(pdev);
89 err:
90 return retval;
93 static void vmic_remove(struct pci_dev *pdev)
95 iounmap(vmic_base);
96 pci_release_regions(pdev);
97 pci_disable_device(pdev);
101 module_pci_driver(vmic_driver);
103 MODULE_DESCRIPTION("VMIVME-7805 board support driver");
104 MODULE_AUTHOR("Arthur Benilov <arthur.benilov@iba-group.com>");
105 MODULE_LICENSE("GPL");