usb_usual.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Interface to the libusual.
  3. *
  4. * Copyright (c) 2005 Pete Zaitcev <zaitcev@redhat.com>
  5. * Copyright (c) 1999-2002 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
  6. * Copyright (c) 1999 Michael Gee (michael@linuxspecific.com)
  7. */
  8. #ifndef __LINUX_USB_USUAL_H
  9. #define __LINUX_USB_USUAL_H
  10. /* We should do this for cleanliness... But other usb_foo.h do not do this. */
  11. /* #include <linux/usb.h> */
  12. /*
  13. * The flags field, which we store in usb_device_id.driver_info.
  14. * It is compatible with the old usb-storage flags in lower 24 bits.
  15. */
  16. /*
  17. * Static flag definitions. We use this roundabout technique so that the
  18. * proc_info() routine can automatically display a message for each flag.
  19. */
  20. #define US_DO_ALL_FLAGS \
  21. US_FLAG(SINGLE_LUN, 0x00000001) \
  22. /* allow access to only LUN 0 */ \
  23. US_FLAG(NEED_OVERRIDE, 0x00000002) \
  24. /* unusual_devs entry is necessary */ \
  25. US_FLAG(SCM_MULT_TARG, 0x00000004) \
  26. /* supports multiple targets */ \
  27. US_FLAG(FIX_INQUIRY, 0x00000008) \
  28. /* INQUIRY response needs faking */ \
  29. US_FLAG(FIX_CAPACITY, 0x00000010) \
  30. /* READ CAPACITY response too big */ \
  31. US_FLAG(IGNORE_RESIDUE, 0x00000020) \
  32. /* reported residue is wrong */ \
  33. US_FLAG(BULK32, 0x00000040) \
  34. /* Uses 32-byte CBW length */ \
  35. US_FLAG(NOT_LOCKABLE, 0x00000080) \
  36. /* PREVENT/ALLOW not supported */ \
  37. US_FLAG(GO_SLOW, 0x00000100) \
  38. /* Need delay after Command phase */ \
  39. US_FLAG(NO_WP_DETECT, 0x00000200) \
  40. /* Don't check for write-protect */ \
  41. US_FLAG(MAX_SECTORS_64, 0x00000400) \
  42. /* Sets max_sectors to 64 */ \
  43. US_FLAG(IGNORE_DEVICE, 0x00000800) \
  44. /* Don't claim device */ \
  45. US_FLAG(CAPACITY_HEURISTICS, 0x00001000) \
  46. /* sometimes sizes is too big */ \
  47. US_FLAG(MAX_SECTORS_MIN,0x00002000) \
  48. /* Sets max_sectors to arch min */ \
  49. US_FLAG(BULK_IGNORE_TAG,0x00004000) \
  50. /* Ignore tag mismatch in bulk operations */ \
  51. US_FLAG(SANE_SENSE, 0x00008000) \
  52. /* Sane Sense (> 18 bytes) */ \
  53. US_FLAG(CAPACITY_OK, 0x00010000) \
  54. /* READ CAPACITY response is correct */ \
  55. US_FLAG(BAD_SENSE, 0x00020000) \
  56. /* Bad Sense (never more than 18 bytes) */
  57. #define US_FLAG(name, value) US_FL_##name = value ,
  58. enum { US_DO_ALL_FLAGS };
  59. #undef US_FLAG
  60. /*
  61. * The bias field for libusual and friends.
  62. */
  63. #define USB_US_TYPE_NONE 0
  64. #define USB_US_TYPE_STOR 1 /* usb-storage */
  65. #define USB_US_TYPE_UB 2 /* ub */
  66. #define USB_US_TYPE(flags) (((flags) >> 24) & 0xFF)
  67. #define USB_US_ORIG_FLAGS(flags) ((flags) & 0x00FFFFFF)
  68. /*
  69. * This is probably not the best place to keep these constants, conceptually.
  70. * But it's the only header included into all places which need them.
  71. */
  72. /* Sub Classes */
  73. #define USB_SC_RBC 0x01 /* Typically, flash devices */
  74. #define USB_SC_8020 0x02 /* CD-ROM */
  75. #define USB_SC_QIC 0x03 /* QIC-157 Tapes */
  76. #define USB_SC_UFI 0x04 /* Floppy */
  77. #define USB_SC_8070 0x05 /* Removable media */
  78. #define USB_SC_SCSI 0x06 /* Transparent */
  79. #define USB_SC_LOCKABLE 0x07 /* Password-protected */
  80. #define USB_SC_ISD200 0xf0 /* ISD200 ATA */
  81. #define USB_SC_CYP_ATACB 0xf1 /* Cypress ATACB */
  82. #define USB_SC_DEVICE 0xff /* Use device's value */
  83. /* Storage protocol codes */
  84. #define USB_PR_CBI 0x00 /* Control/Bulk/Interrupt */
  85. #define USB_PR_CB 0x01 /* Control/Bulk w/o interrupt */
  86. #define USB_PR_BULK 0x50 /* bulk only */
  87. #define USB_PR_UAS 0x62 /* USB Attached SCSI */
  88. #define USB_PR_USBAT 0x80 /* SCM-ATAPI bridge */
  89. #define USB_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */
  90. #define USB_PR_SDDR55 0x82 /* SDDR-55 (made up) */
  91. #define USB_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */
  92. #define USB_PR_FREECOM 0xf1 /* Freecom */
  93. #define USB_PR_DATAFAB 0xf2 /* Datafab chipsets */
  94. #define USB_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */
  95. #define USB_PR_ALAUDA 0xf4 /* Alauda chipsets */
  96. #define USB_PR_KARMA 0xf5 /* Rio Karma */
  97. #define USB_PR_DEVICE 0xff /* Use device's value */
  98. /*
  99. */
  100. extern int usb_usual_ignore_device(struct usb_interface *intf);
  101. extern struct usb_device_id usb_storage_usb_ids[];
  102. #ifdef CONFIG_USB_LIBUSUAL
  103. extern void usb_usual_set_present(int type);
  104. extern void usb_usual_clear_present(int type);
  105. extern int usb_usual_check_type(const struct usb_device_id *, int type);
  106. #else
  107. #define usb_usual_set_present(t) do { } while(0)
  108. #define usb_usual_clear_present(t) do { } while(0)
  109. #define usb_usual_check_type(id, t) (0)
  110. #endif /* CONFIG_USB_LIBUSUAL */
  111. #endif /* __LINUX_USB_USUAL_H */