inka_digio(4)

NAME
inak_digioi - device driver for digital I/O devices of INKA4x0 board

SYNOPSIS
#include <linux/inka_digio.h>

DESCRIPTION
The driver consists of three distinct parts each controlling its own I/O devices. The parts are as follows:

Digital Inputs
There are 20 inputs:
- 4 x Display Type
- 4 x Version
- 2 x Touch Screen Type
- 2 x Keyboard Type
- Printer present
- Battery Low
- Drawer Switch 1
- Drawer Switch 2
- Compact Flash CD1
- Compact Flash CD1
- Memory Extension 1
- Memory Extension 2
Two interfaces are provided:
(a) Character device interface using /dev/digital_in name. For each read() system call the /dev/digital_in device returns 4 bytes of data with the current status of the above inputs. Bits encoding is described in inka_digio.h:
#define DIGIN_DISPLAY_TYPE_MASK 0x0000000f /* Inputs 0-3 */
#define DIGIN_VERSION_MASK 0x00000f00 /* Inputs 8-11 */
#define DIGIN_TOUCHSCR_MASK 0x00003000 /* Inputs 12-13 */
#define DIGIN_KEYB_MASK 0x00030000 /* Inputs 16-17 */
#define DIGIN_PRINTER 0x00100000 /* Input 20 */
#define DIGIN_BATTERY_LOW 0x00200000 /* Input 21 */
#define DIGIN_DRAWER_SW1 0x00400000 /* Input 22 */
#define DIGIN_DRAWER_SW2 0x00800000 /* Input 23 */
#define DIGIN_CFLASH_CD1 0x04000000 /* Input 26 */
#define DIGIN_CFLASH_CD2 0x08000000 /* Input 27 */
#define DIGIN_EXT_MEM1 0x10000000 /* Input 28 */
#define DIGIN_EXT_MEM2 0x20000000 /* Input 29 */
select() or poll() system calls issued on /dev/digital_in return immediately indicating availability of data.
(b) /proc filesystem interface using /proc/driver/digital_in.
Reading from /proc/driver/digital_in returns output as follows:
Display type: 0xf
Version: 0x1
Touchscreen type: 0x2
Keyboard type: 0x3i
Printer: 1
Battery low: 0
Drawer switch 1: 1
Drawer switch 2: 1
CompactFlash slave CD1: 0
CompactFlash slave CD2: 0
Memory ext 1: 1
Memory ext 2: 1

Digital outputs
There are 11 output GPIO pins:
- 6 x front panel LEDs
- Cash Drawer 1
- Cash Drawer 2
- LCD remote inverter on/off
- LCD Up/Down positioning
- LCD Left/Right positioning
Two interfaces are provided:
(a) Character device interface using /dev/digital_out. Each write() system call to the /dev/digital_out device uses only the first 4 bytes of data and read() system call returns 4 bytes of data with the current status of the digital outputs. Bits encoding is described in inka_digio.h:
#define DIGIO_LED0 0x00000001 /* Output 0 */
#define DIGIO_LED1 0x00000002 /* Output 1 */
#define DIGIO_LED2 0x00000004 /* Output 2 */
#define DIGIO_LED3 0x00000008 /* Output 3 */
#define DIGIO_LED4 0x00000010 /* Output 4 */
#define DIGIO_LED5 0x00000020 /* Output 5 */
#define DIGIO_LEDS_MASK (DIGIO_LED0|DIGIO_LED1|DIGIO_LED2| \
DIGIO_LED3|DIGIO_LED4|DIGIO_LED5)
/* Output 6 (speaker) is handled by another driver.
*/
#define DIGIO_DRAWER1 0x00000100 /* Output 8 */
#define DIGIO_DRAWER2 0x00000200 /* Output 9 */
#define DIGIO_DRAWER_MASK (DIGIO_DRAWER1|DIGIO_DRAWER2)
#define DIGIO_INV 0x00000400 /* Output 10 */
#define DIGIO_LCD_UD 0x00001000 /* Output 12 */
#define DIGIO_LCD_LR 0x00002000 /* Output 13 */
(b) /proc filesystem interface using respective names in /proc/driver/digital_out/ directory.
Specifically:
/proc/driver/digital_out/leds
Writing a line of text to this name sets or resets the LED bits. The line must have the form N N N N N N\n, with N being 0 or 1 , other data format is rejected by the driver (discarded). Reading returns the current LEDs status in the same format.
/proc/driver/digital_out/drawer
Controls the Cash Drawer 1 and 2. Returned/accepted data format is
M N\n,
where M corresponds the Cash Drawer1, N - Cash Drawer 2. M and N can be 0 or 1.

/proc/driver/digital_out/inv
Controls the LCD remote inverter. Returned/accepted data format is
N\n.
N can be 0 or 1.
/proc/driver/digital_out/dir
Controls the LCD image positioning. Returned/accepted data format is
M N\n,
where M corresponds the Up/Down, N - Left/Right. M and N can be 0 or 1.

LCD Inverter Dimmer control
Driver controls the LCD inverter dimming using GPIO output pin configured using a Pulse-Width Modulation Timer.
Two interfaces are provided:
(a) Character device interface using /dev/dimm. Each read() and write() system call to the /dev/dimm device uses or returns only the first 4 bytes of data. Data is a dimming value ranging from 0 to 255.
(b) /proc filesystem interface using /proc/driver/digital_out/dimm. Writing a line of text to this name sets the new dimming value. The line must have the form N\n, with N ranging from 0 to 255.
Reading returns the current dimming value in the same format.
The device nodes have the major number of 248 and minor numbers are constructed as follows:
          Name Minor number
          --------------- ------------ /dev/digital_in 0
/dev/digital_out 1
/dev/dimm 2

FUNCTIONS
In general, the inka_digio drivers functions behave as used with other drivers. A function return value of (-1) indicates an error, in which case an appropriate error code can be found in errno.
The inka_digio driver supports the following driver calls:
open()
The minor number of the device node indicates the I/O device (see above).
Error codes:
ENXIO - no I/O device correspond to this minor number.
close()
Error codes: none
read()
Error codes:
ENOMEM - size of the provided buffer is less than 4 bytes.
EINTR - the call was interrupted by a signal.
write()
The write() function is only implemented for the /dev/digital_out and /dev/dimm devices. For /dev/digital_in it always returns (-1) with errno set to ENOSYS.
Error codes:
EINVAL - the size argument is less than 4.
ioctl()
The ioctl() is not supported by the inka_digio driver. On any attempt to issue a non-standard (not one of FIOCLEX, FIONCLEX or FIONBIO) IOCTL command, (-1) will be returned with errno set to ENOTTY.
poll()
The poll() function implemented only for application compatability. Driver does not block and returns the POLLIN|POLLRDNORM event immediately.