devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add support for safeboot pin to UBlox GNSS driver
@ 2025-09-11 12:58 Alejandro Enrique via B4 Relay
  2025-09-11 12:58 ` [PATCH v3 1/2] dt-bindings: gnss: u-blox: add "safeboot-gpios" binding Alejandro Enrique via B4 Relay
  2025-09-11 12:58 ` [PATCH v3 2/2] gnss: ubx: add support for the safeboot gpio Alejandro Enrique via B4 Relay
  0 siblings, 2 replies; 7+ messages in thread
From: Alejandro Enrique via B4 Relay @ 2025-09-11 12:58 UTC (permalink / raw)
  To: Johan Hovold, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: devicetree, linux-kernel, Alejandro Enrique, Krzysztof Kozlowski

U-Blox 8/M8 and M9 chips have a pin to start it in safeboot mode, to
be used to recover from situations where the flash content has become
corrupted and needs to be restored. If this pin is asserted at power
up or reset, the receiver starts in safeboot mode and GNSS operation
is disabled.

If this pin is wired to a GPIO in the host it should be deasserted
before powering up or resetting the GNSS.

This series adds support for handling the safeboot pin when probing
the driver.

Signed-off-by: Alejandro Enrique <alejandroe1@geotab.com>
---
Changes in v3:
- Rebase on top of latest gnss-linus tree
- Link to v2: https://lore.kernel.org/r/20250522-ubx-safeboot-v2-0-08c22378b8c9@geotab.com

Changes in v2:
- Add if/then to dt binding to disallow safeboot-gpios property for neo-6m
- Link to v1: https://lore.kernel.org/r/20250514-ubx-safeboot-v1-0-1ae771335356@geotab.com

---
Alejandro Enrique (2):
      dt-bindings: gnss: u-blox: add "safeboot-gpios" binding
      gnss: ubx: add support for the safeboot gpio

 .../devicetree/bindings/gnss/u-blox,neo-6m.yaml      | 20 ++++++++++++++++----
 drivers/gnss/ubx.c                                   |  8 ++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)
---
base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
change-id: 20250514-ubx-safeboot-3758f22225ec

Best regards,
-- 
Alejandro Enrique <alejandroe1@geotab.com>



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

* [PATCH v3 1/2] dt-bindings: gnss: u-blox: add "safeboot-gpios" binding
  2025-09-11 12:58 [PATCH v3 0/2] Add support for safeboot pin to UBlox GNSS driver Alejandro Enrique via B4 Relay
@ 2025-09-11 12:58 ` Alejandro Enrique via B4 Relay
  2025-11-14 14:42   ` Johan Hovold
  2025-09-11 12:58 ` [PATCH v3 2/2] gnss: ubx: add support for the safeboot gpio Alejandro Enrique via B4 Relay
  1 sibling, 1 reply; 7+ messages in thread
From: Alejandro Enrique via B4 Relay @ 2025-09-11 12:58 UTC (permalink / raw)
  To: Johan Hovold, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: devicetree, linux-kernel, Alejandro Enrique, Krzysztof Kozlowski

From: Alejandro Enrique <alejandroe1@geotab.com>

U-Blox 8/M8/M9 chip have a pin to start it in safeboot mode, to be
used to recover from situations where the flash content has become
corrupted and needs to be restored. Introduce a binding to support
this safeboot pin.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Alejandro Enrique <alejandroe1@geotab.com>
---
 .../devicetree/bindings/gnss/u-blox,neo-6m.yaml      | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml b/Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml
index c0c2bfaa606fb01f7efee1ce7e5d30b1640783f3..44c9421cbe0b377661ef99a9e8c0dcebf3f9c894 100644
--- a/Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml
+++ b/Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml
@@ -6,10 +6,6 @@ $schema: http://devicetree.org/meta-schemas/core.yaml#
 
 title: U-blox GNSS Receiver
 
-allOf:
-  - $ref: gnss-common.yaml#
-  - $ref: /schemas/serial/serial-peripheral-props.yaml#
-
 maintainers:
   - Johan Hovold <johan@kernel.org>
 
@@ -36,6 +32,9 @@ properties:
   reset-gpios:
     maxItems: 1
 
+  safeboot-gpios:
+    maxItems: 1
+
   vcc-supply:
     description: >
       Main voltage regulator
@@ -53,6 +52,18 @@ required:
   - compatible
   - vcc-supply
 
+allOf:
+  - $ref: gnss-common.yaml#
+  - $ref: /schemas/serial/serial-peripheral-props.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: u-blox,neo-6m
+    then:
+      properties:
+        safeboot-gpios: false
+
 unevaluatedProperties: false
 
 examples:
@@ -65,5 +76,6 @@ examples:
             v-bckp-supply = <&gnss_v_bckp_reg>;
             vcc-supply = <&gnss_vcc_reg>;
             reset-gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+            safeboot-gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
         };
     };

-- 
2.34.1



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

* [PATCH v3 2/2] gnss: ubx: add support for the safeboot gpio
  2025-09-11 12:58 [PATCH v3 0/2] Add support for safeboot pin to UBlox GNSS driver Alejandro Enrique via B4 Relay
  2025-09-11 12:58 ` [PATCH v3 1/2] dt-bindings: gnss: u-blox: add "safeboot-gpios" binding Alejandro Enrique via B4 Relay
