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
43 /* internal return code */
47 /* private bus modes */
48 #define SDIOH_MODE_SD4 2
49 #define CLIENT_INTR 0x100 /* Get rid of this! */
52 osl_t *osh; /* osh handler */
53 bool client_intr_enabled; /* interrupt connnected flag */
54 bool intr_handler_valid; /* client driver interrupt handler valid */
55 sdioh_cb_fn_t intr_handler; /* registered interrupt handler */
56 void *intr_handler_arg; /* argument to call interrupt handler */
57 uint16 intmask; /* Current active interrupts */
58 void *sdos_info; /* Pointer to per-OS private data */
60 uint irq; /* Client irq */
61 int intrcount; /* Client interrupts */
62 bool sd_use_dma; /* DMA on CMD53 */
63 bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
64 /* Must be on for sd_multiblock to be effective */
65 bool use_client_ints; /* If this is false, make sure to restore */
66 int sd_mode; /* SD1/SD4/SPI */
67 int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */
68 uint8 num_funcs; /* Supported funcs on client */
70 uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
72 uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */
73 /* SDDMA_DESCRIPTOR SGList[32]; *//* Scatter/Gather DMA List */
76 /************************************************************
77 * Internal interfaces: per-port references into bcmsdh_sdmmc.c
80 /* Global message bits */
81 extern uint sd_msglevel;
83 /* OS-independent interrupt handler */
84 extern bool check_client_intr(sdioh_info_t * sd);
86 /* Core interrupt enable/disable of device interrupts */
87 extern void sdioh_sdmmc_devintr_on(sdioh_info_t * sd);
88 extern void sdioh_sdmmc_devintr_off(sdioh_info_t * sd);
90 /**************************************************************
91 * Internal interfaces: bcmsdh_sdmmc.c references to per-port code
94 /* Register mapping routines */
95 extern uint32 *sdioh_sdmmc_reg_map(osl_t * osh, int32 addr, int size);
96 extern void sdioh_sdmmc_reg_unmap(osl_t * osh, int32 addr, int size);
98 /* Interrupt (de)registration routines */
99 extern int sdioh_sdmmc_register_irq(sdioh_info_t * sd, uint irq);
100 extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t * sd);
102 typedef struct _BCMSDH_SDMMC_INSTANCE {
104 struct sdio_func *func[SDIOD_MAX_IOFUNCS];
106 } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE;
108 #endif /* __BCMSDH_SDMMC_H__ */