diff mbox series

[12/14] power: regulator: scmi: support SCMI multi-channel

Message ID 20220513062622.155433-13-etienne.carriere@linaro.org
State New
Headers show
Series SCMI multi-channel and optee shm | expand

Commit Message

Etienne Carriere May 13, 2022, 6:26 a.m. UTC
Update SCMI regulator controller driver to get its assigned SCMI channel
during initialization. This change allows SCMI voltage domain protocol
to use a dedicated channel when defined in the DT. The reference is
saved in SCMI regulator controller driver private data.

Cc: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
---
 drivers/power/regulator/scmi_regulator.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Comments

Jaehoon Chung May 16, 2022, 11:45 p.m. UTC | #1
On 5/13/22 15:26, Etienne Carriere wrote:
> Update SCMI regulator controller driver to get its assigned SCMI channel
> during initialization. This change allows SCMI voltage domain protocol
> to use a dedicated channel when defined in the DT. The reference is
> saved in SCMI regulator controller driver private data.
> 
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>


Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

> ---
>  drivers/power/regulator/scmi_regulator.c | 20 +++++++++++++++-----
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/power/regulator/scmi_regulator.c b/drivers/power/regulator/scmi_regulator.c
> index 3325ddaf23b..e0343e913f4 100644
> --- a/drivers/power/regulator/scmi_regulator.c
> +++ b/drivers/power/regulator/scmi_regulator.c
> @@ -27,6 +27,7 @@ struct scmi_regulator_platdata {
>  
>  static int scmi_voltd_set_enable(struct udevice *dev, bool enable)
>  {
> +	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
>  	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
>  	struct scmi_voltd_config_set_in in = {
>  		.domain_id = pdata->domain_id,
> @@ -38,7 +39,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool enable)
>  					  in, out);
>  	int ret;
>  
> -	ret = devm_scmi_process_msg(dev, NULL, &msg);
> +	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg);
>  	if (ret)
>  		return ret;
>  
> @@ -51,6 +52,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool enable)
>  
>  static int scmi_voltd_get_enable(struct udevice *dev)
>  {
> +	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
>  	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
>  	struct scmi_voltd_config_get_in in = {
>  		.domain_id = pdata->domain_id,
> @@ -61,7 +63,7 @@ static int scmi_voltd_get_enable(struct udevice *dev)
>  					  in, out);
>  	int ret;
>  
> -	ret = devm_scmi_process_msg(dev, NULL, &msg);
> +	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -74,6 +76,7 @@ static int scmi_voltd_get_enable(struct udevice *dev)
>  
>  static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV)
>  {
> +	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
>  	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
>  	struct scmi_voltd_level_set_in in = {
>  		.domain_id = pdata->domain_id,
> @@ -85,7 +88,7 @@ static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV)
>  					  in, out);
>  	int ret;
>  
> -	ret = devm_scmi_process_msg(dev, NULL, &msg);
> +	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -94,6 +97,7 @@ static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV)
>  
>  static int scmi_voltd_get_voltage_level(struct udevice *dev)
>  {
> +	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
>  	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
>  	struct scmi_voltd_level_get_in in = {
>  		.domain_id = pdata->domain_id,
> @@ -104,7 +108,7 @@ static int scmi_voltd_get_voltage_level(struct udevice *dev)
>  					  in, out);
>  	int ret;
>  
> -	ret = devm_scmi_process_msg(dev, NULL, &msg);
> +	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -131,6 +135,7 @@ static int scmi_regulator_of_to_plat(struct udevice *dev)
>  
>  static int scmi_regulator_probe(struct udevice *dev)
>  {
> +	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
>  	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
>  	struct scmi_voltd_attr_in in = { 0 };
>  	struct scmi_voltd_attr_out out = { 0 };
> @@ -144,10 +149,14 @@ static int scmi_regulator_probe(struct udevice *dev)
>  	};
>  	int ret;
>  
> +	ret = devm_scmi_of_get_channel(dev->parent, scmi_channel_ref);
> +	if (ret)
> +		return ret;
> +
>  	/* Check voltage domain is known from SCMI server */
>  	in.domain_id = pdata->domain_id;
>  
> -	ret = devm_scmi_process_msg(dev, NULL, &scmi_msg);
> +	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &scmi_msg);
>  	if (ret) {
>  		dev_err(dev, "Failed to query voltage domain %u: %d\n",
>  			pdata->domain_id, ret);
> @@ -171,6 +180,7 @@ U_BOOT_DRIVER(scmi_regulator) = {
>  	.probe = scmi_regulator_probe,
>  	.of_to_plat = scmi_regulator_of_to_plat,
>  	.plat_auto = sizeof(struct scmi_regulator_platdata),
> +	.priv_auto = sizeof(struct scmi_channel *),
>  };
>  
>  static int scmi_regulator_bind(struct udevice *dev)
diff mbox series

Patch

diff --git a/drivers/power/regulator/scmi_regulator.c b/drivers/power/regulator/scmi_regulator.c
index 3325ddaf23b..e0343e913f4 100644
--- a/drivers/power/regulator/scmi_regulator.c
+++ b/drivers/power/regulator/scmi_regulator.c
@@ -27,6 +27,7 @@  struct scmi_regulator_platdata {
 
 static int scmi_voltd_set_enable(struct udevice *dev, bool enable)
 {
+	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
 	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
 	struct scmi_voltd_config_set_in in = {
 		.domain_id = pdata->domain_id,
@@ -38,7 +39,7 @@  static int scmi_voltd_set_enable(struct udevice *dev, bool enable)
 					  in, out);
 	int ret;
 
-	ret = devm_scmi_process_msg(dev, NULL, &msg);
+	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg);
 	if (ret)
 		return ret;
 
@@ -51,6 +52,7 @@  static int scmi_voltd_set_enable(struct udevice *dev, bool enable)
 
 static int scmi_voltd_get_enable(struct udevice *dev)
 {
+	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
 	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
 	struct scmi_voltd_config_get_in in = {
 		.domain_id = pdata->domain_id,
@@ -61,7 +63,7 @@  static int scmi_voltd_get_enable(struct udevice *dev)
 					  in, out);
 	int ret;
 
-	ret = devm_scmi_process_msg(dev, NULL, &msg);
+	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg);
 	if (ret < 0)
 		return ret;
 
@@ -74,6 +76,7 @@  static int scmi_voltd_get_enable(struct udevice *dev)
 
 static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV)
 {
+	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
 	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
 	struct scmi_voltd_level_set_in in = {
 		.domain_id = pdata->domain_id,
@@ -85,7 +88,7 @@  static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV)
 					  in, out);
 	int ret;
 
-	ret = devm_scmi_process_msg(dev, NULL, &msg);
+	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg);
 	if (ret < 0)
 		return ret;
 
