usb_desc.conf 3.5 KB

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