• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
3  *
4  * Copyright (C) 1999-2013, Broadcom Corporation
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  *      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.
23  *
24  * $Id: bcmsdh_sdmmc.h 396592 2013-04-13 16:14:38Z $
25  */
26 
27 #ifndef __BCMSDH_SDMMC_H__
28 #define __BCMSDH_SDMMC_H__
29 
30 #define sd_err(x)
31 #define sd_trace(x)
32 #define sd_info(x)
33 #define sd_debug(x)
34 #define sd_data(x)
35 #define sd_ctrl(x)
36 
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 
42 /* Allocate/init/free per-OS private data */
43 extern int sdioh_sdmmc_osinit(sdioh_info_t *sd);
44 extern void sdioh_sdmmc_osfree(sdioh_info_t *sd);
45 
46 #define sd_log(x)
47 
48 #define SDIOH_ASSERT(exp) \
49 	do { if (!(exp)) \
50 		printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
51 	} while (0)
52 
53 #define BLOCK_SIZE_4318 64
54 #define BLOCK_SIZE_4328 512
55 
56 /* internal return code */
57 #define SUCCESS	0
58 #define ERROR	1
59 
60 /* private bus modes */
61 #define SDIOH_MODE_SD4		2
62 #define CLIENT_INTR			0x100	/* Get rid of this! */
63 
64 #ifdef BCMSDIOH_TXGLOM
65 
66 typedef struct glom_buf {
67 	void *glom_pkt_head;
68 	void *glom_pkt_tail;
69 	uint32 count;				/* Total number of pkts queued */
70 } glom_buf_t;
71 #endif /* BCMSDIOH_TXGLOM */
72 
73 struct sdioh_info {
74 	osl_t		*osh;			/* osh handler */
75 	bool		client_intr_enabled;	/* interrupt connnected flag */
76 	bool		intr_handler_valid;	/* client driver interrupt handler valid */
77 	sdioh_cb_fn_t	intr_handler;		/* registered interrupt handler */
78 	void		*intr_handler_arg;	/* argument to call interrupt handler */
79 	uint16		intmask;		/* Current active interrupts */
80 	void		*sdos_info;		/* Pointer to per-OS private data */
81 
82 	uint		irq;			/* Client irq */
83 	int			intrcount;		/* Client interrupts */
84 
85 	bool		sd_use_dma;		/* DMA on CMD53 */
86 	bool		sd_blockmode;		/* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
87 						/*  Must be on for sd_multiblock to be effective */
88 	bool 		use_client_ints;	/* If this is false, make sure to restore */
89 	int 		sd_mode;		/* SD1/SD4/SPI */
90 	int 		client_block_size[SDIOD_MAX_IOFUNCS];		/* Blocksize */
91 	uint8 		num_funcs;		/* Supported funcs on client */
92 	uint32 		com_cis_ptr;
93 	uint32		func_cis_ptr[SDIOD_MAX_IOFUNCS];
94 
95 #define SDIOH_SDMMC_MAX_SG_ENTRIES	32
96 	struct scatterlist sg_list[SDIOH_SDMMC_MAX_SG_ENTRIES];
97 	bool		use_rxchain;
98 
99 #ifdef BCMSDIOH_TXGLOM
100 	glom_buf_t glom_info;		/* pkt information used for glomming */
101 	uint	txglom_mode;		/* Txglom mode: 0 - copy, 1 - multi-descriptor */
102 #endif
103 };
104 
105 /************************************************************
106  * Internal interfaces: per-port references into bcmsdh_sdmmc.c
107  */
108 
109 /* Global message bits */
110 extern uint sd_msglevel;
111 
112 /* OS-independent interrupt handler */
113 extern bool check_client_intr(sdioh_info_t *sd);
114 
115 /* Core interrupt enable/disable of device interrupts */
116 extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd);
117 extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
118 
119 
120 /**************************************************************
121  * Internal interfaces: bcmsdh_sdmmc.c references to per-port code
122  */
123 
124 /* Register mapping routines */
125 extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size);
126 extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size);
127 
128 /* Interrupt (de)registration routines */
129 extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq);
130 extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd);
131 
132 typedef struct _BCMSDH_SDMMC_INSTANCE {
133 	sdioh_info_t	*sd;
134 	struct sdio_func *func[SDIOD_MAX_IOFUNCS];
135 } BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE;
136 
137 #endif /* __BCMSDH_SDMMC_H__ */
138