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

Commit 65d902ec authored by Sunil Paidimarri's avatar Sunil Paidimarri Committed by Gerrit - the friendly Code Review server
Browse files

data-kernel: EMAC: Disable c-tile power collapse



Disable c-tile PC from EMAC driver.
This stops EMAC power collapse in XO-shutdown.

CRs-Fixed: 2240286
Change-Id: I6177907449ff7e8a29309031bee37c3c2a91004f
Acked-by: default avatarRahul Kawadgave <rahulak@qti.qualcomm.com>
Signed-off-by: default avatarSunil Paidimarri <hisunil@codeaurora.org>
parent d84badff
Loading
Loading
Loading
Loading
+78 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ struct DWC_ETH_QOS_prv_data *gDWC_ETH_QOS_prv_data;
struct emac_emb_smmu_cb_ctx emac_emb_smmu_ctx = {0};

#define INVALID_MODULE_PARAM_VAL 0xFFFFFFFF
static struct qmp_pkt pkt;
static char qmp_buf[MAX_QMP_MSG_SIZE + 1] = {0};

int ipa_offload_en = 1;
module_param(ipa_offload_en, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
@@ -778,6 +780,74 @@ static int DWC_ETH_QOS_ioremap(void)
	return ret;
}

int DWC_ETH_QOS_qmp_mailbox_init(struct DWC_ETH_QOS_prv_data *pdata)
{
	pdata->qmp_mbox_client = devm_kzalloc(
	   &pdata->pdev->dev, sizeof(*pdata->qmp_mbox_client), GFP_KERNEL);

	if (IS_ERR(pdata->qmp_mbox_client)){
		EMACERR("qmp alloc client failed\n");
		return -1;
	}

	pdata->qmp_mbox_client->dev = &pdata->pdev->dev;
	pdata->qmp_mbox_client->tx_block = true;
	pdata->qmp_mbox_client->tx_tout = 1000;
	pdata->qmp_mbox_client->knows_txdone = false;

	pdata->qmp_mbox_chan = mbox_request_channel(pdata->qmp_mbox_client, 0);

	if (IS_ERR(pdata->qmp_mbox_chan)) {
		EMACERR("qmp reuest channel failed\n");
		return -1;
	}

	return 0;
}

int DWC_ETH_QOS_qmp_mailbox_send_message(struct DWC_ETH_QOS_prv_data *pdata)
{
	int ret = 0;

	memset(&qmp_buf[0], 0, MAX_QMP_MSG_SIZE + 1);

	snprintf(qmp_buf, MAX_QMP_MSG_SIZE, "{class:ctile, pc:0}");

	pkt.size = ((size_t)strlen(qmp_buf) + 0x3) & ~0x3;
	pkt.data = qmp_buf;

	ret = mbox_send_message(pdata->qmp_mbox_chan, (void*)&pkt);

	EMACDBG("qmp mbox_send_message ret = %d \n", ret);

	if (ret < 0) {
		EMACERR("Disabling c-tile power collapse failed\n");
		return ret;
	}

	EMACINFO("Disabling c-tile power collapse succeded");

	return 0;
}

/**
 *  DWC_ETH_QOS_qmp_mailbox_work - Scheduled from probe
 *  @work: work_struct
 */
void DWC_ETH_QOS_qmp_mailbox_work(struct work_struct *work)
{
	struct DWC_ETH_QOS_prv_data *pdata =
		container_of(work, struct DWC_ETH_QOS_prv_data, qmp_mailbox_work);

	EMACDBG("Enter\n");

	/* Send QMP message to disable c-tile power collapse */
	DWC_ETH_QOS_qmp_mailbox_send_message(pdata);

	EMACDBG("Exit\n");
}


int DWC_ETH_QOS_enable_ptp_clk(struct device *dev)
{
	int ret;
@@ -1465,6 +1535,14 @@ static int DWC_ETH_QOS_configure_netdevice(struct platform_device *pdev)

	DWC_ETH_QOS_create_debugfs(pdata);

	if (EMAC_HW_v2_0_0 == pdata->emac_hw_version_type)
		pdata->disable_ctile_pc = 1;

	if (pdata->disable_ctile_pc && !DWC_ETH_QOS_qmp_mailbox_init(pdata)){
		INIT_WORK(&pdata->qmp_mailbox_work, DWC_ETH_QOS_qmp_mailbox_work);
		queue_work(system_wq, &pdata->qmp_mailbox_work);
	}

	EMACDBG("<-- DWC_ETH_QOS_configure_netdevice\n");

	return 0;
+11 −2
Original line number Diff line number Diff line
@@ -121,6 +121,9 @@
#include <linux/of_gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/err.h>
#include <linux/mailbox_client.h>
#include <linux/mailbox/qmp.h>
#include <linux/mailbox_controller.h>

/* QOS Version Control Macros */
/* #define DWC_ETH_QOS_VER_4_0 */
@@ -666,6 +669,7 @@
#define MII_100_LOW_SVS_CLK_FREQ  (25 * 1000 * 1000UL)
#define MII_10_LOW_SVS_CLK_FREQ  (2.5 * 1000 * 1000UL)

#define MAX_QMP_MSG_SIZE 96
#define NAPI_PER_QUEUE_POLL_BUDGET 64

/**
@@ -692,7 +696,6 @@
#define EMAC_HW_v2_3_2 8
#define EMAC_HW_vMAX 9


/* C data types typedefs */
typedef unsigned short BOOL;
typedef char CHAR;
@@ -1800,8 +1803,15 @@ struct DWC_ETH_QOS_prv_data {
	unsigned int io_macro_tx_mode_non_id;
	unsigned int io_macro_phy_intf;
	int phy_irq;

	unsigned int emac_hw_version_type;

	/* QMP message for disabling ctile power collapse while XO shutdown */
	struct mbox_chan *qmp_mbox_chan;
	struct mbox_client *qmp_mbox_client;
	struct work_struct qmp_mailbox_work;
	int disable_ctile_pc;

	/* Work struct for handling phy interrupt */
	struct work_struct emac_phy_work;

@@ -1812,7 +1822,6 @@ struct DWC_ETH_QOS_prv_data {

	/* Debugfs base dir */
	struct dentry *debugfs_dir;

	/* ptp clock frequency set by PTPCLK_Config ioctl default value is 250MHz */
	unsigned int ptpclk_freq;
};