Ver Fonte

Add UTP functionality.

Vybrid now understands UTP protocol. Can send U-Boot messages from
host to device using Manufacturing Tool. Right now the only UTP
command that is supported is sending a native U-Boot command to be
run on the device.

Signed-off-by: Trace Russell <b45800@freescale.com>
Trace Russell há 12 anos atrás
pai
commit
1903a5b145

+ 0 - 1
drivers/usb/gadget/arcotg_udc.c

@@ -1455,7 +1455,6 @@ static int fsl_pullup(struct usb_gadget *gadget, int is_on)
 {
 	struct fsl_udc *udc;
 
-	printf("FSL pullup\n");
 	udc = container_of(gadget, struct fsl_udc, gadget);
 	udc->softconnect = (is_on != 0);
 	if (can_pullup(udc))

+ 13 - 2
drivers/usb/gadget/f_mass_storage.c

@@ -1132,6 +1132,8 @@ static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh)
 
 	memset(buf, 0, 8);
 	buf[0] = TYPE_DISK;
+	if (curlun->removable)
+		buf[1] = 0x80;
 	buf[2] = 2;		/* ANSI SCSI level 2 */
 	buf[3] = 2;		/* SCSI-2 INQUIRY data format */
 	buf[4] = 31;		/* Additional length */
@@ -1186,8 +1188,10 @@ static int do_request_sense(struct fsg_common *common, struct fsg_buffhd *bh)
 		valid = 0;
 	} else {
 		sd = curlun->sense_data;
+		sdinfo = curlun->sense_data_info;
 		valid = curlun->info_valid << 7;
 		curlun->sense_data = SS_NO_SENSE;
+		curlun->sense_data_info = 0;
 		curlun->info_valid = 0;
 	}
 
@@ -1812,6 +1816,13 @@ static int check_command(struct fsg_common *common, int cmnd_size,
 		}
 	}
 
+	/* If the medium isn't mounted and the command needs to access
+	 * it, return an error. */
+	if (curlun && !curlun->lun_open && needs_medium) {
+		curlun->sense_data = SS_MEDIUM_NOT_PRESENT;
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
@@ -2532,11 +2543,11 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
 
 	for (i = 0; i < nluns; i++) {
 		common->luns[i].removable = 1;
-//#ifndef CONFIG_FSL_UTP
+#ifndef CONFIG_FSL_UTP
 		rc = fsg_lun_open(&common->luns[i], "");
 		if (rc)
 			goto error_luns;
-//#endif
+#endif
 	}
 	common->lun = 0;
 

+ 0 - 3
drivers/usb/gadget/fsl_updater.c

@@ -33,7 +33,6 @@ static u64 get_be64(u8 *buf)
 
 static int utp_init(struct fsg_dev *fsg)
 {
-	printf("top of utp_init\n");
 	/* the max message is 64KB */
 	utp_context.buffer = vmalloc(0x10000);
 	if (!utp_context.buffer) {
@@ -73,7 +72,6 @@ static void utp_user_data_free(struct utp_user_data *uud)
 /* Will be called when the host wants to get the sense data */
 static int utp_get_sense(struct fsg_common *common)
 {
-	printf("top of utp_get_sense\n");
 	struct fsg_dev *fsg;
 
 	fsg = common->fsg;
@@ -385,7 +383,6 @@ static int utp_handle_message(struct fsg_common *common,
 	unsigned long long param;
 	unsigned long tag;
 
-	printf("m->f0: %x\n", m->f0);
 	if (m->f0 != 0xF0)
 		return default_reply;
 

+ 3 - 0
drivers/usb/gadget/g_dnl.c

@@ -64,6 +64,9 @@ static struct usb_device_descriptor device_desc = {
 	.idProduct = __constant_cpu_to_le16(CONFIG_G_DNL_PRODUCT_NUM),
 	.iProduct = STRING_PRODUCT,
 	.bNumConfigurations = 1,
+#ifdef CONFIG_FSL_UTP
+	.iSerialNumber = 0,
+#endif
 };
 
 /* static strings, in UTF-8 */

+ 2 - 0
drivers/usb/gadget/storage_common.c

@@ -303,6 +303,7 @@ struct fsg_lun {
 	unsigned int	registered:1;
 	unsigned int	info_valid:1;
 	unsigned int	nofua:1;
+	unsigned int	lun_open:1;
 
 	u32		sense_data;
 	u32		sense_data_info;
@@ -610,6 +611,7 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename)
 	curlun->ro = ro;
 	curlun->file_length = size;
 	curlun->num_sectors = num_sectors;
+	curlun->lun_open = 1;
 	debug("open backing file: %s\n", filename);
 	rc = 0;