linux/drivers/usb/gadget/udc/aspeed_udc.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (c) 2021 Aspeed Technology Inc.
 */

#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/prefetch.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/slab.h>

#define AST_UDC_NUM_ENDPOINTS
#define AST_UDC_EP0_MAX_PACKET
#define AST_UDC_EPn_MAX_PACKET
#define AST_UDC_DESCS_COUNT
#define AST_UDC_DESC_MODE

#define AST_UDC_EP_DMA_SIZE

/*****************************
 *                           *
 * UDC register definitions  *
 *                           *
 *****************************/

#define AST_UDC_FUNC_CTRL
#define AST_UDC_CONFIG
#define AST_UDC_IER
#define AST_UDC_ISR
#define AST_UDC_EP_ACK_IER
#define AST_UDC_EP_NAK_IER
#define AST_UDC_EP_ACK_ISR
#define AST_UDC_EP_NAK_ISR
#define AST_UDC_DEV_RESET
#define AST_UDC_STS
#define AST_VHUB_EP_DATA
#define AST_VHUB_ISO_TX_FAIL
#define AST_UDC_EP0_CTRL
#define AST_UDC_EP0_DATA_BUFF
#define AST_UDC_SETUP0
#define AST_UDC_SETUP1


/* Main control reg */
#define USB_PHY_CLK_EN
#define USB_FIFO_DYN_PWRD_EN
#define USB_EP_LONG_DESC
#define USB_BIST_TEST_PASS
#define USB_BIST_TURN_ON
#define USB_PHY_RESET_DIS
#define USB_TEST_MODE(x)
#define USB_FORCE_TIMER_HS
#define USB_FORCE_HS
#define USB_REMOTE_WAKEUP_12MS
#define USB_REMOTE_WAKEUP_EN
#define USB_AUTO_REMOTE_WAKEUP_EN
#define USB_STOP_CLK_IN_SUPEND
#define USB_UPSTREAM_FS
#define USB_UPSTREAM_EN

/* Main config reg */
#define UDC_CFG_SET_ADDR(x)
#define UDC_CFG_ADDR_MASK

/* Interrupt ctrl & status reg */
#define UDC_IRQ_EP_POOL_NAK
#define UDC_IRQ_EP_POOL_ACK_STALL
#define UDC_IRQ_BUS_RESUME
#define UDC_IRQ_BUS_SUSPEND
#define UDC_IRQ_BUS_RESET
#define UDC_IRQ_EP0_IN_DATA_NAK
#define UDC_IRQ_EP0_IN_ACK_STALL
#define UDC_IRQ_EP0_OUT_NAK
#define UDC_IRQ_EP0_OUT_ACK_STALL
#define UDC_IRQ_EP0_SETUP
#define UDC_IRQ_ACK_ALL

/* EP isr reg */
#define USB_EP3_ISR
#define USB_EP2_ISR
#define USB_EP1_ISR
#define USB_EP0_ISR
#define UDC_IRQ_EP_ACK_ALL

/*Soft reset reg */
#define ROOT_UDC_SOFT_RESET

/* USB status reg */
#define UDC_STS_HIGHSPEED

/* Programmable EP data toggle */
#define EP_TOGGLE_SET_EPNUM(x)

/* EP0 ctrl reg */
#define EP0_GET_RX_LEN(x)
#define EP0_TX_LEN(x)
#define EP0_RX_BUFF_RDY
#define EP0_TX_BUFF_RDY
#define EP0_STALL

/*************************************
 *                                   *
 * per-endpoint register definitions *
 *                                   *
 *************************************/

#define AST_UDC_EP_CONFIG
#define AST_UDC_EP_DMA_CTRL
#define AST_UDC_EP_DMA_BUFF
#define AST_UDC_EP_DMA_STS

#define AST_UDC_EP_BASE
#define AST_UDC_EP_OFFSET

/* EP config reg */
#define EP_SET_MAX_PKT(x)
#define EP_DATA_FETCH_CTRL(x)
#define EP_AUTO_DATA_DISABLE
#define EP_SET_EP_STALL
#define EP_SET_EP_NUM(x)
#define EP_SET_TYPE_MASK(x)
#define EP_TYPE_BULK
#define EP_TYPE_INT
#define EP_TYPE_ISO
#define EP_DIR_OUT
#define EP_ALLOCATED_MASK
#define EP_ENABLE

/* EP DMA ctrl reg */
#define EP_DMA_CTRL_GET_PROC_STS(x)
#define EP_DMA_CTRL_STS_RX_IDLE
#define EP_DMA_CTRL_STS_TX_IDLE
#define EP_DMA_CTRL_IN_LONG_MODE
#define EP_DMA_CTRL_RESET
#define EP_DMA_SINGLE_STAGE
#define EP_DMA_DESC_MODE

/* EP DMA status reg */
#define EP_DMA_SET_TX_SIZE(x)
#define EP_DMA_GET_TX_SIZE(x)
#define EP_DMA_GET_RPTR(x)
#define EP_DMA_GET_WPTR(x)
#define EP_DMA_SINGLE_KICK

/* EP desc reg */
#define AST_EP_DMA_DESC_INTR_ENABLE
#define AST_EP_DMA_DESC_PID_DATA0
#define AST_EP_DMA_DESC_PID_DATA2
#define AST_EP_DMA_DESC_PID_DATA1
#define AST_EP_DMA_DESC_PID_MDATA
#define EP_DESC1_IN_LEN(x)
#define AST_EP_DMA_DESC_MAX_LEN

