upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / net / wireless / bcm4330 / src / include / bcmsdh_fd.h
1 /*
2  *  BCMSDH Function Driver for SDIO-Linux
3  *
4  * Copyright (C) 1999-2011, 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_fd.h,v 13.5 2008-09-17 23:10:04 $
25  */
26
27 #ifndef __BCMSDH_FD_H__
28 #define __BCMSDH_FD_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 /* 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);
44
45 #define sd_log(x)
46
47 #define SDIOH_ASSERT(exp) \
48         do { if (!(exp)) \
49                 printf("!!!ASSERT fail: file %s lines %d", __FILE__, __LINE__); \
50         } while (0)
51
52 #define BLOCK_SIZE_4318 64
53 #define BLOCK_SIZE_4328 512
54
55 /* internal return code */
56 #define SUCCESS 0
57 #define ERROR   1
58
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)
63
64 struct sdioh_info {
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 */
72
73         uint            irq;                    /* Client irq */
74         int             intrcount;              /* Client interrupts */
75
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 */
83         uint32          com_cis_ptr;
84         uint32          func_cis_ptr[SDIOD_MAX_IOFUNCS];
85         uint            max_dma_len;
86         uint            max_dma_descriptors;    /* DMA Descriptors supported by this controller. */
87         SDDMA_DESCRIPTOR        SGList[32];     /* Scatter/Gather DMA List */
88 };
89
90 /************************************************************
91  * Internal interfaces: per-port references into bcmsdiohfd.c
92  */
93
94 /* Global message bits */
95 extern uint sd_msglevel;
96
97 /* OS-independent interrupt handler */
98 extern bool check_client_intr(sdioh_info_t *sd);
99
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);
103
104
105 /**************************************************************
106  * Internal interfaces: bcmsdiohfd.c references to per-port code
107  */
108
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);
112
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);
116
117 typedef struct _BCMSDH_FD_INSTANCE {
118     PSDDEVICE   pDevice[3];  /* bus driver's device we are supporting */
119         sdioh_info_t    *sd;
120     SDIO_STATUS         LastRequestStatus;  /* last request status */
121 } BCMSDH_FD_INSTANCE, *PBCMSDH_FD_INSTANCE;
122
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;
128
129 /* prototypes */
130 SDIO_STATUS client_init(PBCMSDH_FD_CONTEXT  pFuncContext,
131                                PBCMSDH_FD_INSTANCE pInstance,
132                                PSDDEVICE                 pDevice);
133 void client_detach(PBCMSDH_FD_CONTEXT   pFuncContext,
134                           PBCMSDH_FD_INSTANCE  pInstance);
135
136 #endif /* __BCMSDH_FD_H__ */