linux/drivers/usb/host/isp116x.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 * ISP116x register declarations and HCD data structures
 *
 * Copyright (C) 2005 Olav Kongas <[email protected]>
 * Portions:
 * Copyright (C) 2004 Lothar Wassmann
 * Copyright (C) 2004 Psion Teklogix
 * Copyright (C) 2004 David Brownell
 */

/* us of 1ms frame */
#define MAX_LOAD_LIMIT

/* Full speed: max # of bytes to transfer for a single urb
   at a time must be < 1024 && must be multiple of 64.
   832 allows transferring 4kiB within 5 frames. */
#define MAX_TRANSFER_SIZE_FULLSPEED

/* Low speed: there is no reason to schedule in very big
   chunks; often the requested long transfers are for
   string descriptors containing short strings. */
#define MAX_TRANSFER_SIZE_LOWSPEED

/* Bytetime (us), a rough indication of how much time it
   would take to transfer a byte of useful data over USB */
#define BYTE_TIME_FULLSPEED
#define BYTE_TIME_LOWSPEED

/* Buffer sizes */
#define ISP116x_BUF_SIZE
#define ISP116x_ITL_BUFSIZE
#define ISP116x_ATL_BUFSIZE

#define ISP116x_WRITE_OFFSET

/*------------ ISP116x registers/bits ------------*/
#define HCREVISION
#define HCCONTROL
#define HCCONTROL_HCFS
#define HCCONTROL_USB_RESET
#define HCCONTROL_USB_RESUME
#define HCCONTROL_USB_OPER
#define HCCONTROL_USB_SUSPEND
#define HCCONTROL_RWC
#define HCCONTROL_RWE
#define HCCMDSTAT
#define HCCMDSTAT_HCR
#define HCCMDSTAT_SOC
#define HCINTSTAT
#define HCINT_SO
#define HCINT_WDH
#define HCINT_SF
#define HCINT_RD
#define HCINT_UE
#define HCINT_FNO
#define HCINT_RHSC
#define HCINT_OC
#define HCINT_MIE
#define HCINTENB
#define HCINTDIS
#define HCFMINTVL
#define HCFMREM
#define HCFMNUM
#define HCLSTHRESH
#define HCRHDESCA
#define RH_A_NDP
#define RH_A_PSM
#define RH_A_NPS
#define RH_A_DT
#define RH_A_OCPM
#define RH_A_NOCP
#define RH_A_POTPGT
#define HCRHDESCB
#define RH_B_DR
#define RH_B_PPCM
#define HCRHSTATUS
#define RH_HS_LPS
#define RH_HS_OCI
#define RH_HS_DRWE
#define RH_HS_LPSC
#define RH_HS_OCIC
#define RH_HS_CRWE
#define HCRHPORT1
#define RH_PS_CCS
#define RH_PS_PES
#define RH_PS_PSS
#define RH_PS_POCI
#define RH_PS_PRS
#define RH_PS_PPS
#define RH_PS_LSDA
#define RH_PS_CSC
#define RH_PS_PESC
#define RH_PS_PSSC
#define RH_PS_OCIC
#define RH_PS_PRSC
#define HCRHPORT_CLRMASK
#define HCRHPORT2
#define HCHWCFG
#define HCHWCFG_15KRSEL
#define HCHWCFG_CLKNOTSTOP
#define HCHWCFG_ANALOG_OC
#define HCHWCFG_DACK_MODE
#define HCHWCFG_EOT_POL
#define HCHWCFG_DACK_POL
#define HCHWCFG_DREQ_POL
#define HCHWCFG_DBWIDTH_MASK
#define HCHWCFG_DBWIDTH(n)
#define HCHWCFG_INT_POL
#define HCHWCFG_INT_TRIGGER
#define HCHWCFG_INT_ENABLE
#define HCDMACFG
#define HCDMACFG_BURST_LEN_MASK
#define HCDMACFG_BURST_LEN(n)
#define HCDMACFG_BURST_LEN_1
#define HCDMACFG_BURST_LEN_4
#define HCDMACFG_BURST_LEN_8
#define HCDMACFG_DMA_ENABLE
#define HCDMACFG_BUF_TYPE_MASK
#define HCDMACFG_CTR_SEL
#define HCDMACFG_ITLATL_SEL
#define HCDMACFG_DMA_RW_SELECT
#define HCXFERCTR
#define HCuPINT
#define HCuPINT_SOF
#define HCuPINT_ATL
#define HCuPINT_AIIEOT
#define HCuPINT_OPR
#define HCuPINT_SUSP
#define HCuPINT_CLKRDY
#define HCuPINTENB
#define HCCHIPID
#define HCCHIPID_MASK
#define HCCHIPID_MAGIC
#define HCSCRATCH
#define HCSWRES
#define HCSWRES_MAGIC
#define HCITLBUFLEN
#define HCATLBUFLEN
#define HCBUFSTAT
#define HCBUFSTAT_ITL0_FULL
#define HCBUFSTAT_ITL1_FULL
#define HCBUFSTAT_ATL_FULL
#define HCBUFSTAT_ITL0_DONE
#define HCBUFSTAT_ITL1_DONE
#define HCBUFSTAT_ATL_DONE
#define HCRDITL0LEN
#define HCRDITL1LEN
#define HCITLPORT
#define HCATLPORT