@@ -94,6 +97,7 @@  static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV)
 
 static int scmi_voltd_get_voltage_level(struct udevice *dev)
 {
+	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
 	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
 	struct scmi_voltd_level_get_in in = {
 		.domain_id = pdata->domain_id,
@@ -104,7 +108,7 @@  static int scmi_voltd_get_voltage_level(struct udevice *dev)
 					  in, out);
 	int ret;
 
-	ret = devm_scmi_process_msg(dev, NULL, &msg);
+	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &msg);
 	if (ret < 0)
 		return ret;
 
@@ -131,6 +135,7 @@  static int scmi_regulator_of_to_plat(struct udevice *dev)
 
 static int scmi_regulator_probe(struct udevice *dev)
 {
+	struct scmi_channel **scmi_channel_ref = dev_get_priv(dev);
 	struct scmi_regulator_platdata *pdata = dev_get_plat(dev);
 	struct scmi_voltd_attr_in in = { 0 };
 	struct scmi_voltd_attr_out out = { 0 };
@@ -144,10 +149,14 @@  static int scmi_regulator_probe(struct udevice *dev)
 	};
 	int ret;
 
+	ret = devm_scmi_of_get_channel(dev->parent, scmi_channel_ref);
+	if (ret)
+		return ret;
+
 	/* Check voltage domain is known from SCMI server */
 	in.domain_id = pdata->domain_id;
 
-	ret = devm_scmi_process_msg(dev, NULL, &scmi_msg);
+	ret = devm_scmi_process_msg(dev, *scmi_channel_ref, &scmi_msg);
 	if (ret) {
 		dev_err(dev, "Failed to query voltage domain %u: %d\n",
 			pdata->domain_id, ret);
@@ -171,6 +180,7 @@  U_BOOT_DRIVER(scmi_regulator) = {
 	.probe = scmi_regulator_probe,
 	.of_to_plat = scmi_regulator_of_to_plat,
 	.plat_auto = sizeof(struct scmi_regulator_platdata),
+	.priv_auto = sizeof(struct scmi_channel *),
 };
 
 static int scmi_regulator_bind(struct udevice *dev)