2 * Support for the VMIVME-7805 board access to the Universe II bridge.
4 * Author: Arthur Benilov <arthur.benilov@iba-group.com>
5 * Copyright 2010 Ion Beam Application, Inc.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 #include <linux/version.h>
14 #include <linux/module.h>
15 #include <linux/types.h>
16 #include <linux/errno.h>
17 #include <linux/pci.h>
18 #include <linux/poll.h>
21 #include "vme_vmivme7805.h"
23 static int __init vmic_init(void);
24 static int vmic_probe(struct pci_dev *, const struct pci_device_id *);
25 static void vmic_remove(struct pci_dev *);
26 static void __exit vmic_exit(void);
28 /** Base address to access FPGA register */
29 static void *vmic_base;
31 static char driver_name[] = "vmivme_7805";
33 static struct pci_device_id vmic_ids[] = {
34 { PCI_DEVICE(PCI_VENDOR_ID_VMIC, PCI_DEVICE_ID_VTIMR) },
38 static struct pci_driver vmic_driver = {
42 .remove = vmic_remove,
45 static int __init vmic_init(void)
47 return pci_register_driver(&vmic_driver);
50 static int vmic_probe(struct pci_dev *pdev, const struct pci_device_id *id)
55 /* Enable the device */
56 retval = pci_enable_device(pdev);
58 dev_err(&pdev->dev, "Unable to enable device\n");
63 retval = pci_request_regions(pdev, driver_name);
65 dev_err(&pdev->dev, "Unable to reserve resources\n");
69 /* Map registers in BAR 0 */
70 vmic_base = ioremap_nocache(pci_resource_start(pdev, 0), 16);
72 dev_err(&pdev->dev, "Unable to remap CRG region\n");
77 /* Clear the FPGA VME IF contents */
78 iowrite32(0, vmic_base + VME_CONTROL);
80 /* Clear any initial BERR */
81 data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
82 data |= BM_VME_CONTROL_BERRST;
83 iowrite32(data, vmic_base + VME_CONTROL);
85 /* Enable the vme interface and byte swapping */
86 data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
87 data = data | BM_VME_CONTROL_MASTER_ENDIAN |
88 BM_VME_CONTROL_SLAVE_ENDIAN |
90 BM_VME_CONTROL_BERRI |
91 BM_VME_CONTROL_BPENA |
93 iowrite32(data, vmic_base + VME_CONTROL);
98 pci_release_regions(pdev);
100 pci_disable_device(pdev);
105 static void vmic_remove(struct pci_dev *pdev)
108 pci_release_regions(pdev);
109 pci_disable_device(pdev);
113 static void __exit vmic_exit(void)
115 pci_unregister_driver(&vmic_driver);
118 MODULE_DESCRIPTION("VMIVME-7805 board support driver");
119 MODULE_AUTHOR("Arthur Benilov <arthur.benilov@iba-group.com>");
120 MODULE_LICENSE("GPL");
122 module_init(vmic_init);
123 module_exit(vmic_exit);