2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
17 #ifndef __BCMSDH_SDMMC_H__
18 #define __BCMSDH_SDMMC_H__
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)
36 /* Allocate/init/free per-OS private data */
37 extern int sdioh_sdmmc_osinit(sdioh_info_t *sd);
38 extern void sdioh_sdmmc_osfree(sdioh_info_t *sd);
40 #define BLOCK_SIZE_64 64
41 #define BLOCK_SIZE_512 512
42 #define BLOCK_SIZE_4318 64
43 #define BLOCK_SIZE_4328 512
45 /* internal return code */
49 /* private bus modes */
50 #define SDIOH_MODE_SD4 2
51 #define CLIENT_INTR 0x100 /* Get rid of this! */
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 */
59 u16 intmask; /* Current active interrupts */
60 void *sdos_info; /* Pointer to per-OS private data */
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 */
70 u8 num_funcs; /* Supported funcs on client */
72 u32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
74 uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */
75 /* SDDMA_DESCRIPTOR SGList[32]; *//* Scatter/Gather DMA List */
78 /************************************************************
79 * Internal interfaces: per-port references into bcmsdh_sdmmc.c
82 /* Global message bits */
83 extern uint sd_msglevel;
85 /* OS-independent interrupt handler */
86 extern bool check_client_intr(sdioh_info_t *sd);
88 /* Core interrupt enable/disable of device interrupts */
89 extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd);
90 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
92 /**************************************************************
93 * Internal interfaces: bcmsdh_sdmmc.c references to per-port code
96 /* Register mapping routines */
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);
100 /* Interrupt (de)registration routines */
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);
104 typedef struct _BCMSDH_SDMMC_INSTANCE {
106 struct sdio_func *func[SDIOD_MAX_IOFUNCS];
108 } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE;
110 #endif /* __BCMSDH_SDMMC_H__ */