4 Function: InterfaceIdleModeWakeup
6 Description: This is the hardware specific Function for waking up HW device from Idle mode.
7 A software abort pattern is written to the device to wake it and necessary power state
8 transitions from host are performed here.
10 Input parameters: IN struct bcm_mini_adapter *Adapter - Miniport Adapter Context
13 Return: BCM_STATUS_SUCCESS - If Wakeup of the HW Interface was successful.
14 Other - If an error occurred.
19 Function: InterfaceIdleModeRespond
21 Description: This is the hardware specific Function for responding to Idle mode request from target.
22 Necessary power state transitions from host for idle mode or other device specific
23 initializations are performed here.
25 Input parameters: IN struct bcm_mini_adapter * Adapter - Miniport Adapter Context
28 Return: BCM_STATUS_SUCCESS - If Idle mode response related HW configuration was successful.
29 Other - If an error occurred.
33 "dmem bfc02f00 100" tells how many time device went in Idle mode.
34 this value will be at address bfc02fa4.just before value d0ea1dle.
36 Set time value by writing at bfc02f98 7d0
38 checking the Ack timer expire on kannon by running command
39 d qcslog .. if it shows e means host has not send response to f/w with in 200 ms. Response should be
40 send to f/w with in 200 ms after the Idle/Shutdown req issued
45 int InterfaceIdleModeRespond(struct bcm_mini_adapter
*Adapter
, unsigned int *puiBuffer
)
47 int status
= STATUS_SUCCESS
;
48 unsigned int uiRegRead
= 0;
51 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "SubType of Message :0x%X", ntohl(*puiBuffer
));
53 if (ntohl(*puiBuffer
) == GO_TO_IDLE_MODE_PAYLOAD
) {
54 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, " Got GO_TO_IDLE_MODE_PAYLOAD(210) Msg Subtype");
55 if (ntohl(*(puiBuffer
+1)) == 0 ) {
56 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Got IDLE MODE WAKE UP Response From F/W");
58 status
= wrmalt (Adapter
, SW_ABORT_IDLEMODE_LOC
, &uiRegRead
, sizeof(uiRegRead
));
60 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0, "wrm failed while clearing Idle Mode Reg");
64 if (Adapter
->ulPowerSaveMode
== DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING
) {
65 uiRegRead
= 0x00000000 ;
66 status
= wrmalt (Adapter
, DEBUG_INTERRUPT_GENERATOR_REGISTOR
, &uiRegRead
, sizeof(uiRegRead
));
68 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0, "wrm failed while clearing Idle Mode Reg");
72 /* Below Register should not br read in case of Manual and Protocol Idle mode */
73 else if (Adapter
->ulPowerSaveMode
!= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
) {
74 /* clear on read Register */
75 bytes
= rdmalt(Adapter
, DEVICE_INT_OUT_EP_REG0
, &uiRegRead
, sizeof(uiRegRead
));
78 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0, "rdm failed while clearing H/W Abort Reg0");
81 /* clear on read Register */
82 bytes
= rdmalt(Adapter
, DEVICE_INT_OUT_EP_REG1
, &uiRegRead
, sizeof(uiRegRead
));
85 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0, "rdm failed while clearing H/W Abort Reg1");
89 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Device Up from Idle Mode");
91 /* Set Idle Mode Flag to False and Clear IdleMode reg. */
92 Adapter
->IdleMode
= FALSE
;
93 Adapter
->bTriedToWakeUpFromlowPowerMode
= FALSE
;
95 wake_up(&Adapter
->lowpower_mode_wait_queue
);
98 if (TRUE
== Adapter
->IdleMode
)
100 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Device is already in Idle mode....");
105 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Got Req from F/W to go in IDLE mode \n");
107 if (Adapter
->chip_id
== BCS220_2
||
108 Adapter
->chip_id
== BCS220_2BC
||
109 Adapter
->chip_id
== BCS250_BC
||
110 Adapter
->chip_id
== BCS220_3
) {
112 bytes
= rdmalt(Adapter
, HPM_CONFIG_MSW
, &uiRegRead
, sizeof(uiRegRead
));
115 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "rdm failed while Reading HPM_CONFIG_LDO145 Reg 0\n");
120 uiRegRead
|= (1<<17);
122 status
= wrmalt (Adapter
, HPM_CONFIG_MSW
, &uiRegRead
, sizeof(uiRegRead
));
124 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0, "wrm failed while clearing Idle Mode Reg\n");
129 SendIdleModeResponse(Adapter
);
131 } else if (ntohl(*puiBuffer
) == IDLE_MODE_SF_UPDATE_MSG
) {
132 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "OverRiding Service Flow Params");
133 OverrideServiceFlowParams(Adapter
, puiBuffer
);
138 static int InterfaceAbortIdlemode(struct bcm_mini_adapter
*Adapter
, unsigned int Pattern
)
140 int status
= STATUS_SUCCESS
;
142 unsigned int chip_id
;
143 unsigned long timeout
= 0, itr
= 0;
146 unsigned char aucAbortPattern
[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
147 struct bcm_interface_adapter
*psInterfaceAdapter
= Adapter
->pvInterfaceAdapter
;
149 /* Abort Bus suspend if its already suspended */
150 if ((TRUE
== psInterfaceAdapter
->bSuspended
) && (TRUE
== Adapter
->bDoSuspend
)) {
151 status
= usb_autopm_get_interface(psInterfaceAdapter
->interface
);
152 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Bus got wakeup..Aborting Idle mode... status:%d \n", status
);
156 if ((Adapter
->ulPowerSaveMode
== DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING
)
158 (Adapter
->ulPowerSaveMode
== DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
)) {
159 /* write the SW abort pattern. */
160 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Writing pattern<%d> to SW_ABORT_IDLEMODE_LOC\n", Pattern
);
161 status
= wrmalt(Adapter
, SW_ABORT_IDLEMODE_LOC
, &Pattern
, sizeof(Pattern
));
163 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "WRM to Register SW_ABORT_IDLEMODE_LOC failed..");
168 if (Adapter
->ulPowerSaveMode
== DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING
) {
170 status
= wrmalt(Adapter
, DEBUG_INTERRUPT_GENERATOR_REGISTOR
, &value
, sizeof(value
));
173 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Register failed");
176 } else if (Adapter
->ulPowerSaveMode
!= DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE
) {
178 * Get a Interrupt Out URB and send 8 Bytes Down
179 * To be Done in Thread Context.
180 * Not using Asynchronous Mechanism.
182 status
= usb_interrupt_msg (psInterfaceAdapter
->udev
,
183 usb_sndintpipe(psInterfaceAdapter
->udev
,
184 psInterfaceAdapter
->sIntrOut
.int_out_endpointAddr
),
190 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Sending Abort pattern down fails with status:%d..\n", status
);
193 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "NOB Sent down :%d", lenwritten
);
198 timeout
= jiffies
+ msecs_to_jiffies(50) ;
199 while ( timeout
> jiffies
) {
201 rdmalt(Adapter
, CHIP_ID_REG
, &chip_id
, sizeof(UINT
));
202 if (0xbece3200 == (chip_id
&~(0xF0)))
203 chip_id
= chip_id
&~(0xF0);
204 if (chip_id
== Adapter
->chip_id
)
207 if (timeout
< jiffies
)
208 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Not able to read chip-id even after 25 msec");
210 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Number of completed iteration to read chip-id :%lu", itr
);
212 status
= wrmalt(Adapter
, SW_ABORT_IDLEMODE_LOC
, &Pattern
, sizeof(status
));
214 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0, "WRM to Register SW_ABORT_IDLEMODE_LOC failed..");
220 int InterfaceIdleModeWakeup(struct bcm_mini_adapter
*Adapter
)
223 if (Adapter
->bTriedToWakeUpFromlowPowerMode
) {
224 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Wake up already attempted.. ignoring\n");
226 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_OTHERS
, IDLE_MODE
, DBG_LVL_ALL
, "Writing Low Power Mode Abort pattern to the Device\n");
227 Adapter
->bTriedToWakeUpFromlowPowerMode
= TRUE
;
228 InterfaceAbortIdlemode(Adapter
, Adapter
->usIdleModePattern
);
234 void InterfaceHandleShutdownModeWakeup(struct bcm_mini_adapter
*Adapter
)
236 unsigned int uiRegVal
= 0;
240 if (Adapter
->ulPowerSaveMode
== DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING
) {
241 /* clear idlemode interrupt. */
243 Status
= wrmalt(Adapter
, DEBUG_INTERRUPT_GENERATOR_REGISTOR
, &uiRegVal
, sizeof(uiRegVal
));
245 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0,"WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Failed with err :%d", Status
);
252 /* clear Interrupt EP registers. */
253 bytes
= rdmalt(Adapter
, DEVICE_INT_OUT_EP_REG0
, &uiRegVal
, sizeof(uiRegVal
));
256 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0, "RDM of DEVICE_INT_OUT_EP_REG0 failed with Err :%d", Status
);
260 bytes
= rdmalt(Adapter
, DEVICE_INT_OUT_EP_REG1
, &uiRegVal
, sizeof(uiRegVal
));
263 BCM_DEBUG_PRINT(Adapter
, DBG_TYPE_PRINTK
, 0, 0, "RDM of DEVICE_INT_OUT_EP_REG1 failed with Err :%d", Status
);