Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79880224 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "net: can: qti-can: Notify power events to firmware"

parents 389a0bd2 6fe22ea7
Loading
Loading
Loading
Loading
+32 −4
Original line number Diff line number Diff line
@@ -122,6 +122,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_SUSPEND_EVENT		0x9E
#define CMD_RESUME_EVENT		0x9F

#define IOCTL_RELEASE_CAN_BUFFER	(SIOCDEVPRIVATE + 0)
#define IOCTL_ENABLE_BUFFERING		(SIOCDEVPRIVATE + 1)
@@ -597,6 +599,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;
@@ -1472,6 +1498,7 @@ static int qti_can_suspend(struct device *dev)
{
	struct spi_device *spi = to_spi_device(dev);
	struct qti_can *priv_data = NULL;
	u8 power_event = CMD_SUSPEND_EVENT;
	int ret = 0;

	if (spi) {
@@ -1481,8 +1508,8 @@ static int qti_can_suspend(struct device *dev)
		ret = -1;
	}

	if (priv_data)
		LOGDE("suspend %s", (ret < 0) ? "failed!!" : "success");
	if (priv_data && !(ret < 0))
		ret = qti_can_notify_power_events(priv_data, power_event);

	return ret;
}
@@ -1492,6 +1519,7 @@ static int qti_can_resume(struct device *dev)
	struct spi_device *spi = to_spi_device(dev);
	struct qti_can *priv_data = NULL;
	int ret = 0;
	u8 power_event = CMD_RESUME_EVENT;

	if (spi) {
		priv_data = spi_get_drvdata(spi);
@@ -1506,8 +1534,8 @@ static int qti_can_resume(struct device *dev)
		ret = -1;
	}

	if (priv_data)
		LOGDE("resume %s", (ret < 0) ? "failed!!" : "success");
	if (priv_data && !(ret < 0))
		ret = qti_can_notify_power_events(priv_data, power_event);

	return ret;
}