/home/hillier_g/checkout/most4linux/most-kernel/most-pci.c File Reference

Implementation of the MOST PCI driver. More...

Go to the source code of this file.

Defines

#define DRIVER_NAME   "most-pci"
#define PR   DRIVER_NAME ": "
#define SCTL_MAXLOOP   10000

Functions

static u32 readreg (struct most_dev *, u32)
static void writereg (struct most_dev *, u32, u32)
static void changereg (struct most_dev *, u32, u32, u32)
static int writereg_8104 (struct most_dev *, unsigned char *, size_t, u32)
static int readreg_8104 (struct most_dev *, unsigned char *, size_t, u32)
static bool get_license (struct most_dev *)
static void revision (struct most_dev *)
static void intset (struct most_dev *, unsigned int, unsigned int, unsigned int *)
static void reset (struct most_dev *)
static void intclear (struct most_dev *, unsigned int)
static int features (struct most_dev *)
static int dma_allocate (struct most_dev *, struct dma_buffer *)
static void dma_deallocate (struct most_dev *, struct dma_buffer *)
 MODULE_DEVICE_TABLE (pci, ids)
static u32 loop_until_bit_is_clear (void __iomem *addr, u32 bitmask, bool *timeout)
static u32 readreg_int (struct most_dev *dev, u32 address)
static void writereg_int (struct most_dev *dev, u32 value, u32 address)
static bool keyctrl_reset (struct most_dev *dev)
static unsigned char dsc_shift_read_byte (struct most_dev *dev)
static void dsc_shift_write_byte (struct most_dev *dev, unsigned char data)
static void manage_usage (struct most_dev *dev, int change)
void high_driver_registered (struct most_high_driver *drv)
void high_driver_deregistered (struct most_high_driver *drv)
void proc_show (struct seq_file *s)
static rtnrt_irqreturn_t handle_interrupt (struct most_dev *dev)
 DECLARE_IRQ_PROXY (int_handler, handle_interrupt, struct most_dev)
static int probe (struct pci_dev *lpci_dev, const struct pci_device_id *id)
static void remove (struct pci_dev *lpci_dev)
static void write_map_8104 (struct most_dev *dev, unsigned char map)
static void write_data_8104 (struct most_dev *dev, unsigned char data)
static unsigned char read_data_8104 (struct most_dev *dev)
static int __init most_pci_init (void)
static void __exit most_pci_exit (void)

Variables

static char * version = "$Rev: 639 $"
static int disable_shared_irq = false
static struct most_devdevices [MOST_DEVICE_NUMBER]
static struct rw_semaphore sema = __RWSEM_INITIALIZER(sema)
static struct pci_device_id ids []
static struct pci_driver pci_driver
static struct most_low_driver low_driver


Detailed Description

Implementation of the MOST PCI driver.

Definition in file most-pci.c.


Define Documentation

#define DRIVER_NAME   "most-pci"

The name of the driver.

Definition at line 54 of file most-pci.c.

#define PR   DRIVER_NAME ": "

The prefix for printk outputs.

Definition at line 59 of file most-pci.c.

#define SCTL_MAXLOOP   10000

Maximum loop cound for reading the DSCTRL register.

Definition at line 64 of file most-pci.c.

Referenced by dsc_shift_read_byte(), dsc_shift_write_byte(), and keyctrl_reset().


Function Documentation

static u32 readreg ( struct most_dev dev,
u32  address 
) [static]

Reads a register.

Parameters:
dev the most_dev stucture for the device
address the address to read from
Returns:
the value that was read

Definition at line 811 of file most-pci.c.

References readreg_int().

Referenced by probe().

static void writereg ( struct most_dev dev,
u32  value,
u32  address 
) [static]

Writes a register.

Parameters:
dev the most_dev structure
value the value to write
address the address to write to

Definition at line 823 of file most-pci.c.

References writereg_int().

Referenced by probe().

static void changereg ( struct most_dev dev,
u32  address,
u32  value,
u32  mask 
) [static]

Sets the bits set in value which are set to one in mask.

Parameters:
dev the most_dev structure
address the address to write to
value the value to write
mask the mask for value

Definition at line 836 of file most-pci.c.

References most_dev::lock, readreg_int(), and writereg_int().

Referenced by probe().

static int writereg_8104 ( struct most_dev dev,
unsigned char *  src,
size_t  len,
u32  addr 
) [static]

