18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * udc.h - ChipIdea UDC structures 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2008 Chipidea - MIPS Technologies, Inc. All rights reserved. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Author: David Lopo 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef __DRIVERS_USB_CHIPIDEA_UDC_H 118c2ecf20Sopenharmony_ci#define __DRIVERS_USB_CHIPIDEA_UDC_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <linux/list.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define CTRL_PAYLOAD_MAX 64 168c2ecf20Sopenharmony_ci#define RX 0 /* similar to USB_DIR_OUT but can be used as an index */ 178c2ecf20Sopenharmony_ci#define TX 1 /* similar to USB_DIR_IN but can be used as an index */ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* DMA layout of transfer descriptors */ 208c2ecf20Sopenharmony_cistruct ci_hw_td { 218c2ecf20Sopenharmony_ci /* 0 */ 228c2ecf20Sopenharmony_ci __le32 next; 238c2ecf20Sopenharmony_ci#define TD_TERMINATE BIT(0) 248c2ecf20Sopenharmony_ci#define TD_ADDR_MASK (0xFFFFFFEUL << 5) 258c2ecf20Sopenharmony_ci /* 1 */ 268c2ecf20Sopenharmony_ci __le32 token; 278c2ecf20Sopenharmony_ci#define TD_STATUS (0x00FFUL << 0) 288c2ecf20Sopenharmony_ci#define TD_STATUS_TR_ERR BIT(3) 298c2ecf20Sopenharmony_ci#define TD_STATUS_DT_ERR BIT(5) 308c2ecf20Sopenharmony_ci#define TD_STATUS_HALTED BIT(6) 318c2ecf20Sopenharmony_ci#define TD_STATUS_ACTIVE BIT(7) 328c2ecf20Sopenharmony_ci#define TD_MULTO (0x0003UL << 10) 338c2ecf20Sopenharmony_ci#define TD_IOC BIT(15) 348c2ecf20Sopenharmony_ci#define TD_TOTAL_BYTES (0x7FFFUL << 16) 358c2ecf20Sopenharmony_ci /* 2 */ 368c2ecf20Sopenharmony_ci __le32 page[5]; 378c2ecf20Sopenharmony_ci#define TD_CURR_OFFSET (0x0FFFUL << 0) 388c2ecf20Sopenharmony_ci#define TD_FRAME_NUM (0x07FFUL << 0) 398c2ecf20Sopenharmony_ci#define TD_RESERVED_MASK (0x0FFFUL << 0) 408c2ecf20Sopenharmony_ci} __attribute__ ((packed, aligned(4))); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* DMA layout of queue heads */ 438c2ecf20Sopenharmony_cistruct ci_hw_qh { 448c2ecf20Sopenharmony_ci /* 0 */ 458c2ecf20Sopenharmony_ci __le32 cap; 468c2ecf20Sopenharmony_ci#define QH_IOS BIT(15) 478c2ecf20Sopenharmony_ci#define QH_MAX_PKT (0x07FFUL << 16) 488c2ecf20Sopenharmony_ci#define QH_ZLT BIT(29) 498c2ecf20Sopenharmony_ci#define QH_MULT (0x0003UL << 30) 508c2ecf20Sopenharmony_ci#define QH_ISO_MULT(x) ((x >> 11) & 0x03) 518c2ecf20Sopenharmony_ci /* 1 */ 528c2ecf20Sopenharmony_ci __le32 curr; 538c2ecf20Sopenharmony_ci /* 2 - 8 */ 548c2ecf20Sopenharmony_ci struct ci_hw_td td; 558c2ecf20Sopenharmony_ci /* 9 */ 568c2ecf20Sopenharmony_ci __le32 RESERVED; 578c2ecf20Sopenharmony_ci struct usb_ctrlrequest setup; 588c2ecf20Sopenharmony_ci} __attribute__ ((packed, aligned(4))); 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct td_node { 618c2ecf20Sopenharmony_ci struct list_head td; 628c2ecf20Sopenharmony_ci dma_addr_t dma; 638c2ecf20Sopenharmony_ci struct ci_hw_td *ptr; 648c2ecf20Sopenharmony_ci int td_remaining_size; 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/** 688c2ecf20Sopenharmony_ci * struct ci_hw_req - usb request representation 698c2ecf20Sopenharmony_ci * @req: request structure for gadget drivers 708c2ecf20Sopenharmony_ci * @queue: link to QH list 718c2ecf20Sopenharmony_ci * @tds: link to TD list 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_cistruct ci_hw_req { 748c2ecf20Sopenharmony_ci struct usb_request req; 758c2ecf20Sopenharmony_ci struct list_head queue; 768c2ecf20Sopenharmony_ci struct list_head tds; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci#ifdef CONFIG_USB_CHIPIDEA_UDC 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciint ci_hdrc_gadget_init(struct ci_hdrc *ci); 828c2ecf20Sopenharmony_civoid ci_hdrc_gadget_destroy(struct ci_hdrc *ci); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#else 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic inline int ci_hdrc_gadget_init(struct ci_hdrc *ci) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci return -ENXIO; 898c2ecf20Sopenharmony_ci} 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic inline void ci_hdrc_gadget_destroy(struct ci_hdrc *ci) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#endif 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#endif /* __DRIVERS_USB_CHIPIDEA_UDC_H */ 99