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

Commit 9a9c4cfc authored by Mohammed Javid's avatar Mohammed Javid Committed by Gerrit - the friendly Code Review server
Browse files

msm: ipa: smp2p changes for IPA driver



Add smp2p support in ipa-driver to
communicate with modem to get ipa
reg dump.

Change-Id: Ia2a7ea319a6ff910e4bbabad736e1cc8f642a297
Acked-by: default avatarAbhishek Choubey <abchoube@qti.qualcomm.com>
Signed-off-by: default avatarSkylar Chang <chiaweic@codeaurora.org>
parent 4a79d5ff
Loading
Loading
Loading
Loading
+7 −11
Original line number Diff line number Diff line
@@ -141,14 +141,12 @@ IPA SMMU sub nodes

IPA SMP2P sub nodes

-compatible: "qcom,smp2pgpio-map-ipa-1-out" - represents the out gpio from
-compatible: "qcom,smp2p-map-ipa-1-out" - represents the out smp2p from
					      ipa driver to modem.

-compatible: "qcom,smp2pgpio-map-ipa-1-in" - represents the in gpio to
-compatible: "qcom,smp2p-map-ipa-1-in" - represents the in smp2p to
					     ipa driver from modem.

-gpios: Binding to the gpio defined in XXX-smp2p.dtsi


Example:

