Skip to content

Commit 10d4cf2

Browse files
committed
usb: deprecate legacy USB device support
Deprecate legacy USB device support. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
1 parent 59be327 commit 10d4cf2

File tree

23 files changed

+199
-83
lines changed

23 files changed

+199
-83
lines changed

drivers/usb/device/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
menuconfig USB_DEVICE_DRIVER
77
bool "USB device controller drivers"
8+
select DEPRECATED
89
help
910
Enable USB device controller drivers.
1011

include/zephyr/drivers/uart/cdc_acm.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ typedef void (*cdc_dte_rate_callback_t)(const struct device *dev,
3434
/**
3535
* @brief Set the callback for dwDTERate SetLineCoding requests.
3636
*
37+
* @deprecated Use @ref usbd_api and @ref USBD_MSG_CDC_ACM_LINE_CODING instead.
38+
*
3739
* The callback is invoked when the USB host changes the baud rate.
3840
*
3941
* @note This function is available only when
@@ -44,7 +46,7 @@ typedef void (*cdc_dte_rate_callback_t)(const struct device *dev,
4446
*
4547
* @return 0 on success.
4648
*/
47-
int cdc_acm_dte_rate_callback_set(const struct device *dev,
49+
__deprecated int cdc_acm_dte_rate_callback_set(const struct device *dev,
4850
cdc_dte_rate_callback_t callback);
4951

5052
#ifdef __cplusplus

include/zephyr/drivers/usb/usb_dc.h

Lines changed: 63 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -138,57 +138,69 @@ typedef void (*usb_dc_status_callback)(enum usb_dc_status_code cb_status,
138138
/**
139139
* @brief Attach USB for device connection
140140
*
141+
* @deprecated Use @ref udc_api instead
142+
*
141143
* Function to attach USB for device connection. Upon success, the USB PLL
142144
* is enabled, and the USB device is now capable of transmitting and receiving
143145
* on the USB bus and of generating interrupts.
144146
*
145147
* @return 0 on success, negative errno code on fail.
146148
*/
147-
int usb_dc_attach(void);
149+
__deprecated int usb_dc_attach(void);
148150

149151
/**
150152
* @brief Detach the USB device
151153
*
154+
* @deprecated Use @ref udc_api instead
155+
*
152156
* Function to detach the USB device. Upon success, the USB hardware PLL
153157
* is powered down and USB communication is disabled.
154158
*
155159
* @return 0 on success, negative errno code on fail.
156160
*/
157-
int usb_dc_detach(void);
161+
__deprecated int usb_dc_detach(void);
158162

159163
/**
160164
* @brief Reset the USB device
161165
*
166+
* @deprecated Use @ref udc_api instead
167+
*
162168
* This function returns the USB device and firmware back to it's initial state.
163169
* N.B. the USB PLL is handled by the usb_detach function
164170
*
165171
* @return 0 on success, negative errno code on fail.
166172
*/
167-
int usb_dc_reset(void);
173+
__deprecated int usb_dc_reset(void);
168174

169175
/**
170176
* @brief Set USB device address
171177
*
178+
* @deprecated Use @ref udc_api instead
179+
*
172180
* @param[in] addr Device address
173181
*
174182
* @return 0 on success, negative errno code on fail.
175183
*/
176-
int usb_dc_set_address(const uint8_t addr);
184+
__deprecated int usb_dc_set_address(const uint8_t addr);
177185

178186
/**
179187
* @brief Set USB device controller status callback
180188
*
189+
* @deprecated Use @ref udc_api instead
190+
*
181191
* Function to set USB device controller status callback. The registered
182192
* callback is used to report changes in the status of the device controller.
183193
* The status code are described by the usb_dc_status_code enumeration.
184194
*
185195
* @param[in] cb Callback function
186196
*/
187-
void usb_dc_set_status_callback(const usb_dc_status_callback cb);
197+
__deprecated void usb_dc_set_status_callback(const usb_dc_status_callback cb);
188198

189199
/**
190200
* @brief check endpoint capabilities
191201
*
202+
* @deprecated Use @ref udc_api instead
203+
*
192204
* Function to check capabilities of an endpoint. usb_dc_ep_cfg_data structure
193205
* provides the endpoint configuration parameters: endpoint address,
194206
* endpoint maximum packet size and endpoint type.
@@ -199,11 +211,13 @@ void usb_dc_set_status_callback(const usb_dc_status_callback cb);
199211
*
200212
* @return 0 on success, negative errno code on fail.
201213
*/
202-
int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg);
214+
__deprecated int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg);
203215

204216
/**
205217
* @brief Configure endpoint
206218
*
219+
* @deprecated Use @ref udc_api instead
220+
*
207221
* Function to configure an endpoint. usb_dc_ep_cfg_data structure provides
208222
* the endpoint configuration parameters: endpoint address, endpoint maximum
209223
* packet size and endpoint type.
@@ -212,52 +226,62 @@ int usb_dc_ep_check_cap(const struct usb_dc_ep_cfg_data * const cfg);
212226
*
213227
* @return 0 on success, negative errno code on fail.
214228
*/
215-
int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data * const cfg);
229+
__deprecated int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data * const cfg);
216230

