nidas  v1.2-1520
Macros | Functions | Variables
gpio_mm.c File Reference
#include <linux/types.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/fs.h>
#include <linux/workqueue.h>
#include <linux/poll.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <asm/io.h>
#include "gpio_mm.h"
#include <nidas/linux/ver_macros.h>
#include <nidas/linux/klog.h>
#include <nidas/linux/util.h>
#include <nidas/linux/isa_bus.h>
#include <nidas/linux/Revision.h>

Macros

#define IRQF_SHARED   SA_SHIRQ
 
#define REPO_REVISION   "unknown"
 
#define BUFFER_POLL
 
#define BUFFER_POLL
 

Functions

 module_param_array (ioports_dio, uint, numboards_dio, 0)
 
 module_param_array (ioports, uint, numboards, 0)
 
 module_param_array (irqa, int, numirqa, 0)
 
 module_param_array (irqb, int, numirqb, 0)
 
 module_param (clockHZ, int, 0)
 
 MODULE_AUTHOR ("Gordon Maclean <maclean@ucar.edu>")
 
 MODULE_LICENSE ("Dual BSD/GPL")
 
 MODULE_DESCRIPTION ("Driver for Diamond GPIO card")
 
 MODULE_VERSION (REPO_REVISION)
 
static int gcd (unsigned int a, unsigned int b)
 
static void gpio_mm_set_master_mode (struct GPIO_MM *brd, int chip)
 
static void gpio_mm_setup_counter (struct GPIO_MM *brd, int icntr, unsigned char lmode, unsigned char hmode)
 
static void gpio_mm_cmd_counter (struct GPIO_MM *brd, int icntr, unsigned char cmd)
 
static void gpio_mm_cmd_counters (struct GPIO_MM *brd, int icntr1, int icntr2, unsigned char cmd)
 
static void gpio_mm_arm_counter (struct GPIO_MM *brd, int icntr)
 
static void gpio_mm_arm_counters (struct GPIO_MM *brd, int icntr1, int icntr2)
 
static void gpio_mm_load_counter (struct GPIO_MM *brd, int icntr)
 
static void gpio_mm_load_arm_counter (struct GPIO_MM *brd, int icntr)
 
static void gpio_mm_load_arm_counters (struct GPIO_MM *brd, int icntr1, int icntr2)
 
static void gpio_mm_disarm_counter (struct GPIO_MM *brd, int icntr)
 
static void gpio_mm_disarm_counters (struct GPIO_MM *brd, int icntr1, int icntr2)
 
static void gpio_mm_disarm_save_counter (struct GPIO_MM *brd, int icntr)
 
static void gpio_mm_disarm_save_counters (struct GPIO_MM *brd, int icntr1, int icntr2)
 
static void gpio_mm_set_reg (struct GPIO_MM *brd, int icntr, unsigned short val, unsigned char reg)
 
static unsigned short gpio_mm_get_reg (struct GPIO_MM *brd, int icntr, unsigned char reg)
 
static void gpio_mm_set_load_reg (struct GPIO_MM *brd, int icntr, unsigned short val)
 
static void gpio_mm_set_hold_reg (struct GPIO_MM *brd, int icntr, unsigned short val)
 
static unsigned short gpio_mm_get_hold_reg (struct GPIO_MM *brd, int icntr)
 
static void gpio_mm_set_toggle_out (struct GPIO_MM *brd, int icntr)
 
static void gpio_mm_clear_toggle_out (struct GPIO_MM *brd, int icntr)
 
static unsigned char gpio_mm_get_output_status (struct GPIO_MM *brd, int icntr)
 
static int compute_timer_ticks (struct list_head *cblist, unsigned int *maxUsecsp)
 
static int check_timer_interval (struct GPIO_MM *brd, unsigned int usecs)
 
static void set_ticks (struct GPIO_MM_timer *timer, unsigned int usecs, unsigned int maxUsecs, unsigned short *initial_ticsp)
 
static void start_gpio_timer (struct GPIO_MM_timer *timer, unsigned int usecs, unsigned int maxUsecs)
 
static void stop_gpio_timer (struct GPIO_MM_timer *timer)
 
static void handlePendingCallbacks (struct GPIO_MM_timer *timer)
 
static void free_timer_callbacks (struct GPIO_MM_timer *timer)
 
static void gpio_mm_timer_bottom_half (unsigned long dev)
 
static irqreturn_t gpio_mm_timer_irq_handler (int irq, void *dev_id)
 
