Merge branch 'for-linus' of git://git.kernel.dk/linux-block
[pandora-kernel.git] / drivers / staging / keucr / transport.h
1 #ifndef _TRANSPORT_H_
2 #define _TRANSPORT_H_
3
4 #include <linux/blkdev.h>
5
6 /* Bulk only data structures */
7
8 /* command block wrapper */
9 struct bulk_cb_wrap {
10         __le32  Signature;                      /* contains 'USBC' */
11         __u32   Tag;                            /* unique per command id */
12         __le32  DataTransferLength;     /* size of data */
13         __u8    Flags;                          /* direction in bit 0 */
14         __u8    Lun;                                    /* LUN normally 0 */
15         __u8    Length;                         /* of of the CDB */
16         __u8    CDB[16];                                /* max command */
17 };
18
19 #define US_BULK_CB_WRAP_LEN     31
20 #define US_BULK_CB_SIGN         0x43425355      /*spells out USBC */
21 #define US_BULK_FLAG_IN         1
22 #define US_BULK_FLAG_OUT        0
23
24 /* command status wrapper */
25 struct bulk_cs_wrap {
26         __le32  Signature;              /* should = 'USBS' */
27         __u32           Tag;                    /* same as original command */
28         __le32  Residue;                /* amount not transferred */
29         __u8            Status;         /* see below */
30         __u8            Filler[18];
31 };
32
33 #define US_BULK_CS_WRAP_LEN     13
34 #define US_BULK_CS_SIGN         0x53425355      /* spells out 'USBS' */
35 #define US_BULK_STAT_OK         0
36 #define US_BULK_STAT_FAIL       1
37 #define US_BULK_STAT_PHASE      2
38
39 /* bulk-only class specific requests */
40 #define US_BULK_RESET_REQUEST   0xff
41 #define US_BULK_GET_MAX_LUN     0xfe
42
43 /* usb_stor_bulk_transfer_xxx() return codes, in order of severity */
44 #define USB_STOR_XFER_GOOD      0       /* good transfer                 */
45 #define USB_STOR_XFER_SHORT     1       /* transferred less than expected */
46 #define USB_STOR_XFER_STALLED   2       /* endpoint stalled              */
47 #define USB_STOR_XFER_LONG      3       /* device tried to send too much */
48 #define USB_STOR_XFER_ERROR     4       /* transfer died in the middle   */
49
50 /* Transport return codes */
51 #define USB_STOR_TRANSPORT_GOOD 0       /* Transport good, command good */
52 #define USB_STOR_TRANSPORT_FAILED 1     /* Transport good, command failed */
53 #define USB_STOR_TRANSPORT_NO_SENSE 2   /* Command failed, no auto-sense */
54 #define USB_STOR_TRANSPORT_ERROR 3      /* Transport bad (i.e. device dead) */
55
56 /*
57  * We used to have USB_STOR_XFER_ABORTED and USB_STOR_TRANSPORT_ABORTED
58  * return codes.  But now the transport and low-level transfer routines
59  * treat an abort as just another error (-ENOENT for a cancelled URB).
60  * It is up to the invoke_transport() function to test for aborts and
61  * distinguish them from genuine communication errors.
62  */
63
64 /* CBI accept device specific command */
65 #define US_CBI_ADSC             0
66 extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data*);
67 extern int usb_stor_Bulk_max_lun(struct us_data *);
68 extern int usb_stor_Bulk_reset(struct us_data *);
69 extern void usb_stor_print_cmd(struct scsi_cmnd *);
70 extern void usb_stor_invoke_transport(struct scsi_cmnd *, struct us_data*);
71 extern void usb_stor_stop_transport(struct us_data *);
72 extern int usb_stor_control_msg(struct us_data *us, unsigned int pipe,
73                 u8 request, u8 requesttype, u16 value, u16 index,
74                 void *data, u16 size, int timeout);
75 extern int usb_stor_clear_halt(struct us_data *us, unsigned int pipe);
76 extern int usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
77                 void *buf, unsigned int length, unsigned int *act_len);
78 extern int usb_stor_bulk_transfer_sg(struct us_data *us, unsigned int pipe,
79                 void *buf, unsigned int length, int use_sg, int *residual);
80 extern int usb_stor_bulk_srb(struct us_data *us, unsigned int pipe,
81                 struct scsi_cmnd *srb);
82 extern int usb_stor_port_reset(struct us_data *us);
83
84 /* Protocol handling routines */
85 enum xfer_buf_dir       {TO_XFER_BUF, FROM_XFER_BUF};
86 extern unsigned int usb_stor_access_xfer_buf(struct us_data*,
87         unsigned char *buffer, unsigned int buflen, struct scsi_cmnd *srb,
88         struct scatterlist **, unsigned int *offset, enum xfer_buf_dir dir);
89 extern void usb_stor_set_xfer_buf(struct us_data*, unsigned char *buffer,
90         unsigned int buflen, struct scsi_cmnd *srb,
91         unsigned int dir);
92
93 /*
94  * ENE scsi function
95  */
96 extern void ENE_stor_invoke_transport(struct scsi_cmnd *, struct us_data *);
97 extern int ENE_InitMedia(struct us_data *);
98 extern int ENE_SMInit(struct us_data *);
99 extern int ENE_SendScsiCmd(struct us_data*, BYTE, void*, int);
100 extern int ENE_LoadBinCode(struct us_data*, BYTE);
101 extern int ENE_Read_BYTE(struct us_data*, WORD index, void *buf);
102 extern int ENE_Read_Data(struct us_data*, void *buf, unsigned int length);
103 extern int ENE_Write_Data(struct us_data*, void *buf, unsigned int length);
104 extern void BuildSenseBuffer(struct scsi_cmnd *, int);
105
106 /*
107  * ENE scsi function
108  */
109 extern int SM_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb);
110
111 #endif