s390/ptrace: get rid of long longs in psw_bits
[linux/fpc-iii.git] / drivers / vme / boards / vme_vmivme7805.c
blobac422121f9bb6f48df826530d718c1e8998ea306
1 /*
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>
18 #include <linux/io.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) },
32 { },
35 static struct pci_driver vmic_driver = {
36 .name = driver_name,
37 .id_table = vmic_ids,
38 .probe = vmic_probe,
39 .remove = vmic_remove,
42 static int vmic_probe(struct pci_dev *pdev, const struct pci_device_id *id)
44 int retval;
45 u32 data;
47 /* Enable the device */
48 retval = pci_enable_device(pdev);
49 if (retval) {
50 dev_err(&pdev->dev, "Unable to enable device\n");
51 goto err;
54 /* Map Registers */
55 retval = pci_request_regions(pdev, driver_name);
56 if (retval) {
57 dev_err(&pdev->dev, "Unable to reserve resources\n");
58 goto err_resource;
61 /* Map registers in BAR 0 */
62 vmic_base = ioremap_nocache(pci_resource_start(pdev, 0), 16);
63 if (!vmic_base) {
64 dev_err(&pdev->dev, "Unable to remap CRG region\n");
65 retval = -EIO;
66 goto err_remap;
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 |
81 BM_VME_CONTROL_ABLE |
82 BM_VME_CONTROL_BERRI |
83 BM_VME_CONTROL_BPENA |
84 BM_VME_CONTROL_VBENA;
85 iowrite32(data, vmic_base + VME_CONTROL);
87 return 0;
89 err_remap:
90 pci_release_regions(pdev);
91 err_resource:
92 pci_disable_device(pdev);
93 err:
94 return retval;
97 static void vmic_remove(struct pci_dev *pdev)
99 iounmap(vmic_base);
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");