BEST PCIe driver
 All Data Structures Files Functions Variables Macros Pages
BEST_PCIe.c File Reference

Drivers for BEST PCIe Cyclone V GT card. More...

#include <linux/kernel.h>
#include <linux/cdev.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/jiffies.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <asm/io.h>
#include <asm/ioctl.h>
#include "BEST_PCIe.h"
#include "BEST_PCIe_internal.h"
#include "msgdma/descriptor_regs.h"
#include "msgdma/csr_regs.h"
#include "alt_pcie/alt_pcie_cra_regs.h"
#include "mailbox/mailbox.h"
#include "BEST_dma_device.h"
#include "BEST_mailbox_device.h"
#include "BEST_direct_tetramm.h"
#include "BEST_direct_predac.h"
#include "BEST_flash.h"
#include "system_id/system_id.h"

Data Structures

struct  board_data
 

Macros

#define DEBUG_IRQ   0
 
#define DEBUG_IRQ_SMALL   0
 
#define debug_print(type, fmt, args...)   do { if (type) printk( KERN_DEBUG fmt, ##args); } while (0)
 
#define MOD_NAME   "best_pcie"
 Driver name (shows in lsmod and dmesg)
 
#define BEST_PCIE_NR_BARS   7
 Maximal number of BARs.
 
#define BAR_CTRL   0
 
#define BAR_DIRECT   1
 
#define BAR_MAIL   2
 
#define BAR_FLASH   4
 
#define BAR_FLASH_ERASE   5
 
#define BAR0_DMA_TETRAMMS_OFFSET   0x000
 
#define BAR0_DMA_TETRAMMS_IRQ_MASK   0x10
 
#define BAR0_DMA_DISP_OFFSET   0x100
 
#define BAR0_DMA_DISP_IRQ_MASK   0x1
 
#define BAR0_DMA_POSITION_OFFSET   0x200
 
#define BAR0_DMA_POSITION_IRQ_MASK   0x4
 
#define BAR0_DMA_DAC_OFFSET   0x300
 
#define BAR0_DMA_DAC_IRQ_MASK   0x8
 
#define BAR0_SYSTEM_ID   0x1000
 
#define BAR1_TETRAMM_0_OFFSET   0x0
 
#define BAR1_TETRAMM_1_OFFSET   0x0
 
#define BAR1_DAC_0_OFFSET   0x100
 
#define BAR2_MAILBOX_OFFSET   0x0
 
#define ALTERA_MSGDMA_CSR_OFFSSET   0x0
 mSGDMA CSR offset on Avalon Bus (BAR0)
 
#define ALTERA_MSGDMA_DESC_OFFSSET   0x20
 mSGDMA Desc offset on Avalon Bus (BAR0)
 
#define BAR0_CRA_REGS_OFFSET   0x4000
 Offset or CRA registers on BAR0.
 

Functions

 MODULE_DEVICE_TABLE (pci, ids)
 Macro to save PCI device list.
 
static irqreturn_t best_isr (int irq, void *dev_id)
 BEST interrupt service routine. More...
 
static int probe (struct pci_dev *dev, const struct pci_device_id *id)
 Claims control of PCI device. More...
 
static void remove (struct pci_dev *dev)
 Cleans PCI device things. More...
 
static int __init best_pcie_init (void)
 Registers driver to kernel. More...
 
static void __exit best_pcie_exit (void)
 Removes driver from kernel.
 
 module_init (best_pcie_init)
 Licence on our module is GPL (yet to discuss) More...
 
 module_exit (best_pcie_exit)
 Driver exit point.
 

Variables

int version [3] = {1,0,0}
 
static const struct pci_device_id ids []
 List of devices this driver recognizes. More...
 
static struct pci_driver pci_driver
 PCI driver structure. More...
 

Detailed Description

Drivers for BEST PCIe Cyclone V GT card.

Author
Jan Marjanovic (j.mar.nosp@m.jano.nosp@m.vic@c.nosp@m.aene.nosp@m.ls.co.nosp@m.m)
Date
February 2014

Function Documentation

static irqreturn_t best_isr ( int  irq,
void *  dev_id 
)
static

BEST interrupt service routine.

  • Clean DMA dispatcher irq bit
  • Clean DMA dispatcher irq bit
  • Clean DMA dispatcher irq bit
  • Clean DMA dispatcher irq bit
static int __init best_pcie_init ( void  )
static

Registers driver to kernel.

Returns
0 on success, negative on fail
module_init ( best_pcie_init  )

Licence on our module is GPL (yet to discuss)

Driver entry point

static int probe ( struct pci_dev *  dev,
const struct pci_device_id *  id 
)
static

Claims control of PCI device.

Parameters
devPCI device (bus, ...)
idDevice data (vendor, device, subvendor, subdevice...)
Returns
0 on success, negative on fail
  • Allocate memory for per-board book keeping
  • Enable pci device
  • Enable bus mastering on device
  • Enable MSI interrupts
  • Register interrupts
  • Scan BARs
  • Enable irq in Cra registers
static void remove ( struct pci_dev *  dev)
static

Cleans PCI device things.

Parameters
devPCI device (bus, ...)

Disable MSI

  • Remove character driver
  • Unmap BARs
  • Disable device

Variable Documentation

const struct pci_device_id ids[]
static
Initial value:
= {
{ PCI_DEVICE(0x1172, 0xBE57), },
{ 0, }
}

List of devices this driver recognizes.

struct pci_driver pci_driver
static
Initial value:
= {
.name = MOD_NAME,
.id_table = ids,
.probe = probe,
.remove = remove,
}
static int probe(struct pci_dev *dev, const struct pci_device_id *id)
Claims control of PCI device.
Definition: BEST_PCIe.c:246
#define MOD_NAME
Driver name (shows in lsmod and dmesg)
Definition: BEST_PCIe.c:51
static const struct pci_device_id ids[]
List of devices this driver recognizes.
Definition: BEST_PCIe.c:97

PCI driver structure.