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

Commit 2e34546e authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "iio: adc: Add IPC logging support for VADC"

parents 345835de ddf9572c
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/slab.h>
#include <linux/log2.h>
#include <linux/qpnp/qpnp-revid.h>
#include <linux/ipc_logging.h>

#include <dt-bindings/iio/qcom,spmi-vadc.h>

@@ -157,6 +158,8 @@ struct adc_chip {
	struct completion	complete;
	struct mutex		lock;
	bool			skip_usb_wa;
	void			*ipc_log0;
	void			*ipc_log1;
	struct pmic_revid_data	*pmic_rev_id;
	const struct adc_data	*data;
};
@@ -987,6 +990,7 @@ static int adc_probe(struct platform_device *pdev)
	int ret, irq_eoc;
	u32 reg;
	bool skip_usb_wa = false;
	char adc_name[40];

	regmap = dev_get_regmap(dev->parent, NULL);
	if (!regmap)
@@ -1061,6 +1065,26 @@ static int adc_probe(struct platform_device *pdev)
	indio_dev->channels = adc->iio_chans;
	indio_dev->num_channels = adc->nchannels;

	snprintf(adc_name, sizeof(adc_name), "vadc_%s_0",
					node->parent->full_name);

	adc->ipc_log0 = ipc_log_context_create(IPC_LOGPAGES,
							adc_name, 0);

	if (!adc->ipc_log0)
		pr_err("%s : unable to create IPC Logging 0 for %s ADC\n",
					__func__, node->parent->full_name);

	snprintf(adc_name, sizeof(adc_name), "vadc_%s_1",
					node->parent->full_name);

	adc->ipc_log1 = ipc_log_context_create(IPC_LOGPAGES,
							adc_name, 0);

	if (!adc->ipc_log1)
		pr_err("%s : unable to create IPC Logging 1 for %s ADC\n",
					__func__, node->parent->full_name);

	return devm_iio_device_register(dev, indio_dev);
}

+28 −0
Original line number Diff line number Diff line
@@ -52,6 +52,34 @@
#define VADC5_FULL_SCALE_CODE			0x70e4
#define ADC_USR_DATA_CHECK			0x8000

#define IPC_LOGPAGES 10

#ifdef CONFIG_DEBUG_FS
#define ADC_IPC(idx, dev, msg, args...) do { \
		if (dev) { \
			if ((idx == 0) && (dev)->ipc_log0) \
				ipc_log_string((dev)->ipc_log0, \
					"%s: " msg, __func__, args); \
			else if ((idx == 1) && (dev)->ipc_log1) \
				ipc_log_string((dev)->ipc_log1, \
					"%s: " msg, __func__, args); \
			else \
				pr_debug("adc: invalid logging index\n"); \
		} \
	} while (0)
#define ADC_DBG(dev, msg, args...) do {				\
		ADC_IPC(0, dev, msg, args); \
		pr_debug(msg, ##args);	\
	} while (0)
#define ADC_DBG1(dev, msg, args...) do {				\
		ADC_IPC(1, dev, msg, args); \
		pr_debug(msg, ##args);	\
	} while (0)
#else
#define	ADC_DBG(dev, msg, args...)		pr_debug(msg, ##args)
#define	ADC_DBG1(dev, msg, args...)		pr_debug(msg, ##args)
#endif

/**
 * struct vadc_map_pt - Map the graph representation for ADC channel
 * @x: Represent the ADC digitized code.