1/*
2 * BCMSDH Function Driver for the native SDIO/MMC driver in the Linux Kernel
3 *
4 * Copyright (C) 1999-2012, 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 355594 2012-09-07 10:22:02Z $
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_trace_hw4	sd_trace
38
39#define sd_sync_dma(sd, read, nbytes)
40#define sd_init_dma(sd)
41#define sd_ack_intr(sd)
42#define sd_wakeup(sd);
43
44/* Allocate/init/free per-OS private data */
45extern int sdioh_sdmmc_osinit(sdioh_info_t *sd);
46extern void sdioh_sdmmc_osfree(sdioh_info_t *sd);
47
48#define sd_log(x)
49
50#define SDIOH_ASSERT(exp) \
51	do { if (!(exp)) \
52		printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
53	} while (0)
54
55#define BLOCK_SIZE_4318 64
56#define BLOCK_SIZE_4328 512
57
58/* internal return code */
59#define SUCCESS	0
60#define ERROR	1
61
62/* private bus modes */
63#define SDIOH_MODE_SD4		2
64#define CLIENT_INTR 		0x100	/* Get rid of this! */
65
66struct sdioh_info {
67	osl_t 		*osh;			/* osh handler */
68	bool		client_intr_enabled;	/* interrupt connnected flag */
69	bool		intr_handler_valid;	/* client driver interrupt handler valid */
70	sdioh_cb_fn_t	intr_handler;		/* registered interrupt handler */
71	void		*intr_handler_arg;	/* argument to call interrupt handler */
72	uint16		intmask;		/* Current active interrupts */
73	void		*sdos_info;		/* Pointer to per-OS private data */
74
75	uint 		irq;			/* Client irq */
76	int 		intrcount;		/* Client interrupts */
77
78	bool		sd_use_dma;		/* DMA on CMD53 */
79	bool 		sd_blockmode;		/* sd_blockmode == FALSE => 64 Byte Cmd 53s. */
80						/*  Must be on for sd_multiblock to be effective */
81	bool 		use_client_ints;	/* If this is false, make sure to restore */
82	int 		sd_mode;		/* SD1/SD4/SPI */
83	int 		client_block_size[SDIOD_MAX_IOFUNCS];		/* Blocksize */
84	uint8 		num_funcs;		/* Supported funcs on client */
85	uint32 		com_cis_ptr;
86	uint32 		func_cis_ptr[SDIOD_MAX_IOFUNCS];
87
88#define SDIOH_SDMMC_MAX_SG_ENTRIES	32
89	struct scatterlist sg_list[SDIOH_SDMMC_MAX_SG_ENTRIES];
90	bool		use_rxchain;
91};
92
93/************************************************************
94 * Internal interfaces: per-port references into bcmsdh_sdmmc.c
95 */
96
97/* Global message bits */
98extern uint sd_msglevel;
99
100/* OS-independent interrupt handler */
101extern bool check_client_intr(sdioh_info_t *sd);
102
103/* Core interrupt enable/disable of device interrupts */
104extern void sdioh_sdmmc_devintr_on(sdioh_info_t *sd);
105extern void sdioh_sdmmc_devintr_off(sdioh_info_t *sd);
106
107
108/**************************************************************
109 * Internal interfaces: bcmsdh_sdmmc.c references to per-port code
110 */
111
112/* Register mapping routines */
113extern uint32 *sdioh_sdmmc_reg_map(osl_t *osh, int32 addr, int size);
114extern void sdioh_sdmmc_reg_unmap(osl_t *osh, int32 addr, int size);
115
116/* Interrupt (de)registration routines */
117extern int sdioh_sdmmc_register_irq(sdioh_info_t *sd, uint irq);
118extern void sdioh_sdmmc_free_irq(uint irq, sdioh_info_t *sd);
119
120typedef struct _BCMSDH_SDMMC_INSTANCE {
121	sdioh_info_t	*sd;
122	struct sdio_func *func[SDIOD_MAX_IOFUNCS];
123} BCMSDH_SDMMC_INSTANCE, *PBCMSDH_SDMMC_INSTANCE;
124
125#endif /* __BCMSDH_SDMMC_H__ */
126