Skip to content

Commit 645f910

Browse files
committed
Merge tag 'gnss-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/gnss
Pull GNSS updates from Johan Hovold: - support for the reset pin found on some u-blox receivers - use new regulator helper for the u-blox backup supply * tag 'gnss-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/johan/gnss: gnss: ubx: add support for the reset gpio dt-bindings: gnss: u-blox: add "reset-gpios" binding gnss: ubx: use new helper to remove open coded regulator handling
2 parents c736c9a + 0cbbbe0 commit 645f910

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

Documentation/devicetree/bindings/gnss/u-blox,neo-6m.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ properties:
2828
port or the USB host-controller port to which this device is attached,
2929
depending on the bus used. Required for the DDC, SPI or USB busses.
3030
31+
reset-gpios:
32+
maxItems: 1
33+
3134
vcc-supply:
3235
description: >
3336
Main voltage regulator
@@ -49,10 +52,13 @@ unevaluatedProperties: false
4952

5053
examples:
5154
- |
55+
#include <dt-bindings/gpio/gpio.h>
56+
5257
serial {
5358
gnss {
5459
compatible = "u-blox,neo-8";
5560
v-bckp-supply = <&gnss_v_bckp_reg>;
5661
vcc-supply = <&gnss_vcc_reg>;
62+
reset-gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
5763
};
5864
};

drivers/gnss/ubx.c

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/errno.h>
99
#include <linux/gnss.h>
10+
#include <linux/gpio/consumer.h>
1011
#include <linux/init.h>
1112
#include <linux/kernel.h>
1213
#include <linux/module.h>
@@ -17,7 +18,6 @@
1718
#include "serial.h"
1819

1920
struct ubx_data {
20-
struct regulator *v_bckp;
2121
struct regulator *vcc;
2222
};
2323

@@ -66,6 +66,7 @@ static const struct gnss_serial_ops ubx_gserial_ops = {
6666
static int ubx_probe(struct serdev_device *serdev)
6767
{
6868
struct gnss_serial *gserial;
69+
struct gpio_desc *reset;
6970
struct ubx_data *data;
7071
int ret;
7172

@@ -87,30 +88,23 @@ static int ubx_probe(struct serdev_device *serdev)
8788
goto err_free_gserial;
8889
}
8990

90-
data->v_bckp = devm_regulator_get_optional(&serdev->dev, "v-bckp");
91-
if (IS_ERR(data->v_bckp)) {
92-
ret = PTR_ERR(data->v_bckp);
93-
if (ret == -ENODEV)
94-
data->v_bckp = NULL;
95-
else
96-
goto err_free_gserial;
97-
}
91+
ret = devm_regulator_get_enable_optional(&serdev->dev, "v-bckp");
92+
if (ret < 0 && ret != -ENODEV)
93+
goto err_free_gserial;
9894

99-
if (data->v_bckp) {
100-
ret = regulator_enable(data->v_bckp);
101-
if (ret)
102-
goto err_free_gserial;
95+
/* Deassert reset */
96+
reset = devm_gpiod_get_optional(&serdev->dev, "reset", GPIOD_OUT_LOW);
97+
if (IS_ERR(reset)) {
98+
ret = PTR_ERR(reset);
99+
goto err_free_gserial;
103100
}
104101

105102
ret = gnss_serial_register(gserial);
106103
if (ret)
107-
goto err_disable_v_bckp;
104+
goto err_free_gserial;
108105

109106
return 0;
110107

111-
err_disable_v_bckp:
112-
if (data->v_bckp)
113-
regulator_disable(data->v_bckp);
114108
err_free_gserial:
115109
gnss_serial_free(gserial);
116110

@@ -120,11 +114,8 @@ static int ubx_probe(struct serdev_device *serdev)
120114
static void ubx_remove(struct serdev_device *serdev)
121115
{
122116
struct gnss_serial *gserial = serdev_device_get_drvdata(serdev);
123-
struct ubx_data *data = gnss_serial_get_drvdata(gserial);
124117

125118
gnss_serial_deregister(gserial);
126-
if (data->v_bckp)
127-
regulator_disable(data->v_bckp);
128119
gnss_serial_free(gserial);
129120
}
130121

0 commit comments

Comments
 (0)