All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver: mfd: admit rk805 driver registration without interrupt support
@ 2023-05-25  7:00 ` Milo Spadacini
  0 siblings, 0 replies; 6+ messages in thread
From: Milo Spadacini @ 2023-05-25  7:00 UTC (permalink / raw)
  To: heiko, lee, linux-rockchip, linux-kernel; +Cc: Milo Spadacini

rk805 use interrupt only for "rk808-rtc" and "rk805-pwrkey" drivers.
On custom board these drivers could be not used and the irq gpio
could be not connected.
Force the usage of a not used gpio, that could be floating, could cause
spurious interrupt.

Signed-off-by: Milo Spadacini <milo.spadacini@gmail.com>
---
 drivers/mfd/rk808.c | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index e00da7c7e3b1..ae33be90b312 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -643,6 +643,7 @@ MODULE_DEVICE_TABLE(of, rk808_of_match);
 static int rk808_probe(struct i2c_client *client,
 		       const struct i2c_device_id *id)
 {
+	struct irq_domain * rk808_irq_domain = NULL;
 	struct device_node *np = client->dev.of_node;
 	struct rk808 *rk808;
 	const struct rk808_reg_data *pre_init_reg;
@@ -692,7 +693,11 @@ static int rk808_probe(struct i2c_client *client,
 		pre_init_reg = rk805_pre_init_reg;
 		nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg);
 		cells = rk805s;
-		nr_cells = ARRAY_SIZE(rk805s);
+		if (client->irq)
+			nr_cells = ARRAY_SIZE(rk805s);
+		else
+			nr_cells = ARRAY_SIZE(rk805s) - 2;
+
 		break;
 	case RK808_ID:
 		rk808->regmap_cfg = &rk808_regmap_config;
@@ -734,19 +739,28 @@ static int rk808_probe(struct i2c_client *client,
 		return PTR_ERR(rk808->regmap);
 	}
 
-	if (!client->irq) {
+	if (client->irq) {
+
+		ret = regmap_add_irq_chip(rk808->regmap, client->irq,
+					  IRQF_ONESHOT, -1,
+					  rk808->regmap_irq_chip, &rk808->irq_data);
+		if (ret) {
+			dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
+			return ret;
+		}
+
+		rk808_irq_domain = regmap_irq_get_domain(rk808->irq_data);
+	}
+	else if (rk808->variant == RK805_ID)
+	{
+		dev_warn(&client->dev, "Skip interrupt support, no core IRQ\n");
+	}
+	else
+	{
 		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
 		return -EINVAL;
 	}
 
-	ret = regmap_add_irq_chip(rk808->regmap, client->irq,
-				  IRQF_ONESHOT, -1,
-				  rk808->regmap_irq_chip, &rk808->irq_data);
-	if (ret) {
-		dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
-		return ret;
-	}
-
 	for (i = 0; i < nr_pre_init_regs; i++) {
 		ret = regmap_update_bits(rk808->regmap,
 					pre_init_reg[i].addr,
@@ -762,7 +776,7 @@ static int rk808_probe(struct i2c_client *client,
 
 	ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
 			      cells, nr_cells, NULL, 0,
-			      regmap_irq_get_domain(rk808->irq_data));
+			      rk808_irq_domain);
 	if (ret) {
 		dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
 		goto err_irq;
@@ -796,7 +810,8 @@ static void rk808_remove(struct i2c_client *client)
 {
 	struct rk808 *rk808 = i2c_get_clientdata(client);
 
-	regmap_del_irq_chip(client->irq, rk808->irq_data);
+	if (client->irq)
+		regmap_del_irq_chip(client->irq, rk808->irq_data);
 
 	/**
 	 * pm_power_off may points to a function from another module.
-- 
2.34.1


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

* [PATCH] driver: mfd: admit rk805 driver registration without interrupt support
@ 2023-05-25  7:00 ` Milo Spadacini
  0 siblings, 0 replies; 6+ messages in thread
