Commit | Line | Data |
---|---|---|
1b4a7c03 LJ |
1 | /* |
2 | * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel | |
3 | * | |
4 | * Copyright (C) 2020, Broadcom. | |
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 | * | |
21 | * <<Broadcom-WL-IPTag/Dual:>> | |
22 | */ | |
23 | ||
24 | #ifndef __BCMSDH_SDMMC_H__ | |
25 | #define __BCMSDH_SDMMC_H__ | |
26 | ||
27 | #define sd_err(x) do { if (sd_msglevel & SDH_ERROR_VAL) printf x; } while (0) | |
28 | #define sd_trace(x) do { if (sd_msglevel & SDH_TRACE_VAL) printf x; } while (0) | |
29 | #define sd_info(x) do { if (sd_msglevel & SDH_INFO_VAL) printf x; } while (0) | |
30 | #define sd_debug(x) do { if (sd_msglevel & SDH_DEBUG_VAL) printf x; } while (0) | |
31 | #define sd_data(x) do { if (sd_msglevel & SDH_DATA_VAL) printf x; } while (0) | |
32 | #define sd_ctrl(x) do { if (sd_msglevel & SDH_CTRL_VAL) printf x; } while (0) | |
33 | #define sd_cost(x) do { if (sd_msglevel & SDH_COST_VAL) printf x; } while (0) | |
34 | ||
35 | #define sd_sync_dma(sd, read, nbytes) | |
36 | #define sd_init_dma(sd) | |
37 | #define sd_ack_intr(sd) | |
38 | #define sd_wakeup(sd); | |
39 | ||
40 | #define sd_log(x) | |
41 | ||
42 | #define SDIOH_ASSERT(exp) \ | |
43 | do { if (!(exp)) \ | |
44 | printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \ | |
45 | } while (0) | |
46 | ||
47 | #define BLOCK_SIZE_4318 64 | |
48 | #define BLOCK_SIZE_4328 512 | |
49 | ||
50 | /* internal return code */ | |
51 | #define SUCCESS 0 | |
52 | #define ERROR 1 | |
53 | ||
54 | /* private bus modes */ | |
55 | #define SDIOH_MODE_SD4 2 | |
56 | #define CLIENT_INTR 0x100 /* Get rid of this! */ | |
57 | #define SDIOH_SDMMC_MAX_SG_ENTRIES 64 | |
58 | ||
59 | struct sdioh_info { | |
60 | osl_t *osh; /* osh handler */ | |
61 | void *bcmsdh; /* upper layer handle */ | |
62 | bool client_intr_enabled; /* interrupt connnected flag */ | |
63 | bool intr_handler_valid; /* client driver interrupt handler valid */ | |
64 | sdioh_cb_fn_t intr_handler; /* registered interrupt handler */ | |
65 | void *intr_handler_arg; /* argument to call interrupt handler */ | |
66 | uint16 intmask; /* Current active interrupts */ | |
67 | ||
68 | int intrcount; /* Client interrupts */ | |
69 | bool sd_use_dma; /* DMA on CMD53 */ | |
70 | bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */ | |
71 | /* Must be on for sd_multiblock to be effective */ | |
72 | bool use_client_ints; /* If this is false, make sure to restore */ | |
73 | int sd_mode; /* SD1/SD4/SPI */ | |
74 | int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */ | |
75 | uint8 num_funcs; /* Supported funcs on client */ | |
76 | uint32 com_cis_ptr; | |
77 | uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; | |
78 | bool use_rxchain; | |
79 | struct scatterlist sg_list[SDIOH_SDMMC_MAX_SG_ENTRIES]; | |
80 | struct sdio_func fake_func0; | |
81 | struct sdio_func *func[SDIOD_MAX_IOFUNCS]; | |
82 | uint sd_clk_rate; | |
83 | uint txglom_mode; /* Txglom mode: 0 - copy, 1 - multi-descriptor */ | |
84 | uint32 sdio_spent_time_us; | |
85 | }; | |
86 | ||
87 | /************************************************************ | |
88 | * Internal interfaces: per-port references into bcmsdh_sdmmc.c | |
89 | */ | |
90 | ||
91 | /* Global message bits */ | |
92 | extern uint sd_msglevel; | |
93 | ||
94 | /* OS-independent interrupt handler */ | |
95 | extern bool check_client_intr(sdioh_info_t *sd); | |
96 | ||
97 | /* Core interrupt enable/disable of device interrupts */ | |
98 | extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd); | |
99 | extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd); | |
100 | ||
101 | /************************************************************** | |
102 | * Internal interfaces: bcmsdh_sdmmc.c references to per-port code | |
103 | */ | |
104 | ||
105 | /* Register mapping routines */ | |
106 | extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size); | |
107 | extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size); | |
108 | ||
109 | /* Interrupt (de)registration routines */ | |
110 | extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq); | |
111 | extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd); | |
112 | ||
113 | extern sdioh_info_t *sdioh_attach(osl_t *osh, struct sdio_func *func); | |
114 | extern SDIOH_API_RC sdioh_detach(osl_t *osh, sdioh_info_t *sd); | |
115 | ||
116 | #ifdef GLOBAL_SDMMC_INSTANCE | |
117 | typedef struct _BCMSDH_SDMMC_INSTANCE { | |
118 | sdioh_info_t *sd; | |
119 | struct sdio_func *func[SDIOD_MAX_IOFUNCS]; | |
120 | } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE; | |
121 | #endif | |
122 | ||
123 | #endif /* __BCMSDH_SDMMC_H__ */ |