2 * BCMSDH Function Driver for SDIO-Linux
4 * Copyright (C) 1999-2011, Broadcom Corporation
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:
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.
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.
24 * $Id: bcmsdh_fd.h,v 13.5 2008-09-17 23:10:04 $
27 #ifndef __BCMSDH_FD_H__
28 #define __BCMSDH_FD_H__
37 #define sd_sync_dma(sd, read, nbytes)
38 #define sd_init_dma(sd)
39 #define sd_ack_intr(sd)
40 #define sd_wakeup(sd);
41 /* Allocate/init/free per-OS private data */
42 extern int sdiohfd_osinit(sdioh_info_t *sd);
43 extern void sdiohfd_osfree(sdioh_info_t *sd);
47 #define SDIOH_ASSERT(exp) \
49 printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
52 #define BLOCK_SIZE_4318 64
53 #define BLOCK_SIZE_4328 512
55 /* internal return code */
59 /* private bus modes */
60 #define SDIOH_MODE_SD4 2
61 #define CLIENT_INTR 0x100 /* Get rid of this! */
62 #define DMA_MAX_LEN (7*1024)
65 osl_t *osh; /* osh handler */
66 bool client_intr_enabled; /* interrupt connnected flag */
67 bool intr_handler_valid; /* client driver interrupt handler valid */
68 sdioh_cb_fn_t intr_handler; /* registered interrupt handler */
69 void *intr_handler_arg; /* argument to call interrupt handler */
70 uint16 intmask; /* Current active interrupts */
71 void *sdos_info; /* Pointer to per-OS private data */
73 uint irq; /* Client irq */
74 int intrcount; /* Client interrupts */
76 bool sd_use_dma; /* DMA on CMD53 */
77 bool sd_blockmode; /* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
78 /* Must be on for sd_multiblock to be effective */
79 bool use_client_ints; /* If this is false, make sure to restore */
80 int sd_mode; /* SD1/SD4/SPI */
81 int client_block_size[SDIOD_MAX_IOFUNCS]; /* Blocksize */
82 uint8 num_funcs; /* Supported funcs on client */
84 uint32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
86 uint max_dma_descriptors; /* DMA Descriptors supported by this controller. */
87 SDDMA_DESCRIPTOR SGList[32]; /* Scatter/Gather DMA List */
90 /************************************************************
91 * Internal interfaces: per-port references into bcmsdiohfd.c
94 /* Global message bits */
95 extern uint sd_msglevel;
97 /* OS-independent interrupt handler */
98 extern bool check_client_intr(sdioh_info_t *sd);
100 /* Core interrupt enable/disable of device interrupts */
101 extern void sdiohfd_devintr_on(sdioh_info_t *sd);
102 extern void sdiohfd_devintr_off(sdioh_info_t *sd);
105 /**************************************************************
106 * Internal interfaces: bcmsdiohfd.c references to per-port code
109 /* Register mapping routines */
110 extern uint32 *sdiohfd_reg_map(osl_t *osh, int32 addr, int size);
111 extern void sdiohfd_reg_unmap(osl_t *osh, int32 addr, int size);
113 /* Interrupt (de)registration routines */
114 extern int sdiohfd_register_irq(sdioh_info_t *sd, uint irq);
115 extern void sdiohfd_free_irq(uint irq, sdioh_info_t *sd);
117 typedef struct _BCMSDH_FD_INSTANCE {
118 PSDDEVICE pDevice[3]; /* bus driver's device we are supporting */
120 SDIO_STATUS LastRequestStatus; /* last request status */
121 } BCMSDH_FD_INSTANCE, *PBCMSDH_FD_INSTANCE;
123 typedef struct _BCMSDH_FD_CONTEXT {
124 SDFUNCTION Function; /* function description for bus driver */
125 PBCMSDH_FD_INSTANCE pInstance;
126 SD_BUSCLOCK_RATE ClockOverride; /* clock rate override */
127 } BCMSDH_FD_CONTEXT, *PBCMSDH_FD_CONTEXT;
130 SDIO_STATUS client_init(PBCMSDH_FD_CONTEXT pFuncContext,
131 PBCMSDH_FD_INSTANCE pInstance,
133 void client_detach(PBCMSDH_FD_CONTEXT pFuncContext,
134 PBCMSDH_FD_INSTANCE pInstance);
136 #endif /* __BCMSDH_FD_H__ */