18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * amd5536.h -- header for AMD 5536 UDC high/full speed USB device controller
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2007 AMD (https://www.amd.com)
68c2ecf20Sopenharmony_ci * Author: Thomas Dahlmann
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#ifndef AMD5536UDC_H
108c2ecf20Sopenharmony_ci#define AMD5536UDC_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/* debug control */
138c2ecf20Sopenharmony_ci/* #define UDC_VERBOSE */
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include <linux/extcon.h>
168c2ecf20Sopenharmony_ci#include <linux/usb/ch9.h>
178c2ecf20Sopenharmony_ci#include <linux/usb/gadget.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci/* various constants */
208c2ecf20Sopenharmony_ci#define UDC_RDE_TIMER_SECONDS		1
218c2ecf20Sopenharmony_ci#define UDC_RDE_TIMER_DIV		10
228c2ecf20Sopenharmony_ci#define UDC_POLLSTALL_TIMER_USECONDS	500
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/* Hs AMD5536 chip rev. */
258c2ecf20Sopenharmony_ci#define UDC_HSA0_REV 1
268c2ecf20Sopenharmony_ci#define UDC_HSB1_REV 2
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Broadcom chip rev. */
298c2ecf20Sopenharmony_ci#define UDC_BCM_REV 10
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/*
328c2ecf20Sopenharmony_ci * SETUP usb commands
338c2ecf20Sopenharmony_ci * needed, because some SETUP's are handled in hw, but must be passed to
348c2ecf20Sopenharmony_ci * gadget driver above
358c2ecf20Sopenharmony_ci * SET_CONFIG
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_ci#define UDC_SETCONFIG_DWORD0			0x00000900
388c2ecf20Sopenharmony_ci#define UDC_SETCONFIG_DWORD0_VALUE_MASK		0xffff0000
398c2ecf20Sopenharmony_ci#define UDC_SETCONFIG_DWORD0_VALUE_OFS		16
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci#define UDC_SETCONFIG_DWORD1			0x00000000
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* SET_INTERFACE */
448c2ecf20Sopenharmony_ci#define UDC_SETINTF_DWORD0			0x00000b00
458c2ecf20Sopenharmony_ci#define UDC_SETINTF_DWORD0_ALT_MASK		0xffff0000
468c2ecf20Sopenharmony_ci#define UDC_SETINTF_DWORD0_ALT_OFS		16
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci#define UDC_SETINTF_DWORD1			0x00000000
498c2ecf20Sopenharmony_ci#define UDC_SETINTF_DWORD1_INTF_MASK		0x0000ffff
508c2ecf20Sopenharmony_ci#define UDC_SETINTF_DWORD1_INTF_OFS		0
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci/* Mass storage reset */
538c2ecf20Sopenharmony_ci#define UDC_MSCRES_DWORD0			0x0000ff21
548c2ecf20Sopenharmony_ci#define UDC_MSCRES_DWORD1			0x00000000
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* Global CSR's -------------------------------------------------------------*/
578c2ecf20Sopenharmony_ci#define UDC_CSR_ADDR				0x500
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* EP NE bits */
608c2ecf20Sopenharmony_ci/* EP number */
618c2ecf20Sopenharmony_ci#define UDC_CSR_NE_NUM_MASK			0x0000000f
628c2ecf20Sopenharmony_ci#define UDC_CSR_NE_NUM_OFS			0
638c2ecf20Sopenharmony_ci/* EP direction */
648c2ecf20Sopenharmony_ci#define UDC_CSR_NE_DIR_MASK			0x00000010
658c2ecf20Sopenharmony_ci#define UDC_CSR_NE_DIR_OFS			4
668c2ecf20Sopenharmony_ci/* EP type */
678c2ecf20Sopenharmony_ci#define UDC_CSR_NE_TYPE_MASK			0x00000060
688c2ecf20Sopenharmony_ci#define UDC_CSR_NE_TYPE_OFS			5
698c2ecf20Sopenharmony_ci/* EP config number */
708c2ecf20Sopenharmony_ci#define UDC_CSR_NE_CFG_MASK			0x00000780
718c2ecf20Sopenharmony_ci#define UDC_CSR_NE_CFG_OFS			7
728c2ecf20Sopenharmony_ci/* EP interface number */
738c2ecf20Sopenharmony_ci#define UDC_CSR_NE_INTF_MASK			0x00007800
748c2ecf20Sopenharmony_ci#define UDC_CSR_NE_INTF_OFS			11
758c2ecf20Sopenharmony_ci/* EP alt setting */
768c2ecf20Sopenharmony_ci#define UDC_CSR_NE_ALT_MASK			0x00078000
778c2ecf20Sopenharmony_ci#define UDC_CSR_NE_ALT_OFS			15
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/* max pkt */
808c2ecf20Sopenharmony_ci#define UDC_CSR_NE_MAX_PKT_MASK			0x3ff80000
818c2ecf20Sopenharmony_ci#define UDC_CSR_NE_MAX_PKT_OFS			19
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* Device Config Register ---------------------------------------------------*/
848c2ecf20Sopenharmony_ci#define UDC_DEVCFG_ADDR				0x400
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SOFTRESET			31
878c2ecf20Sopenharmony_ci#define UDC_DEVCFG_HNPSFEN			30
888c2ecf20Sopenharmony_ci#define UDC_DEVCFG_DMARST			29
898c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SET_DESC			18
908c2ecf20Sopenharmony_ci#define UDC_DEVCFG_CSR_PRG			17
918c2ecf20Sopenharmony_ci#define UDC_DEVCFG_STATUS			7
928c2ecf20Sopenharmony_ci#define UDC_DEVCFG_DIR				6
938c2ecf20Sopenharmony_ci#define UDC_DEVCFG_PI				5
948c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SS				4
958c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SP				3
968c2ecf20Sopenharmony_ci#define UDC_DEVCFG_RWKP				2
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SPD_MASK			0x3
998c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SPD_OFS			0
1008c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SPD_HS			0x0
1018c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SPD_FS			0x1
1028c2ecf20Sopenharmony_ci#define UDC_DEVCFG_SPD_LS			0x2
1038c2ecf20Sopenharmony_ci/*#define UDC_DEVCFG_SPD_FS			0x3*/
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci/* Device Control Register --------------------------------------------------*/
1078c2ecf20Sopenharmony_ci#define UDC_DEVCTL_ADDR				0x404
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define UDC_DEVCTL_THLEN_MASK			0xff000000
1108c2ecf20Sopenharmony_ci#define UDC_DEVCTL_THLEN_OFS			24
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#define UDC_DEVCTL_BRLEN_MASK			0x00ff0000
1138c2ecf20Sopenharmony_ci#define UDC_DEVCTL_BRLEN_OFS			16
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci#define UDC_DEVCTL_SRX_FLUSH			14
1168c2ecf20Sopenharmony_ci#define UDC_DEVCTL_CSR_DONE			13
1178c2ecf20Sopenharmony_ci#define UDC_DEVCTL_DEVNAK			12
1188c2ecf20Sopenharmony_ci#define UDC_DEVCTL_SD				10
1198c2ecf20Sopenharmony_ci#define UDC_DEVCTL_MODE				9
1208c2ecf20Sopenharmony_ci#define UDC_DEVCTL_BREN				8
1218c2ecf20Sopenharmony_ci#define UDC_DEVCTL_THE				7
1228c2ecf20Sopenharmony_ci#define UDC_DEVCTL_BF				6
1238c2ecf20Sopenharmony_ci#define UDC_DEVCTL_BE				5
1248c2ecf20Sopenharmony_ci#define UDC_DEVCTL_DU				4
1258c2ecf20Sopenharmony_ci#define UDC_DEVCTL_TDE				3
1268c2ecf20Sopenharmony_ci#define UDC_DEVCTL_RDE				2
1278c2ecf20Sopenharmony_ci#define UDC_DEVCTL_RES				0
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci/* Device Status Register ---------------------------------------------------*/
1318c2ecf20Sopenharmony_ci#define UDC_DEVSTS_ADDR				0x408
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci#define UDC_DEVSTS_TS_MASK			0xfffc0000
1348c2ecf20Sopenharmony_ci#define UDC_DEVSTS_TS_OFS			18
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#define UDC_DEVSTS_SESSVLD			17
1378c2ecf20Sopenharmony_ci#define UDC_DEVSTS_PHY_ERROR			16
1388c2ecf20Sopenharmony_ci#define UDC_DEVSTS_RXFIFO_EMPTY			15
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci#define UDC_DEVSTS_ENUM_SPEED_MASK		0x00006000
1418c2ecf20Sopenharmony_ci#define UDC_DEVSTS_ENUM_SPEED_OFS		13
1428c2ecf20Sopenharmony_ci#define UDC_DEVSTS_ENUM_SPEED_FULL		1
1438c2ecf20Sopenharmony_ci#define UDC_DEVSTS_ENUM_SPEED_HIGH		0
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci#define UDC_DEVSTS_SUSP				12
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define UDC_DEVSTS_ALT_MASK			0x00000f00
1488c2ecf20Sopenharmony_ci#define UDC_DEVSTS_ALT_OFS			8
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#define UDC_DEVSTS_INTF_MASK			0x000000f0
1518c2ecf20Sopenharmony_ci#define UDC_DEVSTS_INTF_OFS			4
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci#define UDC_DEVSTS_CFG_MASK			0x0000000f
1548c2ecf20Sopenharmony_ci#define UDC_DEVSTS_CFG_OFS			0
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci/* Device Interrupt Register ------------------------------------------------*/
1588c2ecf20Sopenharmony_ci#define UDC_DEVINT_ADDR				0x40c
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci#define UDC_DEVINT_SVC				7
1618c2ecf20Sopenharmony_ci#define UDC_DEVINT_ENUM				6
1628c2ecf20Sopenharmony_ci#define UDC_DEVINT_SOF				5
1638c2ecf20Sopenharmony_ci#define UDC_DEVINT_US				4
1648c2ecf20Sopenharmony_ci#define UDC_DEVINT_UR				3
1658c2ecf20Sopenharmony_ci#define UDC_DEVINT_ES				2
1668c2ecf20Sopenharmony_ci#define UDC_DEVINT_SI				1
1678c2ecf20Sopenharmony_ci#define UDC_DEVINT_SC				0
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci/* Device Interrupt Mask Register -------------------------------------------*/
1708c2ecf20Sopenharmony_ci#define UDC_DEVINT_MSK_ADDR			0x410
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci#define UDC_DEVINT_MSK				0x7f
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci/* Endpoint Interrupt Register ----------------------------------------------*/
1758c2ecf20Sopenharmony_ci#define UDC_EPINT_ADDR				0x414
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci#define UDC_EPINT_OUT_MASK			0xffff0000
1788c2ecf20Sopenharmony_ci#define UDC_EPINT_OUT_OFS			16
1798c2ecf20Sopenharmony_ci#define UDC_EPINT_IN_MASK			0x0000ffff
1808c2ecf20Sopenharmony_ci#define UDC_EPINT_IN_OFS			0
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci#define UDC_EPINT_IN_EP0			0
1838c2ecf20Sopenharmony_ci#define UDC_EPINT_IN_EP1			1
1848c2ecf20Sopenharmony_ci#define UDC_EPINT_IN_EP2			2
1858c2ecf20Sopenharmony_ci#define UDC_EPINT_IN_EP3			3
1868c2ecf20Sopenharmony_ci#define UDC_EPINT_OUT_EP0			16
1878c2ecf20Sopenharmony_ci#define UDC_EPINT_OUT_EP1			17
1888c2ecf20Sopenharmony_ci#define UDC_EPINT_OUT_EP2			18
1898c2ecf20Sopenharmony_ci#define UDC_EPINT_OUT_EP3			19
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci#define UDC_EPINT_EP0_ENABLE_MSK		0x001e001e
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci/* Endpoint Interrupt Mask Register -----------------------------------------*/
1948c2ecf20Sopenharmony_ci#define UDC_EPINT_MSK_ADDR			0x418
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci#define UDC_EPINT_OUT_MSK_MASK			0xffff0000
1978c2ecf20Sopenharmony_ci#define UDC_EPINT_OUT_MSK_OFS			16
1988c2ecf20Sopenharmony_ci#define UDC_EPINT_IN_MSK_MASK			0x0000ffff
1998c2ecf20Sopenharmony_ci#define UDC_EPINT_IN_MSK_OFS			0
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci#define UDC_EPINT_MSK_DISABLE_ALL		0xffffffff
2028c2ecf20Sopenharmony_ci/* mask non-EP0 endpoints */
2038c2ecf20Sopenharmony_ci#define UDC_EPDATAINT_MSK_DISABLE		0xfffefffe
2048c2ecf20Sopenharmony_ci/* mask all dev interrupts */
2058c2ecf20Sopenharmony_ci#define UDC_DEV_MSK_DISABLE			0x7f
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci/* Endpoint-specific CSR's --------------------------------------------------*/
2088c2ecf20Sopenharmony_ci#define UDC_EPREGS_ADDR				0x0
2098c2ecf20Sopenharmony_ci#define UDC_EPIN_REGS_ADDR			0x0
2108c2ecf20Sopenharmony_ci#define UDC_EPOUT_REGS_ADDR			0x200
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci#define UDC_EPCTL_ADDR				0x0
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci#define UDC_EPCTL_RRDY				9
2158c2ecf20Sopenharmony_ci#define UDC_EPCTL_CNAK				8
2168c2ecf20Sopenharmony_ci#define UDC_EPCTL_SNAK				7
2178c2ecf20Sopenharmony_ci#define UDC_EPCTL_NAK				6
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci#define UDC_EPCTL_ET_MASK			0x00000030
2208c2ecf20Sopenharmony_ci#define UDC_EPCTL_ET_OFS			4
2218c2ecf20Sopenharmony_ci#define UDC_EPCTL_ET_CONTROL			0
2228c2ecf20Sopenharmony_ci#define UDC_EPCTL_ET_ISO			1
2238c2ecf20Sopenharmony_ci#define UDC_EPCTL_ET_BULK			2
2248c2ecf20Sopenharmony_ci#define UDC_EPCTL_ET_INTERRUPT			3
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci#define UDC_EPCTL_P				3
2278c2ecf20Sopenharmony_ci#define UDC_EPCTL_SN				2
2288c2ecf20Sopenharmony_ci#define UDC_EPCTL_F				1
2298c2ecf20Sopenharmony_ci#define UDC_EPCTL_S				0
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci/* Endpoint Status Registers ------------------------------------------------*/
2328c2ecf20Sopenharmony_ci#define UDC_EPSTS_ADDR				0x4
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci#define UDC_EPSTS_RX_PKT_SIZE_MASK		0x007ff800
2358c2ecf20Sopenharmony_ci#define UDC_EPSTS_RX_PKT_SIZE_OFS		11
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci#define UDC_EPSTS_TDC				10
2388c2ecf20Sopenharmony_ci#define UDC_EPSTS_HE				9
2398c2ecf20Sopenharmony_ci#define UDC_EPSTS_BNA				7
2408c2ecf20Sopenharmony_ci#define UDC_EPSTS_IN				6
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci#define UDC_EPSTS_OUT_MASK			0x00000030
2438c2ecf20Sopenharmony_ci#define UDC_EPSTS_OUT_OFS			4
2448c2ecf20Sopenharmony_ci#define UDC_EPSTS_OUT_DATA			1
2458c2ecf20Sopenharmony_ci#define UDC_EPSTS_OUT_DATA_CLEAR		0x10
2468c2ecf20Sopenharmony_ci#define UDC_EPSTS_OUT_SETUP			2
2478c2ecf20Sopenharmony_ci#define UDC_EPSTS_OUT_SETUP_CLEAR		0x20
2488c2ecf20Sopenharmony_ci#define UDC_EPSTS_OUT_CLEAR			0x30
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci/* Endpoint Buffer Size IN/ Receive Packet Frame Number OUT Registers ------*/
2518c2ecf20Sopenharmony_ci#define UDC_EPIN_BUFF_SIZE_ADDR			0x8
2528c2ecf20Sopenharmony_ci#define UDC_EPOUT_FRAME_NUMBER_ADDR		0x8
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci#define UDC_EPIN_BUFF_SIZE_MASK			0x0000ffff
2558c2ecf20Sopenharmony_ci#define UDC_EPIN_BUFF_SIZE_OFS			0
2568c2ecf20Sopenharmony_ci/* EP0in txfifo = 128 bytes*/
2578c2ecf20Sopenharmony_ci#define UDC_EPIN0_BUFF_SIZE			32
2588c2ecf20Sopenharmony_ci/* EP0in fullspeed txfifo = 128 bytes*/
2598c2ecf20Sopenharmony_ci#define UDC_FS_EPIN0_BUFF_SIZE			32
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci/* fifo size mult = fifo size / max packet */
2628c2ecf20Sopenharmony_ci#define UDC_EPIN_BUFF_SIZE_MULT			2
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci/* EPin data fifo size = 1024 bytes DOUBLE BUFFERING */
2658c2ecf20Sopenharmony_ci#define UDC_EPIN_BUFF_SIZE			256
2668c2ecf20Sopenharmony_ci/* EPin small INT data fifo size = 128 bytes */
2678c2ecf20Sopenharmony_ci#define UDC_EPIN_SMALLINT_BUFF_SIZE		32
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci/* EPin fullspeed data fifo size = 128 bytes DOUBLE BUFFERING */
2708c2ecf20Sopenharmony_ci#define UDC_FS_EPIN_BUFF_SIZE			32
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci#define UDC_EPOUT_FRAME_NUMBER_MASK		0x0000ffff
2738c2ecf20Sopenharmony_ci#define UDC_EPOUT_FRAME_NUMBER_OFS		0
2748c2ecf20Sopenharmony_ci
2758c2ecf20Sopenharmony_ci/* Endpoint Buffer Size OUT/Max Packet Size Registers -----------------------*/
2768c2ecf20Sopenharmony_ci#define UDC_EPOUT_BUFF_SIZE_ADDR		0x0c
2778c2ecf20Sopenharmony_ci#define UDC_EP_MAX_PKT_SIZE_ADDR		0x0c
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci#define UDC_EPOUT_BUFF_SIZE_MASK		0xffff0000
2808c2ecf20Sopenharmony_ci#define UDC_EPOUT_BUFF_SIZE_OFS			16
2818c2ecf20Sopenharmony_ci#define UDC_EP_MAX_PKT_SIZE_MASK		0x0000ffff
2828c2ecf20Sopenharmony_ci#define UDC_EP_MAX_PKT_SIZE_OFS			0
2838c2ecf20Sopenharmony_ci/* EP0in max packet size = 64 bytes */
2848c2ecf20Sopenharmony_ci#define UDC_EP0IN_MAX_PKT_SIZE			64
2858c2ecf20Sopenharmony_ci/* EP0out max packet size = 64 bytes */
2868c2ecf20Sopenharmony_ci#define UDC_EP0OUT_MAX_PKT_SIZE			64
2878c2ecf20Sopenharmony_ci/* EP0in fullspeed max packet size = 64 bytes */
2888c2ecf20Sopenharmony_ci#define UDC_FS_EP0IN_MAX_PKT_SIZE		64
2898c2ecf20Sopenharmony_ci/* EP0out fullspeed max packet size = 64 bytes */
2908c2ecf20Sopenharmony_ci#define UDC_FS_EP0OUT_MAX_PKT_SIZE		64
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci/*
2938c2ecf20Sopenharmony_ci * Endpoint dma descriptors ------------------------------------------------
2948c2ecf20Sopenharmony_ci *
2958c2ecf20Sopenharmony_ci * Setup data, Status dword
2968c2ecf20Sopenharmony_ci */
2978c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_CFG_MASK		0x0fff0000
2988c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_CFG_OFS			16
2998c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_CFG_ALT_MASK		0x000f0000
3008c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_CFG_ALT_OFS		16
3018c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_CFG_INTF_MASK		0x00f00000
3028c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_CFG_INTF_OFS		20
3038c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_CFG_NUM_MASK		0x0f000000
3048c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_CFG_NUM_OFS		24
3058c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_RX_MASK			0x30000000
3068c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_RX_OFS			28
3078c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_BS_MASK			0xc0000000
3088c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_BS_OFS			30
3098c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_BS_HOST_READY		0
3108c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_BS_DMA_BUSY		1
3118c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_BS_DMA_DONE		2
3128c2ecf20Sopenharmony_ci#define UDC_DMA_STP_STS_BS_HOST_BUSY		3
3138c2ecf20Sopenharmony_ci/* IN data, Status dword */
3148c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_TXBYTES_MASK		0x0000ffff
3158c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_TXBYTES_OFS		0
3168c2ecf20Sopenharmony_ci#define	UDC_DMA_IN_STS_FRAMENUM_MASK		0x07ff0000
3178c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_FRAMENUM_OFS		0
3188c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_L			27
3198c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_TX_MASK			0x30000000
3208c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_TX_OFS			28
3218c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_BS_MASK			0xc0000000
3228c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_BS_OFS			30
3238c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_BS_HOST_READY		0
3248c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_BS_DMA_BUSY		1
3258c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_BS_DMA_DONE		2
3268c2ecf20Sopenharmony_ci#define UDC_DMA_IN_STS_BS_HOST_BUSY		3
3278c2ecf20Sopenharmony_ci/* OUT data, Status dword */
3288c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_RXBYTES_MASK		0x0000ffff
3298c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_RXBYTES_OFS		0
3308c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_FRAMENUM_MASK		0x07ff0000
3318c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_FRAMENUM_OFS		0
3328c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_L			27
3338c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_RX_MASK			0x30000000
3348c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_RX_OFS			28
3358c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_BS_MASK			0xc0000000
3368c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_BS_OFS			30
3378c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_BS_HOST_READY		0
3388c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_BS_DMA_BUSY		1
3398c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_BS_DMA_DONE		2
3408c2ecf20Sopenharmony_ci#define UDC_DMA_OUT_STS_BS_HOST_BUSY		3
3418c2ecf20Sopenharmony_ci/* max ep0in packet */
3428c2ecf20Sopenharmony_ci#define UDC_EP0IN_MAXPACKET			1000
3438c2ecf20Sopenharmony_ci/* max dma packet */
3448c2ecf20Sopenharmony_ci#define UDC_DMA_MAXPACKET			65536
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_ci/* un-usable DMA address */
3478c2ecf20Sopenharmony_ci#define DMA_DONT_USE				(~(dma_addr_t) 0 )
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci/* other Endpoint register addresses and values-----------------------------*/
3508c2ecf20Sopenharmony_ci#define UDC_EP_SUBPTR_ADDR			0x10
3518c2ecf20Sopenharmony_ci#define UDC_EP_DESPTR_ADDR			0x14
3528c2ecf20Sopenharmony_ci#define UDC_EP_WRITE_CONFIRM_ADDR		0x1c
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci/* EP number as layouted in AHB space */
3558c2ecf20Sopenharmony_ci#define UDC_EP_NUM				32
3568c2ecf20Sopenharmony_ci#define UDC_EPIN_NUM				16
3578c2ecf20Sopenharmony_ci#define UDC_EPIN_NUM_USED			5
3588c2ecf20Sopenharmony_ci#define UDC_EPOUT_NUM				16
3598c2ecf20Sopenharmony_ci/* EP number of EP's really used = EP0 + 8 data EP's */
3608c2ecf20Sopenharmony_ci#define UDC_USED_EP_NUM				9
3618c2ecf20Sopenharmony_ci/* UDC CSR regs are aligned but AHB regs not - offset for OUT EP's */
3628c2ecf20Sopenharmony_ci#define UDC_CSR_EP_OUT_IX_OFS			12
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci#define UDC_EP0OUT_IX				16
3658c2ecf20Sopenharmony_ci#define UDC_EP0IN_IX				0
3668c2ecf20Sopenharmony_ci
3678c2ecf20Sopenharmony_ci/* Rx fifo address and size = 1k -------------------------------------------*/
3688c2ecf20Sopenharmony_ci#define UDC_RXFIFO_ADDR				0x800
3698c2ecf20Sopenharmony_ci#define UDC_RXFIFO_SIZE				0x400
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ci/* Tx fifo address and size = 1.5k -----------------------------------------*/
3728c2ecf20Sopenharmony_ci#define UDC_TXFIFO_ADDR				0xc00
3738c2ecf20Sopenharmony_ci#define UDC_TXFIFO_SIZE				0x600
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_ci/* default data endpoints --------------------------------------------------*/
3768c2ecf20Sopenharmony_ci#define UDC_EPIN_STATUS_IX			1
3778c2ecf20Sopenharmony_ci#define UDC_EPIN_IX				2
3788c2ecf20Sopenharmony_ci#define UDC_EPOUT_IX				18
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci/* general constants -------------------------------------------------------*/
3818c2ecf20Sopenharmony_ci#define UDC_DWORD_BYTES				4
3828c2ecf20Sopenharmony_ci#define UDC_BITS_PER_BYTE_SHIFT			3
3838c2ecf20Sopenharmony_ci#define UDC_BYTE_MASK				0xff
3848c2ecf20Sopenharmony_ci#define UDC_BITS_PER_BYTE			8
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci/*---------------------------------------------------------------------------*/
3878c2ecf20Sopenharmony_ci/* UDC CSR's */
3888c2ecf20Sopenharmony_cistruct udc_csrs {
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci	/* sca - setup command address */
3918c2ecf20Sopenharmony_ci	u32 sca;
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ci	/* ep ne's */
3948c2ecf20Sopenharmony_ci	u32 ne[UDC_USED_EP_NUM];
3958c2ecf20Sopenharmony_ci} __attribute__ ((packed));
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci/* AHB subsystem CSR registers */
3988c2ecf20Sopenharmony_cistruct udc_regs {
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci	/* device configuration */
4018c2ecf20Sopenharmony_ci	u32 cfg;
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci	/* device control */
4048c2ecf20Sopenharmony_ci	u32 ctl;
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ci	/* device status */
4078c2ecf20Sopenharmony_ci	u32 sts;
4088c2ecf20Sopenharmony_ci
4098c2ecf20Sopenharmony_ci	/* device interrupt */
4108c2ecf20Sopenharmony_ci	u32 irqsts;
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	/* device interrupt mask */
4138c2ecf20Sopenharmony_ci	u32 irqmsk;
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci	/* endpoint interrupt */
4168c2ecf20Sopenharmony_ci	u32 ep_irqsts;
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_ci	/* endpoint interrupt mask */
4198c2ecf20Sopenharmony_ci	u32 ep_irqmsk;
4208c2ecf20Sopenharmony_ci} __attribute__ ((packed));
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci/* endpoint specific registers */
4238c2ecf20Sopenharmony_cistruct udc_ep_regs {
4248c2ecf20Sopenharmony_ci
4258c2ecf20Sopenharmony_ci	/* endpoint control */
4268c2ecf20Sopenharmony_ci	u32 ctl;
4278c2ecf20Sopenharmony_ci
4288c2ecf20Sopenharmony_ci	/* endpoint status */
4298c2ecf20Sopenharmony_ci	u32 sts;
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	/* endpoint buffer size in/ receive packet frame number out */
4328c2ecf20Sopenharmony_ci	u32 bufin_framenum;
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_ci	/* endpoint buffer size out/max packet size */
4358c2ecf20Sopenharmony_ci	u32 bufout_maxpkt;
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci	/* endpoint setup buffer pointer */
4388c2ecf20Sopenharmony_ci	u32 subptr;
4398c2ecf20Sopenharmony_ci
4408c2ecf20Sopenharmony_ci	/* endpoint data descriptor pointer */
4418c2ecf20Sopenharmony_ci	u32 desptr;
4428c2ecf20Sopenharmony_ci
4438c2ecf20Sopenharmony_ci	/* reserved */
4448c2ecf20Sopenharmony_ci	u32 reserved;
4458c2ecf20Sopenharmony_ci
4468c2ecf20Sopenharmony_ci	/* write/read confirmation */
4478c2ecf20Sopenharmony_ci	u32 confirm;
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci} __attribute__ ((packed));
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci/* control data DMA desc */
4528c2ecf20Sopenharmony_cistruct udc_stp_dma {
4538c2ecf20Sopenharmony_ci	/* status quadlet */
4548c2ecf20Sopenharmony_ci	u32	status;
4558c2ecf20Sopenharmony_ci	/* reserved */
4568c2ecf20Sopenharmony_ci	u32	_reserved;
4578c2ecf20Sopenharmony_ci	/* first setup word */
4588c2ecf20Sopenharmony_ci	u32	data12;
4598c2ecf20Sopenharmony_ci	/* second setup word */
4608c2ecf20Sopenharmony_ci	u32	data34;
4618c2ecf20Sopenharmony_ci} __attribute__ ((aligned (16)));
4628c2ecf20Sopenharmony_ci
4638c2ecf20Sopenharmony_ci/* normal data DMA desc */
4648c2ecf20Sopenharmony_cistruct udc_data_dma {
4658c2ecf20Sopenharmony_ci	/* status quadlet */
4668c2ecf20Sopenharmony_ci	u32	status;
4678c2ecf20Sopenharmony_ci	/* reserved */
4688c2ecf20Sopenharmony_ci	u32	_reserved;
4698c2ecf20Sopenharmony_ci	/* buffer pointer */
4708c2ecf20Sopenharmony_ci	u32	bufptr;
4718c2ecf20Sopenharmony_ci	/* next descriptor pointer */
4728c2ecf20Sopenharmony_ci	u32	next;
4738c2ecf20Sopenharmony_ci} __attribute__ ((aligned (16)));
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci/* request packet */
4768c2ecf20Sopenharmony_cistruct udc_request {
4778c2ecf20Sopenharmony_ci	/* embedded gadget ep */
4788c2ecf20Sopenharmony_ci	struct usb_request		req;
4798c2ecf20Sopenharmony_ci
4808c2ecf20Sopenharmony_ci	/* flags */
4818c2ecf20Sopenharmony_ci	unsigned			dma_going : 1,
4828c2ecf20Sopenharmony_ci					dma_done : 1;
4838c2ecf20Sopenharmony_ci	/* phys. address */
4848c2ecf20Sopenharmony_ci	dma_addr_t			td_phys;
4858c2ecf20Sopenharmony_ci	/* first dma desc. of chain */
4868c2ecf20Sopenharmony_ci	struct udc_data_dma		*td_data;
4878c2ecf20Sopenharmony_ci	/* last dma desc. of chain */
4888c2ecf20Sopenharmony_ci	struct udc_data_dma		*td_data_last;
4898c2ecf20Sopenharmony_ci	struct list_head		queue;
4908c2ecf20Sopenharmony_ci
4918c2ecf20Sopenharmony_ci	/* chain length */
4928c2ecf20Sopenharmony_ci	unsigned			chain_len;
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci};
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ci/* UDC specific endpoint parameters */
4978c2ecf20Sopenharmony_cistruct udc_ep {
4988c2ecf20Sopenharmony_ci	struct usb_ep			ep;
4998c2ecf20Sopenharmony_ci	struct udc_ep_regs __iomem	*regs;
5008c2ecf20Sopenharmony_ci	u32 __iomem			*txfifo;
5018c2ecf20Sopenharmony_ci	u32 __iomem			*dma;
5028c2ecf20Sopenharmony_ci	dma_addr_t			td_phys;
5038c2ecf20Sopenharmony_ci	dma_addr_t			td_stp_dma;
5048c2ecf20Sopenharmony_ci	struct udc_stp_dma		*td_stp;
5058c2ecf20Sopenharmony_ci	struct udc_data_dma		*td;
5068c2ecf20Sopenharmony_ci	/* temp request */
5078c2ecf20Sopenharmony_ci	struct udc_request		*req;
5088c2ecf20Sopenharmony_ci	unsigned			req_used;
5098c2ecf20Sopenharmony_ci	unsigned			req_completed;
5108c2ecf20Sopenharmony_ci	/* dummy DMA desc for BNA dummy */
5118c2ecf20Sopenharmony_ci	struct udc_request		*bna_dummy_req;
5128c2ecf20Sopenharmony_ci	unsigned			bna_occurred;
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_ci	/* NAK state */
5158c2ecf20Sopenharmony_ci	unsigned			naking;
5168c2ecf20Sopenharmony_ci
5178c2ecf20Sopenharmony_ci	struct udc			*dev;
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	/* queue for requests */
5208c2ecf20Sopenharmony_ci	struct list_head		queue;
5218c2ecf20Sopenharmony_ci	unsigned			halted;
5228c2ecf20Sopenharmony_ci	unsigned			cancel_transfer;
5238c2ecf20Sopenharmony_ci	unsigned			num : 5,
5248c2ecf20Sopenharmony_ci					fifo_depth : 14,
5258c2ecf20Sopenharmony_ci					in : 1;
5268c2ecf20Sopenharmony_ci};
5278c2ecf20Sopenharmony_ci
5288c2ecf20Sopenharmony_ci/* device struct */
5298c2ecf20Sopenharmony_cistruct udc {
5308c2ecf20Sopenharmony_ci	struct usb_gadget		gadget;
5318c2ecf20Sopenharmony_ci	spinlock_t			lock;	/* protects all state */
5328c2ecf20Sopenharmony_ci	/* all endpoints */
5338c2ecf20Sopenharmony_ci	struct udc_ep			ep[UDC_EP_NUM];
5348c2ecf20Sopenharmony_ci	struct usb_gadget_driver	*driver;
5358c2ecf20Sopenharmony_ci	/* operational flags */
5368c2ecf20Sopenharmony_ci	unsigned			stall_ep0in : 1,
5378c2ecf20Sopenharmony_ci					waiting_zlp_ack_ep0in : 1,
5388c2ecf20Sopenharmony_ci					set_cfg_not_acked : 1,
5398c2ecf20Sopenharmony_ci					data_ep_enabled : 1,
5408c2ecf20Sopenharmony_ci					data_ep_queued : 1,
5418c2ecf20Sopenharmony_ci					sys_suspended : 1,
5428c2ecf20Sopenharmony_ci					connected;
5438c2ecf20Sopenharmony_ci
5448c2ecf20Sopenharmony_ci	u16				chiprev;
5458c2ecf20Sopenharmony_ci
5468c2ecf20Sopenharmony_ci	/* registers */
5478c2ecf20Sopenharmony_ci	struct pci_dev			*pdev;
5488c2ecf20Sopenharmony_ci	struct udc_csrs __iomem		*csr;
5498c2ecf20Sopenharmony_ci	struct udc_regs __iomem		*regs;
5508c2ecf20Sopenharmony_ci	struct udc_ep_regs __iomem	*ep_regs;
5518c2ecf20Sopenharmony_ci	u32 __iomem			*rxfifo;
5528c2ecf20Sopenharmony_ci	u32 __iomem			*txfifo;
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_ci	/* DMA desc pools */
5558c2ecf20Sopenharmony_ci	struct dma_pool			*data_requests;
5568c2ecf20Sopenharmony_ci	struct dma_pool			*stp_requests;
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ci	/* device data */
5598c2ecf20Sopenharmony_ci	unsigned long			phys_addr;
5608c2ecf20Sopenharmony_ci	void __iomem			*virt_addr;
5618c2ecf20Sopenharmony_ci	unsigned			irq;
5628c2ecf20Sopenharmony_ci
5638c2ecf20Sopenharmony_ci	/* states */
5648c2ecf20Sopenharmony_ci	u16				cur_config;
5658c2ecf20Sopenharmony_ci	u16				cur_intf;
5668c2ecf20Sopenharmony_ci	u16				cur_alt;
5678c2ecf20Sopenharmony_ci
5688c2ecf20Sopenharmony_ci	/* for platform device and extcon support */
5698c2ecf20Sopenharmony_ci	struct device			*dev;
5708c2ecf20Sopenharmony_ci	struct phy			*udc_phy;
5718c2ecf20Sopenharmony_ci	struct extcon_dev		*edev;
5728c2ecf20Sopenharmony_ci	struct extcon_specific_cable_nb	extcon_nb;
5738c2ecf20Sopenharmony_ci	struct notifier_block		nb;
5748c2ecf20Sopenharmony_ci	struct delayed_work		drd_work;
5758c2ecf20Sopenharmony_ci	struct workqueue_struct		*drd_wq;
5768c2ecf20Sopenharmony_ci	u32				conn_type;
5778c2ecf20Sopenharmony_ci};
5788c2ecf20Sopenharmony_ci
5798c2ecf20Sopenharmony_ci#define to_amd5536_udc(g)	(container_of((g), struct udc, gadget))
5808c2ecf20Sopenharmony_ci
5818c2ecf20Sopenharmony_ci/* setup request data */
5828c2ecf20Sopenharmony_ciunion udc_setup_data {
5838c2ecf20Sopenharmony_ci	u32			data[2];
5848c2ecf20Sopenharmony_ci	struct usb_ctrlrequest	request;
5858c2ecf20Sopenharmony_ci};
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci/* Function declarations */
5888c2ecf20Sopenharmony_ciint udc_enable_dev_setup_interrupts(struct udc *dev);
5898c2ecf20Sopenharmony_ciint udc_mask_unused_interrupts(struct udc *dev);
5908c2ecf20Sopenharmony_ciirqreturn_t udc_irq(int irq, void *pdev);
5918c2ecf20Sopenharmony_civoid gadget_release(struct device *pdev);
5928c2ecf20Sopenharmony_civoid empty_req_queue(struct udc_ep *ep);
5938c2ecf20Sopenharmony_civoid udc_basic_init(struct udc *dev);
5948c2ecf20Sopenharmony_civoid free_dma_pools(struct udc *dev);
5958c2ecf20Sopenharmony_ciint init_dma_pools(struct udc *dev);
5968c2ecf20Sopenharmony_civoid udc_remove(struct udc *dev);
5978c2ecf20Sopenharmony_ciint udc_probe(struct udc *dev);
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ci/* DMA usage flag */
6008c2ecf20Sopenharmony_cistatic bool use_dma = 1;
6018c2ecf20Sopenharmony_ci/* packet per buffer dma */
6028c2ecf20Sopenharmony_cistatic bool use_dma_ppb = 1;
6038c2ecf20Sopenharmony_ci/* with per descr. update */
6048c2ecf20Sopenharmony_cistatic bool use_dma_ppb_du;
6058c2ecf20Sopenharmony_ci/* full speed only mode */
6068c2ecf20Sopenharmony_cistatic bool use_fullspeed;
6078c2ecf20Sopenharmony_ci
6088c2ecf20Sopenharmony_ci/* module parameters */
6098c2ecf20Sopenharmony_cimodule_param(use_dma, bool, S_IRUGO);
6108c2ecf20Sopenharmony_ciMODULE_PARM_DESC(use_dma, "true for DMA");
6118c2ecf20Sopenharmony_cimodule_param(use_dma_ppb, bool, S_IRUGO);
6128c2ecf20Sopenharmony_ciMODULE_PARM_DESC(use_dma_ppb, "true for DMA in packet per buffer mode");
6138c2ecf20Sopenharmony_cimodule_param(use_dma_ppb_du, bool, S_IRUGO);
6148c2ecf20Sopenharmony_ciMODULE_PARM_DESC(use_dma_ppb_du,
6158c2ecf20Sopenharmony_ci	"true for DMA in packet per buffer mode with descriptor update");
6168c2ecf20Sopenharmony_cimodule_param(use_fullspeed, bool, S_IRUGO);
6178c2ecf20Sopenharmony_ciMODULE_PARM_DESC(use_fullspeed, "true for fullspeed only");
6188c2ecf20Sopenharmony_ci/*
6198c2ecf20Sopenharmony_ci *---------------------------------------------------------------------------
6208c2ecf20Sopenharmony_ci * SET and GET bitfields in u32 values
6218c2ecf20Sopenharmony_ci * via constants for mask/offset:
6228c2ecf20Sopenharmony_ci * <bit_field_stub_name> is the text between
6238c2ecf20Sopenharmony_ci * UDC_ and _MASK|_OFS of appropriate
6248c2ecf20Sopenharmony_ci * constant
6258c2ecf20Sopenharmony_ci *
6268c2ecf20Sopenharmony_ci * set bitfield value in u32 u32Val
6278c2ecf20Sopenharmony_ci */
6288c2ecf20Sopenharmony_ci#define AMD_ADDBITS(u32Val, bitfield_val, bitfield_stub_name)		\
6298c2ecf20Sopenharmony_ci	(((u32Val) & (((u32) ~((u32) bitfield_stub_name##_MASK))))	\
6308c2ecf20Sopenharmony_ci	| (((bitfield_val) << ((u32) bitfield_stub_name##_OFS))		\
6318c2ecf20Sopenharmony_ci		& ((u32) bitfield_stub_name##_MASK)))
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_ci/*
6348c2ecf20Sopenharmony_ci * set bitfield value in zero-initialized u32 u32Val
6358c2ecf20Sopenharmony_ci * => bitfield bits in u32Val are all zero
6368c2ecf20Sopenharmony_ci */
6378c2ecf20Sopenharmony_ci#define AMD_INIT_SETBITS(u32Val, bitfield_val, bitfield_stub_name)	\
6388c2ecf20Sopenharmony_ci	((u32Val)							\
6398c2ecf20Sopenharmony_ci	| (((bitfield_val) << ((u32) bitfield_stub_name##_OFS))		\
6408c2ecf20Sopenharmony_ci		& ((u32) bitfield_stub_name##_MASK)))
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_ci/* get bitfield value from u32 u32Val */
6438c2ecf20Sopenharmony_ci#define AMD_GETBITS(u32Val, bitfield_stub_name)				\
6448c2ecf20Sopenharmony_ci	((u32Val & ((u32) bitfield_stub_name##_MASK))			\
6458c2ecf20Sopenharmony_ci		>> ((u32) bitfield_stub_name##_OFS))
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_ci/* SET and GET bits in u32 values ------------------------------------------*/
6488c2ecf20Sopenharmony_ci#define AMD_BIT(bit_stub_name) (1 << bit_stub_name)
6498c2ecf20Sopenharmony_ci#define AMD_UNMASK_BIT(bit_stub_name) (~AMD_BIT(bit_stub_name))
6508c2ecf20Sopenharmony_ci#define AMD_CLEAR_BIT(bit_stub_name) (~AMD_BIT(bit_stub_name))
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci/* debug macros ------------------------------------------------------------*/
6538c2ecf20Sopenharmony_ci
6548c2ecf20Sopenharmony_ci#define DBG(udc , args...)	dev_dbg(udc->dev, args)
6558c2ecf20Sopenharmony_ci
6568c2ecf20Sopenharmony_ci#ifdef UDC_VERBOSE
6578c2ecf20Sopenharmony_ci#define VDBG			DBG
6588c2ecf20Sopenharmony_ci#else
6598c2ecf20Sopenharmony_ci#define VDBG(udc , args...)	do {} while (0)
6608c2ecf20Sopenharmony_ci#endif
6618c2ecf20Sopenharmony_ci
6628c2ecf20Sopenharmony_ci#endif /* #ifdef AMD5536UDC_H */
663