Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andreas Kemnade and committed by
Johan Hovold
8fafef42 176f011b

+52 -6
+52 -6
drivers/gnss/sirf.c
··· 40 40 struct serdev_device *serdev; 41 41 speed_t speed; 42 42 struct regulator *vcc; 43 + struct regulator *lna; 43 44 struct gpio_desc *on_off; 44 45 struct gpio_desc *wakeup; 45 46 int irq; ··· 290 289 static int sirf_runtime_suspend(struct device *dev) 291 290 { 292 291 struct sirf_data *data = dev_get_drvdata(dev); 292 + int ret2; 293 + int ret; 293 294 294 - if (!data->on_off) 295 - return regulator_disable(data->vcc); 295 + if (data->on_off) 296 + ret = sirf_set_active(data, false); 297 + else 298 + ret = regulator_disable(data->vcc); 296 299 297 - return sirf_set_active(data, false); 300 + if (ret) 301 + return ret; 302 + 303 + ret = regulator_disable(data->lna); 304 + if (ret) 305 + goto err_reenable; 306 + 307 + return 0; 308 + 309 + err_reenable: 310 + if (data->on_off) 311 + ret2 = sirf_set_active(data, true); 312 + else 313 + ret2 = regulator_enable(data->vcc); 314 + 315 + if (ret2) 316 + dev_err(dev, 317 + "failed to reenable power on failed suspend: %d\n", 318 + ret2); 319 + 320 + return ret; 298 321 } 299 322 300 323 static int sirf_runtime_resume(struct device *dev) 301 324 { 302 325 struct sirf_data *data = dev_get_drvdata(dev); 326 + int ret; 303 327 304 - if (!data->on_off) 305 - return regulator_enable(data->vcc); 328 + ret = regulator_enable(data->lna); 329 + if (ret) 330 + return ret; 306 331 307 - return sirf_set_active(data, true); 332 + if (data->on_off) 333 + ret = sirf_set_active(data, true); 334 + else 335 + ret = regulator_enable(data->vcc); 336 + 337 + if (ret) 338 + goto err_disable_lna; 339 + 340 + return 0; 341 + 342 + err_disable_lna: 343 + regulator_disable(data->lna); 344 + 345 + return ret; 308 346 } 309 347 310 348 static int __maybe_unused sirf_suspend(struct device *dev) ··· 428 388 data->vcc = devm_regulator_get(dev, "vcc"); 429 389 if (IS_ERR(data->vcc)) { 430 390 ret = PTR_ERR(data->vcc); 391 + goto err_put_device; 392 + } 393 + 394 + data->lna = devm_regulator_get(dev, "lna"); 395 + if (IS_ERR(data->lna)) { 396 + ret = PTR_ERR(data->lna); 431 397 goto err_put_device; 432 398 } 433 399