gnss: add new GNSS subsystem
Subsystems (3)
Johan Hovold
maintainercover gnss: add new GNSS subsystem
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g. /dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes and which also allows for easy detection and (eventually) identification of GNSS devices.
Note that the character-device interface provides raw access to whatever protocol the receiver is (currently) using, such as NMEA 0183, UBX or SiRF Binary. These protocols are expected to be continued to be handled by user space for the time being, even if some hybrid solutions are also conceivable (e.g. to have kernel drivers issue management commands).
This will still allow for better platform integration by allowing GNSS devices and their resources (e.g. regulators and enable-gpios) to be described by firmware and managed by kernel drivers rather than platform-specific scripts and services.
While the current interface is kept minimal, it could be extended using IOCTLs, sysfs or uevents as needs and proper abstraction levels are identified and determined (e.g. for device and feature identification).
Another possible extension is to add generic 1PPS support.
I decided to go with a custom character-device interface rather than pretend that these abstract GNSS devices are still TTY devices (e.g. /dev/ttyGNSS0). Obviously, modifying line settings or reading modem control signals does not make any sense for a device using, say, a USB (not USB-serial) or iomem interface. This also means, however, that user space would no longer be able to set the line speed to match a new port configuration that can be set using the various GNSS protocols when the underlying interface is indeed a UART; instead this would need to be taken care of by the driver.
Also note that writes are always synchronous instead of requiring user space to call tcdrain() after every command.
This all seems to work well-enough (e.g. with gpsd), but please let me know if I've overlooked something which would indeed require a TTY interface instead.
As proof-of-concept I have implemented drivers for receivers based on two common GNSS chipsets (SiRFstar and u-blox), but due to lack of hardware these have so far only been tested using mockup devices and a USB-serial-based GPS device (using out-of-tree code). [ Let me know if you've got any evalutation kits to spare. ]
Finally, note that documentation (including kerneldoc) remains to be written, but hopefully this will not hinder review given that the current interfaces are fairly self-describing.
Johan
Johan Hovold (7):
gnss: add GNSS receiver subsystem
dt-bindings: add generic gnss binding
gnss: add generic serial driver
dt-bindings: gnss: add u-blox binding
gnss: add driver for u-blox receivers
dt-bindings: gnss: add sirfstar binding
gnss: add driver for sirfstar-based receivers
.../devicetree/bindings/gnss/gnss.txt | 36 ++ .../devicetree/bindings/gnss/sirfstar.txt | 38 ++ .../devicetree/bindings/gnss/u-blox.txt | 31 ++ .../devicetree/bindings/vendor-prefixes.txt | 4 + MAINTAINERS | 7 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/gnss/Kconfig | 43 ++ drivers/gnss/Makefile | 16 + drivers/gnss/core.c | 385 ++++++++++++++++ drivers/gnss/serial.c | 288 ++++++++++++ drivers/gnss/serial.h | 47 ++ drivers/gnss/sirf.c | 415 ++++++++++++++++++ drivers/gnss/ubx.c | 133 ++++++ include/linux/gnss.h | 64 +++ 15 files changed, 1510 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/gnss.txt create mode 100644 Documentation/devicetree/bindings/gnss/sirfstar.txt create mode 100644 Documentation/devicetree/bindings/gnss/u-blox.txt create mode 100644 drivers/gnss/Kconfig create mode 100644 drivers/gnss/Makefile create mode 100644 drivers/gnss/core.c create mode 100644 drivers/gnss/serial.c create mode 100644 drivers/gnss/serial.h create mode 100644 drivers/gnss/sirf.c create mode 100644 drivers/gnss/ubx.c create mode 100644 include/linux/gnss.h
Signature · 1 line
2.17.0
Johan Hovold
maintainerPATCH 1/7 gnss: add GNSS receiver subsystem
Add a new subsystem for GNSS (e.g. GPS) receivers.
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g. /dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes.
Note that the character-device interface provides raw access to whatever protocol the receiver is (currently) using, such as NMEA 0183, UBX or SiRF Binary. These protocols are expected to be continued to be handled by user space for the time being, even if some hybrid solutions are also conceivable (e.g. to have kernel drivers issue management commands).
This will still allow for better platform integration by allowing GNSS devices and their resources (e.g. regulators and enable-gpios) to be described by firmware and managed by kernel drivers rather than platform-specific scripts and services.
While the current interface is kept minimal, it could be extended using IOCTLs, sysfs or uevents as needs and proper abstraction levels are identified and determined (e.g. for device and feature identification).
--- MAINTAINERS | 6 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/gnss/Kconfig | 11 ++ drivers/gnss/Makefile | 7 + drivers/gnss/core.c | 385 ++++++++++++++++++++++++++++++++++++++++++ include/linux/gnss.h | 64 +++++++ 7 files changed, 476 insertions(+) create mode 100644 drivers/gnss/Kconfig create mode 100644 drivers/gnss/Makefile create mode 100644 drivers/gnss/core.c create mode 100644 include/linux/gnss.h
MAINTAINERS +6 -0
@@ -5962,6 +5962,12 @@ F: Documentation/isdn/README.gigaset F: drivers/isdn/gigaset/ F: include/uapi/linux/gigaset_dev.h +GNSS SUBSYSTEM +M: Johan Hovold <[email protected]> +S: Maintained +F: drivers/gnss/ +F: include/linux/gnss.h + GO7007 MPEG CODEC M: Hans Verkuil <[email protected]> L: [email protected]
drivers/Kconfig +2 -0
@@ -9,6 +9,8 @@ source "drivers/bus/Kconfig" source "drivers/connector/Kconfig" +source "drivers/gnss/Kconfig" + source "drivers/mtd/Kconfig" source "drivers/of/Kconfig"
drivers/Makefile +1 -0
@@ -185,3 +185,4 @@ obj-$(CONFIG_TEE) += tee/ obj-$(CONFIG_MULTIPLEXER) += mux/ obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/ obj-$(CONFIG_SIOX) += siox/ +obj-$(CONFIG_GNSS) += gnss/
drivers/gnss/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# +# GNSS receiver configuration +# + +menuconfig GNSS + tristate "GNSS receiver support" + ---help--- + Say Y here if you have a GNSS receiver (e.g. a GPS receiver). + + To compile this driver as a module, choose M here: the module will + be called gnss.
drivers/gnss/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the GNSS subsystem. +# + +obj-$(CONFIG_GNSS) += gnss.o +gnss-y := core.o
drivers/gnss/core.c new file +385 -0
385 lines not on this page · raw message
include/linux/gnss.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.17.0
Greg Kroah-Hartman
maintainerRe: [PATCH 1/7] gnss: add GNSS receiver subsystem
Quoted 1 line · Johan Hovold
+#define
GNSS_MINORS16
Why only 16? Just have to start somewhere?
Quoted 12 lines
drivers/gnss/core.c new file +12
-0+static DEFINE_IDA (gnss_minors); +static dev_t gnss_first; + +/* FIFO size must be a power of two */ +#define GNSS_READ_FIFO_SIZE 4096 +#define GNSS_WRITE_BUF_SIZE 1024 + +#define to_gnss_device (d) container_of((d), struct gnss_device, dev) + +static int gnss_open (struct inode *inode,struct file *file) +{ +struct gnss_device *gdev;
drivers/gnss/core.c line 46
Quoted 10 lines
drivers/gnss/core.c new file +10
-0+int ret =0 ; + + gdev = container_of(inode->i_cdev, struct gnss_device, cdev); + +get_device (&gdev->dev); + +nonseekable_open (inode, file); + file->private_data = gdev; + +down_write (&gdev->rwsem);
Just curious, why a rwsem? They can be slower than a normal semaphore, is this really a contentious lock?
drivers/gnss/core.c line 55
Quoted 9 lines
drivers/gnss/core.c new file +9
-0+if (gdev->disconnected) { + ret = -ENODEV ; + goto unlock; + } + +if (gdev->count++ ==0 ) { + ret = gdev->ops->open (gdev); +if (ret) + gdev->count--;
Why do we care about the opens here? Do you only want the "child driver" to have open called once, like a tty driver? Does it matter?
Again, just curious.
drivers/gnss/core.c line 68
Quoted 13 lines
drivers/gnss/core.c new file +13
-0+ } +unlock: +up_write (&gdev->rwsem); + +if (ret) + goto err_put_device; + +return 0 ; + +err_put_device: +put_device (&gdev->dev); + +return ret;
Those last 9 lines can be rewritten as just:
if (!ret) put_device(&gdev->dev); return ret;
Quoted 60 lines
drivers/gnss/core.c new file +60
-0+} + +static int gnss_release (struct inode *inode,struct file *file) +{ +struct gnss_device *gdev = file->private_data; + +down_write (&gdev->rwsem); +if (gdev->disconnected) + goto unlock; + +if (--gdev->count ==0 ) { + gdev->ops->close (gdev); +kfifo_reset (&gdev->read_fifo); + } +unlock: +up_write (&gdev->rwsem); + +put_device (&gdev->dev); + +return 0 ; +} + +static ssize_t gnss_read (struct file *file,char __user *buf, +size_t count,loff_t *pos) +{ +struct gnss_device *gdev = file->private_data; +unsigned int copied; +int ret; + +mutex_lock (&gdev->read_mutex); +while (kfifo_is_empty (&gdev->read_fifo)) { +mutex_unlock (&gdev->read_mutex); + +if (gdev->disconnected) +return 0 ; + +if (file->f_flags &O_NONBLOCK ) +return -EAGAIN ; + + ret =wait_event_interruptible (gdev->read_queue, + gdev->disconnected || + !kfifo_is_empty (&gdev->read_fifo)); +if (ret) +return -ERESTARTSYS ; + +mutex_lock (&gdev->read_mutex); + } + + ret =kfifo_to_user (&gdev->read_fifo, buf, count, &copied); +if (ret) + goto out_unlock; + + ret = copied; + +dev_dbg (&gdev->dev,"%s - count = %zu\n" , __func__, copied); + +out_unlock: +mutex_unlock (&gdev->read_mutex); + +return ret;
drivers/gnss/core.c line 138
Quoted 10 lines
drivers/gnss/core.c new file +10
-0+} + +static ssize_t gnss_write (struct file *file,const char __user *buf, +size_t count,loff_t *pos) +{ +struct gnss_device *gdev = file->private_data; +size_t written =0 ; +int ret; + +dev_dbg (&gdev->dev,"%s - count = %zu\n" , __func__, count);
Nit, some of these initial dev_dbg() calls might be able to be removed, as ftrace should handle the tracing code now, right?
Quoted 134 lines
drivers/gnss/core.c new file +134
-0+ +if (gdev->disconnected) { +dev_dbg (&gdev->dev,"%s - disconnected\n" , __func__); +return -EIO ; + } + +if (!count) +return 0 ; + +if (!gdev->ops->write_raw) +return -EIO ; + +/* Ignoring O_NONBLOCK, write_raw() is synchronous. */ + + ret =mutex_lock_interruptible (&gdev->write_mutex); +if (ret) +return -ERESTARTSYS ; + +for (;;) { +size_t n = count - written; + +if (n >GNSS_WRITE_BUF_SIZE ) + n =GNSS_WRITE_BUF_SIZE ; + +if (copy_from_user (gdev->write_buf, buf, n)) { + ret = -EFAULT ; + goto out_unlock; + } + +/* +* Assumes write_raw can always accept GNSS_WRITE_BUF_SIZE +* bytes. +* +* FIXME: revisit +*/ +down_read (&gdev->rwsem); +if (!gdev->disconnected) + ret = gdev->ops->write_raw (gdev, gdev->write_buf, n); +else + ret = -EIO ; +up_read (&gdev->rwsem); + +if (ret <0 ) +break ; + + written += ret; + buf += ret; + +if (written == count) +break ; + } + +if (written) + ret = written; +out_unlock: +mutex_unlock (&gdev->write_mutex); + +return ret; +} + +static __poll_t gnss_poll (struct file *file,poll_table *wait) +{ +struct gnss_device *gdev = file->private_data; +__poll_t mask =0 ; + +poll_wait (file, &gdev->read_queue, wait); + +if (!kfifo_is_empty (&gdev->read_fifo)) + mask |=EPOLLIN |EPOLLRDNORM ; +if (gdev->disconnected) + mask |=EPOLLHUP ; + +dev_dbg (&gdev->dev,"%s - mask = 0x%04x\n" , __func__, mask); + +return mask; +} + +static const struct file_operations gnss_fops = { + .owner =THIS_MODULE , + .open = gnss_open, + .release = gnss_release, + .read = gnss_read, + .write = gnss_write, + .poll = gnss_poll, + .llseek = no_llseek, +}; + +static struct class *gnss_class; + +static void gnss_device_release (struct device *dev) +{ +struct gnss_device *gdev =to_gnss_device (dev); + +dev_dbg (dev,"%s\n" , __func__); + +kfree (gdev->write_buf); +kfifo_free (&gdev->read_fifo); +ida_simple_remove (&gnss_minors, gdev->id); +kfree (gdev); +} + +struct gnss_device *gnss_allocate_device (struct device *parent) +{ +struct gnss_device *gdev; +struct device *dev; +int id; +int ret; + + gdev =kzalloc (sizeof (*gdev),GFP_KERNEL ); +if (!gdev) +return NULL ; + + id =ida_simple_get (&gnss_minors,0 ,GNSS_MINORS ,GFP_KERNEL ); +if (id <0 ) { +kfree (gdev); +return ERR_PTR (id); + } + + gdev->id = id; + + dev = &gdev->dev; +device_initialize (dev); + dev->devt = gnss_first + id; + dev->class = gnss_class; + dev->parent = parent; + dev->release = gnss_device_release; +dev_set_drvdata (dev, gdev); +dev_set_name (dev,"gnss%d" , id); + +init_rwsem (&gdev->rwsem); +mutex_init (&gdev->read_mutex); +mutex_init (&gdev->write_mutex); +init_waitqueue_head (&gdev->read_queue); +
drivers/gnss/core.c line 282
Quoted 10 lines
drivers/gnss/core.c new file +10
-0+ ret =kfifo_alloc (&gdev->read_fifo,GNSS_READ_FIFO_SIZE ,GFP_KERNEL ); +if (ret) + goto err_put_device; + + gdev->write_buf =kzalloc (GNSS_WRITE_BUF_SIZE ,GFP_KERNEL ); +if (!gdev->write_buf) + goto err_put_device; + +cdev_init (&gdev->cdev, &gnss_fops); + gdev->cdev.owner =THIS_MODULE ;
This protects this module from being unloaded, but how do you pass on the module reference counts to the "child" gnss driver? Am I just missing that logic here somewhere?
Anyway, minor things, this looks really clean, nice job.
greg k-h
Johan Hovold
maintainerRe: [PATCH 1/7] gnss: add GNSS receiver subsystem
Quoted 4 lines · Greg Kroah-Hartman
Quoted 1 line · Johan Hovold
+#define
GNSS_MINORS16Why only 16? Just have to start somewhere?
Yeah, a mostly arbitrarily picked number. I figured only developers would have an interest in having even that many GNSS receivers in one system. But it can be raised, now or later.
Quoted 8 lines
Quoted 8 lines
drivers/gnss/core.c new file +8
-0+static int gnss_open (struct inode *inode,struct file *file) +{ +struct gnss_device *gdev; +int ret =0 ; + + gdev = container_of(inode->i_cdev, struct gnss_device, cdev); + +get_device (&gdev->dev);
Quoted 8 lines
drivers/gnss/core.c line 46
Quoted 5 lines
drivers/gnss/core.c new file +5
-0+ +nonseekable_open (inode, file); + file->private_data = gdev; + +down_write (&gdev->rwsem);Just curious, why a rwsem? They can be slower than a normal semaphore, is this really a contentious lock?
I use the rwsem to deal with hotplugging; the underlying device can go away at any time and the core makes sure that no further calls into the corresponding driver is made once all currently executing callbacks return.
Quoted 4 lines
Quoted 4 lines
drivers/gnss/core.c new file +4
-0+if (gdev->disconnected) { + ret = -ENODEV ; + goto unlock; + }
Quoted 8 lines
drivers/gnss/core.c line 55
Quoted 5 lines
drivers/gnss/core.c new file +5
-0+ +if (gdev->count++ ==0 ) { + ret = gdev->ops->open (gdev); +if (ret) + gdev->count--;Why do we care about the opens here? Do you only want the "child driver" to have open called once, like a tty driver? Does it matter?
Exactly, core deals with the open counts so that the individual gnss drivers need not. Serdev, for example, blows up if you try to open the same device twice.
Quoted 18 lines
Again, just curious.
drivers/gnss/core.c line 68
Quoted 13 lines
drivers/gnss/core.c new file +13
-0+ } +unlock: +up_write (&gdev->rwsem); + +if (ret) + goto err_put_device; + +return 0 ; + +err_put_device: +put_device (&gdev->dev); + +return ret;Those last 9 lines can be rewritten as just:
Quoted 4 lines
if (!ret) put_device(&gdev->dev); return ret;
Yeah, I usually prefer having an explicit return 0 in the success path and clearly separate the error paths even if it adds few extra lines. This case could become an exception though.
Quoted 11 lines
drivers/gnss/core.c line 138
Quoted 8 lines
drivers/gnss/core.c new file +8
-0+static ssize_t gnss_write (struct file *file,const char __user *buf, +size_t count,loff_t *pos) +{ +struct gnss_device *gdev = file->private_data; +size_t written =0 ; +int ret; + +dev_dbg (&gdev->dev,"%s - count = %zu\n" , __func__, count);Nit, some of these initial
dev_dbg()calls might be able to be removed, as ftrace should handle the tracing code now, right?
Right. The were probably mostly useful to me during development, and can be added back later if it turns out they have any further value.
Quoted 49 lines
Quoted 49 lines
drivers/gnss/core.c new file +48
-0+static const struct file_operations gnss_fops = { + .owner =THIS_MODULE , + .open = gnss_open, + .release = gnss_release, + .read = gnss_read, + .write = gnss_write, + .poll = gnss_poll, + .llseek = no_llseek, +}; +struct gnss_device *gnss_allocate_device (struct device *parent) +{ +struct gnss_device *gdev; +struct device *dev; +int id; +int ret; + + gdev =kzalloc (sizeof (*gdev),GFP_KERNEL ); +if (!gdev) +return NULL ; + + id =ida_simple_get (&gnss_minors,0 ,GNSS_MINORS ,GFP_KERNEL ); +if (id <0 ) { +kfree (gdev); +return ERR_PTR (id); + } + + gdev->id = id; + + dev = &gdev->dev; +device_initialize (dev); + dev->devt = gnss_first + id; + dev->class = gnss_class; + dev->parent = parent; + dev->release = gnss_device_release; +dev_set_drvdata (dev, gdev); +dev_set_name (dev,"gnss%d" , id); + +init_rwsem (&gdev->rwsem); +mutex_init (&gdev->read_mutex); +mutex_init (&gdev->write_mutex); +init_waitqueue_head (&gdev->read_queue); + + ret =kfifo_alloc (&gdev->read_fifo,GNSS_READ_FIFO_SIZE ,GFP_KERNEL ); +if (ret) + goto err_put_device; + + gdev->write_buf =kzalloc (GNSS_WRITE_BUF_SIZE ,GFP_KERNEL ); +if (!gdev->write_buf)
Quoted 8 lines
drivers/gnss/core.c line 282
Quoted 4 lines
drivers/gnss/core.c new file +4
-0+ goto err_put_device; + +cdev_init (&gdev->cdev, &gnss_fops); + gdev->cdev.owner =THIS_MODULE ;This protects this module from being unloaded, but how do you pass on the module reference counts to the "child" gnss driver? Am I just missing that logic here somewhere?
Due to the hotplug support mentioned above, I do not need to pin the "child" gnss driver modules. Their devices can go away at any time, be it due to hotplugging, driver unbind through sysfs, or module unload.
Quoted 1 line
Anyway, minor things, this looks really clean, nice job.
Thanks again!
Johan
Johan Hovold
maintainerRe: [PATCH 1/7] gnss: add GNSS receiver subsystem
Quoted 20 lines · Johan Hovold
Quoted 18 lines · Greg Kroah-Hartman
drivers/gnss/core.c line 46
Quoted 13 lines · Johan Hovold
drivers/gnss/core.c new file +13
-0+static int gnss_open (struct inode *inode,struct file *file) +{ +struct gnss_device *gdev; +int ret =0 ; + + gdev = container_of(inode->i_cdev, struct gnss_device, cdev); + +get_device (&gdev->dev); + +nonseekable_open (inode, file); + file->private_data = gdev; + +down_write (&gdev->rwsem);Just curious, why a rwsem? They can be slower than a normal semaphore, is this really a contentious lock?
Quoted 4 lines
I use the rwsem to deal with hotplugging; the underlying device can go away at any time and the core makes sure that no further calls into the corresponding driver is made once all currently executing callbacks return.
I just did find one access to the gnss ops which was unsafe however; the existence check for a write_raw callback in write() needs to be replaced by a device flag.
Thanks,
Johan
Greg Kroah-Hartman
maintainerRe: [PATCH 1/7] gnss: add GNSS receiver subsystem
Quoted 21 lines · Johan Hovold
Quoted 20 lines · Johan Hovold
Quoted 18 lines · Greg Kroah-Hartman
drivers/gnss/core.c line 46
Quoted 13 lines · Johan Hovold
drivers/gnss/core.c new file +13
-0+static int gnss_open (struct inode *inode,struct file *file) +{ +struct gnss_device *gdev; +int ret =0 ; + + gdev = container_of(inode->i_cdev, struct gnss_device, cdev); + +get_device (&gdev->dev); + +nonseekable_open (inode, file); + file->private_data = gdev; + +down_write (&gdev->rwsem);Just curious, why a rwsem? They can be slower than a normal semaphore, is this really a contentious lock?
Quoted 8 lines
Quoted 4 lines
I use the rwsem to deal with hotplugging; the underlying device can go away at any time and the core makes sure that no further calls into the corresponding driver is made once all currently executing callbacks return.
I just did find one access to the gnss ops which was unsafe however; the existence check for a
write_rawcallback inwrite()needs to be replaced by a device flag.
Ok, in looking at this closer, it makes more sense to me, and my worries are not true, you are handling this properly, sorry for the noise.
I'll wait for the next resend of this series to review it again and consider merging it.
thanks,
greg k-h
Johan Hovold
maintainerRe: [PATCH 1/7] gnss: add GNSS receiver subsystem
Quoted 2 lines · Greg Kroah-Hartman
I'll wait for the next resend of this series to review it again and consider merging it.
Thanks, I'll send a v2 sometime next week.
Johan
Johan Hovold
maintainerPATCH 2/7 dt-bindings: add generic gnss binding
In reply to Johan HovoldDescribe generic properties for GNSS receivers.
--- .../devicetree/bindings/gnss/gnss.txt | 36 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/gnss.txt
Documentation/devicetree/bindings/gnss/gnss.txt new file +36 -0
@@ -0,0 +1,36 @@ +GNSS Receiver DT binding + +This documents the binding structure and common properties for GNSS receiver +devices. + +A GNSS receiver node is a node named "gnss" and typically resides on a serial +bus (e.g. UART, I2C or SPI). + +Please refer to the following documents for generic properties: + + Documentation/devicetree/bindings/serial/slave-device.txt + Documentation/devicetree/bindings/spi/spi-bus.txt + +Required Properties: + +- compatible : A string reflecting the vendor and specific device the node + represents + +Optional Properties: +- enable-gpios : GPIO used to power on (or off) the device +- timepulse-gpios : Timepulse (e.g. 1PPS) GPIO + +Example: + +serial@1234 { + compatible = "ns16550a"; + + gnss { + compatible = "u-blox,neo-8"; + + vcc-supply = <&gnss_reg>; + timepulse-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + + current-speed = <4800>; + }; +};
MAINTAINERS +1 -0
@@ -5965,6 +5965,7 @@ F: include/uapi/linux/gigaset_dev.h GNSS SUBSYSTEM M: Johan Hovold <[email protected]> S: Maintained +F: Documentation/devicetree/bindings/gnss/ F: drivers/gnss/ F: include/linux/gnss.h
Signature · 1 line
2.17.0
Re: [PATCH 2/7] dt-bindings: add generic gnss binding
Quoted 8 lines · Johan Hovold
Describe generic properties for GNSS receivers.
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/gnss/gnss.txt | 36 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/gnss.txt
Johan Hovold
maintainerPATCH 3/7 gnss: add generic serial driver
In reply to Johan HovoldAdd a generic serial GNSS driver (library) which provides a common implementation for the gnss interface and power management (runtime and system suspend). This allows GNSS drivers for specific chip to be implemented by simply providing a set_power() callback to handle three
states: ACTIVE, STANDBY and OFF.
--- drivers/gnss/Kconfig | 7 + drivers/gnss/Makefile | 3 + drivers/gnss/serial.c | 288 ++++++++++++++++++++++++++++++++++++++++++ drivers/gnss/serial.h | 47 +++++++ 4 files changed, 345 insertions(+) create mode 100644 drivers/gnss/serial.c create mode 100644 drivers/gnss/serial.h
drivers/gnss/Kconfig +7 -0
@@ -9,3 +9,10 @@ menuconfig GNSS To compile this driver as a module, choose M here: the module will be called gnss. + +if GNSS + +config GNSS_SERIAL + tristate + +endif # GNSS
drivers/gnss/Makefile +3 -0
@@ -5,3 +5,6 @@ obj-$(CONFIG_GNSS) += gnss.o gnss-y := core.o + +obj-$(CONFIG_GNSS_SERIAL) += gnss-serial.o +gnss-serial-y := serial.o
drivers/gnss/serial.c new file +288 -0
288 lines not on this page · raw message
drivers/gnss/serial.h new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.17.0
Greg Kroah-Hartman
maintainerRe: [PATCH 3/7] gnss: add generic serial driver
Quoted 21 lines · Johan Hovold
Add a generic serial GNSS driver (library) which provides a common implementation for the gnss interface and power management (runtime and system suspend). This allows GNSS drivers for specific chip to be implemented by simply providing a
set_power()callback to handle three
states: ACTIVE, STANDBY and OFF.Signed-off-by Johan Hovold <[email protected]>--- drivers/gnss/Kconfig | 7 + drivers/gnss/Makefile | 3 + drivers/gnss/serial.c | 288 ++++++++++++++++++++++++++++++++++++++++++ drivers/gnss/serial.h | 47 +++++++ 4 files changed, 345 insertions(+) create mode 100644 drivers/gnss/serial.c create mode 100644 drivers/gnss/serial.hdrivers/gnss/Kconfig +0
-0
drivers/gnss/Kconfig menuconfig GNSS · line 17
Quoted 9 lines
drivers/gnss/Kconfig +6
-0@@ -9,3 +9,10 @@ menuconfig GNSS To compile this driver as a module, choose M here: the module will be called gnss. + +if GNSS + +config GNSS_SERIAL + tristate +
Maybe a real help entry? Or is this only selected from child drivers? I haven't gotten that far in the series, sorry...
Johan Hovold
maintainerRe: [PATCH 3/7] gnss: add generic serial driver
Quoted 23 lines · Greg Kroah-Hartman
Quoted 22 lines · Johan Hovold
Add a generic serial GNSS driver (library) which provides a common implementation for the gnss interface and power management (runtime and system suspend). This allows GNSS drivers for specific chip to be implemented by simply providing a
set_power()callback to handle three
states: ACTIVE, STANDBY and OFF.Signed-off-by Johan Hovold <[email protected]>--- drivers/gnss/Kconfig | 7 + drivers/gnss/Makefile | 3 + drivers/gnss/serial.c | 288 ++++++++++++++++++++++++++++++++++++++++++ drivers/gnss/serial.h | 47 +++++++ 4 files changed, 345 insertions(+) create mode 100644 drivers/gnss/serial.c create mode 100644 drivers/gnss/serial.hdrivers/gnss/Kconfig +0
-0@@ -9,3 +9,10 @@ menuconfig GNSS
Quoted 11 lines
drivers/gnss/Kconfig menuconfig GNSS · line 17
Quoted 8 lines
drivers/gnss/Kconfig +6
-0To compile this driver as a module, choose M here: the module will be called gnss. + +if GNSS + +config GNSS_SERIAL + tristate +Maybe a real help entry? Or is this only selected from child drivers? I haven't gotten that far in the series, sorry...
Correct, it's only selected by child drivers.
Johan
Greg Kroah-Hartman
maintainerRe: [PATCH 3/7] gnss: add generic serial driver
In reply to Johan Hovolddrivers/gnss/serial.h line 45
Quoted 4 lines · Johan Hovold
drivers/gnss/serial.h new file +4
-0+static inline void *gnss_serial_get_drvdata (struct gnss_serial *gserial) +{ +return &gserial[1 ]; +}
Oh that's the best hack I have seen in a long time. I need to remember that one for next time.
Anyway, in reading this driver, I don't think the module reference counting is being handled here, so you might want to add that to the gnss core to keep things from going south if modules are unloaded.
thanks,
greg k-h
Johan Hovold
maintainerRe: [PATCH 3/7] gnss: add generic serial driver
Quoted 9 lines · Greg Kroah-Hartman
drivers/gnss/serial.h line 45
Quoted 4 lines · Johan Hovold
drivers/gnss/serial.h new file +4
-0+static inline void *gnss_serial_get_drvdata (struct gnss_serial *gserial) +{ +return &gserial[1 ]; +}Oh that's the best hack I have seen in a long time. I need to remember that one for next time.
Quoted 3 lines
Anyway, in reading this driver, I don't think the module reference counting is being handled here, so you might want to add that to the gnss core to keep things from going south if modules are unloaded.
As I just mentioned in my reply to your comment about module references in core, I think I got this covered through the hotplug support. Devices can go away at anytime, including through a module unload.
Thanks,
Johan
Johan Hovold
maintainerPATCH 4/7 dt-bindings: gnss: add u-blox binding
In reply to Johan HovoldAdd binding for u-blox GNSS receivers.
Note that the u-blox product names encodes form factor (e.g. "neo"), chipset (e.g. "8") and variant (e.g. "q"), but that only formfactor and chipset is used for the compatible strings (for now).
--- .../devicetree/bindings/gnss/u-blox.txt | 31 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/u-blox.txt
Documentation/devicetree/bindings/gnss/u-blox.txt new file +31 -0
@@ -0,0 +1,31 @@ +u-blox GNSS Receiver DT binding + +The u-blox GNSS receivers can use UART, DDC (I2C), SPI and USB interfaces. + +Please see Documentation/devicetree/bindings/gnss/gnss.txt for generic +properties. + +Required Properties: + +- compatible : Must be one of + + "u-blox,neo-8" + "u-blox,neo-m8" + +- vcc-supply : Main voltage regulator (VCC) + +Optional Properties: + +- timepulse-gpios : Timepulse (e.g. 1PPS) GPIO (TIMEPULSE) + +Example: + +serial@1234 { + compatible = "ns16550a"; + + gnss { + compatible = "u-blox,neo-8"; + + vcc-supply = <&gnss_reg>; + }; +};
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -374,6 +374,7 @@ tronsmart Tronsmart truly Truly Semiconductors Limited tsd Theobroma Systems Design und Consulting GmbH tyan Tyan Computer Corporation +u-blox u-blox ucrobotics uCRobotics ubnt Ubiquiti Networks udoo Udoo
Signature · 1 line
2.17.0
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 24 lines · Johan Hovold
Add binding for u-blox GNSS receivers.
Note that the u-blox product names encodes form factor (e.g. "neo"), chipset (e.g. "8") and variant (e.g. "q"), but that only formfactor and chipset is used for the compatible strings (for now).
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/gnss/u-blox.txt | 31 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/u-blox.txtDocumentation/devicetree/bindings/gnss/u-blox.txt new file +5
-0@@ -0,0 +1,31 @@ +u-blox GNSS Receiver DT binding + +The u-blox GNSS receivers can use UART, DDC (I2C), SPI and USB interfaces. + +Please see Documentation/devicetree/bindings/gnss/gnss.txt for generic
Documentation/devicetree/bindings/gnss/u-blox.txt line 15
Quoted 10 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +10
-0+properties. + +Required Properties: + +- compatible : Must be one of + + "u-blox,neo-8" + "u-blox,neo-m8" + +- vcc-supply : Main voltage regulator (VCC)
What about V_BCKP?
Documentation/devicetree/bindings/gnss/u-blox.txt line 17
Quoted 2 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +2
-0+ +Optional Properties:
reg is required if using I2C, SPI, or USB.
Datasheet also shows an interrupt pin.
Documentation/devicetree/bindings/gnss/u-blox.txt line 19
Quoted 2 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +2
-0+ +- timepulse-gpios : Timepulse (e.g. 1PPS) GPIO (TIMEPULSE)
Why the 3rd "TIMEPULSE"?
Quoted 27 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +12
-0+ +Example: + +serial@1234 { + compatible = "ns16550a"; + + gnss { + compatible = "u-blox,neo-8"; + + vcc-supply = <&gnss_reg>; + }; +};Documentation/devicetree/bindings/vendor-prefixes.txt +1
-1@@ -374,6 +374,7 @@ tronsmart Tronsmart truly Truly Semiconductors Limited tsd Theobroma Systems Design und Consulting GmbH tyan Tyan Computer Corporation +u-blox u-blox ucrobotics uCRobotics ubnt Ubiquiti Networks udoo Udoo --2.17.0
Johan Hovold
maintainerRe: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 29 lines · Rob Herring
Quoted 28 lines · Johan Hovold
Add binding for u-blox GNSS receivers.
Note that the u-blox product names encodes form factor (e.g. "neo"), chipset (e.g. "8") and variant (e.g. "q"), but that only formfactor and chipset is used for the compatible strings (for now).
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/gnss/u-blox.txt | 31 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/u-blox.txtDocumentation/devicetree/bindings/gnss/u-blox.txt new file +9
-0@@ -0,0 +1,31 @@ +u-blox GNSS Receiver DT binding + +The u-blox GNSS receivers can use UART, DDC (I2C), SPI and USB interfaces. + +Please see Documentation/devicetree/bindings/gnss/gnss.txt for generic +properties. + +Required Properties: +
Quoted 8 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 15
Quoted 6 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +6
-0+- compatible : Must be one of + + "u-blox,neo-8" + "u-blox,neo-m8" + +- vcc-supply : Main voltage regulator (VCC)What about
V_BCKP?
That's the backup supply for for the RTC and batter-backed RAM. In configurations where a battery is not used it should be connected to VCC.
How would you model that? I can enable a vbckp regulator at probe, but what if someone then accurately describes the corresponding pin as being connected to VCC? I guess we can check if the regulators are identical, and then just have the driver ignore V_BKUP. Knowing whether there is a (hopefully charged) battery connected could be useful.
I can't seem to find any other bindings that describe battery supplies, but I'll add it here.
Quoted 4 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 17
Quoted 2 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +2
-0+ +Optional Properties:reg is required if using I2C, SPI, or USB.
I'll add that (even if there is no driver support for these yet).
Quoted 1 line
Datasheet also shows an interrupt pin.
Not used currently, but I'll add it to the binding as well.
Quoted 4 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 19
Quoted 2 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +2
-0+ +- timepulse-gpios : Timepulse (e.g. 1PPS) GPIO (TIMEPULSE)Why the 3rd "TIMEPULSE"?
That's the pin name, which in this case is identical to the property name, so I'll drop it here.
Take a look at the sirf binding; vendors use different names for their timepulse pins and in that case I added the actual pin names (1PPS, TM) in parenthesis after the description.
Note that I mentioned "timepulse-gpios" in the generic binding with the intent of trying to enforce a generic name for pins with such a function (similarly for "enable-gpios", which I guess is already established).
Thanks,
Johan
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 39 lines · Johan Hovold
Quoted 29 lines · Rob Herring
Quoted 28 lines · Johan Hovold
Add binding for u-blox GNSS receivers.
Note that the u-blox product names encodes form factor (e.g. "neo"), chipset (e.g. "8") and variant (e.g. "q"), but that only formfactor and chipset is used for the compatible strings (for now).
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/gnss/u-blox.txt | 31 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/u-blox.txtDocumentation/devicetree/bindings/gnss/u-blox.txt new file +9
-0@@ -0,0 +1,31 @@ +u-blox GNSS Receiver DT binding + +The u-blox GNSS receivers can use UART, DDC (I2C), SPI and USB interfaces. + +Please see Documentation/devicetree/bindings/gnss/gnss.txt for generic +properties. + +Required Properties: +Quoted 8 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 15
Quoted 6 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +6
-0+- compatible : Must be one of + + "u-blox,neo-8" + "u-blox,neo-m8" + +- vcc-supply : Main voltage regulator (VCC)What about
V_BCKP?
Quoted 7 lines
That's the backup supply for for the RTC and batter-backed RAM. In configurations where a battery is not used it should be connected to VCC.
How would you model that? I can enable a vbckp regulator at probe, but what if someone then accurately describes the corresponding pin as being connected to VCC?
You mean how to model a battery? It would just be a 'regulator' because the regulator binding covers any supply really.
Then you just set both rails to the same supply phandle.
Quoted 3 lines
I guess we can check if the regulators are identical,
and then just have the driver ignoreV_BKUP. Knowing whether there is a (hopefully charged) battery connected could be useful.
Regulators are ref counted, so just enable it twice. Or the driver can just ignore it until it supports battery backup.
Quoted 2 lines
I can't seem to find any other bindings that describe battery supplies, but I'll add it here.
There must be some. But then the battery and charger bindings are not in the best shape.
Quoted 11 lines
Quoted 4 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 17
Quoted 2 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +2
-0+ +Optional Properties:reg is required if using I2C, SPI, or USB.
I'll add that (even if there is no driver support for these yet).
Quoted 1 line
Datasheet also shows an interrupt pin.
Not used currently, but I'll add it to the binding as well.
Quoted 7 lines
Quoted 4 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 19
Quoted 2 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +2
-0+ +- timepulse-gpios : Timepulse (e.g. 1PPS) GPIO (TIMEPULSE)Why the 3rd "TIMEPULSE"?
That's the pin name, which in this case is identical to the property name, so I'll drop it here.
Then what is the 2nd "Timepulse"?
Maybe just a "pin name: X" prefix so it is clear.
Quoted 8 lines
Take a look at the sirf binding; vendors use different names for their timepulse pins and in that case I added the actual pin names (1PPS, TM) in parenthesis after the description.
Note that I mentioned "timepulse-gpios" in the generic binding with the intent of trying to enforce a generic name for pins with such a function (similarly for "enable-gpios", which I guess is already established).
Yes, I think that's good.
Though with the enable-gpios I was debating the name for sirfstar a bit because it isn't the normal drive it active to enable, but rather a pulse to enable or disable.
Rob
Johan Hovold
maintainerRe: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 44 lines · Rob Herring
Quoted 43 lines · Johan Hovold
Quoted 29 lines · Rob Herring
Quoted 28 lines · Johan Hovold
Add binding for u-blox GNSS receivers.
Note that the u-blox product names encodes form factor (e.g. "neo"), chipset (e.g. "8") and variant (e.g. "q"), but that only formfactor and chipset is used for the compatible strings (for now).
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/gnss/u-blox.txt | 31 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/u-blox.txtDocumentation/devicetree/bindings/gnss/u-blox.txt new file +9
-0@@ -0,0 +1,31 @@ +u-blox GNSS Receiver DT binding + +The u-blox GNSS receivers can use UART, DDC (I2C), SPI and USB interfaces. + +Please see Documentation/devicetree/bindings/gnss/gnss.txt for generic +properties. + +Required Properties: +Quoted 8 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 15
Quoted 6 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +6
-0+- compatible : Must be one of + + "u-blox,neo-8" + "u-blox,neo-m8" + +- vcc-supply : Main voltage regulator (VCC)What about
V_BCKP?That's the backup supply for for the RTC and batter-backed RAM. In configurations where a battery is not used it should be connected to VCC.
Quoted 8 lines
Quoted 3 lines
How would you model that? I can enable a vbckp regulator at probe, but what if someone then accurately describes the corresponding pin as being connected to VCC?
You mean how to model a battery? It would just be a 'regulator' because the regulator binding covers any supply really.
Then you just set both rails to the same supply phandle.
Yes, but...
Quoted 6 lines
Quoted 3 lines
I guess we can check if the regulators are identical,
and then just have the driver ignoreV_BKUP. Knowing whether there is a (hopefully charged) battery connected could be useful.Regulators are ref counted, so just enable it twice. Or the driver can just ignore it until it supports battery backup.
...my point was that in case there's no backup battery, you don't want to enable vcc (via v_bckp) at probe (and instead have the device cold boot whenever it's used).
Hence, the driver would need to check if the v_bckp-supply is identical to vcc and not enable the former at probe in that case (i.e. similar to if no v_bckp had been specified and we considered it optional).
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 19
Quoted 1 line
Documentation/devicetree/bindings/gnss/u-blox.txt new file +1
-0+- timepulse-gpios : Timepulse (e.g. 1PPS) GPIO (TIMEPULSE)Why the 3rd "TIMEPULSE"?
That's the pin name, which in this case is identical to the property name, so I'll drop it here.
Then what is the 2nd "Timepulse"?
That's the generic function name.
Quoted 1 line
Maybe just a "pin name: X" prefix so it is clear.
For u-blox devices, where property-, function- and pin name coincide, I could just change this to:
+- timepulse-gpios : Timepulse GPIO
and then for the sirfstar binding, which will be used by devices from multiple vendors which have decided to name their pins differently, I can add a "pin name: " prefix for clarity?
Quoted 9 lines
Quoted 8 lines
Take a look at the sirf binding; vendors use different names for their timepulse pins and in that case I added the actual pin names (1PPS, TM) in parenthesis after the description.
Note that I mentioned "timepulse-gpios" in the generic binding with the intent of trying to enforce a generic name for pins with such a function (similarly for "enable-gpios", which I guess is already established).
Quoted 5 lines
Yes, I think that's good.
Though with the enable-gpios I was debating the name for sirfstar a bit because it isn't the normal drive it active to enable, but rather a pulse to enable or disable.
I had some concerns along those lines as well, and if you agree I'll change the property name to on_off-gpios (or onoff-gpios) which matches the vendor data sheets for this pin, and which I think would be better.
Thanks,
Johan
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 60 lines · Johan Hovold
Quoted 44 lines · Rob Herring
Quoted 43 lines · Johan Hovold
Quoted 29 lines · Rob Herring
Quoted 28 lines · Johan Hovold
Add binding for u-blox GNSS receivers.
Note that the u-blox product names encodes form factor (e.g. "neo"), chipset (e.g. "8") and variant (e.g. "q"), but that only formfactor and chipset is used for the compatible strings (for now).
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/gnss/u-blox.txt | 31 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/u-blox.txtDocumentation/devicetree/bindings/gnss/u-blox.txt new file +9
-0@@ -0,0 +1,31 @@ +u-blox GNSS Receiver DT binding + +The u-blox GNSS receivers can use UART, DDC (I2C), SPI and USB interfaces. + +Please see Documentation/devicetree/bindings/gnss/gnss.txt for generic +properties. + +Required Properties: +Quoted 8 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 15
Quoted 6 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +6
-0+- compatible : Must be one of + + "u-blox,neo-8" + "u-blox,neo-m8" + +- vcc-supply : Main voltage regulator (VCC)What about
V_BCKP?That's the backup supply for for the RTC and batter-backed RAM. In configurations where a battery is not used it should be connected to VCC.
Quoted 8 lines
Quoted 3 lines
How would you model that? I can enable a vbckp regulator at probe, but what if someone then accurately describes the corresponding pin as being connected to VCC?
You mean how to model a battery? It would just be a 'regulator' because the regulator binding covers any supply really.
Then you just set both rails to the same supply phandle.
Yes, but...
Quoted 4 lines
Quoted 3 lines
I guess we can check if the regulators are identical,
and then just have the driver ignoreV_BKUP. Knowing whether there is a (hopefully charged) battery connected could be useful.
Quoted 6 lines
Quoted 2 lines
Regulators are ref counted, so just enable it twice. Or the driver can just ignore it until it supports battery backup.
...my point was that in case there's no backup battery, you don't want to enable vcc (via
v_bckp) at probe (and instead have the device cold boot whenever it's used).
Wouldn't that result in very long acquisition times? I guess I was thinking Vcc would be always on when running and V_bckp was just for suspend.
Quoted 3 lines
Hence, the driver would need to check if the v_bckp-supply is identical to vcc and not enable the former at probe in that case (i.e. similar to if no
v_bckphad been specified and we considered it optional).
I guess if that's the intended operation, then making it optional is fine.
Rob
Quoted 14 lines
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Documentation/devicetree/bindings/gnss/u-blox.txt line 19
Quoted 2 lines
Documentation/devicetree/bindings/gnss/u-blox.txt new file +1
-0+- timepulse-gpios : Timepulse (e.g. 1PPS) GPIO (TIMEPULSE)Why the 3rd "TIMEPULSE"?
That's the pin name, which in this case is identical to the property name, so I'll drop it here.
Then what is the 2nd "Timepulse"?
That's the generic function name.
Quoted 1 line
Maybe just a "pin name: X" prefix so it is clear.
Quoted 8 lines
For u-blox devices, where property-, function- and pin name coincide, I could just change this to:
+- timepulse-gpios : Timepulse GPIO
and then for the sirfstar binding, which will be used by devices from multiple vendors which have decided to name their pins differently, I can add a "pin name: " prefix for clarity?
Sounds good.
Quoted 11 lines
Quoted 11 lines
Quoted 8 lines
Take a look at the sirf binding; vendors use different names for their timepulse pins and in that case I added the actual pin names (1PPS, TM) in parenthesis after the description.
Note that I mentioned "timepulse-gpios" in the generic binding with the intent of trying to enforce a generic name for pins with such a function (similarly for "enable-gpios", which I guess is already established).
Yes, I think that's good.
Quoted 7 lines
Quoted 3 lines
Though with the enable-gpios I was debating the name for sirfstar a bit because it isn't the normal drive it active to enable, but rather a pulse to enable or disable.
I had some concerns along those lines as well, and if you agree I'll change the property name to on_off-gpios (or onoff-gpios) which matches the vendor data sheets for this pin, and which I think would be better.
Okay, just add a vendor prefix. And note that using '_' is discouraged.
Rob
Johan Hovold
maintainerRe: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 18 lines · Rob Herring
Quoted 16 lines · Johan Hovold
Quoted 15 lines · Rob Herring
Quoted 14 lines · Johan Hovold
Quoted 13 lines · Rob Herring
Documentation/devicetree/bindings/gnss/u-blox.txt line 15
Quoted 10 lines · Johan Hovold
Add binding for u-blox GNSS receivers.
Documentation/devicetree/bindings/gnss/u-blox.txt new file +8
-0+Required Properties: + +- compatible : Must be one of + + "u-blox,neo-8" + "u-blox,neo-m8" + +- vcc-supply : Main voltage regulator (VCC)What about
V_BCKP?
Quoted 7 lines
Quoted 3 lines
...my point was that in case there's no backup battery, you don't want to enable vcc (via
v_bckp) at probe (and instead have the device cold boot whenever it's used).Wouldn't that result in very long acquisition times? I guess I was thinking Vcc would be always on when running and
V_bckpwas just for suspend.
Yes, the acquisition times would certainly be longer, but for a GNSS receiver which is rarely used that might still be preferred. And since I'm using runtime pm to manage the supply, this policy decision can be deferred to user space and controlled through the power/control attribute.
Quoted 5 lines
Quoted 3 lines
Hence, the driver would need to check if the v_bckp-supply is identical to vcc and not enable the former at probe in that case (i.e. similar to if no
v_bckphad been specified and we considered it optional).I guess if that's the intended operation, then making it optional is fine.
Ok.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 8 lines
Take a look at the sirf binding; vendors use different names for their timepulse pins and in that case I added the actual pin names (1PPS, TM) in parenthesis after the description.
Note that I mentioned "timepulse-gpios" in the generic binding with the intent of trying to enforce a generic name for pins with such a function (similarly for "enable-gpios", which I guess is already established).
Yes, I think that's good.
Though with the enable-gpios I was debating the name for sirfstar a bit because it isn't the normal drive it active to enable, but rather a pulse to enable or disable.
Quoted 5 lines
Quoted 3 lines
I had some concerns along those lines as well, and if you agree I'll change the property name to on_off-gpios (or onoff-gpios) which matches the vendor data sheets for this pin, and which I think would be better.
Okay, just add a vendor prefix. And note that using '_' is discouraged.
Ok, I'll name it "sirf,onoff-gpios".
Thanks,
Johan
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
In reply to Johan HovoldQuoted 6 lines
Am 02.05.2018 um 10:16 schrieb Johan Hovold <[email protected]>:
Quoted 2 lines · Rob Herring
On Thu, Apr 26, 2018 at 4:10 AM, Johan Hovold <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
Though with the enable-gpios I was debating the name for sirfstar a bit because it isn't the normal drive it active to enable, but rather a pulse to enable or disable.
I had some concerns along those lines as well, and if you agree I'll change the property name to on_off-gpios (or onoff-gpios) which matches the vendor data sheets for this pin, and which I think would be better.
In our original submission of our w2sg bindings we also did call that "on-off-gpios", but Rob suggested to use the standard way of "enable-gpios":
https://patchwork.kernel.org/patch/9738981/
We changed this and got his acked-by for our w2sg bindings:
https://patchwork.kernel.org/patch/10054911/
We also have found an agreed wording for the description:
- enable-gpios: the GPIO that controls the module's power toggle input. A positive impulse of sufficent length toggles the power state.
But what should I expect from someone who constantly ignores, rejects and belittles previous work of others and prefers to reinvent almost the same thing and claims that it is 100% original work?
I am so heavily upset this time because we had been asked by reviewers if it was not Neil Brown who laid the foundation and yes, we of course looked how to formulate proper attribution:
https://patchwork.kernel.org/patch/10059705/
I stand to my view that this is a good example how to ruin the willingness of volunteers to send submissions for review, since the paycheck a volunteer receives uses the currency of being welcome, recognition and visibility in the final git log.
And I had expected that reviewers from kernel.org are more generous/liberal with code flaws (finding them is IMHO the sole purpose of the review process) and don't expect that everyone has the same background.
Anyways, let's forget this type of discussion and come back to a technical level:
I have realized that the w2sg0004 is an exception (although a Sirf chip) that it does not provide a WAKEUP signal. And another significant difference is that we have to keep the serdev UART enabled even if there is no user-space client. Otherwise we are not able to detect unexpected activity. So we unfortunately can't move serdev open/close into the .open and .close ops but need to open it in probe.
Therefore, it is in my opinion still better to have a separate driver for the w2sg0004 instead of hacking the support of this chip into your WAKEUP capable sirfstar driver. So I suggest that you make WAKEUP a required property.
We had faced a comparable decision last year with the ov9650 and ov9655 camera sensors which are almost the same. But not same enough to integrate both into a single driver.
So (despite my grown doubts about the review process), I'll now submit a v7 of our w2sg0004 driver, adjusted to your gnss framework API and tested on GTA04 hardware. It is only covering the w2sg0004 module and not even claiming to handle the w2sg0084(i) to avoid overlap with your work.
BR,
Nikolaus
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 7 lines · On Thu, 3 May 2018 11:35:21 +0200 H. Nikolaus Schaller <[email protected]>…
I have realized that the w2sg0004 is an exception (although a Sirf chip) that it does not provide a WAKEUP signal. And another significant difference is that we have to keep the serdev UART enabled even if there is no user-space client. Otherwise we are not able to detect unexpected activity. So we unfortunately can't move serdev open/close into the .open and .close ops but need to open it in probe.
how much power does it use to keep the uart enabled? Or should it better be reprogrammed as gpio?
Regards,
Andreas
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Hi Andreas,
Quoted 13 lines
Am 03.05.2018 um 20:50 schrieb Andreas Kemnade <[email protected]>:
Quoted 7 lines · On Thu, 3 May 2018 11:35:21 +0200 H. Nikolaus Schaller <[email protected]>…
I have realized that the w2sg0004 is an exception (although a Sirf chip) that it does not provide a WAKEUP signal. And another significant difference is that we have to keep the serdev UART enabled even if there is no user-space client. Otherwise we are not able to detect unexpected activity. So we unfortunately can't move serdev open/close into the .open and .close ops but need to open it in probe.
Quoted 2 lines
how much power does it use to keep the uart enabled? Or should it better be reprogrammed as gpio?
I think it does not need much more (if at all) than a gpio controller on the OMAP3 chip (I think the clocks are active anyways for use by the other UARTs).
We had proposed years ago to reprogram the UART RX pin by pinmux-states into an interrupt gpio but that was rejected because it was not general enough and ugly in the device tree (an rx-gpios record where the rx-line is already connected to the UART-rx).
Then we did experiment with tapping the UART driver and finally the serdev API was developed to solve this problem. Hence we use it now this way.
BR and thanks,
Nikolaus
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
[+cc Tony]
Hi,
Quoted 18 lines · H. Nikolaus Schaller
Quoted 11 lines
Am 03.05.2018 um 20:50 schrieb Andreas Kemnade <[email protected]>:
Quoted 7 lines · On Thu, 3 May 2018 11:35:21 +0200 H. Nikolaus Schaller <[email protected]>…
I have realized that the w2sg0004 is an exception (although a Sirf chip) that it does not provide a WAKEUP signal. And another significant difference is that we have to keep the serdev UART enabled even if there is no user-space client. Otherwise we are not able to detect unexpected activity. So we unfortunately can't move serdev open/close into the .open and .close ops but need to open it in probe.
Quoted 2 lines
how much power does it use to keep the uart enabled? Or should it better be reprogrammed as gpio?
I think it does not need much more (if at all) than a gpio controller on the OMAP3 chip (I think the clocks are active anyways for use by the other UARTs).
Quoted 8 lines
We had proposed years ago to reprogram the UART RX pin by pinmux-states into an interrupt gpio but that was rejected because it was not general enough and ugly in the device tree (an rx-gpios record where the rx-line is already connected to the UART-rx).
Then we did experiment with tapping the UART driver and finally the serdev API was developed to solve this problem. Hence we use it now this way.
Having any UART active on OMAP results in the SoC not entering idle/off wasting energy. For normal (i.e. not connected to a peripheral) TTYs you can enable runtime autosuspend and configure the RX pin as wakeup interrupt. This will wakeup the TTY on incoming traffic, but you will lose the first few characters (since the serial device needs some time to wakeup). This is for example supported by the N900 uart3 (debug uart):
$ grep -A4 "&uart3 {" arch/arm/boot/dts/omap3-n900.dts
&uart3 {
interrupts-extended = <&intc 74 &omap3_pmx_core OMAP3_UART3_RX>;
pinctrl-names = "default";
pinctrl-0 = <&uart3_pins>;
};To get it working, you also need to enable autosuspend for the tty in userspace (echo 3000 /sys/class/tty/ttyS2/device/power/autosuspend_delay_ms). This is not enabled by default due to the character loss characteristic during wakeup.
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
-- Sebastian
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Hi Sebastian,
Quoted 39 lines
Am 04.05.2018 um 13:42 schrieb Sebastian Reichel <[email protected]>:
[+cc Tony]
Hi,
Quoted 4 lines
I think it does not need much more (if at all) than a gpio controller on the OMAP3 chip (I think the clocks are active anyways for use by the other UARTs).
Quoted 8 lines
We had proposed years ago to reprogram the UART RX pin by pinmux-states into an interrupt gpio but that was rejected because it was not general enough and ugly in the device tree (an rx-gpios record where the rx-line is already connected to the UART-rx).
Then we did experiment with tapping the UART driver and finally the serdev API was developed to solve this problem. Hence we use it now this way.
Having any UART active on OMAP results in the SoC not entering idle/off wasting energy. For normal (i.e. not connected to a peripheral) TTYs you can enable runtime autosuspend and configure the RX pin as wakeup interrupt. This will wakeup the TTY on incoming traffic, but you will lose the first few characters (since the serial device needs some time to wakeup). This is for example supported by the N900 uart3 (debug uart):
$ grep -A4 "&uart3 {" arch/arm/boot/dts/omap3-n900.dts &uart3 { interrupts-extended = <&intc 74 &omap3_pmx_core OMAP3_UART3_RX>; pinctrl-names = "default"; pinctrl-0 = <&uart3_pins>; };To get it working, you also need to enable autosuspend for the tty in userspace (echo 3000
/sys/class/tty/ttyS2/device/power/autosuspend_delay_ms). This is not enabled by default due to the character loss characteristic during wakeup.
Quoted 5 lines
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
thanks for explaining this! We originally had similar thoughts when proposing a w2sg0004 driver for the first time (years ago), but we can not accept loosing characters...
Now, I could imagine a potential solution. The key situation why we keep the serdev open and listening is if the driver did try to turn the module off, but in fact did turn it on (because it was not in sync).
It should be possible to cover this by a timer that is started in this case. If there is serdev data received after assuming the module is turned off, the driver has detected the wrong case - and can safely close the serdev until we want to have it powered on again.
If there is no response after turing off, the module power state is already in sync and we can close the serdev as well - after the timeout (let's say 30 seconds). Then, the serdev UART can idle. We should open the serdev and start this timer also in the probe function to catch an initially wrong state.
But I think we should focus on the basics of this driver first. Then it can be optimized later on.
BR and thanks,
Nikolaus
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Hi,
Quoted 53 lines · H. Nikolaus Schaller
Quoted 34 lines
Am 04.05.2018 um 13:42 schrieb Sebastian Reichel <[email protected]>:
Quoted 4 lines
I think it does not need much more (if at all) than a gpio controller on the OMAP3 chip (I think the clocks are active anyways for use by the other UARTs).
Quoted 8 lines
We had proposed years ago to reprogram the UART RX pin by pinmux-states into an interrupt gpio but that was rejected because it was not general enough and ugly in the device tree (an rx-gpios record where the rx-line is already connected to the UART-rx).
Then we did experiment with tapping the UART driver and finally the serdev API was developed to solve this problem. Hence we use it now this way.
Having any UART active on OMAP results in the SoC not entering idle/off wasting energy. For normal (i.e. not connected to a peripheral) TTYs you can enable runtime autosuspend and configure the RX pin as wakeup interrupt. This will wakeup the TTY on incoming traffic, but you will lose the first few characters (since the serial device needs some time to wakeup). This is for example supported by the N900 uart3 (debug uart):
$ grep -A4 "&uart3 {" arch/arm/boot/dts/omap3-n900.dts &uart3 { interrupts-extended = <&intc 74 &omap3_pmx_core OMAP3_UART3_RX>; pinctrl-names = "default"; pinctrl-0 = <&uart3_pins>; };To get it working, you also need to enable autosuspend for the tty in userspace (echo 3000
/sys/class/tty/ttyS2/device/power/autosuspend_delay_ms). This is not enabled by default due to the character loss characteristic during wakeup.Quoted 5 lines
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
thanks for explaining this! We originally had similar thoughts when proposing a w2sg0004 driver for the first time (years ago), but we can not accept loosing characters...
Now, I could imagine a potential solution. The key situation why we keep the serdev open and listening is if the driver did try to turn the module off, but in fact did turn it on (because it was not in sync).
It should be possible to cover this by a timer that is started in this case. If there is serdev data received after assuming the module is turned off, the driver has detected the wrong case - and can safely close the serdev until we want to have it powered on again.
Quoted 5 lines
If there is no response after turing off, the module power state is already in sync and we can close the serdev as well - after the timeout (let's say 30 seconds). Then, the serdev UART can idle. We should open the serdev and start this timer also in the probe function to catch an initially wrong state.
That sounds like a good plan.
Quoted 2 lines
But I think we should focus on the basics of this driver first. Then it can be optimized later on.
Definitely.
-- Sebastian.
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 56 lines · Sebastian Reichel
Hi,
Quoted 53 lines · H. Nikolaus Schaller
Quoted 34 lines
Am 04.05.2018 um 13:42 schrieb Sebastian Reichel <[email protected]>:
Quoted 4 lines
I think it does not need much more (if at all) than a gpio controller on the OMAP3 chip (I think the clocks are active anyways for use by the other UARTs).
Quoted 8 lines
We had proposed years ago to reprogram the UART RX pin by pinmux-states into an interrupt gpio but that was rejected because it was not general enough and ugly in the device tree (an rx-gpios record where the rx-line is already connected to the UART-rx).
Then we did experiment with tapping the UART driver and finally the serdev API was developed to solve this problem. Hence we use it now this way.
Having any UART active on OMAP results in the SoC not entering idle/off wasting energy. For normal (i.e. not connected to a peripheral) TTYs you can enable runtime autosuspend and configure the RX pin as wakeup interrupt. This will wakeup the TTY on incoming traffic, but you will lose the first few characters (since the serial device needs some time to wakeup). This is for example supported by the N900 uart3 (debug uart):
$ grep -A4 "&uart3 {" arch/arm/boot/dts/omap3-n900.dts &uart3 { interrupts-extended = <&intc 74 &omap3_pmx_core OMAP3_UART3_RX>; pinctrl-names = "default"; pinctrl-0 = <&uart3_pins>; };To get it working, you also need to enable autosuspend for the tty in userspace (echo 3000
/sys/class/tty/ttyS2/device/power/autosuspend_delay_ms). This is not enabled by default due to the character loss characteristic during wakeup.Quoted 5 lines
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
thanks for explaining this! We originally had similar thoughts when proposing a w2sg0004 driver for the first time (years ago), but we can not accept loosing characters...
Now, I could imagine a potential solution. The key situation why we keep the serdev open and listening is if the driver did try to turn the module off, but in fact did turn it on (because it was not in sync).
It should be possible to cover this by a timer that is started in this case. If there is serdev data received after assuming the module is turned off, the driver has detected the wrong case - and can safely close the serdev until we want to have it powered on again.
Quoted 7 lines
Quoted 5 lines
If there is no response after turing off, the module power state is already in sync and we can close the serdev as well - after the timeout (let's say 30 seconds). Then, the serdev UART can idle. We should open the serdev and start this timer also in the probe function to catch an initially wrong state.
That sounds like a good plan.
I don't know the details, but sounds like you should might be able to just the timer that comes with pm_runtime_use_autosuspend() :)
Regards,
Tony
Johan Hovold
maintainerRe: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
In reply to H. Nikolaus SchallerQuoted 10 lines · H. Nikolaus Schaller
It should be possible to cover this by a timer that is started in this case. If there is serdev data received after assuming the module is turned off, the driver has detected the wrong case - and can safely close the serdev until we want to have it powered on again.
If there is no response after turing off, the module power state is already in sync and we can close the serdev as well - after the timeout (let's say 30 seconds). Then, the serdev UART can idle. We should open the serdev and start this timer also in the probe function to catch an initially wrong state.
Right, the only thing that worried me about that was that we cannot really delay system suspend for 30 seconds even if a somewhat shorter delay should be probably be sufficient (still a number of seconds).
Configuring the serial controller as a wakeup source which aborts suspend or resumes if the driver gets it wrong might be preferred to draining the battery in suspend however.
Johan
Johan Hovold
maintainerRe: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
In reply to Sebastian ReichelQuoted 5 lines · Sebastian Reichel
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
I'm not sure we want generic runtime-pm support for the controllers in the sense that the slave device state is always reflected by the serial controller. Similar as for i2c and spi, we really only want to keep the controller active when we are doing I/O, but we may want to keep a client active for longer.
Take the u-blox driver in this series for example. As I'm using runtime PM to manage device power, user-space can chose to prevent the receiver from runtime suspending in order to avoid lengthy (re-)acquisition times in setups without a backup battery (by means of the power/control attribute).
Note that serdev not enabling runtime pm for controllers is roughly equivalent to setting the .ignore_children flag, which is what we do for i2c and spi controller, and possibly what we want here too.
Thanks,
Johan
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Hi,
Quoted 8 lines · Johan Hovold
Quoted 5 lines · Sebastian Reichel
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
Quoted 5 lines
I'm not sure we want generic runtime-pm support for the controllers in the sense that the slave device state is always reflected by the serial controller. Similar as for i2c and spi, we really only want to keep the controller active when we are doing I/O, but we may want to keep a client active for longer.
Yeah i2c seems to do the right thing where the bus takes care of runtime PM.
Quoted 5 lines
Take the u-blox driver in this series for example. As I'm using runtime PM to manage device power, user-space can chose to prevent the receiver from runtime suspending in order to avoid lengthy (re-)acquisition times in setups without a backup battery (by means of the power/control attribute).
Sorry I don't seem to have that one, care to paste the subject line of that patch?
Quoted 3 lines
Note that serdev not enabling runtime pm for controllers is roughly equivalent to setting the .ignore_children flag, which is what we do for i2c and spi controller, and possibly what we want here too.
We currently don't idle serdev at all even if not in use. What I noticed is if I have these in my .config:
CONFIG_SERIAL_DEV_BUS=yCONFIG_SERIAL_DEV_CTRL_TTYPORT=y
And no hci_serdev.ko driver loaded, then the 8250 port still stays active and there are no sysfs entries to idle it.
Are you seeing this with your series?
Regards,
Tony
Johan Hovold
maintainerRe: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 11 lines · Tony Lindgren
Hi,
Quoted 8 lines · Johan Hovold
Quoted 5 lines · Sebastian Reichel
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
Quoted 8 lines
Quoted 5 lines
I'm not sure we want generic runtime-pm support for the controllers in the sense that the slave device state is always reflected by the serial controller. Similar as for i2c and spi, we really only want to keep the controller active when we are doing I/O, but we may want to keep a client active for longer.
Yeah i2c seems to do the right thing where the bus takes care of runtime PM.
Yeah, but since serial is async in contrast to i2c/spi, we may not be able to push this entirely into core. The serdev drivers may need to indicate when they expect or need to do I/O by opening and closing the port. And this is how I implemented these first couple of gnss drivers.
Also note that most serial driver do not do runtime pm while the port is open (as OMAP does), and doing so also has the drawbacks of lost characters etc. as Sebastian mentioned.
Quoted 8 lines
Quoted 5 lines
Take the u-blox driver in this series for example. As I'm using runtime PM to manage device power, user-space can chose to prevent the receiver from runtime suspending in order to avoid lengthy (re-)acquisition times in setups without a backup battery (by means of the power/control attribute).
Sorry I don't seem to have that one, care to paste the subject line of that patch?
"[PATCH 5/7] gnss: add driver for u-blox receivers" https://lkml.kernel.org/r/[email protected]
Quoted 4 lines
Quoted 3 lines
Note that serdev not enabling runtime pm for controllers is roughly equivalent to setting the .ignore_children flag, which is what we do for i2c and spi controller, and possibly what we want here too.
Quoted 8 lines
We currently don't idle serdev at all even if not in use. What I noticed is if I have these in my .config:
CONFIG_SERIAL_DEV_BUS=yCONFIG_SERIAL_DEV_CTRL_TTYPORT=yAnd no hci_serdev.ko driver loaded, then the 8250 port still stays active and there are no sysfs entries to idle it.
Sounds like the 8250_omap driver is doing something funky. Why would there not be any sysfs attributes to control runtime pm?
Quoted 1 line
Are you seeing this with your series?
I'm using omap-serial (on BBB) and like 8250_omap, the driver disables runtime pm at probe by setting a negative autosuspend timeout.
Changing this through sysfs causes the serial controller to runtime suspend, but something is not right in my setup as it doesn't wake up on incoming data.
I'd say the omap drivers are broken; the controller should definitely idle when the port is closed (whether using serdev or not) without having to fiddle with sysfs.
Thanks,
Johan
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 18 lines · Johan Hovold
Quoted 17 lines · Tony Lindgren
Hi,
Quoted 13 lines · Johan Hovold
Quoted 5 lines · Sebastian Reichel
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
I'm not sure we want generic runtime-pm support for the controllers in the sense that the slave device state is always reflected by the serial controller. Similar as for i2c and spi, we really only want to keep the controller active when we are doing I/O, but we may want to keep a client active for longer.
Quoted 7 lines
Quoted 2 lines
Yeah i2c seems to do the right thing where the bus takes care of runtime PM.
Yeah, but since serial is async in contrast to i2c/spi, we may not be able to push this entirely into core. The serdev drivers may need to indicate when they expect or need to do I/O by opening and closing the port. And this is how I implemented these first couple of gnss drivers.
OK
Quoted 3 lines
Also note that most serial driver do not do runtime pm while the port is open (as OMAP does), and doing so also has the drawbacks of lost characters etc. as Sebastian mentioned.
Yes serdev seems really nice for the oob wake gpios :)
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Take the u-blox driver in this series for example. As I'm using runtime PM to manage device power, user-space can chose to prevent the receiver from runtime suspending in order to avoid lengthy (re-)acquisition times in setups without a backup battery (by means of the power/control attribute).
Quoted 6 lines
Quoted 2 lines
Sorry I don't seem to have that one, care to paste the subject line of that patch?
"[PATCH 5/7] gnss: add driver for u-blox receivers" https://lkml.kernel.org/r/[email protected]
Thanks will take a look.
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
Note that serdev not enabling runtime pm for controllers is roughly equivalent to setting the .ignore_children flag, which is what we do for i2c and spi controller, and possibly what we want here too.
We currently don't idle serdev at all even if not in use. What I noticed is if I have these in my .config:
Quoted 8 lines
Quoted 5 lines
CONFIG_SERIAL_DEV_BUS=yCONFIG_SERIAL_DEV_CTRL_TTYPORT=yAnd no hci_serdev.ko driver loaded, then the 8250 port still stays active and there are no sysfs entries to idle it.
Sounds like the 8250_omap driver is doing something funky. Why would there not be any sysfs attributes to control runtime pm?
I don't know, they are there for the ports that don't have any serdev device. But if there is a serdev child node, the sysfs disappear for the 8250 port like it's /dev/ttyS* entry. That is even with no hci_serdev.ko loaded :)
Quoted 4 lines
Quoted 1 line
Are you seeing this with your series?
I'm using omap-serial (on BBB) and like 8250_omap, the driver disables runtime pm at probe by setting a negative autosuspend timeout.
Hmm I though we now have both 8250_omap and serial-omap behave the same way for PM.
Quoted 3 lines
Changing this through sysfs causes the serial controller to runtime suspend, but something is not right in my setup as it doesn't wake up on incoming data.
Do you have also a /dev/ttyO* entry created for the serdev port?
Quoted 3 lines
I'd say the omap drivers are broken; the controller should definitely idle when the port is closed (whether using serdev or not) without having to fiddle with sysfs.
This is happening for the non-serdev ports for sure. FYI, there is one patch needed for omap4 to idle unused ports that I posted few days ago:
[PATCHv3] serial: 8250: omap: Fix idling of clocks for unused uarts
But the serdev port is never idled, even if unused.
Can you check your serdev port clkctrl reg with rwmem or similar tool when it's idle?
You can do it with:
rwmem -s32 0x44e004b4 # uart 1 on l4_wkup rwmem -s32 0x44e0006c+0x10 # uart 2 - 5 on l4_per rwmem -s32 0x44e00038 # uart 6 on l4_per
And here's what I have on my bbb with 8250_omap:
0x44e004b4 = 0x000000020x44e0006c = 0x000300000x44e00070 = 0x000300000x44e00074 = 0x000300000x44e00078 = 0x000300000x44e00038 = 0x00030000
So all disabled except for the console UART.
Regards,
Tony
Johan Hovold
maintainerRe: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 20 lines · Tony Lindgren
Quoted 19 lines · Johan Hovold
Quoted 17 lines · Tony Lindgren
Hi,
Quoted 5 lines · Johan Hovold
On Fri, May 04, 2018 at 01:42:13PM +0200, Sebastian Reichel wrote:
Note that serdev not enabling runtime pm for controllers is roughly equivalent to setting the .ignore_children flag, which is what we do for i2c and spi controller, and possibly what we want here too.
We currently don't idle serdev at all even if not in use. What I noticed is if I have these in my .config:
CONFIG_SERIAL_DEV_BUS=yCONFIG_SERIAL_DEV_CTRL_TTYPORT=yAnd no hci_serdev.ko driver loaded, then the 8250 port still stays active and there are no sysfs entries to idle it.
Quoted 7 lines
Quoted 2 lines
Sounds like the 8250_omap driver is doing something funky. Why would there not be any sysfs attributes to control runtime pm?
I don't know, they are there for the ports that don't have any serdev device. But if there is a serdev child node, the sysfs disappear for the 8250 port like it's
/dev/ttyS*entry. That is even with no hci_serdev.ko loaded :)
It sounds to me like you have a udev rule that's matching on TTY devices and setting an autosuspend timeout that allows the controller to runtime suspend. Is that so?
With serdev such a rule would no longer be sufficient as it would no longer configure all controllers. You can always set the autosuspend directly through the platform device node, for example:
/sys/bus/platform/devices/481aa000.serial
But the point is, we really don't want the runtime PM behaviour to be dependent on the presence of such rules. The serial controllers should always be idle when not in use (unless overridden by user space).
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Are you seeing this with your series?
I'm using omap-serial (on BBB) and like 8250_omap, the driver disables runtime pm at probe by setting a negative autosuspend timeout.
Hmm I though we now have both 8250_omap and serial-omap behave the same way for PM.
It looks like they've been implemented the same way (e.g. the negative autosuspend timeout).
Quoted 5 lines
Quoted 3 lines
Changing this through sysfs causes the serial controller to runtime suspend, but something is not right in my setup as it doesn't wake up on incoming data.
Do you have also a
/dev/ttyO*entry created for the serdev port?
No, serdev claims the port and no tty device is created.
Quoted 11 lines
Quoted 3 lines
I'd say the omap drivers are broken; the controller should definitely idle when the port is closed (whether using serdev or not) without having to fiddle with sysfs.
This is happening for the non-serdev ports for sure. FYI, there is one patch needed for omap4 to idle unused ports that I posted few days ago:
[PATCHv3] serial: 8250: omap: Fix idling of clocks for unused uarts
But the serdev port is never idled, even if unused.
With the negative autosuspend set in both omap drivers probe functions, this is the expected behaviour. Which I think we must fix.
Quoted 11 lines
Can you check your serdev port clkctrl reg with rwmem or similar tool when it's idle?
You can do it with:
rwmem -s32 0x44e004b4 # uart 1 on l4_wkup rwmem -s32 0x44e0006c+0x10 # uart 2 - 5 on l4_per rwmem -s32 0x44e00038 # uart 6 on l4_perAnd here's what I have on my bbb with 8250_omap:
Quoted 8 lines
0x44e004b4=0x000000020x44e0006c=0x000300000x44e00070=0x000300000x44e00074=0x000300000x44e00078=0x000300000x44e00038=0x00030000So all disabled except for the console UART.
On BBB with omap-serial I have:
0x44e004b4 = 0x2 (uart 1, console, open)0x44e0006c = 0x2 (uart 2, serdev, closed)0x44e00070 = 0x30000 (uart 3, disabled in DT)0x44e00074 = 0x30000 (uart 4, disabled in DT)0x44e00078 = 0x2 (uart 5, serdev, closed)0x44e00038 = 0x2 (uart 6, ttyO5, closed)
So no enabled and closed port is idle, whether using serdev or not.
Thanks,
Johan
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 9 lines · Johan Hovold
Quoted 4 lines · Tony Lindgren
I don't know, they are there for the ports that don't have any serdev device. But if there is a serdev child node, the sysfs disappear for the 8250 port like it's
/dev/ttyS*entry. That is even with no hci_serdev.ko loaded :)It sounds to me like you have a udev rule that's matching on TTY devices and setting an autosuspend timeout that allows the controller to runtime suspend. Is that so?
Oh you are right, I do have an old init script that idles the UARTs.
And that script is looking for tty[SO]*. Updating it to use /sys/bus/platform/devices fixes the issue I was seeing:
uarts=$(find /sys/bus/platform/devices/4*.serial/power/ -type d) for uart in $uarts; do
echo -n 1000 > $uart/autosuspend_delay_ms
echo -n enabled > $uart/wakeup
echo -n auto > $uart/control
done
The above also idles the console so beware though.
Quoted 3 lines
But the point is, we really don't want the runtime PM behaviour to be dependent on the presence of such rules. The serial controllers should always be idle when not in use (unless overridden by user space).
I agree, and that seems broken right now.
Quoted 3 lines
Quoted 1 line
Do you have also a
/dev/ttyO*entry created for the serdev port?No, serdev claims the port and no tty device is created.
And this is no longer the issue when using /sys/bus/platform/devices instead of tty[SO]* in my init script :)
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
I'd say the omap drivers are broken; the controller should definitely idle when the port is closed (whether using serdev or not) without having to fiddle with sysfs.
This is happening for the non-serdev ports for sure. FYI, there is one patch needed for omap4 to idle unused ports that I posted few days ago:
Quoted 6 lines
Quoted 3 lines
[PATCHv3] serial: 8250: omap: Fix idling of clocks for unused uarts
But the serdev port is never idled, even if unused.
With the negative autosuspend set in both omap drivers probe functions, this is the expected behaviour. Which I think we must fix.
Yes indeed. I've been using my script for years now and have completely missed the fact that the unused ports are not idled at all on start-up when unused.
Quoted 22 lines
Quoted 11 lines
Can you check your serdev port clkctrl reg with rwmem or similar tool when it's idle?
You can do it with:
rwmem -s32 0x44e004b4 # uart 1 on l4_wkup rwmem -s32 0x44e0006c+0x10 # uart 2 - 5 on l4_per rwmem -s32 0x44e00038 # uart 6 on l4_perAnd here's what I have on my bbb with 8250_omap:
Quoted 8 lines
0x44e004b4=0x000000020x44e0006c=0x000300000x44e00070=0x000300000x44e00074=0x000300000x44e00078=0x000300000x44e00038=0x00030000So all disabled except for the console UART.
On BBB with omap-serial I have:
Quoted 8 lines
0x44e004b4=0x2(uart 1, console, open)0x44e0006c=0x2(uart 2, serdev, closed)0x44e00070=0x30000(uart 3, disabled in DT)0x44e00074=0x30000(uart 4, disabled in DT)0x44e00078=0x2(uart 5, serdev, closed)0x44e00038=0x2(uart 6, ttyO5, closed)So no enabled and closed port is idle, whether using serdev or not.
OK so we really have currently just one PM related bug where unused UARTs should be idled on init. And then the serdev PM can be handled the way you're doing it and tested with the above rwmem.
Hmm maybe all we need for serdev runtime PM is to set the parent UART autoidle timeout to immediate (0 instead of -1) from the serdev child driver to allow the serdev driver manage the PM.
Regards,
Tony
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 7 lines · Tony Lindgren
Quoted 2 lines · Johan Hovold
With the negative autosuspend set in both omap drivers probe functions, this is the expected behaviour. Which I think we must fix.
Yes indeed. I've been using my script for years now and have completely missed the fact that the unused ports are not idled at all on start-up when unused.
This might be all that's needed, care to try it and if it works I'll send out two separate proper patches?
I'm seeing this now on my bbb after temporarily disabling my UART idle init script:
# rwmem -s32 0x44e004b4 # uart 1 on l4_wkup 0x44e004b4 = 0x00000002
# rwmem -s32 0x44e0006c+0x10 # uart 2 - 5 on l4_per 0x44e0006c = 0x00030000 0x44e00070 = 0x00030000 0x44e00074 = 0x00030000 0x44e00078 = 0x00030000
# rwmem -s32 0x44e00038 # uart 6 on l4_per 0x44e00038 = 0x00030000
Regards,
Tony
8< ----------------------
drivers/tty/serial/8250/8250_omap.c +2 -4
@@ -685,8 +685,7 @@ static void omap_8250_shutdown(struct uart_port *port)serial_out (up,UART_LCR , up->lcr & ~UART_LCR_SBC );serial_out (up,UART_FCR ,UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT ); -pm_runtime_mark_last_busy (port->dev); -pm_runtime_put_autosuspend (port->dev); +pm_runtime_put_sync (port->dev);free_irq (port->irq, port);dev_pm_clear_wake_irq (port->dev); }
@@ -1265,8 +1264,7 @@ static int omap8250_probe(struct platform_device *pdev) } priv->line = ret;platform_set_drvdata (pdev, priv); -pm_runtime_mark_last_busy (&pdev->dev); -pm_runtime_put_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev);return 0 ; err:pm_runtime_dont_use_autosuspend (&pdev->dev);
drivers/tty/serial/omap-serial.c +2 -4
@@ -821,8 +821,7 @@ static void serial_omap_shutdown(struct uart_port *port)if (serial_in (up,UART_LSR ) &UART_LSR_DR ) (void )serial_in (up,UART_RX ); -pm_runtime_mark_last_busy (up->dev); -pm_runtime_put_autosuspend (up->dev); +pm_runtime_put_sync (up->dev);free_irq (up->port.irq, up);dev_pm_clear_wake_irq (up->dev); }
@@ -1751,8 +1750,7 @@ static int serial_omap_probe(struct platform_device *pdev)if (ret !=0 ) goto err_add_port; -pm_runtime_mark_last_busy (up->dev); -pm_runtime_put_autosuspend (up->dev); +pm_runtime_put_sync (&pdev->dev);return 0 ; err_add_port:
Signature · 1 line
2.17.0
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 18 lines · Tony Lindgren
Quoted 7 lines · Tony Lindgren
Quoted 2 lines · Johan Hovold
With the negative autosuspend set in both omap drivers probe functions, this is the expected behaviour. Which I think we must fix.
Yes indeed. I've been using my script for years now and have completely missed the fact that the unused ports are not idled at all on start-up when unused.
This might be all that's needed, care to try it and if it works I'll send out two separate proper patches?
I'm seeing this now on my bbb after temporarily disabling my UART idle init script:
# rwmem -s32 0x44e004b4 # uart 1 on l4_wkup 0x44e004b4 = 0x00000002
Quoted 8 lines
# rwmem -s32 0x44e0006c+0x10 # uart 2 - 5 on l4_per 0x44e0006c = 0x00030000 0x44e00070 = 0x00030000 0x44e00074 = 0x00030000 0x44e00078 = 0x00030000# rwmem -s32 0x44e00038 # uart 6 on l4_per 0x44e00038 = 0x00030000
Hmm I forgot to remove status = "disabled" from the other ports, still not idling the unused ports with the patch below it seems.
Regards,
Tony
Quoted 49 lines
8< ----------------------
drivers/tty/serial/8250/8250_omap.c +2
-4@@ -685,8 +685,7 @@ static void omap_8250_shutdown(struct uart_port *port)serial_out (up,UART_LCR , up->lcr & ~UART_LCR_SBC );serial_out (up,UART_FCR ,UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT ); -pm_runtime_mark_last_busy (port->dev); -pm_runtime_put_autosuspend (port->dev); +pm_runtime_put_sync (port->dev);free_irq (port->irq, port);dev_pm_clear_wake_irq (port->dev); }@@ -1265,8 +1264,7 @@ static int omap8250_probe(struct platform_device *pdev) } priv->line = ret;platform_set_drvdata (pdev, priv); -pm_runtime_mark_last_busy (&pdev->dev); -pm_runtime_put_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev);return 0 ; err:pm_runtime_dont_use_autosuspend (&pdev->dev);drivers/tty/serial/omap-serial.c +2
-4@@ -821,8 +821,7 @@ static void serial_omap_shutdown(struct uart_port *port)if (serial_in (up,UART_LSR ) &UART_LSR_DR ) (void )serial_in (up,UART_RX ); -pm_runtime_mark_last_busy (up->dev); -pm_runtime_put_autosuspend (up->dev); +pm_runtime_put_sync (up->dev);free_irq (up->port.irq, up);dev_pm_clear_wake_irq (up->dev); }@@ -1751,8 +1750,7 @@ static int serial_omap_probe(struct platform_device *pdev)if (ret !=0 ) goto err_add_port; -pm_runtime_mark_last_busy (up->dev); -pm_runtime_put_autosuspend (up->dev); +pm_runtime_put_sync (&pdev->dev);return 0 ; err_add_port:Signature · 1 line
2.17.0
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
Quoted 25 lines · Tony Lindgren
Quoted 24 lines · Tony Lindgren
Quoted 7 lines · Tony Lindgren
Quoted 2 lines · Johan Hovold
With the negative autosuspend set in both omap drivers probe functions, this is the expected behaviour. Which I think we must fix.
Yes indeed. I've been using my script for years now and have completely missed the fact that the unused ports are not idled at all on start-up when unused.
This might be all that's needed, care to try it and if it works I'll send out two separate proper patches?
I'm seeing this now on my bbb after temporarily disabling my UART idle init script:
# rwmem -s32 0x44e004b4 # uart 1 on l4_wkup 0x44e004b4 = 0x00000002# rwmem -s32 0x44e0006c+0x10 # uart 2 - 5 on l4_per 0x44e0006c = 0x00030000 0x44e00070 = 0x00030000 0x44e00074 = 0x00030000 0x44e00078 = 0x00030000
Quoted 5 lines
Quoted 2 lines
# rwmem -s32 0x44e00038 # uart 6 on l4_per 0x44e00038 = 0x00030000Hmm I forgot to remove status = "disabled" from the other ports, still not idling the unused ports with the patch below it seems.
No need to enable/disable autosuspend except in startup and shutdown I think. The patch below works for me, now includes removal of the status = "disabled" flags too. Only tested with 8250_omap on bbb so far.
I wonder if other places still need fixing for autosuspend like console support?
Regards,
Tony
8< -------------------
arch/arm/boot/dts/am33xx.dtsi +0 -6
@@ -347,7 +347,6 @@ clock-frequency = <48000000>; reg = <0x44e09000 0x2000>; interrupts = <72>; - status = "disabled"; dmas = <&edma 26 0>, <&edma 27 0>; dma-names = "tx", "rx"; };
@@ -358,7 +357,6 @@ clock-frequency = <48000000>; reg = <0x48022000 0x2000>; interrupts = <73>; - status = "disabled"; dmas = <&edma 28 0>, <&edma 29 0>; dma-names = "tx", "rx"; };
@@ -369,7 +367,6 @@ clock-frequency = <48000000>; reg = <0x48024000 0x2000>; interrupts = <74>; - status = "disabled"; dmas = <&edma 30 0>, <&edma 31 0>; dma-names = "tx", "rx"; };
@@ -380,7 +377,6 @@ clock-frequency = <48000000>; reg = <0x481a6000 0x2000>; interrupts = <44>; - status = "disabled"; }; uart4: serial@481a8000 {
@@ -389,7 +385,6 @@ clock-frequency = <48000000>; reg = <0x481a8000 0x2000>; interrupts = <45>; - status = "disabled"; }; uart5: serial@481aa000 {
@@ -398,7 +393,6 @@ clock-frequency = <48000000>; reg = <0x481aa000 0x2000>; interrupts = <46>; - status = "disabled"; }; i2c0: i2c@44e0b000 {
drivers/tty/serial/8250/8250_omap.c +6 -5
@@ -605,6 +605,7 @@ static int omap_8250_startup(struct uart_port *port)return ret; } +pm_runtime_use_autosuspend (port->dev);pm_runtime_get_sync (port->dev); up->mcr =0 ;
@@ -685,8 +686,8 @@ static void omap_8250_shutdown(struct uart_port *port)serial_out (up,UART_LCR , up->lcr & ~UART_LCR_SBC );serial_out (up,UART_FCR ,UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT ); -pm_runtime_mark_last_busy (port->dev); -pm_runtime_put_autosuspend (port->dev); +pm_runtime_dont_use_autosuspend (port->dev); +pm_runtime_put_sync (port->dev);free_irq (port->irq, port);dev_pm_clear_wake_irq (port->dev); }
@@ -1226,7 +1227,7 @@ static int omap8250_probe(struct platform_device *pdev)spin_lock_init (&priv->rx_dma_lock);device_init_wakeup (&pdev->dev, true); -pm_runtime_use_autosuspend (&pdev->dev); +/* See omap_8250_startup and shutdown for autosuspend */ pm_runtime_set_autosuspend_delay (&pdev->dev,-1 );pm_runtime_irq_safe (&pdev->dev);
@@ -1265,8 +1266,8 @@ static int omap8250_probe(struct platform_device *pdev) } priv->line = ret;platform_set_drvdata (pdev, priv); -pm_runtime_mark_last_busy (&pdev->dev); -pm_runtime_put_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev); +return 0 ; err:pm_runtime_dont_use_autosuspend (&pdev->dev);
drivers/tty/serial/omap-serial.c +5 -5
@@ -740,6 +740,7 @@ static int serial_omap_startup(struct uart_port *port)dev_dbg (up->port.dev,"serial_omap_startup+%d\n" , up->port.line); +pm_runtime_use_autosuspend (up->dev);pm_runtime_get_sync (up->dev);/* * Clear the FIFO buffers and disable them.
@@ -821,8 +822,8 @@ static void serial_omap_shutdown(struct uart_port *port)if (serial_in (up,UART_LSR ) &UART_LSR_DR ) (void )serial_in (up,UART_RX ); -pm_runtime_mark_last_busy (up->dev); -pm_runtime_put_autosuspend (up->dev); +pm_runtime_dont_use_autosuspend (up->dev); +pm_runtime_put_sync (up->dev);free_irq (up->port.irq, up);dev_pm_clear_wake_irq (up->dev); }
@@ -1733,7 +1734,7 @@ static int serial_omap_probe(struct platform_device *pdev) omap_up_info->autosuspend_timeout =-1 ;device_init_wakeup (up->dev, true); -pm_runtime_use_autosuspend (&pdev->dev); +/* See serial_omap_startup and shutdown for autosuspend */ pm_runtime_set_autosuspend_delay (&pdev->dev, omap_up_info->autosuspend_timeout);
@@ -1751,8 +1752,7 @@ static int serial_omap_probe(struct platform_device *pdev)if (ret !=0 ) goto err_add_port; -pm_runtime_mark_last_busy (up->dev); -pm_runtime_put_autosuspend (up->dev); +pm_runtime_put_sync (&pdev->dev);return 0 ; err_add_port:
Johan Hovold
maintainerOMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
[ Updating subject and adding linux-serial, linux-pm and linux-omap. ]
Quoted 32 lines · Tony Lindgren
Quoted 25 lines · Tony Lindgren
Quoted 24 lines · Tony Lindgren
Quoted 7 lines · Tony Lindgren
Quoted 2 lines · Johan Hovold
With the negative autosuspend set in both omap drivers probe functions, this is the expected behaviour. Which I think we must fix.
Yes indeed. I've been using my script for years now and have completely missed the fact that the unused ports are not idled at all on start-up when unused.
This might be all that's needed, care to try it and if it works I'll send out two separate proper patches?
I'm seeing this now on my bbb after temporarily disabling my UART idle init script:
# rwmem -s32 0x44e004b4 # uart 1 on l4_wkup 0x44e004b4 = 0x00000002# rwmem -s32 0x44e0006c+0x10 # uart 2 - 5 on l4_per 0x44e0006c = 0x00030000 0x44e00070 = 0x00030000 0x44e00074 = 0x00030000 0x44e00078 = 0x00030000Quoted 5 lines
Quoted 2 lines
# rwmem -s32 0x44e00038 # uart 6 on l4_per 0x44e00038 = 0x00030000Hmm I forgot to remove status = "disabled" from the other ports, still not idling the unused ports with the patch below it seems.
Quoted 7 lines
No need to enable/disable autosuspend except in startup and shutdown I think. The patch below works for me, now includes removal of the status = "disabled" flags too. Only tested with 8250_omap on bbb so far.
I wonder if other places still need fixing for autosuspend like console support?
While this seems to fix the idling of closed ports here too, I'm not sure we can move use_autosuspend to startup() like this.
First, this flag should be set before registering the tty so that udev can be used to update the attributes.
Second, this prevents setting the autosuspend delay through sysfs when the port is closed (when autosuspend is disabled).
It seems we really should not be using the negative autosuspend to configure the RPM behaviour the way these drivers do. Perhaps a new mechanism is needed.
But I'm afraid I don't have time to look at this today.
Thanks,
Johan
Quoted 40 lines
drivers/tty/serial/8250/8250_omap.c +6
-5@@ -605,6 +605,7 @@ static int omap_8250_startup(struct uart_port *port)return ret; } +pm_runtime_use_autosuspend (port->dev);pm_runtime_get_sync (port->dev); up->mcr =0 ;@@ -685,8 +686,8 @@ static void omap_8250_shutdown(struct uart_port *port)serial_out (up,UART_LCR , up->lcr & ~UART_LCR_SBC );serial_out (up,UART_FCR ,UART_FCR_CLEAR_RCVR |UART_FCR_CLEAR_XMIT ); -pm_runtime_mark_last_busy (port->dev); -pm_runtime_put_autosuspend (port->dev); +pm_runtime_dont_use_autosuspend (port->dev); +pm_runtime_put_sync (port->dev);free_irq (port->irq, port);dev_pm_clear_wake_irq (port->dev); }@@ -1226,7 +1227,7 @@ static int omap8250_probe(struct platform_device *pdev)spin_lock_init (&priv->rx_dma_lock);device_init_wakeup (&pdev->dev, true); -pm_runtime_use_autosuspend (&pdev->dev); +/* See omap_8250_startup and shutdown for autosuspend */ pm_runtime_set_autosuspend_delay (&pdev->dev,-1 );pm_runtime_irq_safe (&pdev->dev);@@ -1265,8 +1266,8 @@ static int omap8250_probe(struct platform_device *pdev) } priv->line = ret;platform_set_drvdata (pdev, priv); -pm_runtime_mark_last_busy (&pdev->dev); -pm_runtime_put_autosuspend (&pdev->dev); +pm_runtime_put_sync (&pdev->dev); +return 0 ; err:
Re: OMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
Quoted 8 lines · Johan Hovold
While this seems to fix the idling of closed ports here too, I'm not sure we can move
use_autosuspendtostartup()like this.First, this flag should be set before registering the tty so that udev can be used to update the attributes.
Second, this prevents setting the autosuspend delay through sysfs when the port is closed (when autosuspend is disabled).
Yeah I noticed that too yesterday.
Quoted 3 lines
It seems we really should not be using the negative autosuspend to configure the RPM behaviour the way these drivers do. Perhaps a new mechanism is needed.
Hmm well simply defaulting to "on" instead of "auto" and setting the autosuspend_ms to 3000 by default might be doable. I think that way we can keep use_autosuspend() in probe. Let's hope there are no existing use cases that would break with that.
Quoted 1 line
But I'm afraid I don't have time to look at this today.
Sure np thanks,
Tony
Johan Hovold
maintainerRe: OMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
[ Sorry about the late reply. ]
Quoted 10 lines · Tony Lindgren
Quoted 3 lines · Johan Hovold
It seems we really should not be using the negative autosuspend to configure the RPM behaviour the way these drivers do. Perhaps a new mechanism is needed.
Hmm well simply defaulting to "on" instead of "auto" and setting the
autosuspend_msto 3000 by default might be doable. I think that way we can keepuse_autosuspend()in probe. Let's hope there are no existing use cases that would break with that.
No, defaulting to "on" (i.e. calling pm_runtime_forbid()) wouldn't work either as that would also prevent the device from runtime suspending just as the current negative autosuspend delay does.
I fail to see how we can implement this using the current toolbox. What you're after here is really a mechanism for selecting between two different runtime PM schemes at runtime:
1. normal serial RPM, where the controller is active while the port is open (this should be the safe default)
2. aggressive serial RPM, where the controller is allowed to suspend while the port is open even though this may result in lost characters when waking up on incoming data
For normal ttys, we need a user-space interface for selecting between the two, and for serdev we may want a way to select the RPM scheme from within the kernel.
Note that with my serdev controller runtime PM patch, serdev core could always opt for aggressive PM (as by default serdev core holds an RPM reference for the controller while the port is open).
Thanks,
Johan
Re: OMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
Quoted 9 lines · Johan Hovold
[ Sorry about the late reply. ]
Quoted 6 lines · Tony Lindgren
Quoted 3 lines · Johan Hovold
It seems we really should not be using the negative autosuspend to configure the RPM behaviour the way these drivers do. Perhaps a new mechanism is needed.
Quoted 8 lines
Quoted 4 lines
Hmm well simply defaulting to "on" instead of "auto" and setting the
autosuspend_msto 3000 by default might be doable. I think that way we can keepuse_autosuspend()in probe. Let's hope there are no existing use cases that would break with that.No, defaulting to "on" (i.e. calling
pm_runtime_forbid()) wouldn't work either as that would also prevent the device from runtime suspending just as the current negative autosuspend delay does.
Well in that case we should just stick with -1 value for the autosuspend. And just do pm_runtime_put_sync_suspend() after probe and on close.
Quoted 6 lines
I fail to see how we can implement this using the current toolbox. What you're after here is really a mechanism for selecting between two different runtime PM schemes at runtime:
1. normal serial RPM, where the controller is active while the port is open (this should be the safe default)
Agreed. And that is the case already.
Quoted 3 lines
2. aggressive serial RPM, where the controller is allowed to suspend while the port is open even though this may result in lost characters when waking up on incoming data
In this case it seems that the only thing needed is to just configure the autosuspend delay for the parent port. The use of -1 has been around since the start of runtime PM AFAIK, so maybe we should just document it. I guess we could also introduce pm_runtime_block_autoidle_unless_configured() :)
Quoted 7 lines
For normal ttys, we need a user-space interface for selecting between the two, and for serdev we may want a way to select the RPM scheme from within the kernel.
Note that with my serdev controller runtime PM patch, serdev core could always opt for aggressive PM (as by default serdev core holds an RPM reference for the controller while the port is open).
So if your serdev controller was to set the parent autosuspend delay on open() and set it back on close() this should work?
Regards,
Tony
Johan Hovold
maintainerRe: OMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
Quoted 15 lines · Tony Lindgren
Quoted 14 lines · Johan Hovold
[ Sorry about the late reply. ]
Quoted 10 lines · Tony Lindgren
Quoted 3 lines · Johan Hovold
It seems we really should not be using the negative autosuspend to configure the RPM behaviour the way these drivers do. Perhaps a new mechanism is needed.
Hmm well simply defaulting to "on" instead of "auto" and setting the
autosuspend_msto 3000 by default might be doable. I think that way we can keepuse_autosuspend()in probe. Let's hope there are no existing use cases that would break with that.
Quoted 7 lines
Quoted 3 lines
No, defaulting to "on" (i.e. calling
pm_runtime_forbid()) wouldn't work either as that would also prevent the device from runtime suspending just as the current negative autosuspend delay does.Well in that case we should just stick with -1 value for the autosuspend. And just do
pm_runtime_put_sync_suspend()after probe and on close.
That won't work either as a negative autosuspend delay prevents runtime suspend completely (by grabbing an extra RPM reference).
Quoted 8 lines
Quoted 6 lines
I fail to see how we can implement this using the current toolbox. What you're after here is really a mechanism for selecting between two different runtime PM schemes at runtime:
1. normal serial RPM, where the controller is active while the port is open (this should be the safe default)
Agreed. And that is the case already.
Yes, but it's not really the case today as since omap-serial (and 8250-omap) sets a negative autosuspend at probe and hence does not runtime-suspend when the port is closed. So that's the long-standing bug which needs fixing.
Quoted 9 lines
Quoted 3 lines
2. aggressive serial RPM, where the controller is allowed to suspend while the port is open even though this may result in lost characters when waking up on incoming data
In this case it seems that the only thing needed is to just configure the autosuspend delay for the parent port. The use of -1 has been around since the start of runtime PM AFAIK, so maybe we should just document it. I guess we could also introduce
pm_runtime_block_autoidle_unless_configured():)
The implications of a negative autosuspend delay are already documented (in Documentation/power/runtime_pm.txt); it's just the omap drivers that gets it wrong when trying to do things which aren't currently supported (and never have been).
So I still think we need a new mechanism for this.
Quoted 10 lines
Quoted 7 lines
For normal ttys, we need a user-space interface for selecting between the two, and for serdev we may want a way to select the RPM scheme from within the kernel.
Note that with my serdev controller runtime PM patch, serdev core could always opt for aggressive PM (as by default serdev core holds an RPM reference for the controller while the port is open).
So if your serdev controller was to set the parent autosuspend delay on
open()and set it back onclose()this should work?
Is it really the job of a serdev driver to set the autosuspend delay of a parent controller? Isn't this somethings which depends on the characteristics of the controller (possibly configurable by user space) such as the cost of runtime suspending and resuming?
The patch I posted works with what we have today; if a parent serial controller driver uses aggressive runtime PM by default or after having been configured through sysfs to do so.
What I'm getting at here is that the delay should be set by the serial driver implementing aggressive runtime PM. Then all we need is a mechanism to determine whether an extra RPM reference should be taken at tty open or not (configurable by user space, defaulting to yes).
Specifically, the serial drivers themselves would always use autosuspend and not have to deal with supporting the two RPM schemes (normal vs aggressive runtime PM).
Thanks,
Johan
Re: OMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
Quoted 6 lines · Johan Hovold
Quoted 5 lines · Tony Lindgren
Quoted 3 lines · Johan Hovold
No, defaulting to "on" (i.e. calling
pm_runtime_forbid()) wouldn't work either as that would also prevent the device from runtime suspending just as the current negative autosuspend delay does.
Quoted 6 lines
Quoted 3 lines
Well in that case we should just stick with -1 value for the autosuspend. And just do
pm_runtime_put_sync_suspend()after probe and on close.That won't work either as a negative autosuspend delay prevents runtime suspend completely (by grabbing an extra RPM reference).
Well so negative autosuspend delay is working as documented then :)
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
I fail to see how we can implement this using the current toolbox. What you're after here is really a mechanism for selecting between two different runtime PM schemes at runtime:
1. normal serial RPM, where the controller is active while the port is open (this should be the safe default)
Quoted 6 lines
Quoted 1 line
Agreed. And that is the case already.
Yes, but it's not really the case today as since omap-serial (and 8250-omap) sets a negative autosuspend at probe and hence does not runtime-suspend when the port is closed. So that's the long-standing bug which needs fixing.
Yes the bug for closed ports needs to be fixed for sure.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
2. aggressive serial RPM, where the controller is allowed to suspend while the port is open even though this may result in lost characters when waking up on incoming data
In this case it seems that the only thing needed is to just configure the autosuspend delay for the parent port. The use of -1 has been around since the start of runtime PM AFAIK, so maybe we should just document it. I guess we could also introduce
pm_runtime_block_autoidle_unless_configured():)
Quoted 6 lines
The implications of a negative autosuspend delay are already documented (in
Documentation/power/runtime_pm.txt); it's just the omap drivers that gets it wrong when trying to do things which aren't currently supported (and never have been).So I still think we need a new mechanism for this.
Well if you have some better mechanism in mind let's try it out. Short of sprinkling pm_runtime_force_suspend/resume calls all over, I'm out of ideas right now.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
For normal ttys, we need a user-space interface for selecting between the two, and for serdev we may want a way to select the RPM scheme from within the kernel.
Note that with my serdev controller runtime PM patch, serdev core could always opt for aggressive PM (as by default serdev core holds an RPM reference for the controller while the port is open).
Quoted 7 lines
Quoted 2 lines
So if your serdev controller was to set the parent autosuspend delay on
open()and set it back onclose()this should work?Is it really the job of a serdev driver to set the autosuspend delay of a parent controller? Isn't this somethings which depends on the characteristics of the controller (possibly configurable by user space) such as the cost of runtime suspending and resuming?
Only in some cases will the serdev driver know it's safe to configure the parent controller. Configuring the parent controller from userspace works just fine as we've seen for years now.
Quoted 3 lines
The patch I posted works with what we have today; if a parent serial controller driver uses aggressive runtime PM by default or after having been configured through sysfs to do so.
Yeah let's stick with configuring the parent controller from userspace for now at least.
Quoted 4 lines
What I'm getting at here is that the delay should be set by the serial driver implementing aggressive runtime PM. Then all we need is a mechanism to determine whether an extra RPM reference should be taken at tty open or not (configurable by user space, defaulting to yes).
OK yeah some additional on/off switch seems to be missing here.
Quoted 3 lines
Specifically, the serial drivers themselves would always use autosuspend and not have to deal with supporting the two RPM schemes (normal vs aggressive runtime PM).
OK. So if I understand your idea right, we could have autosuspend timeout set to 3000ms in the 8250_omap.c but still default to RPM blocked? Then user can enable aggressive PM via /sys as desired, right?
Regards,
Tony
Johan Hovold
maintainerRe: OMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
Quoted 4 lines · Tony Lindgren
Quoted 2 lines · Johan Hovold
Quoted 1 line · Tony Lindgren
* Johan Hovold <[email protected]> [180517 10:12]:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Well in that case we should just stick with -1 value for the autosuspend. And just do
pm_runtime_put_sync_suspend()after probe and on close.That won't work either as a negative autosuspend delay prevents runtime suspend completely (by grabbing an extra RPM reference).
Well so negative autosuspend delay is working as documented then :)
Yes, indeed. All too well. ;)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
I fail to see how we can implement this using the current toolbox. What you're after here is really a mechanism for selecting between two different runtime PM schemes at runtime:
1. normal serial RPM, where the controller is active while the port is open (this should be the safe default)
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Agreed. And that is the case already.
Yes, but it's not really the case today as since omap-serial (and 8250-omap) sets a negative autosuspend at probe and hence does not runtime-suspend when the port is closed. So that's the long-standing bug which needs fixing.
Yes the bug for closed ports needs to be fixed for sure.
I did some forensic on this and it seems this problem has "always" been there. Specifically, closed ports have never been runtime suspended unless a non-negative autosuspend delay has been set by user space since fcdca75728ac ("ARM: OMAP2+: UART: Add runtime pm support for omap-serial driver") which was merged seven years ago.
So while it would certainly be nice to save some more power by default, this would really be a new feature rather than a bug or regression fix (which reduces the urgency for this issue somewhat too).
Quoted 15 lines
Quoted 15 lines
Quoted 9 lines
Quoted 3 lines
2. aggressive serial RPM, where the controller is allowed to suspend while the port is open even though this may result in lost characters when waking up on incoming data
In this case it seems that the only thing needed is to just configure the autosuspend delay for the parent port. The use of -1 has been around since the start of runtime PM AFAIK, so maybe we should just document it. I guess we could also introduce
pm_runtime_block_autoidle_unless_configured():)The implications of a negative autosuspend delay are already documented (in
Documentation/power/runtime_pm.txt); it's just the omap drivers that gets it wrong when trying to do things which aren't currently supported (and never have been).
Quoted 5 lines
Quoted 1 line
So I still think we need a new mechanism for this.
Well if you have some better mechanism in mind let's try it out. Short of sprinkling pm_runtime_force_suspend/resume calls all over, I'm out of ideas right now.
Yeah, that would be too much of a hack and likely wouldn't work either (and we really should do away with those _force calls altogether).
I've been thinking a bit too much about this already, but it may be possible to use the pm QoS framework for this. A resume latency can be set through sysfs where "n/a" is defined to mean "no latency accepted" (i.e. controller remains always-on while port is open) and "0" means "any latency accepted" (i.e. omap aggressive serial RPM is allowed).
Now, implementing this may get a little tricky as we want to be able to change this setting on the fly (consider consoles) and we need to figure out the interaction with serdev (user space should probably not be allowed to request a resume latency for ports used by serdev).
I'd be happy to dig into this some more, but not in my spare time I'm afraid.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
For normal ttys, we need a user-space interface for selecting between the two, and for serdev we may want a way to select the RPM scheme from within the kernel.
Note that with my serdev controller runtime PM patch, serdev core could always opt for aggressive PM (as by default serdev core holds an RPM reference for the controller while the port is open).
So if your serdev controller was to set the parent autosuspend delay on
open()and set it back onclose()this should work?
Quoted 8 lines
Quoted 4 lines
Is it really the job of a serdev driver to set the autosuspend delay of a parent controller? Isn't this somethings which depends on the characteristics of the controller (possibly configurable by user space) such as the cost of runtime suspending and resuming?
Only in some cases will the serdev driver know it's safe to configure the parent controller. Configuring the parent controller from userspace works just fine as we've seen for years now.
Yes, user space may override the default settings provided by the serial driver, but a serdev driver, in contrast, knows nothing about the underlying serial hardware.
Quoted 6 lines
Quoted 3 lines
The patch I posted works with what we have today; if a parent serial controller driver uses aggressive runtime PM by default or after having been configured through sysfs to do so.
Yeah let's stick with configuring the parent controller from userspace for now at least.
Yep, status quo works for the time being (since this isn't a regression).
Quoted 6 lines
Quoted 4 lines
What I'm getting at here is that the delay should be set by the serial driver implementing aggressive runtime PM. Then all we need is a mechanism to determine whether an extra RPM reference should be taken at tty open or not (configurable by user space, defaulting to yes).
OK yeah some additional on/off switch seems to be missing here.
As mentioned above, PM QoS resume latency may possibly be used, and otherwise me may able to define a new (generic) QoS flag for this.
Quoted 7 lines
Quoted 3 lines
Specifically, the serial drivers themselves would always use autosuspend and not have to deal with supporting the two RPM schemes (normal vs aggressive runtime PM).
OK. So if I understand your idea right, we could have autosuspend timeout set to 3000ms in the
8250_omap.cbut still default to RPM blocked? Then user can enable aggressive PM via /sys as desired, right?
Not RPM blocked; the ports must always be able to suspend when the port is closed. But user space should be able to enable the aggressive (active) runtime PM via sysfs independently of the autosuspend delay, yes.
Thanks,
Johan
Re: OMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
Quoted 10 lines · Johan Hovold
Quoted 2 lines · Tony Lindgren
Yes the bug for closed ports needs to be fixed for sure.
I did some forensic on this and it seems this problem has "always" been there. Specifically, closed ports have never been runtime suspended unless a non-negative autosuspend delay has been set by user space since
fcdca75728ac("ARM: OMAP2+: UART: Add runtime pm support for omap-serial driver") which was merged seven years ago.
Quoted 3 lines
So while it would certainly be nice to save some more power by default, this would really be a new feature rather than a bug or regression fix (which reduces the urgency for this issue somewhat too).
Yes it's been there since the start.
Quoted 21 lines
Quoted 15 lines
Quoted 15 lines
Quoted 9 lines
Quoted 3 lines
2. aggressive serial RPM, where the controller is allowed to suspend while the port is open even though this may result in lost characters when waking up on incoming data
In this case it seems that the only thing needed is to just configure the autosuspend delay for the parent port. The use of -1 has been around since the start of runtime PM AFAIK, so maybe we should just document it. I guess we could also introduce
pm_runtime_block_autoidle_unless_configured():)The implications of a negative autosuspend delay are already documented (in
Documentation/power/runtime_pm.txt); it's just the omap drivers that gets it wrong when trying to do things which aren't currently supported (and never have been).Quoted 5 lines
Quoted 1 line
So I still think we need a new mechanism for this.
Well if you have some better mechanism in mind let's try it out. Short of sprinkling pm_runtime_force_suspend/resume calls all over, I'm out of ideas right now.
Quoted 8 lines
Yeah, that would be too much of a hack and likely wouldn't work either (and we really should do away with those
_forcecalls altogether).I've been thinking a bit too much about this already, but it may be possible to use the pm QoS framework for this. A resume latency can be set through sysfs where "n/a" is defined to mean "no latency accepted" (i.e. controller remains always-on while port is open) and "0" means "any latency accepted" (i.e. omap aggressive serial RPM is allowed).
Oh yeah, PM QoS might work here!
Quoted 4 lines
Now, implementing this may get a little tricky as we want to be able to change this setting on the fly (consider consoles) and we need to figure out the interaction with serdev (user space should probably not be allowed to request a resume latency for ports used by serdev).
It sounds like Andy Shevchenko has a series of patches that just might allow us to make this all generic for Linux serial framework. So adding Andy to Cc, I don't think he has posted all the patches yet.
Andy, see the PM QoS comment above for console idling :)
Quoted 2 lines
I'd be happy to dig into this some more, but not in my spare time I'm afraid.
Indeed.
Quoted 39 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
For normal ttys, we need a user-space interface for selecting between the two, and for serdev we may want a way to select the RPM scheme from within the kernel.
Note that with my serdev controller runtime PM patch, serdev core could always opt for aggressive PM (as by default serdev core holds an RPM reference for the controller while the port is open).
So if your serdev controller was to set the parent autosuspend delay on
open()and set it back onclose()this should work?Quoted 8 lines
Quoted 4 lines
Is it really the job of a serdev driver to set the autosuspend delay of a parent controller? Isn't this somethings which depends on the characteristics of the controller (possibly configurable by user space) such as the cost of runtime suspending and resuming?
Only in some cases will the serdev driver know it's safe to configure the parent controller. Configuring the parent controller from userspace works just fine as we've seen for years now.
Yes, user space may override the default settings provided by the serial driver, but a serdev driver, in contrast, knows nothing about the underlying serial hardware.
Quoted 6 lines
Quoted 3 lines
The patch I posted works with what we have today; if a parent serial controller driver uses aggressive runtime PM by default or after having been configured through sysfs to do so.
Yeah let's stick with configuring the parent controller from userspace for now at least.
Yep, status quo works for the time being (since this isn't a regression).
Quoted 5 lines
Quoted 4 lines
What I'm getting at here is that the delay should be set by the serial driver implementing aggressive runtime PM. Then all we need is a mechanism to determine whether an extra RPM reference should be taken at tty open or not (configurable by user space, defaulting to yes).
Quoted 4 lines
Quoted 1 line
OK yeah some additional on/off switch seems to be missing here.
As mentioned above, PM QoS resume latency may possibly be used, and otherwise me may able to define a new (generic) QoS flag for this.
Good idea.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Specifically, the serial drivers themselves would always use autosuspend and not have to deal with supporting the two RPM schemes (normal vs aggressive runtime PM).
Quoted 8 lines
Quoted 3 lines
OK. So if I understand your idea right, we could have autosuspend timeout set to 3000ms in the
8250_omap.cbut still default to RPM blocked? Then user can enable aggressive PM via /sys as desired, right?Not RPM blocked; the ports must always be able to suspend when the port is closed. But user space should be able to enable the aggressive (active) runtime PM via sysfs independently of the autosuspend delay, yes.
Yup OK, I like the PM QoS approach.
Regards,
Tony
Johan Hovold
maintainerRe: OMAP serial runtime PM and autosuspend (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding))
Quoted 10 lines · Tony Lindgren
Quoted 9 lines · Johan Hovold
Quoted 3 lines · Tony Lindgren
Well if you have some better mechanism in mind let's try it out. Short of sprinkling pm_runtime_force_suspend/resume calls all over, I'm out of ideas right now.
Yeah, that would be too much of a hack and likely wouldn't work either (and we really should do away with those
_forcecalls altogether).
Quoted 7 lines
Quoted 5 lines
I've been thinking a bit too much about this already, but it may be possible to use the pm QoS framework for this. A resume latency can be set through sysfs where "n/a" is defined to mean "no latency accepted" (i.e. controller remains always-on while port is open) and "0" means "any latency accepted" (i.e. omap aggressive serial RPM is allowed).
Oh yeah, PM QoS might work here!
Actually, after reading a recent QoS related bug report, I realised that a resume latency request of "n/a" is actually a third way of disabling runtime PM, which similarly to the negative autosuspend would prevent also a closed port from suspending.
Using a small positive resume latency for this feels like too much of a hack, but defining a new QoS flag might still work.
Johan
Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
In reply to Johan HovoldHi,
Quoted 19 lines · Johan Hovold
Quoted 9 lines · Tony Lindgren
Quoted 8 lines · Johan Hovold
Quoted 5 lines · Sebastian Reichel
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
Quoted 8 lines
Quoted 5 lines
I'm not sure we want generic runtime-pm support for the controllers in the sense that the slave device state is always reflected by the serial controller. Similar as for i2c and spi, we really only want to keep the controller active when we are doing I/O, but we may want to keep a client active for longer.
Yeah i2c seems to do the right thing where the bus takes care of runtime PM.
Quoted 8 lines
Yeah, but since serial is async in contrast to i2c/spi, we may not be able to push this entirely into core. The serdev drivers may need to indicate when they expect or need to do I/O by opening and closing the port. And this is how I implemented these first couple of gnss drivers.
Also note that most serial driver do not do runtime pm while the port is open (as OMAP does), and doing so also has the drawbacks of lost characters etc. as Sebastian mentioned.
I think using open/close for runtime pm is good enough for GPS, since it regularly sends data and draws lots of power anyways. But devices, that have an out-of-band wakeup signal can do proper runtime PM of the serial port without loosing characters.
Note, that OMAP does not reach deep idle states with active serial port. This is not acceptable for low power devices.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Take the u-blox driver in this series for example. As I'm using runtime PM to manage device power, user-space can chose to prevent the receiver from runtime suspending in order to avoid lengthy (re-)acquisition times in setups without a backup battery (by means of the power/control attribute).
Quoted 10 lines
Quoted 2 lines
Sorry I don't seem to have that one, care to paste the subject line of that patch?
"[PATCH 5/7] gnss: add driver for u-blox receivers" https://lkml.kernel.org/r/[email protected]Quoted 3 lines
Quoted 3 lines
Note that serdev not enabling runtime pm for controllers is roughly equivalent to setting the .ignore_children flag, which is what we do for i2c and spi controller, and possibly what we want here too.
For I2C/SPI this works, since receive operations are initiated by the controller. Unfortunately its harder to implement for async serial. But I agree, that we may want to have runtime PM for the serdev client and .ignore_children is the way to go.
I think the client API should allow two things:
1. minimal runtime PM support: The controller is runtime enabled on serdev open and disabled on serdev close. This may be enough for some clients and useful for writing new drivers.
2. full runtime PM support: The controller is sleeping by default even with serdev open. The calls to write/change port settings/... automatically enables the device, similar to i2c/spi. But there must be additional functions to enable/disable runtime PM based on a wakeup gpio or similar out-of-band information. It may be enough to just provide:
int serdev_pm_runtime_get_sync(struct serdev_device *serdev) {
pm_runtime_get_sync(&serdev->dev);
}int serdev_pm_runtime_put_autosuspend(struct serdev_device *serdev) {
pm_runtime_put_autosuspend(&serdev->dev);
}-- Sebastian
Johan Hovold
maintainerSerdev runtime PM (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding)
[ Changing the subject line as this is thread is no longer about DT
bindings.
Also adding linux-serial and linux-pm while keeping some context. ]
Quoted 27 lines · Sebastian Reichel
Hi,
Quoted 24 lines · Johan Hovold
Quoted 9 lines · Tony Lindgren
Quoted 8 lines · Johan Hovold
Quoted 5 lines · Sebastian Reichel
Having said all of this, serdev does not yet support runtime PM (at all). Tony is currently looking into it. Fortunately serdev allows us to enable runtime PM by default (once implemented), since we know the remote side and can (hopefully) avoid losing characters (i.e. with sideband wakeup gpios).
Quoted 8 lines
Quoted 5 lines
I'm not sure we want generic runtime-pm support for the controllers in the sense that the slave device state is always reflected by the serial controller. Similar as for i2c and spi, we really only want to keep the controller active when we are doing I/O, but we may want to keep a client active for longer.
Yeah i2c seems to do the right thing where the bus takes care of runtime PM.
Yeah, but since serial is async in contrast to i2c/spi, we may not be able to push this entirely into core. The serdev drivers may need to indicate when they expect or need to do I/O by opening and closing the port. And this is how I implemented these first couple of gnss drivers.
Quoted 8 lines
Quoted 3 lines
Also note that most serial driver do not do runtime pm while the port is open (as OMAP does), and doing so also has the drawbacks of lost characters etc. as Sebastian mentioned.
I think using open/close for runtime pm is good enough for GPS, since it regularly sends data and draws lots of power anyways. But devices, that have an out-of-band wakeup signal can do proper runtime PM of the serial port without loosing characters.
Yeah, there may be some applications where this is possible. And this is not the case for GPS, but not just because of a generally higher power consumption, but due to the fact that we cannot afford having the first message in every report burst be dropped.
Quoted 2 lines
Note, that OMAP does not reach deep idle states with active serial port. This is not acceptable for low power devices.
Sure, but note that OMAP is the only serial driver which currently implements this kind of aggressive runtime PM (besides a couple of usb-serial drivers). This means that a serdev driver can never rely on this being the case, and therefore needs to be restrictive about how long the port is kept open if it cares about power at all.
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
Quoted 5 lines
Take the u-blox driver in this series for example. As I'm using runtime PM to manage device power, user-space can chose to prevent the receiver from runtime suspending in order to avoid lengthy (re-)acquisition times in setups without a backup battery (by means of the power/control attribute).
Sorry I don't seem to have that one, care to paste the subject line of that patch?
"[PATCH 5/7] gnss: add driver for u-blox receivers" https://lkml.kernel.org/r/[email protected]
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Note that serdev not enabling runtime pm for controllers is roughly equivalent to setting the .ignore_children flag, which is what we do for i2c and spi controller, and possibly what we want here too.
For I2C/SPI this works, since receive operations are initiated by the controller. Unfortunately its harder to implement for async serial. But I agree, that we may want to have runtime PM for the serdev client and .ignore_children is the way to go.
It's really about adding runtime PM support to serdev controllers. Serdev client drivers can already use runtime PM (as mentioned above).
The ignore_children flag would then allow the controller RPM state to be managed independently of the child/slave device state when more fine grained RPM control is desired.
Quoted 5 lines
I think the client API should allow two things:
1. minimal runtime PM support: The controller is runtime enabled on serdev open and disabled on serdev close. This may be enough for some clients and useful for writing new drivers.
Right, and we already have something like this today by means of how the serial driver implement runtime PM (i.e. they are generally active while the port is open).
Quoted 7 lines
2. full runtime PM support: The controller is sleeping by default even with serdev open. The calls to write/change port settings/... automatically enables the device, similar to i2c/spi. But there must be additional functions to enable/disable runtime PM based on a wakeup gpio or similar out-of-band information. It may be enough to just provide:
Quoted 7 lines
int serdev_pm_runtime_get_sync(struct serdev_device *serdev) { pm_runtime_get_sync(&serdev->dev); }int serdev_pm_runtime_put_autosuspend(struct serdev_device *serdev) { pm_runtime_put_autosuspend(&serdev->dev); }
I'm not a big fan of rpm wrappers and prefer using the RPM interface directly, but that's a side note. In the above case we really want to manage the controller (&serdev->ctrl->dev) rather than the client however (.ignore_children should be set, remember).
Also note that a serial driver implementing aggressive RPM (e.g. using autosuspend) would manage the RPM counts itself when changing terminal settings etc, so the only thing that would be needed is for the client/slave device to resume the controller pro-actively when it is expecting incoming data.
To make this more concrete; an example could be a device with an OOB wake-up signal, but using a request-response type protocol so that the client driver knows when it's safe to allow the controller to again suspend.
We can model this similarly to how we do it for usb-serial, namely that the core takes an extra RPM reference at open, which a sufficiently power aware driver can then chose to drop in order to allow for more aggressive controller runtime PM (should the underlying device and driver support it).
I've cooked up a patch which I'll be sending as a reply to this mail.
Thanks,
Johan
Johan Hovold
maintainerRe: Serdev runtime PM (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding)
Quoted 1 line · Johan Hovold
I've cooked up a patch which I'll be sending as a reply to this mail.
Forgot to add the in-reply-to header of course. For the interested, the patch can be found here:
https://lkml.kernel.org/r/[email protected]
Johan
Re: Serdev runtime PM (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding)
In reply to Johan HovoldQuoted 10 lines · Johan Hovold
Quoted 4 lines · Sebastian Reichel
I think using open/close for runtime pm is good enough for GPS, since it regularly sends data and draws lots of power anyways. But devices, that have an out-of-band wakeup signal can do proper runtime PM of the serial port without loosing characters.
Yeah, there may be some applications where this is possible. And this is not the case for GPS, but not just because of a generally higher power consumption, but due to the fact that we cannot afford having the first message in every report burst be dropped.
Well most of the phone implementations use one or two out of band GPIOs to first wake the UART before any data is sent. For serdev this can be called from the serdev consumer write function for TX. For RX, the serdev consumer needs to implement an interrupt handler and wake up the parent UART before serdev RX.
Quoted 8 lines
Quoted 2 lines
Note, that OMAP does not reach deep idle states with active serial port. This is not acceptable for low power devices.
Sure, but note that OMAP is the only serial driver which currently implements this kind of aggressive runtime PM (besides a couple of usb-serial drivers). This means that a serdev driver can never rely on this being the case, and therefore needs to be restrictive about how long the port is kept open if it cares about power at all.
Well by default we don't allow lossy UART. It needs to be manually configured via /sys for the timeout. With serdev, this can all be done with no /sys configuration needed for the cases with GPIO wake irqs :)
Regards,
Tony
Johan Hovold
maintainerRe: Serdev runtime PM (was: Re: [PATCH 4/7] dt-bindings: gnss: add u-blox binding)
Quoted 12 lines · Tony Lindgren
Quoted 10 lines · Johan Hovold
Quoted 4 lines · Sebastian Reichel
I think using open/close for runtime pm is good enough for GPS, since it regularly sends data and draws lots of power anyways. But devices, that have an out-of-band wakeup signal can do proper runtime PM of the serial port without loosing characters.
Yeah, there may be some applications where this is possible. And this is not the case for GPS, but not just because of a generally higher power consumption, but due to the fact that we cannot afford having the first message in every report burst be dropped.
Quoted 5 lines
Well most of the phone implementations use one or two out of band GPIOs to first wake the UART before any data is sent. For serdev this can be called from the serdev consumer write function for TX. For RX, the serdev consumer needs to implement an interrupt handler and wake up the parent UART before serdev RX.
Right, but the client driver would then wake the parent controller when expecting RX, while waking its own (serial-attached) device when wanting to do TX.
Just for the record, we also cleared this up here:
https://marc.info/?l=linux-kernel&m=152604434504868&w=2
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Note, that OMAP does not reach deep idle states with active serial port. This is not acceptable for low power devices.
Sure, but note that OMAP is the only serial driver which currently implements this kind of aggressive runtime PM (besides a couple of usb-serial drivers). This means that a serdev driver can never rely on this being the case, and therefore needs to be restrictive about how long the port is kept open if it cares about power at all.
Quoted 4 lines
Well by default we don't allow lossy UART. It needs to be manually configured via /sys for the timeout. With serdev, this can all be done with no /sys configuration needed for the cases with GPIO wake irqs :)
Indeed, but serdev client drivers must also work with serial drivers which do not implement this kind of aggressive runtime PM, and then the only way to save power is to close the port when not in use.
Thanks,
Johan
Johan Hovold
maintainerRe: [PATCH 4/7] dt-bindings: gnss: add u-blox binding
In reply to H. Nikolaus SchallerQuoted 6 lines · H. Nikolaus Schaller
I have realized that the w2sg0004 is an exception (although a Sirf chip) that it does not provide a WAKEUP signal. And another significant difference is that we have to keep the serdev UART enabled even if there is no user-space client. Otherwise we are not able to detect unexpected activity. So we unfortunately can't move serdev open/close into the .open and .close ops but need to open it in probe.
As have also been discussed elsewhere in this thread it may be possible, and it is definitely desirable, to only keep the port open when really needed. But given the complexity of implementing this, starting with a simpler and less power efficient method for sirf-chips without WAKEUP may be acceptable.
Quoted 4 lines
Therefore, it is in my opinion still better to have a separate driver for the w2sg0004 instead of hacking the support of this chip into your WAKEUP capable sirfstar driver. So I suggest that you make WAKEUP a required property.
I disagree. The sirf driver subsumes your particular wi2wi module and configurations without WAKEUP are described by the datasheets for other modules as well.
Quoted 3 lines
We had faced a comparable decision last year with the ov9650 and ov9655 camera sensors which are almost the same. But not same enough to integrate both into a single driver.
But here we are talking about two configuration for the same chip (even if your particular chip only supports one).
Johan
Johan Hovold
maintainerPATCH 5/7 gnss: add driver for u-blox receivers
In reply to Johan HovoldAdd driver for serial-connected u-blox GNSS receivers.
Note that the driver uses the generic GNSS serial implementation and therefore essentially only manages power abstracted into three power
states: ACTIVE, STANDBY, and OFF.
For u-blox receivers with a single supply and no enable-gpios, this simply means that the main supply is disabled in STANDBY and OFF.
Note that timepulse-support is not yet implemented.
--- drivers/gnss/Kconfig | 13 +++++ drivers/gnss/Makefile | 3 + drivers/gnss/ubx.c | 133 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 drivers/gnss/ubx.c
drivers/gnss/Kconfig +13 -0
@@ -15,4 +15,17 @@ if GNSS config GNSS_SERIAL tristate +config GNSS_UBX_SERIAL + tristate "u-blox GNSS receiver support" + depends on SERIAL_DEV_BUS + select GNSS_SERIAL + ---help--- + Say Y here if you have a u-blox GNSS receiver which uses a serial + interface. + + To compile this driver as a module, choose M here: the module will + be called gnss-ubx. + + If unsure, say N. + endif # GNSS
drivers/gnss/Makefile +3 -0
@@ -8,3 +8,6 @@ gnss-y := core.o obj-$(CONFIG_GNSS_SERIAL) += gnss-serial.o gnss-serial-y := serial.o + +obj-$(CONFIG_GNSS_UBX_SERIAL) += gnss-ubx.o +gnss-ubx-y := ubx.o
drivers/gnss/ubx.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.17.0
Johan Hovold
maintainerPATCH 6/7 dt-bindings: gnss: add sirfstar binding
In reply to Johan HovoldAdd binding for SiRFstar-based GNSS receivers.
Note that while four compatible-strings are initially added representing devices which differ in which I/O interfaces they support, they otherwise essentially share the same feature set.
Pin and supply names (and some recommended timings) vary slightly, but the binding recommends using a common set of names.
Note that the wakeup gpio is not intended to be as a wakeup source, but rather to detect the current power state of the device (active or hibernate).
--- .../devicetree/bindings/gnss/sirfstar.txt | 38 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 3 ++ 2 files changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/sirfstar.txt
Documentation/devicetree/bindings/gnss/sirfstar.txt new file +38 -0
@@ -0,0 +1,38 @@ +SiRFstar-based GNSS Receiver DT binding + +SiRFstar chipsets are used in GNSS-receiver modules produced by several +vendors and can use UART, SPI or I2C interfaces. + +Please see Documentation/devicetree/bindings/gnss/gnss.txt for generic +properties. + +Required Properties: + +- compatible : Must be one of + + "fastrax,uc430" + "linx,r4" + "wi2wi,w2sg0008i" + "wi2wi,w2sg0084i" + +- vcc-supply : Main voltage regulator (3V3_IN, VDD, VCC) + +Optional Properties: + +- enable-gpios : GPIO used to power on and off device (ON_OFF) +- wakeup-gpios : GPIO used to determine device power state (WAKEUP, RFPWRUP) +- timepulse-gpios : Timepulse (e.g 1PPS) GPIO (1PPS, TM) + +Example: + +serial@1234 { + compatible = "ns16550a"; + + gnss { + compatible = "wi2wi,w2sg0084i"; + + vcc-supply = <&gnss_reg>; + enable-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + wakeup-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; + }; +};
Documentation/devicetree/bindings/vendor-prefixes.txt +3 -0
@@ -120,6 +120,7 @@ excito Excito ezchip EZchip Semiconductor fairphone Fairphone B.V. faraday Faraday Technology Corporation +fastrax Fastrax Oy fcs Fairchild Semiconductor firefly Firefly focaltech FocalTech Systems Co.,Ltd
@@ -197,6 +198,7 @@ licheepi Lichee Pi linaro Linaro Limited linksys Belkin International, Inc. (Linksys) linux Linux-specific binding +linx Linx Technologies lltc Linear Technology Corporation lsi LSI Corp. (LSI Logic) lwn Liebherr-Werk Nenzing GmbH
@@ -390,6 +392,7 @@ vivante Vivante Corporation vocore VoCore Studio voipac Voipac Technologies s.r.o. vot Vision Optical Technology Co., Ltd. +wi2wi Wi2Wi wd Western Digital Corp. wetek WeTek Electronics, limited. wexler Wexler
Signature · 1 line
2.17.0
Re: [PATCH 6/7] dt-bindings: gnss: add sirfstar binding
Quoted 13 lines · Johan Hovold
Add binding for SiRFstar-based GNSS receivers.
Note that while four compatible-strings are initially added representing devices which differ in which I/O interfaces they support, they otherwise essentially share the same feature set.
Pin and supply names (and some recommended timings) vary slightly, but the binding recommends using a common set of names.
Note that the wakeup gpio is not intended to be as a wakeup source, but rather to detect the current power state of the device (active or hibernate).
Quoted 6 lines
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/gnss/sirfstar.txt | 38 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 3 ++ 2 files changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/sirfstar.txt
One nit below, otherwise:
Quoted 65 lines
Documentation/devicetree/bindings/gnss/sirfstar.txt new file +38
-0@@ -0,0 +1,38 @@ +SiRFstar-based GNSS Receiver DT binding + +SiRFstar chipsets are used in GNSS-receiver modules produced by several +vendors and can use UART, SPI or I2C interfaces. + +Please see Documentation/devicetree/bindings/gnss/gnss.txt for generic +properties. + +Required Properties: + +- compatible : Must be one of + + "fastrax,uc430" + "linx,r4" + "wi2wi,w2sg0008i" + "wi2wi,w2sg0084i" + +- vcc-supply : Main voltage regulator (3V3_IN, VDD, VCC) + +Optional Properties: + +- enable-gpios : GPIO used to power on and off device (ON_OFF) +- wakeup-gpios : GPIO used to determine device power state (WAKEUP, RFPWRUP) +- timepulse-gpios : Timepulse (e.g 1PPS) GPIO (1PPS, TM) + +Example: + +serial@1234 { + compatible = "ns16550a"; + + gnss { + compatible = "wi2wi,w2sg0084i"; + + vcc-supply = <&gnss_reg>; + enable-gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + wakeup-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; + }; +};Documentation/devicetree/bindings/vendor-prefixes.txt +2
-0@@ -120,6 +120,7 @@ excito Excito ezchip EZchip Semiconductor fairphone Fairphone B.V. faraday Faraday Technology Corporation +fastrax Fastrax Oy fcs Fairchild Semiconductor firefly Firefly focaltech FocalTech Systems Co.,Ltd@@ -197,6 +198,7 @@ licheepi Lichee Pi linaro Linaro Limited linksys Belkin International, Inc. (Linksys) linux Linux-specific binding +linx Linx Technologies lltc Linear Technology Corporation lsi LSI Corp. (LSI Logic) lwn Liebherr-Werk Nenzing GmbH
Documentation/devicetree/bindings/vendor-prefixes.txt vivante Vivante Corporation · line 395
Quoted 4 lines
Documentation/devicetree/bindings/vendor-prefixes.txt +1
-0@@ -390,6 +392,7 @@ vivante Vivante Corporation vocore VoCore Studio voipac Voipac Technologies s.r.o. vot Vision Optical Technology Co., Ltd. +wi2wi Wi2Wi
Wrong spot.
Quoted 6 lines
Documentation/devicetree/bindings/vendor-prefixes.txt +0
-1wd Western Digital Corp. wetek WeTek Electronics, limited. wexler Wexler --2.17.0
Johan Hovold
maintainerRe: [PATCH 6/7] dt-bindings: gnss: add sirfstar binding
Quoted 25 lines · Rob Herring
Quoted 13 lines · Johan Hovold
Add binding for SiRFstar-based GNSS receivers.
Note that while four compatible-strings are initially added representing devices which differ in which I/O interfaces they support, they otherwise essentially share the same feature set.
Pin and supply names (and some recommended timings) vary slightly, but the binding recommends using a common set of names.
Note that the wakeup gpio is not intended to be as a wakeup source, but rather to detect the current power state of the device (active or hibernate).
Quoted 6 lines
Signed-off-by Johan Hovold <[email protected]>--- .../devicetree/bindings/gnss/sirfstar.txt | 38 +++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 3 ++ 2 files changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/gnss/sirfstar.txtOne nit below, otherwise:
Reviewed-by Rob Herring <[email protected]>
Quoted 7 lines
Documentation/devicetree/bindings/vendor-prefixes.txt vivante Vivante Corporation · line 395
Quoted 5 lines
Documentation/devicetree/bindings/vendor-prefixes.txt +1
-0@@ -390,6 +392,7 @@ vivante Vivante Corporation vocore VoCore Studio voipac Voipac Technologies s.r.o. vot Vision Optical Technology Co., Ltd. +wi2wi Wi2WiWrong spot.
Duh. I had first misspelled this w2wi (which happens to be a different company), and then forgot to move the entry when I corrected my mistake.
Quoted 3 lines
Documentation/devicetree/bindings/vendor-prefixes.txt vivante Vivante Corporation · line 398
Quoted 3 lines
Documentation/devicetree/bindings/vendor-prefixes.txt +0
-0wd Western Digital Corp. wetek WeTek Electronics, limited. wexler Wexler
Thanks,
Johan
Johan Hovold
maintainerPATCH 7/7 gnss: add driver for sirfstar-based receivers
In reply to Johan HovoldAdd driver for serial-connected SiRFstar-based GNSS receivers.
These devices typically boot into hibernate mode from which they can be woken using a pulse on the ON_OFF (enable) input pin. Once active, a pulse on the same ON_OFF pin is used to put the device back into hibernate mode. The current state can be determined by sampling the WAKEUP output.
Hardware configurations where WAKEUP has been connected to ON_OFF (and where an initial WAKEUP pulse during boot is sufficient to have the device boot into active mode) are also supported. In this case, device power is managed using the main-supply regulator only.
Note that configurations where WAKEUP is left not connected, so that the device power state can only indirectly be determined using the I/O interface, is currently not supported. It should be fairly straight-forward to extend the current implementation with such support however (and this this is the main reason for not using the generic serial implementation for this driver).
Note that timepulse-support is left unimplemented.
--- drivers/gnss/Kconfig | 12 ++ drivers/gnss/Makefile | 3 + drivers/gnss/sirf.c | 415 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 430 insertions(+) create mode 100644 drivers/gnss/sirf.c
drivers/gnss/Kconfig +12 -0
@@ -15,6 +15,18 @@ if GNSS config GNSS_SERIAL tristate +config GNSS_SIRF_SERIAL + tristate "SiRFstar GNSS receiver support" + depends on SERIAL_DEV_BUS + ---help--- + Say Y here if you have a SiRFstar-based GNSS receiver which uses a + serial interface. + + To compile this driver as a module, choose M here: the module will + be called gnss-sirf. + + If unsure, say N. + config GNSS_UBX_SERIAL tristate "u-blox GNSS receiver support" depends on SERIAL_DEV_BUS
drivers/gnss/Makefile +3 -0
@@ -9,5 +9,8 @@ gnss-y := core.o obj-$(CONFIG_GNSS_SERIAL) += gnss-serial.o gnss-serial-y := serial.o +obj-$(CONFIG_GNSS_SIRF_SERIAL) += gnss-sirf.o +gnss-sirf-y := sirf.o + obj-$(CONFIG_GNSS_UBX_SERIAL) += gnss-ubx.o gnss-ubx-y := ubx.o
drivers/gnss/sirf.c new file +415 -0
415 lines not on this page · raw message
Signature · 1 line
2.17.0
Hi Johan,
Quoted 4 lines
Am 24.04.2018 um 18:34 schrieb Johan Hovold <[email protected]>:
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
Great!
Quoted 24 lines
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g.
/dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes and which also allows for easy detection and (eventually) identification of GNSS devices.Note that the character-device interface provides raw access to whatever protocol the receiver is (currently) using, such as NMEA 0183, UBX or SiRF Binary. These protocols are expected to be continued to be handled by user space for the time being, even if some hybrid solutions are also conceivable (e.g. to have kernel drivers issue management commands).
This will still allow for better platform integration by allowing GNSS devices and their resources (e.g. regulators and enable-gpios) to be described by firmware and managed by kernel drivers rather than platform-specific scripts and services.
Quoted 5 lines
While the current interface is kept minimal, it could be extended using IOCTLs, sysfs or uevents as needs and proper abstraction levels are identified and determined (e.g. for device and feature identification).
Another possible extension is to add generic 1PPS support.
would be nice but not first priority.
Quoted 11 lines
I decided to go with a custom character-device interface rather than pretend that these abstract GNSS devices are still TTY devices (e.g.
/dev/ttyGNSS0). Obviously, modifying line settings or reading modem control signals does not make any sense for a device using, say, a USB (not USB-serial) or iomem interface. This also means, however, that user space would no longer be able to set the line speed to match a new port configuration that can be set using the various GNSS protocols when the underlying interface is indeed a UART; instead this would need to be taken care of by the driver.
Quoted 6 lines
Also note that writes are always synchronous instead of requiring user space to call
tcdrain()after every command.This all seems to work well-enough (e.g. with gpsd), but please let me know if I've overlooked something which would indeed require a TTY interface instead.
tcgetattr() / tcsetattr() for controlling line disciplines, e.g. stty -icanon </dev/ttyGNSS0 do not work.
It may be possible to use non-blocking I/O or select() or threads to achieve the same result but may be more complex.
But gpsd seems not to make use of it (or has a built-in fallback - I have never looked into its code).
Quoted 6 lines
As proof-of-concept I have implemented drivers for receivers based on two common GNSS chipsets (SiRFstar and u-blox), but due to lack of hardware these have so far only been tested using mockup devices and a USB-serial-based GPS device (using out-of-tree code). [ Let me know if you've got any evalutation kits to spare. ]
Ok, those drivers look nice on first glance.
BTW: I have refactored our w2sg00x4 driver into a gps-core (still creating a /dev/GPS0) and a driver using a common API.
With that it should almost fit by coping some lines from your serdev based device drivers.
I haven't found time to submit anything, so it is just living (and working) in our private tree (please ignore w2cbw003 and trs3386 stuff):
http://git.goldelico.com/?p=gta04-kernel.git;a=shortlog;h=refs/heads/work/letux-base/hns/misc/w2sg-serdev-v6
http://git.goldelico.com/?p=gta04-kernel.git;a=commit;h=164c13373462596cabdd3b5308e5f7d8626a05af
Quoted 4 lines
Finally, note that documentation (including kerneldoc) remains to be written, but hopefully this will not hinder review given that the current interfaces are fairly self-describing.
I'll apply your patches and try to adjust our w2sg driver. And report issues if they arise.
BR and thanks,
Nikolaus
Quoted 44 lines
Johan
Johan Hovold (7):
gnss: add GNSS receiver subsystem
dt-bindings: add generic gnss binding
gnss: add generic serial driver
dt-bindings: gnss: add u-blox binding
gnss: add driver for u-blox receivers
dt-bindings: gnss: add sirfstar binding
gnss: add driver for sirfstar-based receivers.../devicetree/bindings/gnss/gnss.txt | 36 ++ .../devicetree/bindings/gnss/sirfstar.txt | 38 ++ .../devicetree/bindings/gnss/u-blox.txt | 31 ++ .../devicetree/bindings/vendor-prefixes.txt | 4 + MAINTAINERS | 7 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/gnss/Kconfig | 43 ++ drivers/gnss/Makefile | 16 + drivers/gnss/core.c | 385 ++++++++++++++++ drivers/gnss/serial.c | 288 ++++++++++++ drivers/gnss/serial.h | 47 ++ drivers/gnss/sirf.c | 415 ++++++++++++++++++ drivers/gnss/ubx.c | 133 ++++++ include/linux/gnss.h | 64 +++ 15 files changed, 1510 insertions(+)create mode 100644
Documentation/devicetree/bindings/gnss/gnss.txtcreate mode 100644Documentation/devicetree/bindings/gnss/sirfstar.txtcreate mode 100644Documentation/devicetree/bindings/gnss/u-blox.txtcreate mode 100644drivers/gnss/Kconfig
create mode 100644drivers/gnss/Makefile
create mode 100644drivers/gnss/core.c
create mode 100644drivers/gnss/serial.c
create mode 100644drivers/gnss/serial.h
create mode 100644drivers/gnss/sirf.c
create mode 100644drivers/gnss/ubx.c
create mode 100644include/linux/gnss.hSignature · 1 line
2.17.0
Johan Hovold
maintainerQuoted 10 lines · H. Nikolaus Schaller
Hi Johan,
Quoted 7 lines
Am 24.04.2018 um 18:34 schrieb Johan Hovold <[email protected]>:
As proof-of-concept I have implemented drivers for receivers based on two common GNSS chipsets (SiRFstar and u-blox), but due to lack of hardware these have so far only been tested using mockup devices and a USB-serial-based GPS device (using out-of-tree code). [ Let me know if you've got any evalutation kits to spare. ]
Quoted 7 lines
Ok, those drivers look nice on first glance.
BTW: I have refactored our w2sg00x4 driver into a gps-core (still creating a
/dev/GPS0) and a driver using a common API.With that it should almost fit by coping some lines from your serdev based device drivers.
I think it should be done the other way round (if I understand you correctly), that is, by adding support for configurations were WAKEUP is left not connected to the sirf driver instead. I had that use-case in mind when implementing the driver, and some ideas of how it should be done, but did not get around to actually implement it yet.
Thanks,
Johan
Quoted 19 lines
Am 24.04.2018 um 19:50 schrieb Johan Hovold <[email protected]>:
Quoted 15 lines · H. Nikolaus Schaller
Hi Johan,
Quoted 7 lines
Am 24.04.2018 um 18:34 schrieb Johan Hovold <[email protected]>:
As proof-of-concept I have implemented drivers for receivers based on two common GNSS chipsets (SiRFstar and u-blox), but due to lack of hardware these have so far only been tested using mockup devices and a USB-serial-based GPS device (using out-of-tree code). [ Let me know if you've got any evalutation kits to spare. ]
Ok, those drivers look nice on first glance.
BTW: I have refactored our w2sg00x4 driver into a gps-core (still creating a
/dev/GPS0) and a driver using a common API.
Quoted 6 lines
Quoted 2 lines
With that it should almost fit by coping some lines from your serdev based device drivers.
I think it should be done the other way round (if I understand you correctly), that is, by adding support for configurations were WAKEUP is left not connected to the sirf driver instead.
Hm. Yes, the w2sg00x4 is a Sirf based chip.
Quoted 1 line
I had that use-case in mind when implementing
s/implementing/reinventing/
Quoted 2 lines
the driver, and some ideas of how it should be done, but did not get around to actually implement it yet.
What do you need ideas for? We have that function working and submitted year after year, but it was always rejected for API reasons.
You could have simply reused what we have proposed [1] and just adapt it to the new API instead of writing a new driver (which is missing some features for us).
"proof-of-concept" is misleading if you expect this to become *the* Sirf driver and we are just invited to add some features to that. Making our own work and proposals completely obsolete.
What I find really strange and foul play is that we are in the review process and then comes a hidden counter-proposal by the reviewer.
Well, this is FOSS...
BR,
Nikolaus
Johan Hovold
maintainerQuoted 15 lines · H. Nikolaus Schaller
Quoted 5 lines
Am 24.04.2018 um 19:50 schrieb Johan Hovold <[email protected]>:
I think it should be done the other way round (if I understand you correctly), that is, by adding support for configurations were WAKEUP is left not connected to the sirf driver instead.
Hm. Yes, the w2sg00x4 is a Sirf based chip.
Quoted 1 line
I had that use-case in mind when implementing
s/implementing/reinventing/
Quoted 2 lines
the driver, and some ideas of how it should be done, but did not get around to actually implement it yet.
Quoted 7 lines
What do you need ideas for? We have that function working and submitted year after year, but it was always rejected for API reasons.
You could have simply reused what we have proposed [1] and just adapt it to the new API instead of writing a new driver (which is missing some features for us).
Your code was broken or needed to be updated in several ways as I pointed out in the thread you refer to.
It also did not support all those systems that use the same family of chips, but which has the WAKEUP signal connected.
Quoted 7 lines
"proof-of-concept" is misleading if you expect this to become *the* Sirf driver and we are just invited to add some features to that. Making our own work and proposals completely obsolete.
What I find really strange and foul play is that we are in the review process and then comes a hidden counter-proposal by the reviewer.
Dude, in the very same thread you refer to above, after being asked to reiterate your proposal to find and appropriate abstraction level you reply:
"Yes, please feel free to write patches that implement it that way."
Now I've done just that for you, and then you whine about that too.
SiRF is a very common chip and I wanted to make sure that the common setup with WAKEUP connected was supported from the start. I'll get to your configuration in time too.
Johan
Quoted 1 line
Hi Johan,
Quoted 23 lines
Am 25.04.2018 um 10:11 schrieb Johan Hovold <[email protected]>:
Quoted 19 lines · H. Nikolaus Schaller
Quoted 5 lines
Am 24.04.2018 um 19:50 schrieb Johan Hovold <[email protected]>:
I think it should be done the other way round (if I understand you correctly), that is, by adding support for configurations were WAKEUP is left not connected to the sirf driver instead.
Hm. Yes, the w2sg00x4 is a Sirf based chip.
Quoted 1 line
I had that use-case in mind when implementing
s/implementing/reinventing/
Quoted 2 lines
the driver, and some ideas of how it should be done, but did not get around to actually implement it yet.
What do you need ideas for? We have that function working and submitted year after year, but it was always rejected for API reasons.
Quoted 6 lines
Quoted 3 lines
You could have simply reused what we have proposed [1] and just adapt it to the new API instead of writing a new driver (which is missing some features for us).
Your code was broken or needed to be updated in several ways as I pointed out in the thread you refer to.
No, it was not broken (it is in daily use and no practical problems are known), but surely does not cover some corner-cases (e.g. races).
I said we should focus firstly on the "abstraction level". So I postponed these code issues from discussion.
In the end you announced to provide a new kernel API which would make most of the code (all tty stuff) and related problems go away anyways.
Therefore I simply did wait for this API to come, before fixing the remaining issues and submitting a new v6.
Quoted 2 lines
It also did not support all those systems that use the same family of chips, but which has the WAKEUP signal connected.
That is simply wrong.
It supports them. It just does not make use of the WAKEUP signal, but uses a different mechanism to detect the power state of the chip.
So our driver is more complete because it gracefully handles a WAKEUP line (by ignoring it) while yours doesn't handle the opposite case of a missing WAKEUP.
Quoted 9 lines
Quoted 8 lines
"proof-of-concept" is misleading if you expect this to become *the* Sirf driver and we are just invited to add some features to that. Making our own work and proposals completely obsolete.
What I find really strange and foul play is that we are in the review process and then comes a hidden counter-proposal by the reviewer.
Quoted 6 lines
Dude, in the very same thread you refer to above, after being asked to reiterate your proposal to find and appropriate abstraction level you reply:
"Yes, please feel free to write patches that implement it that way."
When looking back, I understand that as that I suggested to add a "proper abstraction level" (i.e. a gps framework) so that *we* can make use of it.
I never meant that you should completely replace our driver by an incomplete solution.
Quoted 2 lines
Now I've done just that for you, and then you whine about that too.
At the end of the thread (which I take as the result of v5 review) you said:
"Yeah, I think this is a dead end. We need some kind of gps framework with drivers that can implement the device specific bits.
I may have some time to look at little closer at it this week."
And I answered and laid down my plans for a v6:
"Ok, that would be fine if we can get that!
For a minimal set of API I think something like this (following hci_dev) would suffice:
...
If that would wrap all creation of some /dev/ttyGPS0 (or however it is called), it would fit our needs for a driver and user-space for our system.
And I would be happy to get rid of creating and registering a /dev/ttyGPS0 in the w2sg0004 driver.
Then, the driver will not need to be touched if the GPS framework is improved in some far future (e.g. to provide some additional ioctl for getting kalman-filtered position+heading by doing sensor fusion with some iio-based accelerometer/gyro).
So I am looking forward to some framework for review and integration testing."
I think it was clear and understandable what I expected (a new framework instead of creating ttys in the driver) and what I did not (a replacement of our w2sg0004 proposal with a variant with missing features).
The problem I have with this sort of review process is that I now have to reintegrate the missing pieces of handling the non-WAKEUP case and LNA control and rfkill into your code.
Instead of stripping down our code and adjusting to your API.
Alternatively I have to wait until you present some code of which you think it works. Would you also test it? Probably no. Because of lack of hardware. So I have to test your new code in an area where I have well-hung code being in daily use.
And your new code may still be incomplete wrt. what our driver provides to users.
I hope that you understand that this is now more work for me in any case...
So in the end I will have:
* a new but still incomplete driver that is a regression compared to our old driver
* even more testing work in addition 5 years urging for acceptance
* no appreciation because you sign off and author everything
Is this a good deal or a reason to contribute to our common project?
If you want an example how to get rid of volunteers contributing, this may be one...
Quoted 4 lines
SiRF is a very common chip and I wanted to make sure that the common setup with WAKEUP connected was supported from the start. I'll get to your configuration in time too.
As said, our driver would also work if the WAKEUP line exists, and is described in DT, but is broken.
So we will probably stay with our out-of the kernel driver for the time being.
BR,
Nikolaus
Quoted 1 line
Johan Hovold
maintainerQuoted 10 lines · H. Nikolaus Schaller
Quoted 10 lines
Am 25.04.2018 um 10:11 schrieb Johan Hovold <[email protected]>:
Quoted 5 lines · H. Nikolaus Schaller
Quoted 1 line
Am 24.04.2018 um 19:50 schrieb Johan Hovold <[email protected]>:
You could have simply reused what we have proposed [1] and just adapt it to the new API instead of writing a new driver (which is missing some features for us).
Quoted 5 lines
Quoted 2 lines
Your code was broken or needed to be updated in several ways as I pointed out in the thread you refer to.
No, it was not broken (it is in daily use and no practical problems are known), but surely does not cover some corner-cases (e.g. races).
I'd certainly be sceptical about accepting code into the kernel from anyone who completely ignores locking and considers concurrency to be a corner case that he cannot be bothered with.
Sure, out-of-tree code is often sub-par, and that is partly why it remains out of tree.
Quoted 9 lines
I said we should focus firstly on the "abstraction level". So I postponed these code issues from discussion.
In the end you announced to provide a new kernel API which would make most of the code (all tty stuff) and related problems go away anyways.
Therefore I simply did wait for this API to come, before fixing the remaining issues and submitting a new v6.
Yes, and that's perfectly reasonable, but I wouldn't want to base my work on something in that state.
Quoted 7 lines
Quoted 2 lines
It also did not support all those systems that use the same family of chips, but which has the WAKEUP signal connected.
That is simply wrong.
It supports them. It just does not make use of the WAKEUP signal, but uses a different mechanism to detect the power state of the chip.
Sure, but in a highly inefficient way since without WAKEUP you can never be certain that the device is in hibernate, but only assume so after a lengthy (as in seconds) timeout has passed without any I/O.
Quoted 3 lines
So our driver is more complete because it gracefully handles a WAKEUP line (by ignoring it) while yours doesn't handle the opposite case of a missing WAKEUP.
I never claimed to support your configuration from the start, but I kept it in mind while implementing the framework in order to facilitate for you.
Heck, besides getting the whole frame work implemented for you -- thereby making this the closest to mainline support for your system that you've been over the course of the past five years or however long you've been at it -- there's now also an already integrated generic sirf driver with all the basics in place (including runtime PM, and not relying on legacy interfaces) that you can base your work off of.
Quoted 12 lines
Quoted 12 lines
Quoted 7 lines
"proof-of-concept" is misleading if you expect this to become *the* Sirf driver and we are just invited to add some features to that. Making our own work and proposals completely obsolete.
What I find really strange and foul play is that we are in the review process and then comes a hidden counter-proposal by the reviewer.
Dude, in the very same thread you refer to above, after being asked to reiterate your proposal to find and appropriate abstraction level you reply:
Quoted 6 lines
Quoted 2 lines
"Yes, please feel free to write patches that implement it that way."When looking back, I understand that as that I suggested to add a "proper abstraction level" (i.e. a gps framework) so that *we* can make use of it.
Yes, you clearly weren't interesting in doing that work yourself.
Quoted 2 lines
I never meant that you should completely replace our driver by an incomplete solution.
But surely you didn't expect your work not to require any kind of integration into a new framework.
Quoted 27 lines
Quoted 1 line
Now I've done just that for you, and then you whine about that too.
At the end of the thread (which I take as the result of v5 review) you said:
"Yeah, I think this is a dead end. We need some kind of gps framework with drivers that can implement the device specific bits.
I may have some time to look at little closer at it this week."
And I answered and laid down my plans for a v6:
"Ok, that would be fine if we can get that!
For a minimal set of API I think something like this (following
hci_dev) would suffice:...
If that would wrap all creation of some
/dev/ttyGPS0(or however it is called), it would fit our needs for a driver and user-space for our system.And I would be happy to get rid of creating and registering a
/dev/ttyGPS0in the w2sg0004 driver.Then, the driver will not need to be touched if the GPS framework is improved in some far future (e.g. to provide some additional ioctl for getting kalman-filtered position+heading by doing sensor fusion with some iio-based accelerometer/gyro).
Quoted 5 lines
So I am looking forward to some framework for review and integration testing."
I think it was clear and understandable what I expected (a new framework instead of creating ttys in the driver) and what I did not (a replacement of our w2sg0004 proposal with a variant with missing features).
Sounds like you think you've given me some kind of order that I had to fulfil. Sorry, but it doesn't work that way.
Quoted 3 lines
The problem I have with this sort of review process is that I now have to reintegrate the missing pieces of handling the non-WAKEUP case and LNA control and rfkill into your code.
Yes, you're not getting everything for free.
Besides, I have concerns about using rfkill for GNSS (which does not transmit any radio), and external LNA control is not something that is a chip feature but rather something that should be handled by the framework.
So this wouldn't be a simple code dump for you anyway.
Quoted 6 lines
Instead of stripping down our code and adjusting to your API.
Alternatively I have to wait until you present some code of which you think it works. Would you also test it? Probably no. Because of lack of hardware. So I have to test your new code in an area where I have well-hung code being in daily use.
Of course I'll test it, but I can't say solving your problems for you again is at the top of my list, if it ever were.
Quoted 5 lines
And your new code may still be incomplete wrt. what our driver provides to users.
I hope that you understand that this is now more work for me in any case...
I fail to see how not having to implement a GNSS framework can be considered more work for you.
Quoted 3 lines
So in the end I will have:
* a new but still incomplete driver that is a regression compared to our old driver
It's not a regression, the new mainline driver just wouldn't support your configuration yet.
Quoted 2 lines
* even more testing work in addition 5 years urging for acceptance
* no appreciation because you sign off and author everything
You'd sign off on your own work (or was it really Neil Brown who implemented the driver that you've since been adapting?).
There's still room for adding support for sirf configurations without WAKEUP, generic LNA support, and possibly rfkill.
Quoted 4 lines
Is this a good deal or a reason to contribute to our common project?
If you want an example how to get rid of volunteers contributing, this may be one...
Come on...
Quoted 9 lines
Quoted 3 lines
SiRF is a very common chip and I wanted to make sure that the common setup with WAKEUP connected was supported from the start. I'll get to your configuration in time too.
As said, our driver would also work if the WAKEUP line exists, and is described in DT, but is broken.
So we will probably stay with our out-of the kernel driver for the time being.
Ok.
Johan
Hi!
Quoted 2 lines
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
Actually... I'd just call it GPS subsystem. Yes, GPS is a bit misleading, but so is GNSS. We'd like Loran to use similar interface, right? We'd like to QZSS to use similar interface, too...
https://www.pcworld.com/article/205325/japan_launches_its_first_gps_satellite.html
. QZSS is not _global_ positioning system. Still they call it GPS. I'd call it GPS too.
(Alternatively, we could have drivers/position and /dev/pos0...)
Looking closer... I'm not sure if it makes sense to push different protocols (SiRF, NMEA, ...) through one device. Userland should know what protocol to expect... Yes, there will be common code between /dev/nmea0 and /dev/sirf0...
I don't know. I'd really like to see '/dev/input/event0'-like layer, so that userland would not need to know about different protocols. But your work solves some problems we have now...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 15 lines · On Tue, 24 Apr 2018 22:13:19 +0200 Pavel Machek <[email protected]> wrote:
Hi!
Quoted 2 lines
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
Actually... I'd just call it GPS subsystem. Yes, GPS is a bit misleading, but so is GNSS. We'd like Loran to use similar interface, right? We'd like to QZSS to use similar interface, too...
https://www.pcworld.com/article/205325/japan_launches_its_first_gps_satellite.html
. QZSS is not _global_ positioning system. Still they call it GPS. I'd call it GPS too.(Alternatively, we could have
drivers/positionand/dev/pos0...)
Quoted 9 lines
Looking closer... I'm not sure if it makes sense to push different protocols (SiRF, NMEA, ...) through one device. Userland should know what protocol to expect... Yes, there will be common code between
/dev/nmea0and/dev/sirf0...I don't know. I'd really like to see '/dev/input/event0'-like layer, so that userland would not need to know about different protocols. But your work solves some problems we have now...
I am not really sure what to do here. The question is if we can remove nmea parsing from userspace if the kernel does it? There is the use-case of having external loggers storing nmea data and userspace will access the logger data and needs to have nmea parsing for that anyway.
But for other more exotic stuff, it would be helpful that the user space does not need to handle the differences.
Hmm, maybe userspace could register something like uinput devices for having more complex calculation. Maybe triangulating using gsm cell reception data. And the uinput-like device would have properties attached like accuracy, costs.
Regards,
Andreas
Johan Hovold
maintainerQuoted 33 lines · Andreas Kemnade
Quoted 15 lines · On Tue, 24 Apr 2018 22:13:19 +0200 Pavel Machek <[email protected]> wrote:
Hi!
Quoted 2 lines
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
Actually... I'd just call it GPS subsystem. Yes, GPS is a bit misleading, but so is GNSS. We'd like Loran to use similar interface, right? We'd like to QZSS to use similar interface, too...
https://www.pcworld.com/article/205325/japan_launches_its_first_gps_satellite.html
. QZSS is not _global_ positioning system. Still they call it GPS. I'd call it GPS too.(Alternatively, we could have
drivers/positionand/dev/pos0...)Quoted 9 lines
Looking closer... I'm not sure if it makes sense to push different protocols (SiRF, NMEA, ...) through one device. Userland should know what protocol to expect... Yes, there will be common code between
/dev/nmea0and/dev/sirf0...I don't know. I'd really like to see '/dev/input/event0'-like layer, so that userland would not need to know about different protocols. But your work solves some problems we have now...
I am not really sure what to do here. The question is if we can remove nmea parsing from userspace if the kernel does it? There is the use-case of having external loggers storing nmea data and userspace will access the logger data and needs to have nmea parsing for that anyway.
Quoted 7 lines
But for other more exotic stuff, it would be helpful that the user space does not need to handle the differences.
Hmm, maybe userspace could register something like uinput devices for having more complex calculation. Maybe triangulating using gsm cell reception data. And the uinput-like device would have properties attached like accuracy, costs.
There's also seems to be trend towards exposing raw measurements and experimenting with different Position-Velocity-Time algorithms in user space.
But in any case, moving gpsd into the kernel is not my aim here.
With a GNSS subsystem in place which would give us device detection and power management from the start, people can start experimenting with more features (e.g. device identification, feature flags, or possibly higher-level protocol interfaces).
Thanks,
Johan
Hi Pavel,
Quoted 6 lines
Quoted 2 lines
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
Actually... I'd just call it GPS subsystem. Yes, GPS is a bit misleading, but so is GNSS. We'd like Loran to use similar interface, right? We'd like to QZSS to use similar interface, too…
GNSS is the term that is known and used by everybody in the industry to identify GPS, GLONASS, Galileo etc.
Quoted 10 lines
https://www.pcworld.com/article/205325/japan_launches_its_first_gps_satellite.html
. QZSS is not _global_ positioning system. Still they call it GPS. I'd call it GPS too.(Alternatively, we could have
drivers/positionand/dev/pos0...)Looking closer... I'm not sure if it makes sense to push different protocols (SiRF, NMEA, ...) through one device. Userland should know what protocol to expect... Yes, there will be common code between
/dev/nmea0and /dev/sirf0…
Device node naming is pointless, use DEVTYPE uevent property for identifying the expected protocol.
Regards
Marcel
Johan Hovold
maintainerQuoted 5 lines · Pavel Machek
Hi!
Quoted 2 lines
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
Quoted 7 lines
Actually... I'd just call it GPS subsystem. Yes, GPS is a bit misleading, but so is GNSS. We'd like Loran to use similar interface, right? We'd like to QZSS to use similar interface, too...
https://www.pcworld.com/article/205325/japan_launches_its_first_gps_satellite.html
. QZSS is not _global_ positioning system. Still they call it GPS. I'd call it GPS too.
What Marcel said. Never heard of Loran, but apparently it's no longer in use:
https://en.wikipedia.org/wiki/Radio_navigation#Satellite_navigation
Quoted 1 line
(Alternatively, we could have
drivers/positionand/dev/pos0...)
If you find such a system in use and implement a driver for it, we'll just let it be the odd bird.
Quoted 4 lines
Looking closer... I'm not sure if it makes sense to push different protocols (SiRF, NMEA, ...) through one device. Userland should know what protocol to expect... Yes, there will be common code between
/dev/nmea0and/dev/sirf0...
That's not how GNSS devices work. It does not seem to be uncommon to switch to a vendor protocol with a richer feature set and back to NMEA (e.g. for configuration). Raw GNSS data may also be available over the vendor protocol, etc. And some devices even support using to protocols concurrently on one port.
I was going to call the device node /dev/gnssraw0 (cf. hidraw), but since "raw" GNSS measurement already has a meaning in this space I decided to drop that suffix. It can all be accessed over /dev/gnss0.
Quoted 3 lines
I don't know. I'd really like to see '/dev/input/event0'-like layer, so that userland would not need to know about different protocols. But your work solves some problems we have now...
Yeah, and moving gpsd into the kernel is probably never going to happen. But if it were, we probably wouldn't be using a character device to access it anyway.
Johan
Quoted 6 lines
As proof-of-concept I have implemented drivers for receivers based on two common GNSS chipsets (SiRFstar and u-blox), but due to lack of hardware these have so far only been tested using mockup devices and a USB-serial-based GPS device (using out-of-tree code). [ Let me know if you've got any evalutation kits to spare. ]
Do you have easy access to Nokia N900 or Motorola Droid 4? They should be reasonably cheap, and each provides unique challenge.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 8 lines
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
Quoted 6 lines
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g.
/dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes and which also allows for easy detection and (eventually) identification of GNSS devices.
Actually... no, what you done is not GNSS subsystem. It is generic subsystem for a link + some controls, typically for power.
Yes, that setup is common for GPS receivers, but it is there also for modems (droid 4: usb + gpios) and bluetooth dongles (n900: serial + gpios).
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
maintainerQuoted 17 lines · Pavel Machek
Hi!
Quoted 8 lines
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
Quoted 6 lines
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g.
/dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes and which also allows for easy detection and (eventually) identification of GNSS devices.
Quoted 6 lines
Actually... no, what you done is not GNSS subsystem. It is generic subsystem for a link + some controls, typically for power.
Yes, that setup is common for GPS receivers, but it is there also for modems (droid 4: usb + gpios) and bluetooth dongles (n900: serial + gpios).
Those would be handled by other subsystems.
The idea here is that eventually there may be more GNSS specific bits added, such as 1PPS support that I already mentioned. If someone is crazy enough to put a location service in the kernel with a more high-level interface (an in-kernel gpsd) they can try, but I'm more and more convinced that needs to remain in user space.
I did also already mentioned however, that some hybrid approach may be doable, such as handling port setup over NMEA/UBX/SiRF from within the kernel.
Johan
Greg Kroah-Hartman
maintainerQuoted 2 lines · Johan Hovold
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
YEAH!!!!
Thanks so much for doing this, great work!
Quoted 52 lines
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g.
/dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes and which also allows for easy detection and (eventually) identification of GNSS devices.Note that the character-device interface provides raw access to whatever protocol the receiver is (currently) using, such as NMEA 0183, UBX or SiRF Binary. These protocols are expected to be continued to be handled by user space for the time being, even if some hybrid solutions are also conceivable (e.g. to have kernel drivers issue management commands).
This will still allow for better platform integration by allowing GNSS devices and their resources (e.g. regulators and enable-gpios) to be described by firmware and managed by kernel drivers rather than platform-specific scripts and services.
While the current interface is kept minimal, it could be extended using IOCTLs, sysfs or uevents as needs and proper abstraction levels are identified and determined (e.g. for device and feature identification).
Another possible extension is to add generic 1PPS support.
I decided to go with a custom character-device interface rather than pretend that these abstract GNSS devices are still TTY devices (e.g.
/dev/ttyGNSS0). Obviously, modifying line settings or reading modem control signals does not make any sense for a device using, say, a USB (not USB-serial) or iomem interface. This also means, however, that user space would no longer be able to set the line speed to match a new port configuration that can be set using the various GNSS protocols when the underlying interface is indeed a UART; instead this would need to be taken care of by the driver.Also note that writes are always synchronous instead of requiring user space to call
tcdrain()after every command.This all seems to work well-enough (e.g. with gpsd), but please let me know if I've overlooked something which would indeed require a TTY interface instead.
As proof-of-concept I have implemented drivers for receivers based on two common GNSS chipsets (SiRFstar and u-blox), but due to lack of hardware these have so far only been tested using mockup devices and a USB-serial-based GPS device (using out-of-tree code). [ Let me know if you've got any evalutation kits to spare. ]
Quoted 3 lines
Finally, note that documentation (including kerneldoc) remains to be written, but hopefully this will not hinder review given that the current interfaces are fairly self-describing.
Is this just a RFC, or a "here's a first cut at submitting this, review it please!" submission? I'm glad to review if you think it's worth it at this point.
thanks,
greg k-h
Johan Hovold
maintainerQuoted 7 lines · Greg Kroah-Hartman
Quoted 2 lines · Johan Hovold
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
YEAH!!!!
Thanks so much for doing this, great work!
Thanks!
Quoted 10 lines
Quoted 10 lines
This all seems to work well-enough (e.g. with gpsd), but please let me know if I've overlooked something which would indeed require a TTY interface instead.
As proof-of-concept I have implemented drivers for receivers based on two common GNSS chipsets (SiRFstar and u-blox), but due to lack of hardware these have so far only been tested using mockup devices and a USB-serial-based GPS device (using out-of-tree code). [ Let me know if you've got any evalutation kits to spare. ]
Quoted 7 lines
Quoted 3 lines
Finally, note that documentation (including kerneldoc) remains to be written, but hopefully this will not hinder review given that the current interfaces are fairly self-describing.
Is this just a RFC, or a "here's a first cut at submitting this, review it please!" submission? I'm glad to review if you think it's worth it at this point.
It's more than just an RFC, so thanks for starting to review it.
Johan
Hi Johan,
Quoted 55 lines · Johan Hovold
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g.
/dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes and which also allows for easy detection and (eventually) identification of GNSS devices.Note that the character-device interface provides raw access to whatever protocol the receiver is (currently) using, such as NMEA 0183, UBX or SiRF Binary. These protocols are expected to be continued to be handled by user space for the time being, even if some hybrid solutions are also conceivable (e.g. to have kernel drivers issue management commands).
This will still allow for better platform integration by allowing GNSS devices and their resources (e.g. regulators and enable-gpios) to be described by firmware and managed by kernel drivers rather than platform-specific scripts and services.
While the current interface is kept minimal, it could be extended using IOCTLs, sysfs or uevents as needs and proper abstraction levels are identified and determined (e.g. for device and feature identification).
Another possible extension is to add generic 1PPS support.
I decided to go with a custom character-device interface rather than pretend that these abstract GNSS devices are still TTY devices (e.g.
/dev/ttyGNSS0). Obviously, modifying line settings or reading modem control signals does not make any sense for a device using, say, a USB (not USB-serial) or iomem interface. This also means, however, that user space would no longer be able to set the line speed to match a new port configuration that can be set using the various GNSS protocols when the underlying interface is indeed a UART; instead this would need to be taken care of by the driver.Also note that writes are always synchronous instead of requiring user space to call
tcdrain()after every command.This all seems to work well-enough (e.g. with gpsd), but please let me know if I've overlooked something which would indeed require a TTY interface instead.
As proof-of-concept I have implemented drivers for receivers based on two common GNSS chipsets (SiRFstar and u-blox), but due to lack of hardware these have so far only been tested using mockup devices and a USB-serial-based GPS device (using out-of-tree code). [ Let me know if you've got any evalutation kits to spare. ]
Quoted 3 lines
Finally, note that documentation (including kerneldoc) remains to be written, but hopefully this will not hinder review given that the current interfaces are fairly self-describing.
Great work. I like your design decisions. I have quite a few devices with have non-serial based GPS peripherals using binary protocols (*). As far as I can see it should be possible to add support for those.
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
(*) I have those in mind:
Nokia N900: The phone has GPS integrated into the modem and uses ISI encapsulated data. The protocol has been reverse engineered and it should be possible to write a kernel driver for handling the GPS packets and dumping the raw data to /dev/gnss0. I don't think this is particularly useful without a non-raw interface, though. It would still require a custom userspace implementation.
Nokia N950/N9: Those phones have an I2C connected BCM4751, which uses (proprietary, non-reverse-engineered) MEIF binary protocol. Nokia's kernel had a driver, which provides a similar userspace interface (char device with raw data from chip).
Droid 4: GPS is similar to N900, but different protocol and QMI encapsulated. This one also has known protocol with userspace implementation. I did not yet have a detailed look, if its possible to (un)wrap this in the kernel.
-- Sebastian
Hi!
Quoted 8 lines
Quoted 3 lines
Finally, note that documentation (including kerneldoc) remains to be written, but hopefully this will not hinder review given that the current interfaces are fairly self-describing.
Great work. I like your design decisions. I have quite a few devices with have non-serial based GPS peripherals using binary protocols (*). As far as I can see it should be possible to add support for those.
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
Yep, that would be nice.
Quoted 8 lines
(*) I have those in mind:
Nokia N900: The phone has GPS integrated into the modem and uses ISI encapsulated data. The protocol has been reverse engineered and it should be possible to write a kernel driver for handling the GPS packets and dumping the raw data to
/dev/gnss0. I don't think this is particularly useful without a non-raw interface, though. It would still require a custom userspace implementation.
Actually... in this case it would be nice to do the protocol processing in kernel and just present reasonable interface to userland... or maybe NMEA.
Quoted 4 lines
Droid 4: GPS is similar to N900, but different protocol and QMI encapsulated. This one also has known protocol with userspace implementation. I did not yet have a detailed look, if its possible to (un)wrap this in the kernel.
So, this is actually NMEA over QMI. I do have patches libqmi that provides NMEA on stdout.
But there seems to be another possibile interface (yes, that modem is crazy, and you can talk to it over few different interfaces), and that's NMEA over GSM07.10. That one should be feasible to decode in kernel and just provide NMEA to userland.
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
Hi,
Quoted 28 lines · Pavel Machek
Quoted 8 lines
Quoted 3 lines
Finally, note that documentation (including kerneldoc) remains to be written, but hopefully this will not hinder review given that the current interfaces are fairly self-describing.
Great work. I like your design decisions. I have quite a few devices with have non-serial based GPS peripherals using binary protocols (*). As far as I can see it should be possible to add support for those.
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
Yep, that would be nice.
Quoted 8 lines
(*) I have those in mind:
Nokia N900: The phone has GPS integrated into the modem and uses ISI encapsulated data. The protocol has been reverse engineered and it should be possible to write a kernel driver for handling the GPS packets and dumping the raw data to
/dev/gnss0. I don't think this is particularly useful without a non-raw interface, though. It would still require a custom userspace implementation.
Quoted 3 lines
Actually... in this case it would be nice to do the protocol processing in kernel and just present reasonable interface to userland... or maybe NMEA.
Converting a binary protocol to NMEA, which needs to be string parsed is not very nice. I think first step would be to write a simple driver, which exposes the binary location protocol without ISI header. Then in a second step we can think about a reasonable interface, that should be supported by all GNSS devices.
Quoted 7 lines
Quoted 4 lines
Droid 4: GPS is similar to N900, but different protocol and QMI encapsulated. This one also has known protocol with userspace implementation. I did not yet have a detailed look, if its possible to (un)wrap this in the kernel.
So, this is actually NMEA over QMI. I do have patches libqmi that provides NMEA on stdout.
Ok. So raw data is NMEA for this one. Should be reasonably easy to write a driver exposing this via /dev/gnss device.
Quoted 4 lines
But there seems to be another possibile interface (yes, that modem is crazy, and you can talk to it over few different interfaces), and that's NMEA over GSM07.10. That one should be feasible to decode in kernel and just provide NMEA to userland.
I think both should be feasible. I suggest to wait a bit more until you and Tony figured out some more details. You've got the libqmi patch as workaround for now and we want a stable API later.
-- Sebastian
Hi!
Quoted 13 lines
Quoted 9 lines
Quoted 8 lines
(*) I have those in mind:
Nokia N900: The phone has GPS integrated into the modem and uses ISI encapsulated data. The protocol has been reverse engineered and it should be possible to write a kernel driver for handling the GPS packets and dumping the raw data to
/dev/gnss0. I don't think this is particularly useful without a non-raw interface, though. It would still require a custom userspace implementation.Quoted 3 lines
Actually... in this case it would be nice to do the protocol processing in kernel and just present reasonable interface to userland... or maybe NMEA.
Quoted 5 lines
Converting a binary protocol to NMEA, which needs to be string parsed is not very nice. I think first step would be to write a simple driver, which exposes the binary location protocol without ISI header. Then in a second step we can think about a reasonable interface, that should be supported by all GNSS devices.
Well, most of the userspace expects NMEA. So yes, its an ugly protocol, but .. it is not really a high-performance device.
I'd suggest modeling this over input subsystem. We could use similar tag/value/sync protocol (evdev). In similar way /dev/input/mice was used for running legacy apps during transition, we'd have /dev/...//nmea.
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines
Droid 4: GPS is similar to N900, but different protocol and QMI encapsulated. This one also has known protocol with userspace implementation. I did not yet have a detailed look, if its possible to (un)wrap this in the kernel.
So, this is actually NMEA over QMI. I do have patches libqmi that provides NMEA on stdout.
Ok. So raw data is NMEA for this one. Should be reasonably easy to write a driver exposing this via
/dev/gnssdevice.
If we have qmi implementation somewhere in kernel. Do we?
Quoted 9 lines
Quoted 4 lines
But there seems to be another possibile interface (yes, that modem is crazy, and you can talk to it over few different interfaces), and that's NMEA over GSM07.10. That one should be feasible to decode in kernel and just provide NMEA to userland.
I think both should be feasible. I suggest to wait a bit more until you and Tony figured out some more details. You've got the libqmi patch as workaround for now and we want a stable API later.
I do have the gsm07.10 one now, too. That one is certainly simple enough (and should eat less power -- no need to keep USB running).
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
Hi Pavel,
Quoted 19 lines
Quoted 13 lines
Quoted 9 lines
Quoted 8 lines
(*) I have those in mind:
Nokia N900: The phone has GPS integrated into the modem and uses ISI encapsulated data. The protocol has been reverse engineered and it should be possible to write a kernel driver for handling the GPS packets and dumping the raw data to
/dev/gnss0. I don't think this is particularly useful without a non-raw interface, though. It would still require a custom userspace implementation.Quoted 3 lines
Actually... in this case it would be nice to do the protocol processing in kernel and just present reasonable interface to userland... or maybe NMEA.
Quoted 5 lines
Converting a binary protocol to NMEA, which needs to be string parsed is not very nice. I think first step would be to write a simple driver, which exposes the binary location protocol without ISI header. Then in a second step we can think about a reasonable interface, that should be supported by all GNSS devices.
Quoted 6 lines
Well, most of the userspace expects NMEA. So yes, its an ugly protocol, but .. it is not really a high-performance device.
I'd suggest modeling this over input subsystem. We could use similar tag/value/sync protocol (evdev). In similar way
/dev/input/micewas used for running legacy apps during transition, we'd have/dev/...//nmea.
I would _not_ model it after the input system. And /dev/input/mice was a really bad design choice. It was there because userspace was too stupid.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Droid 4: GPS is similar to N900, but different protocol and QMI encapsulated. This one also has known protocol with userspace implementation. I did not yet have a detailed look, if its possible to (un)wrap this in the kernel.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
So, this is actually NMEA over QMI. I do have patches libqmi that provides NMEA on stdout.
Ok. So raw data is NMEA for this one. Should be reasonably easy to write a driver exposing this via
/dev/gnssdevice.If we have qmi implementation somewhere in kernel. Do we?
Not in a way that it can easily be hooked up, but essentially the QMUX part and everything around it needs to be done in the kernel. Like Phonet and CAIF have been done before that.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
But there seems to be another possibile interface (yes, that modem is crazy, and you can talk to it over few different interfaces), and that's NMEA over GSM07.10. That one should be feasible to decode in kernel and just provide NMEA to userland.
Quoted 7 lines
Quoted 4 lines
I think both should be feasible. I suggest to wait a bit more until you and Tony figured out some more details. You've got the libqmi patch as workaround for now and we want a stable API later.
I do have the gsm07.10 one now, too. That one is certainly simple enough (and should eat less power -- no need to keep USB running).
Someone also needs to make the GSM 07.10 multiplexer code serdev aware. Since currently it is a line discipline and that is not really needed. In case this is a USB serial, it might be better to be hooked up directly into GSM 07.10 without even going through serdev.
Regards
Marcel
Johan Hovold
maintainerQuoted 24 lines · Sebastian Reichel
Hi Johan,
Quoted 15 lines · Johan Hovold
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g.
/dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes and which also allows for easy detection and (eventually) identification of GNSS devices.Quoted 5 lines
Note that the character-device interface provides raw access to whatever protocol the receiver is (currently) using, such as NMEA 0183, UBX or SiRF Binary. These protocols are expected to be continued to be handled by user space for the time being, even if some hybrid solutions are also conceivable (e.g. to have kernel drivers issue management commands).
Quoted 3 lines
Great work. I like your design decisions. I have quite a few devices with have non-serial based GPS peripherals using binary protocols (*). As far as I can see it should be possible to add support for those.
Thanks! Yeah, the aim here was to abstract the actual I/O interface used.
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
One problem I see here would be that the driver does not necessarily know either what protocol is currently being used. Some devices have boot-pins which can be used to configure the initial protocol used (and this could perhaps be reflected in DT), but this can often later be changed (by user space) and even be made persistent using battery-backed ram or eeproms.
Also note that at least u-blox devices supports having more than one protocol active on the same port...
Thanks,
Johan
Hi Johan,
Quoted 44 lines
Quoted 21 lines
Quoted 15 lines
This series adds a new subsystem for GNSS receivers (e.g. GPS receivers).
While GNSS receivers are typically accessed using a UART interface they often also support other I/O interfaces such as I2C, SPI and USB, while yet other devices use iomem or even some form of remote-processor messaging (rpmsg).
The new GNSS subsystem abstracts the underlying interface and provides a new "gnss" class type, which exposes a character-device interface (e.g.
/dev/gnss0) to user space. This allows GNSS receivers to have a representation in the Linux device model, something which is important not least for power management purposes and which also allows for easy detection and (eventually) identification of GNSS devices.Quoted 5 lines
Note that the character-device interface provides raw access to whatever protocol the receiver is (currently) using, such as NMEA 0183, UBX or SiRF Binary. These protocols are expected to be continued to be handled by user space for the time being, even if some hybrid solutions are also conceivable (e.g. to have kernel drivers issue management commands).
Quoted 3 lines
Great work. I like your design decisions. I have quite a few devices with have non-serial based GPS peripherals using binary protocols (*). As far as I can see it should be possible to add support for those.
Thanks! Yeah, the aim here was to abstract the actual I/O interface used.
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
One problem I see here would be that the driver does not necessarily know either what protocol is currently being used. Some devices have boot-pins which can be used to configure the initial protocol used (and this could perhaps be reflected in DT), but this can often later be changed (by user space) and even be made persistent using battery-backed ram or eeproms.
Quoted 2 lines
Also note that at least u-blox devices supports having more than one protocol active on the same port...
as long as userspace can determine that it is GNSS hardware and what hardware it is, then you deal with the rest in userspace.
Regards
Marcel
Johan Hovold
maintainerQuoted 16 lines · Marcel Holtmann
Quoted 16 lines
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
One problem I see here would be that the driver does not necessarily know either what protocol is currently being used. Some devices have boot-pins which can be used to configure the initial protocol used (and this could perhaps be reflected in DT), but this can often later be changed (by user space) and even be made persistent using battery-backed ram or eeproms.
Quoted 5 lines
Quoted 2 lines
Also note that at least u-blox devices supports having more than one protocol active on the same port...
as long as userspace can determine that it is GNSS hardware and what hardware it is, then you deal with the rest in userspace.
Yeah, I think that will do for now.
Thanks,
Johan
Hi Johan,
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
One problem I see here would be that the driver does not necessarily know either what protocol is currently being used. Some devices have boot-pins which can be used to configure the initial protocol used (and this could perhaps be reflected in DT), but this can often later be changed (by user space) and even be made persistent using battery-backed ram or eeproms.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Also note that at least u-blox devices supports having more than one protocol active on the same port...
as long as userspace can determine that it is GNSS hardware and what hardware it is, then you deal with the rest in userspace.
Yeah, I think that will do for now.
I forgot to mention that this part should be simple. So providing a DEVTYPE attribute that can be easily associated to the /dev/gnssX nodes is a must have here. Doing complex mapping of USB or DT layouts to figure out this is NMEA vs some vendor vs I need extra code to change the mode etc.
So a proper GNSS daemon will require some hardware abstraction anyway. There will be still a few GNSS devices that are part of the cellular modem, where you have to go via the telephony daemon to get access to it. We have done this within oFono since there would be otherwise no access to it. So only extra pieces that could be done here is to provide a /dev/ugnss (like /dev/uinput, /dev/uhid) so that you can emulate GNSS hardware from userspace as well. In oFono, we could then just hook this up with /dev/ugnss and the GNSS daemon would not have to have to know how to talk to oFono.
Regards
Marcel
Johan Hovold
maintainerQuoted 24 lines · Marcel Holtmann
Hi Johan,
Quoted 22 lines
Quoted 21 lines
Quoted 16 lines
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
One problem I see here would be that the driver does not necessarily know either what protocol is currently being used. Some devices have boot-pins which can be used to configure the initial protocol used (and this could perhaps be reflected in DT), but this can often later be changed (by user space) and even be made persistent using battery-backed ram or eeproms.
Quoted 2 lines
Also note that at least u-blox devices supports having more than one protocol active on the same port...
as long as userspace can determine that it is GNSS hardware and what hardware it is, then you deal with the rest in userspace.
Quoted 7 lines
Quoted 1 line
Yeah, I think that will do for now.
I forgot to mention that this part should be simple. So providing a DEVTYPE attribute that can be easily associated to the
/dev/gnssXnodes is a must have here. Doing complex mapping of USB or DT layouts to figure out this is NMEA vs some vendor vs I need extra code to change the mode etc.
Yes, as I mentioned in the cover letter some kind of generic interface for identifying the device type (and its features) should be defined eventually.
Note that this is not necessarily something that is needed from the start however as, for example, gpsd implements protocol detection.
Quoted 9 lines
So a proper GNSS daemon will require some hardware abstraction anyway. There will be still a few GNSS devices that are part of the cellular modem, where you have to go via the telephony daemon to get access to it. We have done this within oFono since there would be otherwise no access to it. So only extra pieces that could be done here is to provide a
/dev/ugnss(like/dev/uinput,/dev/uhid) so that you can emulate GNSS hardware from userspace as well. In oFono, we could then just hook this up with/dev/ugnssand the GNSS daemon would not have to have to know how to talk to oFono.
Interesting idea, could be useful for testing purposes as well. But just so I understand your use case better, why do you need to go through oFono rather than implement, say, a serdev driver for the GNSS port of the modem? To enable the receiver using AT commands on a different port? Or what kind of interface did you have in mind here?
Thanks,
Johan
Hi Johan,
Quoted 30 lines
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 16 lines
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
One problem I see here would be that the driver does not necessarily know either what protocol is currently being used. Some devices have boot-pins which can be used to configure the initial protocol used (and this could perhaps be reflected in DT), but this can often later be changed (by user space) and even be made persistent using battery-backed ram or eeproms.
Quoted 2 lines
Also note that at least u-blox devices supports having more than one protocol active on the same port...
as long as userspace can determine that it is GNSS hardware and what hardware it is, then you deal with the rest in userspace.
Quoted 7 lines
Quoted 1 line
Yeah, I think that will do for now.
I forgot to mention that this part should be simple. So providing a DEVTYPE attribute that can be easily associated to the
/dev/gnssXnodes is a must have here. Doing complex mapping of USB or DT layouts to figure out this is NMEA vs some vendor vs I need extra code to change the mode etc.
Quoted 4 lines
Yes, as I mentioned in the cover letter some kind of generic interface for identifying the device type (and its features) should be defined eventually.
I think this needs to be present from the start. Half backed subsystems are dangerous. And I really want to avoid hacking in userspace to figure out details about the hardware.
Quoted 2 lines
Note that this is not necessarily something that is needed from the start however as, for example, gpsd implements protocol detection.
That might be, but that is a total hack. Lets get this right from the get-go.
Quoted 10 lines
Quoted 9 lines
So a proper GNSS daemon will require some hardware abstraction anyway. There will be still a few GNSS devices that are part of the cellular modem, where you have to go via the telephony daemon to get access to it. We have done this within oFono since there would be otherwise no access to it. So only extra pieces that could be done here is to provide a
/dev/ugnss(like/dev/uinput,/dev/uhid) so that you can emulate GNSS hardware from userspace as well. In oFono, we could then just hook this up with/dev/ugnssand the GNSS daemon would not have to have to know how to talk to oFono.
Quoted 5 lines
Interesting idea, could be useful for testing purposes as well. But just so I understand your use case better, why do you need to go through oFono rather than implement, say, a serdev driver for the GNSS port of the modem? To enable the receiver using AT commands on a different port? Or what kind of interface did you have in mind here?
There are bunch of AT command based modems that will require you to send an AT command to enable NMEA reporting. Same as QMI requires you to send a command to enable the reporting. The QMI part might be eventually moved into the kernel if we get QMUX done there and all the USB modems ported to participate in a QMI subsystem so to speak. Until then even for QMI this is needed. Look at oFono and its location reporting drivers. We could easily change oFono to support /dev/ugnss and feed this all into a single GNSS subsystem.
Regards
Marcel
Johan Hovold
maintainerHi Marcel,
Sorry about the late reply. I got side-tracked with other things.
Quoted 32 lines · Marcel Holtmann
Hi Johan,
Quoted 30 lines
Quoted 29 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 8 lines
I have one concern, though. While providing raw data by default is fine generally, it is a problem with device auto-discovery. I think there should be some IOCTL from the start, that can be used to inform userspace about the raw protocol being used (i.e. "NMEA"). I fear, that userspace may start to just assume raw = NMEA without having this (especially since all initial drivers provide NMEA).
One problem I see here would be that the driver does not necessarily know either what protocol is currently being used. Some devices have boot-pins which can be used to configure the initial protocol used (and this could perhaps be reflected in DT), but this can often later be changed (by user space) and even be made persistent using battery-backed ram or eeproms.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Also note that at least u-blox devices supports having more than one protocol active on the same port...
as long as userspace can determine that it is GNSS hardware and what hardware it is, then you deal with the rest in userspace.
Yeah, I think that will do for now.
I forgot to mention that this part should be simple. So providing a DEVTYPE attribute that can be easily associated to the
/dev/gnssXnodes is a must have here. Doing complex mapping of USB or DT layouts to figure out this is NMEA vs some vendor vs I need extra code to change the mode etc.
Quoted 7 lines
Quoted 3 lines
Yes, as I mentioned in the cover letter some kind of generic interface for identifying the device type (and its features) should be defined eventually.
I think this needs to be present from the start. Half backed subsystems are dangerous. And I really want to avoid hacking in userspace to figure out details about the hardware.
Fair enough. I've now added support for determining the GNSS type, which reflects the protocol(s) supported by the device and which should allow, for example, the gpsd protocol probing hack to be dropped.
Currently, there are three types defined:
"NMEA" NMEA 0183
"SiRF" SiRF Binary
"UBX" UBXNote that both SiRF and UBX type devices typically support a subset of NMEA 0183 with vendor extensions (e.g. to allow switching to the vendor protocol).
Quoted 5 lines
Quoted 2 lines
Note that this is not necessarily something that is needed from the start however as, for example, gpsd implements protocol detection.
That might be, but that is a total hack. Lets get this right from the get-go.
I agree; it's horrid.
Thanks,
Johan