summaryrefslogtreecommitdiffstats
path: root/drivers/gnss
diff options
context:
space:
mode:
authorAndreas Kemnade <andreas@kemnade.info>2019-01-24 07:34:38 +0100
committerJohan Hovold <johan@kernel.org>2019-01-25 12:07:42 +0100
commit8fafef42c799eed3afe9abbd3ad517bb8223bc37 (patch)
tree0220ce1aee00da6ef75eac96342769644ca44c72 /drivers/gnss
parent176f011bda551f2bb884dc25595859c3b35ac479 (diff)
downloadlinux-8fafef42c799eed3afe9abbd3ad517bb8223bc37.tar.bz2
gnss: sirf: add a separate supply for a lna
Devices might have a separate lna between antenna input of the gps chip and the antenna which might have a separate supply. Signed-off-by: Andreas Kemnade <andreas@kemnade.info> Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/gnss')
-rw-r--r--drivers/gnss/sirf.c58
1 files changed, 52 insertions, 6 deletions
diff --git a/drivers/gnss/sirf.c b/drivers/gnss/sirf.c
index 703d9f17c583..effed3a8d398 100644
--- a/drivers/gnss/sirf.c
+++ b/drivers/gnss/sirf.c
@@ -40,6 +40,7 @@ struct sirf_data {
struct serdev_device *serdev;
speed_t speed;
struct regulator *vcc;
+ struct regulator *lna;
struct gpio_desc *on_off;
struct gpio_desc *wakeup;
int irq;
@@ -289,21 +290,60 @@ static int sirf_set_active(struct sirf_data *data, bool active)
static int sirf_runtime_suspend(struct device *dev)
{
struct sirf_data *data = dev_get_drvdata(dev);
+ int ret2;
+ int ret;
+
+ if (data->on_off)
+ ret = sirf_set_active(data, false);
+ else
+ ret = regulator_disable(data->vcc);
+
+ if (ret)
+ return ret;
+
+ ret = regulator_disable(data->lna);
+ if (ret)
+ goto err_reenable;
+
+ return 0;
+
+err_reenable:
+ if (data->on_off)
+ ret2 = sirf_set_active(data, true);
+ else
+ ret2 = regulator_enable(data->vcc);
- if (!data->on_off)
- return regulator_disable(data->vcc);
+ if (ret2)
+ dev_err(dev,
+ "failed to reenable power on failed suspend: %d\n",
+ ret2);
- return sirf_set_active(data, false);
+ return ret;
}
static int sirf_runtime_resume(struct device *dev)
{
struct sirf_data *data = dev_get_drvdata(dev);
+ int ret;
- if (!data->on_off)
- return regulator_enable(data->vcc);
+ ret = regulator_enable(data->lna);
+ if (ret)
+ return ret;
+
+ if (data->on_off)
+ ret = sirf_set_active(data, true);
+ else
+ ret = regulator_enable(data->vcc);
+
+ if (ret)
+ goto err_disable_lna;
- return sirf_set_active(data, true);
+ return 0;
+
+err_disable_lna:
+ regulator_disable(data->lna);
+
+ return ret;
}
static int __maybe_unused sirf_suspend(struct device *dev)
@@ -391,6 +431,12 @@ static int sirf_probe(struct serdev_device *serdev)
goto err_put_device;
}
+ data->lna = devm_regulator_get(dev, "lna");
+ if (IS_ERR(data->lna)) {
+ ret = PTR_ERR(data->lna);
+ goto err_put_device;
+ }
+
data->on_off = devm_gpiod_get_optional(dev, "sirf,onoff",
GPIOD_OUT_LOW);
if (IS_ERR(data->on_off))