/* Philips transfer descriptor */
struct ptd {} __attribute__ ((packed, aligned));

/* PTD accessor macros. */
#define PTD_GET_COUNT(p)
#define PTD_COUNT(v)
#define PTD_GET_TOGGLE(p)
#define PTD_TOGGLE(v)
#define PTD_GET_ACTIVE(p)
#define PTD_ACTIVE(v)
#define PTD_GET_CC(p)
#define PTD_CC(v)
#define PTD_GET_MPS(p)
#define PTD_MPS(v)
#define PTD_GET_SPD(p)
#define PTD_SPD(v)
#define PTD_GET_LAST(p)
#define PTD_LAST(v)
#define PTD_GET_EP(p)
#define PTD_EP(v)
#define PTD_GET_LEN(p)
#define PTD_LEN(v)
#define PTD_GET_DIR(p)
#define PTD_DIR(v)
#define PTD_GET_B5_5(p)
#define PTD_B5_5(v)
#define PTD_GET_FA(p)
#define PTD_FA(v)
#define PTD_GET_FMT(p)
#define PTD_FMT(v)

/*  Hardware transfer status codes -- CC from ptd->count */
#define TD_CC_NOERROR
#define TD_CC_CRC
#define TD_CC_BITSTUFFING
#define TD_CC_DATATOGGLEM
#define TD_CC_STALL
#define TD_DEVNOTRESP
#define TD_PIDCHECKFAIL
#define TD_UNEXPECTEDPID
#define TD_DATAOVERRUN
#define TD_DATAUNDERRUN
    /* 0x0A, 0x0B reserved for hardware */
#define TD_BUFFEROVERRUN
#define TD_BUFFERUNDERRUN
    /* 0x0E, 0x0F reserved for HCD */
#define TD_NOTACCESSED

/* map PTD status codes (CC) to errno values */
static const int cc_to_error[16] =;

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

#define LOG2_PERIODIC_SIZE
#define PERIODIC_SIZE

struct isp116x {};

static inline struct isp116x *hcd_to_isp116x(struct usb_hcd *hcd)
{}

static inline struct usb_hcd *isp116x_to_hcd(struct isp116x *isp116x)
{}

struct isp116x_ep {};

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

#define DBG(stuff...)

#ifdef VERBOSE
#define VDBG
#else
#define VDBG(stuff...)
#endif

#define ERR(stuff...)
#define WARNING(stuff...)
#define INFO(stuff...)

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

#if defined(USE_PLATFORM_DELAY)
#if defined(USE_NDELAY)
#error USE_PLATFORM_DELAY and USE_NDELAY simultaneously defined.
#endif
#define isp116x_delay(h,d)
#define isp116x_check_platform_delay(h)
#elif defined(USE_NDELAY)
#define isp116x_delay
#define isp116x_check_platform_delay
#else
#define isp116x_delay
#define isp116x_check_platform_delay
#endif

static inline void isp116x_write_addr(struct isp116x *isp116x, unsigned reg)
{}

static inline void isp116x_write_data16(struct isp116x *isp116x, u16 val)
{}

