Back to home page

OSCL-LXR

 
 

    


0001 VME Device Drivers
0002 ==================
0003 
0004 Driver registration
0005 -------------------
0006 
0007 As with other subsystems within the Linux kernel, VME device drivers register
0008 with the VME subsystem, typically called from the devices init routine.  This is
0009 achieved via a call to :c:func:`vme_register_driver`.
0010 
0011 A pointer to a structure of type :c:type:`struct vme_driver <vme_driver>` must
0012 be provided to the registration function. Along with the maximum number of
0013 devices your driver is able to support.
0014 
0015 At the minimum, the '.name', '.match' and '.probe' elements of
0016 :c:type:`struct vme_driver <vme_driver>` should be correctly set. The '.name'
0017 element is a pointer to a string holding the device driver's name.
0018 
0019 The '.match' function allows control over which VME devices should be registered
0020 with the driver. The match function should return 1 if a device should be
0021 probed and 0 otherwise. This example match function (from vme_user.c) limits
0022 the number of devices probed to one:
0023 
0024 .. code-block:: c
0025 
0026         #define USER_BUS_MAX    1
0027         ...
0028         static int vme_user_match(struct vme_dev *vdev)
0029         {
0030                 if (vdev->id.num >= USER_BUS_MAX)
0031                         return 0;
0032                 return 1;
0033         }
0034 
0035 The '.probe' element should contain a pointer to the probe routine. The
0036 probe routine is passed a :c:type:`struct vme_dev <vme_dev>` pointer as an
0037 argument.
0038 
0039 Here, the 'num' field refers to the sequential device ID for this specific
0040 driver. The bridge number (or bus number) can be accessed using
0041 dev->bridge->num.
0042 
0043 A function is also provided to unregister the driver from the VME core called
0044 :c:func:`vme_unregister_driver` and should usually be called from the device
0045 driver's exit routine.
0046 
0047 
0048 Resource management
0049 -------------------
0050 
0051 Once a driver has registered with the VME core the provided match routine will
0052 be called the number of times specified during the registration. If a match
0053 succeeds, a non-zero value should be returned. A zero return value indicates
0054 failure. For all successful matches, the probe routine of the corresponding
0055 driver is called. The probe routine is passed a pointer to the devices
0056 device structure. This pointer should be saved, it will be required for
0057 requesting VME resources.
0058 
0059 The driver can request ownership of one or more master windows
0060 (:c:func:`vme_master_request`), slave windows (:c:func:`vme_slave_request`)
0061 and/or dma channels (:c:func:`vme_dma_request`). Rather than allowing the device
0062 driver to request a specific window or DMA channel (which may be used by a
0063 different driver) the API allows a resource to be assigned based on the required
0064 attributes of the driver in question. For slave windows these attributes are
0065 split into the VME address spaces that need to be accessed in 'aspace' and VME
0066 bus cycle types required in 'cycle'. Master windows add a further set of
0067 attributes in 'width' specifying the required data transfer widths. These
0068 attributes are defined as bitmasks and as such any combination of the
0069 attributes can be requested for a single window, the core will assign a window
0070 that meets the requirements, returning a pointer of type vme_resource that
0071 should be used to identify the allocated resource when it is used. For DMA
0072 controllers, the request function requires the potential direction of any
0073 transfers to be provided in the route attributes. This is typically VME-to-MEM
0074 and/or MEM-to-VME, though some hardware can support VME-to-VME and MEM-to-MEM
0075 transfers as well as test pattern generation. If an unallocated window fitting
0076 the requirements can not be found a NULL pointer will be returned.
0077 
0078 Functions are also provided to free window allocations once they are no longer
0079 required. These functions (:c:func:`vme_master_free`, :c:func:`vme_slave_free`
0080 and :c:func:`vme_dma_free`) should be passed the pointer to the resource
0081 provided during resource allocation.
0082 
0083 
0084 Master windows
0085 --------------
0086 
0087 Master windows provide access from the local processor[s] out onto the VME bus.
0088 The number of windows available and the available access modes is dependent on
0089 the underlying chipset. A window must be configured before it can be used.
0090 
0091 
0092 Master window configuration
0093 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
0094 
0095 Once a master window has been assigned :c:func:`vme_master_set` can be used to
0096 configure it and :c:func:`vme_master_get` to retrieve the current settings. The
0097 address spaces, transfer widths and cycle types are the same as described
0098 under resource management, however some of the options are mutually exclusive.
0099 For example, only one address space may be specified.
0100 
0101 
0102 Master window access
0103 ~~~~~~~~~~~~~~~~~~~~
0104 
0105 The function :c:func:`vme_master_read` can be used to read from and
0106 :c:func:`vme_master_write` used to write to configured master windows.
0107 
0108 In addition to simple reads and writes, :c:func:`vme_master_rmw` is provided to
0109 do a read-modify-write transaction. Parts of a VME window can also be mapped
0110 into user space memory using :c:func:`vme_master_mmap`.
0111 
0112 
0113 Slave windows
0114 -------------
0115 
0116 Slave windows provide devices on the VME bus access into mapped portions of the
0117 local memory. The number of windows available and the access modes that can be
0118 used is dependent on the underlying chipset. A window must be configured before
0119 it can be used.
0120 
0121 
0122 Slave window configuration
0123 ~~~~~~~~~~~~~~~~~~~~~~~~~~
0124 
0125 Once a slave window has been assigned :c:func:`vme_slave_set` can be used to
0126 configure it and :c:func:`vme_slave_get` to retrieve the current settings.
0127 
0128 The address spaces, transfer widths and cycle types are the same as described
0129 under resource management, however some of the options are mutually exclusive.
0130 For example, only one address space may be specified.
0131 
0132 
0133 Slave window buffer allocation
0134 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0135 
0136 Functions are provided to allow the user to allocate
0137 (:c:func:`vme_alloc_consistent`) and free (:c:func:`vme_free_consistent`)
0138 contiguous buffers which will be accessible by the VME bridge. These functions
0139 do not have to be used, other methods can be used to allocate a buffer, though
0140 care must be taken to ensure that they are contiguous and accessible by the VME
0141 bridge.
0142 
0143 
0144 Slave window access
0145 ~~~~~~~~~~~~~~~~~~~
0146 
0147 Slave windows map local memory onto the VME bus, the standard methods for
0148 accessing memory should be used.
0149 
0150 
0151 DMA channels
0152 ------------
0153 
0154 The VME DMA transfer provides the ability to run link-list DMA transfers. The
0155 API introduces the concept of DMA lists. Each DMA list is a link-list which can
0156 be passed to a DMA controller. Multiple lists can be created, extended,
0157 executed, reused and destroyed.
0158 
0159 
0160 List Management
0161 ~~~~~~~~~~~~~~~
0162 
0163 The function :c:func:`vme_new_dma_list` is provided to create and
0164 :c:func:`vme_dma_list_free` to destroy DMA lists. Execution of a list will not
0165 automatically destroy the list, thus enabling a list to be reused for repetitive
0166 tasks.
0167 
0168 
0169 List Population
0170 ~~~~~~~~~~~~~~~
0171 
0172 An item can be added to a list using :c:func:`vme_dma_list_add` (the source and
0173 destination attributes need to be created before calling this function, this is
0174 covered under "Transfer Attributes").
0175 
0176 .. note::
0177 
0178         The detailed attributes of the transfers source and destination
0179         are not checked until an entry is added to a DMA list, the request
0180         for a DMA channel purely checks the directions in which the
0181         controller is expected to transfer data. As a result it is
0182         possible for this call to return an error, for example if the
0183         source or destination is in an unsupported VME address space.
0184 
0185 Transfer Attributes
0186 ~~~~~~~~~~~~~~~~~~~
0187 
0188 The attributes for the source and destination are handled separately from adding
0189 an item to a list. This is due to the diverse attributes required for each type
0190 of source and destination. There are functions to create attributes for PCI, VME
0191 and pattern sources and destinations (where appropriate):
0192 
0193  - PCI source or destination: :c:func:`vme_dma_pci_attribute`
0194  - VME source or destination: :c:func:`vme_dma_vme_attribute`
0195  - Pattern source: :c:func:`vme_dma_pattern_attribute`
0196 
0197 The function :c:func:`vme_dma_free_attribute` should be used to free an
0198 attribute.
0199 
0200 
0201 List Execution
0202 ~~~~~~~~~~~~~~
0203 
0204 The function :c:func:`vme_dma_list_exec` queues a list for execution and will
0205 return once the list has been executed.
0206 
0207 
0208 Interrupts
0209 ----------
0210 
0211 The VME API provides functions to attach and detach callbacks to specific VME
0212 level and status ID combinations and for the generation of VME interrupts with
0213 specific VME level and status IDs.
0214 
0215 
0216 Attaching Interrupt Handlers
0217 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0218 
0219 The function :c:func:`vme_irq_request` can be used to attach and
0220 :c:func:`vme_irq_free` to free a specific VME level and status ID combination.
0221 Any given combination can only be assigned a single callback function. A void
0222 pointer parameter is provided, the value of which is passed to the callback
0223 function, the use of this pointer is user undefined. The callback parameters are
0224 as follows. Care must be taken in writing a callback function, callback
0225 functions run in interrupt context:
0226 
0227 .. code-block:: c
0228 
0229         void callback(int level, int statid, void *priv);
0230 
0231 
0232 Interrupt Generation
0233 ~~~~~~~~~~~~~~~~~~~~
0234 
0235 The function :c:func:`vme_irq_generate` can be used to generate a VME interrupt
0236 at a given VME level and VME status ID.
0237 
0238 
0239 Location monitors
0240 -----------------
0241 
0242 The VME API provides the following functionality to configure the location
0243 monitor.
0244 
0245 
0246 Location Monitor Management
0247 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
0248 
0249 The function :c:func:`vme_lm_request` is provided to request the use of a block
0250 of location monitors and :c:func:`vme_lm_free` to free them after they are no
0251 longer required. Each block may provide a number of location monitors,
0252 monitoring adjacent locations. The function :c:func:`vme_lm_count` can be used
0253 to determine how many locations are provided.
0254 
0255 
0256 Location Monitor Configuration
0257 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0258 
0259 Once a bank of location monitors has been allocated, the function
0260 :c:func:`vme_lm_set` is provided to configure the location and mode of the
0261 location monitor. The function :c:func:`vme_lm_get` can be used to retrieve
0262 existing settings.
0263 
0264 
0265 Location Monitor Use
0266 ~~~~~~~~~~~~~~~~~~~~
0267 
0268 The function :c:func:`vme_lm_attach` enables a callback to be attached and
0269 :c:func:`vme_lm_detach` allows on to be detached from each location monitor
0270 location. Each location monitor can monitor a number of adjacent locations. The
0271 callback function is declared as follows.
0272 
0273 .. code-block:: c
0274 
0275         void callback(void *data);
0276 
0277 
0278 Slot Detection
0279 --------------
0280 
0281 The function :c:func:`vme_slot_num` returns the slot ID of the provided bridge.
0282 
0283 
0284 Bus Detection
0285 -------------
0286 
0287 The function :c:func:`vme_bus_num` returns the bus ID of the provided bridge.
0288 
0289 
0290 VME API
0291 -------
0292 
0293 .. kernel-doc:: drivers/staging/vme_user/vme.h
0294    :internal:
0295 
0296 .. kernel-doc:: drivers/staging/vme_user/vme.c
0297    :export: