summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalachandra C S <balacs@codeaurora.org>2018-07-09 17:24:41 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2018-07-19 06:36:40 -0700
commitfc93ec766ea3e9413f999ac1e4763ad41e44d07e (patch)
treede3895da2fc8370bada2191e8f419036558d5c8f
parenteb119bcb2aa86a2847efe3bc43e9af59db8059ed (diff)
drivers: net: can: Inform power states to CAN controller
CAN controller needs to be aware of host power state to decide if a timestamp message can be sent to host or not. Change-Id: I89a570a2fb38336c38d0105bbb3df8b89d7e3035 Signed-off-by: Balachandra C S <balacs@codeaurora.org>
-rw-r--r--drivers/net/can/spi/qti-can.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/drivers/net/can/spi/qti-can.c b/drivers/net/can/spi/qti-can.c
index 7083d0011b18..f7ba4510d1bc 100644
--- a/drivers/net/can/spi/qti-can.c
+++ b/drivers/net/can/spi/qti-can.c
@@ -121,6 +121,8 @@ struct spi_miso { /* TLV for MISO line */
#define CMD_END_BOOT_ROM_UPGRADE 0x9B
#define CMD_END_FW_UPDATE_FILE 0x9C
#define CMD_UPDATE_TIME_INFO 0x9D
+#define CMD_UPDATE_SUSPEND_EVENT 0x9E
+#define CMD_UPDATE_RESUME_EVENT 0x9F
#define IOCTL_RELEASE_CAN_BUFFER (SIOCDEVPRIVATE + 0)
#define IOCTL_ENABLE_BUFFERING (SIOCDEVPRIVATE + 1)
@@ -580,6 +582,30 @@ static int qti_can_query_firmware_version(struct qti_can *priv_data)
return ret;
}
+static int qti_can_notify_power_events(struct qti_can *priv_data, u8 event_type)
+{
+ char *tx_buf, *rx_buf;
+ int ret;
+ struct spi_mosi *req;
+
+ mutex_lock(&priv_data->spi_lock);
+ tx_buf = priv_data->tx_buf;
+ rx_buf = priv_data->rx_buf;
+ memset(tx_buf, 0, XFER_BUFFER_SIZE);
+ memset(rx_buf, 0, XFER_BUFFER_SIZE);
+ priv_data->xfer_length = XFER_BUFFER_SIZE;
+
+ req = (struct spi_mosi *)tx_buf;
+ req->cmd = event_type;
+ req->len = 0;
+ req->seq = atomic_inc_return(&priv_data->msg_seq);
+
+ ret = qti_can_do_spi_transaction(priv_data);
+ mutex_unlock(&priv_data->spi_lock);
+
+ return ret;
+}
+
static int qti_can_set_bitrate(struct net_device *netdev)
{
char *tx_buf, *rx_buf;
@@ -1439,6 +1465,10 @@ static int qti_can_remove(struct spi_device *spi)
static int qti_can_suspend(struct device *dev)
{
struct spi_device *spi = to_spi_device(dev);
+ struct qti_can *priv_data = spi_get_drvdata(spi);
+ u8 power_event = CMD_UPDATE_SUSPEND_EVENT;
+
+ qti_can_notify_power_events(priv_data, power_event);
enable_irq_wake(spi->irq);
return 0;
@@ -1448,9 +1478,10 @@ static int qti_can_resume(struct device *dev)
{
struct spi_device *spi = to_spi_device(dev);
struct qti_can *priv_data = spi_get_drvdata(spi);
+ u8 power_event = CMD_UPDATE_RESUME_EVENT;
disable_irq_wake(spi->irq);
- qti_can_rx_message(priv_data);
+ qti_can_notify_power_events(priv_data, power_event);
return 0;
}