static inline void isp116x_raw_write_data16(struct isp116x *isp116x, u16 val)
{}

static inline u16 isp116x_read_data16(struct isp116x *isp116x)
{}

static inline u16 isp116x_raw_read_data16(struct isp116x *isp116x)
{}

static inline void isp116x_write_data32(struct isp116x *isp116x, u32 val)
{}

static inline u32 isp116x_read_data32(struct isp116x *isp116x)
{}

/* Let's keep register access functions out of line. Hint:
   we wait at least 150 ns at every access.
*/
static u16 isp116x_read_reg16(struct isp116x *isp116x, unsigned reg)
{}

static u32 isp116x_read_reg32(struct isp116x *isp116x, unsigned reg)
{}

static void isp116x_write_reg16(struct isp116x *isp116x, unsigned reg,
				unsigned val)
{}

static void isp116x_write_reg32(struct isp116x *isp116x, unsigned reg,
				unsigned val)
{}

#define isp116x_show_reg_log(d,r,s)
#define isp116x_show_reg_seq(d,r,s)

#define isp116x_show_regs(d,type,s)

/*
   Dump registers for debugfs.
*/
static inline void isp116x_show_regs_seq(struct isp116x *isp116x,
					  struct seq_file *s)
{}

/*
   Dump registers to syslog.
*/
static inline void isp116x_show_regs_log(struct isp116x *isp116x)
{}

#if defined(URB_TRACE)

#define PIPETYPE
#define PIPEDIR
#define URB_NOTSHORT

/* print debug info about the URB */
static void urb_dbg(struct urb *urb, char *msg)
{
	unsigned int pipe;

	if (!urb) {
		DBG("%s: zero urb\n", msg);
		return;
	}
	pipe = urb->pipe;
	DBG("%s: FA %d ep%d%s %s: len %d/%d %s\n", msg,
	    usb_pipedevice(pipe), usb_pipeendpoint(pipe),
	    PIPEDIR(pipe), PIPETYPE(pipe),
	    urb->transfer_buffer_length, urb->actual_length, URB_NOTSHORT(urb));
}

#else

#define urb_dbg(urb,msg)

#endif				/* ! defined(URB_TRACE) */

#if defined(PTD_TRACE)

#define PTD_DIR_STR

/*
  Dump PTD info. The code documents the format
  perfectly, right :)
*/
static inline void dump_ptd(struct ptd *ptd)
{
	printk(KERN_WARNING "td: %x %d%c%d %d,%d,%d  %x %x%x%x\n",
	       PTD_GET_CC(ptd), PTD_GET_FA(ptd),
	       PTD_DIR_STR(ptd), PTD_GET_EP(ptd),
	       PTD_GET_COUNT(ptd), PTD_GET_LEN(ptd), PTD_GET_MPS(ptd),
	       PTD_GET_TOGGLE(ptd), PTD_GET_ACTIVE(ptd),
	       PTD_GET_SPD(ptd), PTD_GET_LAST(ptd));
}

static inline void dump_ptd_out_data(struct ptd *ptd, u8 * buf)
{
	int k;

	if (PTD_GET_DIR(ptd) != PTD_DIR_IN && PTD_GET_LEN(ptd)) {
		printk(KERN_WARNING "-> ");
		for (k = 0; k < PTD_GET_LEN(ptd); ++k)
			printk("%02x ", ((u8 *) buf)[k]);
		printk("\n");
	}
}

static inline void dump_ptd_in_data(struct ptd *ptd, u8 * buf)
{
	int k;

	if (PTD_GET_DIR(ptd) == PTD_DIR_IN && PTD_GET_COUNT(ptd)) {
		printk(KERN_WARNING "<- ");
		for (k = 0; k < PTD_GET_COUNT(ptd); ++k)
			printk("%02x ", ((u8 *) buf)[k]);
		printk("\n");
	}
	if (PTD_GET_LAST(ptd))
		printk(KERN_WARNING "-\n");
}

#else

#define dump_ptd(ptd)
#define dump_ptd_in_data(ptd,buf)
#define dump_ptd_out_data(ptd,buf)

#endif				/* ! defined(PTD_TRACE) */