GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / vme / boards / vme_vmivme7805.c
blobe88eca18d44de0fa2d0ebd04c21995af0797a85e
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 __init vmic_init(void);
23 static int vmic_probe(struct pci_dev *, const struct pci_device_id *);
24 static void vmic_remove(struct pci_dev *);
25 static void __exit vmic_exit(void);
27 /** Base address to access FPGA register */
28 static void *vmic_base;
30 static char driver_name[] = "vmivme_7805";
32 static struct pci_device_id vmic_ids[] = {
33 { PCI_DEVICE(PCI_VENDOR_ID_VMIC, PCI_DEVICE_ID_VTIMR) },
34 { },
37 static struct pci_driver vmic_driver = {
38 .name = driver_name,
39 .id_table = vmic_ids,
40 .probe = vmic_probe,
41 .remove = vmic_remove,
44 static int __init vmic_init(void)
46 return pci_register_driver(&vmic_driver);
49 static int vmic_probe(struct pci_dev *pdev, const struct pci_device_id *id)
51 int retval;
52 u32 data;
54 /* Enable the device */
55 retval = pci_enable_device(pdev);
56 if (retval) {
57 dev_err(&pdev->dev, "Unable to enable device\n");
58 goto err;
61 /* Map Registers */
62 retval = pci_request_regions(pdev, driver_name);
63 if (retval) {
64 dev_err(&pdev->dev, "Unable to reserve resources\n");
65 goto err_resource;
68 /* Map registers in BAR 0 */
69 vmic_base = ioremap_nocache(pci_resource_start(pdev, 0), 16);
70 if (!vmic_base) {
71 dev_err(&pdev->dev, "Unable to remap CRG region\n");
72 retval = -EIO;
73 goto err_remap;
76 /* Clear the FPGA VME IF contents */
77 iowrite32(0, vmic_base + VME_CONTROL);
79 /* Clear any initial BERR */
80 data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
81 data |= BM_VME_CONTROL_BERRST;
82 iowrite32(data, vmic_base + VME_CONTROL);
84 /* Enable the vme interface and byte swapping */
85 data = ioread32(vmic_base + VME_CONTROL) & 0x00000FFF;
86 data = data | BM_VME_CONTROL_MASTER_ENDIAN |
87 BM_VME_CONTROL_SLAVE_ENDIAN |
88 BM_VME_CONTROL_ABLE |
89 BM_VME_CONTROL_BERRI |
90 BM_VME_CONTROL_BPENA |
91 BM_VME_CONTROL_VBENA;
92 iowrite32(data, vmic_base + VME_CONTROL);
94 return 0;
96 err_remap:
97 pci_release_regions(pdev);
98 err_resource:
99 pci_disable_device(pdev);
100 err:
101 return retval;
104 static void vmic_remove(struct pci_dev *pdev)
106 iounmap(vmic_base);
107 pci_release_regions(pdev);
108 pci_disable_device(pdev);
112 static void __exit vmic_exit(void)
114 pci_unregister_driver(&vmic_driver);
117 MODULE_DESCRIPTION("VMIVME-7805 board support driver");
118 MODULE_AUTHOR("Arthur Benilov <arthur.benilov@iba-group.com>");
119 MODULE_LICENSE("GPL");
121 module_init(vmic_init);
122 module_exit(vmic_exit);