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/bcmsdh_fd.h
Views: 3960
1
/*
2
* BCMSDH Function Driver for SDIO-Linux
3
*
4
* Copyright (C) 1999-2012, Broadcom Corporation
5
*
6
* Unless you and Broadcom execute a separate written software license
7
* agreement governing use of this software, this software is licensed to you
8
* under the terms of the GNU General Public License version 2 (the "GPL"),
9
* available at http://www.broadcom.com/licenses/GPLv2.php, with the
10
* following added to such license:
11
*
12
* As a special exception, the copyright holders of this software give you
13
* permission to link this software with independent modules, and to copy and
14
* distribute the resulting executable under terms of your choice, provided that
15
* you also meet, for each linked independent module, the terms and conditions of
16
* the license of that module. An independent module is a module which is not
17
* derived from this software. The special exception does not apply to any
18
* modifications of the software.
19
*
20
* Notwithstanding the above, under no circumstances may you combine this
21
* software in any way with any other Broadcom software provided under a license
22
* other than the GPL, without Broadcom's express prior written consent.
23
*
24
* $Id: bcmsdh_fd.h 241182 2011-02-17 21:50:03Z gmo $
25
*/
26
27
#ifndef __BCMSDH_FD_H__
28
#define __BCMSDH_FD_H__
29
30
#ifdef BCMDBG
31
#define sd_err(x) do { if (sd_msglevel & SDH_ERROR_VAL) printf x; } while (0)
32
#define sd_trace(x) do { if (sd_msglevel & SDH_TRACE_VAL) printf x; } while (0)
33
#define sd_info(x) do { if (sd_msglevel & SDH_INFO_VAL) printf x; } while (0)
34
#define sd_debug(x) do { if (sd_msglevel & SDH_DEBUG_VAL) printf x; } while (0)
35
#define sd_data(x) do { if (sd_msglevel & SDH_DATA_VAL) printf x; } while (0)
36
#define sd_ctrl(x) do { if (sd_msglevel & SDH_CTRL_VAL) printf x; } while (0)
37
#else
38
#define sd_err(x)
39
#define sd_trace(x)
40
#define sd_info(x)
41
#define sd_debug(x)
42
#define sd_data(x)
43
#define sd_ctrl(x)
44
#endif
45
46
#define sd_sync_dma(sd, read, nbytes)
47
#define sd_init_dma(sd)
48
#define sd_ack_intr(sd)
49
#define sd_wakeup(sd);
50
/* Allocate/init/free per-OS private data */
51
extern int sdiohfd_osinit(sdioh_info_t *sd);
52
extern void sdiohfd_osfree(sdioh_info_t *sd);
53
54
#ifdef BCMPERFSTATS
55
#define sd_log(x) do { if (sd_msglevel & SDH_LOG_VAL) bcmlog x; } while (0)
56
#else
57
#define sd_log(x)
58
#endif
59
60
#define SDIOH_ASSERT(exp) \
61
do { if (!(exp)) \
62
printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
63
} while (0)
64
65
#define BLOCK_SIZE_4318 64
66
#define BLOCK_SIZE_4328 512
67
68
/* internal return code */
69
#define SUCCESS 0
70
#define ERROR 1
71
72
/* private bus modes */
73
#define SDIOH_MODE_SD4 2
74
#define CLIENT_INTR 0x100 /* Get rid of this! */
75
#define DMA_MAX_LEN (7*1024)
76
77
struct sdioh_info {
78
osl_t *osh; /* osh handler */
79
bool client_intr_enabled; /* interrupt connnected flag */
80
bool intr_handler_valid; /* client driver interrupt handler valid */
81
sdioh_cb_fn_t intr_handler; /* registered interrupt handler */
82
void *intr_handler_arg; /* argument to call interrupt handler */
83
uint16 intmask; /* Current active interrupts */
84
void *sdos_info; /* Pointer to per-OS private data */
85
86
uint irq; /* Client irq */
87
int intrcount; /* Client interrupts */
88
89
bool sd_use_dma; /* DMA on CMD53 */
90
bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
91
/* Must be on for sd_multiblock to be effective */
92
bool use_client_ints; /* If this is false, make sure to restore */
93
int sd_mode; /* SD1/SD4/SPI */
94
int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */
95
uint8 num_funcs; /* Supported funcs on client */
96
uint32 com_cis_ptr;
97
uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
98
uint max_dma_len;
99
uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */
100
SDDMA_DESCRIPTOR SGList[32]; /* Scatter/Gather DMA List */
101
};
102
103
/************************************************************
104
* Internal interfaces: per-port references into bcmsdiohfd.c
105
*/
106
107
/* Global message bits */
108
extern uint sd_msglevel;
109
110
/* OS-independent interrupt handler */
111
extern bool check_client_intr(sdioh_info_t *sd);
112
113
/* Core interrupt enable/disable of device interrupts */
114
extern void sdiohfd_devintr_on(sdioh_info_t *sd);
115
extern void sdiohfd_devintr_off(sdioh_info_t *sd);
116
117
118
/**************************************************************
119
* Internal interfaces: bcmsdiohfd.c references to per-port code
120
*/
121
122
/* Register mapping routines */
123
extern uint32 *sdiohfd_reg_map(osl_t *osh, int32 addr, int size);
124
extern void sdiohfd_reg_unmap(osl_t *osh, int32 addr, int size);
125
126
/* Interrupt (de)registration routines */
127
extern int sdiohfd_register_irq(sdioh_info_t *sd, uint irq);
128
extern void sdiohfd_free_irq(uint irq, sdioh_info_t *sd);
129
130
typedef struct _BCMSDH_FD_INSTANCE {
131
PSDDEVICE pDevice[3]; /* bus driver's device we are supporting */
132
sdioh_info_t *sd;
133
SDIO_STATUS LastRequestStatus; /* last request status */
134
} BCMSDH_FD_INSTANCE, *PBCMSDH_FD_INSTANCE;
135
136
typedef struct _BCMSDH_FD_CONTEXT {
137
SDFUNCTION Function; /* function description for bus driver */
138
PBCMSDH_FD_INSTANCE pInstance;
139
SD_BUSCLOCK_RATE ClockOverride; /* clock rate override */
140
} BCMSDH_FD_CONTEXT, *PBCMSDH_FD_CONTEXT;
141
142
/* prototypes */
143
SDIO_STATUS client_init(PBCMSDH_FD_CONTEXT pFuncContext,
144
PBCMSDH_FD_INSTANCE pInstance,
145
PSDDEVICE pDevice);
146
void client_detach(PBCMSDH_FD_CONTEXT pFuncContext,
147
PBCMSDH_FD_INSTANCE pInstance);
148
149
#endif /* __BCMSDH_FD_H__ */
150
151