Performs a write of of one or more registers on the OS8104. For a detailled description see the comment near the typedef read_os8104_func.

Parameters:
dev the most_dev structure for the device (which must be a PCI structure in that case
src the source array to read from (kernel address space)
len the number of bytes to write
addr the start address to write to from
Returns:
the number of bytes that have been written on success, a negative error code on failure

Definition at line 995 of file most-pci.c.

References most_dev::lock, MOST_IF_PAGE, PCI_DEV, write_data_8104(), and write_map_8104().

Referenced by probe().

static int readreg_8104 ( struct most_dev dev,
unsigned char *  dest,
size_t  len,
u32  addr 
) [static]

Performs a read of of one or more registers on the OS8104. For a detailled description see the comment near the typedef write_os8104_func.

Parameters:
dev the most_dev structure for the device (which must be a PCI structure in that case
dest the destination to copy (kernel address space)
len the number of bytes to read
addr the start address to read from
Returns:
the number of bytes that have been read on success, a negative error code on failure

Definition at line 953 of file most-pci.c.

References most_dev::lock, MOST_IF_PAGE, PCI_DEV, read_data_8104(), write_data_8104(), and write_map_8104().

Referenced by probe().

static bool get_license ( struct most_dev dev  )  [static]

Gets the license.

Returns:
true on success, false on failure

Definition at line 294 of file most-pci.c.

References dsc_shift_read_byte(), dsc_shift_write_byte(), DSCTL_CRC_EN, DSCTL_CRC_RST, keyctrl_reset(), LICENSE_ADDRESS_HW, MOST_PCI_DSCTRL_REG, MOST_PCI_LICCOMP_REG, MOST_PCI_LICENSE_REG, PR, rtnrt_info, most_dev::serial_number, and writereg_int().

Referenced by probe().

static void revision ( struct most_dev dev  )  [static]

Sets the fpga_revision, product_id and fpga_features of the device structure.

Parameters:
dev the device

Definition at line 433 of file most-pci.c.

References MOST_PCI_FW_FOT_STATUS, MOST_PCI_FW_NEW_PACKET_LEN_POS, MOST_PCI_FW_RX_TX_BIG_ENABLE, MOST_PCI_FW_SEC_ASYNC_ADDR, MOST_PCI_VERSION_REG, PCI_DEV, PR, most_dev::product_id, readreg_int(), and rtnrt_info.

Referenced by probe().

static void intset ( struct most_dev dev,
unsigned int  interrupts,
unsigned int  mask,
unsigned int *  oldmask 
) [static]

Impements the interrupt disable method of a most_dev.

Parameters:
dev the most_dev which must be a PCI device here
interrupts value to set
mask the mask which must be applied to value before applying value to the interrupt mask register
oldmask if not NULL it will be set to the old value of the interrupt mask register (doesn't correspond to mask parameter)

Definition at line 1035 of file most-pci.c.

References most_dev::lock, MOST_PCI_INTMASK_REG, PR, pr_irq_debug, readreg_int(), and writereg_int().

Referenced by probe().

static void reset ( struct most_dev dev  )  [static]

Reset the MOST Transceiver

Parameters:
dev the device

Definition at line 1079 of file most-pci.c.

References EXEC, most_dev::lock, loop_until_bit_is_clear(), MOST_PCI_CMD_REG, MRST, PCI_DEV, and writereg_int().

Referenced by probe().

static void intclear ( struct most_dev dev,
unsigned int  interrupts 
) [static]

Clears the given interrupt

Parameters:
dev the MOST device
interrupts the interrupt mask to clear

Definition at line 1069 of file most-pci.c.

References MOST_PCI_INTSTATUS_REG, and writereg_int().

Referenced by probe().

int features ( struct most_dev dev  )  [static]

Check which features are available. Returns a bitwise combination of MOST_PCI_FEATURE_ASYNC, MOST_PCI_FEATURE_SYNC, MOST_PCI_FEATURE_MASTER and MOST_PCI_FEATURE_CTRL.

Definition at line 404 of file most-pci.c.

References DSCTL_EN_ASYNC, DSCTL_EN_CTRL, DSCTL_EN_MASTER, DSCTL_EN_SYNC, MOST_FEATURE_ASYNC, MOST_FEATURE_CTRL, MOST_FEATURE_MASTER, MOST_FEATURE_SYNC, MOST_PCI_DSCTRL_REG, and readreg_int().

Referenced by probe().

static int dma_allocate ( struct most_dev dev,
struct dma_buffer dma 
) [static]

Allocates a DMA buffer.

Parameters:
dev the MOST device
dma the DMA buffer
Returns:
0 on success, a negative error failure

Definition at line 1102 of file most-pci.c.

References dma_buffer::addr_bus, dma_buffer::addr_virt, PCI_DEV, PR, pr_reg_access_debug, rtnrt_err, and dma_buffer::size.

Referenced by probe().

static void dma_deallocate ( struct most_dev dev,
struct dma_buffer dma 
) [static]

Deallocate DMA buffer.

Parameters:
dev the MOST device
dma the DMA buffer
Returns:
0 on success, a negative error failure

Definition at line 1125 of file most-pci.c.

References dma_buffer::addr_bus, dma_buffer::addr_virt, PCI_DEV, PR, pr_reg_access_debug, and dma_buffer::size.

Referenced by probe().

MODULE_DEVICE_TABLE ( pci  ,
ids   
)

The module device table for Linux

static u32 loop_until_bit_is_clear ( void __iomem *  addr,
u32  bitmask,
bool timeout 
) [inline, static]

Reads out an address until a given bit is clear. This is done in a "intelligent" way, i.e. it's only looped MOST_MAX_POLL times and a delay (without bus transfers) is added between the tries.

Parameters:
addr the address to read from
bitmask the bit mask to check for
timeout if not NULL this value will be set to true if the operation finished because a timeout (and not because of the condition is met) and to false if the operation finished because the condition was met
Returns:
the value at addr

Definition at line 140 of file most-pci.c.

References MOST_DELAY_INCREMENT, MOST_MAX_POLL, and rtnrt_err.

Referenced by read_data_8104(), reset(), write_data_8104(), and write_map_8104().

static u32 readreg_int ( struct most_dev dev,
u32  address 
) [inline, static]

Internal readreg function, inlined.

Parameters:
[in] dev the MOST device
[in] address address the address to read

Definition at line 173 of file most-pci.c.

References PCI_DEV, PR, and pr_reg_access_debug.

Referenced by changereg(), dsc_shift_read_byte(), dsc_shift_write_byte(), features(), handle_interrupt(), intset(), keyctrl_reset(), readreg(), and revision().

static void writereg_int ( struct most_dev dev,
u32  value,
u32  address 
) [inline, static]

Internal writereg function, inlined.

Parameters:
[in] dev the MOST device
[in] value the value to write at address
[in] address address the address to read

Definition at line 187 of file most-pci.c.

References PCI_DEV, PR, and pr_reg_access_debug.

Referenced by changereg(), dsc_shift_read_byte(), dsc_shift_write_byte(), get_license(), handle_interrupt(), intclear(), intset(), keyctrl_reset(), read_data_8104(), reset(), write_data_8104(), write_map_8104(), and writereg().

static bool keyctrl_reset ( struct most_dev dev  )  [inline, static]

Resets the Dallas Silicon Key (LIC)

Parameters:
[in] dev the MOST device

Definition at line 198 of file most-pci.c.

References DSCTL_PRE, DSCTL_RST, MOST_PCI_DSCTRL_REG, PR, readreg_int(), rtnrt_err, SCTL_MAXLOOP, and writereg_int().

Referenced by get_license().

static unsigned char dsc_shift_read_byte ( struct most_dev dev  )  [static]

(LIC) Dallas Silicon Key Control (DSCTRL) Register

Parameters:
[in] dev the MOST device

Definition at line 226 of file most-pci.c.

References DSCTL_RD, DSCTL_RD_VAL, MOST_PCI_DSCTRL_REG, readreg_int(), SCTL_MAXLOOP, and writereg_int().

Referenced by get_license().

static void dsc_shift_write_byte ( struct most_dev dev,
unsigned char  data 
) [static]

(LIC) Dallas Silicon Key Control (DSCTRL) Register

Parameters:
[in] dev the MOST device
[in] data the data to write

Definition at line 262 of file most-pci.c.

References DSCTL_WR, DSCTL_WR_VAL, MOST_PCI_DSCTRL_REG, readreg_int(), SCTL_MAXLOOP, and writereg_int().

Referenced by get_license().

static void manage_usage ( struct most_dev dev,
int  change 
) [static]

Increase usage count

Parameters:
dev unused
change change 1 if the usage count should be increased, -1 if it should be decreased

Definition at line 388 of file most-pci.c.

References PR, and rtnrt_err.

Referenced by probe().

void high_driver_registered ( struct most_high_driver drv  ) 

Called from most_base.ko if a high-level driver was registered. Calls the probe function for the high driver for each device already present in the system.

Parameters:
drv the high driver which was just registered

Definition at line 467 of file most-pci.c.

References devices, MOST_DEVICE_NUMBER, most_high_driver::probe, and sema.

void high_driver_deregistered ( struct most_high_driver drv  ) 

Called from most_base.ko if a high-level driver was registered. Calls the remove function for the high driver for each device present in the system.

Parameters:
drv the high driver which was just deregistered

Definition at line 488 of file most-pci.c.

References devices, MOST_DEVICE_NUMBER, most_high_driver::remove, and sema.

void proc_show ( struct seq_file *  s  ) 

Shows information about PCI devices in the MOST proc file.

Parameters:
s the sequence file

Definition at line 508 of file most-pci.c.

References devices, MOST_DEVICE_NUMBER, and sema.

static rtnrt_irqreturn_t handle_interrupt ( struct most_dev dev  )  [inline, static]

Does the actual interrupt handling.

Parameters:
dev the MOST device

Definition at line 532 of file most-pci.c.

References most_high_driver::int_handler, most_high_driver::interrupt_mask, spin_locked_list::list, spin_locked_list::lock, measuring_int_begin, measuring_int_end, measuring_int_error_sharing, most_base_high_drivers_spin, MOST_PCI_INTMASK_REG, MOST_PCI_INTSTATUS_REG, PR, pr_irq_debug, readreg_int(), RTNRT_IRQ_HANDLED, RTNRT_IRQ_NONE, rtnrt_lock_get, rtnrt_lock_put, most_high_driver::spin_list, and writereg_int().

DECLARE_IRQ_PROXY ( int_handler  ,
handle_interrupt  ,
struct  most_dev 
)

The real-time interrupt service routine of a PCI driver.

static int probe ( struct pci_dev *  lpci_dev,
const struct pci_device_id *  id 
) [static]

The probe function. This function is called if the PCI card was found, i.e. normally on the insertion of the Kernel module for each PCI card that has the right IDs.

Parameters:
lpci_dev the pci_dev structure for the device
id the id that was responsible for calling this function
Returns:
0 on success, any other error code on failure

Definition at line 589 of file most-pci.c.

References most_dev::card_number, changereg(), most_ops::changereg, devices, disable_shared_irq, dma_allocate(), most_ops::dma_allocate, dma_deallocate(), most_ops::dma_deallocate, features(), most_ops::features, get_license(), most_dev::impl, most_high_driver::int_handler, intclear(), most_ops::intclear, intset(), most_ops::intset, rwsema_locked_list::list, rwsema_locked_list::lock, manage_usage(), most_dev::manage_usage, most_base_high_drivers_sema, MOST_DEV_CARDNUMBER, most_dev_free(), most_dev_new(), MOST_DEVICE_NUMBER, most_intset, most_dev::name, most_dev::ops, PCI_DEV, PR, most_high_driver::probe, most_ops_rt::readreg, readreg(), most_ops::readreg, most_ops::readreg8104, readreg_8104(), reset(), most_ops::reset, revision(), most_dev::rt_ops, rtnrt_err, rtnrt_free_interrupt_handler, rtnrt_info, rtnrt_irq_enable, rtnrt_register_interrupt_handler, rtnrt_warn, sema, most_high_driver::sema_list, most_dev::serial_number, most_ops_rt::writereg, writereg(), most_ops::writereg, most_ops::writereg8104, and writereg_8104().

static void remove ( struct pci_dev *  lpci_dev  )  [static]

This function gets called if the PCI card was removed from the system. Since normal PCs are not hot-pluggable, the function is called while unloading the module.

Parameters:
lpci_dev the pci_dev structure for the device that was removed from the system

Definition at line 761 of file most-pci.c.

References most_dev::card_number, devices, rwsema_locked_list::list, rwsema_locked_list::lock, most_base_high_drivers_sema, MOST_DEV_CARDNUMBER, most_dev_free(), PCI_DEV, most_high_driver::remove, rtnrt_free_interrupt_handler, rtnrt_info, and sema.

static void write_map_8104 ( struct most_dev dev,
unsigned char  map 
) [inline, static]

Writes MAP. This is only a helper function. The dev->lock_cmdreg must be held when calling this function.

Parameters:
dev the device
map the address

Definition at line 856 of file most-pci.c.

References EXEC, loop_until_bit_is_clear(), MOST_PCI_CMD_REG, PCI_DEV, pr_devfunc_debug, and writereg_int().

Referenced by readreg_8104(), and writereg_8104().

static void write_data_8104 ( struct most_dev dev,
unsigned char  data 
) [inline, static]

Writes data. This is only a help function. The dev->lock_cmdreg must be held when calling this function.

Parameters:
dev the device
data the data

Definition at line 885 of file most-pci.c.

References CPOP1, EXEC, loop_until_bit_is_clear(), MOST_PCI_CMD_REG, PCI_DEV, pr_devfunc_debug, and writereg_int().

Referenced by readreg_8104(), and writereg_8104().

static unsigned char read_data_8104 ( struct most_dev dev  )  [inline, static]

Reads data. This is only a helper function. The dev->lock_cmdreg must be held when calling this function.

Parameters:
dev the device

Definition at line 912 of file most-pci.c.

References CPOP0, CPOP1, EXEC, loop_until_bit_is_clear(), MOST_PCI_CMD_REG, PCI_DEV, pr_devfunc_debug, VALUE_DATA, and writereg_int().

Referenced by readreg_8104().

static int __init most_pci_init ( void   )  [static]

This function gets called if the kernel loads this module.

Returns:
0 on success, an error code on failure

Definition at line 1161 of file most-pci.c.

References DRIVER_NAME, low_driver, most_register_low_driver(), pci_driver, rtnrt_info, and version.

static void __exit most_pci_exit ( void   )  [static]

This function gets called if the Kernel removes this module.

Definition at line 1172 of file most-pci.c.

References DRIVER_NAME, low_driver, most_deregister_low_driver(), pci_driver, rtnrt_info, and version.


Variable Documentation

char* version = "$Rev: 639 $" [static]

Variable that holds the driver version.

Definition at line 69 of file most-pci.c.

int disable_shared_irq = false [static]

Module parameter which disables IRQ sharing.

Definition at line 92 of file most-pci.c.

Referenced by probe().

struct most_dev* devices[MOST_DEVICE_NUMBER] [static]

Array of all MOST PCI devices.

Definition at line 104 of file most-pci.c.

Referenced by high_driver_deregistered(), high_driver_registered(), probe(), proc_show(), and remove().

struct rw_semaphore sema = __RWSEM_INITIALIZER(sema) [static]

Lock for all PCI devices. This is needed to travers the devices list.

Definition at line 109 of file most-pci.c.

Referenced by high_driver_deregistered(), high_driver_registered(), probe(), proc_show(), and remove().

struct pci_device_id ids[] [static]

Initial value:

 { 
    { PCI_DEVICE(PCI_VENDOR_ID_OASIS, PCI_DEVICE_ID_OASIS_MOST_PCI_INTERFACE) },
    { PCI_DEVICE(0, 0) },
}
The ID table for this PCI device.

Definition at line 114 of file most-pci.c.

struct pci_driver pci_driver [static]

Initial value:

 {
    .name     = DRIVER_NAME,
    .id_table = ids,
    .probe    = probe,
    .remove   = remove
}
The PCI driver structure for the PCI subsystem of the Kernel. This driver does not support power-management.

Definition at line 1138 of file most-pci.c.

Referenced by most_pci_exit(), and most_pci_init().

struct most_low_driver low_driver [static]

Initial value:

 {
    .name                       = "most-pci",
    .list                       = LIST_HEAD_INIT(low_driver.list),
    .high_driver_registered     = high_driver_registered,
    .high_driver_deregistered   = high_driver_deregistered,
    .proc_show                  = proc_show
}
The low driver which is registered in the most_base.ko module.

Definition at line 1148 of file most-pci.c.

Referenced by most_base_seq_show(), most_deregister_high_driver(), most_pci_exit(), most_pci_init(), and most_register_high_driver().


Generated on Fri Mar 9 14:48:58 2007 for MOST Linux Drivers (Linux and RTAI) by  doxygen 1.5.0