217231
/**
218232
* @brief Set stall condition for the selected endpoint
219233
*
234+
* @deprecated Use @ref udc_api instead
235+
*
220236
* @param[in] ep Endpoint address corresponding to the one
221237
* listed in the device configuration table
222238
*
223239
* @return 0 on success, negative errno code on fail.
224240
*/
225-
int usb_dc_ep_set_stall(const uint8_t ep);
241+
__deprecated int usb_dc_ep_set_stall(const uint8_t ep);
226242

227243
/**
228244
* @brief Clear stall condition for the selected endpoint
229245
*
246+
* @deprecated Use @ref udc_api instead
247+
*
230248
* @param[in] ep Endpoint address corresponding to the one
231249
* listed in the device configuration table
232250
*
233251
* @return 0 on success, negative errno code on fail.
234252
*/
235-
int usb_dc_ep_clear_stall(const uint8_t ep);
253+
__deprecated int usb_dc_ep_clear_stall(const uint8_t ep);
236254

237255
/**
238256
* @brief Check if the selected endpoint is stalled
239257
*
258+
* @deprecated Use @ref udc_api instead
259+
*
240260
* @param[in] ep Endpoint address corresponding to the one
241261
* listed in the device configuration table
242262
* @param[out] stalled Endpoint stall status
243263
*
244264
* @return 0 on success, negative errno code on fail.
245265
*/
246-
int usb_dc_ep_is_stalled(const uint8_t ep, uint8_t *const stalled);
266+
__deprecated int usb_dc_ep_is_stalled(const uint8_t ep, uint8_t *const stalled);
247267

248268
/**
249269
* @brief Halt the selected endpoint
250270
*
271+
* @deprecated Use @ref udc_api instead
272+
*
251273
* @param[in] ep Endpoint address corresponding to the one
252274
* listed in the device configuration table
253275
*
254276
* @return 0 on success, negative errno code on fail.
255277
*/
256-
int usb_dc_ep_halt(const uint8_t ep);
278+
__deprecated int usb_dc_ep_halt(const uint8_t ep);
257279

258280
/**
259281
* @brief Enable the selected endpoint
260282
*
283+
* @deprecated Use @ref udc_api instead
284+
*
261285
* Function to enable the selected endpoint. Upon success interrupts are
262286
* enabled for the corresponding endpoint and the endpoint is ready for
263287
* transmitting/receiving data.
@@ -267,11 +291,13 @@ int usb_dc_ep_halt(const uint8_t ep);
267291
*
268292
* @return 0 on success, negative errno code on fail.
269293
*/
270-
int usb_dc_ep_enable(const uint8_t ep);
294+
__deprecated int usb_dc_ep_enable(const uint8_t ep);
271295

