Commit 16468d7b authored by popcornmix's avatar popcornmix
Browse files

Add dwc_otg driver



Signed-off-by: default avatarpopcornmix <popcornmix@gmail.com>
parent 94d94c7e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ obj-$(CONFIG_USB_U132_HCD) += host/
obj-$(CONFIG_USB_R8A66597_HCD)	+= host/
obj-$(CONFIG_USB_HWA_HCD)	+= host/
obj-$(CONFIG_USB_ISP1760_HCD)	+= host/
obj-$(CONFIG_USB_DWCOTG)	+= host/
obj-$(CONFIG_USB_IMX21_HCD)	+= host/
obj-$(CONFIG_USB_FSL_MPH_DR_OF)	+= host/
obj-$(CONFIG_USB_FUSBH200_HCD)	+= host/
+1 −0
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ int usb_choose_configuration(struct usb_device *udev)
		dev_warn(&udev->dev,
			"no configuration chosen from %d choice%s\n",
			num_configs, plural(num_configs));
		dev_warn(&udev->dev, "No support over %dmA\n", udev->bus_mA);
	}
	return i;
}
+79 −0
Original line number Diff line number Diff line
@@ -1888,6 +1888,85 @@ free_interfaces:
	if (cp->string == NULL &&
			!(dev->quirks & USB_QUIRK_CONFIG_INTF_STRINGS))
		cp->string = usb_cache_string(dev, cp->desc.iConfiguration);
/* Uncomment this define to enable the HS Electrical Test support */
#define DWC_HS_ELECT_TST 1
#ifdef DWC_HS_ELECT_TST
		/* Here we implement the HS Electrical Test support. The
		 * tester uses a vendor ID of 0x1A0A to indicate we should
		 * run a special test sequence. The product ID tells us
		 * which sequence to run. We invoke the test sequence by
		 * sending a non-standard SetFeature command to our root
		 * hub port. Our dwc_otg_hcd_hub_control() routine will
		 * recognize the command and perform the desired test
		 * sequence.
		 */
		if (dev->descriptor.idVendor == 0x1A0A) {
			/* HSOTG Electrical Test */
			dev_warn(&dev->dev, "VID from HSOTG Electrical Test Fixture\n");

			if (dev->bus && dev->bus->root_hub) {
				struct usb_device *hdev = dev->bus->root_hub;
				dev_warn(&dev->dev, "Got PID 0x%x\n", dev->descriptor.idProduct);

				switch (dev->descriptor.idProduct) {
				case 0x0101:	/* TEST_SE0_NAK */
					dev_warn(&dev->dev, "TEST_SE0_NAK\n");
					usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
							USB_REQ_SET_FEATURE, USB_RT_PORT,
							USB_PORT_FEAT_TEST, 0x300, NULL, 0, HZ);
					break;

				case 0x0102:	/* TEST_J */
					dev_warn(&dev->dev, "TEST_J\n");
					usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
							USB_REQ_SET_FEATURE, USB_RT_PORT,
							USB_PORT_FEAT_TEST, 0x100, NULL, 0, HZ);
					break;

				case 0x0103:	/* TEST_K */
					dev_warn(&dev->dev, "TEST_K\n");
					usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
							USB_REQ_SET_FEATURE, USB_RT_PORT,
							USB_PORT_FEAT_TEST, 0x200, NULL, 0, HZ);
					break;

				case 0x0104:	/* TEST_PACKET */
					dev_warn(&dev->dev, "TEST_PACKET\n");
					usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
							USB_REQ_SET_FEATURE, USB_RT_PORT,
							USB_PORT_FEAT_TEST, 0x400, NULL, 0, HZ);
					break;

				case 0x0105:	/* TEST_FORCE_ENABLE */
					dev_warn(&dev->dev, "TEST_FORCE_ENABLE\n");
					usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
							USB_REQ_SET_FEATURE, USB_RT_PORT,
							USB_PORT_FEAT_TEST, 0x500, NULL, 0, HZ);
					break;

				case 0x0106:	/* HS_HOST_PORT_SUSPEND_RESUME */
					dev_warn(&dev->dev, "HS_HOST_PORT_SUSPEND_RESUME\n");
					usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
							USB_REQ_SET_FEATURE, USB_RT_PORT,
							USB_PORT_FEAT_TEST, 0x600, NULL, 0, 40 * HZ);
					break;

				case 0x0107:	/* SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup */
					dev_warn(&dev->dev, "SINGLE_STEP_GET_DEVICE_DESCRIPTOR setup\n");
					usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
							USB_REQ_SET_FEATURE, USB_RT_PORT,
							USB_PORT_FEAT_TEST, 0x700, NULL, 0, 40 * HZ);
					break;

				case 0x0108:	/* SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute */
					dev_warn(&dev->dev, "SINGLE_STEP_GET_DEVICE_DESCRIPTOR execute\n");
					usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0),
							USB_REQ_SET_FEATURE, USB_RT_PORT,
							USB_PORT_FEAT_TEST, 0x800, NULL, 0, 40 * HZ);
				}
			}
		}
