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

Commit 00923319 authored by Hardik Kantilal Patel's avatar Hardik Kantilal Patel
Browse files

wcnss: Add VBATT support for MSM8952



- Add ADC entry for wcnss which is use to listen low vbatt
  notification from ADC.
- Prevent sending vbatt notification to FW incase of ADC
  channel not present.

CRs-Fixed: 855069
Change-Id: If53a2d2089f292cbd87418d0a451bd11a0c95322
Signed-off-by: default avatarHardik Kantilal Patel <hkpatel@codeaurora.org>
parent b8c492ed
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ in TX data path and correct voting to RPM will be decided for booting.
	1      -  WCN RPM power collapse enabled
	1      -  WCN standalone power collapse enabled
	6      -  GPIO strength value

- qcom,has-vsys-adc-channel: boolean flag to determine which ADC HW channel need
to use for VBATT feature.

Example:

+2 −0
Original line number Diff line number Diff line
@@ -944,6 +944,8 @@
		qcom,has-autodetect-xo;
		qcom,is-pronto-v4;
		qcom,has-pronto-hw;
		qcom,has-vsys-adc-channel;
		qcom,wcnss-adc_tm = <&pm8950_adc_tm>;
	};

	usb_otg: usb@78db000 {
+21 −5
Original line number Diff line number Diff line
@@ -371,6 +371,7 @@ static struct {
	int		triggered;
	int		smd_channel_ready;
	u32		wlan_rx_buff_count;
	int		is_vsys_adc_channel;
	smd_channel_t	*smd_ch;
	unsigned char	wcnss_version[WCNSS_VERSION_LEN];
	unsigned char   fw_major;
@@ -1859,6 +1860,8 @@ static int wcnss_smd_tx(void *data, int len)

static void wcnss_notify_vbat(enum qpnp_tm_state state, void *ctx)
{
	int rc = 0;

	mutex_lock(&penv->vbat_monitor_mutex);
	cancel_delayed_work_sync(&penv->vbatt_work);

@@ -1886,9 +1889,15 @@ static void wcnss_notify_vbat(enum qpnp_tm_state state, void *ctx)
			penv->vbat_monitor_params.low_thr,
			penv->vbat_monitor_params.high_thr);

	qpnp_adc_tm_channel_measure(penv->adc_tm_dev,
	rc = qpnp_adc_tm_channel_measure(penv->adc_tm_dev,
					 &penv->vbat_monitor_params);
	schedule_delayed_work(&penv->vbatt_work, msecs_to_jiffies(2000));

	if (rc)
		pr_err("%s: tm setup failed: %d\n", __func__, rc);
	else
		schedule_delayed_work(&penv->vbatt_work,
				      msecs_to_jiffies(2000));

	mutex_unlock(&penv->vbat_monitor_mutex);
}

@@ -1903,7 +1912,12 @@ static int wcnss_setup_vbat_monitoring(void)
	penv->vbat_monitor_params.low_thr = WCNSS_VBATT_THRESHOLD;
	penv->vbat_monitor_params.high_thr = WCNSS_VBATT_THRESHOLD;
	penv->vbat_monitor_params.state_request = ADC_TM_HIGH_LOW_THR_ENABLE;

	if (penv->is_vsys_adc_channel)
		penv->vbat_monitor_params.channel = VSYS;
	else
		penv->vbat_monitor_params.channel = VBAT_SNS;

	penv->vbat_monitor_params.btm_ctx = (void *)penv;
	penv->vbat_monitor_params.timer_interval = ADC_MEAS1_INTERVAL_1S;
	penv->vbat_monitor_params.threshold_notification = &wcnss_notify_vbat;
@@ -1914,7 +1928,7 @@ static int wcnss_setup_vbat_monitoring(void)
	rc = qpnp_adc_tm_channel_measure(penv->adc_tm_dev,
					&penv->vbat_monitor_params);
	if (rc)
		pr_err("wcnss: tm setup failed: %d\n", rc);
		pr_err("%s: tm setup failed: %d\n", __func__, rc);

	return rc;
}
@@ -2658,6 +2672,8 @@ wcnss_trigger_config(struct platform_device *pdev)
	is_pronto_v3 = of_property_read_bool(pdev->dev.of_node,
							"qcom,is-pronto-v3");

	penv->is_vsys_adc_channel = of_property_read_bool(pdev->dev.of_node,
						"qcom,has-vsys-adc-channel");
	if (of_property_read_u32(pdev->dev.of_node,
			"qcom,wlan-rx-buff-count", &penv->wlan_rx_buff_count)) {
		penv->wlan_rx_buff_count = WCNSS_DEF_WLAN_RX_BUFF_COUNT;