static irqreturn_t gpio_mm_event_irq_handler (int irq, void *dev_id)
 
static int gpio_mm_set_irq_user (struct GPIO_MM *brd, int irq_ab, irq_handler_t handler)
 
static int gpio_mm_remove_irq_user (struct GPIO_MM *brd, int irq_ab)
 
static int gpio_mm_set_timer_irq_user (struct GPIO_MM *brd)
 
static int gpio_mm_remove_timer_irq_user (struct GPIO_MM *brd)
 
static int gpio_mm_reserve_cntrs (struct GPIO_MM *brd, int ic1, int icn)
 
static int gpio_mm_free_cntrs (struct GPIO_MM *brd, int ic0, int icn)
 
static int get_pulse_counter (struct GPIO_MM_fcntr *fcntr)
 
static int gpio_mm_setup_fcntr (struct GPIO_MM_fcntr *fcntr)
 
static int gpio_mm_stop_fcntr (struct GPIO_MM_fcntr *fcntr)
 
static void fcntr_timer_callback_func (void *privateData)
 
static int start_fcntr (struct GPIO_MM_fcntr *fcntr, struct GPIO_MM_fcntr_config *cfg)
 
static int stop_fcntr (struct GPIO_MM_fcntr *fcntr)
 
static int gpio_mm_open_fcntr (struct inode *inode, struct file *filp)
 
static int gpio_mm_release_fcntr (struct inode *inode, struct file *filp)
 
