CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/cache/sources/wl/include/bcmsdspi.h
Views: 3959
1
/*
2
* SD-SPI Protocol Conversion - BCMSDH->SPI Translation Layer
3
*
4
* $ Copyright Open Broadcom Corporation $
5
*
6
* $Id: bcmsdspi.h 294363 2011-11-06 23:02:20Z $
7
*/
8
#ifndef _BCM_SD_SPI_H
9
#define _BCM_SD_SPI_H
10
11
/* global msglevel for debug messages - bitvals come from sdiovar.h */
12
13
#define sd_err(x)
14
#define sd_trace(x)
15
#define sd_info(x)
16
#define sd_debug(x)
17
#define sd_data(x)
18
#define sd_ctrl(x)
19
20
#define sd_log(x)
21
22
#define SDIOH_ASSERT(exp) \
23
do { if (!(exp)) \
24
printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
25
} while (0)
26
27
#define BLOCK_SIZE_4318 64
28
#define BLOCK_SIZE_4328 512
29
30
/* internal return code */
31
#define SUCCESS 0
32
#undef ERROR
33
#define ERROR 1
34
35
/* private bus modes */
36
#define SDIOH_MODE_SPI 0
37
38
#define USE_BLOCKMODE 0x2 /* Block mode can be single block or multi */
39
#define USE_MULTIBLOCK 0x4
40
41
struct sdioh_info {
42
uint cfg_bar; /* pci cfg address for bar */
43
uint32 caps; /* cached value of capabilities reg */
44
uint bar0; /* BAR0 for PCI Device */
45
osl_t *osh; /* osh handler */
46
void *controller; /* Pointer to SPI Controller's private data struct */
47
48
uint lockcount; /* nest count of sdspi_lock() calls */
49
bool client_intr_enabled; /* interrupt connnected flag */
50
bool intr_handler_valid; /* client driver interrupt handler valid */
51
sdioh_cb_fn_t intr_handler; /* registered interrupt handler */
52
void *intr_handler_arg; /* argument to call interrupt handler */
53
bool initialized; /* card initialized */
54
uint32 target_dev; /* Target device ID */
55
uint32 intmask; /* Current active interrupts */
56
void *sdos_info; /* Pointer to per-OS private data */
57
58
uint32 controller_type; /* Host controller type */
59
uint8 version; /* Host Controller Spec Compliance Version */
60
uint irq; /* Client irq */
61
uint32 intrcount; /* Client interrupts */
62
uint32 local_intrcount; /* Controller interrupts */
63
bool host_init_done; /* Controller initted */
64
bool card_init_done; /* Client SDIO interface initted */
65
bool polled_mode; /* polling for command completion */
66
67
bool sd_use_dma; /* DMA on CMD53 */
68
bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
69
/* Must be on for sd_multiblock to be effective */
70
bool use_client_ints; /* If this is false, make sure to restore */
71
bool got_hcint; /* Host Controller interrupt. */
72
/* polling hack in wl_linux.c:wl_timer() */
73
int adapter_slot; /* Maybe dealing with multiple slots/controllers */
74
int sd_mode; /* SD1/SD4/SPI */
75
int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */
76
uint32 data_xfer_count; /* Current register transfer size */
77
uint32 cmd53_wr_data; /* Used to pass CMD53 write data */
78
uint32 card_response; /* Used to pass back response status byte */
79
uint32 card_rsp_data; /* Used to pass back response data word */
80
uint16 card_rca; /* Current Address */
81
uint8 num_funcs; /* Supported funcs on client */
82
uint32 com_cis_ptr;
83
uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
84
void *dma_buf;
85
ulong dma_phys;
86
int r_cnt; /* rx count */
87
int t_cnt; /* tx_count */
88
};
89
90
/************************************************************
91
* Internal interfaces: per-port references into bcmsdspi.c
92
*/
93
94
/* Global message bits */
95
extern uint sd_msglevel;
96
97
/**************************************************************
98
* Internal interfaces: bcmsdspi.c references to per-port code
99
*/
100
101
/* Register mapping routines */
102
extern uint32 *spi_reg_map(osl_t *osh, uintptr addr, int size);
103
extern void spi_reg_unmap(osl_t *osh, uintptr addr, int size);
104
105
/* Interrupt (de)registration routines */
106
extern int spi_register_irq(sdioh_info_t *sd, uint irq);
107
extern void spi_free_irq(uint irq, sdioh_info_t *sd);
108
109
/* OS-specific interrupt wrappers (atomic interrupt enable/disable) */
110
extern void spi_lock(sdioh_info_t *sd);
111
extern void spi_unlock(sdioh_info_t *sd);
112
113
/* Allocate/init/free per-OS private data */
114
extern int spi_osinit(sdioh_info_t *sd);
115
extern void spi_osfree(sdioh_info_t *sd);
116
117
#endif /* _BCM_SD_SPI_H */
118
119