gnss: sirf: add support for w2sg0004 + lna
Subsystems (2)
cover gnss: sirf: add support for w2sg0004 + lna
Here is another chapter of the story to get gta04 gnss power management into the mainline kernel.
There is a w2sg0004 without wakeup line in there, so power state can only be determined indirectly by looking at the serial data lines. Then there as also an lna which needs to be powered for real gps reception. That part needs probably more discussion, since it might be an idea to have it more generalized since it has nothing todo with the chip itself.
I marked the corresponding patches as RFC. The support for the w2sg0004 without wakeup can imho go in without the lna first because users of that chip without an additional lna power supply can already benefit from it if we should do more discussion first. I just kept them together so that the full picture can be seen.
Andreas Kemnade (5):
gnss: sirf: write data to gnss only when the gnss device is open
gnss: sirf: power on logic for devices without wakeup signal
dt-bindings: gnss: add w2sg0004 compatible string
gnss: sirf: add a separate supply for a lna
dt-bindings: gnss: add lna-supply property
.../devicetree/bindings/gnss/sirfstar.txt | 2 + drivers/gnss/sirf.c | 126 +++++++++++++++------ 2 files changed, 96 insertions(+), 32 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/5 gnss: sirf: write data to gnss only when the gnss device is open
The api forbids writing data there otherwise. Prepare for the serdev_open()/close() being a part of runtime pm.
--- drivers/gnss/sirf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/gnss/sirf.c +15 -1
@@ -34,6 +34,7 @@ struct sirf_data {struct gpio_desc *wakeup;int irq;bool active; +bool opened;wait_queue_head_t power_wait; };
@@ -43,6 +44,7 @@ static int sirf_open(struct gnss_device *gdev)struct serdev_device *serdev = data->serdev;int ret; + data->opened = true; ret =serdev_device_open (serdev);if (ret)return ret;
@@ -54,6 +56,7 @@ static int sirf_open(struct gnss_device *gdev)if (ret <0 ) {dev_err (&gdev->dev,"failed to runtime resume: %d\n" , ret);pm_runtime_put_noidle (&serdev->dev); + data->opened = false; goto err_close; }
@@ -73,6 +76,7 @@ static void sirf_close(struct gnss_device *gdev)serdev_device_close (serdev);pm_runtime_put (&serdev->dev); + data->opened = false; } static int sirf_write_raw(struct gnss_device *gdev, const unsigned char *buf,
@@ -105,7 +109,17 @@ static int sirf_receive_buf(struct serdev_device *serdev,struct sirf_data *data =serdev_device_get_drvdata (serdev);struct gnss_device *gdev = data->gdev; -return gnss_insert_raw (gdev, buf, count); +/* +* we might come here everytime when runtime is resumed +* and data is received. Two cases are possible +* 1. device is opened during initialisation +* 2. kernel is compiled without runtime pm +* and device is opened all the time +*/ +if (data->opened) +return gnss_insert_raw (gdev, buf, count); + +return 0 ; }static const struct serdev_device_ops sirf_serdev_ops = {
Signature · 1 line
2.11.0
Johan Hovold
maintainerRe: [PATCH 1/5] gnss: sirf: write data to gnss only when the gnss device is open
Quoted 20 lines · Andreas Kemnade
The api forbids writing data there otherwise. Prepare for the serdev_open()/close() being a part of runtime pm.
Signed-off-by Andreas Kemnade <[email protected]>--- drivers/gnss/sirf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/gnss/sirf.c +1
-0@@ -73,6 +76,7 @@ static void sirf_close(struct gnss_device *gdev)serdev_device_close (serdev);pm_runtime_put (&serdev->dev); + data->opened = false; } static int sirf_write_raw(struct gnss_device *gdev, const unsigned char *buf,@@ -105,7 +109,17 @@ static int sirf_receive_buf(struct serdev_device *serdev,struct sirf_data *data =serdev_device_get_drvdata (serdev);struct gnss_device *gdev = data->gdev;
drivers/gnss/sirf.c static int sirf_receive_buf(struct serdev_device *serdev, · line 120
Quoted 10 lines
drivers/gnss/sirf.c +9
-1-return gnss_insert_raw (gdev, buf, count); +/* +* we might come here everytime when runtime is resumed +* and data is received. Two cases are possible +* 1. device is opened during initialisation +* 2. kernel is compiled without runtime pm +* and device is opened all the time +*/ +if (data->opened) +return gnss_insert_raw (gdev, buf, count);
This can race with sirf_close() when you move serdev handling out of sirf_open()/close(). Not sure how best to handle that yet.
Johan
Re: [PATCH 1/5] gnss: sirf: write data to gnss only when the gnss device is open
Quoted 21 lines · On Wed, 5 Dec 2018 15:47:39 +0100 Johan Hovold <[email protected]> wrote:
Quoted 20 lines · Andreas Kemnade
The api forbids writing data there otherwise. Prepare for the serdev_open()/close() being a part of runtime pm.
Signed-off-by Andreas Kemnade <[email protected]>--- drivers/gnss/sirf.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)drivers/gnss/sirf.c +1
-0@@ -73,6 +76,7 @@ static void sirf_close(struct gnss_device *gdev)serdev_device_close (serdev);pm_runtime_put (&serdev->dev); + data->opened = false; } static int sirf_write_raw(struct gnss_device *gdev, const unsigned char *buf,@@ -105,7 +109,17 @@ static int sirf_receive_buf(struct serdev_device *serdev,struct sirf_data *data =serdev_device_get_drvdata (serdev);struct gnss_device *gdev = data->gdev;
Quoted 14 lines
drivers/gnss/sirf.c static int sirf_receive_buf(struct serdev_device *serdev, · line 120
Quoted 10 lines
drivers/gnss/sirf.c +9
-1-return gnss_insert_raw (gdev, buf, count); +/* +* we might come here everytime when runtime is resumed +* and data is received. Two cases are possible +* 1. device is opened during initialisation +* 2. kernel is compiled without runtime pm +* and device is opened all the time +*/ +if (data->opened) +return gnss_insert_raw (gdev, buf, count);This can race with
sirf_close()when you move serdev handling out of sirf_open()/close(). Not sure how best to handle that yet.
Ok, first lets check whether we have a common idea of the problem before coming to a solution. So race condition here can happen if the serdev is still opened after the pm_runtime_put in sirf_close() which might happen if runtime is not suspended after that. I missed that case. Then if (data->opened)
is checked, data->opened set to false
then gnss_insert_raw() is executed.
There is data inserted into the fifo which will be read by the next one opening the gnss device. And there might be trouble at deregistering time.
And now if we simply add locks:
For sirf_receive_buf(), it somehow feels dangerous if we call gnss_insert_raw() with a lock held but I have not analyzed it thoroughly. For sirf_close(), we could simply
put a lock around data->opened = false;
Am I missing something?
I will check if anything changes when I move the serdev_open()/close() calls a bit. In the end me end to have the serdev open whenever the userspace wants data or we want to change the state of the gnss chip without wakeup.
Maybe add a special driver state for that situation where the power state of the gps chip is changed without having it opened. If we check that at the beginning of that action, we might have luck.
Regards,
Andreas
PATCH 2/5 gnss: sirf: power on logic for devices without wakeup signal
In reply to Andreas KemnadeSome Wi2Wi devices do not have a wakeup output, so device state can only be indirectly detected by looking whether there is communitcation over the serial lines.
Additionally it checks for the initial state of the device during probing to ensure it is off.
Timeout values need to be increased, because the reaction on serial line is slower and are in line with previous patches by
Neil Brown <[email protected]> and H. Nikolaus Schaller <[email protected]>.
--- drivers/gnss/sirf.c | 97 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 32 deletions(-)
drivers/gnss/sirf.c +65 -32
@@ -22,8 +22,8 @@#define SIRF_BOOT_DELAY 500#define SIRF_ON_OFF_PULSE_TIME 100 -#define SIRF_ACTIVATE_TIMEOUT 200 -#define SIRF_HIBERNATE_TIMEOUT 200 +#define SIRF_ACTIVATE_TIMEOUT 1000 +#define SIRF_HIBERNATE_TIMEOUT 1000struct sirf_data {struct gnss_device *gdev;
@@ -45,26 +45,14 @@ static int sirf_open(struct gnss_device *gdev)int ret; data->opened = true; - ret =serdev_device_open (serdev); -if (ret) -return ret; - -serdev_device_set_baudrate (serdev, data->speed); -serdev_device_set_flow_control (serdev, false); ret =pm_runtime_get_sync (&serdev->dev);if (ret <0 ) {dev_err (&gdev->dev,"failed to runtime resume: %d\n" , ret);pm_runtime_put_noidle (&serdev->dev); data->opened = false; - goto err_close; } -return 0 ; - -err_close: -serdev_device_close (serdev); -return ret; }
@@ -73,8 +61,6 @@ static void sirf_close(struct gnss_device *gdev)struct sirf_data *data =gnss_get_drvdata (gdev);struct serdev_device *serdev = data->serdev; -serdev_device_close (serdev); -pm_runtime_put (&serdev->dev); data->opened = false; }
@@ -109,6 +95,11 @@ static int sirf_receive_buf(struct serdev_device *serdev,struct sirf_data *data =serdev_device_get_drvdata (serdev);struct gnss_device *gdev = data->gdev; +if ((!data->wakeup) && (!data->active)) { + data->active =1 ; +wake_up_interruptible (&data->power_wait); + } +/* * we might come here everytime when runtime is resumed * and data is received. Two cases are possible
@@ -149,6 +140,25 @@ static int sirf_wait_for_power_state(struct sirf_data *data, bool active, {int ret; +/* no wakeup pin, success condition is that +* no byte comes in in the period +*/ +if ((!data->wakeup) && (!active) && (data->active)) { +/* some bytes might come, so sleep a bit first */ +msleep (timeout); + data->active = false; + ret =wait_event_interruptible_timeout (data->power_wait, + data->active == true,msecs_to_jiffies (timeout)); + +if (ret <0 ) +return ret; + +/* we are still getting woken up -> timeout */ +if (ret >0 ) +return -ETIMEDOUT ; +return 0 ; + } + ret =wait_event_interruptible_timeout (data->power_wait, data->active == active,msecs_to_jiffies (timeout));if (ret <0 )
@@ -203,21 +213,48 @@ 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 ret;if (!data->on_off)return regulator_disable (data->vcc); + ret =sirf_set_active (data, false); -return sirf_set_active (data, false); +if (ret) +dev_err (dev,"failed to deactivate" ); + +/* we should close it anyways, so the following receptions +* will not run into the empty +*/ +serdev_device_close (data->serdev); +return 0 ; }static int sirf_runtime_resume (struct device *dev) { +int ret;struct sirf_data *data =dev_get_drvdata (dev); + ret =serdev_device_open (data->serdev); +if (ret) +return ret; -if (!data->on_off) -return regulator_enable (data->vcc); +serdev_device_set_baudrate (data->serdev, data->speed); +serdev_device_set_flow_control (data->serdev, false); + +if (!data->on_off) { + ret =regulator_enable (data->vcc); +if (ret) + goto err_close_serdev; + } + ret =sirf_set_active (data, true); + +if (!ret) +return 0 ; -return sirf_set_active (data, true); +if (!data->on_off) +regulator_disable (data->vcc); +err_close_serdev: +serdev_device_close (data->serdev); +return ret; }static int __maybe_unused sirf_suspend (struct device *dev)
@@ -311,18 +348,6 @@ static int sirf_probe(struct serdev_device *serdev)if (data->on_off) { data->wakeup =devm_gpiod_get_optional (dev,"sirf,wakeup" ,GPIOD_IN ); -if (IS_ERR (data->wakeup)) - goto err_put_device; - -/* -* Configurations where WAKEUP has been left not connected, -* are currently not supported. -*/ -if (!data->wakeup) { -dev_err (dev,"no wakeup gpio specified\n" ); - ret = -ENODEV ; - goto err_put_device; - } }if (data->wakeup) {
@@ -352,6 +377,13 @@ static int sirf_probe(struct serdev_device *serdev)if (IS_ENABLED (CONFIG_PM )) {pm_runtime_set_suspended (dev);/* clear runtime_error flag */ pm_runtime_enable (dev); +/* device might be enabled at boot, so lets first enable it, +* then disable it to bring it into a clear state +*/ + ret =pm_runtime_get_sync (dev); +if (ret) + goto err_disable_rpm; +pm_runtime_put (dev); }else { ret =sirf_runtime_resume (dev);if (ret <0 )
@@ -401,6 +433,7 @@ static const struct of_device_id sirf_of_match[] = { { .compatible = "linx,r4" }, { .compatible = "wi2wi,w2sg0008i" }, { .compatible = "wi2wi,w2sg0084i" }, + { .compatible = "wi2wi,w2sg0004" }, {}, };MODULE_DEVICE_TABLE (of, sirf_of_match);
Signature · 1 line
2.11.0
Re: [PATCH 2/5] gnss: sirf: power on logic for devices without wakeup signal
Quoted 179 lines
Am 18.11.2018 um 22:57 schrieb Andreas Kemnade <[email protected]>:
Some Wi2Wi devices do not have a wakeup output, so device state can only be indirectly detected by looking whether there is communitcation over the serial lines.
Additionally it checks for the initial state of the device during probing to ensure it is off.
Timeout values need to be increased, because the reaction on serial line is slower and are in line with previous patches by
Neil Brown <[email protected]> and H. Nikolaus Schaller <[email protected]>.Signed-off-by Andreas Kemnade <[email protected]>---
drivers/gnss/sirf.c| 97 +++++++++++++++++++++++++++++++++++------------------1 file changed, 65 insertions(+), 32 deletions(-)drivers/gnss/sirf.c +57
-32@@ -22,8 +22,8 @@#define SIRF_BOOT_DELAY 500#define SIRF_ON_OFF_PULSE_TIME 100 -#define SIRF_ACTIVATE_TIMEOUT 200 -#define SIRF_HIBERNATE_TIMEOUT 200 +#define SIRF_ACTIVATE_TIMEOUT 1000 +#define SIRF_HIBERNATE_TIMEOUT 1000struct sirf_data {struct gnss_device *gdev;@@ -45,26 +45,14 @@ static int sirf_open(struct gnss_device *gdev)int ret; data->opened = true; - ret =serdev_device_open (serdev); -if (ret) -return ret; - -serdev_device_set_baudrate (serdev, data->speed); -serdev_device_set_flow_control (serdev, false); ret =pm_runtime_get_sync (&serdev->dev);if (ret <0 ) {dev_err (&gdev->dev,"failed to runtime resume: %d\n" , ret);pm_runtime_put_noidle (&serdev->dev); data->opened = false; - goto err_close; } -return 0 ; - -err_close: -serdev_device_close (serdev); -return ret; }@@ -73,8 +61,6 @@ static void sirf_close(struct gnss_device *gdev)struct sirf_data *data =gnss_get_drvdata (gdev);struct serdev_device *serdev = data->serdev; -serdev_device_close (serdev); -pm_runtime_put (&serdev->dev); data->opened = false; }@@ -109,6 +95,11 @@ static int sirf_receive_buf(struct serdev_device *serdev,struct sirf_data *data =serdev_device_get_drvdata (serdev);struct gnss_device *gdev = data->gdev; +if ((!data->wakeup) && (!data->active)) { + data->active =1 ; +wake_up_interruptible (&data->power_wait); + } +/* * we might come here everytime when runtime is resumed * and data is received. Two cases are possible @@ -149,6 +140,25 @@ static int sirf_wait_for_power_state(struct sirf_data *data, bool active, {int ret; +/* no wakeup pin, success condition is that +* no byte comes in in the period +*/ +if ((!data->wakeup) && (!active) && (data->active)) { +/* some bytes might come, so sleep a bit first */ +msleep (timeout); + data->active = false; + ret =wait_event_interruptible_timeout (data->power_wait, + data->active == true,msecs_to_jiffies (timeout)); + +if (ret <0 ) +return ret; + +/* we are still getting woken up -> timeout */ +if (ret >0 ) +return -ETIMEDOUT ; +return 0 ; + } + ret =wait_event_interruptible_timeout (data->power_wait, data->active == active,msecs_to_jiffies (timeout));if (ret <0 )@@ -203,21 +213,48 @@ 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 ret;if (!data->on_off)return regulator_disable (data->vcc); + ret =sirf_set_active (data, false); -return sirf_set_active (data, false); +if (ret) +dev_err (dev,"failed to deactivate" ); + +/* we should close it anyways, so the following receptions +* will not run into the empty +*/ +serdev_device_close (data->serdev); +return 0 ; }static int sirf_runtime_resume (struct device *dev) { +int ret;struct sirf_data *data =dev_get_drvdata (dev); + ret =serdev_device_open (data->serdev); +if (ret) +return ret; -if (!data->on_off) -return regulator_enable (data->vcc); +serdev_device_set_baudrate (data->serdev, data->speed); +serdev_device_set_flow_control (data->serdev, false); + +if (!data->on_off) { + ret =regulator_enable (data->vcc); +if (ret) + goto err_close_serdev; + } + ret =sirf_set_active (data, true); + +if (!ret) +return 0 ; -return sirf_set_active (data, true); +if (!data->on_off) +regulator_disable (data->vcc); +err_close_serdev: +serdev_device_close (data->serdev); +return ret; }static int __maybe_unused sirf_suspend (struct device *dev)@@ -311,18 +348,6 @@ static int sirf_probe(struct serdev_device *serdev)if (data->on_off) { data->wakeup =devm_gpiod_get_optional (dev,"sirf,wakeup" ,GPIOD_IN ); -if (IS_ERR (data->wakeup)) - goto err_put_device; - -/* -* Configurations where WAKEUP has been left not connected, -* are currently not supported. -*/ -if (!data->wakeup) { -dev_err (dev,"no wakeup gpio specified\n" ); - ret = -ENODEV ; - goto err_put_device; - } }if (data->wakeup) {
drivers/gnss/sirf.c static int sirf_probe(struct serdev_device *serdev) · line 382
Quoted 6 lines
drivers/gnss/sirf.c +3
-0@@ -352,6 +377,13 @@ static int sirf_probe(struct serdev_device *serdev)if (IS_ENABLED (CONFIG_PM )) {pm_runtime_set_suspended (dev);/* clear runtime_error flag */ pm_runtime_enable (dev); +/* device might be enabled at boot, so lets first enable it, +* then disable it to bring it into a clear state +*/
That is an interesting trick to solve the "device is powered on but kernel does not know" problem.
The assumption to make your trick work is that there is nobody besides the running kernel who can turn on/off the device so that after this operation, the kernel can simply track the power state in a boolean flag.
Since the power control gpio is grabbed by this driver, it can't be exported to user-space and hence I think we can take this assumption for granted.
Quoted 23 lines
drivers/gnss/sirf.c +5
-0+ ret =pm_runtime_get_sync (dev); +if (ret) + goto err_disable_rpm; +pm_runtime_put (dev); }else { ret =sirf_runtime_resume (dev);if (ret <0 )@@ -401,6 +433,7 @@ static const struct of_device_id sirf_of_match[] = { { .compatible = "linx,r4" }, { .compatible = "wi2wi,w2sg0008i" }, { .compatible = "wi2wi,w2sg0084i" }, + { .compatible = "wi2wi,w2sg0004" }, {}, };MODULE_DEVICE_TABLE (of, sirf_of_match);Signature · 7 lines
2.11.0 _______________________________________________ http://projects.goldelico.com/p/gta04-kernel/ Letux-kernel mailing list [email protected] http://lists.goldelico.com/mailman/listinfo.cgi/letux-kernel
BR,
Nikolaus
Johan Hovold
maintainerRe: [PATCH 2/5] gnss: sirf: power on logic for devices without wakeup signal
In reply to Andreas KemnadeQuoted 19 lines · Andreas Kemnade
Some Wi2Wi devices do not have a wakeup output, so device state can only be indirectly detected by looking whether there is communitcation over the serial lines.
Additionally it checks for the initial state of the device during probing to ensure it is off.
Timeout values need to be increased, because the reaction on serial line is slower and are in line with previous patches by
Neil Brown <[email protected]> and H. Nikolaus Schaller <[email protected]>.Signed-off-by Andreas Kemnade <[email protected]>--- drivers/gnss/sirf.c | 97 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 32 deletions(-)drivers/gnss/sirf.c +0
-0
drivers/gnss/sirf.c line 26
Quoted 7 lines
drivers/gnss/sirf.c +2
-2@@ -22,8 +22,8 @@#define SIRF_BOOT_DELAY 500#define SIRF_ON_OFF_PULSE_TIME 100 -#define SIRF_ACTIVATE_TIMEOUT 200 -#define SIRF_HIBERNATE_TIMEOUT 200 +#define SIRF_ACTIVATE_TIMEOUT 1000 +#define SIRF_HIBERNATE_TIMEOUT 1000
We shouldn't increase the timeouts for the general case where we have wakeup connected.
drivers/gnss/sirf.c static int sirf_open(struct gnss_device *gdev) · line 53
Quoted 12 lines
drivers/gnss/sirf.c +0
-6struct sirf_data {struct gnss_device *gdev;@@ -45,26 +45,14 @@ static int sirf_open(struct gnss_device *gdev)int ret; data->opened = true; - ret =serdev_device_open (serdev); -if (ret) -return ret; - -serdev_device_set_baudrate (serdev, data->speed); -serdev_device_set_flow_control (serdev, false);
And also here, I think we shouldn't change the general case (wakeup connected) unnecessarily. Currently user space can request the receiver to remain powered, while not keeping the port open unnecessarily.
Quoted 27 lines
drivers/gnss/sirf.c +0
-8ret =pm_runtime_get_sync (&serdev->dev);if (ret <0 ) {dev_err (&gdev->dev,"failed to runtime resume: %d\n" , ret);pm_runtime_put_noidle (&serdev->dev); data->opened = false; - goto err_close; } -return 0 ; - -err_close: -serdev_device_close (serdev); -return ret; }@@ -73,8 +61,6 @@ static void sirf_close(struct gnss_device *gdev)struct sirf_data *data =gnss_get_drvdata (gdev);struct serdev_device *serdev = data->serdev; -serdev_device_close (serdev); -pm_runtime_put (&serdev->dev); data->opened = false; }
drivers/gnss/sirf.c static int sirf_receive_buf(struct serdev_device *serdev, · line 98
Quoted 4 lines
drivers/gnss/sirf.c +1
-0@@ -109,6 +95,11 @@ static int sirf_receive_buf(struct serdev_device *serdev,struct sirf_data *data =serdev_device_get_drvdata (serdev);struct gnss_device *gdev = data->gdev; +if ((!data->wakeup) && (!data->active)) {
You have superfluous parenthesis like the above throughout the series.
drivers/gnss/sirf.c static int sirf_receive_buf(struct serdev_device *serdev, · line 99
Quoted 1 line
drivers/gnss/sirf.c +1
-0+ data->active =1 ;
active is bool, so use "true".
drivers/gnss/sirf.c static int sirf_wait_for_power_state(struct sirf_data *data, bool active, · line 145
Quoted 13 lines
drivers/gnss/sirf.c +6
-0+wake_up_interruptible (&data->power_wait); + } +/* * we might come here everytime when runtime is resumed * and data is received. Two cases are possible @@ -149,6 +140,25 @@ static int sirf_wait_for_power_state(struct sirf_data *data, bool active, {int ret; +/* no wakeup pin, success condition is that +* no byte comes in in the period +*/
Multiline comment style needs to be fixed throughout. Also use sentence case and periods where appropriate.
drivers/gnss/sirf.c static int sirf_wait_for_power_state(struct sirf_data *data, bool active, · line 148
Quoted 3 lines
drivers/gnss/sirf.c +3
-0+if ((!data->wakeup) && (!active) && (data->active)) { +/* some bytes might come, so sleep a bit first */ +msleep (timeout);
This changes the semantics of the functions and effectively doubles the requested timeout.
Quoted 17 lines
drivers/gnss/sirf.c +13
-0+ data->active = false; + ret =wait_event_interruptible_timeout (data->power_wait, + data->active == true,msecs_to_jiffies (timeout)); + +if (ret <0 ) +return ret; + +/* we are still getting woken up -> timeout */ +if (ret >0 ) +return -ETIMEDOUT ; +return 0 ; + } + ret =wait_event_interruptible_timeout (data->power_wait, data->active == active,msecs_to_jiffies (timeout));if (ret <0 )
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 219
Quoted 7 lines
drivers/gnss/sirf.c +1
-0@@ -203,21 +213,48 @@ 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 ret;if (!data->on_off)return regulator_disable (data->vcc);
Missing newline.
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 221
Quoted 2 lines
drivers/gnss/sirf.c +1
-0+ ret =sirf_set_active (data, false);
Superfluous newline.
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 223
Quoted 3 lines
drivers/gnss/sirf.c +2
-1-return sirf_set_active (data, false); +if (ret) +dev_err (dev,"failed to deactivate" );
Missing '\n'.
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 227
Quoted 4 lines
drivers/gnss/sirf.c +4
-0+ +/* we should close it anyways, so the following receptions +* will not run into the empty +*/
Not sure what you mean here, please rephrase.
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 234
Quoted 7 lines
drivers/gnss/sirf.c +3
-0+serdev_device_close (data->serdev); +return 0 ; }static int sirf_runtime_resume (struct device *dev) { +int ret;
Please, place after the next declaration (reverse xmas style).
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 235
Quoted 1 line
drivers/gnss/sirf.c +0
-0struct sirf_data *data =dev_get_drvdata (dev);
Missing newline.
Quoted 4 lines
drivers/gnss/sirf.c +3
-0+ ret =serdev_device_open (data->serdev); +if (ret) +return ret;
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 247
Quoted 10 lines
drivers/gnss/sirf.c +8
-2-if (!data->on_off) -return regulator_enable (data->vcc); +serdev_device_set_baudrate (data->serdev, data->speed); +serdev_device_set_flow_control (data->serdev, false); + +if (!data->on_off) { + ret =regulator_enable (data->vcc); +if (ret) + goto err_close_serdev; + }
Newline.
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 251
Quoted 4 lines
drivers/gnss/sirf.c +4
-0+ ret =sirf_set_active (data, true); + +if (!ret) +return 0 ;
Add an error label instead, and return 0 unconditionally in the success path.
Quoted 11 lines
drivers/gnss/sirf.c +5
-1-return sirf_set_active (data, true); +if (!data->on_off) +regulator_disable (data->vcc); +err_close_serdev: +serdev_device_close (data->serdev); +return ret; }static int __maybe_unused sirf_suspend (struct device *dev)
drivers/gnss/sirf.c static int sirf_probe(struct serdev_device *serdev) · line 315
Quoted 5 lines
drivers/gnss/sirf.c +0
-2@@ -311,18 +348,6 @@ static int sirf_probe(struct serdev_device *serdev)if (data->on_off) { data->wakeup =devm_gpiod_get_optional (dev,"sirf,wakeup" ,GPIOD_IN ); -if (IS_ERR (data->wakeup)) - goto err_put_device;
You still want to check for errors here.
Quoted 28 lines
drivers/gnss/sirf.c +7
-10- -/* -* Configurations where WAKEUP has been left not connected, -* are currently not supported. -*/ -if (!data->wakeup) { -dev_err (dev,"no wakeup gpio specified\n" ); - ret = -ENODEV ; - goto err_put_device; - } }if (data->wakeup) {@@ -352,6 +377,13 @@ static int sirf_probe(struct serdev_device *serdev)if (IS_ENABLED (CONFIG_PM )) {pm_runtime_set_suspended (dev);/* clear runtime_error flag */ pm_runtime_enable (dev); +/* device might be enabled at boot, so lets first enable it, +* then disable it to bring it into a clear state +*/ + ret =pm_runtime_get_sync (dev); +if (ret) + goto err_disable_rpm; +pm_runtime_put (dev); }else { ret =sirf_runtime_resume (dev);if (ret <0 )
drivers/gnss/sirf.c static const struct of_device_id sirf_of_match[] = { · line 436
Quoted 4 lines
drivers/gnss/sirf.c +1
-0@@ -401,6 +433,7 @@ static const struct of_device_id sirf_of_match[] = { { .compatible = "linx,r4" }, { .compatible = "wi2wi,w2sg0008i" }, { .compatible = "wi2wi,w2sg0084i" }, + { .compatible = "wi2wi,w2sg0004" },
Keep the entries sorted.
drivers/gnss/sirf.c static const struct of_device_id sirf_of_match[] = { · line 439
Quoted 3 lines
drivers/gnss/sirf.c +0
-0{}, };MODULE_DEVICE_TABLE (of, sirf_of_match);
Johan
Re: [PATCH 2/5] gnss: sirf: power on logic for devices without wakeup signal
Quoted 21 lines · On Wed, 5 Dec 2018 16:01:16 +0100 Johan Hovold <[email protected]> wrote:
Quoted 20 lines · Andreas Kemnade
Some Wi2Wi devices do not have a wakeup output, so device state can only be indirectly detected by looking whether there is communitcation over the serial lines.
Additionally it checks for the initial state of the device during probing to ensure it is off.
Timeout values need to be increased, because the reaction on serial line is slower and are in line with previous patches by
Neil Brown <[email protected]> and H. Nikolaus Schaller <[email protected]>.Signed-off-by Andreas Kemnade <[email protected]>--- drivers/gnss/sirf.c | 97 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 65 insertions(+), 32 deletions(-)drivers/gnss/sirf.c +0
-0@@ -22,8 +22,8 @@
Quoted 10 lines
drivers/gnss/sirf.c line 26
Quoted 6 lines
drivers/gnss/sirf.c +2
-2#define SIRF_BOOT_DELAY 500#define SIRF_ON_OFF_PULSE_TIME 100 -#define SIRF_ACTIVATE_TIMEOUT 200 -#define SIRF_HIBERNATE_TIMEOUT 200 +#define SIRF_ACTIVATE_TIMEOUT 1000 +#define SIRF_HIBERNATE_TIMEOUT 1000We shouldn't increase the timeouts for the general case where we have wakeup connected.
Well, in most times they are not hit in the general case, only once if the internal state is not in sync.
But I can add a second pair of defines with more refined defines.
Quoted 5 lines
Quoted 5 lines
drivers/gnss/sirf.c +0
-0struct sirf_data {struct gnss_device *gdev;@@ -45,26 +45,14 @@ static int sirf_open(struct gnss_device *gdev)int ret;
Quoted 12 lines
drivers/gnss/sirf.c static int sirf_open(struct gnss_device *gdev) · line 53
Quoted 7 lines
drivers/gnss/sirf.c +0
-6data->opened = true; - ret =serdev_device_open (serdev); -if (ret) -return ret; - -serdev_device_set_baudrate (serdev, data->speed); -serdev_device_set_flow_control (serdev, false);And also here, I think we shouldn't change the general case (wakeup connected) unnecessarily. Currently user space can request the receiver to remain powered, while not keeping the port open unnecessarily.
Yes, that usecase makes sense. There is even no need to keep that device opened in the no-wakeup case. If I just open the serdev during state change, code will probably be cleaner.
Quoted 30 lines
Quoted 30 lines
drivers/gnss/sirf.c +0
-8ret =pm_runtime_get_sync (&serdev->dev);if (ret <0 ) {dev_err (&gdev->dev,"failed to runtime resume: %d\n" , ret);pm_runtime_put_noidle (&serdev->dev); data->opened = false; - goto err_close; } -return 0 ; - -err_close: -serdev_device_close (serdev); -return ret; }@@ -73,8 +61,6 @@ static void sirf_close(struct gnss_device *gdev)struct sirf_data *data =gnss_get_drvdata (gdev);struct serdev_device *serdev = data->serdev; -serdev_device_close (serdev); -pm_runtime_put (&serdev->dev); data->opened = false; }@@ -109,6 +95,11 @@ static int sirf_receive_buf(struct serdev_device *serdev,struct sirf_data *data =serdev_device_get_drvdata (serdev);struct gnss_device *gdev = data->gdev;
Quoted 4 lines
drivers/gnss/sirf.c static int sirf_receive_buf(struct serdev_device *serdev, · line 98
Quoted 1 line
drivers/gnss/sirf.c +1
-0+if ((!data->wakeup) && (!data->active)) {You have superfluous parenthesis like the above throughout the series.
OK, will reduce them.
Quoted 14 lines
drivers/gnss/sirf.c static int sirf_receive_buf(struct serdev_device *serdev, · line 99
Quoted 1 line
drivers/gnss/sirf.c +1
-0+ data->active =1 ;active is bool, so use "true".
Quoted 10 lines
drivers/gnss/sirf.c +3
-0+wake_up_interruptible (&data->power_wait); + } +/* * we might come here everytime when runtime is resumed * and data is received. Two cases are possible @@ -149,6 +140,25 @@ static int sirf_wait_for_power_state(struct sirf_data *data, bool active, {int ret;
Quoted 7 lines
drivers/gnss/sirf.c static int sirf_wait_for_power_state(struct sirf_data *data, bool active, · line 145
Quoted 3 lines
drivers/gnss/sirf.c +3
-0+/* no wakeup pin, success condition is that +* no byte comes in in the period +*/ Multiline comment style needs to be fixed throughout. Also use sentence case and periods where appropriate.
OK. maybe I did believe too much in checkpatch.pl. It likes this patch. I thought it would moan about such basic things.
Quoted 7 lines
drivers/gnss/sirf.c static int sirf_wait_for_power_state(struct sirf_data *data, bool active, · line 148
Quoted 3 lines
drivers/gnss/sirf.c +3
-0+if ((!data->wakeup) && (!active) && (data->active)) { +/* some bytes might come, so sleep a bit first */ +msleep (timeout);This changes the semantics of the functions and effectively doubles the requested timeout.
So maybe I should sort this block out into a properly-named function with properly named constants?
The logic is to give the device some time first to calm down. And then check for some time if it is really down.
Quoted 22 lines
Quoted 22 lines
drivers/gnss/sirf.c +14
-0+ data->active = false; + ret =wait_event_interruptible_timeout (data->power_wait, + data->active == true,msecs_to_jiffies (timeout)); + +if (ret <0 ) +return ret; + +/* we are still getting woken up -> timeout */ +if (ret >0 ) +return -ETIMEDOUT ; +return 0 ; + } + ret =wait_event_interruptible_timeout (data->power_wait, data->active == active,msecs_to_jiffies (timeout));if (ret <0 )@@ -203,21 +213,48 @@ 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 ret;
Quoted 3 lines
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 219
Quoted 2 lines
drivers/gnss/sirf.c +0
-0if (!data->on_off)return regulator_disable (data->vcc);
[..] minor style issues ... will fix, still wondering why checkpatch does not complain. Just saved the patch again and checked.
Quoted 7 lines
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 227
Quoted 4 lines
drivers/gnss/sirf.c +4
-0+ +/* we should close it anyways, so the following receptions +* will not run into the empty +*/ Not sure what you mean here, please rephrase.
If the serdev is closed, nothing will be sent to a probably not-existing-anymore gnss device.
Quoted 4 lines
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 231
Quoted 4 lines
drivers/gnss/sirf.c +2
-0+serdev_device_close (data->serdev); +return 0 ; }
[...] more minor style issues
Quoted 9 lines
drivers/gnss/sirf.c static int sirf_set_active(struct sirf_data *data, bool active) · line 251
Quoted 5 lines
drivers/gnss/sirf.c +4
-0+ ret =sirf_set_active (data, true); + +if (!ret) +return 0 ;Add an error label instead, and return 0 unconditionally in the success path.
Ok, makes sense.
Quoted 9 lines
Quoted 9 lines
drivers/gnss/sirf.c +5
-1-return sirf_set_active (data, true); +if (!data->on_off) +regulator_disable (data->vcc); +err_close_serdev: +serdev_device_close (data->serdev); +return ret; }
Quoted 10 lines
drivers/gnss/sirf.c static int sirf_probe(struct serdev_device *serdev) · line 315
Quoted 7 lines
drivers/gnss/sirf.c +0
-2static int __maybe_unused sirf_suspend (struct device *dev)@@ -311,18 +348,6 @@ static int sirf_probe(struct serdev_device *serdev)if (data->on_off) { data->wakeup =devm_gpiod_get_optional (dev,"sirf,wakeup" ,GPIOD_IN ); -if (IS_ERR (data->wakeup)) - goto err_put_device;You still want to check for errors here.
Yes, I should only ignore NULL here..
Regards,
Andreas
PATCH 3/5 dt-bindings: gnss: add w2sg0004 compatible string
In reply to Andreas KemnadeAdd w2sg0004 compatible string since devices without wakeup pins are now supported.
--- Documentation/devicetree/bindings/gnss/sirfstar.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/gnss/sirfstar.txt +1 -0
@@ -14,6 +14,7 @@ Required properties: "linx,r4" "wi2wi,w2sg0008i" "wi2wi,w2sg0084i" + "wi2wi,w2sg0004" - vcc-supply : Main voltage regulator (pin name: 3V3_IN, VCC, VDD)
Signature · 1 line
2.11.0
Re: [PATCH 3/5] dt-bindings: gnss: add w2sg0004 compatible string
Quoted 8 lines · Andreas Kemnade
Add w2sg0004 compatible string since devices without wakeup pins are now supported.
Signed-off-by Andreas Kemnade <[email protected]>--- Documentation/devicetree/bindings/gnss/sirfstar.txt | 1 + 1 file changed, 1 insertion(+)
Johan Hovold
maintainerRe: [PATCH 3/5] dt-bindings: gnss: add w2sg0004 compatible string
In reply to Andreas KemnadeQuoted 13 lines · Andreas Kemnade
Add w2sg0004 compatible string since devices without wakeup pins are now supported.
Signed-off-by Andreas Kemnade <[email protected]>--- Documentation/devicetree/bindings/gnss/sirfstar.txt | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/gnss/sirfstar.txt +0
-0
Documentation/devicetree/bindings/gnss/sirfstar.txt Required properties: · line 17
Quoted 4 lines
Documentation/devicetree/bindings/gnss/sirfstar.txt +1
-0@@ -14,6 +14,7 @@ Required properties: "linx,r4" "wi2wi,w2sg0008i" "wi2wi,w2sg0084i" + "wi2wi,w2sg0004"
Please keep the entries sorted.
Documentation/devicetree/bindings/gnss/sirfstar.txt Required properties: · line 19
Quoted 2 lines
Documentation/devicetree/bindings/gnss/sirfstar.txt +0
-0- vcc-supply : Main voltage regulator (pin name: 3V3_IN, VCC, VDD)
Johan
RFC PATCH 4/5 gnss: sirf: add a separate supply for a lna
In reply to Andreas KemnadeDevices might have a separate lna between antenna output of the gps chip and the antenna which might have a separate supply
--- drivers/gnss/sirf.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gnss/sirf.c +15 -0
@@ -30,6 +30,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;
@@ -217,6 +218,7 @@ static int sirf_runtime_suspend(struct device *dev)if (!data->on_off)return regulator_disable (data->vcc); +regulator_disable (data->lna); ret =sirf_set_active (data, false);if (ret)
@@ -245,13 +247,20 @@ static int sirf_runtime_resume(struct device *dev)if (ret) goto err_close_serdev; } + + ret =regulator_enable (data->lna); +if (ret) + goto err_disable_vcc; + ret =sirf_set_active (data, true);if (!ret)return 0 ; +err_disable_vcc:if (!data->on_off)regulator_disable (data->vcc); + err_close_serdev:serdev_device_close (data->serdev);return ret;
@@ -340,6 +349,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))
Signature · 1 line
2.11.0
Re: [Letux-kernel] [PATCH RFC 4/5] gnss: sirf: add a separate supply for a lna
Quoted 73 lines
Am 18.11.2018 um 22:58 schrieb Andreas Kemnade <[email protected]>:
Devices might have a separate lna between antenna output of the gps chip and the antenna which might have a separate supply
Signed-off-by Andreas Kemnade <[email protected]>---
drivers/gnss/sirf.c| 15 +++++++++++++++1 file changed, 15 insertions(+)drivers/gnss/sirf.c +9
-0@@ -30,6 +30,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;@@ -217,6 +218,7 @@ static int sirf_runtime_suspend(struct device *dev)if (!data->on_off)return regulator_disable (data->vcc); +regulator_disable (data->lna); ret =sirf_set_active (data, false);if (ret)@@ -245,13 +247,20 @@ static int sirf_runtime_resume(struct device *dev)if (ret) goto err_close_serdev; } + + ret =regulator_enable (data->lna); +if (ret) + goto err_disable_vcc; + ret =sirf_set_active (data, true);if (!ret)return 0 ; +err_disable_vcc:if (!data->on_off)regulator_disable (data->vcc); +
err_close_serdev:serdev_device_close(data->serdev); return ret;drivers/gnss/sirf.c +6
-0@@ -340,6 +349,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))Signature · 7 lines
2.11.0 _______________________________________________ http://projects.goldelico.com/p/gta04-kernel/ Letux-kernel mailing list [email protected] http://lists.goldelico.com/mailman/listinfo.cgi/letux-kernel
Looks good and to do what it is designed for.
BR and thanks,
Nikolaus
Re: [PATCH RFC 4/5] gnss: sirf: add a separate supply for a lna
In reply to Andreas KemnadeHi!
Quoted 2 lines
Devices might have a separate lna between antenna output of the gps chip and the antenna which might have a separate supply
Might have.
drivers/gnss/sirf.c static int sirf_probe(struct serdev_device *serdev) · line 357
Quoted 10 lines
drivers/gnss/sirf.c +6
-0@@ -340,6 +349,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; + } +
But it is not optional in the code. Probably should be?
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [PATCH RFC 4/5] gnss: sirf: add a separate supply for a lna
Hi,
Quoted 11 lines · On Tue, 27 Nov 2018 19:03:57 +0100 Pavel Machek <[email protected]> wrote:
Hi!
Quoted 2 lines
Devices might have a separate lna between antenna output of the gps chip and the antenna which might have a separate supply
Might have.
Quoted 4 lines
drivers/gnss/sirf.c +0
-0@@ -340,6 +349,12 @@ static int sirf_probe(struct serdev_device *serdev) goto err_put_device; }
Quoted 8 lines
drivers/gnss/sirf.c static int sirf_probe(struct serdev_device *serdev) · line 357
Quoted 6 lines
drivers/gnss/sirf.c +6
-0+ data->lna =devm_regulator_get (dev,"lna" ); +if (IS_ERR (data->lna)) { + ret =PTR_ERR (data->lna); + goto err_put_device; + } +But it is not optional in the code. Probably should be?
well, if it no lna regulator is defined in the dtb, the regulator framework will return a dummy regulator. devm_regulator_get_optional() would not do that and would require more error checking in the code. But if there is some rule which says that devm_regulator_get_optional() should be used here, I can of course change that.
Before sending a v2, is that the only issue here?
Regards,
Andreas
Re: [PATCH RFC 4/5] gnss: sirf: add a separate supply for a lna
Quoted 25 lines · Andreas Kemnade
Hi,
Quoted 11 lines · On Tue, 27 Nov 2018 19:03:57 +0100 Pavel Machek <[email protected]> wrote:
Hi!
Quoted 2 lines
Devices might have a separate lna between antenna output of the gps chip and the antenna which might have a separate supply
Might have.
Quoted 4 lines
drivers/gnss/sirf.c +0
-0@@ -340,6 +349,12 @@ static int sirf_probe(struct serdev_device *serdev) goto err_put_device; }Quoted 8 lines
drivers/gnss/sirf.c static int sirf_probe(struct serdev_device *serdev) · line 357
Quoted 6 lines
drivers/gnss/sirf.c +6
-0+ data->lna =devm_regulator_get (dev,"lna" ); +if (IS_ERR (data->lna)) { + ret =PTR_ERR (data->lna); + goto err_put_device; + } +But it is not optional in the code. Probably should be?
Quoted 2 lines
well, if it no lna regulator is defined in the dtb, the regulator framework will return a dummy
Aha, did not know that detail. It is ok, then...
Quoted 4 lines
would not do that and would require more error checking in the code. But if there is some rule which says that
devm_regulator_get_optional()should be used here, I can of course change that.
Before sending a v2, is that the only issue here?
Quick look did not reveal anything else.
Best regards,
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Johan Hovold
maintainerRe: [PATCH RFC 4/5] gnss: sirf: add a separate supply for a lna
In reply to Andreas KemnadeQuoted 21 lines · Andreas Kemnade
Devices might have a separate lna between antenna output of the gps chip and the antenna which might have a separate supply
Signed-off-by Andreas Kemnade <[email protected]>--- drivers/gnss/sirf.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)drivers/gnss/sirf.c +1
-0@@ -30,6 +30,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;
drivers/gnss/sirf.c static int sirf_runtime_suspend(struct device *dev) · line 221
Quoted 4 lines
drivers/gnss/sirf.c +1
-0@@ -217,6 +218,7 @@ static int sirf_runtime_suspend(struct device *dev)if (!data->on_off)return regulator_disable (data->vcc); +regulator_disable (data->lna);
I don't think you want to disable it until the device has entered hibernate mode.
drivers/gnss/sirf.c static int sirf_runtime_resume(struct device *dev) · line 253
Quoted 11 lines
drivers/gnss/sirf.c +4
-0ret =sirf_set_active (data, false);if (ret)@@ -245,13 +247,20 @@ static int sirf_runtime_resume(struct device *dev)if (ret) goto err_close_serdev; } + + ret =regulator_enable (data->lna); +if (ret) + goto err_disable_vcc;
This one needs to be managed as vcc in the case where we have no onoff-signal connected, right? Similar for suspend of course.
drivers/gnss/sirf.c static int sirf_runtime_resume(struct device *dev) · line 263
Quoted 10 lines
drivers/gnss/sirf.c +3
-0+ ret =sirf_set_active (data, true);if (!ret)return 0 ; +err_disable_vcc:if (!data->on_off)regulator_disable (data->vcc); +
Superfluous newline.
drivers/gnss/sirf.c static int sirf_runtime_resume(struct device *dev) · line 266
Quoted 3 lines
drivers/gnss/sirf.c +0
-0err_close_serdev:serdev_device_close (data->serdev);return ret;
Johan
RFC PATCH 5/5 dt-bindings: gnss: add lna-supply property
In reply to Andreas KemnadeAdd lna-supply property.
--- Documentation/devicetree/bindings/gnss/sirfstar.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/gnss/sirfstar.txt +1 -0
@@ -30,6 +30,7 @@ Optional properties: - sirf,wakeup-gpios : GPIO used to determine device power state (pin name: RFPWRUP, WAKEUP) - timepulse-gpios : Time pulse GPIO (pin name: 1PPS, TM) +- lna-supply : Separate supply for a LNA Example:
Signature · 1 line
2.11.0
Re: [PATCH RFC 5/5] dt-bindings: gnss: add lna-supply property
Quoted 7 lines · Andreas Kemnade
Add lna-supply property.
Signed-off-by Andreas Kemnade <[email protected]>--- Documentation/devicetree/bindings/gnss/sirfstar.txt | 1 + 1 file changed, 1 insertion(+)
Johan Hovold
maintainerRe: [PATCH RFC 5/5] dt-bindings: gnss: add lna-supply property
In reply to Andreas KemnadeQuoted 12 lines · Andreas Kemnade
Add lna-supply property.
Signed-off-by Andreas Kemnade <[email protected]>--- Documentation/devicetree/bindings/gnss/sirfstar.txt | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/gnss/sirfstar.txt +0
-0
Documentation/devicetree/bindings/gnss/sirfstar.txt Optional properties: · line 33
Quoted 4 lines
Documentation/devicetree/bindings/gnss/sirfstar.txt +1
-0@@ -30,6 +30,7 @@ Optional properties: - sirf,wakeup-gpios : GPIO used to determine device power state (pin name: RFPWRUP, WAKEUP) - timepulse-gpios : Time pulse GPIO (pin name: 1PPS, TM) +- lna-supply : Separate supply for a LNA
"Supply for external LNA"?
And please keep the entries sorted.
Documentation/devicetree/bindings/gnss/sirfstar.txt Optional properties: · line 35
Quoted 2 lines
Documentation/devicetree/bindings/gnss/sirfstar.txt +0
-0Example:
Johan
Re: [PATCH RFC 5/5] dt-bindings: gnss: add lna-supply property
Quoted 8 lines · On Wed, 5 Dec 2018 16:09:39 +0100 Johan Hovold <[email protected]> wrote:
Quoted 7 lines · Andreas Kemnade
Add lna-supply property.
Signed-off-by Andreas Kemnade <[email protected]>--- Documentation/devicetree/bindings/gnss/sirfstar.txt | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
Documentation/devicetree/bindings/gnss/sirfstar.txt Optional properties: · line 33
Quoted 9 lines
Documentation/devicetree/bindings/gnss/sirfstar.txt +1
-0@@ -30,6 +30,7 @@ Optional properties: - sirf,wakeup-gpios : GPIO used to determine device power state (pin name: RFPWRUP, WAKEUP) - timepulse-gpios : Time pulse GPIO (pin name: 1PPS, TM) +- lna-supply : Separate supply for a LNA"Supply for external LNA"?
"External" might be misleading:
- not part of the gps chip itself: yes
- but might also be inside of the device.
In case of the GTA04 this includes power supply for an antenna switch (operates by plug detection) + internal or external antenna.
Regards,
Andreas
Hi,
Quoted 10 lines
Am 18.11.2018 um 22:57 schrieb Andreas Kemnade <[email protected]>:
Here is another chapter of the story to get gta04 gnss power management into the mainline kernel.
There is a w2sg0004 without wakeup line in there, so power state can only be determined indirectly by looking at the serial data lines. Then there as also an lna which needs to be powered for real gps reception. That part needs probably more discussion, since it might be an idea to have it more generalized since it has nothing todo with the chip itself.
On the other hand if we follow the "SoC is the spider in the net" way of looking at DTS hierarchy, we have the uart as a child of the SoC and the gnss receiver as a serdev child of the UART. The LNA is even one step more distantly connected to the gnss. So it makes sense to me to have it as a property/reference of the gnss chip's DTS record which is a sibling of the compatible records. So the only place where it can be reasonably processed is the driver.
Quoted 13 lines
I marked the corresponding patches as RFC. The support for the w2sg0004 without wakeup can imho go in without the lna first because users of that chip without an additional lna power supply can already benefit from it if we should do more discussion first. I just kept them together so that the full picture can be seen.
Andreas Kemnade (5):
gnss: sirf: write data to gnss only when the gnss device is open
gnss: sirf: power on logic for devices without wakeup signal
dt-bindings: gnss: add w2sg0004 compatible string
gnss: sirf: add a separate supply for a lna
dt-bindings: gnss: add lna-supply property
Quoted 12 lines
.../devicetree/bindings/gnss/sirfstar.txt| 2 +drivers/gnss/sirf.c| 126 +++++++++++++++------2 files changed, 96 insertions(+), 32 deletions(-)Signature · 7 lines
2.11.0 _______________________________________________ http://projects.goldelico.com/p/gta04-kernel/ Letux-kernel mailing list [email protected] http://lists.goldelico.com/mailman/listinfo.cgi/letux-kernel
BR,
Nikolaus
Hi,
Quoted 13 lines · On Mon, 19 Nov 2018 09:22:59 +0100 "H. Nikolaus Schaller" <[email protected]>…
Hi,
Quoted 10 lines
Am 18.11.2018 um 22:57 schrieb Andreas Kemnade <[email protected]>:
Here is another chapter of the story to get gta04 gnss power management into the mainline kernel.
There is a w2sg0004 without wakeup line in there, so power state can only be determined indirectly by looking at the serial data lines. Then there as also an lna which needs to be powered for real gps reception. That part needs probably more discussion, since it might be an idea to have it more generalized since it has nothing todo with the chip itself.
Quoted 8 lines
On the other hand if we follow the "SoC is the spider in the net" way of looking at DTS hierarchy, we have the uart as a child of the SoC and the gnss receiver as a serdev child of the UART. The LNA is even one step more distantly connected to the gnss. So it makes sense to me to have it as a property/reference of the gnss chip's DTS record which is a sibling of the compatible records. So the only place where it can be reasonably processed is the driver.
Or the lna is a child of the gnss receiver. The whole thing should probably not be overdesigned, but it does not make sense that every gnss chip driver has some lna logic.
Maybe the regulator should just be stored in the struct gnss_device and then drivers/gnss/core.c takes care.
Regards,
Andreas
Hi,
Quoted 28 lines
Am 19.11.2018 um 19:44 schrieb Andreas Kemnade <[email protected]>:
Hi,
Quoted 13 lines · On Mon, 19 Nov 2018 09:22:59 +0100 "H. Nikolaus Schaller" <[email protected]>…
Hi,
Quoted 10 lines
Am 18.11.2018 um 22:57 schrieb Andreas Kemnade <[email protected]>:
Here is another chapter of the story to get gta04 gnss power management into the mainline kernel.
There is a w2sg0004 without wakeup line in there, so power state can only be determined indirectly by looking at the serial data lines. Then there as also an lna which needs to be powered for real gps reception. That part needs probably more discussion, since it might be an idea to have it more generalized since it has nothing todo with the chip itself.Quoted 8 lines
On the other hand if we follow the "SoC is the spider in the net" way of looking at DTS hierarchy, we have the uart as a child of the SoC and the gnss receiver as a serdev child of the UART. The LNA is even one step more distantly connected to the gnss. So it makes sense to me to have it as a property/reference of the gnss chip's DTS record which is a sibling of the compatible records. So the only place where it can be reasonably processed is the driver.
Quoted 1 line
Or the lna is a child of the gnss receiver.
Well, this IMHO would assume the gnss receiver is a bus master...
Quoted 5 lines
The whole thing
should probably not be overdesigned, but it does not make sense that every gnss chip driver has some lna logic.
Maybe the regulator should just be stored in the structgnss_deviceand thendrivers/gnss/core.ctakes care.
Probably yes, but likely not difficult to refactor and generalize later if users of other chips report a similar need. More important is to get upstream support for the gta04 with this chip.
BR,
Nikolaus
Johan Hovold
maintainerQuoted 22 lines · Andreas Kemnade
Quoted 11 lines · On Mon, 19 Nov 2018 09:22:59 +0100 "H. Nikolaus Schaller" <[email protected]>…
Quoted 10 lines
Am 18.11.2018 um 22:57 schrieb Andreas Kemnade <[email protected]>:
Here is another chapter of the story to get gta04 gnss power management into the mainline kernel.
There is a w2sg0004 without wakeup line in there, so power state can only be determined indirectly by looking at the serial data lines. Then there as also an lna which needs to be powered for real gps reception. That part needs probably more discussion, since it might be an idea to have it more generalized since it has nothing todo with the chip itself.Quoted 8 lines
On the other hand if we follow the "SoC is the spider in the net" way of looking at DTS hierarchy, we have the uart as a child of the SoC and the gnss receiver as a serdev child of the UART. The LNA is even one step more distantly connected to the gnss. So it makes sense to me to have it as a property/reference of the gnss chip's DTS record which is a sibling of the compatible records. So the only place where it can be reasonably processed is the driver.
Quoted 3 lines
Or the lna is a child of the gnss receiver. The whole thing should probably not be overdesigned, but it does not make sense that every gnss chip driver has some lna logic.
Did you mean "does make sense" here?
Quoted 2 lines
Maybe the regulator should just be stored in the struct
gnss_deviceand thendrivers/gnss/core.ctakes care.
Maybe eventually, but keeping it per driver is fine for now.
As you say above, this really isn't part of the chip itself, and therefore should probably be a generic gnss property as it could be required for any receiver (in principle).
But we still need driver support for coordinating it with the rest of the receiver power management, so adding it to drivers as need arises seems reasonable.
Thanks,
Johan
Johan Hovold
maintainerQuoted 35 lines · Johan Hovold
Quoted 22 lines · Andreas Kemnade
Quoted 11 lines · On Mon, 19 Nov 2018 09:22:59 +0100 "H. Nikolaus Schaller" <[email protected]>…
Quoted 10 lines
Am 18.11.2018 um 22:57 schrieb Andreas Kemnade <[email protected]>:
Here is another chapter of the story to get gta04 gnss power management into the mainline kernel.
There is a w2sg0004 without wakeup line in there, so power state can only be determined indirectly by looking at the serial data lines. Then there as also an lna which needs to be powered for real gps reception. That part needs probably more discussion, since it might be an idea to have it more generalized since it has nothing todo with the chip itself.Quoted 8 lines
On the other hand if we follow the "SoC is the spider in the net" way of looking at DTS hierarchy, we have the uart as a child of the SoC and the gnss receiver as a serdev child of the UART. The LNA is even one step more distantly connected to the gnss. So it makes sense to me to have it as a property/reference of the gnss chip's DTS record which is a sibling of the compatible records. So the only place where it can be reasonably processed is the driver.
Quoted 3 lines
Or the lna is a child of the gnss receiver. The whole thing should probably not be overdesigned, but it does not make sense that every gnss chip driver has some lna logic.
Did you mean "does make sense" here?
Quoted 2 lines
Maybe the regulator should just be stored in the struct
gnss_deviceand thendrivers/gnss/core.ctakes care.Maybe eventually, but keeping it per driver is fine for now.
Quoted 7 lines
As you say above, this really isn't part of the chip itself, and therefore should probably be a generic gnss property as it could be required for any receiver (in principle).
But we still need driver support for coordinating it with the rest of the receiver power management, so adding it to drivers as need arises seems reasonable.
Actually, the property probably still should go into gnss.txt as a generic optional property, but driver support for it will be added as need arises.
Rob?
Thanks,
Johan