1 // SPDX-License-Identifier: GPL-2.0-or-later
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.
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>
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) },
31 static struct pci_driver vmic_driver = {
35 .remove = vmic_remove,
38 static int vmic_probe(struct pci_dev *pdev, const struct pci_device_id *id)
43 /* Enable the device */
44 retval = pci_enable_device(pdev);
46 dev_err(&pdev->dev, "Unable to enable device\n");
51 retval = pci_request_regions(pdev, driver_name);
53 dev_err(&pdev->dev, "Unable to reserve resources\n");
57 /* Map registers in BAR 0 */
58 vmic_base = ioremap(pci_resource_start(pdev, 0), 16);
60 dev_err(&pdev->dev, "Unable to remap CRG region\n");
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 |
78 BM_VME_CONTROL_BERRI |
79 BM_VME_CONTROL_BPENA |
81 iowrite32(data, vmic_base + VME_CONTROL);
86 pci_release_regions(pdev);
88 pci_disable_device(pdev);
93 static void vmic_remove(struct pci_dev *pdev)
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");