misc: Add Nordic driver sleep mode support

Add HMD nordic driver suspend and sleep
mode when standlone or bonded with
remote controllers.

Change-Id: I0dda7e5d474341f8636b78a07ff70f5a164dd082
Signed-off-by: Wei Tan <quic_weitan@quicinc.com>
This commit is contained in:
Wei Tan authored and Gerrit - the friendly Code Review server committed 2023-01-18 18:42:06 -08:00
1 parent 0589df7994
commit 5b284b6c49
2 files changed
+32 -3

No files matched your search

+31 -3
View File
@@ -226,6 +226,10 @@ static ssize_t jsrequest_show(struct device *dev,
} else {
size = scnprintf(buf, PAGE_SIZE, "no need to ack\n");
}
pinctrl_select_state(
gspi_client->pinctrl_info.pinctrl,
gspi_client->pinctrl_info.active);
gspi_client->js_ledl_state = 0;
mutex_unlock(&gspi_client->js_mutex);
return size;
@@ -244,6 +248,11 @@ static ssize_t jsrequest_store(struct device *dev,
return size;
}
pinctrl_select_state(
gspi_client->pinctrl_info.pinctrl,
gspi_client->pinctrl_info.suspend);
gspi_client->js_ledl_state = 1;
mutex_lock(&gspi_client->js_mutex);
err = kstrtouint(buf, 16, &input);
if (err) {
@@ -252,9 +261,21 @@ static ssize_t jsrequest_store(struct device *dev,
memset(&request, 0, sizeof(request_t));
request.requestHead.requestType =
((input & 0x7f000000) >> 24);
request.requestData[0] = (input & 0x000000ff);
request.requestData[1] = (input & 0x0000ff00);
request.requestData[2] = (input & 0x00ff0000);
if (request.requestHead.requestType == 0xc) {
request.requestData[0] =
(input & 0x000000ff);
request.requestData[1] =
((input & 0x0000ff00) >> 8);
request.requestData[2] =
((input & 0x00ff0000) >> 16);
} else {
request.requestData[0] =
(input & 0x000000ff);
request.requestData[1] =
(input & 0x0000ff00);
request.requestData[2] =
(input & 0x00ff0000);
}
switch (request.requestHead.requestType) {
case setVibStateRequest:
@@ -285,6 +306,7 @@ static ssize_t jsrequest_store(struct device *dev,
case getRightJoyStickProductNameRequest:
case getLeftJoyStickFwVersionRequest:
case getRightJoyStickFwVersionRequest:
case setControllerSleepMode:
atomic_set(&gspi_client->userRequest,
input);
atomic_inc(&gspi_client->dataflag);
@@ -466,6 +488,12 @@ static int js_thread(void *data)
spi_client->txbuffer[2] =
(currentRequest.requestData[0]&0x01);
break;
case setControllerSleepMode:
spi_client->txbuffer[2] =
currentRequest.requestData[0];
spi_client->txbuffer[3] =
currentRequest.requestData[1];
break;
default:
break;
}
+1
View File
@@ -109,6 +109,7 @@ typedef enum _requestType_t
getRightJoyStickProductNameRequest,
getLeftJoyStickFwVersionRequest,
getRightJoyStickFwVersionRequest,
setControllerSleepMode = 12,
invalidRequest,
} requestType_t;