Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * Special Initializers for certain USB Mass Storage devices
0004  *
0005  * Current development and maintenance by:
0006  *   (c) 1999, 2000 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
0007  *
0008  * This driver is based on the 'USB Mass Storage Class' document. This
0009  * describes in detail the protocol used to communicate with such
0010  * devices.  Clearly, the designers had SCSI and ATAPI commands in
0011  * mind when they created this document.  The commands are all very
0012  * similar to commands in the SCSI-II and ATAPI specifications.
0013  *
0014  * It is important to note that in a number of cases this class
0015  * exhibits class-specific exemptions from the USB specification.
0016  * Notably the usage of NAK, STALL and ACK differs from the norm, in
0017  * that they are used to communicate wait, failed and OK on commands.
0018  *
0019  * Also, for certain devices, the interrupt endpoint is used to convey
0020  * status of a command.
0021  */
0022 
0023 #include <linux/errno.h>
0024 
0025 #include "usb.h"
0026 #include "initializers.h"
0027 #include "debug.h"
0028 #include "transport.h"
0029 
0030 /*
0031  * This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target
0032  * mode
0033  */
0034 int usb_stor_euscsi_init(struct us_data *us)
0035 {
0036     int result;
0037 
0038     usb_stor_dbg(us, "Attempting to init eUSCSI bridge...\n");
0039     result = usb_stor_control_msg(us, us->send_ctrl_pipe,
0040             0x0C, USB_RECIP_INTERFACE | USB_TYPE_VENDOR,
0041             0x01, 0x0, NULL, 0x0, 5 * HZ);
0042     usb_stor_dbg(us, "-- result is %d\n", result);
0043 
0044     return 0;
0045 }
0046 
0047 /*
0048  * This function is required to activate all four slots on the UCR-61S2B
0049  * flash reader
0050  */
0051 int usb_stor_ucr61s2b_init(struct us_data *us)
0052 {
0053     struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap*) us->iobuf;
0054     struct bulk_cs_wrap *bcs = (struct bulk_cs_wrap*) us->iobuf;
0055     int res;
0056     unsigned int partial;
0057     static char init_string[] = "\xec\x0a\x06\x00$PCCHIPS";
0058 
0059     usb_stor_dbg(us, "Sending UCR-61S2B initialization packet...\n");
0060 
0061     bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
0062     bcb->Tag = 0;
0063     bcb->DataTransferLength = cpu_to_le32(0);
0064     bcb->Flags = bcb->Lun = 0;
0065     bcb->Length = sizeof(init_string) - 1;
0066     memset(bcb->CDB, 0, sizeof(bcb->CDB));
0067     memcpy(bcb->CDB, init_string, sizeof(init_string) - 1);
0068 
0069     res = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, bcb,
0070             US_BULK_CB_WRAP_LEN, &partial);
0071     if (res)
0072         return -EIO;
0073 
0074     usb_stor_dbg(us, "Getting status packet...\n");
0075     res = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, bcs,
0076             US_BULK_CS_WRAP_LEN, &partial);
0077     if (res)
0078         return -EIO;
0079 
0080     return 0;
0081 }
0082 
0083 /* This places the HUAWEI E220 devices in multi-port mode */
0084 int usb_stor_huawei_e220_init(struct us_data *us)
0085 {
0086     int result;
0087 
0088     result = usb_stor_control_msg(us, us->send_ctrl_pipe,
0089                       USB_REQ_SET_FEATURE,
0090                       USB_TYPE_STANDARD | USB_RECIP_DEVICE,
0091                       0x01, 0x0, NULL, 0x0, 1 * HZ);
0092     usb_stor_dbg(us, "Huawei mode set result is %d\n", result);
0093     return 0;
0094 }