vme_user: Use device_type methods to map per-bridge information into userland

Use the mechanisms provided by the device model to
set the ground for supporting multiple bridges
concurrently.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme_user: Export slot id to userland

Introduce a new ioctl VME_GET_SLOT_ID that exports
the result of vme_slot_get into userland.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
tsi148: Allow for exporting the bridge status

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme: Put shared kernel/userland constants into a separate header

Place all definitions from vme.h that are required for userland
applications info a new header file, vme_defs.h. Also include
the file in the list of exported userland headers.

This makes cycle types etc. safely shareable with userland,
invalidating some comments to the contrary in the vme_user
driver.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme, vme_user: Make bridge status public

Several status bits are of generic interest. Provide an
interface function that allows for obtaining this information
without having to resort to device-specific methods.

While at it, also export the information to userland via
the ioctl VME_GET_STATUS.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme_user: Simplify ioctl state machine

Concentrate error handling in one central spot so
that less clutter is present in the main dispatcher.
While at it, also switch to using pr_warn for the warning messages.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme_user: Make registration procedure more straightforward

Since there are no resources allocations that need
to be reversed in case of an error, we can save a few
pointless gotos.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme_user: Move master/slave window data structures into user-visible header

The definitions are required when userland requests, sets or
gets windows and their properties. While moving the structures
around, factor out some commonalities.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme_user: Dynamically request resource windows

Do not request all available master and slave windows at
initialisation time. Instead, a new ioctl VME_REQUEST_WINDOW
is introduced that must be used to request a window with
desired properties.

TODO: Could not do any harm to split this commit into smaller ones

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
VME: Allow for exclusive bus access

Introduce a bridge method (vme_set_dwb) to set the "device
wants bus" bit, which grants exclusive access to bus.
The bridge method vme_get_dwb_dhb() can be used to check
success of the request. It allows for reading both, the
DWB and DHB bits of the bus.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
VME: Implement device {has, wants} bus methods for tsi148

Query respectively set the appropriate registers.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme_user: Allow for exporting/setting dwb/dhb properties to/from userland

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
VME: Support acfail and sysfail interrupts

Both events are asynchronous and must usually be handled immediately,
so polling the corresponding status bits alone is not sufficient
(although it may be useful in certain cases). Extend the vme
framework to take care of these interrupts, and allow for registering
callback functions.

The irq_mtx mutex used for the generic IRQ callbacks is extended to
also cover manipulations of the interrupt masks in the acfail
and sysfail case.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
vme_tsi148: Add support for acfail and sysfail

Implement bridge methods for enabling and disabling the
acfail and sysfail interrupts, and introduce a corresponding
interrupt handler that calls any callbacks registered via
the generic VME framework.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
VME: Fix location monitor locking

Attaching and detaching location monitors manipulates
the interrupt mask, so use the irq_mtx mutex to protect
against concurrent accesses from other irq mask manipulations.

Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>