272296
/**
273297
* @brief Disable the selected endpoint
274298
*
299+
* @deprecated Use @ref udc_api instead
300+
*
275301
* Function to disable the selected endpoint. Upon success interrupts are
276302
* disabled for the corresponding endpoint and the endpoint is no longer able
277303
* for transmitting/receiving data.
@@ -281,23 +307,27 @@ int usb_dc_ep_enable(const uint8_t ep);
281307
*
282308
* @return 0 on success, negative errno code on fail.
283309
*/
284-
int usb_dc_ep_disable(const uint8_t ep);
310+
__deprecated int usb_dc_ep_disable(const uint8_t ep);
285311

286312
/**
287313
* @brief Flush the selected endpoint
288314
*
315+
* @deprecated Use @ref udc_api instead
316+
*
289317
* This function flushes the FIFOs for the selected endpoint.
290318
*
291319
* @param[in] ep Endpoint address corresponding to the one
292320
* listed in the device configuration table
293321
*
294322
* @return 0 on success, negative errno code on fail.
295323
*/
296-
int usb_dc_ep_flush(const uint8_t ep);
324+
__deprecated int usb_dc_ep_flush(const uint8_t ep);
297325

298326
/**
299327
* @brief Write data to the specified endpoint
300328
*
329+
* @deprecated Use @ref udc_api instead
330+
*
301331
* This function is called to write data to the specified endpoint. The
302332
* supplied usb_ep_callback function will be called when data is transmitted
303333
* out.
@@ -313,12 +343,14 @@ int usb_dc_ep_flush(const uint8_t ep);
313343
*
314344
* @return 0 on success, negative errno code on fail.
315345
*/
316-
int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data,
346+
__deprecated int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data,
317347
const uint32_t data_len, uint32_t * const ret_bytes);
318348

319349
/**
320350
* @brief Read data from the specified endpoint
321351
*
352+
* @deprecated Use @ref udc_api instead
353+
*
322354
* This function is called by the endpoint handler function, after an OUT
323355
* interrupt has been received for that EP. The application must only call this
324356
* function through the supplied usb_ep_callback function. This function clears
@@ -335,12 +367,14 @@ int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data,
335367
*
336368
* @return 0 on success, negative errno code on fail.
337369
*/
338-
int usb_dc_ep_read(const uint8_t ep, uint8_t *const data,
370+
__deprecated int usb_dc_ep_read(const uint8_t ep, uint8_t *const data,
339371
const uint32_t max_data_len, uint32_t *const read_bytes);
340372

341373
/**
342374
* @brief Set callback function for the specified endpoint
343375
*
376+
* @deprecated Use @ref udc_api instead
377+
*
344378
* Function to set callback function for notification of data received and
345379
* available to application or transmit done on the selected endpoint,
346380
* NULL if callback not required by application code. The callback status
@@ -352,11 +386,13 @@ int usb_dc_ep_read(const uint8_t ep, uint8_t *const data,
352386
*
353387
* @return 0 on success, negative errno code on fail.
354388
*/
355-
int usb_dc_ep_set_callback(const uint8_t ep, const usb_dc_ep_callback cb);
389+
__deprecated int usb_dc_ep_set_callback(const uint8_t ep, const usb_dc_ep_callback cb);
356390

357391
/**
358392
* @brief Read data from the specified endpoint
359393
*
394+
* @deprecated Use @ref udc_api instead
395+
*
360396
* This is similar to usb_dc_ep_read, the difference being that, it doesn't
361397
* clear the endpoint NAKs so that the consumer is not bogged down by further
362398
* upcalls till he is done with the processing of the data. The caller should
@@ -372,12 +408,14 @@ int usb_dc_ep_set_callback(const uint8_t ep, const usb_dc_ep_callback cb);
372408
*
373409
* @return 0 on success, negative errno code on fail.
374410
*/
375-
int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data, uint32_t max_data_len,
411+
__deprecated int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data, uint32_t max_data_len,
376412
uint32_t *read_bytes);
377413

