diff mbox series

[RFC,15/17] net: ipa: Add IPA v2.6L initialization sequence support

Message ID 20210920030811.57273-16-sireeshkodali1@gmail.com (mailing list archive)
State Not Applicable
Headers show
Series net: ipa: Add support for IPA v2.x | expand

Commit Message

Sireesh Kodali Sept. 20, 2021, 3:08 a.m. UTC
The biggest changes are:

- Make SMP2P functions no-operation
- Make resource init no-operation
- Skip firmware loading
- Add reset sequence

Signed-off-by: Sireesh Kodali <sireeshkodali1@gmail.com>
---
 drivers/net/ipa/ipa_main.c     | 19 ++++++++++++++++---
 drivers/net/ipa/ipa_resource.c |  3 +++
 drivers/net/ipa/ipa_smp2p.c    | 11 +++++++++--
 3 files changed, 28 insertions(+), 5 deletions(-)

Comments

Alex Elder Oct. 13, 2021, 10:30 p.m. UTC | #1
On 9/19/21 10:08 PM, Sireesh Kodali wrote:
> The biggest changes are:
> 
> - Make SMP2P functions no-operation
> - Make resource init no-operation
> - Skip firmware loading
> - Add reset sequence

The only comments I have are not very major, so I'll wait
for a later review to suggest that sort of fine tuning.

					-Alex

