1 /* Copyright (c) 2019-2025 Allwinner Technology Co., Ltd. ALL rights reserved.
2 
3  * Allwinner is a trademark of Allwinner Technology Co.,Ltd., registered in
4  * the the People's Republic of China and other countries.
5  * All Allwinner Technology Co.,Ltd. trademarks are used with permission.
6 
7  * DISCLAIMER
8  * THIRD PARTY LICENCES MAY BE REQUIRED TO IMPLEMENT THE SOLUTION/PRODUCT.
9  * IF YOU NEED TO INTEGRATE THIRD PART'S TECHNOLOGY (SONY, DTS, DOLBY, AVS OR MPEGLA, ETC.)
10  * IN ALLWINNER'SDK OR PRODUCTS, YOU SHALL BE SOLELY RESPONSIBLE TO OBTAIN
11  * ALL APPROPRIATELY REQUIRED THIRD PARTY LICENCES.
12  * ALLWINNER SHALL HAVE NO WARRANTY, INDEMNITY OR OTHER OBLIGATIONS WITH RESPECT TO MATTERS
13  * COVERED UNDER ANY REQUIRED THIRD PARTY LICENSE.
14  * YOU ARE SOLELY RESPONSIBLE FOR YOUR USAGE OF THIRD PART'S TECHNOLOGY.
15 
16 
17  * THIS SOFTWARE IS PROVIDED BY ALLWINNER"AS IS" AND TO THE MAXIMUM EXTENT
18  * PERMITTED BY LAW, ALLWINNER EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND,
19  * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION REGARDING
20  * THE TITLE, NON-INFRINGEMENT, ACCURACY, CONDITION, COMPLETENESS, PERFORMANCE
21  * OR MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22  * IN NO EVENT SHALL ALLWINNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS, OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef __USB_STORAGE_H__
33 #define __USB_STORAGE_H__
34 
35 /*
36  * linux/usb/storage.h
37  *
38  * Copyright Matthew Wilcox for Intel Corp, 2010
39  *
40  * This file contains definitions taken from the
41  * USB Mass Storage Class Specification Overview
42  *
43  * Distributed under the terms of the GNU GPL, version two.
44  */
45 
46 /* Storage subclass codes */
47 
48 #define USB_SC_RBC  0x01        /* Typically, flash devices */
49 #define USB_SC_8020 0x02        /* CD-ROM */
50 #define USB_SC_QIC  0x03        /* QIC-157 Tapes */
51 #define USB_SC_UFI  0x04        /* Floppy */
52 #define USB_SC_8070 0x05        /* Removable media */
53 #define USB_SC_SCSI 0x06        /* Transparent */
54 #define USB_SC_LOCKABLE 0x07        /* Password-protected */
55 
56 #define USB_SC_ISD200   0xf0        /* ISD200 ATA */
57 #define USB_SC_CYP_ATACB    0xf1    /* Cypress ATACB */
58 #define USB_SC_DEVICE   0xff        /* Use device's value */
59 
60 /* Storage protocol codes */
61 
62 #define USB_PR_CBI  0x00        /* Control/Bulk/Interrupt */
63 #define USB_PR_CB   0x01        /* Control/Bulk w/o interrupt */
64 #define USB_PR_BULK 0x50        /* bulk only */
65 #define USB_PR_UAS  0x62        /* USB Attached SCSI */
66 
67 #define USB_PR_USBAT    0x80        /* SCM-ATAPI bridge */
68 #define USB_PR_EUSB_SDDR09  0x81    /* SCM-SCSI bridge for SDDR-09 */
69 #define USB_PR_SDDR55   0x82        /* SDDR-55 (made up) */
70 #define USB_PR_DPCM_USB 0xf0        /* Combination CB/SDDR09 */
71 #define USB_PR_FREECOM  0xf1        /* Freecom */
72 #define USB_PR_DATAFAB  0xf2        /* Datafab chipsets */
73 #define USB_PR_JUMPSHOT 0xf3        /* Lexar Jumpshot */
74 #define USB_PR_ALAUDA   0xf4        /* Alauda chipsets */
75 #define USB_PR_KARMA    0xf5        /* Rio Karma */
76 
77 #define USB_PR_DEVICE   0xff        /* Use device's value */
78 
79 /*
80  * Bulk only data structures
81  */
82 
83 /* command block wrapper */
84 struct bulk_cb_wrap {
85     uint32_t    Signature;      /* contains 'USBC' */
86     uint32_t    Tag;            /* unique per command id */
87     uint32_t    DataTransferLength; /* size of data */
88     uint8_t     Flags;          /* direction in bit 0 */
89     uint8_t     Lun;            /* LUN normally 0 */
90     uint8_t     Length;         /* length of the CDB */
91     uint8_t     CDB[16];        /* max command */
92 };
93 
94 #define US_BULK_CB_WRAP_LEN 31
95 #define US_BULK_CB_SIGN     0x43425355  /* spells out 'USBC' */
96 #define US_BULK_FLAG_IN     (1 << 7)
97 #define US_BULK_FLAG_OUT    0
98 
99 /* command status wrapper */
100 struct bulk_cs_wrap {
101     uint32_t    Signature;  /* contains 'USBS' */
102     uint32_t    Tag;        /* same as original command */
103     uint32_t    Residue;    /* amount not transferred */
104     uint8_t     Status;     /* see below */
105 };
106 
107 #define US_BULK_CS_WRAP_LEN 13
108 #define US_BULK_CS_SIGN     0x53425355      /* spells out 'USBS' */
109 #define US_BULK_STAT_OK     0
110 #define US_BULK_STAT_FAIL   1
111 #define US_BULK_STAT_PHASE  2
112 
113 /* bulk-only class specific requests */
114 #define US_BULK_RESET_REQUEST   0xff
115 #define US_BULK_GET_MAX_LUN     0xfe
116 
117 #endif /* __USB_STORAGE_H__ */
118