From: Milo Spadacini @ 2023-05-25  7:00 UTC (permalink / raw)
  To: heiko, lee, linux-rockchip, linux-kernel; +Cc: Milo Spadacini

rk805 use interrupt only for "rk808-rtc" and "rk805-pwrkey" drivers.
On custom board these drivers could be not used and the irq gpio
could be not connected.
Force the usage of a not used gpio, that could be floating, could cause
spurious interrupt.

Signed-off-by: Milo Spadacini <milo.spadacini@gmail.com>
---
 drivers/mfd/rk808.c | 39 +++++++++++++++++++++++++++------------
 1 file changed, 27 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
index e00da7c7e3b1..ae33be90b312 100644
--- a/drivers/mfd/rk808.c
+++ b/drivers/mfd/rk808.c
@@ -643,6 +643,7 @@ MODULE_DEVICE_TABLE(of, rk808_of_match);
 static int rk808_probe(struct i2c_client *client,
 		       const struct i2c_device_id *id)
 {
+	struct irq_domain * rk808_irq_domain = NULL;
 	struct device_node *np = client->dev.of_node;
 	struct rk808 *rk808;
 	const struct rk808_reg_data *pre_init_reg;
@@ -692,7 +693,11 @@ static int rk808_probe(struct i2c_client *client,
 		pre_init_reg = rk805_pre_init_reg;
 		nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg);
 		cells = rk805s;
-		nr_cells = ARRAY_SIZE(rk805s);
+		if (client->irq)
+			nr_cells = ARRAY_SIZE(rk805s);
+		else
+			nr_cells = ARRAY_SIZE(rk805s) - 2;
+
 		break;
 	case RK808_ID:
 		rk808->regmap_cfg = &rk808_regmap_config;
@@ -734,19 +739,28 @@ static int rk808_probe(struct i2c_client *client,
 		return PTR_ERR(rk808->regmap);
 	}
 
-	if (!client->irq) {
+	if (client->irq) {
+
+		ret = regmap_add_irq_chip(rk808->regmap, client->irq,
+					  IRQF_ONESHOT, -1,
+					  rk808->regmap_irq_chip, &rk808->irq_data);
+		if (ret) {
+			dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
+			return ret;
+		}
+
+		rk808_irq_domain = regmap_irq_get_domain(rk808->irq_data);
+	}
+	else if (rk808->variant == RK805_ID)
+	{
+		dev_warn(&client->dev, "Skip interrupt support, no core IRQ\n");
+	}
+	else
+	{
 		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
 		return -EINVAL;
 	}
 
-	ret = regmap_add_irq_chip(rk808->regmap, client->irq,
-				  IRQF_ONESHOT, -1,
-				  rk808->regmap_irq_chip, &rk808->irq_data);
-	if (ret) {
-		dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
-		return ret;
-	}
-
 	for (i = 0; i < nr_pre_init_regs; i++) {
 		ret = regmap_update_bits(rk808->regmap,
 					pre_init_reg[i].addr,
@@ -762,7 +776,7 @@ static int rk808_probe(struct i2c_client *client,
 
 	ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
 			      cells, nr_cells, NULL, 0,
-			      regmap_irq_get_domain(rk808->irq_data));
+			      rk808_irq_domain);
 	if (ret) {
 		dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
 		goto err_irq;
@@ -796,7 +810,8 @@ static void rk808_remove(struct i2c_client *client)
 {
 	struct rk808 *rk808 = i2c_get_clientdata(client);
 
-	regmap_del_irq_chip(client->irq, rk808->irq_data);
+	if (client->irq)
+		regmap_del_irq_chip(client->irq, rk808->irq_data);
 
 	/**
 	 * pm_power_off may points to a function from another module.
-- 
2.34.1


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH] driver: mfd: admit rk805 driver registration without interrupt support
  2023-05-25  7:00 ` Milo Spadacini
@ 2023-05-25 11:00   ` Lee Jones
  -1 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2023-05-25 11:00 UTC (permalink / raw)
  To: Milo Spadacini; +Cc: heiko, linux-rockchip, linux-kernel

Do you mean "Omit"?

On Thu, 25 May 2023, Milo Spadacini wrote:

> rk805 use interrupt only for "rk808-rtc" and "rk805-pwrkey" drivers.

RK805 only uses interrupts for ...

> On custom board these drivers could be not used and the irq gpio

"boards"
"IRQ GPIQs"

> could be not connected.

"are not connected"

> Force the usage of a not used gpio, that could be floating, could cause
> spurious interrupt.

Please rephrase this.  I can't quite make it out to make suggestions.

> Signed-off-by: Milo Spadacini <milo.spadacini@gmail.com>
> ---
>  drivers/mfd/rk808.c | 39 +++++++++++++++++++++++++++------------
>  1 file changed, 27 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index e00da7c7e3b1..ae33be90b312 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -643,6 +643,7 @@ MODULE_DEVICE_TABLE(of, rk808_of_match);
>  static int rk808_probe(struct i2c_client *client,
>  		       const struct i2c_device_id *id)
>  {
> +	struct irq_domain * rk808_irq_domain = NULL;

Drop the ' ' after the '*'.

>  	struct device_node *np = client->dev.of_node;
>  	struct rk808 *rk808;
>  	const struct rk808_reg_data *pre_init_reg;
> @@ -692,7 +693,11 @@ static int rk808_probe(struct i2c_client *client,
>  		pre_init_reg = rk805_pre_init_reg;
>  		nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg);
>  		cells = rk805s;
> -		nr_cells = ARRAY_SIZE(rk805s);
> +		if (client->irq)
> +			nr_cells = ARRAY_SIZE(rk805s);
> +		else
> +			nr_cells = ARRAY_SIZE(rk805s) - 2;

What's 2?  Please define it.

Does this rely on the ordering of rk805s?  Seems fragile.

> +
>  		break;
>  	case RK808_ID:
>  		rk808->regmap_cfg = &rk808_regmap_config;
> @@ -734,19 +739,28 @@ static int rk808_probe(struct i2c_client *client,
>  		return PTR_ERR(rk808->regmap);
>  	}
>  
> -	if (!client->irq) {
> +	if (client->irq) {
> +
> +		ret = regmap_add_irq_chip(rk808->regmap, client->irq,
> +					  IRQF_ONESHOT, -1,
> +					  rk808->regmap_irq_chip, &rk808->irq_data);
> +		if (ret) {
> +			dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
> +			return ret;
> +		}
> +
> +		rk808_irq_domain = regmap_irq_get_domain(rk808->irq_data);
> +	}
> +	else if (rk808->variant == RK805_ID)

else goes on the line above.
> +	{
> +		dev_warn(&client->dev, "Skip interrupt support, no core IRQ\n");
> +	}
> +	else
> +	{
>  		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
>  		return -EINVAL;
>  	}
>  
> -	ret = regmap_add_irq_chip(rk808->regmap, client->irq,
> -				  IRQF_ONESHOT, -1,
> -				  rk808->regmap_irq_chip, &rk808->irq_data);
> -	if (ret) {
> -		dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
> -		return ret;
> -	}
> -
>  	for (i = 0; i < nr_pre_init_regs; i++) {
>  		ret = regmap_update_bits(rk808->regmap,
>  					pre_init_reg[i].addr,
> @@ -762,7 +776,7 @@ static int rk808_probe(struct i2c_client *client,
>  
>  	ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
>  			      cells, nr_cells, NULL, 0,
> -			      regmap_irq_get_domain(rk808->irq_data));
> +			      rk808_irq_domain);
>  	if (ret) {
>  		dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
>  		goto err_irq;
> @@ -796,7 +810,8 @@ static void rk808_remove(struct i2c_client *client)
>  {
>  	struct rk808 *rk808 = i2c_get_clientdata(client);
>  
> -	regmap_del_irq_chip(client->irq, rk808->irq_data);
> +	if (client->irq)
> +		regmap_del_irq_chip(client->irq, rk808->irq_data);
>  
>  	/**
>  	 * pm_power_off may points to a function from another module.
> -- 
> 2.34.1
> 

-- 
Lee Jones [李琼斯]

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH] driver: mfd: admit rk805 driver registration without interrupt support
@ 2023-05-25 11:00   ` Lee Jones
  0 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2023-05-25 11:00 UTC (permalink / raw)
  To: Milo Spadacini; +Cc: heiko, linux-rockchip, linux-kernel

Do you mean "Omit"?

On Thu, 25 May 2023, Milo Spadacini wrote:

> rk805 use interrupt only for "rk808-rtc" and "rk805-pwrkey" drivers.

RK805 only uses interrupts for ...

> On custom board these drivers could be not used and the irq gpio

"boards"
"IRQ GPIQs"

> could be not connected.

"are not connected"

> Force the usage of a not used gpio, that could be floating, could cause
> spurious interrupt.

Please rephrase this.  I can't quite make it out to make suggestions.

> Signed-off-by: Milo Spadacini <milo.spadacini@gmail.com>
> ---
>  drivers/mfd/rk808.c | 39 +++++++++++++++++++++++++++------------
>  1 file changed, 27 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/mfd/rk808.c b/drivers/mfd/rk808.c
> index e00da7c7e3b1..ae33be90b312 100644
> --- a/drivers/mfd/rk808.c
> +++ b/drivers/mfd/rk808.c
> @@ -643,6 +643,7 @@ MODULE_DEVICE_TABLE(of, rk808_of_match);
>  static int rk808_probe(struct i2c_client *client,
>  		       const struct i2c_device_id *id)
>  {
> +	struct irq_domain * rk808_irq_domain = NULL;

Drop the ' ' after the '*'.

>  	struct device_node *np = client->dev.of_node;
>  	struct rk808 *rk808;
>  	const struct rk808_reg_data *pre_init_reg;
> @@ -692,7 +693,11 @@ static int rk808_probe(struct i2c_client *client,
>  		pre_init_reg = rk805_pre_init_reg;
>  		nr_pre_init_regs = ARRAY_SIZE(rk805_pre_init_reg);
>  		cells = rk805s;
> -		nr_cells = ARRAY_SIZE(rk805s);
> +		if (client->irq)
> +			nr_cells = ARRAY_SIZE(rk805s);
> +		else
> +			nr_cells = ARRAY_SIZE(rk805s) - 2;

What's 2?  Please define it.

Does this rely on the ordering of rk805s?  Seems fragile.

> +
>  		break;
>  	case RK808_ID:
>  		rk808->regmap_cfg = &rk808_regmap_config;
> @@ -734,19 +739,28 @@ static int rk808_probe(struct i2c_client *client,
>  		return PTR_ERR(rk808->regmap);
>  	}
>  
> -	if (!client->irq) {
> +	if (client->irq) {
> +
> +		ret = regmap_add_irq_chip(rk808->regmap, client->irq,
> +					  IRQF_ONESHOT, -1,
> +					  rk808->regmap_irq_chip, &rk808->irq_data);
> +		if (ret) {
> +			dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
> +			return ret;
> +		}
> +
> +		rk808_irq_domain = regmap_irq_get_domain(rk808->irq_data);
> +	}
> +	else if (rk808->variant == RK805_ID)

else goes on the line above.
> +	{
> +		dev_warn(&client->dev, "Skip interrupt support, no core IRQ\n");
> +	}
> +	else
> +	{
>  		dev_err(&client->dev, "No interrupt support, no core IRQ\n");
>  		return -EINVAL;
>  	}
>  
> -	ret = regmap_add_irq_chip(rk808->regmap, client->irq,
> -				  IRQF_ONESHOT, -1,
> -				  rk808->regmap_irq_chip, &rk808->irq_data);
> -	if (ret) {
> -		dev_err(&client->dev, "Failed to add irq_chip %d\n", ret);
> -		return ret;
> -	}
> -
>  	for (i = 0; i < nr_pre_init_regs; i++) {
>  		ret = regmap_update_bits(rk808->regmap,
>  					pre_init_reg[i].addr,
> @@ -762,7 +776,7 @@ static int rk808_probe(struct i2c_client *client,
>  
>  	ret = devm_mfd_add_devices(&client->dev, PLATFORM_DEVID_NONE,
>  			      cells, nr_cells, NULL, 0,
> -			      regmap_irq_get_domain(rk808->irq_data));
> +			      rk808_irq_domain);
>  	if (ret) {
>  		dev_err(&client->dev, "failed to add MFD devices %d\n", ret);
>  		goto err_irq;
> @@ -796,7 +810,8 @@ static void rk808_remove(struct i2c_client *client)
>  {
>  	struct rk808 *rk808 = i2c_get_clientdata(client);
>  
> -	regmap_del_irq_chip(client->irq, rk808->irq_data);
> +	if (client->irq)
> +		regmap_del_irq_chip(client->irq, rk808->irq_data);
>  
>  	/**
>  	 * pm_power_off may points to a function from another module.
> -- 
> 2.34.1
> 

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH] driver: mfd: admit rk805 driver registration without interrupt support
  2023-05-25  7:00 ` Milo Spadacini
@ 2023-05-26  0:00   ` Sebastian Reichel
  -1 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2023-05-26  0:00 UTC (permalink / raw)
  To: Milo Spadacini; +Cc: heiko, lee, linux-rockchip, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 637 bytes --]

Hi,

On Thu, May 25, 2023 at 09:00:11AM +0200, Milo Spadacini wrote:
> rk805 use interrupt only for "rk808-rtc" and "rk805-pwrkey" drivers.
> On custom board these drivers could be not used and the irq gpio
> could be not connected.
> Force the usage of a not used gpio, that could be floating, could cause
> spurious interrupt.
> 
> Signed-off-by: Milo Spadacini <milo.spadacini@gmail.com>
> ---
>  drivers/mfd/rk808.c | 39 +++++++++++++++++++++++++++------------

This will not apply to for-mfd-next, since the file has been renamed
to rk8xx-core.c in my patchset adding rk806/spi support.

Greetings,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] driver: mfd: admit rk805 driver registration without interrupt support
@ 2023-05-26  0:00   ` Sebastian Reichel
  0 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2023-05-26  0:00 UTC (permalink / raw)
  To: Milo Spadacini; +Cc: heiko, lee, linux-rockchip, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 637 bytes --]

Hi,

On Thu, May 25, 2023 at 09:00:11AM +0200, Milo Spadacini wrote:
> rk805 use interrupt only for "rk808-rtc" and "rk805-pwrkey" drivers.
> On custom board these drivers could be not used and the irq gpio
> could be not connected.
> Force the usage of a not used gpio, that could be floating, could cause
> spurious interrupt.
> 
> Signed-off-by: Milo Spadacini <milo.spadacini@gmail.com>
> ---
>  drivers/mfd/rk808.c | 39 +++++++++++++++++++++++++++------------

This will not apply to for-mfd-next, since the file has been renamed
to rk8xx-core.c in my patchset adding rk806/spi support.

Greetings,

-- Sebastian

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

end of thread, other threads:[~2023-05-26  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25  7:00 [PATCH] driver: mfd: admit rk805 driver registration without interrupt support Milo Spadacini
2023-05-25  7:00 ` Milo Spadacini
2023-05-25 11:00 ` Lee Jones
2023-05-25 11:00   ` Lee Jones
2023-05-26  0:00 ` Sebastian Reichel
2023-05-26  0:00   ` Sebastian Reichel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.