> Signed-off-by: Sireesh Kodali <sireeshkodali1@gmail.com>
> ---
>   drivers/net/ipa/ipa_main.c     | 19 ++++++++++++++++---
>   drivers/net/ipa/ipa_resource.c |  3 +++
>   drivers/net/ipa/ipa_smp2p.c    | 11 +++++++++--
>   3 files changed, 28 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
> index ea6c4347f2c6..b437fbf95edf 100644
> --- a/drivers/net/ipa/ipa_main.c
> +++ b/drivers/net/ipa/ipa_main.c
> @@ -355,12 +355,22 @@ static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *data)
>   	u32 granularity;
>   	u32 val;
>   
> +	if (ipa->version <= IPA_VERSION_2_6L) {
> +		iowrite32(1, ipa->reg_virt + IPA_REG_COMP_SW_RESET_OFFSET);
> +		iowrite32(0, ipa->reg_virt + IPA_REG_COMP_SW_RESET_OFFSET);
> +
> +		iowrite32(1, ipa->reg_virt + ipa_reg_comp_cfg_offset(ipa->version));
> +	}
> +
>   	/* IPA v4.5+ has no backward compatibility register */
> -	if (version < IPA_VERSION_4_5) {
> +	if (version >= IPA_VERSION_2_5 && version < IPA_VERSION_4_5) {
>   		val = data->backward_compat;
>   		iowrite32(val, ipa->reg_virt + ipa_reg_bcr_offset(ipa->version));
>   	}
>   
> +	if (ipa->version <= IPA_VERSION_2_6L)
> +		return;
> +
>   	/* Implement some hardware workarounds */
>   	if (version >= IPA_VERSION_4_0 && version < IPA_VERSION_4_5) {
>   		/* Disable PA mask to allow HOLB drop */
> @@ -412,7 +422,8 @@ static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *data)
>   static void ipa_hardware_deconfig(struct ipa *ipa)
>   {
>   	/* Mostly we just leave things as we set them. */
> -	ipa_hardware_dcd_deconfig(ipa);
> +	if (ipa->version > IPA_VERSION_2_6L)
> +		ipa_hardware_dcd_deconfig(ipa);
>   }
>   
>   /**
> @@ -765,8 +776,10 @@ static int ipa_probe(struct platform_device *pdev)
>   
>   	/* Otherwise we need to load the firmware and have Trust Zone validate
>   	 * and install it.  If that succeeds we can proceed with setup.
> +	 * But on IPA v2.6L we don't need to do firmware loading :D
>   	 */
> -	ret = ipa_firmware_load(dev);
> +	if (ipa->version > IPA_VERSION_2_6L)
> +		ret = ipa_firmware_load(dev);
>   	if (ret)
>   		goto err_deconfig;
>   
> diff --git a/drivers/net/ipa/ipa_resource.c b/drivers/net/ipa/ipa_resource.c
> index e3da95d69409..36a72324d828 100644
> --- a/drivers/net/ipa/ipa_resource.c
> +++ b/drivers/net/ipa/ipa_resource.c
> @@ -162,6 +162,9 @@ int ipa_resource_config(struct ipa *ipa, const struct ipa_resource_data *data)
>   {
>   	u32 i;
>   
> +	if (ipa->version <= IPA_VERSION_2_6L)
> +		return 0;
> +
>   	if (!ipa_resource_limits_valid(ipa, data))
>   		return -EINVAL;
>   
> diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c
> index df7639c39d71..fa4a9f1c196a 100644
> --- a/drivers/net/ipa/ipa_smp2p.c
> +++ b/drivers/net/ipa/ipa_smp2p.c
> @@ -233,6 +233,10 @@ int ipa_smp2p_init(struct ipa *ipa, bool modem_init)
>   	u32 valid_bit;
>   	int ret;
>   
> +	/* With IPA v2.6L and earlier SMP2P interrupts are used */
> +	if (ipa->version <= IPA_VERSION_2_6L)
> +		return 0;
> +
>   	valid_state = qcom_smem_state_get(dev, "ipa-clock-enabled-valid",
>   					  &valid_bit);
>   	if (IS_ERR(valid_state))
> @@ -302,6 +306,9 @@ void ipa_smp2p_exit(struct ipa *ipa)
>   {
>   	struct ipa_smp2p *smp2p = ipa->smp2p;
>   
> +	if (!smp2p)
> +		return;
> +
>   	if (smp2p->setup_ready_irq)
>   		ipa_smp2p_irq_exit(smp2p, smp2p->setup_ready_irq);
>   	ipa_smp2p_panic_notifier_unregister(smp2p);
> @@ -317,7 +324,7 @@ void ipa_smp2p_disable(struct ipa *ipa)
>   {
>   	struct ipa_smp2p *smp2p = ipa->smp2p;
>   
> -	if (!smp2p->setup_ready_irq)
> +	if (!smp2p || !smp2p->setup_ready_irq)
>   		return;
>   
>   	mutex_lock(&smp2p->mutex);
> @@ -333,7 +340,7 @@ void ipa_smp2p_notify_reset(struct ipa *ipa)
>   	struct ipa_smp2p *smp2p = ipa->smp2p;
>   	u32 mask;
>   
> -	if (!smp2p->notified)
> +	if (!smp2p || !smp2p->notified)
>   		return;
>   
>   	ipa_smp2p_power_release(ipa);
>
diff mbox series

Patch

diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index ea6c4347f2c6..b437fbf95edf 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -355,12 +355,22 @@  static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *data)
 	u32 granularity;
 	u32 val;
 
+	if (ipa->version <= IPA_VERSION_2_6L) {
+		iowrite32(1, ipa->reg_virt + IPA_REG_COMP_SW_RESET_OFFSET);
+		iowrite32(0, ipa->reg_virt + IPA_REG_COMP_SW_RESET_OFFSET);
+
+		iowrite32(1, ipa->reg_virt + ipa_reg_comp_cfg_offset(ipa->version));
+	}
+
 	/* IPA v4.5+ has no backward compatibility register */
-	if (version < IPA_VERSION_4_5) {
+	if (version >= IPA_VERSION_2_5 && version < IPA_VERSION_4_5) {
 		val = data->backward_compat;
 		iowrite32(val, ipa->reg_virt + ipa_reg_bcr_offset(ipa->version));
 	}
 
+	if (ipa->version <= IPA_VERSION_2_6L)
+		return;
+
 	/* Implement some hardware workarounds */
 	if (version >= IPA_VERSION_4_0 && version < IPA_VERSION_4_5) {
 		/* Disable PA mask to allow HOLB drop */
@@ -412,7 +422,8 @@  static void ipa_hardware_config(struct ipa *ipa, const struct ipa_data *data)
 static void ipa_hardware_deconfig(struct ipa *ipa)
 {
 	/* Mostly we just leave things as we set them. */
-	ipa_hardware_dcd_deconfig(ipa);
+	if (ipa->version > IPA_VERSION_2_6L)
+		ipa_hardware_dcd_deconfig(ipa);
 }
 
 /**
@@ -765,8 +776,10 @@  static int ipa_probe(struct platform_device *pdev)
 
 	/* Otherwise we need to load the firmware and have Trust Zone validate
 	 * and install it.  If that succeeds we can proceed with setup.
+	 * But on IPA v2.6L we don't need to do firmware loading :D
 	 */
-	ret = ipa_firmware_load(dev);
+	if (ipa->version > IPA_VERSION_2_6L)
+		ret = ipa_firmware_load(dev);
 	if (ret)
 		goto err_deconfig;
 
diff --git a/drivers/net/ipa/ipa_resource.c b/drivers/net/ipa/ipa_resource.c
index e3da95d69409..36a72324d828 100644
--- a/drivers/net/ipa/ipa_resource.c
+++ b/drivers/net/ipa/ipa_resource.c
@@ -162,6 +162,9 @@  int ipa_resource_config(struct ipa *ipa, const struct ipa_resource_data *data)
 {
 	u32 i;
 
+	if (ipa->version <= IPA_VERSION_2_6L)
+		return 0;
+
 	if (!ipa_resource_limits_valid(ipa, data))
 		return -EINVAL;
 
diff --git a/drivers/net/ipa/ipa_smp2p.c b/drivers/net/ipa/ipa_smp2p.c
index df7639c39d71..fa4a9f1c196a 100644
--- a/drivers/net/ipa/ipa_smp2p.c
+++ b/drivers/net/ipa/ipa_smp2p.c
@@ -233,6 +233,10 @@  int ipa_smp2p_init(struct ipa *ipa, bool modem_init)
 	u32 valid_bit;
 	int ret;
 
+	/* With IPA v2.6L and earlier SMP2P interrupts are used */
+	if (ipa->version <= IPA_VERSION_2_6L)
+		return 0;
+
 	valid_state = qcom_smem_state_get(dev, "ipa-clock-enabled-valid",
 					  &valid_bit);
 	if (IS_ERR(valid_state))
@@ -302,6 +306,9 @@  void ipa_smp2p_exit(struct ipa *ipa)
 {
 	struct ipa_smp2p *smp2p = ipa->smp2p;
 
+	if (!smp2p)
+		return;
+
 	if (smp2p->setup_ready_irq)
 		ipa_smp2p_irq_exit(smp2p, smp2p->setup_ready_irq);
 	ipa_smp2p_panic_notifier_unregister(smp2p);
@@ -317,7 +324,7 @@  void ipa_smp2p_disable(struct ipa *ipa)
 {
 	struct ipa_smp2p *smp2p = ipa->smp2p;
 
-	if (!smp2p->setup_ready_irq)
+	if (!smp2p || !smp2p->setup_ready_irq)
 		return;
 
 	mutex_lock(&smp2p->mutex);
@@ -333,7 +340,7 @@  void ipa_smp2p_notify_reset(struct ipa *ipa)
 	struct ipa_smp2p *smp2p = ipa->smp2p;
 	u32 mask;
 
-	if (!smp2p->notified)
+	if (!smp2p || !smp2p->notified)
 		return;
 
 	ipa_smp2p_power_release(ipa);