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

Commit 0f81e6c5 authored by Yue Ma's avatar Yue Ma
Browse files

cnss2: Enable device time snapshot before getting host time



In order to minimize the time difference between getting device time
and getting host time, enable device time snapshot before getting host
time.

Change-Id: I55f27720af78b125d662f45e0ef819823d241ab6
Signed-off-by: default avatarYue Ma <yuem@codeaurora.org>
parent e0458878
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -1081,9 +1081,6 @@ static int cnss_pci_get_device_timestamp(struct cnss_pci_data *pci_priv,
		return -EINVAL;
	}

	cnss_pci_reg_write(pci_priv, QCA6390_WLAON_GLOBAL_COUNTER_CTRL5,
			   QCA6390_TIME_SYNC_ENABLE);

	cnss_pci_reg_read(pci_priv, QCA6390_WLAON_GLOBAL_COUNTER_CTRL3, &low);
	cnss_pci_reg_read(pci_priv, QCA6390_WLAON_GLOBAL_COUNTER_CTRL4, &high);

@@ -1094,6 +1091,18 @@ static int cnss_pci_get_device_timestamp(struct cnss_pci_data *pci_priv,
	return 0;
}

static void cnss_pci_enable_time_sync_counter(struct cnss_pci_data *pci_priv)
{
	cnss_pci_reg_write(pci_priv, QCA6390_WLAON_GLOBAL_COUNTER_CTRL5,
			   QCA6390_TIME_SYNC_ENABLE);
}

static void cnss_pci_clear_time_sync_counter(struct cnss_pci_data *pci_priv)
{
	cnss_pci_reg_write(pci_priv, QCA6390_WLAON_GLOBAL_COUNTER_CTRL5,
			   QCA6390_TIME_SYNC_CLEAR);
}

static int cnss_pci_update_timestamp(struct cnss_pci_data *pci_priv)
{
	struct cnss_plat_data *plat_priv = pci_priv->plat_priv;
@@ -1111,10 +1120,11 @@ static int cnss_pci_update_timestamp(struct cnss_pci_data *pci_priv)
		return ret;

	spin_lock_irqsave(&time_sync_lock, flags);
	cnss_pci_reg_write(pci_priv, QCA6390_WLAON_GLOBAL_COUNTER_CTRL5,
			   QCA6390_TIME_SYNC_CLEAR);
	cnss_pci_clear_time_sync_counter(pci_priv);
	cnss_pci_enable_time_sync_counter(pci_priv);
	host_time_us = cnss_get_host_timestamp(plat_priv);
	ret = cnss_pci_get_device_timestamp(pci_priv, &device_time_us);
	cnss_pci_clear_time_sync_counter(pci_priv);
	spin_unlock_irqrestore(&time_sync_lock, flags);
	if (ret)
		goto force_wake_put;