struct ast_udc_request {};

#define to_ast_req(__req)

struct ast_dma_desc {};

struct ast_udc_ep {};

#define to_ast_ep(__ep)

struct ast_udc_dev {};

#define to_ast_dev(__g)

static const char * const ast_ep_name[] =;

#ifdef AST_UDC_DEBUG_ALL
#define AST_UDC_DEBUG
#define AST_SETUP_DEBUG
#define AST_EP_DEBUG
#define AST_ISR_DEBUG
#endif

#ifdef AST_SETUP_DEBUG
#define SETUP_DBG
#else
#define SETUP_DBG(u, fmt, ...)
#endif

#ifdef AST_EP_DEBUG
#define EP_DBG
#else
#define EP_DBG(ep, fmt, ...)
#endif

#ifdef AST_UDC_DEBUG
#define UDC_DBG
#else
#define UDC_DBG(u, fmt, ...)
#endif

#ifdef AST_ISR_DEBUG
#define ISR_DBG
#else
#define ISR_DBG(u, fmt, ...)
#endif

/*-------------------------------------------------------------------------*/
#define ast_udc_read(udc, offset)
#define ast_udc_write(udc, val, offset)

#define ast_ep_read(ep, reg)
#define ast_ep_write(ep, val, reg)

/*-------------------------------------------------------------------------*/

static void ast_udc_done(struct ast_udc_ep *ep, struct ast_udc_request *req,
			 int status)
{}

static void ast_udc_nuke(struct ast_udc_ep *ep, int status)
{}

/*
 * Stop activity on all endpoints.
 * Device controller for which EP activity is to be stopped.
 *
 * All the endpoints are stopped and any pending transfer requests if any on
 * the endpoint are terminated.
 */
static void ast_udc_stop_activity(struct ast_udc_dev *udc)
{}

static int ast_udc_ep_enable(struct usb_ep *_ep,
			     const struct usb_endpoint_descriptor *desc)
{}

static int ast_udc_ep_disable(struct usb_ep *_ep)
{}

static struct usb_request *ast_udc_ep_alloc_request(struct usb_ep *_ep,
						    gfp_t gfp_flags)
{}

static void ast_udc_ep_free_request(struct usb_ep *_ep,
				    struct usb_request *_req)
{}

static int ast_dma_descriptor_setup(struct ast_udc_ep *ep, u32 dma_buf,
				    u16 tx_len, struct ast_udc_request *req)
{}

static void ast_udc_epn_kick(struct ast_udc_ep *ep, struct ast_udc_request *req)
{}

static void ast_udc_epn_kick_desc(struct ast_udc_ep *ep,
				  struct ast_udc_request *req)
{}

static void ast_udc_ep0_queue(struct ast_udc_ep *ep,
			      struct ast_udc_request *req)
{}

static int ast_udc_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
			    gfp_t gfp_flags)
{}

static int ast_udc_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
{}

static int ast_udc_ep_set_halt(struct usb_ep *_ep, int value)
{}

static const struct usb_ep_ops ast_udc_ep_ops =;

static void ast_udc_ep0_rx(struct ast_udc_dev *udc)
{}

static void ast_udc_ep0_tx(struct ast_udc_dev *udc)
{}

static void ast_udc_ep0_out(struct ast_udc_dev *udc)
{}

static void ast_udc_ep0_in(struct ast_udc_dev *udc)
{}

static void ast_udc_epn_handle(struct ast_udc_dev *udc, u16 ep_num)
{}

static void ast_udc_epn_handle_desc(struct ast_udc_dev *udc, u16 ep_num)
{}

static void ast_udc_ep0_data_tx(struct ast_udc_dev *udc, u8 *tx_data, u32 len)
{}

static void ast_udc_getstatus(struct ast_udc_dev *udc)
{}

static void ast_udc_ep0_handle_setup(struct ast_udc_dev *udc)
{}

static irqreturn_t ast_udc_isr(int irq, void *data)
{}

static int ast_udc_gadget_getframe(struct usb_gadget *gadget)
{}

static void ast_udc_wake_work(struct work_struct *work)
{}

static void ast_udc_wakeup_all(struct ast_udc_dev *udc)
{}

static int ast_udc_wakeup(struct usb_gadget *gadget)
{}

/*
 * Activate/Deactivate link with host
 */
static int ast_udc_pullup(struct usb_gadget *gadget, int is_on)
{}

static int ast_udc_start(struct usb_gadget *gadget,
			 struct usb_gadget_driver *driver)
{}

static int ast_udc_stop(struct usb_gadget *gadget)
{}

static const struct usb_gadget_ops ast_udc_ops =;

/*
 * Support 1 Control Endpoint.
 * Support multiple programmable endpoints that can be configured to
 * Bulk IN/OUT, Interrupt IN/OUT, and Isochronous IN/OUT type endpoint.
 */
static void ast_udc_init_ep(struct ast_udc_dev *udc)
{}

static void ast_udc_init_dev(struct ast_udc_dev *udc)
{}

static void ast_udc_init_hw(struct ast_udc_dev *udc)
{}

static void ast_udc_remove(struct platform_device *pdev)
{}

static int ast_udc_probe(struct platform_device *pdev)
{}

static const struct of_device_id ast_udc_of_dt_ids[] =;

MODULE_DEVICE_TABLE(of, ast_udc_of_dt_ids);

static struct platform_driver ast_udc_driver =;

module_platform_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();