openocd: fix SPDX tag format for files .c
[fw/openocd] / src / jtag / drivers / OpenULINK / src / usb.c
index a8299103bb34dc6e53d4f4c98c17cc234fcbaa4e..408e21217820998dc62abcca83cd109a7ced0df6 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
- *   Copyright (C) 2011 by Martin Schmoelzer                               *
+ *   Copyright (C) 2011-2013 by Martin Schmoelzer                          *
  *   <martin.schmoelzer@student.tuwien.ac.at>                              *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
 /**
@@ -40,90 +27,75 @@ volatile bool EP2_in;
 volatile __xdata __at 0x7FE8 struct setup_data setup_data;
 
 /* Define number of endpoints (except Control Endpoint 0) in a central place.
- * Be sure to include the neccessary endpoint descriptors! */
+ * Be sure to include the necessary endpoint descriptors! */
 #define NUM_ENDPOINTS 2
 
-/*
- * Normally, we would initialize the descriptor structures in C99 style:
- *
- * __code usb_device_descriptor_t device_descriptor = {
- *   .bLength = foo,
- *   .bDescriptorType = bar,
- *   .bcdUSB = 0xABCD,
- *   ...
- * };
- *
- * But SDCC currently does not support this, so we have to do it the
- * old-fashioned way...
- */
-
 __code struct usb_device_descriptor device_descriptor = {
-       /* .bLength = */ sizeof(struct usb_device_descriptor),
-       /* .bDescriptorType = */ DESCRIPTOR_TYPE_DEVICE,
-       /* .bcdUSB = */ 0x0110,         /* BCD: 01.00 (Version 1.0 USB spec) */
-       /* .bDeviceClass = */ 0xFF,     /* 0xFF = vendor-specific */
-       /* .bDeviceSubClass = */ 0xFF,
-       /* .bDeviceProtocol = */ 0xFF,
-       /* .bMaxPacketSize0 = */ 64,
-       /* .idVendor = */ 0xC251,
-       /* .idProduct = */ 0x2710,
-       /* .bcdDevice = */ 0x0100,
-       /* .iManufacturer = */ 1,
-       /* .iProduct = */ 2,
-       /* .iSerialNumber = */ 3,
-       /* .bNumConfigurations = */ 1
+       .bLength =              sizeof(struct usb_device_descriptor),
+       .bDescriptorType =      DESCRIPTOR_TYPE_DEVICE,
+       .bcdUSB =               0x0110, /* BCD: 01.00 (Version 1.0 USB spec) */
+       .bDeviceClass =         0xFF,   /* 0xFF = vendor-specific */
+       .bDeviceSubClass =      0xFF,
+       .bDeviceProtocol =      0xFF,
+       .bMaxPacketSize0 =      64,
+       .idVendor =             0xC251,
+       .idProduct =            0x2710,
+       .bcdDevice =            0x0100,
+       .iManufacturer =        1,
+       .iProduct =             2,
+       .iSerialNumber =        3,
+       .bNumConfigurations =   1
 };
 
 /* WARNING: ALL config, interface and endpoint descriptors MUST be adjacent! */
 
 __code struct usb_config_descriptor config_descriptor = {
-       /* .bLength = */ sizeof(struct usb_config_descriptor),
-       /* .bDescriptorType = */ DESCRIPTOR_TYPE_CONFIGURATION,
-       /* .wTotalLength = */ sizeof(struct usb_config_descriptor) +
-       sizeof(struct usb_interface_descriptor) +
-       (NUM_ENDPOINTS *
-        sizeof(struct usb_endpoint_descriptor)),
-       /* .bNumInterfaces = */ 1,
-       /* .bConfigurationValue = */ 1,
-       /* .iConfiguration = */ 4,      /* String describing this configuration */
-       /* .bmAttributes = */ 0x80,     /* Only MSB set according to USB spec */
-       /* .MaxPower = */ 50            /* 100 mA */
+       .bLength =              sizeof(struct usb_config_descriptor),
+       .bDescriptorType =      DESCRIPTOR_TYPE_CONFIGURATION,
+       .wTotalLength =         sizeof(struct usb_config_descriptor) +
+               sizeof(struct usb_interface_descriptor) +
+               (NUM_ENDPOINTS * sizeof(struct usb_endpoint_descriptor)),
+       .bNumInterfaces =       1,
+       .bConfigurationValue =  1,
+       .iConfiguration =       4,      /* String describing this configuration */
+       .bmAttributes =         0x80,   /* Only MSB set according to USB spec */
+       .MaxPower =             50      /* 100 mA */
 };
 
 __code struct usb_interface_descriptor interface_descriptor00 = {
-       /* .bLength = */ sizeof(struct usb_interface_descriptor),
-       /* .bDescriptorType = */ DESCRIPTOR_TYPE_INTERFACE,
-       /* .bInterfaceNumber = */ 0,
-       /* .bAlternateSetting = */ 0,
-       /* .bNumEndpoints = */ NUM_ENDPOINTS,
-       /* .bInterfaceClass = */ 0xFF,
-       /* .bInterfaceSubclass = */ 0xFF,
-       /* .bInterfaceProtocol = */ 0xFF,
-       /* .iInterface = */ 0
+       .bLength = sizeof(struct usb_interface_descriptor),
+       .bDescriptorType =      DESCRIPTOR_TYPE_INTERFACE,
+       .bInterfaceNumber =     0,
+       .bAlternateSetting =    0,
+       .bNumEndpoints =        NUM_ENDPOINTS,
+       .bInterfaceClass =      0xFF,
+       .bInterfaceSubclass =   0xFF,
+       .bInterfaceProtocol =   0xFF,
+       .iInterface =           0
 };
 
 __code struct usb_endpoint_descriptor Bulk_EP2_IN_Endpoint_Descriptor = {
-       /* .bLength = */ sizeof(struct usb_endpoint_descriptor),
-       /* .bDescriptorType = */ 0x05,
-       /* .bEndpointAddress = */ 2 | USB_DIR_IN,
-       /* .bmAttributes = */ 0x02,
-       /* .wMaxPacketSize = */ 64,
-       /* .bInterval = */ 0
+       .bLength =              sizeof(struct usb_endpoint_descriptor),
+       .bDescriptorType =      0x05,
+       .bEndpointAddress =     (2 | USB_DIR_IN),
+       .bmAttributes =         0x02,
+       .wMaxPacketSize =       64,
+       .bInterval =            0
 };
 
 __code struct usb_endpoint_descriptor Bulk_EP2_OUT_Endpoint_Descriptor = {
-       /* .bLength = */ sizeof(struct usb_endpoint_descriptor),
-       /* .bDescriptorType = */ 0x05,
-       /* .bEndpointAddress = */ 2 | USB_DIR_OUT,
-       /* .bmAttributes = */ 0x02,
-       /* .wMaxPacketSize = */ 64,
-       /* .bInterval = */ 0
+       .bLength =              sizeof(struct usb_endpoint_descriptor),
+       .bDescriptorType =      0x05,
+       .bEndpointAddress =     (2 | USB_DIR_OUT),
+       .bmAttributes =         0x02,
+       .wMaxPacketSize =       64,
+       .bInterval =            0
 };
 
 __code struct usb_language_descriptor language_descriptor = {
-       /* .bLength =  */ 4,
-       /* .bDescriptorType = */ DESCRIPTOR_TYPE_STRING,
-       /* .wLANGID = */ {0x0409 /* US English */}
+       .bLength =              4,
+       .bDescriptorType =      DESCRIPTOR_TYPE_STRING,
+       .wLANGID =              {0x0409 /* US English */}
 };
 
 __code struct usb_string_descriptor strManufacturer =