@@ -201,15 +199,13 @@ qcom,ipa@fd4c0000 {
		qcom,descriptor-fifo-size = <0x300>;
	};

	/* smp2p gpio information */
	qcom,smp2pgpio_map_ipa_1_out {
		compatible = "qcom,smp2pgpio-map-ipa-1-out";
		gpios = <&smp2pgpio_ipa_1_out 0 0>;
	/* smp2p information */
	qcom,smp2p_map_ipa_1_out {
		compatible = "qcom,smp2p-map-ipa-1-out";
	};

	qcom,smp2pgpio_map_ipa_1_in {
		compatible = "qcom,smp2pgpio-map-ipa-1-in";
		gpios = <&smp2pgpio_ipa_1_in 0 0>;
	qcom,smp2p_map_ipa_1_in {
		compatible = "qcom,smp2p-map-ipa-1-in";
	};

	ipa_smmu_ap: ipa_smmu_ap {
+2 −2
Original line number Diff line number Diff line
@@ -2771,8 +2771,8 @@ static const struct of_device_id ipa_plat_drv_match[] = {
	{ .compatible = "qcom,ipa-smmu-ap-cb", },
	{ .compatible = "qcom,ipa-smmu-wlan-cb", },
	{ .compatible = "qcom,ipa-smmu-uc-cb", },
	{ .compatible = "qcom,smp2pgpio-map-ipa-1-in", },
	{ .compatible = "qcom,smp2pgpio-map-ipa-1-out", },
	{ .compatible = "qcom,smp2p-map-ipa-1-in", },
	{ .compatible = "qcom,smp2p-map-ipa-1-out", },
	{}
};

+30 −42
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@
#include <linux/soc/qcom/smem.h>
#include <soc/qcom/scm.h>
#include <asm/cacheflush.h>
#include <linux/soc/qcom/smem_state.h>
#include <linux/of_irq.h>

#ifdef CONFIG_ARM64

@@ -61,6 +63,8 @@
#define IPA_GPIO_IN_QUERY_CLK_IDX 0
#define IPA_GPIO_OUT_CLK_RSP_CMPLT_IDX 0
#define IPA_GPIO_OUT_CLK_VOTE_IDX 1
#define IPA_SMP2P_SMEM_STATE_MASK 3


#define IPA_SUMMING_THRESHOLD (0x10)
#define IPA_PIPE_MEM_START_OFST (0x0)
@@ -4245,8 +4249,9 @@ static void ipa3_freeze_clock_vote_and_notify_modem(void)
	if (ipa3_ctx->smp2p_info.res_sent)
		return;

	if (ipa3_ctx->smp2p_info.out_base_id == 0) {
		IPAERR("smp2p out gpio not assigned\n");
	if (IS_ERR(ipa3_ctx->smp2p_info.smem_state)) {
		IPAERR("fail to get smp2p clk resp bit %d\n",
			PTR_ERR(ipa3_ctx->smp2p_info.smem_state));
		return;
	}

@@ -4257,11 +4262,9 @@ static void ipa3_freeze_clock_vote_and_notify_modem(void)
	else
		ipa3_ctx->smp2p_info.ipa_clk_on = true;

	gpio_set_value(ipa3_ctx->smp2p_info.out_base_id +
		IPA_GPIO_OUT_CLK_VOTE_IDX,
		ipa3_ctx->smp2p_info.ipa_clk_on);
	gpio_set_value(ipa3_ctx->smp2p_info.out_base_id +
		IPA_GPIO_OUT_CLK_RSP_CMPLT_IDX, 1);
	qcom_smem_state_update_bits(ipa3_ctx->smp2p_info.smem_state,
			BIT(IPA_SMP2P_SMEM_STATE_MASK),
			BIT(ipa3_ctx->smp2p_info.ipa_clk_on | (1<<1)));

	ipa3_ctx->smp2p_info.res_sent = true;
	IPADBG("IPA clocks are %s\n",
@@ -6250,56 +6253,42 @@ static int ipa3_smp2p_probe(struct device *dev)
{
	struct device_node *node = dev->of_node;
	int res;
	int irq = 0;

	if (ipa3_ctx == NULL) {
		IPAERR("ipa3_ctx was not initialized\n");
		return -ENXIO;
		return -EPROBE_DEFER;
	}
	IPADBG("node->name=%s\n", node->name);
	if (strcmp("qcom,smp2pgpio_map_ipa_1_out", node->name) == 0) {
		res = of_get_gpio(node, 0);
		if (res < 0) {
			IPADBG("of_get_gpio returned %d\n", res);
			return res;
		}

		ipa3_ctx->smp2p_info.out_base_id = res;
		IPADBG("smp2p out_base_id=%d\n",
			ipa3_ctx->smp2p_info.out_base_id);
	} else if (strcmp("qcom,smp2pgpio_map_ipa_1_in", node->name) == 0) {
		int irq;

		res = of_get_gpio(node, 0);
	if (strcmp("qcom,smp2p_map_ipa_1_out", node->name) == 0) {
		if (of_find_property(node, "qcom,smem-states", NULL)) {
			ipa3_ctx->smp2p_info.smem_state =
			qcom_smem_state_get(dev, "ipa-smp2p-out",
			&ipa3_ctx->smp2p_info.smem_bit);
			if (IS_ERR(ipa3_ctx->smp2p_info.smem_state)) {
				IPAERR("fail to get smp2p clk resp bit %d\n",
				PTR_ERR(ipa3_ctx->smp2p_info.smem_state));
				return PTR_ERR(ipa3_ctx->smp2p_info.smem_state);
			}
			IPADBG("smem_bit=%d\n", ipa3_ctx->smp2p_info.smem_bit);
		}
	} else if (strcmp("qcom,smp2p_map_ipa_1_in", node->name) == 0) {
		res = irq = of_irq_get_byname(node, "ipa-smp2p-in");
		if (res < 0) {
			IPADBG("of_get_gpio returned %d\n", res);
			IPADBG("of_irq_get_byname returned %d\n", irq);
			return res;
		}

		ipa3_ctx->smp2p_info.in_base_id = res;
		IPADBG("smp2p in_base_id=%d\n",
			ipa3_ctx->smp2p_info.in_base_id);

		/* register for modem clk query */
		irq = gpio_to_irq(ipa3_ctx->smp2p_info.in_base_id +
			IPA_GPIO_IN_QUERY_CLK_IDX);
		if (irq < 0) {
			IPAERR("gpio_to_irq failed %d\n", irq);
			return -ENODEV;
		}
		ipa3_ctx->smp2p_info.in_base_id = irq;
		IPADBG("smp2p irq#=%d\n", irq);
		res = request_irq(irq,
		res = devm_request_threaded_irq(dev, irq, NULL,
			(irq_handler_t)ipa3_smp2p_modem_clk_query_isr,
			IRQF_TRIGGER_RISING, "ipa_smp2p_clk_vote", dev);
		if (res) {
			IPAERR("fail to register smp2p irq=%d\n", irq);
			return -ENODEV;
		}
		res = enable_irq_wake(ipa3_ctx->smp2p_info.in_base_id +
			IPA_GPIO_IN_QUERY_CLK_IDX);
		if (res)
			IPAERR("failed to enable irq wake\n");
	}

	return 0;
}

@@ -6339,11 +6328,10 @@ int ipa3_plat_drv_probe(struct platform_device *pdev_p,
	}

	if (of_device_is_compatible(dev->of_node,
	    "qcom,smp2pgpio-map-ipa-1-in"))
	    "qcom,smp2p-map-ipa-1-out"))
		return ipa3_smp2p_probe(dev);

	if (of_device_is_compatible(dev->of_node,
	    "qcom,smp2pgpio-map-ipa-1-out"))
	    "qcom,smp2p-map-ipa-1-in"))
		return ipa3_smp2p_probe(dev);

	result = get_ipa_dts_configuration(pdev_p, &ipa3_res);
+2 −0
Original line number Diff line number Diff line
@@ -1092,6 +1092,8 @@ struct ipa3_smp2p_info {
	u32 in_base_id;
	bool ipa_clk_on;
	bool res_sent;
	unsigned int smem_bit;
	struct qcom_smem_state *smem_state;
};

/**