378414
/**
379415
* @brief Continue reading data from the endpoint
380416
*
417+
* @deprecated Use @ref udc_api instead
418+
*
381419
* Clear the endpoint NAK and enable the endpoint to accept more data
382420
* from the host. Usually called after usb_dc_ep_read_wait() when the consumer
383421
* is fine to accept more data. Thus these calls together act as a flow control
@@ -388,26 +426,30 @@ int usb_dc_ep_read_wait(uint8_t ep, uint8_t *data, uint32_t max_data_len,
388426
*
389427
* @return 0 on success, negative errno code on fail.
390428
*/
391-
int usb_dc_ep_read_continue(uint8_t ep);
429+
__deprecated int usb_dc_ep_read_continue(uint8_t ep);
392430

393431
/**
394432
* @brief Get endpoint max packet size
395433
*
434+
* @deprecated Use @ref udc_api instead
435+
*
396436
* @param[in] ep Endpoint address corresponding to the one
397437
* listed in the device configuration table
398438
*
399439
* @return Endpoint max packet size (mps)
400440
*/
401-
int usb_dc_ep_mps(uint8_t ep);
441+
__deprecated int usb_dc_ep_mps(uint8_t ep);
402442

403443
/**
404444
* @brief Start the host wake up procedure.
405445
*
446+
* @deprecated Use @ref udc_api instead
447+
*
406448
* Function to wake up the host if it's currently in sleep mode.
407449
*
408450
* @return 0 on success, negative errno code on fail.
409451
*/
410-
int usb_dc_wakeup_request(void);
452+
__deprecated int usb_dc_wakeup_request(void);
411453

412454
/**
413455
* @}

include/zephyr/usb/class/usb_audio.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ struct usb_audio_ops {
279279
};
280280

281281
/** @brief Get the frame size that is accepted by the Host.
282+
*
283+
* @deprecated Use @ref uac2_device instead.
282284
*
283285
* This function returns the frame size for Input Devices that is expected
284286
* by the Host. Returned value rely on Input Device configuration:
@@ -292,23 +294,27 @@ struct usb_audio_ops {
292294
* @warning Do not use with OUT only devices (Headphones).
293295
* For OUT only devices this function shall return 0.
294296
*/
295-
size_t usb_audio_get_in_frame_size(const struct device *dev);
297+
__deprecated size_t usb_audio_get_in_frame_size(const struct device *dev);
296298

297299
/**
298300
* @brief Register the USB Audio device and make it usable.
299301
* This must be called in order to make the device work
300302
* and respond to all relevant requests.
301303
*
304+
* @deprecated Use @ref uac2_device instead.
305+
*
302306
* @param dev USB Audio device
303307
* @param ops USB audio callback structure. Callback are used to
304308
* inform the user about what is happening
305309
*/
306-
void usb_audio_register(const struct device *dev,
310+
__deprecated void usb_audio_register(const struct device *dev,
307311
const struct usb_audio_ops *ops);
308312

309313
/**
310314
* @brief Send data using USB Audio device
311315
*
316+
* @deprecated Use @ref uac2_device instead.
317+
*
312318
* @param dev USB Audio device which will send the data
313319
* over its ISO IN endpoint
314320
* @param buffer Pointer to the buffer that should be send. User is
@@ -326,7 +332,7 @@ void usb_audio_register(const struct device *dev,
326332
*
327333
* @return 0 on success, negative error on fail
328334
*/
329-
int usb_audio_send(const struct device *dev, struct net_buf *buffer,
335+
__deprecated int usb_audio_send(const struct device *dev, struct net_buf *buffer,
330336
size_t len);
331337

332338
#endif /* ZEPHYR_INCLUDE_USB_CLASS_AUDIO_H_ */

include/zephyr/usb/class/usb_cdc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#define ZEPHYR_INCLUDE_USB_CLASS_USB_CDC_H_
2323

2424
/** CDC Specification release number in BCD format */
25-
#define CDC_SRN_1_20 0x0120
25+
#define CDC_SRN_1_20 0x0120 __DEPRECATED_MACRO
2626

2727
/** Communications Class Subclass Codes */
2828
#define ACM_SUBCLASS 0x02

0 commit comments

Comments
 (0)