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/module.h>
14 #include <linux/types.h>
15 #include <linux/errno.h>
16 #include <linux/pci.h>
17 #include <linux/poll.h>
20 #include "vme_vmivme7805.h"
22 static int vmic_probe(struct pci_dev
*, const struct pci_device_id
*);
23 static void vmic_remove(struct pci_dev
*);
25 /** Base address to access FPGA register */
26 static void __iomem
*vmic_base
;
28 static const char driver_name
[] = "vmivme_7805";
30 static const struct pci_device_id vmic_ids
[] = {
31 { PCI_DEVICE(PCI_VENDOR_ID_VMIC
, PCI_DEVICE_ID_VTIMR
) },
35 static struct pci_driver vmic_driver
= {
39 .remove
= vmic_remove
,
42 static int vmic_probe(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
47 /* Enable the device */
48 retval
= pci_enable_device(pdev
);
50 dev_err(&pdev
->dev
, "Unable to enable device\n");
55 retval
= pci_request_regions(pdev
, driver_name
);
57 dev_err(&pdev
->dev
, "Unable to reserve resources\n");
61 /* Map registers in BAR 0 */
62 vmic_base
= ioremap_nocache(pci_resource_start(pdev
, 0), 16);
64 dev_err(&pdev
->dev
, "Unable to remap CRG region\n");
69 /* Clear the FPGA VME IF contents */
70 iowrite32(0, vmic_base
+ VME_CONTROL
);
72 /* Clear any initial BERR */
73 data
= ioread32(vmic_base
+ VME_CONTROL
) & 0x00000FFF;
74 data
|= BM_VME_CONTROL_BERRST
;
75 iowrite32(data
, vmic_base
+ VME_CONTROL
);
77 /* Enable the vme interface and byte swapping */
78 data
= ioread32(vmic_base
+ VME_CONTROL
) & 0x00000FFF;
79 data
= data
| BM_VME_CONTROL_MASTER_ENDIAN
|
80 BM_VME_CONTROL_SLAVE_ENDIAN
|
82 BM_VME_CONTROL_BERRI
|
83 BM_VME_CONTROL_BPENA
|
85 iowrite32(data
, vmic_base
+ VME_CONTROL
);
90 pci_release_regions(pdev
);
92 pci_disable_device(pdev
);
97 static void vmic_remove(struct pci_dev
*pdev
)
100 pci_release_regions(pdev
);
101 pci_disable_device(pdev
);
105 module_pci_driver(vmic_driver
);
107 MODULE_DESCRIPTION("VMIVME-7805 board support driver");
108 MODULE_AUTHOR("Arthur Benilov <arthur.benilov@iba-group.com>");
109 MODULE_LICENSE("GPL");