aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/cpc-usb/cpcusb.h
blob: 6bdf30be239f205cbadfef3152b12172fb2ffb38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* Header for CPC-USB Driver ********************
 * Copyright 1999, 2000, 2001
 *
 * Company:  EMS Dr. Thomas Wuensche
 *           Sonnenhang 3
 *           85304 Ilmmuenster
 *           Phone: +49-8441-490260
 *           Fax:   +49-8441-81860
 *           email: support@ems-wuensche.com
 *           WWW:   www.ems-wuensche.com
 */

#ifndef CPCUSB_H
#define CPCUSB_H

#undef err
#undef dbg
#undef info

/* Use our own dbg macro */
#define dbg(format, arg...) do { if (debug) printk(KERN_INFO "CPC-USB: " format "\n" , ## arg); } while (0)
#define info(format, arg...) do { printk(KERN_INFO "CPC-USB: " format "\n" , ## arg); } while (0)
#define err(format, arg...) do { printk(KERN_INFO "CPC-USB(ERROR): " format "\n" , ## arg); } while (0)

#define CPC_USB_CARD_CNT      4

typedef struct CPC_USB_READ_URB {
	unsigned char *buffer;	/* the buffer to send data */
	size_t size;		/* the size of the send buffer */
	struct urb *urb;	/* the urb used to send data */
} CPC_USB_READ_URB_T;

typedef struct CPC_USB_WRITE_URB {
	unsigned char *buffer;	/* the buffer to send data */
	size_t size;		/* the size of the send buffer */
	struct urb *urb;	/* the urb used to send data */
	atomic_t busy;		/* true if write urb is busy */
	struct completion finished;	/* wait for the write to finish */
} CPC_USB_WRITE_URB_T;

#define CPC_USB_URB_CNT  10

typedef struct CPC_USB {
	struct usb_device *udev;	/* save off the usb device pointer */
	struct usb_interface *interface;	/* the interface for this device */
	unsigned char minor;	/* the starting minor number for this device */
	unsigned char num_ports;	/* the number of ports this device has */
	int num_intr_in;	/* number of interrupt in endpoints we have */
	int num_bulk_in;	/* number of bulk in endpoints we have */
	int num_bulk_out;	/* number of bulk out endpoints we have */

	CPC_USB_READ_URB_T urbs[CPC_USB_URB_CNT];

	unsigned char intr_in_buffer[4];	/* interrupt transfer buffer */
	struct urb *intr_in_urb;	/* interrupt transfer urb */

	CPC_USB_WRITE_URB_T wrUrbs[CPC_USB_URB_CNT];

	int open;		/* if the port is open or not */
	int present;		/* if the device is not disconnected */
	struct semaphore sem;	/* locks this structure */

	int free_slots;		/* free send slots of CPC-USB */
	int idx;

	spinlock_t slock;

	char serialNumber[128];	/* serial number */
	int productId;		/* product id to differ between M16C and LPC2119 */
	CPC_CHAN_T *chan;
} CPC_USB_T;

#define CPCTable               CPCUSB_Table

#define CPC_DRIVER_VERSION "0.724"
#define CPC_DRIVER_SERIAL  "not applicable"

#define OBUF_SIZE 255		/* 4096 */

/* read timeouts -- RD_NAK_TIMEOUT * RD_EXPIRE = Number of seconds */
#define RD_NAK_TIMEOUT (10*HZ)	/* Default number of X seconds to wait */
#define RD_EXPIRE 12		/* Number of attempts to wait X seconds */

#define CPC_USB_BASE_MNR 0	/* CPC-USB start at minor 0  */

#endif