Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/next/external/cache/sources/wl/include/bcmsdh.h
Views: 3959
/*1* SDIO host client driver interface of Broadcom HNBU2* export functions to client drivers3* abstract OS and BUS specific details of SDIO4*5* $ Copyright Open License Broadcom Corporation $6*7* $Id: bcmsdh.h 327775 2012-04-16 18:54:32Z $8*/910/**11* @file bcmsdh.h12*/1314#ifndef _bcmsdh_h_15#define _bcmsdh_h_1617#define BCMSDH_ERROR_VAL 0x0001 /* Error */18#define BCMSDH_INFO_VAL 0x0002 /* Info */19extern const uint bcmsdh_msglevel;2021#define BCMSDH_ERROR(x)22#define BCMSDH_INFO(x)2324#if (defined(BCMSDIOH_STD) || defined(BCMSDIOH_BCM) || defined(BCMSDIOH_SPI))25#define BCMSDH_ADAPTER26#endif /* BCMSDIO && (BCMSDIOH_STD || BCMSDIOH_BCM || BCMSDIOH_SPI) */2728/* forward declarations */29typedef struct bcmsdh_info bcmsdh_info_t;30typedef void (*bcmsdh_cb_fn_t)(void *);3132/* Attach and build an interface to the underlying SD host driver.33* - Allocates resources (structs, arrays, mem, OS handles, etc) needed by bcmsdh.34* - Returns the bcmsdh handle and virtual address base for register access.35* The returned handle should be used in all subsequent calls, but the bcmsh36* implementation may maintain a single "default" handle (e.g. the first or37* most recent one) to enable single-instance implementations to pass NULL.38*/3940#if 0 && (NDISVER >= 0x0630) && 141extern bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl,42void **regsva, uint irq, shared_info_t *sh);43#else44extern bcmsdh_info_t *bcmsdh_attach(osl_t *osh, void *cfghdl, void **regsva, uint irq);45#endif4647/* Detach - freeup resources allocated in attach */48extern int bcmsdh_detach(osl_t *osh, void *sdh);4950/* Query if SD device interrupts are enabled */51extern bool bcmsdh_intr_query(void *sdh);5253/* Enable/disable SD interrupt */54extern int bcmsdh_intr_enable(void *sdh);55extern int bcmsdh_intr_disable(void *sdh);5657/* Register/deregister device interrupt handler. */58extern int bcmsdh_intr_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);59extern int bcmsdh_intr_dereg(void *sdh);6061#if defined(DHD_DEBUG)62/* Query pending interrupt status from the host controller */63extern bool bcmsdh_intr_pending(void *sdh);64#endif6566/* Register a callback to be called if and when bcmsdh detects67* device removal. No-op in the case of non-removable/hardwired devices.68*/69extern int bcmsdh_devremove_reg(void *sdh, bcmsdh_cb_fn_t fn, void *argh);7071/* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).72* fn: function number73* addr: unmodified SDIO-space address74* data: data byte to write75* err: pointer to error code (or NULL)76*/77extern uint8 bcmsdh_cfg_read(void *sdh, uint func, uint32 addr, int *err);78extern void bcmsdh_cfg_write(void *sdh, uint func, uint32 addr, uint8 data, int *err);7980/* Read/Write 4bytes from/to cfg space */81extern uint32 bcmsdh_cfg_read_word(void *sdh, uint fnc_num, uint32 addr, int *err);82extern void bcmsdh_cfg_write_word(void *sdh, uint fnc_num, uint32 addr, uint32 data, int *err);8384/* Read CIS content for specified function.85* fn: function whose CIS is being requested (0 is common CIS)86* cis: pointer to memory location to place results87* length: number of bytes to read88* Internally, this routine uses the values from the cis base regs (0x9-0xB)89* to form an SDIO-space address to read the data from.90*/91extern int bcmsdh_cis_read(void *sdh, uint func, uint8 *cis, uint length);9293/* Synchronous access to device (client) core registers via CMD53 to F1.94* addr: backplane address (i.e. >= regsva from attach)95* size: register width in bytes (2 or 4)96* data: data for register write97*/98extern uint32 bcmsdh_reg_read(void *sdh, uint32 addr, uint size);99extern uint32 bcmsdh_reg_write(void *sdh, uint32 addr, uint size, uint32 data);100101/* set sb address window */102extern int bcmsdhsdio_set_sbaddr_window(void *sdh, uint32 address, bool force_set);103104/* Indicate if last reg read/write failed */105extern bool bcmsdh_regfail(void *sdh);106107/* Buffer transfer to/from device (client) core via cmd53.108* fn: function number109* addr: backplane address (i.e. >= regsva from attach)110* flags: backplane width, address increment, sync/async111* buf: pointer to memory data buffer112* nbytes: number of bytes to transfer to/from buf113* pkt: pointer to packet associated with buf (if any)114* complete: callback function for command completion (async only)115* handle: handle for completion callback (first arg in callback)116* Returns 0 or error code.117* NOTE: Async operation is not currently supported.118*/119typedef void (*bcmsdh_cmplt_fn_t)(void *handle, int status, bool sync_waiting);120extern int bcmsdh_send_buf(void *sdh, uint32 addr, uint fn, uint flags,121uint8 *buf, uint nbytes, void *pkt,122bcmsdh_cmplt_fn_t complete_fn, void *handle);123extern int bcmsdh_recv_buf(void *sdh, uint32 addr, uint fn, uint flags,124uint8 *buf, uint nbytes, void *pkt,125bcmsdh_cmplt_fn_t complete_fn, void *handle);126127/* Flags bits */128#define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */129#define SDIO_REQ_FIXED 0x2 /* Fixed address (FIFO) (vs. incrementing address) */130#define SDIO_REQ_ASYNC 0x4 /* Async request (vs. sync request) */131#define SDIO_BYTE_MODE 0x8 /* Byte mode request(non-block mode) */132133/* Pending (non-error) return code */134#define BCME_PENDING 1135136/* Read/write to memory block (F1, no FIFO) via CMD53 (sync only).137* rw: read or write (0/1)138* addr: direct SDIO address139* buf: pointer to memory data buffer140* nbytes: number of bytes to transfer to/from buf141* Returns 0 or error code.142*/143extern int bcmsdh_rwdata(void *sdh, uint rw, uint32 addr, uint8 *buf, uint nbytes);144145/* Issue an abort to the specified function */146extern int bcmsdh_abort(void *sdh, uint fn);147148/* Start SDIO Host Controller communication */149extern int bcmsdh_start(void *sdh, int stage);150151/* Stop SDIO Host Controller communication */152extern int bcmsdh_stop(void *sdh);153154/* Wait system lock free */155extern int bcmsdh_waitlockfree(void *sdh);156157/* Returns the "Device ID" of target device on the SDIO bus. */158extern int bcmsdh_query_device(void *sdh);159160/* Returns the number of IO functions reported by the device */161extern uint bcmsdh_query_iofnum(void *sdh);162163/* Miscellaneous knob tweaker. */164extern int bcmsdh_iovar_op(void *sdh, const char *name,165void *params, int plen, void *arg, int len, bool set);166167/* Reset and reinitialize the device */168extern int bcmsdh_reset(bcmsdh_info_t *sdh);169170/* helper functions */171172extern void *bcmsdh_get_sdioh(bcmsdh_info_t *sdh);173174/* callback functions */175typedef struct {176/* attach to device */177void *(*attach)(uint16 vend_id, uint16 dev_id, uint16 bus, uint16 slot,178uint16 func, uint bustype, void * regsva, osl_t * osh,179void * param);180/* detach from device */181void (*detach)(void *ch);182} bcmsdh_driver_t;183184/* platform specific/high level functions */185extern int bcmsdh_register(bcmsdh_driver_t *driver);186extern void bcmsdh_unregister(void);187extern bool bcmsdh_chipmatch(uint16 vendor, uint16 device);188extern void bcmsdh_device_remove(void * sdh);189190#if defined(OOB_INTR_ONLY)191extern int bcmsdh_register_oob_intr(void * dhdp);192extern void bcmsdh_unregister_oob_intr(void);193extern void bcmsdh_oob_intr_set(bool enable);194#endif /* defined(OOB_INTR_ONLY) */195196/* Function to pass device-status bits to DHD. */197extern uint32 bcmsdh_get_dstatus(void *sdh);198199/* Function to return current window addr */200extern uint32 bcmsdh_cur_sbwad(void *sdh);201202/* Function to pass chipid and rev to lower layers for controlling pr's */203extern void bcmsdh_chipinfo(void *sdh, uint32 chip, uint32 chiprev);204205#ifdef BCMSPI206extern void bcmsdh_dwordmode(void *sdh, bool set);207#endif /* BCMSPI */208209extern int bcmsdh_sleep(void *sdh, bool enab);210211/* GPIO support */212extern int bcmsdh_gpio_init(void *sd);213extern bool bcmsdh_gpioin(void *sd, uint32 gpio);214extern int bcmsdh_gpioouten(void *sd, uint32 gpio);215extern int bcmsdh_gpioout(void *sd, uint32 gpio, bool enab);216217#endif /* _bcmsdh_h_ */218219220