]>
Commit | Line | Data |
---|---|---|
a9533e7e HP |
1 | /* |
2 | * Copyright (c) 2010 Broadcom Corporation | |
3 | * | |
4 | * Permission to use, copy, modify, and/or distribute this software for any | |
5 | * purpose with or without fee is hereby granted, provided that the above | |
6 | * copyright notice and this permission notice appear in all copies. | |
7 | * | |
8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
11 | * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | |
13 | * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |
14 | * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
15 | */ | |
16 | ||
17 | #ifndef __BCMSDH_SDMMC_H__ | |
18 | #define __BCMSDH_SDMMC_H__ | |
19 | ||
20 | #ifdef BCMDBG | |
21 | #define sd_err(x) do { if ((sd_msglevel & SDH_ERROR_VAL) && net_ratelimit()) printf x; } while (0) | |
22 | #define sd_trace(x) do { if ((sd_msglevel & SDH_TRACE_VAL) && net_ratelimit()) printf x; } while (0) | |
23 | #define sd_info(x) do { if ((sd_msglevel & SDH_INFO_VAL) && net_ratelimit()) printf x; } while (0) | |
24 | #define sd_debug(x) do { if ((sd_msglevel & SDH_DEBUG_VAL) && net_ratelimit()) printf x; } while (0) | |
25 | #define sd_data(x) do { if ((sd_msglevel & SDH_DATA_VAL) && net_ratelimit()) printf x; } while (0) | |
26 | #define sd_ctrl(x) do { if ((sd_msglevel & SDH_CTRL_VAL) && net_ratelimit()) printf x; } while (0) | |
27 | #else | |
28 | #define sd_err(x) | |
29 | #define sd_trace(x) | |
30 | #define sd_info(x) | |
31 | #define sd_debug(x) | |
32 | #define sd_data(x) | |
33 | #define sd_ctrl(x) | |
34 | #endif | |
35 | ||
36 | /* Allocate/init/free per-OS private data */ | |
7cc4a4c0 JC |
37 | extern int sdioh_sdmmc_osinit(sdioh_info_t *sd); |
38 | extern void sdioh_sdmmc_osfree(sdioh_info_t *sd); | |
a9533e7e HP |
39 | |
40 | #define BLOCK_SIZE_64 64 | |
41 | #define BLOCK_SIZE_512 512 | |
cf2b4488 HP |
42 | #define BLOCK_SIZE_4318 64 |
43 | #define BLOCK_SIZE_4328 512 | |
a9533e7e HP |
44 | |
45 | /* internal return code */ | |
46 | #define SUCCESS 0 | |
47 | #define ERROR 1 | |
48 | ||
49 | /* private bus modes */ | |
50 | #define SDIOH_MODE_SD4 2 | |
51 | #define CLIENT_INTR 0x100 /* Get rid of this! */ | |
52 | ||
53 | struct sdioh_info { | |
54 | osl_t *osh; /* osh handler */ | |
55 | bool client_intr_enabled; /* interrupt connnected flag */ | |
56 | bool intr_handler_valid; /* client driver interrupt handler valid */ | |
57 | sdioh_cb_fn_t intr_handler; /* registered interrupt handler */ | |
58 | void *intr_handler_arg; /* argument to call interrupt handler */ | |
7d4df48e | 59 | u16 intmask; /* Current active interrupts */ |
a9533e7e HP |
60 | void *sdos_info; /* Pointer to per-OS private data */ |
61 | ||
62 | uint irq; /* Client irq */ | |
63 | int intrcount; /* Client interrupts */ | |
64 | bool sd_use_dma; /* DMA on CMD53 */ | |
65 | bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */ | |
66 | /* Must be on for sd_multiblock to be effective */ | |
67 | bool use_client_ints; /* If this is false, make sure to restore */ | |
68 | int sd_mode; /* SD1/SD4/SPI */ | |
69 | int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */ | |
de9bca63 | 70 | u8 num_funcs; /* Supported funcs on client */ |
66cbd3ab GKH |
71 | u32 com_cis_ptr; |
72 | u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; | |
a9533e7e HP |
73 | uint max_dma_len; |
74 | uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */ | |
75 | /* SDDMA_DESCRIPTOR SGList[32]; *//* Scatter/Gather DMA List */ | |
76 | }; | |
77 | ||
78 | /************************************************************ | |
79 | * Internal interfaces: per-port references into bcmsdh_sdmmc.c | |
80 | */ | |
81 | ||
82 | /* Global message bits */ | |
83 | extern uint sd_msglevel; | |
84 | ||
85 | /* OS-independent interrupt handler */ | |
7cc4a4c0 | 86 | extern bool check_client_intr(sdioh_info_t *sd); |
a9533e7e HP |
87 | |
88 | /* Core interrupt enable/disable of device interrupts */ | |
7cc4a4c0 JC |
89 | extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd); |
90 | extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd); | |
a9533e7e HP |
91 | |
92 | /************************************************************** | |
93 | * Internal interfaces: bcmsdh_sdmmc.c references to per-port code | |
94 | */ | |
95 | ||
96 | /* Register mapping routines */ | |
3e26416e GKH |
97 | extern u32 *sdioh_sdmmc_reg_map(osl_t *osh, s32 addr, int size); |
98 | extern void sdioh_sdmmc_reg_unmap(osl_t *osh, s32 addr, int size); | |
a9533e7e HP |
99 | |
100 | /* Interrupt (de)registration routines */ | |
7cc4a4c0 JC |
101 | extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq); |
102 | extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd); | |
a9533e7e HP |
103 | |
104 | typedef struct _BCMSDH_SDMMC_INSTANCE { | |
105 | sdioh_info_t *sd; | |
106 | struct sdio_func *func[SDIOD_MAX_IOFUNCS]; | |
66cbd3ab | 107 | u32 host_claimed; |
a9533e7e HP |
108 | } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE; |
109 | ||
110 | #endif /* __BCMSDH_SDMMC_H__ */ |