diff options
author | Arthur Benilov <arthur.benilov@iba-group.com> | 2010-02-16 09:41:51 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-03 19:43:02 -0500 |
commit | 3c2aabc41da7e9f957bc826363115a54764fb396 (patch) | |
tree | 812d416910afc9bcbca3a22d78efa8b157cccaea | |
parent | 33e920d9ebaddbc9cf51cf6e1de7baa8d7b8d6dd (diff) |
Staging: vme: VMIVME-7805 board support
VMIVME-7805 board has a special control register that has to be used in
order to activate the VME bus access via the Universe II bridge.
This control register also handles endianess convertion.
Signed-off-by: Arthur Benilov <arthur.benilov@iba-group.com>
Signed-off-by: Vincent Bossier <vincent.bossier@iba-group.com>
Acked-by: Martyn Welch <martyn.welch@ge.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/vme/Kconfig | 2 | ||||
-rw-r--r-- | drivers/staging/vme/Makefile | 1 | ||||
-rw-r--r-- | drivers/staging/vme/boards/Kconfig | 9 | ||||
-rw-r--r-- | drivers/staging/vme/boards/Makefile | 5 | ||||
-rw-r--r-- | drivers/staging/vme/boards/vme_vmivme7805.c | 124 | ||||
-rw-r--r-- | drivers/staging/vme/boards/vme_vmivme7805.h | 37 |
6 files changed, 178 insertions, 0 deletions
diff --git a/drivers/staging/vme/Kconfig b/drivers/staging/vme/Kconfig index ae628a58b0c6..6411ae51ed3f 100644 --- a/drivers/staging/vme/Kconfig +++ b/drivers/staging/vme/Kconfig | |||
@@ -14,4 +14,6 @@ source "drivers/staging/vme/bridges/Kconfig" | |||
14 | 14 | ||
15 | source "drivers/staging/vme/devices/Kconfig" | 15 | source "drivers/staging/vme/devices/Kconfig" |
16 | 16 | ||
17 | source "drivers/staging/vme/boards/Kconfig" | ||
18 | |||
17 | endif # VME | 19 | endif # VME |
diff --git a/drivers/staging/vme/Makefile b/drivers/staging/vme/Makefile index 8c3b90ee5853..b4ea3f8d0a50 100644 --- a/drivers/staging/vme/Makefile +++ b/drivers/staging/vme/Makefile | |||
@@ -5,3 +5,4 @@ obj-$(CONFIG_VME_BUS) += vme.o | |||
5 | 5 | ||
6 | obj-y += bridges/ | 6 | obj-y += bridges/ |
7 | obj-y += devices/ | 7 | obj-y += devices/ |
8 | obj-y += boards/ | ||
diff --git a/drivers/staging/vme/boards/Kconfig b/drivers/staging/vme/boards/Kconfig new file mode 100644 index 000000000000..761631353527 --- /dev/null +++ b/drivers/staging/vme/boards/Kconfig | |||
@@ -0,0 +1,9 @@ | |||
1 | comment "VME Board Drivers" | ||
2 | |||
3 | config VMIVME_7805 | ||
4 | tristate "VMIVME-7805" | ||
5 | help | ||
6 | If you say Y here you get support for the VMIVME-7805 board. | ||
7 | This board has an additional control interface to the Universe II | ||
8 | chip. This driver has to be included if you want to access VME bus | ||
9 | with VMIVME-7805 board. | ||
diff --git a/drivers/staging/vme/boards/Makefile b/drivers/staging/vme/boards/Makefile new file mode 100644 index 000000000000..43658340885d --- /dev/null +++ b/drivers/staging/vme/boards/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # | ||
2 | # Makefile for the VME board drivers. | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_VMIVME_7805) += vme_vmivme7805.o | ||
diff --git a/drivers/staging/vme/boards/vme_vmivme7805.c b/drivers/staging/vme/boards/vme_vmivme7805.c new file mode 100644 index 000000000000..843c9edde555 --- /dev/null +++ b/drivers/staging/vme/boards/vme_vmivme7805.c | |||
@@ -0,0 +1,124 @@ | |||
1 | /* | ||
2 | * Support for the VMIVME-7805 board access to the Universe II bridge. | ||
3 | * | ||
4 | * Author: Arthur Benilov <arthur.benilov@iba-group.com> | ||
5 | * Copyright 2010 Ion Beam Application, Inc. | ||
6 | * | ||
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. | ||
11 | */ | ||
12 | |||
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> | ||
19 | #include <linux/io.h> | ||
20 | |||
21 | #include "vme_vmivme7805.h" | ||
22 | |||
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); | ||
27 | |||
28 | /** Base address to access FPGA register */ | ||
29 | static void *vmic_base; | ||
30 | |||
31 | static char driver_name[] = "vmivme_7805"; | ||
32 | |||
33 | static struct pci_device_id vmic_ids[] = { | ||
34 | { PCI_DEVICE(PCI_VENDOR_ID_VMIC, PCI_DEVICE_ID_VTIMR) }, | ||
35 | { }, | ||
36 | }; | ||
37 | |||
38 | static struct pci_driver vmic_driver = { | ||
39 | .name = driver_name, | ||
40 | .id_table = vmic_ids, | ||
41 | .probe = vmic_probe, | ||
42 | .remove = vmic_remove, | ||
43 | }; | ||
44 | |||
45 | static int __init vmic_init(void) | ||
46 | { | ||
47 | return pci_register_driver(&vmic_driver); | ||
48 | } | ||
49 | |||
50 | static int vmic_probe(struct pci_dev *pdev, const struct pci_device_id *id) | ||
51 | { | ||
52 | int retval; | ||
53 | u32 data; | ||
54 | |||
55 | /* Enable the device */ | ||
56 | retval = pci_enable_device(pdev); | ||
57 | if (retval) { | ||
58 | dev_err(&pdev->dev, "Unable to enable device\n"); | ||
59 | goto err; | ||
60 | } | ||
61 | |||
62 | /* Map Registers */ | ||
63 | retval = pci_request_regions(pdev, driver_name); | ||
64 | if (retval) { | ||
65 | dev_err(&pdev->dev, "Unable to reserve resources\n"); | ||
66 | goto err_resource; | ||
67 | } | ||
68 | |||
69 | /* Map registers in BAR 0 */ | ||
70 | vmic_base = ioremap_nocache(pci_resource_start(pdev, 0), 16); | ||
71 | if (!vmic_base) { | ||
72 | dev_err(&pdev->dev, "Unable to remap CRG region\n"); | ||
73 | retval = -EIO; | ||
74 | goto err_remap; | ||
75 | } | ||
76 | |||
77 | /* Clear the FPGA VME IF contents */ | ||
78 | iowrite32(0, vmic_base + VME_CONTROL); | ||
79 | |||
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); | ||
84 | |||
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 | | ||
89 | BM_VME_CONTROL_ABLE | | ||
90 | BM_VME_CONTROL_BERRI | | ||
91 | BM_VME_CONTROL_BPENA | | ||
92 | BM_VME_CONTROL_VBENA; | ||
93 | iowrite32(data, vmic_base + VME_CONTROL); | ||
94 | |||
95 | return 0; | ||
96 | |||
97 | err_remap: | ||
98 | pci_release_regions(pdev); | ||
99 | err_resource: | ||
100 | pci_disable_device(pdev); | ||
101 | err: | ||
102 | return retval; | ||
103 | } | ||
104 | |||
105 | static void vmic_remove(struct pci_dev *pdev) | ||
106 | { | ||
107 | iounmap(vmic_base); | ||
108 | pci_release_regions(pdev); | ||
109 | pci_disable_device(pdev); | ||
110 | |||
111 | } | ||
112 | |||
113 | static void __exit vmic_exit(void) | ||
114 | { | ||
115 | pci_unregister_driver(&vmic_driver); | ||
116 | } | ||
117 | |||
118 | MODULE_DESCRIPTION("VMIVME-7805 board support driver"); | ||
119 | MODULE_AUTHOR("Arthur Benilov <arthur.benilov@iba-group.com>"); | ||
120 | MODULE_LICENSE("GPL"); | ||
121 | |||
122 | module_init(vmic_init); | ||
123 | module_exit(vmic_exit); | ||
124 | |||
diff --git a/drivers/staging/vme/boards/vme_vmivme7805.h b/drivers/staging/vme/boards/vme_vmivme7805.h new file mode 100644 index 000000000000..44c2c449808c --- /dev/null +++ b/drivers/staging/vme/boards/vme_vmivme7805.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * vmivme_7805.h | ||
3 | * | ||
4 | * Support for the VMIVME-7805 board access to the Universe II bridge. | ||
5 | * | ||
6 | * Author: Arthur Benilov <arthur.benilov@iba-group.com> | ||
7 | * Copyright 2010 Ion Beam Application, Inc. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | */ | ||
14 | |||
15 | |||
16 | #ifndef _VMIVME_7805_H | ||
17 | #define _VMIVME_7805_H | ||
18 | |||
19 | #ifndef PCI_VENDOR_ID_VMIC | ||
20 | #define PCI_VENDOR_ID_VMIC 0x114A | ||
21 | #endif | ||
22 | |||
23 | #ifndef PCI_DEVICE_ID_VTIMR | ||
24 | #define PCI_DEVICE_ID_VTIMR 0x0004 | ||
25 | #endif | ||
26 | |||
27 | #define VME_CONTROL 0x0000 | ||
28 | #define BM_VME_CONTROL_MASTER_ENDIAN 0x0001 | ||
29 | #define BM_VME_CONTROL_SLAVE_ENDIAN 0x0002 | ||
30 | #define BM_VME_CONTROL_ABLE 0x0004 | ||
31 | #define BM_VME_CONTROL_BERRI 0x0040 | ||
32 | #define BM_VME_CONTROL_BERRST 0x0080 | ||
33 | #define BM_VME_CONTROL_BPENA 0x0400 | ||
34 | #define BM_VME_CONTROL_VBENA 0x0800 | ||
35 | |||
36 | #endif /* _VMIVME_7805_H */ | ||
37 | |||