11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * drivers/usb/core/otg_whitelist.h
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Copyright (C) 2004 Texas Instruments
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This program is free software; you can redistribute it and/or modify
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * it under the terms of the GNU General Public License as published by
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * the Free Software Foundation; either version 2 of the License, or
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (at your option) any later version.
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
13026f3fcbb0fc516e0fd3467318f13a6144e519a7Peter Chen * This OTG and Embedded Host Whitelist is "Targeted Peripheral List".
14026f3fcbb0fc516e0fd3467318f13a6144e519a7Peter Chen * It should mostly use of USB_DEVICE() or USB_DEVICE_VER() entries..
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * YOU _SHOULD_ CHANGE THIS LIST TO MATCH YOUR PRODUCT AND ITS TESTING!
1784cca820ee798a6bc8b01a4ccc9548943bc41f7fGreg Kroah-Hartman */
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct usb_device_id whitelist_table [] = {
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* hubs are optional in OTG, but very handy ... */
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), },
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef	CONFIG_USB_PRINTER		/* ignoring nonstatic linkage! */
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* FIXME actually, printers are NOT supposed to use device classes;
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * they're supposed to use interface classes...
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ USB_DEVICE_INFO(7, 1, 1) },
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ USB_DEVICE_INFO(7, 1, 2) },
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ USB_DEVICE_INFO(7, 1, 3) },
321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
347fe89e9cc8ebd9da70f760409a4301d26f80a460Robert P. J. Day#ifdef	CONFIG_USB_NET_CDCETHER
351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Linux-USB CDC Ethernet gadget */
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ USB_DEVICE(0x0525, 0xa4a1), },
371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Linux-USB CDC Ethernet + RNDIS gadget */
381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ USB_DEVICE(0x0525, 0xa4a2), },
391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#if	defined(CONFIG_USB_TEST) || defined(CONFIG_USB_TEST_MODULE)
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* gadget zero, for testing */
431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ USB_DEVICE(0x0525, 0xa4a0), },
441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif
451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ }	/* Terminating entry */
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int is_targeted(struct usb_device *dev)
501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct usb_device_id	*id = whitelist_table;
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* HNP test device is _never_ targeted (see OTG spec 6.6.6) */
5484cca820ee798a6bc8b01a4ccc9548943bc41f7fGreg Kroah-Hartman	if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	     le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		return 0;
571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* NOTE: can't use usb_match_id() since interface caches
591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 * aren't set up yet. this is cut/paste from that code.
601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	 */
611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	for (id = whitelist_table; id->match_flags; id++) {
621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		    id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			continue;
651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		    id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			continue;
691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* No need to test id->bcdDevice_lo != 0, since 0 is never
711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		   greater than any unsigned number. */
721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		    (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			continue;
751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		    (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			continue;
791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		    (id->bDeviceClass != dev->descriptor.bDeviceClass))
821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			continue;
831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
8584cca820ee798a6bc8b01a4ccc9548943bc41f7fGreg Kroah-Hartman		    (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			continue;
871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		    (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			continue;
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		return 1;
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* add other match criteria here ... */
961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	/* OTG MESSAGE: report errors here, customize to match your product */
991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		le16_to_cpu(dev->descriptor.idVendor),
1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		le16_to_cpu(dev->descriptor.idProduct));
102026f3fcbb0fc516e0fd3467318f13a6144e519a7Peter Chen
1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	return 0;
1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
106