beceem: remove ifdef's
[pandora-kernel.git] / drivers / staging / bcm / InterfaceIsr.c
1 #include "headers.h"
2
3
4 static void read_int_callback(struct urb *urb/*, struct pt_regs *regs*/)
5 {
6         int             status = urb->status;
7         PS_INTERFACE_ADAPTER psIntfAdapter = (PS_INTERFACE_ADAPTER)urb->context;
8         PMINI_ADAPTER Adapter = psIntfAdapter->psAdapter ;
9
10         if(Adapter->device_removed == TRUE)
11         {
12                 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Device has Got Removed.");
13                 return ;
14         }
15
16         if(((Adapter->bPreparingForLowPowerMode == TRUE) && (Adapter->bDoSuspend == TRUE)) ||
17                 psIntfAdapter->bSuspended ||
18                 psIntfAdapter->bPreparingForBusSuspend)
19         {
20                         BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt call back is called while suspending the device");
21                         return ;
22         }
23
24         //BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL, "interrupt urb status %d", status);
25         switch (status) {
26             /* success */
27             case STATUS_SUCCESS:
28                 if ( urb->actual_length )
29                 {
30
31                         if(psIntfAdapter->ulInterruptData[1] & 0xFF)
32                         {
33                                 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "Got USIM interrupt");
34                         }
35
36                         if(psIntfAdapter->ulInterruptData[1] & 0xFF00)
37                         {
38                                 atomic_set(&Adapter->CurrNumFreeTxDesc,
39                                         (psIntfAdapter->ulInterruptData[1] & 0xFF00) >> 8);
40                                 atomic_set (&Adapter->uiMBupdate, TRUE);
41                                 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL, "TX mailbox contains %d",
42                                         atomic_read(&Adapter->CurrNumFreeTxDesc));
43                         }
44                         if(psIntfAdapter->ulInterruptData[1] >> 16)
45                         {
46                                 Adapter->CurrNumRecvDescs=
47                                         (psIntfAdapter->ulInterruptData[1]  >> 16);
48                                 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"RX mailbox contains %d",
49                                         Adapter->CurrNumRecvDescs);
50                                 InterfaceRx(psIntfAdapter);
51                         }
52                         if(Adapter->fw_download_done &&
53                                 !Adapter->downloadDDR &&
54                                 atomic_read(&Adapter->CurrNumFreeTxDesc))
55                         {
56                                 psIntfAdapter->psAdapter->downloadDDR +=1;
57                                 wake_up(&Adapter->tx_packet_wait_queue);
58                         }
59                         if(FALSE == Adapter->waiting_to_fw_download_done)
60                         {
61                                 Adapter->waiting_to_fw_download_done = TRUE;
62                                 wake_up(&Adapter->ioctl_fw_dnld_wait_queue);
63                         }
64                         if(!atomic_read(&Adapter->TxPktAvail))
65                         {
66                                 atomic_set(&Adapter->TxPktAvail, 1);
67                                 wake_up(&Adapter->tx_packet_wait_queue);
68                         }
69                         BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Firing interrupt in URB");
70                 }
71                 break;
72                 case -ENOENT :
73                 {
74                         BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"URB has got disconnected ....");
75                         return ;
76                 }
77                 case -EINPROGRESS:
78                 {
79                         //This situation may happend when URBunlink is used. for detail check usb_unlink_urb documentation.
80                         BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Impossibe condition has occured... something very bad is going on");
81                         break ;
82                         //return;
83                 }
84                 case -EPIPE:
85                 {
86                                 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt IN endPoint  has got halted/stalled...need to clear this");
87                                 Adapter->bEndPointHalted = TRUE ;
88                                 wake_up(&Adapter->tx_packet_wait_queue);
89                                 urb->status = STATUS_SUCCESS ;;
90                                 return;
91                 }
92             /* software-driven interface shutdown */
93             case -ECONNRESET: //URB got unlinked.
94             case -ESHUTDOWN:            // hardware gone. this is the serious problem.
95                                                         //Occurs only when something happens with the host controller device
96             case -ENODEV : //Device got removed
97                 case -EINVAL : //Some thing very bad happened with the URB. No description is available.
98                 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"interrupt urb error %d", status);
99                         urb->status = STATUS_SUCCESS ;
100                         break ;
101                         //return;
102             default:
103                         //This is required to check what is the defaults conditions when it occurs..
104                         BCM_DEBUG_PRINT(Adapter,DBG_TYPE_TX, NEXT_SEND, DBG_LVL_ALL,"GOT DEFAULT INTERRUPT URB STATUS :%d..Please Analyze it...", status);
105                 break;
106         }
107
108         StartInterruptUrb(psIntfAdapter);
109
110
111 }
112
113 int CreateInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter)
114 {
115         psIntfAdapter->psInterruptUrb = usb_alloc_urb(0, GFP_KERNEL);
116         if (!psIntfAdapter->psInterruptUrb)
117         {
118                 BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot allocate interrupt urb");
119                 return -ENOMEM;
120         }
121         psIntfAdapter->psInterruptUrb->transfer_buffer =
122                                                                 psIntfAdapter->ulInterruptData;
123         psIntfAdapter->psInterruptUrb->transfer_buffer_length =
124                                                         sizeof(psIntfAdapter->ulInterruptData);
125
126         psIntfAdapter->sIntrIn.int_in_pipe = usb_rcvintpipe(psIntfAdapter->udev,
127                                                 psIntfAdapter->sIntrIn.int_in_endpointAddr);
128
129         usb_fill_int_urb(psIntfAdapter->psInterruptUrb, psIntfAdapter->udev,
130                                         psIntfAdapter->sIntrIn.int_in_pipe,
131                                         psIntfAdapter->psInterruptUrb->transfer_buffer,
132                                         psIntfAdapter->psInterruptUrb->transfer_buffer_length,
133                                         read_int_callback, psIntfAdapter,
134                                         psIntfAdapter->sIntrIn.int_in_interval);
135
136         BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Interrupt Interval: %d\n",
137                                 psIntfAdapter->sIntrIn.int_in_interval);
138         return 0;
139 }
140
141
142 INT StartInterruptUrb(PS_INTERFACE_ADAPTER psIntfAdapter)
143 {
144         INT status = 0;
145
146         if( FALSE == psIntfAdapter->psAdapter->device_removed &&
147                 FALSE == psIntfAdapter->psAdapter->bEndPointHalted &&
148                 FALSE == psIntfAdapter->bSuspended &&
149                 FALSE == psIntfAdapter->bPreparingForBusSuspend &&
150                 FALSE == psIntfAdapter->psAdapter->StopAllXaction)
151         {
152                 status = usb_submit_urb(psIntfAdapter->psInterruptUrb, GFP_ATOMIC);
153                 if (status)
154                 {
155                         BCM_DEBUG_PRINT(psIntfAdapter->psAdapter,DBG_TYPE_OTHERS, INTF_INIT, DBG_LVL_ALL,"Cannot send int urb %d\n", status);
156                         if(status == -EPIPE)
157                         {
158                                 psIntfAdapter->psAdapter->bEndPointHalted = TRUE ;
159                                 wake_up(&psIntfAdapter->psAdapter->tx_packet_wait_queue);
160                         }
161                 }
162         }
163         return status;
164 }
165
166 /*
167 Function:                               InterfaceEnableInterrupt
168
169 Description:                    This is the hardware specific Function for configuring
170                                                 and enabling the interrupts on the device.
171
172 Input parameters:               IN PMINI_ADAPTER Adapter   - Miniport Adapter Context
173
174
175 Return:                         BCM_STATUS_SUCCESS - If configuring the interrupts was successful.
176                                                 Other           - If an error occured.
177 */
178
179 void InterfaceEnableInterrupt(PMINI_ADAPTER Adapter)
180 {
181
182 }
183
184 /*
185 Function:                               InterfaceDisableInterrupt
186
187 Description:                    This is the hardware specific Function for disabling the interrupts on the device.
188
189 Input parameters:               IN PMINI_ADAPTER Adapter   - Miniport Adapter Context
190
191
192 Return:                         BCM_STATUS_SUCCESS - If disabling the interrupts was successful.
193                                                 Other           - If an error occured.
194 */
195
196 void InterfaceDisableInterrupt(PMINI_ADAPTER Adapter)
197 {
198
199 }
200
201