3 #ifndef BCM_SHM_INTERFACE
6 InterfaceAdapterGet(PMINI_ADAPTER psAdapter
)
12 return (PS_INTERFACE_ADAPTER
)(psAdapter
->pvInterfaceAdapter
);
16 InterfaceRDM(PS_INTERFACE_ADAPTER psIntfAdapter
,
22 USHORT usRetries
= 0 ;
23 if(psIntfAdapter
== NULL
)
25 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_PRINTK
, 0, 0,"Interface Adapter is NULL");
29 if(psIntfAdapter
->psAdapter
->device_removed
== TRUE
)
31 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_PRINTK
, 0, 0,"Device got removed");
35 if((psIntfAdapter
->psAdapter
->StopAllXaction
== TRUE
) && (psIntfAdapter
->psAdapter
->chip_id
>= T3LPB
))
37 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_OTHERS
, RDM
, DBG_LVL_ALL
,"Currently Xaction is not allowed on the bus");
41 if(psIntfAdapter
->bSuspended
==TRUE
|| psIntfAdapter
->bPreparingForBusSuspend
== TRUE
)
43 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_OTHERS
, RDM
, DBG_LVL_ALL
,"Bus is in suspended states hence RDM not allowed..");
46 psIntfAdapter
->psAdapter
->DeviceAccess
= TRUE
;
48 retval
= usb_control_msg(psIntfAdapter
->udev
,
49 usb_rcvctrlpipe(psIntfAdapter
->udev
,0),
53 ((addr
>> 16) & 0xFFFF),
61 psIntfAdapter
->psAdapter
->device_removed
=TRUE
;
65 }while((retval
< 0) && (usRetries
< MAX_RDM_WRM_RETIRES
) );
69 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_OTHERS
, RDM
, DBG_LVL_ALL
, "RDM failed status :%d, retires :%d", retval
,usRetries
);
70 psIntfAdapter
->psAdapter
->DeviceAccess
= FALSE
;
75 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_OTHERS
, RDM
, DBG_LVL_ALL
, "RDM sent %d", retval
);
76 psIntfAdapter
->psAdapter
->DeviceAccess
= FALSE
;
77 return STATUS_SUCCESS
;
82 InterfaceWRM(PS_INTERFACE_ADAPTER psIntfAdapter
,
88 USHORT usRetries
= 0 ;
90 if(psIntfAdapter
== NULL
)
92 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_PRINTK
, 0, 0, "Interface Adapter is NULL");
95 if(psIntfAdapter
->psAdapter
->device_removed
== TRUE
)
98 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_PRINTK
, 0, 0,"Device got removed");
102 if((psIntfAdapter
->psAdapter
->StopAllXaction
== TRUE
) && (psIntfAdapter
->psAdapter
->chip_id
>= T3LPB
))
104 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_OTHERS
, WRM
, DBG_LVL_ALL
,"Currently Xaction is not allowed on the bus...");
108 if(psIntfAdapter
->bSuspended
==TRUE
|| psIntfAdapter
->bPreparingForBusSuspend
== TRUE
)
110 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_OTHERS
, WRM
, DBG_LVL_ALL
,"Bus is in suspended states hence RDM not allowed..");
113 psIntfAdapter
->psAdapter
->DeviceAccess
= TRUE
;
115 retval
= usb_control_msg(psIntfAdapter
->udev
,
116 usb_sndctrlpipe(psIntfAdapter
->udev
,0),
120 ((addr
>> 16) & 0xFFFF),
126 if(-ENODEV
== retval
)
128 psIntfAdapter
->psAdapter
->device_removed
= TRUE
;
132 }while((retval
< 0) && ( usRetries
< MAX_RDM_WRM_RETIRES
));
136 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_OTHERS
, WRM
, DBG_LVL_ALL
, "WRM failed status :%d, retires :%d", retval
, usRetries
);
137 psIntfAdapter
->psAdapter
->DeviceAccess
= FALSE
;
142 psIntfAdapter
->psAdapter
->DeviceAccess
= FALSE
;
143 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_OTHERS
, WRM
, DBG_LVL_ALL
, "WRM sent %d", retval
);
144 return STATUS_SUCCESS
;
156 return InterfaceRDM((PS_INTERFACE_ADAPTER
)arg
, addr
, buff
, len
);
165 return InterfaceWRM((PS_INTERFACE_ADAPTER
)arg
, addr
, buff
, len
);
170 INT
Bcm_clear_halt_of_endpoints(PMINI_ADAPTER Adapter
)
172 PS_INTERFACE_ADAPTER psIntfAdapter
= (PS_INTERFACE_ADAPTER
)(Adapter
->pvInterfaceAdapter
);
173 INT status
= STATUS_SUCCESS
;
176 usb_clear_halt - tells device to clear endpoint halt/stall condition
177 @dev: device whose endpoint is halted
178 @pipe: endpoint "pipe" being cleared
179 @ Context: !in_interrupt ()
181 usb_clear_halt is the synchrnous call and returns 0 on success else returns with error code.
182 This is used to clear halt conditions for bulk and interrupt endpoints only.
183 Control and isochronous endpoints never halts.
185 Any URBs queued for such an endpoint should normally be unlinked by the driver
186 before clearing the halt condition.
190 //Killing all the submitted urbs to different end points.
191 Bcm_kill_all_URBs(psIntfAdapter
);
194 //clear the halted/stalled state for every end point
195 status
= usb_clear_halt(psIntfAdapter
->udev
,psIntfAdapter
->sIntrIn
.int_in_pipe
);
196 if(status
!= STATUS_SUCCESS
)
197 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, INTF_INIT
, DBG_LVL_ALL
, "Unable to Clear Halt of Interrupt IN end point. :%d ", status
);
199 status
= usb_clear_halt(psIntfAdapter
->udev
,psIntfAdapter
->sBulkIn
.bulk_in_pipe
);
200 if(status
!= STATUS_SUCCESS
)
201 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, INTF_INIT
, DBG_LVL_ALL
, "Unable to Clear Halt of Bulk IN end point. :%d ", status
);
203 status
= usb_clear_halt(psIntfAdapter
->udev
,psIntfAdapter
->sBulkOut
.bulk_out_pipe
);
204 if(status
!= STATUS_SUCCESS
)
205 BCM_DEBUG_PRINT(Adapter
,DBG_TYPE_OTHERS
, INTF_INIT
, DBG_LVL_ALL
, "Unable to Clear Halt of Bulk OUT end point. :%d ", status
);
211 VOID
Bcm_kill_all_URBs(PS_INTERFACE_ADAPTER psIntfAdapter
)
213 struct urb
*tempUrb
= NULL
;
217 * usb_kill_urb - cancel a transfer request and wait for it to finish
218 * @urb: pointer to URB describing a previously submitted request,
219 * returns nothing as it is void returned API.
221 * This routine cancels an in-progress request. It is guaranteed that
222 * upon return all completion handlers will have finished and the URB
223 * will be totally idle and available for reuse
225 * This routine may not be used in an interrupt context (such as a bottom
226 * half or a completion handler), or when holding a spinlock, or in other
227 * situations where the caller can't schedule().
231 /* Cancel submitted Interrupt-URB's */
232 if(psIntfAdapter
->psInterruptUrb
!= NULL
)
234 if(psIntfAdapter
->psInterruptUrb
->status
== -EINPROGRESS
)
235 usb_kill_urb(psIntfAdapter
->psInterruptUrb
);
238 /* Cancel All submitted TX URB's */
239 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_PRINTK
, 0, 0, "Cancelling All Submitted TX Urbs \n");
241 for(i
= 0; i
< MAXIMUM_USB_TCB
; i
++)
243 tempUrb
= psIntfAdapter
->asUsbTcb
[i
].urb
;
246 if(tempUrb
->status
== -EINPROGRESS
)
247 usb_kill_urb(tempUrb
);
252 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_PRINTK
, 0, 0, "Cancelling All submitted Rx Urbs \n");
254 for(i
= 0; i
< MAXIMUM_USB_RCB
; i
++)
256 tempUrb
= psIntfAdapter
->asUsbRcb
[i
].urb
;
259 if(tempUrb
->status
== -EINPROGRESS
)
260 usb_kill_urb(tempUrb
);
265 atomic_set(&psIntfAdapter
->uNumTcbUsed
, 0);
266 atomic_set(&psIntfAdapter
->uCurrTcb
, 0);
268 atomic_set(&psIntfAdapter
->uNumRcbUsed
, 0);
269 atomic_set(&psIntfAdapter
->uCurrRcb
, 0);
271 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_PRINTK
, 0, 0, "TCB: used- %d cur-%d\n", atomic_read(&psIntfAdapter
->uNumTcbUsed
), atomic_read(&psIntfAdapter
->uCurrTcb
));
272 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_PRINTK
, 0, 0, "RCB: used- %d cur-%d\n", atomic_read(&psIntfAdapter
->uNumRcbUsed
), atomic_read(&psIntfAdapter
->uCurrRcb
));
276 VOID
putUsbSuspend(struct work_struct
*work
)
278 PS_INTERFACE_ADAPTER psIntfAdapter
= NULL
;
279 struct usb_interface
*intf
= NULL
;
280 psIntfAdapter
= container_of(work
, S_INTERFACE_ADAPTER
,usbSuspendWork
);
281 intf
=psIntfAdapter
->interface
;
283 if(psIntfAdapter
->bSuspended
== FALSE
)
284 usb_autopm_put_interface(intf
);
286 BCM_DEBUG_PRINT(psIntfAdapter
->psAdapter
,DBG_TYPE_TX
, NEXT_SEND
, DBG_LVL_ALL
, "Interface Resumed Completely\n");