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/bcmspibrcm.h
Views: 3959
1
/*
2
* SD-SPI Protocol Conversion - BCMSDH->gSPI Translation Layer
3
*
4
* Copyright (C) 2013, Broadcom Corporation
5
* All Rights Reserved.
6
*
7
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
8
* the contents of this file may not be disclosed to third parties, copied
9
* or duplicated in any form, in whole or in part, without the prior
10
* written permission of Broadcom Corporation.
11
*
12
* $Id: bcmspibrcm.h 241182 2011-02-17 21:50:03Z $
13
*/
14
#ifndef _BCM_SPI_BRCM_H
15
#define _BCM_SPI_BRCM_H
16
17
/* global msglevel for debug messages - bitvals come from sdiovar.h */
18
19
#define sd_err(x)
20
#define sd_trace(x)
21
#define sd_info(x)
22
#define sd_debug(x)
23
#define sd_data(x)
24
#define sd_ctrl(x)
25
26
#define sd_log(x)
27
28
#define SDIOH_ASSERT(exp) \
29
do { if (!(exp)) \
30
printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
31
} while (0)
32
33
#define BLOCK_SIZE_F1 64
34
#define BLOCK_SIZE_F2 2048
35
#define BLOCK_SIZE_F3 2048
36
37
/* internal return code */
38
#define SUCCESS 0
39
#undef ERROR
40
#define ERROR 1
41
#define ERROR_UF 2
42
#define ERROR_OF 3
43
44
/* private bus modes */
45
#define SDIOH_MODE_SPI 0
46
47
#define USE_BLOCKMODE 0x2 /* Block mode can be single block or multi */
48
#define USE_MULTIBLOCK 0x4
49
50
struct sdioh_info {
51
uint cfg_bar; /* pci cfg address for bar */
52
uint32 caps; /* cached value of capabilities reg */
53
void *bar0; /* BAR0 for PCI Device */
54
osl_t *osh; /* osh handler */
55
void *controller; /* Pointer to SPI Controller's private data struct */
56
57
uint lockcount; /* nest count of spi_lock() calls */
58
bool client_intr_enabled; /* interrupt connnected flag */
59
bool intr_handler_valid; /* client driver interrupt handler valid */
60
sdioh_cb_fn_t intr_handler; /* registered interrupt handler */
61
void *intr_handler_arg; /* argument to call interrupt handler */
62
bool initialized; /* card initialized */
63
uint32 target_dev; /* Target device ID */
64
uint32 intmask; /* Current active interrupts */
65
void *sdos_info; /* Pointer to per-OS private data */
66
67
uint32 controller_type; /* Host controller type */
68
uint8 version; /* Host Controller Spec Compliance Version */
69
uint irq; /* Client irq */
70
uint32 intrcount; /* Client interrupts */
71
uint32 local_intrcount; /* Controller interrupts */
72
bool host_init_done; /* Controller initted */
73
bool card_init_done; /* Client SDIO interface initted */
74
bool polled_mode; /* polling for command completion */
75
76
bool sd_use_dma; /* DMA on CMD53 */
77
bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
78
/* Must be on for sd_multiblock to be effective */
79
bool use_client_ints; /* If this is false, make sure to restore */
80
/* polling hack in wl_linux.c:wl_timer() */
81
int adapter_slot; /* Maybe dealing with multiple slots/controllers */
82
int sd_mode; /* SD1/SD4/SPI */
83
int client_block_size[SPI_MAX_IOFUNCS]; /* Blocksize */
84
uint32 data_xfer_count; /* Current transfer */
85
uint16 card_rca; /* Current Address */
86
uint8 num_funcs; /* Supported funcs on client */
87
uint32 card_dstatus; /* 32bit device status */
88
uint32 com_cis_ptr;
89
uint32 func_cis_ptr[SPI_MAX_IOFUNCS];
90
void *dma_buf;
91
ulong dma_phys;
92
int r_cnt; /* rx count */
93
int t_cnt; /* tx_count */
94
uint32 wordlen; /* host processor 16/32bits */
95
uint32 prev_fun;
96
uint32 chip;
97
uint32 chiprev;
98
bool resp_delay_all;
99
bool dwordmode;
100
bool resp_delay_new;
101
102
struct spierrstats_t spierrstats;
103
};
104
105
/************************************************************
106
* Internal interfaces: per-port references into bcmspibrcm.c
107
*/
108
109
/* Global message bits */
110
extern uint sd_msglevel;
111
112
/**************************************************************
113
* Internal interfaces: bcmspibrcm.c references to per-port code
114
*/
115
116
/* Interrupt (de)registration routines */
117
extern int spi_register_irq(sdioh_info_t *sd, uint irq);
118
extern void spi_free_irq(uint irq, sdioh_info_t *sd);
119
120
/* OS-specific interrupt wrappers (atomic interrupt enable/disable) */
121
extern void spi_lock(sdioh_info_t *sd);
122
extern void spi_unlock(sdioh_info_t *sd);
123
124
/* Allocate/init/free per-OS private data */
125
extern int spi_osinit(sdioh_info_t *sd);
126
extern void spi_osfree(sdioh_info_t *sd);
127
128
#define SPI_RW_FLAG_M BITFIELD_MASK(1) /* Bit [31] - R/W Command Bit */
129
#define SPI_RW_FLAG_S 31
130
#define SPI_ACCESS_M BITFIELD_MASK(1) /* Bit [30] - Fixed/Incr Access */
131
#define SPI_ACCESS_S 30
132
#define SPI_FUNCTION_M BITFIELD_MASK(2) /* Bit [29:28] - Function Number */
133
#define SPI_FUNCTION_S 28
134
#define SPI_REG_ADDR_M BITFIELD_MASK(17) /* Bit [27:11] - Address */
135
#define SPI_REG_ADDR_S 11
136
#define SPI_LEN_M BITFIELD_MASK(11) /* Bit [10:0] - Packet length */
137
#define SPI_LEN_S 0
138
139
#endif /* _BCM_SPI_BRCM_H */
140
141