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>
This commit is contained in:
parent
eb119bcb2a
commit
fc93ec766e
1 changed files with 32 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue