linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc: qcom: pmic_glink: Add support for SOCCP remoteproc channels
@ 2025-09-02 21:45 Anjelique Melendez
  2025-09-02 23:57 ` Dmitry Baryshkov
  0 siblings, 1 reply; 2+ messages in thread
From: Anjelique Melendez @ 2025-09-02 21:45 UTC (permalink / raw)
  To: andersson, konradybcio; +Cc: linux-arm-msm, linux-kernel

Add support for charger FW running on SOCCP by adding the
"PMIC_RTR_SOCCP_APPS" channel name to the rpmsg_match list and
updating notify_clients logic.

SOCCP does not have multiple PDs and hence PDR is not supported. So, if
the subsystem comes up/down, rpmsg driver would be probed or removed.
Use that for notifiying clients of pmic_glink for PDR events.

Signed-off-by: Anjelique Melendez <anjelique.melendez@oss.qualcomm.com>
---
 drivers/soc/qcom/pmic_glink.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/qcom/pmic_glink.c b/drivers/soc/qcom/pmic_glink.c
index c0a4be5df926..bcd17fc05544 100644
--- a/drivers/soc/qcom/pmic_glink.c
+++ b/drivers/soc/qcom/pmic_glink.c
@@ -17,6 +17,11 @@
 
 #define PMIC_GLINK_SEND_TIMEOUT (5 * HZ)
 
+enum {
+	PMIC_GLINK_PDR_UNAVAIL = 0,
+	PMIC_GLINK_PDR_AVAIL,
+};
+
 enum {
 	PMIC_GLINK_CLIENT_BATT = 0,
 	PMIC_GLINK_CLIENT_ALTMODE,
@@ -39,6 +44,7 @@ struct pmic_glink {
 	struct mutex state_lock;
 	unsigned int client_state;
 	unsigned int pdr_state;
+	bool pdr_available;
 
 	/* serializing clients list updates */
 	spinlock_t client_lock;
@@ -203,17 +209,17 @@ static void pmic_glink_del_aux_device(struct pmic_glink *pg,
 	auxiliary_device_uninit(aux);
 }
 
-static void pmic_glink_state_notify_clients(struct pmic_glink *pg)
+static void pmic_glink_state_notify_clients(struct pmic_glink *pg, unsigned int state)
 {
 	struct pmic_glink_client *client;
 	unsigned int new_state = pg->client_state;
 	unsigned long flags;
 
 	if (pg->client_state != SERVREG_SERVICE_STATE_UP) {
-		if (pg->pdr_state == SERVREG_SERVICE_STATE_UP && pg->ept)
+		if (state == SERVREG_SERVICE_STATE_UP && pg->ept)
 			new_state = SERVREG_SERVICE_STATE_UP;
 	} else {
-		if (pg->pdr_state == SERVREG_SERVICE_STATE_DOWN || !pg->ept)
+		if (state == SERVREG_SERVICE_STATE_DOWN || !pg->ept)
 			new_state = SERVREG_SERVICE_STATE_DOWN;
 	}
 
@@ -233,7 +239,7 @@ static void pmic_glink_pdr_callback(int state, char *svc_path, void *priv)
 	guard(mutex)(&pg->state_lock);
 	pg->pdr_state = state;
 
-	pmic_glink_state_notify_clients(pg);
+	pmic_glink_state_notify_clients(pg, state);
 }
 
 static int pmic_glink_rpmsg_probe(struct rpmsg_device *rpdev)
@@ -246,10 +252,14 @@ static int pmic_glink_rpmsg_probe(struct rpmsg_device *rpdev)
 		return dev_err_probe(&rpdev->dev, -ENODEV, "no pmic_glink device to attach to\n");
 
 	dev_set_drvdata(&rpdev->dev, pg);
+	pg->pdr_available = rpdev->id.driver_data;
 
 	guard(mutex)(&pg->state_lock);
 	pg->ept = rpdev->ept;
-	pmic_glink_state_notify_clients(pg);
+	if (pg->pdr_available)
+		pmic_glink_state_notify_clients(pg, pg->pdr_state);
+	else
+		pmic_glink_state_notify_clients(pg, SERVREG_SERVICE_STATE_UP);
 
 	return 0;
 }
@@ -265,11 +275,15 @@ static void pmic_glink_rpmsg_remove(struct rpmsg_device *rpdev)
 
 	guard(mutex)(&pg->state_lock);
 	pg->ept = NULL;
-	pmic_glink_state_notify_clients(pg);
+	if (pg->pdr_available)
+		pmic_glink_state_notify_clients(pg, pg->pdr_state);
+	else
+		pmic_glink_state_notify_clients(pg, SERVREG_SERVICE_STATE_DOWN);
 }
 
 static const struct rpmsg_device_id pmic_glink_rpmsg_id_match[] = {
-	{ "PMIC_RTR_ADSP_APPS" },
+	{.name = "PMIC_RTR_ADSP_APPS", .driver_data = PMIC_GLINK_PDR_AVAIL },
+	{.name = "PMIC_RTR_SOCCP_APPS", .driver_data = PMIC_GLINK_PDR_UNAVAIL },
 	{}
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] soc: qcom: pmic_glink: Add support for SOCCP remoteproc channels
  2025-09-02 21:45 [PATCH] soc: qcom: pmic_glink: Add support for SOCCP remoteproc channels Anjelique Melendez
@ 2025-09-02 23:57 ` Dmitry Baryshkov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Baryshkov @ 2025-09-02 23:57 UTC (permalink / raw)
  To: Anjelique Melendez; +Cc: andersson, konradybcio, linux-arm-msm, linux-kernel

