usb_desc.conf 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. # -*- perl -*-
  2. #
  3. # Invoked from usbdescgen.pl
  4. #
  5. require '../../iodevs.conf';
  6. require 'hconst.ph';
  7. my %usbparam = header_const('usbparam.vh');
  8. usb_languages('en_US', 'sv_SE');
  9. my $vendor_id = word(0x4680); # was: word(0x1d50); [OpenMoko]
  10. my $device_id = word(0x0881); # was: word(0x6149); [free public allocations]
  11. my $version_id = word(0x0100);
  12. my $serial = usb_serial('XXXXXX-XXXXXX'); # 12 characters
  13. my $manufacturer = usb_string('' => 'Peter & Per');
  14. my $product = usb_string('' => 'MAX80 I/O card for ABC');
  15. my $maxpacket = 1 << ($usbparam{'USB_PACKET_BITS'} || 6);
  16. sub acm_channels($$@) {
  17. my($channel_count,$ep_base,@names) = @_;
  18. my @d;
  19. for (my $c = 0; $c < $channel_count; $c++) {
  20. my $ep_data = $ep_base + ($c << 1);
  21. my $ep_intr = $ep_data + 1;
  22. my $mgmt_if;
  23. my $data_if;
  24. my $name = defined($names[$c]) ? $names[$c] : usb_string();
  25. push(@d,
  26. # Interface association descriptor
  27. usb_desc('interface_association',
  28. byte(\$mgmt_if), # First interface index
  29. byte(2), # Interface count
  30. # USB spec says to copy the first interface class
  31. usb_class('cdc','acm','none'),
  32. $name),
  33. # Management interface
  34. usb_dset {
  35. usb_desc('interface',
  36. byte($mgmt_if = usb_index),
  37. byte(0), # No alternate settings
  38. byte(1), # Endpoint count
  39. usb_class('cdc','acm','none'),
  40. $name),
  41. usb_desc('cs_interface.header',
  42. word(0x120)), # CDC spec version 1.20
  43. usb_desc('cs_interface.call_management',
  44. byte(0x03), # AT commands over setup or data
  45. byte(\$data_if)), # Which data interface
  46. usb_desc('cs_interface.acm',
  47. # Supports SET_CONTROL_LINE_STATE and
  48. # SEND_BREAK. This also means
  49. # GET|SET_LINE_CODING has to be handled,
  50. # at least vacuously.
  51. byte(0x06)),
  52. usb_desc('cs_interface.union',
  53. byte(\$mgmt_if), # Controlling interface
  54. byte(\$data_if)), # Data interface
  55. # Notification endpoint (input)
  56. usb_desc('endpoint',
  57. ep_i($ep_intr),
  58. byte(3), # Interrupt, data
  59. word($maxpacket),
  60. byte(2)), # Interval
  61. },
  62. # Data interface
  63. usb_dset {
  64. usb_desc('interface',
  65. byte($data_if = usb_index),
  66. byte(0), # No alternate settings
  67. byte(2), # Endpoint count
  68. usb_class('cdc_data'),
  69. usb_string()),
  70. # Data endpoint (input)
  71. usb_desc('endpoint',
  72. ep_i($ep_data),
  73. byte(2), # Bulk, data
  74. word($maxpacket),
  75. byte(0)), # Interval
  76. # Data endpoint (output)
  77. usb_desc('endpoint',
  78. ep_o($ep_data),
  79. byte(2), # Bulk, data
  80. word($maxpacket),
  81. byte(0)) # Interval
  82. });
  83. }
  84. return @d;
  85. }
  86. usb_device {
  87. usb_desc('device',
  88. word(0x101), # USB version
  89. usb_class('multi'), # Device with multiple interfaces
  90. byte(8), # Max packet size on endpoint 0
  91. $vendor_id, $device_id, $version_id,
  92. $manufacturer, $product, $serial,
  93. byte(usb_children) # Number of configurations
  94. ),
  95. usb_dset {
  96. usb_desc('configuration',
  97. word(usb_totallen), # Total length for this dset
  98. byte(usb_children), # Number of interfaces
  99. byte(usb_index,1), # This configuration index
  100. usb_string(), # Text description (empty)
  101. byte(0xc0), # Self or bus powered
  102. byte(500 >> 1)), # Up to 500 mA
  103. # Descriptors for each ACM channel, starting at endpoint 1
  104. acm_channels($consts{'TTY_CHANNELS'}, 1,
  105. # Names of ACM channels
  106. usb_string('' => 'MAX80 console'),
  107. usb_string('' => 'PUN80 network'))
  108. },
  109. };
  110. usb_additional_data {
  111. # Line state structure
  112. dword(38400), # Baud rate (largest POSIX required value)
  113. byte(0), # 1 stop bit
  114. byte(0), # No parity
  115. byte(8) # 8 data bits
  116. };