#endif /* DWC_HS_ELECT_TST */

	/* Now that the interfaces are installed, re-enable LPM. */
	usb_unlocked_enable_lpm(dev);
+117 −43
Original line number Diff line number Diff line
@@ -19,33 +19,82 @@
static struct usb_device_id whitelist_table [] = {

/* hubs are optional in OTG, but very handy ... */
#define CERT_WITHOUT_HUBS
#if defined(CERT_WITHOUT_HUBS)
{ USB_DEVICE( 0x0000, 0x0000 ), }, /* Root HUB Only*/
#else
{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), },
{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 2), },
#endif

#ifdef	CONFIG_USB_PRINTER		/* ignoring nonstatic linkage! */
/* FIXME actually, printers are NOT supposed to use device classes;
 * they're supposed to use interface classes...
 */
{ USB_DEVICE_INFO(7, 1, 1) },
{ USB_DEVICE_INFO(7, 1, 2) },
{ USB_DEVICE_INFO(7, 1, 3) },
//{ USB_DEVICE_INFO(7, 1, 1) },
//{ USB_DEVICE_INFO(7, 1, 2) },
//{ USB_DEVICE_INFO(7, 1, 3) },
#endif

#ifdef	CONFIG_USB_NET_CDCETHER
/* Linux-USB CDC Ethernet gadget */
{ USB_DEVICE(0x0525, 0xa4a1), },
//{ USB_DEVICE(0x0525, 0xa4a1), },
/* Linux-USB CDC Ethernet + RNDIS gadget */
{ USB_DEVICE(0x0525, 0xa4a2), },
//{ USB_DEVICE(0x0525, 0xa4a2), },
#endif

#if	defined(CONFIG_USB_TEST) || defined(CONFIG_USB_TEST_MODULE)
/* gadget zero, for testing */
{ USB_DEVICE(0x0525, 0xa4a0), },
//{ USB_DEVICE(0x0525, 0xa4a0), },
#endif

/* OPT Tester */
{ USB_DEVICE( 0x1a0a, 0x0101 ), }, /* TEST_SE0_NAK */
{ USB_DEVICE( 0x1a0a, 0x0102 ), }, /* Test_J */
{ USB_DEVICE( 0x1a0a, 0x0103 ), }, /* Test_K */
{ USB_DEVICE( 0x1a0a, 0x0104 ), }, /* Test_PACKET */
{ USB_DEVICE( 0x1a0a, 0x0105 ), }, /* Test_FORCE_ENABLE */
{ USB_DEVICE( 0x1a0a, 0x0106 ), }, /* HS_PORT_SUSPEND_RESUME  */
{ USB_DEVICE( 0x1a0a, 0x0107 ), }, /* SINGLE_STEP_GET_DESCRIPTOR setup */
{ USB_DEVICE( 0x1a0a, 0x0108 ), }, /* SINGLE_STEP_GET_DESCRIPTOR execute */