On Tue, Sep 02, 2025 at 02:45:44PM -0700, Anjelique Melendez wrote:
> Add support for charger FW running on SOCCP by adding the
> "PMIC_RTR_SOCCP_APPS" channel name to the rpmsg_match list and
> updating notify_clients logic.
> 
> SOCCP does not have multiple PDs and hence PDR is not supported. So, if
> the subsystem comes up/down, rpmsg driver would be probed or removed.
> Use that for notifiying clients of pmic_glink for PDR events.
> 
> Signed-off-by: Anjelique Melendez <anjelique.melendez@oss.qualcomm.com>
> ---
>  drivers/soc/qcom/pmic_glink.c | 28 +++++++++++++++++++++-------
>  1 file changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/soc/qcom/pmic_glink.c b/drivers/soc/qcom/pmic_glink.c
> index c0a4be5df926..bcd17fc05544 100644
> --- a/drivers/soc/qcom/pmic_glink.c
> +++ b/drivers/soc/qcom/pmic_glink.c
> @@ -17,6 +17,11 @@
>  
>  #define PMIC_GLINK_SEND_TIMEOUT (5 * HZ)
>  
> +enum {
> +	PMIC_GLINK_PDR_UNAVAIL = 0,
> +	PMIC_GLINK_PDR_AVAIL,

No need for this, just use boolean instead.

> +};
> +
>  enum {
>  	PMIC_GLINK_CLIENT_BATT = 0,
>  	PMIC_GLINK_CLIENT_ALTMODE,
> @@ -39,6 +44,7 @@ struct pmic_glink {
>  	struct mutex state_lock;
>  	unsigned int client_state;
>  	unsigned int pdr_state;
> +	bool pdr_available;
>  
>  	/* serializing clients list updates */
>  	spinlock_t client_lock;
> @@ -203,17 +209,17 @@ static void pmic_glink_del_aux_device(struct pmic_glink *pg,
>  	auxiliary_device_uninit(aux);
>  }
>  
> -static void pmic_glink_state_notify_clients(struct pmic_glink *pg)
> +static void pmic_glink_state_notify_clients(struct pmic_glink *pg, unsigned int state)
>  {
>  	struct pmic_glink_client *client;
>  	unsigned int new_state = pg->client_state;
>  	unsigned long flags;
>  
>  	if (pg->client_state != SERVREG_SERVICE_STATE_UP) {
> -		if (pg->pdr_state == SERVREG_SERVICE_STATE_UP && pg->ept)
> +		if (state == SERVREG_SERVICE_STATE_UP && pg->ept)
>  			new_state = SERVREG_SERVICE_STATE_UP;
>  	} else {
> -		if (pg->pdr_state == SERVREG_SERVICE_STATE_DOWN || !pg->ept)
> +		if (state == SERVREG_SERVICE_STATE_DOWN || !pg->ept)
>  			new_state = SERVREG_SERVICE_STATE_DOWN;
>  	}
>  
> @@ -233,7 +239,7 @@ static void pmic_glink_pdr_callback(int state, char *svc_path, void *priv)
>  	guard(mutex)(&pg->state_lock);
>  	pg->pdr_state = state;
>  
> -	pmic_glink_state_notify_clients(pg);
> +	pmic_glink_state_notify_clients(pg, state);
>  }
>  
>  static int pmic_glink_rpmsg_probe(struct rpmsg_device *rpdev)
> @@ -246,10 +252,14 @@ static int pmic_glink_rpmsg_probe(struct rpmsg_device *rpdev)
>  		return dev_err_probe(&rpdev->dev, -ENODEV, "no pmic_glink device to attach to\n");
>  
>  	dev_set_drvdata(&rpdev->dev, pg);
> +	pg->pdr_available = rpdev->id.driver_data;
>  
>  	guard(mutex)(&pg->state_lock);
>  	pg->ept = rpdev->ept;
> -	pmic_glink_state_notify_clients(pg);
> +	if (pg->pdr_available)

I think it would be easier to do:

	if (!pg->pdr_available)
		pg->pdr_state = SERVREG_SERVICE_STATE_UP;

	pmic_glink_state_notify_clients(pg, pg->pdr_state);

> +		pmic_glink_state_notify_clients(pg, pg->pdr_state);
> +	else
> +		pmic_glink_state_notify_clients(pg, SERVREG_SERVICE_STATE_UP);
>  
>  	return 0;
>  }
> @@ -265,11 +275,15 @@ static void pmic_glink_rpmsg_remove(struct rpmsg_device *rpdev)
>  
>  	guard(mutex)(&pg->state_lock);
>  	pg->ept = NULL;
> -	pmic_glink_state_notify_clients(pg);
> +	if (pg->pdr_available)
> +		pmic_glink_state_notify_clients(pg, pg->pdr_state);
> +	else
> +		pmic_glink_state_notify_clients(pg, SERVREG_SERVICE_STATE_DOWN);

likewise

>  }
>  
>  static const struct rpmsg_device_id pmic_glink_rpmsg_id_match[] = {
> -	{ "PMIC_RTR_ADSP_APPS" },
> +	{.name = "PMIC_RTR_ADSP_APPS", .driver_data = PMIC_GLINK_PDR_AVAIL },
> +	{.name = "PMIC_RTR_SOCCP_APPS", .driver_data = PMIC_GLINK_PDR_UNAVAIL },
>  	{}
>  };
>  
> -- 
> 2.34.1
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-02 23:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-02 21:45 [PATCH] soc: qcom: pmic_glink: Add support for SOCCP remoteproc channels Anjelique Melendez
2025-09-02 23:57 ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).