static ssize_t gpio_mm_read_fcntr (struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
 
static long gpio_mm_ioctl_fcntr (struct file *filp, unsigned int cmd, unsigned long arg)
 
unsigned int gpio_mm_poll_fcntr (struct file *filp, poll_table *wait)
 
static int gpio_mm_setup_event (struct GPIO_MM_event *event)
 
static int gpio_mm_stop_event (struct GPIO_MM_event *event)
 
static int start_event (struct GPIO_MM_event *event, struct GPIO_MM_event_config *cfg)
 
static int stop_event (struct GPIO_MM_event *event)
 
static int gpio_mm_open_event (struct inode *inode, struct file *filp)
 
static int gpio_mm_release_event (struct inode *inode, struct file *filp)
 
static ssize_t gpio_mm_read_event (struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
 
static long gpio_mm_ioctl_event (struct file *filp, unsigned int cmd, unsigned long arg)
 
unsigned int gpio_mm_poll_event (struct file *filp, poll_table *wait)
 
static int cleanup_fcntrs (struct GPIO_MM *brd)
 
static int init_fcntrs (struct GPIO_MM *brd)
 
static int cleanup_event (struct GPIO_MM *brd)
 
static int init_event (struct GPIO_MM *brd)
 
static struct gpio_timer_callback * register_gpio_timer_callback_priv (struct GPIO_MM_timer *timer, gpio_timer_callback_func_t callback, unsigned int usecs, void *privateData, int *errp)
 
static long unregister_gpio_timer_callback_priv (struct GPIO_MM_timer *timer, struct gpio_timer_callback *cb, int wait)
 
struct gpio_timer_callback * register_gpio_timer_callback (gpio_timer_callback_func_t callback, unsigned int usecs, void *privateData, int *errp)
 
 EXPORT_SYMBOL (register_gpio_timer_callback)
 
long unregister_gpio_timer_callback (struct gpio_timer_callback *cb, int wait)
 
 EXPORT_SYMBOL (unregister_gpio_timer_callback)
 
static void cleanup_gpio_timer (struct GPIO_MM_timer *timer)
 
static struct GPIO_MM_timer * init_gpio_timer (struct GPIO_MM *brd)
 
static void gpio_mm_cleanup (void)
 
static int __init gpio_mm_init (void)
 
 module_init (gpio_mm_init)
 
 module_exit (gpio_mm_cleanup)
 

Variables

static const char * driver_name = "gpio_mm"
 
static unsigned int ioports [MAX_GPIO_MM_BOARDS] ={ 0x080, 0, 0, 0 , 0}
 
static unsigned int ioports_dio [MAX_GPIO_MM_BOARDS] = { 0x040, 0, 0, 0, 0 }
 
static int numboards = 0
 
static int numboards_alloc = 0
 
static int numboards_dio = 0
 
static int irqa [MAX_GPIO_MM_BOARDS] = { 3, 0, 0, 0, 0 }
 
static int irqb [MAX_GPIO_MM_BOARDS] = { 0, 0, 0, 0, 0 }
 
static int numirqa = 0
 
static int numirqb = 0
 
static int clockHZ = GPIO_MM_CT_CLOCK_HZ
 
static dev_t gpio_mm_device = MKDEV(0,0)
 
static struct GPIO_MM * board = 0
 
static struct class * gpio_mm_class
 
static struct file_operations fcntr_fops
 
static struct file_operations event_fops
 

Macro Definition Documentation

#define BUFFER_POLL
#define BUFFER_POLL
#define IRQF_SHARED   SA_SHIRQ

Referenced by gpio_mm_set_irq_user().

#define REPO_REVISION   "unknown"

Referenced by gpio_mm_init().

Function Documentation

static int check_timer_interval ( struct GPIO_MM *  brd,
unsigned int  usecs 
)
static
static int cleanup_event ( struct GPIO_MM *  brd)
static
static int cleanup_fcntrs ( struct GPIO_MM *  brd)
static
static void cleanup_gpio_timer ( struct GPIO_MM_timer *  timer)
static
static int compute_timer_ticks ( struct list_head *  cblist,
unsigned int *  maxUsecsp 
)
static

References gcd().

Referenced by handlePendingCallbacks().

EXPORT_SYMBOL ( register_gpio_timer_callback  )
EXPORT_SYMBOL ( unregister_gpio_timer_callback  )
static void fcntr_timer_callback_func ( void *  privateData)
static
static void free_timer_callbacks ( struct GPIO_MM_timer *  timer)
static

Referenced by cleanup_gpio_timer().

static int gcd ( unsigned int  a,
unsigned int  b 
)
static

Referenced by compute_timer_ticks().

static int get_pulse_counter ( struct GPIO_MM_fcntr *  fcntr)
static
static void gpio_mm_arm_counter ( struct GPIO_MM *  brd,
int  icntr 
)
inlinestatic

References CTS9513_ARM, and gpio_mm_cmd_counter().

Referenced by start_gpio_timer().

static void gpio_mm_arm_counters ( struct GPIO_MM *  brd,
int  icntr1,
int  icntr2 
)
inlinestatic
static void gpio_mm_cleanup ( void  )
static
static void gpio_mm_clear_toggle_out ( struct GPIO_MM *  brd,
int  icntr 
)
static
static void gpio_mm_cmd_counter ( struct GPIO_MM *  brd,
int  icntr,
unsigned char  cmd 
)
static
static void gpio_mm_cmd_counters ( struct GPIO_MM *  brd,
int  icntr1,
int  icntr2,
unsigned char  cmd 
)
static
static void gpio_mm_disarm_counter ( struct GPIO_MM *  brd,
int  icntr 
)
inlinestatic
static void gpio_mm_disarm_counters ( struct GPIO_MM *  brd,
int  icntr1,
int  icntr2 
)
inlinestatic
static void gpio_mm_disarm_save_counter ( struct GPIO_MM *  brd,
int  icntr 
)
static
static void gpio_mm_disarm_save_counters ( struct GPIO_MM *  brd,
int  icntr1,
int  icntr2 
)
inlinestatic
static irqreturn_t gpio_mm_event_irq_handler ( int  irq,
void *  dev_id 
)
static

References GPIO_MM_IRQ_CTL_STATUS.

Referenced by gpio_mm_setup_event().

static int gpio_mm_free_cntrs ( struct GPIO_MM *  brd,
int  ic0,
int  icn 
)
static

Referenced by gpio_mm_stop_fcntr().

static unsigned short gpio_mm_get_hold_reg ( struct GPIO_MM *  brd,
int  icntr 
)
inlinestatic
static unsigned char gpio_mm_get_output_status ( struct GPIO_MM *  brd,
int  icntr 
)
static
static unsigned short gpio_mm_get_reg ( struct GPIO_MM *  brd,
int  icntr,
unsigned char  reg 
)
static
static int __init gpio_mm_init ( void  )
static
static long gpio_mm_ioctl_event ( struct file *  filp,
unsigned int  cmd,
unsigned long  arg 
)
static
static long gpio_mm_ioctl_fcntr ( struct file *  filp,
unsigned int  cmd,
unsigned long  arg 
)
static
static void gpio_mm_load_arm_counter ( struct GPIO_MM *  brd,
int  icntr 
)
inlinestatic
static void gpio_mm_load_arm_counters ( struct GPIO_MM *  brd,
int  icntr1,
int  icntr2 
)
inlinestatic
static void gpio_mm_load_counter ( struct GPIO_MM *  brd,
int  icntr 
)
static

References CTS9513_LOAD, and gpio_mm_cmd_counter().

Referenced by start_gpio_timer().

static int gpio_mm_open_event ( struct inode *  inode,
struct file *  filp 
)
static

References board, and numboards.

static int gpio_mm_open_fcntr ( struct inode *  inode,
struct file *  filp 
)
static

References board, and numboards.

unsigned int gpio_mm_poll_event ( struct file *  filp,
poll_table *  wait 
)
unsigned int gpio_mm_poll_fcntr ( struct file *  filp,
poll_table *  wait 
)
static ssize_t gpio_mm_read_event ( struct file *  filp,
char __user *  buf,
size_t  count,
loff_t *  f_pos 
)
static

References nidas_circbuf_read().

static ssize_t gpio_mm_read_fcntr ( struct file *  filp,
char __user *  buf,
size_t  count,
loff_t *  f_pos 
)
static

References nidas_circbuf_read().

static int gpio_mm_release_event ( struct inode *  inode,
struct file *  filp 
)
static

References board, numboards, and stop_event().

static int gpio_mm_release_fcntr ( struct inode *  inode,
struct file *  filp 
)
static

References board, numboards, and stop_fcntr().

static int gpio_mm_remove_irq_user ( struct GPIO_MM *  brd,
int  irq_ab 
)
static
static int gpio_mm_remove_timer_irq_user ( struct GPIO_MM *  brd)
static

References gpio_mm_remove_irq_user().

Referenced by cleanup_gpio_timer().

static int gpio_mm_reserve_cntrs ( struct GPIO_MM *  brd,
int  ic1,
int  icn 
)
static
static void gpio_mm_set_hold_reg ( struct GPIO_MM *  brd,
int  icntr,
unsigned short  val 
)
inlinestatic
static int gpio_mm_set_irq_user ( struct GPIO_MM *  brd,
int  irq_ab,
irq_handler_t  handler 
)
static
static void gpio_mm_set_load_reg ( struct GPIO_MM *  brd,
int  icntr,
unsigned short  val 
)
inlinestatic
static void gpio_mm_set_master_mode ( struct GPIO_MM *  brd,
int  chip 
)
static
static void gpio_mm_set_reg ( struct GPIO_MM *  brd,
int  icntr,
unsigned short  val,
unsigned char  reg 
)
static
static int gpio_mm_set_timer_irq_user ( struct GPIO_MM *  brd)
static
static void gpio_mm_set_toggle_out ( struct GPIO_MM *  brd,
int  icntr 
)
static
static void gpio_mm_setup_counter ( struct GPIO_MM *  brd,
int  icntr,
unsigned char  lmode,
unsigned char  hmode 
)
static
static int gpio_mm_setup_event ( struct GPIO_MM_event *  event)
static
static int gpio_mm_setup_fcntr ( struct GPIO_MM_fcntr *  fcntr)
static
static int gpio_mm_stop_event ( struct GPIO_MM_event *  event)
static
static int gpio_mm_stop_fcntr ( struct GPIO_MM_fcntr *  fcntr)
static
static void gpio_mm_timer_bottom_half ( unsigned long  dev)
static

References handlePendingCallbacks().

Referenced by init_gpio_timer().

static irqreturn_t gpio_mm_timer_irq_handler ( int  irq,
void *  dev_id 
)
static
static void handlePendingCallbacks ( struct GPIO_MM_timer *  timer)
static
static int init_event ( struct GPIO_MM *  brd)
static
static int init_fcntrs ( struct GPIO_MM *  brd)
static
static struct GPIO_MM_timer* init_gpio_timer ( struct GPIO_MM *  brd)
static
MODULE_AUTHOR ( "Gordon Maclean <maclean@ucar.edu>"  )
MODULE_DESCRIPTION ( "Driver for Diamond GPIO card"  )
module_exit ( gpio_mm_cleanup  )
module_init ( gpio_mm_init  )
MODULE_LICENSE ( "Dual BSD/GPL"  )
module_param ( clockHZ  ,
int  ,
 
)
module_param_array ( ioports_dio  ,
uint  ,
numboards_dio  ,
 
)
module_param_array ( ioports  ,
uint  ,
numboards  ,
 
)
module_param_array ( irqa  ,
int  ,
numirqa  ,
 
)
module_param_array ( irqb  ,
int  ,
numirqb  ,
 
)
MODULE_VERSION ( REPO_REVISION  )
struct gpio_timer_callback* register_gpio_timer_callback ( gpio_timer_callback_func_t  callback,
unsigned int  usecs,
void *  privateData,
int *  errp 
)
static struct gpio_timer_callback* register_gpio_timer_callback_priv ( struct GPIO_MM_timer *  timer,
gpio_timer_callback_func_t  callback,
unsigned int  usecs,
void *  privateData,
int *  errp 
)
static
static void set_ticks ( struct GPIO_MM_timer *  timer,
unsigned int  usecs,
unsigned int  maxUsecs,
unsigned short *  initial_ticsp 
)
static
static int start_event ( struct GPIO_MM_event *  event,
struct GPIO_MM_event_config cfg 
)
static
static int start_fcntr ( struct GPIO_MM_fcntr *  fcntr,
struct GPIO_MM_fcntr_config cfg 
)
static
static void start_gpio_timer ( struct GPIO_MM_timer *  timer,
unsigned int  usecs,
unsigned int  maxUsecs 
)
static
static int stop_event ( struct GPIO_MM_event *  event)
static
static int stop_fcntr ( struct GPIO_MM_fcntr *  fcntr)
static
static void stop_gpio_timer ( struct GPIO_MM_timer *  timer)
static
long unregister_gpio_timer_callback ( struct gpio_timer_callback *  cb,
int  wait 
)
static long unregister_gpio_timer_callback_priv ( struct GPIO_MM_timer *  timer,
struct gpio_timer_callback *  cb,
int  wait 
)
static

Variable Documentation

struct GPIO_MM* board = 0
static
int clockHZ = GPIO_MM_CT_CLOCK_HZ
static
const char* driver_name = "gpio_mm"
static
struct file_operations event_fops
static
Initial value:
= {
.owner = THIS_MODULE,
.unlocked_ioctl = gpio_mm_ioctl_event,
.llseek = no_llseek,
}
static int gpio_mm_release_event(struct inode *inode, struct file *filp)
Definition: gpio_mm.c:1662
static int gpio_mm_open_event(struct inode *inode, struct file *filp)
Definition: gpio_mm.c:1632
unsigned int gpio_mm_poll_event(struct file *filp, poll_table *wait)
Definition: gpio_mm.c:1746
static ssize_t gpio_mm_read_event(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
Definition: gpio_mm.c:1685
static long gpio_mm_ioctl_event(struct file *filp, unsigned int cmd, unsigned long arg)
Definition: gpio_mm.c:1696
struct file_operations fcntr_fops
static
Initial value:
= {
.owner = THIS_MODULE,
.unlocked_ioctl = gpio_mm_ioctl_fcntr,
.llseek = no_llseek,
}
static long gpio_mm_ioctl_fcntr(struct file *filp, unsigned int cmd, unsigned long arg)
Definition: gpio_mm.c:1462
static int gpio_mm_open_fcntr(struct inode *inode, struct file *filp)
Definition: gpio_mm.c:1395
static int gpio_mm_release_fcntr(struct inode *inode, struct file *filp)
Definition: gpio_mm.c:1426
static ssize_t gpio_mm_read_fcntr(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
Definition: gpio_mm.c:1451
unsigned int gpio_mm_poll_fcntr(struct file *filp, poll_table *wait)
Definition: gpio_mm.c:1512
struct class* gpio_mm_class
static
dev_t gpio_mm_device = MKDEV(0,0)
static
unsigned int ioports[MAX_GPIO_MM_BOARDS] ={ 0x080, 0, 0, 0 , 0}
static

Referenced by gpio_mm_init().

unsigned int ioports_dio[MAX_GPIO_MM_BOARDS] = { 0x040, 0, 0, 0, 0 }
static

Referenced by gpio_mm_init().

int irqa[MAX_GPIO_MM_BOARDS] = { 3, 0, 0, 0, 0 }
static

Referenced by gpio_mm_init().

int irqb[MAX_GPIO_MM_BOARDS] = { 0, 0, 0, 0, 0 }
static

Referenced by gpio_mm_init().

int numboards = 0
static
int numboards_alloc = 0
static

Referenced by gpio_mm_cleanup(), and gpio_mm_init().

int numboards_dio = 0
static

Referenced by gpio_mm_init().

int numirqa = 0
static
int numirqb = 0
static