nidas v1.2.3
viper_dio.h
Go to the documentation of this file.
1/* -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8; -*- */
2/* vim: set shiftwidth=8 softtabstop=8 expandtab: */
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2007, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26/*
27
28 Driver for Viper digital IO ports. There are 8 independent inputs, IN0-7,
29 and 8 independent outputs OUT0-7. The value of the inputs can be read,
30 and the value of the outputs written or read.
31
32 Original Author: Gordon Maclean
33
34*/
35
36#ifndef NIDAS_ARCOM_VIPER_DIO_H
37#define NIDAS_ARCOM_VIPER_DIO_H
38
39#ifndef __KERNEL__
40
41/* User programs need this for the _IO macros, but kernel
42 * modules get their's elsewhere.
43 */
44#include <sys/ioctl.h>
45#include <sys/types.h>
46
47#endif
48
49#define VIPER_DIO_IOC_MAGIC 'v'
50
54#define VIPER_DIO_GET_NOUT _IO(VIPER_DIO_IOC_MAGIC,0)
55
57#define VIPER_DIO_GET_NIN _IO(VIPER_DIO_IOC_MAGIC,1)
58
60#define VIPER_DIO_CLEAR \
61 _IOW(VIPER_DIO_IOC_MAGIC,2,unsigned char)
62
64#define VIPER_DIO_SET \
65 _IOW(VIPER_DIO_IOC_MAGIC,3,unsigned char)
66
69#define VIPER_DIO_SET_TO_VAL \
70 _IOW(VIPER_DIO_IOC_MAGIC,4,unsigned char[2])
71
73#define VIPER_DIO_GET_DOUT \
74 _IOR(VIPER_DIO_IOC_MAGIC,5,unsigned char)
75
77#define VIPER_DIO_GET_DIN \
78 _IOR(VIPER_DIO_IOC_MAGIC,6,unsigned char)
79
80#define VIPER_DIO_IOC_MAXNR 6
81
82#define VIPER_DIO_NOUT 8
83
84#define VIPER_DIO_NIN 8
85
86#ifdef __KERNEL__
87/******** Start of definitions used by the driver module only **********/
88
89#include <linux/version.h>
90#include <linux/fs.h>
91#include <linux/types.h>
92#include <linux/device.h>
93#include <linux/cdev.h>
94
95#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
96#include <mach/viper.h>
97#else
98#include <asm/arch/viper.h>
99#endif
100
101/*
102 Definitions missing from viper.h for GPIO read register.
103 Physical address of 16 bit GPIO read register */
104#define _VIPER_GPIO_PHYS (VIPER_CPLD_PHYS + 0x500000)
105/* Virtual address of 16 bit GPIO read register */
106#define VIPER_GPIO __VIPER_CPLD_REG(_VIPER_GPIO_PHYS)
107
111struct VIPER_DIO {
112
113 char deviceName[64];
114
115 struct cdev cdev;
116
117#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
118 struct mutex reg_mutex; // enforce atomic access to dio regs
119#else
120 struct semaphore reg_mutex; // enforce atomic access to dio regs
121#endif
122
123 struct class* vclass;
124
125 struct device* device;
126};
127
128#endif
129
130#endif
static string device
Definition sing.cc:60