@ 2025-09-11 12:58 ` Alejandro Enrique via B4 Relay
  2025-11-14 14:59   ` Johan Hovold
  1 sibling, 1 reply; 7+ messages in thread
From: Alejandro Enrique via B4 Relay @ 2025-09-11 12:58 UTC (permalink / raw)
  To: Johan Hovold, Rob Herring, Krzysztof Kozlowski, Conor Dooley
  Cc: devicetree, linux-kernel, Alejandro Enrique, Krzysztof Kozlowski

From: Alejandro Enrique <alejandroe1@geotab.com>

U-Blox 8/M8/M9 chip have a pin to start it in safeboot mode, to be
used to recover from situations where the flash content has become
corrupted and needs to be restored. If this pin is asserted at power
up/reset, the receiver starts in safeboot mode and GNSS operation is
disabled.

Deassert the safeboot pin when probing this driver.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Alejandro Enrique <alejandroe1@geotab.com>
---
 drivers/gnss/ubx.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gnss/ubx.c b/drivers/gnss/ubx.c
index 92402f6082c415c7b9051338eef5406b09e09455..1d6acace84f76f8d5d2eacdbbf5ab7a934b33486 100644
--- a/drivers/gnss/ubx.c
+++ b/drivers/gnss/ubx.c
@@ -67,6 +67,7 @@ static int ubx_probe(struct serdev_device *serdev)
 {
 	struct gnss_serial *gserial;
 	struct gpio_desc *reset;
+	struct gpio_desc *safeboot;
 	struct ubx_data *data;
 	int ret;
 
@@ -82,6 +83,13 @@ static int ubx_probe(struct serdev_device *serdev)
 
 	data = gnss_serial_get_drvdata(gserial);
 
+	/* Deassert safeboot */
+	safeboot = devm_gpiod_get_optional(&serdev->dev, "safeboot", GPIOD_OUT_LOW);
+	if (IS_ERR(safeboot)) {
+		ret = PTR_ERR(safeboot);
+		goto err_free_gserial;
+	}
+
 	data->vcc = devm_regulator_get(&serdev->dev, "vcc");
 	if (IS_ERR(data->vcc)) {
 		ret = PTR_ERR(data->vcc);

-- 
2.34.1



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

* Re: [PATCH v3 1/2] dt-bindings: gnss: u-blox: add "safeboot-gpios" binding
  2025-09-11 12:58 ` [PATCH v3 1/2] dt-bindings: gnss: u-blox: add "safeboot-gpios" binding Alejandro Enrique via B4 Relay
@ 2025-11-14 14:42   ` Johan Hovold
  0 siblings, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2025-11-14 14:42 UTC (permalink / raw)
  To: alejandroe1
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	linux-kernel, Krzysztof Kozlowski

On Thu, Sep 11, 2025 at 02:58:28PM +0200, Alejandro Enrique via B4 Relay wrote:
> From: Alejandro Enrique <alejandroe1@geotab.com>
> 
> U-Blox 8/M8/M9 chip have a pin to start it in safeboot mode, to be
> used to recover from situations where the flash content has become
> corrupted and needs to be restored. Introduce a binding to support
> this safeboot pin.
> 
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Signed-off-by: Alejandro Enrique <alejandroe1@geotab.com>
 
> +allOf:
> +  - $ref: gnss-common.yaml#
> +  - $ref: /schemas/serial/serial-peripheral-props.yaml#
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: u-blox,neo-6m
> +    then:
> +      properties:
> +        safeboot-gpios: false
> +

I don't think it's worth adding conditionals like this for an optional
gpio as it just makes the binding harder to read for no good reason (cf.
a dt checker can't verify that you're not using the wrong host pin in
your identifier either).

So I used your v1 without this (and dropped Krzysztof's tag).

>  unevaluatedProperties: false
>  
>  examples:
> @@ -65,5 +76,6 @@ examples:
>              v-bckp-supply = <&gnss_v_bckp_reg>;
>              vcc-supply = <&gnss_vcc_reg>;
>              reset-gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
> +            safeboot-gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
>          };
>      };

Johan

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

* Re: [PATCH v3 2/2] gnss: ubx: add support for the safeboot gpio
  2025-09-11 12:58 ` [PATCH v3 2/2] gnss: ubx: add support for the safeboot gpio Alejandro Enrique via B4 Relay
@ 2025-11-14 14:59   ` Johan Hovold
  2025-11-17 16:33     ` Alejandro Enrique
  2025-11-20 15:51     ` Johan Hovold
  0 siblings, 2 replies; 7+ messages in thread
From: Johan Hovold @ 2025-11-14 14:59 UTC (permalink / raw)
  To: alejandroe1
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	linux-kernel, Krzysztof Kozlowski

On Thu, Sep 11, 2025 at 02:58:29PM +0200, Alejandro Enrique via B4 Relay wrote:
> From: Alejandro Enrique <alejandroe1@geotab.com>
> 
> U-Blox 8/M8/M9 chip have a pin to start it in safeboot mode, to be
> used to recover from situations where the flash content has become
> corrupted and needs to be restored. If this pin is asserted at power
> up/reset, the receiver starts in safeboot mode and GNSS operation is
> disabled.
> 
> Deassert the safeboot pin when probing this driver.
> 
> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Signed-off-by: Alejandro Enrique <alejandroe1@geotab.com>

Sorry about the late feedback on this. I had to think about how best to
handle this, given that we don't have an interface yet to actually
assert these pins.

I guess we can go ahead and request them at probe as you're doing here
and add an interface for controlling them later if needed (instead of
not claiming them and allowing emergency control through gpiolib).

> @@ -82,6 +83,13 @@ static int ubx_probe(struct serdev_device *serdev)
>  
>  	data = gnss_serial_get_drvdata(gserial);
>  
> +	/* Deassert safeboot */
> +	safeboot = devm_gpiod_get_optional(&serdev->dev, "safeboot", GPIOD_OUT_LOW);
> +	if (IS_ERR(safeboot)) {
> +		ret = PTR_ERR(safeboot);
> +		goto err_free_gserial;
> +	}
> +
>  	data->vcc = devm_regulator_get(&serdev->dev, "vcc");

Note that the driver is not enabling the supply until open() so I moved
the deassert to after the supplies have been requested (but before reset
is deasserted).

Note however that both the RESET_N and SAFEBOOT_N pins should be
declared as open-drain to avoid driving them while the main supply is
off.

I added a comment about this to the commit message about this when
applying and will send a follow-on patch to update the binding example.

>  	if (IS_ERR(data->vcc)) {
>  		ret = PTR_ERR(data->vcc);

Johan

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

* Re: [PATCH v3 2/2] gnss: ubx: add support for the safeboot gpio
  2025-11-14 14:59   ` Johan Hovold
@ 2025-11-17 16:33     ` Alejandro Enrique
  2025-11-20 15:51     ` Johan Hovold
  1 sibling, 0 replies; 7+ messages in thread
From: Alejandro Enrique @ 2025-11-17 16:33 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	linux-kernel, Krzysztof Kozlowski

On Fri, Nov 14, 2025 at 3:59 PM Johan Hovold <johan@kernel.org> wrote:
>
> On Thu, Sep 11, 2025 at 02:58:29PM +0200, Alejandro Enrique via B4 Relay wrote:
> > From: Alejandro Enrique <alejandroe1@geotab.com>
> >
> > U-Blox 8/M8/M9 chip have a pin to start it in safeboot mode, to be
> > used to recover from situations where the flash content has become
> > corrupted and needs to be restored. If this pin is asserted at power
> > up/reset, the receiver starts in safeboot mode and GNSS operation is
> > disabled.
> >
> > Deassert the safeboot pin when probing this driver.
> >
> > Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > Signed-off-by: Alejandro Enrique <alejandroe1@geotab.com>
>
> Sorry about the late feedback on this. I had to think about how best to
> handle this, given that we don't have an interface yet to actually
> assert these pins.
>
> I guess we can go ahead and request them at probe as you're doing here
> and add an interface for controlling them later if needed (instead of
> not claiming them and allowing emergency control through gpiolib).
>
> > @@ -82,6 +83,13 @@ static int ubx_probe(struct serdev_device *serdev)
> >
> >       data = gnss_serial_get_drvdata(gserial);
> >
> > +     /* Deassert safeboot */
> > +     safeboot = devm_gpiod_get_optional(&serdev->dev, "safeboot", GPIOD_OUT_LOW);
> > +     if (IS_ERR(safeboot)) {
> > +             ret = PTR_ERR(safeboot);
> > +             goto err_free_gserial;
> > +     }
> > +
> >       data->vcc = devm_regulator_get(&serdev->dev, "vcc");
>
> Note that the driver is not enabling the supply until open() so I moved
> the deassert to after the supplies have been requested (but before reset
> is deasserted).
>
> Note however that both the RESET_N and SAFEBOOT_N pins should be
> declared as open-drain to avoid driving them while the main supply is
> off.
I will keep that in mind.
Thank you for the note and your time in reviewing this.
>
>
> I added a comment about this to the commit message about this when
> applying and will send a follow-on patch to update the binding example.
>
> >       if (IS_ERR(data->vcc)) {
> >               ret = PTR_ERR(data->vcc);
>
> Johan

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

* Re: [PATCH v3 2/2] gnss: ubx: add support for the safeboot gpio
  2025-11-14 14:59   ` Johan Hovold
  2025-11-17 16:33     ` Alejandro Enrique
@ 2025-11-20 15:51     ` Johan Hovold
  1 sibling, 0 replies; 7+ messages in thread
From: Johan Hovold @ 2025-11-20 15:51 UTC (permalink / raw)
  To: alejandroe1
  Cc: Rob Herring, Krzysztof Kozlowski, Conor Dooley, devicetree,
	linux-kernel, Krzysztof Kozlowski

On Fri, Nov 14, 2025 at 03:59:24PM +0100, Johan Hovold wrote:
> On Thu, Sep 11, 2025 at 02:58:29PM +0200, Alejandro Enrique via B4 Relay wrote:
> > From: Alejandro Enrique <alejandroe1@geotab.com>
> > 
> > U-Blox 8/M8/M9 chip have a pin to start it in safeboot mode, to be
> > used to recover from situations where the flash content has become
> > corrupted and needs to be restored. If this pin is asserted at power
> > up/reset, the receiver starts in safeboot mode and GNSS operation is
> > disabled.
> > 
> > Deassert the safeboot pin when probing this driver.

> Note however that both the RESET_N and SAFEBOOT_N pins should be
> declared as open-drain to avoid driving them while the main supply is
> off.
> 
> I added a comment about this to the commit message about this when
> applying and will send a follow-on patch to update the binding example.

I was playing with the idea of adding a warning about this to the driver
when realised that there would typically be a level shifter for these
signals that makes sure they are not driven while the supply is off so I
dropped the comment instead.

Johan

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

end of thread, other threads:[~2025-11-20 15:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11 12:58 [PATCH v3 0/2] Add support for safeboot pin to UBlox GNSS driver Alejandro Enrique via B4 Relay
2025-09-11 12:58 ` [PATCH v3 1/2] dt-bindings: gnss: u-blox: add "safeboot-gpios" binding Alejandro Enrique via B4 Relay
2025-11-14 14:42   ` Johan Hovold
2025-09-11 12:58 ` [PATCH v3 2/2] gnss: ubx: add support for the safeboot gpio Alejandro Enrique via B4 Relay
2025-11-14 14:59   ` Johan Hovold
2025-11-17 16:33     ` Alejandro Enrique
2025-11-20 15:51     ` Johan Hovold

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).