162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef __LINUX_FOTG210_H 362306a36Sopenharmony_ci#define __LINUX_FOTG210_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/usb/ehci-dbgp.h> 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci/* definitions used for the EHCI driver */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* 1062306a36Sopenharmony_ci * __hc32 and __hc16 are "Host Controller" types, they may be equivalent to 1162306a36Sopenharmony_ci * __leXX (normally) or __beXX (given FOTG210_BIG_ENDIAN_DESC), depending on 1262306a36Sopenharmony_ci * the host controller implementation. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * To facilitate the strongest possible byte-order checking from "sparse" 1562306a36Sopenharmony_ci * and so on, we use __leXX unless that's not practical. 1662306a36Sopenharmony_ci */ 1762306a36Sopenharmony_ci#define __hc32 __le32 1862306a36Sopenharmony_ci#define __hc16 __le16 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/* statistics can be kept for tuning/monitoring */ 2162306a36Sopenharmony_cistruct fotg210_stats { 2262306a36Sopenharmony_ci /* irq usage */ 2362306a36Sopenharmony_ci unsigned long normal; 2462306a36Sopenharmony_ci unsigned long error; 2562306a36Sopenharmony_ci unsigned long iaa; 2662306a36Sopenharmony_ci unsigned long lost_iaa; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci /* termination of urbs from core */ 2962306a36Sopenharmony_ci unsigned long complete; 3062306a36Sopenharmony_ci unsigned long unlink; 3162306a36Sopenharmony_ci}; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* fotg210_hcd->lock guards shared data against other CPUs: 3462306a36Sopenharmony_ci * fotg210_hcd: async, unlink, periodic (and shadow), ... 3562306a36Sopenharmony_ci * usb_host_endpoint: hcpriv 3662306a36Sopenharmony_ci * fotg210_qh: qh_next, qtd_list 3762306a36Sopenharmony_ci * fotg210_qtd: qtd_list 3862306a36Sopenharmony_ci * 3962306a36Sopenharmony_ci * Also, hold this lock when talking to HC registers or 4062306a36Sopenharmony_ci * when updating hw_* fields in shared qh/qtd/... structures. 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define FOTG210_MAX_ROOT_PORTS 1 /* see HCS_N_PORTS */ 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/* 4662306a36Sopenharmony_ci * fotg210_rh_state values of FOTG210_RH_RUNNING or above mean that the 4762306a36Sopenharmony_ci * controller may be doing DMA. Lower values mean there's no DMA. 4862306a36Sopenharmony_ci */ 4962306a36Sopenharmony_cienum fotg210_rh_state { 5062306a36Sopenharmony_ci FOTG210_RH_HALTED, 5162306a36Sopenharmony_ci FOTG210_RH_SUSPENDED, 5262306a36Sopenharmony_ci FOTG210_RH_RUNNING, 5362306a36Sopenharmony_ci FOTG210_RH_STOPPING 5462306a36Sopenharmony_ci}; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci/* 5762306a36Sopenharmony_ci * Timer events, ordered by increasing delay length. 5862306a36Sopenharmony_ci * Always update event_delays_ns[] and event_handlers[] (defined in 5962306a36Sopenharmony_ci * ehci-timer.c) in parallel with this list. 6062306a36Sopenharmony_ci */ 6162306a36Sopenharmony_cienum fotg210_hrtimer_event { 6262306a36Sopenharmony_ci FOTG210_HRTIMER_POLL_ASS, /* Poll for async schedule off */ 6362306a36Sopenharmony_ci FOTG210_HRTIMER_POLL_PSS, /* Poll for periodic schedule off */ 6462306a36Sopenharmony_ci FOTG210_HRTIMER_POLL_DEAD, /* Wait for dead controller to stop */ 6562306a36Sopenharmony_ci FOTG210_HRTIMER_UNLINK_INTR, /* Wait for interrupt QH unlink */ 6662306a36Sopenharmony_ci FOTG210_HRTIMER_FREE_ITDS, /* Wait for unused iTDs and siTDs */ 6762306a36Sopenharmony_ci FOTG210_HRTIMER_ASYNC_UNLINKS, /* Unlink empty async QHs */ 6862306a36Sopenharmony_ci FOTG210_HRTIMER_IAA_WATCHDOG, /* Handle lost IAA interrupts */ 6962306a36Sopenharmony_ci FOTG210_HRTIMER_DISABLE_PERIODIC, /* Wait to disable periodic sched */ 7062306a36Sopenharmony_ci FOTG210_HRTIMER_DISABLE_ASYNC, /* Wait to disable async sched */ 7162306a36Sopenharmony_ci FOTG210_HRTIMER_IO_WATCHDOG, /* Check for missing IRQs */ 7262306a36Sopenharmony_ci FOTG210_HRTIMER_NUM_EVENTS /* Must come last */ 7362306a36Sopenharmony_ci}; 7462306a36Sopenharmony_ci#define FOTG210_HRTIMER_NO_EVENT 99 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_cistruct fotg210_hcd { /* one per controller */ 7762306a36Sopenharmony_ci /* timing support */ 7862306a36Sopenharmony_ci enum fotg210_hrtimer_event next_hrtimer_event; 7962306a36Sopenharmony_ci unsigned enabled_hrtimer_events; 8062306a36Sopenharmony_ci ktime_t hr_timeouts[FOTG210_HRTIMER_NUM_EVENTS]; 8162306a36Sopenharmony_ci struct hrtimer hrtimer; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci int PSS_poll_count; 8462306a36Sopenharmony_ci int ASS_poll_count; 8562306a36Sopenharmony_ci int died_poll_count; 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci /* glue to PCI and HCD framework */ 8862306a36Sopenharmony_ci struct fotg210_caps __iomem *caps; 8962306a36Sopenharmony_ci struct fotg210_regs __iomem *regs; 9062306a36Sopenharmony_ci struct ehci_dbg_port __iomem *debug; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ci __u32 hcs_params; /* cached register copy */ 9362306a36Sopenharmony_ci spinlock_t lock; 9462306a36Sopenharmony_ci enum fotg210_rh_state rh_state; 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci /* general schedule support */ 9762306a36Sopenharmony_ci bool scanning:1; 9862306a36Sopenharmony_ci bool need_rescan:1; 9962306a36Sopenharmony_ci bool intr_unlinking:1; 10062306a36Sopenharmony_ci bool async_unlinking:1; 10162306a36Sopenharmony_ci bool shutdown:1; 10262306a36Sopenharmony_ci struct fotg210_qh *qh_scan_next; 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci /* async schedule support */ 10562306a36Sopenharmony_ci struct fotg210_qh *async; 10662306a36Sopenharmony_ci struct fotg210_qh *dummy; /* For AMD quirk use */ 10762306a36Sopenharmony_ci struct fotg210_qh *async_unlink; 10862306a36Sopenharmony_ci struct fotg210_qh *async_unlink_last; 10962306a36Sopenharmony_ci struct fotg210_qh *async_iaa; 11062306a36Sopenharmony_ci unsigned async_unlink_cycle; 11162306a36Sopenharmony_ci unsigned async_count; /* async activity count */ 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci /* periodic schedule support */ 11462306a36Sopenharmony_ci#define DEFAULT_I_TDPS 1024 /* some HCs can do less */ 11562306a36Sopenharmony_ci unsigned periodic_size; 11662306a36Sopenharmony_ci __hc32 *periodic; /* hw periodic table */ 11762306a36Sopenharmony_ci dma_addr_t periodic_dma; 11862306a36Sopenharmony_ci struct list_head intr_qh_list; 11962306a36Sopenharmony_ci unsigned i_thresh; /* uframes HC might cache */ 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci union fotg210_shadow *pshadow; /* mirror hw periodic table */ 12262306a36Sopenharmony_ci struct fotg210_qh *intr_unlink; 12362306a36Sopenharmony_ci struct fotg210_qh *intr_unlink_last; 12462306a36Sopenharmony_ci unsigned intr_unlink_cycle; 12562306a36Sopenharmony_ci unsigned now_frame; /* frame from HC hardware */ 12662306a36Sopenharmony_ci unsigned next_frame; /* scan periodic, start here */ 12762306a36Sopenharmony_ci unsigned intr_count; /* intr activity count */ 12862306a36Sopenharmony_ci unsigned isoc_count; /* isoc activity count */ 12962306a36Sopenharmony_ci unsigned periodic_count; /* periodic activity count */ 13062306a36Sopenharmony_ci /* max periodic time per uframe */ 13162306a36Sopenharmony_ci unsigned uframe_periodic_max; 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci /* list of itds completed while now_frame was still active */ 13562306a36Sopenharmony_ci struct list_head cached_itd_list; 13662306a36Sopenharmony_ci struct fotg210_itd *last_itd_to_free; 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_ci /* per root hub port */ 13962306a36Sopenharmony_ci unsigned long reset_done[FOTG210_MAX_ROOT_PORTS]; 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci /* bit vectors (one bit per port) 14262306a36Sopenharmony_ci * which ports were already suspended at the start of a bus suspend 14362306a36Sopenharmony_ci */ 14462306a36Sopenharmony_ci unsigned long bus_suspended; 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci /* which ports are edicated to the companion controller */ 14762306a36Sopenharmony_ci unsigned long companion_ports; 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci /* which ports are owned by the companion during a bus suspend */ 15062306a36Sopenharmony_ci unsigned long owned_ports; 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci /* which ports have the change-suspend feature turned on */ 15362306a36Sopenharmony_ci unsigned long port_c_suspend; 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci /* which ports are suspended */ 15662306a36Sopenharmony_ci unsigned long suspended_ports; 15762306a36Sopenharmony_ci 15862306a36Sopenharmony_ci /* which ports have started to resume */ 15962306a36Sopenharmony_ci unsigned long resuming_ports; 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci /* per-HC memory pools (could be per-bus, but ...) */ 16262306a36Sopenharmony_ci struct dma_pool *qh_pool; /* qh per active urb */ 16362306a36Sopenharmony_ci struct dma_pool *qtd_pool; /* one or more per qh */ 16462306a36Sopenharmony_ci struct dma_pool *itd_pool; /* itd per iso urb */ 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ci unsigned random_frame; 16762306a36Sopenharmony_ci unsigned long next_statechange; 16862306a36Sopenharmony_ci ktime_t last_periodic_enable; 16962306a36Sopenharmony_ci u32 command; 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci /* SILICON QUIRKS */ 17262306a36Sopenharmony_ci unsigned need_io_watchdog:1; 17362306a36Sopenharmony_ci unsigned fs_i_thresh:1; /* Intel iso scheduling */ 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci u8 sbrn; /* packed release number */ 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci /* irq statistics */ 17862306a36Sopenharmony_ci#ifdef FOTG210_STATS 17962306a36Sopenharmony_ci struct fotg210_stats stats; 18062306a36Sopenharmony_ci# define INCR(x) ((x)++) 18162306a36Sopenharmony_ci#else 18262306a36Sopenharmony_ci# define INCR(x) do {} while (0) 18362306a36Sopenharmony_ci#endif 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci struct fotg210 *fotg; /* Overarching FOTG210 device */ 18662306a36Sopenharmony_ci /* silicon clock */ 18762306a36Sopenharmony_ci struct clk *pclk; 18862306a36Sopenharmony_ci}; 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ci/* convert between an HCD pointer and the corresponding FOTG210_HCD */ 19162306a36Sopenharmony_cistatic inline struct fotg210_hcd *hcd_to_fotg210(struct usb_hcd *hcd) 19262306a36Sopenharmony_ci{ 19362306a36Sopenharmony_ci return (struct fotg210_hcd *)(hcd->hcd_priv); 19462306a36Sopenharmony_ci} 19562306a36Sopenharmony_cistatic inline struct usb_hcd *fotg210_to_hcd(struct fotg210_hcd *fotg210) 19662306a36Sopenharmony_ci{ 19762306a36Sopenharmony_ci return container_of((void *) fotg210, struct usb_hcd, hcd_priv); 19862306a36Sopenharmony_ci} 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */ 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci/* Section 2.2 Host Controller Capability Registers */ 20562306a36Sopenharmony_cistruct fotg210_caps { 20662306a36Sopenharmony_ci /* these fields are specified as 8 and 16 bit registers, 20762306a36Sopenharmony_ci * but some hosts can't perform 8 or 16 bit PCI accesses. 20862306a36Sopenharmony_ci * some hosts treat caplength and hciversion as parts of a 32-bit 20962306a36Sopenharmony_ci * register, others treat them as two separate registers, this 21062306a36Sopenharmony_ci * affects the memory map for big endian controllers. 21162306a36Sopenharmony_ci */ 21262306a36Sopenharmony_ci u32 hc_capbase; 21362306a36Sopenharmony_ci#define HC_LENGTH(fotg210, p) (0x00ff&((p) >> /* bits 7:0 / offset 00h */ \ 21462306a36Sopenharmony_ci (fotg210_big_endian_capbase(fotg210) ? 24 : 0))) 21562306a36Sopenharmony_ci#define HC_VERSION(fotg210, p) (0xffff&((p) >> /* bits 31:16 / offset 02h */ \ 21662306a36Sopenharmony_ci (fotg210_big_endian_capbase(fotg210) ? 0 : 16))) 21762306a36Sopenharmony_ci u32 hcs_params; /* HCSPARAMS - offset 0x4 */ 21862306a36Sopenharmony_ci#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci u32 hcc_params; /* HCCPARAMS - offset 0x8 */ 22162306a36Sopenharmony_ci#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */ 22262306a36Sopenharmony_ci#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/ 22362306a36Sopenharmony_ci u8 portroute[8]; /* nibbles for routing - offset 0xC */ 22462306a36Sopenharmony_ci}; 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_ci 22762306a36Sopenharmony_ci/* Section 2.3 Host Controller Operational Registers */ 22862306a36Sopenharmony_cistruct fotg210_regs { 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci /* USBCMD: offset 0x00 */ 23162306a36Sopenharmony_ci u32 command; 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci/* EHCI 1.1 addendum */ 23462306a36Sopenharmony_ci/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */ 23562306a36Sopenharmony_ci#define CMD_PARK (1<<11) /* enable "park" on async qh */ 23662306a36Sopenharmony_ci#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */ 23762306a36Sopenharmony_ci#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */ 23862306a36Sopenharmony_ci#define CMD_ASE (1<<5) /* async schedule enable */ 23962306a36Sopenharmony_ci#define CMD_PSE (1<<4) /* periodic schedule enable */ 24062306a36Sopenharmony_ci/* 3:2 is periodic frame list size */ 24162306a36Sopenharmony_ci#define CMD_RESET (1<<1) /* reset HC not bus */ 24262306a36Sopenharmony_ci#define CMD_RUN (1<<0) /* start/stop HC */ 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_ci /* USBSTS: offset 0x04 */ 24562306a36Sopenharmony_ci u32 status; 24662306a36Sopenharmony_ci#define STS_ASS (1<<15) /* Async Schedule Status */ 24762306a36Sopenharmony_ci#define STS_PSS (1<<14) /* Periodic Schedule Status */ 24862306a36Sopenharmony_ci#define STS_RECL (1<<13) /* Reclamation */ 24962306a36Sopenharmony_ci#define STS_HALT (1<<12) /* Not running (any reason) */ 25062306a36Sopenharmony_ci/* some bits reserved */ 25162306a36Sopenharmony_ci /* these STS_* flags are also intr_enable bits (USBINTR) */ 25262306a36Sopenharmony_ci#define STS_IAA (1<<5) /* Interrupted on async advance */ 25362306a36Sopenharmony_ci#define STS_FATAL (1<<4) /* such as some PCI access errors */ 25462306a36Sopenharmony_ci#define STS_FLR (1<<3) /* frame list rolled over */ 25562306a36Sopenharmony_ci#define STS_PCD (1<<2) /* port change detect */ 25662306a36Sopenharmony_ci#define STS_ERR (1<<1) /* "error" completion (overflow, ...) */ 25762306a36Sopenharmony_ci#define STS_INT (1<<0) /* "normal" completion (short, ...) */ 25862306a36Sopenharmony_ci 25962306a36Sopenharmony_ci /* USBINTR: offset 0x08 */ 26062306a36Sopenharmony_ci u32 intr_enable; 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_ci /* FRINDEX: offset 0x0C */ 26362306a36Sopenharmony_ci u32 frame_index; /* current microframe number */ 26462306a36Sopenharmony_ci /* CTRLDSSEGMENT: offset 0x10 */ 26562306a36Sopenharmony_ci u32 segment; /* address bits 63:32 if needed */ 26662306a36Sopenharmony_ci /* PERIODICLISTBASE: offset 0x14 */ 26762306a36Sopenharmony_ci u32 frame_list; /* points to periodic list */ 26862306a36Sopenharmony_ci /* ASYNCLISTADDR: offset 0x18 */ 26962306a36Sopenharmony_ci u32 async_next; /* address of next async queue head */ 27062306a36Sopenharmony_ci 27162306a36Sopenharmony_ci u32 reserved1; 27262306a36Sopenharmony_ci /* PORTSC: offset 0x20 */ 27362306a36Sopenharmony_ci u32 port_status; 27462306a36Sopenharmony_ci/* 31:23 reserved */ 27562306a36Sopenharmony_ci#define PORT_USB11(x) (((x)&(3<<10)) == (1<<10)) /* USB 1.1 device */ 27662306a36Sopenharmony_ci#define PORT_RESET (1<<8) /* reset port */ 27762306a36Sopenharmony_ci#define PORT_SUSPEND (1<<7) /* suspend port */ 27862306a36Sopenharmony_ci#define PORT_RESUME (1<<6) /* resume it */ 27962306a36Sopenharmony_ci#define PORT_PEC (1<<3) /* port enable change */ 28062306a36Sopenharmony_ci#define PORT_PE (1<<2) /* port enable */ 28162306a36Sopenharmony_ci#define PORT_CSC (1<<1) /* connect status change */ 28262306a36Sopenharmony_ci#define PORT_CONNECT (1<<0) /* device connected */ 28362306a36Sopenharmony_ci#define PORT_RWC_BITS (PORT_CSC | PORT_PEC) 28462306a36Sopenharmony_ci u32 reserved2[19]; 28562306a36Sopenharmony_ci 28662306a36Sopenharmony_ci /* OTGCSR: offet 0x70 */ 28762306a36Sopenharmony_ci u32 otgcsr; 28862306a36Sopenharmony_ci#define OTGCSR_HOST_SPD_TYP (3 << 22) 28962306a36Sopenharmony_ci#define OTGCSR_A_BUS_DROP (1 << 5) 29062306a36Sopenharmony_ci#define OTGCSR_A_BUS_REQ (1 << 4) 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ci /* OTGISR: offset 0x74 */ 29362306a36Sopenharmony_ci u32 otgisr; 29462306a36Sopenharmony_ci#define OTGISR_OVC (1 << 10) 29562306a36Sopenharmony_ci 29662306a36Sopenharmony_ci u32 reserved3[15]; 29762306a36Sopenharmony_ci 29862306a36Sopenharmony_ci /* GMIR: offset 0xB4 */ 29962306a36Sopenharmony_ci u32 gmir; 30062306a36Sopenharmony_ci#define GMIR_INT_POLARITY (1 << 3) /*Active High*/ 30162306a36Sopenharmony_ci#define GMIR_MHC_INT (1 << 2) 30262306a36Sopenharmony_ci#define GMIR_MOTG_INT (1 << 1) 30362306a36Sopenharmony_ci#define GMIR_MDEV_INT (1 << 0) 30462306a36Sopenharmony_ci}; 30562306a36Sopenharmony_ci 30662306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 30762306a36Sopenharmony_ci 30862306a36Sopenharmony_ci#define QTD_NEXT(fotg210, dma) cpu_to_hc32(fotg210, (u32)dma) 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci/* 31162306a36Sopenharmony_ci * EHCI Specification 0.95 Section 3.5 31262306a36Sopenharmony_ci * QTD: describe data transfer components (buffer, direction, ...) 31362306a36Sopenharmony_ci * See Fig 3-6 "Queue Element Transfer Descriptor Block Diagram". 31462306a36Sopenharmony_ci * 31562306a36Sopenharmony_ci * These are associated only with "QH" (Queue Head) structures, 31662306a36Sopenharmony_ci * used with control, bulk, and interrupt transfers. 31762306a36Sopenharmony_ci */ 31862306a36Sopenharmony_cistruct fotg210_qtd { 31962306a36Sopenharmony_ci /* first part defined by EHCI spec */ 32062306a36Sopenharmony_ci __hc32 hw_next; /* see EHCI 3.5.1 */ 32162306a36Sopenharmony_ci __hc32 hw_alt_next; /* see EHCI 3.5.2 */ 32262306a36Sopenharmony_ci __hc32 hw_token; /* see EHCI 3.5.3 */ 32362306a36Sopenharmony_ci#define QTD_TOGGLE (1 << 31) /* data toggle */ 32462306a36Sopenharmony_ci#define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff) 32562306a36Sopenharmony_ci#define QTD_IOC (1 << 15) /* interrupt on complete */ 32662306a36Sopenharmony_ci#define QTD_CERR(tok) (((tok)>>10) & 0x3) 32762306a36Sopenharmony_ci#define QTD_PID(tok) (((tok)>>8) & 0x3) 32862306a36Sopenharmony_ci#define QTD_STS_ACTIVE (1 << 7) /* HC may execute this */ 32962306a36Sopenharmony_ci#define QTD_STS_HALT (1 << 6) /* halted on error */ 33062306a36Sopenharmony_ci#define QTD_STS_DBE (1 << 5) /* data buffer error (in HC) */ 33162306a36Sopenharmony_ci#define QTD_STS_BABBLE (1 << 4) /* device was babbling (qtd halted) */ 33262306a36Sopenharmony_ci#define QTD_STS_XACT (1 << 3) /* device gave illegal response */ 33362306a36Sopenharmony_ci#define QTD_STS_MMF (1 << 2) /* incomplete split transaction */ 33462306a36Sopenharmony_ci#define QTD_STS_STS (1 << 1) /* split transaction state */ 33562306a36Sopenharmony_ci#define QTD_STS_PING (1 << 0) /* issue PING? */ 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_ci#define ACTIVE_BIT(fotg210) cpu_to_hc32(fotg210, QTD_STS_ACTIVE) 33862306a36Sopenharmony_ci#define HALT_BIT(fotg210) cpu_to_hc32(fotg210, QTD_STS_HALT) 33962306a36Sopenharmony_ci#define STATUS_BIT(fotg210) cpu_to_hc32(fotg210, QTD_STS_STS) 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci __hc32 hw_buf[5]; /* see EHCI 3.5.4 */ 34262306a36Sopenharmony_ci __hc32 hw_buf_hi[5]; /* Appendix B */ 34362306a36Sopenharmony_ci 34462306a36Sopenharmony_ci /* the rest is HCD-private */ 34562306a36Sopenharmony_ci dma_addr_t qtd_dma; /* qtd address */ 34662306a36Sopenharmony_ci struct list_head qtd_list; /* sw qtd list */ 34762306a36Sopenharmony_ci struct urb *urb; /* qtd's urb */ 34862306a36Sopenharmony_ci size_t length; /* length of buffer */ 34962306a36Sopenharmony_ci} __aligned(32); 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci/* mask NakCnt+T in qh->hw_alt_next */ 35262306a36Sopenharmony_ci#define QTD_MASK(fotg210) cpu_to_hc32(fotg210, ~0x1f) 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci#define IS_SHORT_READ(token) (QTD_LENGTH(token) != 0 && QTD_PID(token) == 1) 35562306a36Sopenharmony_ci 35662306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 35762306a36Sopenharmony_ci 35862306a36Sopenharmony_ci/* type tag from {qh,itd,fstn}->hw_next */ 35962306a36Sopenharmony_ci#define Q_NEXT_TYPE(fotg210, dma) ((dma) & cpu_to_hc32(fotg210, 3 << 1)) 36062306a36Sopenharmony_ci 36162306a36Sopenharmony_ci/* 36262306a36Sopenharmony_ci * Now the following defines are not converted using the 36362306a36Sopenharmony_ci * cpu_to_le32() macro anymore, since we have to support 36462306a36Sopenharmony_ci * "dynamic" switching between be and le support, so that the driver 36562306a36Sopenharmony_ci * can be used on one system with SoC EHCI controller using big-endian 36662306a36Sopenharmony_ci * descriptors as well as a normal little-endian PCI EHCI controller. 36762306a36Sopenharmony_ci */ 36862306a36Sopenharmony_ci/* values for that type tag */ 36962306a36Sopenharmony_ci#define Q_TYPE_ITD (0 << 1) 37062306a36Sopenharmony_ci#define Q_TYPE_QH (1 << 1) 37162306a36Sopenharmony_ci#define Q_TYPE_SITD (2 << 1) 37262306a36Sopenharmony_ci#define Q_TYPE_FSTN (3 << 1) 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci/* next async queue entry, or pointer to interrupt/periodic QH */ 37562306a36Sopenharmony_ci#define QH_NEXT(fotg210, dma) \ 37662306a36Sopenharmony_ci (cpu_to_hc32(fotg210, (((u32)dma)&~0x01f)|Q_TYPE_QH)) 37762306a36Sopenharmony_ci 37862306a36Sopenharmony_ci/* for periodic/async schedules and qtd lists, mark end of list */ 37962306a36Sopenharmony_ci#define FOTG210_LIST_END(fotg210) \ 38062306a36Sopenharmony_ci cpu_to_hc32(fotg210, 1) /* "null pointer" to hw */ 38162306a36Sopenharmony_ci 38262306a36Sopenharmony_ci/* 38362306a36Sopenharmony_ci * Entries in periodic shadow table are pointers to one of four kinds 38462306a36Sopenharmony_ci * of data structure. That's dictated by the hardware; a type tag is 38562306a36Sopenharmony_ci * encoded in the low bits of the hardware's periodic schedule. Use 38662306a36Sopenharmony_ci * Q_NEXT_TYPE to get the tag. 38762306a36Sopenharmony_ci * 38862306a36Sopenharmony_ci * For entries in the async schedule, the type tag always says "qh". 38962306a36Sopenharmony_ci */ 39062306a36Sopenharmony_ciunion fotg210_shadow { 39162306a36Sopenharmony_ci struct fotg210_qh *qh; /* Q_TYPE_QH */ 39262306a36Sopenharmony_ci struct fotg210_itd *itd; /* Q_TYPE_ITD */ 39362306a36Sopenharmony_ci struct fotg210_fstn *fstn; /* Q_TYPE_FSTN */ 39462306a36Sopenharmony_ci __hc32 *hw_next; /* (all types) */ 39562306a36Sopenharmony_ci void *ptr; 39662306a36Sopenharmony_ci}; 39762306a36Sopenharmony_ci 39862306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_ci/* 40162306a36Sopenharmony_ci * EHCI Specification 0.95 Section 3.6 40262306a36Sopenharmony_ci * QH: describes control/bulk/interrupt endpoints 40362306a36Sopenharmony_ci * See Fig 3-7 "Queue Head Structure Layout". 40462306a36Sopenharmony_ci * 40562306a36Sopenharmony_ci * These appear in both the async and (for interrupt) periodic schedules. 40662306a36Sopenharmony_ci */ 40762306a36Sopenharmony_ci 40862306a36Sopenharmony_ci/* first part defined by EHCI spec */ 40962306a36Sopenharmony_cistruct fotg210_qh_hw { 41062306a36Sopenharmony_ci __hc32 hw_next; /* see EHCI 3.6.1 */ 41162306a36Sopenharmony_ci __hc32 hw_info1; /* see EHCI 3.6.2 */ 41262306a36Sopenharmony_ci#define QH_CONTROL_EP (1 << 27) /* FS/LS control endpoint */ 41362306a36Sopenharmony_ci#define QH_HEAD (1 << 15) /* Head of async reclamation list */ 41462306a36Sopenharmony_ci#define QH_TOGGLE_CTL (1 << 14) /* Data toggle control */ 41562306a36Sopenharmony_ci#define QH_HIGH_SPEED (2 << 12) /* Endpoint speed */ 41662306a36Sopenharmony_ci#define QH_LOW_SPEED (1 << 12) 41762306a36Sopenharmony_ci#define QH_FULL_SPEED (0 << 12) 41862306a36Sopenharmony_ci#define QH_INACTIVATE (1 << 7) /* Inactivate on next transaction */ 41962306a36Sopenharmony_ci __hc32 hw_info2; /* see EHCI 3.6.2 */ 42062306a36Sopenharmony_ci#define QH_SMASK 0x000000ff 42162306a36Sopenharmony_ci#define QH_CMASK 0x0000ff00 42262306a36Sopenharmony_ci#define QH_HUBADDR 0x007f0000 42362306a36Sopenharmony_ci#define QH_HUBPORT 0x3f800000 42462306a36Sopenharmony_ci#define QH_MULT 0xc0000000 42562306a36Sopenharmony_ci __hc32 hw_current; /* qtd list - see EHCI 3.6.4 */ 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci /* qtd overlay (hardware parts of a struct fotg210_qtd) */ 42862306a36Sopenharmony_ci __hc32 hw_qtd_next; 42962306a36Sopenharmony_ci __hc32 hw_alt_next; 43062306a36Sopenharmony_ci __hc32 hw_token; 43162306a36Sopenharmony_ci __hc32 hw_buf[5]; 43262306a36Sopenharmony_ci __hc32 hw_buf_hi[5]; 43362306a36Sopenharmony_ci} __aligned(32); 43462306a36Sopenharmony_ci 43562306a36Sopenharmony_cistruct fotg210_qh { 43662306a36Sopenharmony_ci struct fotg210_qh_hw *hw; /* Must come first */ 43762306a36Sopenharmony_ci /* the rest is HCD-private */ 43862306a36Sopenharmony_ci dma_addr_t qh_dma; /* address of qh */ 43962306a36Sopenharmony_ci union fotg210_shadow qh_next; /* ptr to qh; or periodic */ 44062306a36Sopenharmony_ci struct list_head qtd_list; /* sw qtd list */ 44162306a36Sopenharmony_ci struct list_head intr_node; /* list of intr QHs */ 44262306a36Sopenharmony_ci struct fotg210_qtd *dummy; 44362306a36Sopenharmony_ci struct fotg210_qh *unlink_next; /* next on unlink list */ 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci unsigned unlink_cycle; 44662306a36Sopenharmony_ci 44762306a36Sopenharmony_ci u8 needs_rescan; /* Dequeue during giveback */ 44862306a36Sopenharmony_ci u8 qh_state; 44962306a36Sopenharmony_ci#define QH_STATE_LINKED 1 /* HC sees this */ 45062306a36Sopenharmony_ci#define QH_STATE_UNLINK 2 /* HC may still see this */ 45162306a36Sopenharmony_ci#define QH_STATE_IDLE 3 /* HC doesn't see this */ 45262306a36Sopenharmony_ci#define QH_STATE_UNLINK_WAIT 4 /* LINKED and on unlink q */ 45362306a36Sopenharmony_ci#define QH_STATE_COMPLETING 5 /* don't touch token.HALT */ 45462306a36Sopenharmony_ci 45562306a36Sopenharmony_ci u8 xacterrs; /* XactErr retry counter */ 45662306a36Sopenharmony_ci#define QH_XACTERR_MAX 32 /* XactErr retry limit */ 45762306a36Sopenharmony_ci 45862306a36Sopenharmony_ci /* periodic schedule info */ 45962306a36Sopenharmony_ci u8 usecs; /* intr bandwidth */ 46062306a36Sopenharmony_ci u8 gap_uf; /* uframes split/csplit gap */ 46162306a36Sopenharmony_ci u8 c_usecs; /* ... split completion bw */ 46262306a36Sopenharmony_ci u16 tt_usecs; /* tt downstream bandwidth */ 46362306a36Sopenharmony_ci unsigned short period; /* polling interval */ 46462306a36Sopenharmony_ci unsigned short start; /* where polling starts */ 46562306a36Sopenharmony_ci#define NO_FRAME ((unsigned short)~0) /* pick new start */ 46662306a36Sopenharmony_ci 46762306a36Sopenharmony_ci struct usb_device *dev; /* access to TT */ 46862306a36Sopenharmony_ci unsigned is_out:1; /* bulk or intr OUT */ 46962306a36Sopenharmony_ci unsigned clearing_tt:1; /* Clear-TT-Buf in progress */ 47062306a36Sopenharmony_ci}; 47162306a36Sopenharmony_ci 47262306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 47362306a36Sopenharmony_ci 47462306a36Sopenharmony_ci/* description of one iso transaction (up to 3 KB data if highspeed) */ 47562306a36Sopenharmony_cistruct fotg210_iso_packet { 47662306a36Sopenharmony_ci /* These will be copied to iTD when scheduling */ 47762306a36Sopenharmony_ci u64 bufp; /* itd->hw_bufp{,_hi}[pg] |= */ 47862306a36Sopenharmony_ci __hc32 transaction; /* itd->hw_transaction[i] |= */ 47962306a36Sopenharmony_ci u8 cross; /* buf crosses pages */ 48062306a36Sopenharmony_ci /* for full speed OUT splits */ 48162306a36Sopenharmony_ci u32 buf1; 48262306a36Sopenharmony_ci}; 48362306a36Sopenharmony_ci 48462306a36Sopenharmony_ci/* temporary schedule data for packets from iso urbs (both speeds) 48562306a36Sopenharmony_ci * each packet is one logical usb transaction to the device (not TT), 48662306a36Sopenharmony_ci * beginning at stream->next_uframe 48762306a36Sopenharmony_ci */ 48862306a36Sopenharmony_cistruct fotg210_iso_sched { 48962306a36Sopenharmony_ci struct list_head td_list; 49062306a36Sopenharmony_ci unsigned span; 49162306a36Sopenharmony_ci struct fotg210_iso_packet packet[]; 49262306a36Sopenharmony_ci}; 49362306a36Sopenharmony_ci 49462306a36Sopenharmony_ci/* 49562306a36Sopenharmony_ci * fotg210_iso_stream - groups all (s)itds for this endpoint. 49662306a36Sopenharmony_ci * acts like a qh would, if EHCI had them for ISO. 49762306a36Sopenharmony_ci */ 49862306a36Sopenharmony_cistruct fotg210_iso_stream { 49962306a36Sopenharmony_ci /* first field matches fotg210_hq, but is NULL */ 50062306a36Sopenharmony_ci struct fotg210_qh_hw *hw; 50162306a36Sopenharmony_ci 50262306a36Sopenharmony_ci u8 bEndpointAddress; 50362306a36Sopenharmony_ci u8 highspeed; 50462306a36Sopenharmony_ci struct list_head td_list; /* queued itds */ 50562306a36Sopenharmony_ci struct list_head free_list; /* list of unused itds */ 50662306a36Sopenharmony_ci struct usb_device *udev; 50762306a36Sopenharmony_ci struct usb_host_endpoint *ep; 50862306a36Sopenharmony_ci 50962306a36Sopenharmony_ci /* output of (re)scheduling */ 51062306a36Sopenharmony_ci int next_uframe; 51162306a36Sopenharmony_ci __hc32 splits; 51262306a36Sopenharmony_ci 51362306a36Sopenharmony_ci /* the rest is derived from the endpoint descriptor, 51462306a36Sopenharmony_ci * trusting urb->interval == f(epdesc->bInterval) and 51562306a36Sopenharmony_ci * including the extra info for hw_bufp[0..2] 51662306a36Sopenharmony_ci */ 51762306a36Sopenharmony_ci u8 usecs, c_usecs; 51862306a36Sopenharmony_ci u16 interval; 51962306a36Sopenharmony_ci u16 tt_usecs; 52062306a36Sopenharmony_ci u16 maxp; 52162306a36Sopenharmony_ci u16 raw_mask; 52262306a36Sopenharmony_ci unsigned bandwidth; 52362306a36Sopenharmony_ci 52462306a36Sopenharmony_ci /* This is used to initialize iTD's hw_bufp fields */ 52562306a36Sopenharmony_ci __hc32 buf0; 52662306a36Sopenharmony_ci __hc32 buf1; 52762306a36Sopenharmony_ci __hc32 buf2; 52862306a36Sopenharmony_ci 52962306a36Sopenharmony_ci /* this is used to initialize sITD's tt info */ 53062306a36Sopenharmony_ci __hc32 address; 53162306a36Sopenharmony_ci}; 53262306a36Sopenharmony_ci 53362306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 53462306a36Sopenharmony_ci 53562306a36Sopenharmony_ci/* 53662306a36Sopenharmony_ci * EHCI Specification 0.95 Section 3.3 53762306a36Sopenharmony_ci * Fig 3-4 "Isochronous Transaction Descriptor (iTD)" 53862306a36Sopenharmony_ci * 53962306a36Sopenharmony_ci * Schedule records for high speed iso xfers 54062306a36Sopenharmony_ci */ 54162306a36Sopenharmony_cistruct fotg210_itd { 54262306a36Sopenharmony_ci /* first part defined by EHCI spec */ 54362306a36Sopenharmony_ci __hc32 hw_next; /* see EHCI 3.3.1 */ 54462306a36Sopenharmony_ci __hc32 hw_transaction[8]; /* see EHCI 3.3.2 */ 54562306a36Sopenharmony_ci#define FOTG210_ISOC_ACTIVE (1<<31) /* activate transfer this slot */ 54662306a36Sopenharmony_ci#define FOTG210_ISOC_BUF_ERR (1<<30) /* Data buffer error */ 54762306a36Sopenharmony_ci#define FOTG210_ISOC_BABBLE (1<<29) /* babble detected */ 54862306a36Sopenharmony_ci#define FOTG210_ISOC_XACTERR (1<<28) /* XactErr - transaction error */ 54962306a36Sopenharmony_ci#define FOTG210_ITD_LENGTH(tok) (((tok)>>16) & 0x0fff) 55062306a36Sopenharmony_ci#define FOTG210_ITD_IOC (1 << 15) /* interrupt on complete */ 55162306a36Sopenharmony_ci 55262306a36Sopenharmony_ci#define ITD_ACTIVE(fotg210) cpu_to_hc32(fotg210, FOTG210_ISOC_ACTIVE) 55362306a36Sopenharmony_ci 55462306a36Sopenharmony_ci __hc32 hw_bufp[7]; /* see EHCI 3.3.3 */ 55562306a36Sopenharmony_ci __hc32 hw_bufp_hi[7]; /* Appendix B */ 55662306a36Sopenharmony_ci 55762306a36Sopenharmony_ci /* the rest is HCD-private */ 55862306a36Sopenharmony_ci dma_addr_t itd_dma; /* for this itd */ 55962306a36Sopenharmony_ci union fotg210_shadow itd_next; /* ptr to periodic q entry */ 56062306a36Sopenharmony_ci 56162306a36Sopenharmony_ci struct urb *urb; 56262306a36Sopenharmony_ci struct fotg210_iso_stream *stream; /* endpoint's queue */ 56362306a36Sopenharmony_ci struct list_head itd_list; /* list of stream's itds */ 56462306a36Sopenharmony_ci 56562306a36Sopenharmony_ci /* any/all hw_transactions here may be used by that urb */ 56662306a36Sopenharmony_ci unsigned frame; /* where scheduled */ 56762306a36Sopenharmony_ci unsigned pg; 56862306a36Sopenharmony_ci unsigned index[8]; /* in urb->iso_frame_desc */ 56962306a36Sopenharmony_ci} __aligned(32); 57062306a36Sopenharmony_ci 57162306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 57262306a36Sopenharmony_ci 57362306a36Sopenharmony_ci/* 57462306a36Sopenharmony_ci * EHCI Specification 0.96 Section 3.7 57562306a36Sopenharmony_ci * Periodic Frame Span Traversal Node (FSTN) 57662306a36Sopenharmony_ci * 57762306a36Sopenharmony_ci * Manages split interrupt transactions (using TT) that span frame boundaries 57862306a36Sopenharmony_ci * into uframes 0/1; see 4.12.2.2. In those uframes, a "save place" FSTN 57962306a36Sopenharmony_ci * makes the HC jump (back) to a QH to scan for fs/ls QH completions until 58062306a36Sopenharmony_ci * it hits a "restore" FSTN; then it returns to finish other uframe 0/1 work. 58162306a36Sopenharmony_ci */ 58262306a36Sopenharmony_cistruct fotg210_fstn { 58362306a36Sopenharmony_ci __hc32 hw_next; /* any periodic q entry */ 58462306a36Sopenharmony_ci __hc32 hw_prev; /* qh or FOTG210_LIST_END */ 58562306a36Sopenharmony_ci 58662306a36Sopenharmony_ci /* the rest is HCD-private */ 58762306a36Sopenharmony_ci dma_addr_t fstn_dma; 58862306a36Sopenharmony_ci union fotg210_shadow fstn_next; /* ptr to periodic q entry */ 58962306a36Sopenharmony_ci} __aligned(32); 59062306a36Sopenharmony_ci 59162306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 59262306a36Sopenharmony_ci 59362306a36Sopenharmony_ci/* Prepare the PORTSC wakeup flags during controller suspend/resume */ 59462306a36Sopenharmony_ci 59562306a36Sopenharmony_ci#define fotg210_prepare_ports_for_controller_suspend(fotg210, do_wakeup) \ 59662306a36Sopenharmony_ci fotg210_adjust_port_wakeup_flags(fotg210, true, do_wakeup) 59762306a36Sopenharmony_ci 59862306a36Sopenharmony_ci#define fotg210_prepare_ports_for_controller_resume(fotg210) \ 59962306a36Sopenharmony_ci fotg210_adjust_port_wakeup_flags(fotg210, false, false) 60062306a36Sopenharmony_ci 60162306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 60262306a36Sopenharmony_ci 60362306a36Sopenharmony_ci/* 60462306a36Sopenharmony_ci * Some EHCI controllers have a Transaction Translator built into the 60562306a36Sopenharmony_ci * root hub. This is a non-standard feature. Each controller will need 60662306a36Sopenharmony_ci * to add code to the following inline functions, and call them as 60762306a36Sopenharmony_ci * needed (mostly in root hub code). 60862306a36Sopenharmony_ci */ 60962306a36Sopenharmony_ci 61062306a36Sopenharmony_cistatic inline unsigned int 61162306a36Sopenharmony_cifotg210_get_speed(struct fotg210_hcd *fotg210, unsigned int portsc) 61262306a36Sopenharmony_ci{ 61362306a36Sopenharmony_ci return (readl(&fotg210->regs->otgcsr) 61462306a36Sopenharmony_ci & OTGCSR_HOST_SPD_TYP) >> 22; 61562306a36Sopenharmony_ci} 61662306a36Sopenharmony_ci 61762306a36Sopenharmony_ci/* Returns the speed of a device attached to a port on the root hub. */ 61862306a36Sopenharmony_cistatic inline unsigned int 61962306a36Sopenharmony_cifotg210_port_speed(struct fotg210_hcd *fotg210, unsigned int portsc) 62062306a36Sopenharmony_ci{ 62162306a36Sopenharmony_ci switch (fotg210_get_speed(fotg210, portsc)) { 62262306a36Sopenharmony_ci case 0: 62362306a36Sopenharmony_ci return 0; 62462306a36Sopenharmony_ci case 1: 62562306a36Sopenharmony_ci return USB_PORT_STAT_LOW_SPEED; 62662306a36Sopenharmony_ci case 2: 62762306a36Sopenharmony_ci default: 62862306a36Sopenharmony_ci return USB_PORT_STAT_HIGH_SPEED; 62962306a36Sopenharmony_ci } 63062306a36Sopenharmony_ci} 63162306a36Sopenharmony_ci 63262306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 63362306a36Sopenharmony_ci 63462306a36Sopenharmony_ci#define fotg210_has_fsl_portno_bug(e) (0) 63562306a36Sopenharmony_ci 63662306a36Sopenharmony_ci/* 63762306a36Sopenharmony_ci * While most USB host controllers implement their registers in 63862306a36Sopenharmony_ci * little-endian format, a minority (celleb companion chip) implement 63962306a36Sopenharmony_ci * them in big endian format. 64062306a36Sopenharmony_ci * 64162306a36Sopenharmony_ci * This attempts to support either format at compile time without a 64262306a36Sopenharmony_ci * runtime penalty, or both formats with the additional overhead 64362306a36Sopenharmony_ci * of checking a flag bit. 64462306a36Sopenharmony_ci * 64562306a36Sopenharmony_ci */ 64662306a36Sopenharmony_ci 64762306a36Sopenharmony_ci#define fotg210_big_endian_mmio(e) 0 64862306a36Sopenharmony_ci#define fotg210_big_endian_capbase(e) 0 64962306a36Sopenharmony_ci 65062306a36Sopenharmony_cistatic inline unsigned int fotg210_readl(const struct fotg210_hcd *fotg210, 65162306a36Sopenharmony_ci __u32 __iomem *regs) 65262306a36Sopenharmony_ci{ 65362306a36Sopenharmony_ci return readl(regs); 65462306a36Sopenharmony_ci} 65562306a36Sopenharmony_ci 65662306a36Sopenharmony_cistatic inline void fotg210_writel(const struct fotg210_hcd *fotg210, 65762306a36Sopenharmony_ci const unsigned int val, __u32 __iomem *regs) 65862306a36Sopenharmony_ci{ 65962306a36Sopenharmony_ci writel(val, regs); 66062306a36Sopenharmony_ci} 66162306a36Sopenharmony_ci 66262306a36Sopenharmony_ci/* cpu to fotg210 */ 66362306a36Sopenharmony_cistatic inline __hc32 cpu_to_hc32(const struct fotg210_hcd *fotg210, const u32 x) 66462306a36Sopenharmony_ci{ 66562306a36Sopenharmony_ci return cpu_to_le32(x); 66662306a36Sopenharmony_ci} 66762306a36Sopenharmony_ci 66862306a36Sopenharmony_ci/* fotg210 to cpu */ 66962306a36Sopenharmony_cistatic inline u32 hc32_to_cpu(const struct fotg210_hcd *fotg210, const __hc32 x) 67062306a36Sopenharmony_ci{ 67162306a36Sopenharmony_ci return le32_to_cpu(x); 67262306a36Sopenharmony_ci} 67362306a36Sopenharmony_ci 67462306a36Sopenharmony_cistatic inline u32 hc32_to_cpup(const struct fotg210_hcd *fotg210, 67562306a36Sopenharmony_ci const __hc32 *x) 67662306a36Sopenharmony_ci{ 67762306a36Sopenharmony_ci return le32_to_cpup(x); 67862306a36Sopenharmony_ci} 67962306a36Sopenharmony_ci 68062306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 68162306a36Sopenharmony_ci 68262306a36Sopenharmony_cistatic inline unsigned fotg210_read_frame_index(struct fotg210_hcd *fotg210) 68362306a36Sopenharmony_ci{ 68462306a36Sopenharmony_ci return fotg210_readl(fotg210, &fotg210->regs->frame_index); 68562306a36Sopenharmony_ci} 68662306a36Sopenharmony_ci 68762306a36Sopenharmony_ci/*-------------------------------------------------------------------------*/ 68862306a36Sopenharmony_ci 68962306a36Sopenharmony_ci#endif /* __LINUX_FOTG210_H */ 690