/* Sony cameras */
{ USB_DEVICE_VER(0x054c,0x0010,0x0410, 0x0500), },

/* Memory Devices */
//{ USB_DEVICE( 0x0781, 0x5150 ), }, /* SanDisk */
//{ USB_DEVICE( 0x05DC, 0x0080 ), }, /* Lexar */
//{ USB_DEVICE( 0x4146, 0x9281 ), }, /* IOMEGA */
//{ USB_DEVICE( 0x067b, 0x2507 ), }, /* Hammer 20GB External HD  */
{ USB_DEVICE( 0x0EA0, 0x2168 ), }, /* Ours Technology Inc. (BUFFALO ClipDrive)*/
//{ USB_DEVICE( 0x0457, 0x0150 ), }, /* Silicon Integrated Systems Corp. */

/* HP Printers */
//{ USB_DEVICE( 0x03F0, 0x1102 ), }, /* HP Photosmart 245 */
//{ USB_DEVICE( 0x03F0, 0x1302 ), }, /* HP Photosmart 370 Series */

/* Speakers */
//{ USB_DEVICE( 0x0499, 0x3002 ), }, /* YAMAHA YST-MS35D USB Speakers */
//{ USB_DEVICE( 0x0672, 0x1041 ), }, /* Labtec USB Headset */

{ }	/* Terminating entry */
};

static inline void report_errors(struct usb_device *dev)
{
	/* OTG MESSAGE: report errors here, customize to match your product */
	dev_info(&dev->dev, "device Vendor:%04x Product:%04x is not supported\n",
		 le16_to_cpu(dev->descriptor.idVendor),
		 le16_to_cpu(dev->descriptor.idProduct));
        if (USB_CLASS_HUB == dev->descriptor.bDeviceClass){
                dev_printk(KERN_CRIT, &dev->dev, "Unsupported Hub Topology\n");
        } else {
                dev_printk(KERN_CRIT, &dev->dev, "Attached Device is not Supported\n");
        }
}


static int is_targeted(struct usb_device *dev)
{
	struct usb_device_id	*id = whitelist_table;
@@ -55,14 +104,37 @@ static int is_targeted(struct usb_device *dev)
		return 1;

	/* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
	if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
	     le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
	if (dev->descriptor.idVendor == 0x1a0a &&
            dev->descriptor.idProduct == 0xbadd) {
                return 0;
	} else if (!enable_whitelist) {
		return 1;
        } else {

#ifdef DEBUG
                dev_dbg(&dev->dev, "device V:%04x P:%04x DC:%04x SC:%04x PR:%04x \n",
                        dev->descriptor.idVendor,
                        dev->descriptor.idProduct,
                        dev->descriptor.bDeviceClass,
                        dev->descriptor.bDeviceSubClass,
                        dev->descriptor.bDeviceProtocol);
#endif

		return 1;
		/* NOTE: can't use usb_match_id() since interface caches
		 * aren't set up yet. this is cut/paste from that code.
		 */
		for (id = whitelist_table; id->match_flags; id++) {
#ifdef DEBUG
			dev_dbg(&dev->dev,
				"ID: V:%04x P:%04x DC:%04x SC:%04x PR:%04x \n",
				id->idVendor,
				id->idProduct,
				id->bDeviceClass,
				id->bDeviceSubClass,
				id->bDeviceProtocol);
#endif

			if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
			    id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
				continue;
@@ -95,18 +167,20 @@ static int is_targeted(struct usb_device *dev)

			return 1;
		}
	}

	/* add other match criteria here ... */


	/* OTG MESSAGE: report errors here, customize to match your product */
	dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
		le16_to_cpu(dev->descriptor.idVendor),
		le16_to_cpu(dev->descriptor.idProduct));
#ifdef	CONFIG_USB_OTG_WHITELIST
	report_errors(dev);
	return 0;
#else
	if (enable_whitelist) {
		report_errors(dev);
		return 0;
	} else {
		return 1;
	}
#endif
}
+3676 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading