altos: Rename 'core' to 'kernel'
[fw/altos] / src / kernel / ao_product.c
1 /*
2  * Copyright © 2009 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #include "ao.h"
19 #include "ao_product.h"
20
21 /* Defines which mark this particular AltOS product */
22
23 const char ao_version[AO_MAX_VERSION] = AO_iVersion_STRING;
24 const char ao_manufacturer[] = AO_iManufacturer_STRING;
25 const char ao_product[] = AO_iProduct_STRING;
26
27 #define LE_WORD(x)    ((x)&0xFF),((uint8_t) (((uint16_t) (x))>>8))
28
29 #if HAS_USB
30
31 /* Maximum power in mA */
32 #ifndef AO_USB_MAX_POWER
33 #define AO_USB_MAX_POWER        100
34 #endif
35
36 #include "ao_usb.h"
37 /* USB descriptors in one giant block of bytes */
38 AO_ROMCONFIG_SYMBOL(0x00aa) uint8_t ao_usb_descriptors [] =
39 {
40         /* Device descriptor */
41         0x12,
42         AO_USB_DESC_DEVICE,
43         LE_WORD(0x0110),        /*  bcdUSB */
44         0x02,                   /*  bDeviceClass */
45         0x00,                   /*  bDeviceSubClass */
46         0x00,                   /*  bDeviceProtocol */
47         AO_USB_CONTROL_SIZE,    /*  bMaxPacketSize */
48         LE_WORD(0xFFFE),        /*  idVendor */
49         LE_WORD(AO_idProduct_NUMBER),   /*  idProduct */
50         LE_WORD(0x0100),        /*  bcdDevice */
51         0x01,                   /*  iManufacturer */
52         0x02,                   /*  iProduct */
53         0x03,                   /*  iSerialNumber */
54         0x01,                   /*  bNumConfigurations */
55
56         /* Configuration descriptor */
57         0x09,
58         AO_USB_DESC_CONFIGURATION,
59         LE_WORD(67),            /*  wTotalLength */
60         0x02,                   /*  bNumInterfaces */
61         0x01,                   /*  bConfigurationValue */
62         0x00,                   /*  iConfiguration */
63         0xC0,                   /*  bmAttributes */
64         AO_USB_MAX_POWER >> 1,  /*  bMaxPower, 2mA units */
65
66         /* Control class interface */
67         0x09,
68         AO_USB_DESC_INTERFACE,
69         0x00,                   /*  bInterfaceNumber */
70         0x00,                   /*  bAlternateSetting */
71         0x01,                   /*  bNumEndPoints */
72         0x02,                   /*  bInterfaceClass */
73         0x02,                   /*  bInterfaceSubClass */
74         0x01,                   /*  bInterfaceProtocol, linux requires value of 1 for the cdc_acm module */
75         0x00,                   /*  iInterface */
76
77         /* Header functional descriptor */
78         0x05,
79         AO_USB_CS_INTERFACE,
80         0x00,                   /*  bDescriptor SubType Header */
81         LE_WORD(0x0110),        /*  CDC version 1.1 */
82
83         /* Call management functional descriptor */
84         0x05,
85         AO_USB_CS_INTERFACE,
86         0x01,                   /* bDescriptor SubType Call Management */
87         0x01,                   /* bmCapabilities = device handles call management */
88         0x01,                   /* bDataInterface call management interface number */
89
90         /* ACM functional descriptor */
91         0x04,
92         AO_USB_CS_INTERFACE,
93         0x02,                   /* bDescriptor SubType Abstract Control Management */
94         0x02,                   /* bmCapabilities = D1 (Set_line_Coding, Set_Control_Line_State, Get_Line_Coding and Serial_State) */
95
96         /* Union functional descriptor */
97         0x05,
98         AO_USB_CS_INTERFACE,
99         0x06,                   /* bDescriptor SubType Union Functional descriptor */
100         0x00,                   /* bMasterInterface */
101         0x01,                   /* bSlaveInterface0 */
102
103         /* Notification EP */
104         0x07,
105         AO_USB_DESC_ENDPOINT,
106         AO_USB_INT_EP|0x80,     /* bEndpointAddress */
107         0x03,                   /* bmAttributes = intr */
108         LE_WORD(8),             /* wMaxPacketSize */
109         0xff,                   /* bInterval */
110
111         /* Data class interface descriptor */
112         0x09,
113         AO_USB_DESC_INTERFACE,
114         0x01,                   /* bInterfaceNumber */
115         0x00,                   /* bAlternateSetting */
116         0x02,                   /* bNumEndPoints */
117         0x0A,                   /* bInterfaceClass = data */
118         0x00,                   /* bInterfaceSubClass */
119         0x00,                   /* bInterfaceProtocol */
120         0x00,                   /* iInterface */
121
122         /* Data EP OUT */
123         0x07,
124         AO_USB_DESC_ENDPOINT,
125         AO_USB_OUT_EP,          /* bEndpointAddress */
126         0x02,                   /* bmAttributes = bulk */
127         LE_WORD(AO_USB_OUT_SIZE),/* wMaxPacketSize */
128         0x00,                   /* bInterval */
129
130         /* Data EP in */
131         0x07,
132         AO_USB_DESC_ENDPOINT,
133         AO_USB_IN_EP|0x80,      /* bEndpointAddress */
134         0x02,                   /* bmAttributes = bulk */
135         LE_WORD(AO_USB_IN_SIZE),/* wMaxPacketSize */
136         0x00,                   /* bInterval */
137
138         /* String descriptors */
139         0x04,
140         AO_USB_DESC_STRING,
141         LE_WORD(0x0409),
142
143         /* iManufacturer */
144         AO_iManufacturer_LEN,
145         AO_USB_DESC_STRING,
146         AO_iManufacturer_UCS2,
147
148         /* iProduct */
149         AO_iProduct_LEN,
150         AO_USB_DESC_STRING,
151         AO_iProduct_UCS2,
152
153         /* iSerial */
154         AO_iSerial_LEN,
155         AO_USB_DESC_STRING,
156         AO_iSerial_UCS2,
157
158         /* Terminating zero */
159         0
160 };
161 #endif