linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
@ 2023-11-26 19:18 Andreas Kemnade
  2023-11-26 19:18 ` [RFC PATCH 1/3] gnss: Add AI2 protocol used by some TI combo chips Andreas Kemnade
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Andreas Kemnade @ 2023-11-26 19:18 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz, johan, arnd, gregkh, andreas,
	linux-bluetooth, linux-kernel, tomi.valkeinen, Tony Lindgren,
	Péter Ujfalusi, robh

Some of these chips have GNSS support. In some vendor kernels
a driver on top of misc/ti-st can be found providing a /dev/tigps
device which speaks the secretive Air Independent Interface (AI2) protocol.
Implement something comparable as a GNSS interface.

With some userspace tools a proof-of-concept can be shown. A position
can be successfully read out.  Basic properties of the protocol are
understood.

This was tested on the Epson Moverio BT-200.

This is sent out as an early RFC to ensure I am going onto the right
track:

So the main questions I see:
- is the approach right to abandon drivers/misc/ti-st?

- Output at /dev/gnssX:
  AI2 vs. NMEA
  The chip can be configured into sending AI2-encapsulated NMEA,
  or proving data in a binary format.
  Some research has to be done yet for the details.
  A pile of logs is waiting for further analysis...

  Arguments for/against NMEA:
  + Userspace is prepared to handle it
  + Power management can be easily done by the kernel
  - Less functionality can be used.

  Arguments for/against AI2:
  + Full functionality can be accessed from userspace (incl. A-GPS,
    maybe raw satellite data)
  - Userspace has to behave to have proper power management
  - No freely (not even as in beer) tool available to fully use AI2,
    so there will be only a real advantage after long "French Cafe"
    sessions.

More detailed tings:
  - Some live cycle management is left out. Since it depends
    on the decisions above, I have not put much thought into it.
  - Should some pieces go into drivers/gnss?
  - detection for GNSS availability: For now the node name is
    used. But the device should be there if the chip supports it
    and things are wired up properly.

Andreas Kemnade (3):
  gnss: Add AI2 protocol used by some TI combo chips.
  bluetooth: ti-st: add GNSS support for TI Wilink chips
  drivers: misc: ti-st: begin to deorbit

 drivers/bluetooth/hci_ll.c | 154 ++++++++++++++++++++++++++++++++++++-
 drivers/gnss/core.c        |   1 +
 drivers/misc/ti-st/Kconfig |   2 +-
 include/linux/gnss.h       |   1 +
 4 files changed, 156 insertions(+), 2 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [RFC PATCH 1/3] gnss: Add AI2 protocol used by some TI combo chips.
  2023-11-26 19:18 [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Andreas Kemnade
@ 2023-11-26 19:18 ` Andreas Kemnade
  2023-11-26 19:18 ` [RFC PATCH 2/3] bluetooth: ti-st: add GNSS support for TI Wilink chips Andreas Kemnade
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Andreas Kemnade @ 2023-11-26 19:18 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz, johan, arnd, gregkh, andreas,
	linux-bluetooth, linux-kernel, tomi.valkeinen, Tony Lindgren,
	Péter Ujfalusi, robh

Texas Instruments uses something called Air Independent Interface (AI2) for
their WLAN/BT/GPS combo chips.
No public documentation is available, by looking into captured data, it
becomes clear that you can either raw data or encapsulated NMEA after some
initialization commands.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/gnss/core.c  | 1 +
 include/linux/gnss.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
index 48f2ee0f78c4d..cac9f45aec4b2 100644
--- a/drivers/gnss/core.c
+++ b/drivers/gnss/core.c
@@ -335,6 +335,7 @@ static const char * const gnss_type_names[GNSS_TYPE_COUNT] = {
 	[GNSS_TYPE_SIRF]	= "SiRF",
 	[GNSS_TYPE_UBX]		= "UBX",
 	[GNSS_TYPE_MTK]		= "MTK",
+	[GNSS_TYPE_AI2]		= "AI2",
 };
 
 static const char *gnss_type_name(const struct gnss_device *gdev)
diff --git a/include/linux/gnss.h b/include/linux/gnss.h
index 36968a0f33e8d..16b565dab83ea 100644
--- a/include/linux/gnss.h
+++ b/include/linux/gnss.h
@@ -23,6 +23,7 @@ enum gnss_type {
 	GNSS_TYPE_SIRF,
 	GNSS_TYPE_UBX,
 	GNSS_TYPE_MTK,
+	GNSS_TYPE_AI2,
 
 	GNSS_TYPE_COUNT
 };
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 2/3] bluetooth: ti-st: add GNSS support for TI Wilink chips
  2023-11-26 19:18 [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Andreas Kemnade
  2023-11-26 19:18 ` [RFC PATCH 1/3] gnss: Add AI2 protocol used by some TI combo chips Andreas Kemnade
@ 2023-11-26 19:18 ` Andreas Kemnade
  2023-11-26 19:18 ` [RFC PATCH 3/3] drivers: misc: ti-st: begin to deorbit Andreas Kemnade
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 15+ messages in thread
From: Andreas Kemnade @ 2023-11-26 19:18 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz, johan, arnd, gregkh, andreas,
	linux-bluetooth, linux-kernel, tomi.valkeinen, Tony Lindgren,
	Péter Ujfalusi, robh

Some of these chips have GNSS support. GNSS support
is available through channel 9 whilst FM is through channel 8.
Add support for it.
A driver providing a /dev/tigps device is found in some vendor-kernels. The
GNSS device provided by this patch seems to be compatible.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/bluetooth/hci_ll.c | 154 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 153 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
index 4a0b5c3160c2b..718dab0f529a7 100644
--- a/drivers/bluetooth/hci_ll.c
+++ b/drivers/bluetooth/hci_ll.c
@@ -39,6 +39,7 @@
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
+#include <linux/gnss.h>
 #include <linux/gpio/consumer.h>
 #include <linux/nvmem-consumer.h>
 
@@ -68,6 +69,10 @@ struct ll_device {
 	struct gpio_desc *enable_gpio;
 	struct clk *ext_clk;
 	bdaddr_t bdaddr;
+
+	struct mutex gdev_mutex;
+	bool gdev_open;
+	struct gnss_device *gdev;
 };
 
 struct ll_struct {
@@ -78,6 +83,20 @@ struct ll_struct {
 	struct sk_buff_head tx_wait_q;	/* HCILL wait queue	*/
 };
 
+/* Channel-9 details for GPS */
+#define GPS_CH9_PKT_HDR_SIZE		4
+#define GPS_CH9_PKT_NUMBER		0x9
+#define GPS_CH9_OP_WRITE		0x1
+#define GPS_CH9_OP_READ			0x2
+#define GPS_CH9_OP_COMPLETED_EVT	0x3
+
+struct gnssdrv_event_hdr {
+	uint8_t opcode;
+	uint16_t plen;
+} __packed;
+
+
+static int gnss_recv_frame(struct hci_dev *hdev, struct sk_buff *skb);
 /*
  * Builds and sends an HCILL command packet.
  * These are very simple packets with only 1 cmd byte
@@ -411,6 +430,13 @@ static int ll_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
 	.lsize = 0, \
 	.maxlen = 0
 
+#define LL_RECV_GNSS \
+	.type = GPS_CH9_PKT_NUMBER, \
+	.hlen = 3, \
+	.loff = 1, \
+	.lsize = 2 \
+
+
 static const struct h4_recv_pkt ll_recv_pkts[] = {
 	{ H4_RECV_ACL,       .recv = hci_recv_frame },
 	{ H4_RECV_SCO,       .recv = hci_recv_frame },
@@ -419,6 +445,7 @@ static const struct h4_recv_pkt ll_recv_pkts[] = {
 	{ LL_RECV_SLEEP_ACK, .recv = ll_recv_frame  },
 	{ LL_RECV_WAKE_IND,  .recv = ll_recv_frame  },
 	{ LL_RECV_WAKE_ACK,  .recv = ll_recv_frame  },
+	{ LL_RECV_GNSS,      .recv = gnss_recv_frame },
 };
 
 /* Recv data */
@@ -682,12 +709,124 @@ static int ll_setup(struct hci_uart *hu)
 
 static const struct hci_uart_proto llp;
 
+static int gnss_lldev_open(struct gnss_device *gdev)
+{
+	struct ll_device *lldev = gnss_get_drvdata(gdev);
+
+	mutex_lock(&lldev->gdev_mutex);
+	lldev->gdev_open = true;
+	mutex_unlock(&lldev->gdev_mutex);
+
+	return 0;
+}
+
+static void gnss_lldev_close(struct gnss_device *gdev)
+{
+	struct ll_device *lldev = gnss_get_drvdata(gdev);
+
+	mutex_lock(&lldev->gdev_mutex);
+	lldev->gdev_open = false;
+	mutex_unlock(&lldev->gdev_mutex);
+}
+
+static int gnss_lldev_write_raw(struct gnss_device *gdev,
+		const unsigned char *buf, size_t count)
+{
+	struct ll_device *lldev = gnss_get_drvdata(gdev);
+	int err = 0;
+	struct sk_buff *skb = NULL;
+	struct gnssdrv_event_hdr gnssdrv_hdr = { GPS_CH9_OP_WRITE, 0x0000 };
+
+	/* allocate packet */
+	skb = bt_skb_alloc(sizeof(gnssdrv_hdr) + count, GFP_ATOMIC);
+	if (!skb) {
+		BT_ERR("cannot allocate memory for HCILL packet");
+		err = -ENOMEM;
+		goto out;
+	}
+
+	/* GPS channel */
+
+	gnssdrv_hdr.plen = count;
+	hci_skb_pkt_type(skb) = GPS_CH9_PKT_NUMBER;
+	skb_put_data(skb, &gnssdrv_hdr, sizeof(gnssdrv_hdr));
+	skb_put_data(skb, buf, count);
+
+	lldev->hu.hdev->send(lldev->hu.hdev, skb);
+
+	/* TODO: wait on completion? */
+	return count;
+out:
+	return err;
+}
+
+static const struct gnss_operations gnss_lldev_ops = {
+	.open		= gnss_lldev_open,
+	.close		= gnss_lldev_close,
+	.write_raw	= gnss_lldev_write_raw,
+};
+
+static int gnss_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
+{
+	struct hci_uart *hu = hci_get_drvdata(hdev);
+	struct ll_device *lldev = container_of(hu, struct ll_device, hu);
+
+	if (!IS_ENABLED(CONFIG_GNSS))
+		return 0;
+
+	if (!lldev->gdev)
+		return 0;
+
+	if (hci_skb_pkt_type(skb) == GPS_CH9_PKT_NUMBER) {
+		struct gnssdrv_event_hdr *gnss_hdr =
+			(struct gnssdrv_event_hdr *)skb->data;
+		void *data = skb_pull(skb, sizeof(*gnss_hdr));
+		/*
+		 * REVISIT: maybe do something with the completed
+		 * event
+		 */
+		if (gnss_hdr->opcode ==	GPS_CH9_OP_READ) {
+			mutex_lock(&lldev->gdev_mutex);
+			if (lldev->gdev_open)
+				gnss_insert_raw(lldev->gdev, data, skb->len);
+			mutex_unlock(&lldev->gdev_mutex);
+		}
+	}
+	kfree_skb(skb);
+
+	return 0;
+}
+
+static int ll_gnss_register(struct ll_device *lldev)
+{
+	struct gnss_device *gdev;
+	int ret;
+
+	gdev = gnss_allocate_device(&lldev->serdev->dev);
+	if (!gdev)
+		return -ENOMEM;
+
+	gdev->ops = &gnss_lldev_ops;
+	gdev->type = GNSS_TYPE_AI2;
+	gnss_set_drvdata(gdev, lldev);
+	mutex_init(&lldev->gdev_mutex);
+
+	ret = gnss_register_device(gdev);
+	if (ret == 0) {
+		lldev->gdev = gdev;
+		return 0;
+	}
+	gnss_put_device(gdev);
+	return ret;
+}
+
 static int hci_ti_probe(struct serdev_device *serdev)
 {
 	struct hci_uart *hu;
 	struct ll_device *lldev;
 	struct nvmem_cell *bdaddr_cell;
 	u32 max_speed = 3000000;
+	int ret;
 
 	lldev = devm_kzalloc(&serdev->dev, sizeof(struct ll_device), GFP_KERNEL);
 	if (!lldev)
@@ -756,14 +895,27 @@ static int hci_ti_probe(struct serdev_device *serdev)
 		kfree(bdaddr);
 	}
 
-	return hci_uart_register_device(hu, &llp);
+	ret = hci_uart_register_device(hu, &llp);
+	if (ret)
+		return ret;
+
+	if (IS_ENABLED(CONFIG_GNSS) &&
+	    strstr(of_node_full_name(serdev->dev.of_node), "gnss"))
+		ll_gnss_register(lldev);
+
+	return 0;
 }
 
+
 static void hci_ti_remove(struct serdev_device *serdev)
 {
 	struct ll_device *lldev = serdev_device_get_drvdata(serdev);
 
 	hci_uart_unregister_device(&lldev->hu);
+	if (IS_ENABLED(CONFIG_GNSS) && lldev->gdev) {
+		gnss_deregister_device(lldev->gdev);
+		gnss_put_device(lldev->gdev);
+	}
 }
 
 static const struct of_device_id hci_ti_of_match[] = {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [RFC PATCH 3/3] drivers: misc: ti-st: begin to deorbit
  2023-11-26 19:18 [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Andreas Kemnade
  2023-11-26 19:18 ` [RFC PATCH 1/3] gnss: Add AI2 protocol used by some TI combo chips Andreas Kemnade
  2023-11-26 19:18 ` [RFC PATCH 2/3] bluetooth: ti-st: add GNSS support for TI Wilink chips Andreas Kemnade
@ 2023-11-26 19:18 ` Andreas Kemnade
  2023-11-27  8:25   ` Greg KH
  2023-11-27 13:54 ` [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Tony Lindgren
  2023-11-27 14:03 ` Adam Ford
  4 siblings, 1 reply; 15+ messages in thread
From: Andreas Kemnade @ 2023-11-26 19:18 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz, johan, arnd, gregkh, andreas,
	linux-bluetooth, linux-kernel, tomi.valkeinen, Tony Lindgren,
	Péter Ujfalusi, robh

The TI-ST driver seems not to be used anymore. For bluetooth needs
there is hci_ll.c which has device tree support and can work without
this one. Also firmware download support is there, so it is also not needed
here. GPS can also reuse parts of the framework in hci_ll

Contrary from this driver, device tree support has been removed.

So start deorbiting it by marking it as broken.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
---
 drivers/misc/ti-st/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/ti-st/Kconfig b/drivers/misc/ti-st/Kconfig
index 1503a6496f632..6bf9cc845745c 100644
--- a/drivers/misc/ti-st/Kconfig
+++ b/drivers/misc/ti-st/Kconfig
@@ -7,7 +7,7 @@ menu "Texas Instruments shared transport line discipline"
 config TI_ST
 	tristate "Shared transport core driver"
 	depends on NET && TTY
-	depends on GPIOLIB || COMPILE_TEST
+	depends on GPIOLIB || COMPILE_TEST || BROKEN
 	select FW_LOADER
 	help
 	  This enables the shared transport core driver for TI
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] drivers: misc: ti-st: begin to deorbit
  2023-11-26 19:18 ` [RFC PATCH 3/3] drivers: misc: ti-st: begin to deorbit Andreas Kemnade
@ 2023-11-27  8:25   ` Greg KH
  2023-11-27 13:50     ` Tony Lindgren
  2023-12-10 21:50     ` Andreas Kemnade
  0 siblings, 2 replies; 15+ messages in thread
From: Greg KH @ 2023-11-27  8:25 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: marcel, johan.hedberg, luiz.dentz, johan, arnd, linux-bluetooth,
	linux-kernel, tomi.valkeinen, Tony Lindgren, Péter Ujfalusi,
	robh

On Sun, Nov 26, 2023 at 08:18:40PM +0100, Andreas Kemnade wrote:
> The TI-ST driver seems not to be used anymore. For bluetooth needs
> there is hci_ll.c which has device tree support and can work without
> this one. Also firmware download support is there, so it is also not needed
> here. GPS can also reuse parts of the framework in hci_ll
> 
> Contrary from this driver, device tree support has been removed.
> 
> So start deorbiting it by marking it as broken.
> 
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
>  drivers/misc/ti-st/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ti-st/Kconfig b/drivers/misc/ti-st/Kconfig
> index 1503a6496f632..6bf9cc845745c 100644
> --- a/drivers/misc/ti-st/Kconfig
> +++ b/drivers/misc/ti-st/Kconfig
> @@ -7,7 +7,7 @@ menu "Texas Instruments shared transport line discipline"
>  config TI_ST
>  	tristate "Shared transport core driver"
>  	depends on NET && TTY
> -	depends on GPIOLIB || COMPILE_TEST
> +	depends on GPIOLIB || COMPILE_TEST || BROKEN

Why not just delete it?  Why have it stick around any longer?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] drivers: misc: ti-st: begin to deorbit
  2023-11-27  8:25   ` Greg KH
@ 2023-11-27 13:50     ` Tony Lindgren
  2023-12-10 21:50     ` Andreas Kemnade
  1 sibling, 0 replies; 15+ messages in thread
From: Tony Lindgren @ 2023-11-27 13:50 UTC (permalink / raw)
  To: Greg KH
  Cc: Andreas Kemnade, marcel, johan.hedberg, luiz.dentz, johan, arnd,
	linux-bluetooth, linux-kernel, tomi.valkeinen,
	Péter Ujfalusi, robh

* Greg KH <gregkh@linuxfoundation.org> [231127 08:25]:
> On Sun, Nov 26, 2023 at 08:18:40PM +0100, Andreas Kemnade wrote:
> > The TI-ST driver seems not to be used anymore. For bluetooth needs
> > there is hci_ll.c which has device tree support and can work without
> > this one. Also firmware download support is there, so it is also not needed
> > here. GPS can also reuse parts of the framework in hci_ll
> > 
> > Contrary from this driver, device tree support has been removed.
> > 
> > So start deorbiting it by marking it as broken.
> > 
> > Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> > ---
> >  drivers/misc/ti-st/Kconfig | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/misc/ti-st/Kconfig b/drivers/misc/ti-st/Kconfig
> > index 1503a6496f632..6bf9cc845745c 100644
> > --- a/drivers/misc/ti-st/Kconfig
> > +++ b/drivers/misc/ti-st/Kconfig
> > @@ -7,7 +7,7 @@ menu "Texas Instruments shared transport line discipline"
> >  config TI_ST
> >  	tristate "Shared transport core driver"
> >  	depends on NET && TTY
> > -	depends on GPIOLIB || COMPILE_TEST
> > +	depends on GPIOLIB || COMPILE_TEST || BROKEN
> 
> Why not just delete it?  Why have it stick around any longer?

Sounds good to me too.

Regards,

Tony

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
  2023-11-26 19:18 [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Andreas Kemnade
                   ` (2 preceding siblings ...)
  2023-11-26 19:18 ` [RFC PATCH 3/3] drivers: misc: ti-st: begin to deorbit Andreas Kemnade
@ 2023-11-27 13:54 ` Tony Lindgren
  2023-11-27 20:51   ` Andreas Kemnade
  2023-11-27 14:03 ` Adam Ford
  4 siblings, 1 reply; 15+ messages in thread
From: Tony Lindgren @ 2023-11-27 13:54 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: marcel, johan.hedberg, luiz.dentz, johan, arnd, gregkh,
	linux-bluetooth, linux-kernel, tomi.valkeinen,
	Péter Ujfalusi, robh

* Andreas Kemnade <andreas@kemnade.info> [231126 19:18]:
> So the main questions I see:
> - is the approach right to abandon drivers/misc/ti-st?

Yes.

> - Output at /dev/gnssX:
>   AI2 vs. NMEA
>   The chip can be configured into sending AI2-encapsulated NMEA,
>   or proving data in a binary format.
>   Some research has to be done yet for the details.
>   A pile of logs is waiting for further analysis...
> 
>   Arguments for/against NMEA:
>   + Userspace is prepared to handle it
>   + Power management can be easily done by the kernel
>   - Less functionality can be used.

I'd go with NMEA format as the default setting :)

>   Arguments for/against AI2:
>   + Full functionality can be accessed from userspace (incl. A-GPS,
>     maybe raw satellite data)
>   - Userspace has to behave to have proper power management
>   - No freely (not even as in beer) tool available to fully use AI2,
>     so there will be only a real advantage after long "French Cafe"
>     sessions.

Seems AI2 could be optionally enabled as needed with some writes
to /dev/gnss0 to change the mode?

Regards,

Tony

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
  2023-11-26 19:18 [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Andreas Kemnade
                   ` (3 preceding siblings ...)
  2023-11-27 13:54 ` [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Tony Lindgren
@ 2023-11-27 14:03 ` Adam Ford
  2023-11-27 19:51   ` Andreas Kemnade
  4 siblings, 1 reply; 15+ messages in thread
From: Adam Ford @ 2023-11-27 14:03 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: marcel, johan.hedberg, luiz.dentz, johan, arnd, gregkh,
	linux-bluetooth, linux-kernel, tomi.valkeinen, Tony Lindgren,
	Péter Ujfalusi, robh

On Sun, Nov 26, 2023 at 1:47 PM Andreas Kemnade <andreas@kemnade.info> wrote:
>
> Some of these chips have GNSS support. In some vendor kernels
> a driver on top of misc/ti-st can be found providing a /dev/tigps
> device which speaks the secretive Air Independent Interface (AI2) protocol.
> Implement something comparable as a GNSS interface.
>
> With some userspace tools a proof-of-concept can be shown. A position
> can be successfully read out.  Basic properties of the protocol are
> understood.
>
> This was tested on the Epson Moverio BT-200.

Can you tell me which WiLink chip this uses?

I'd like to try it on the WL1283, but I want to understand which
WiLink chips you're targeting.

adam
>
> This is sent out as an early RFC to ensure I am going onto the right
> track:
>
> So the main questions I see:
> - is the approach right to abandon drivers/misc/ti-st?
>
> - Output at /dev/gnssX:
>   AI2 vs. NMEA
>   The chip can be configured into sending AI2-encapsulated NMEA,
>   or proving data in a binary format.
>   Some research has to be done yet for the details.
>   A pile of logs is waiting for further analysis...
>
>   Arguments for/against NMEA:
>   + Userspace is prepared to handle it
>   + Power management can be easily done by the kernel
>   - Less functionality can be used.
>
>   Arguments for/against AI2:
>   + Full functionality can be accessed from userspace (incl. A-GPS,
>     maybe raw satellite data)
>   - Userspace has to behave to have proper power management
>   - No freely (not even as in beer) tool available to fully use AI2,
>     so there will be only a real advantage after long "French Cafe"
>     sessions.
>
> More detailed tings:
>   - Some live cycle management is left out. Since it depends
>     on the decisions above, I have not put much thought into it.
>   - Should some pieces go into drivers/gnss?
>   - detection for GNSS availability: For now the node name is
>     used. But the device should be there if the chip supports it
>     and things are wired up properly.
>
> Andreas Kemnade (3):
>   gnss: Add AI2 protocol used by some TI combo chips.
>   bluetooth: ti-st: add GNSS support for TI Wilink chips
>   drivers: misc: ti-st: begin to deorbit
>
>  drivers/bluetooth/hci_ll.c | 154 ++++++++++++++++++++++++++++++++++++-
>  drivers/gnss/core.c        |   1 +
>  drivers/misc/ti-st/Kconfig |   2 +-
>  include/linux/gnss.h       |   1 +
>  4 files changed, 156 insertions(+), 2 deletions(-)
>
> --
> 2.39.2
>
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
  2023-11-27 14:03 ` Adam Ford
@ 2023-11-27 19:51   ` Andreas Kemnade
  0 siblings, 0 replies; 15+ messages in thread
From: Andreas Kemnade @ 2023-11-27 19:51 UTC (permalink / raw)
  To: Adam Ford
  Cc: marcel, johan.hedberg, luiz.dentz, johan, arnd, gregkh,
	linux-bluetooth, linux-kernel, tomi.valkeinen, Tony Lindgren,
	Péter Ujfalusi, robh

On Mon, 27 Nov 2023 08:03:24 -0600
Adam Ford <aford173@gmail.com> wrote:

> On Sun, Nov 26, 2023 at 1:47 PM Andreas Kemnade <andreas@kemnade.info> wrote:
> >
> > Some of these chips have GNSS support. In some vendor kernels
> > a driver on top of misc/ti-st can be found providing a /dev/tigps
> > device which speaks the secretive Air Independent Interface (AI2) protocol.
> > Implement something comparable as a GNSS interface.
> >
> > With some userspace tools a proof-of-concept can be shown. A position
> > can be successfully read out.  Basic properties of the protocol are
> > understood.
> >
> > This was tested on the Epson Moverio BT-200.  
> 
> Can you tell me which WiLink chip this uses?
> 
> I'd like to try it on the WL1283, but I want to understand which
> WiLink chips you're targeting.
> 
I think, it is a WL1283 here, too.

If you want to play around with it now:
- set the devicetree node name to bluetooth-gnss
- for testing you can use the read-gps program at https://github.com/akemnade/bt200tools

Regards,
Andreas

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
  2023-11-27 13:54 ` [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Tony Lindgren
@ 2023-11-27 20:51   ` Andreas Kemnade
  2023-12-08 14:39     ` Adam Ford
  2023-12-08 16:25     ` Johan Hovold
  0 siblings, 2 replies; 15+ messages in thread
From: Andreas Kemnade @ 2023-11-27 20:51 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: marcel, johan.hedberg, luiz.dentz, johan, arnd, gregkh,
	linux-bluetooth, linux-kernel, tomi.valkeinen,
	Péter Ujfalusi, robh

Hi,

On Mon, 27 Nov 2023 15:54:24 +0200
Tony Lindgren <tony@atomide.com> wrote:

[...]
> > - Output at /dev/gnssX:
> >   AI2 vs. NMEA
> >   The chip can be configured into sending AI2-encapsulated NMEA,
> >   or proving data in a binary format.
> >   Some research has to be done yet for the details.
> >   A pile of logs is waiting for further analysis...
> > 
> >   Arguments for/against NMEA:
> >   + Userspace is prepared to handle it
> >   + Power management can be easily done by the kernel
> >   - Less functionality can be used.  
> 
> I'd go with NMEA format as the default setting :)
> 
yes, that would also be my preference.

> >   Arguments for/against AI2:
> >   + Full functionality can be accessed from userspace (incl. A-GPS,
> >     maybe raw satellite data)
> >   - Userspace has to behave to have proper power management
> >   - No freely (not even as in beer) tool available to fully use AI2,
> >     so there will be only a real advantage after long "French Cafe"
> >     sessions.  
> 
> Seems AI2 could be optionally enabled as needed with some writes
> to /dev/gnss0 to change the mode?

Hmm, we have
/sys/class/gnss/gnss0/type to get the mode, maybe we add some file
to change the mode? Or having it hidden behing a module parameter
and implement something better accessible if any need arrives?

If we want NMEA output, probably some init commands will be sent at
open(), but userspace doing something with AI2 probably does not want
the device touched, so it should probably be already be set before open().

Regards,
Andreas

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
  2023-11-27 20:51   ` Andreas Kemnade
@ 2023-12-08 14:39     ` Adam Ford
  2023-12-08 17:47       ` Andreas Kemnade
  2023-12-08 16:25     ` Johan Hovold
  1 sibling, 1 reply; 15+ messages in thread
From: Adam Ford @ 2023-12-08 14:39 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: Tony Lindgren, marcel, johan.hedberg, luiz.dentz, johan, arnd,
	gregkh, linux-bluetooth, linux-kernel, tomi.valkeinen,
	Péter Ujfalusi, robh

On Mon, Nov 27, 2023 at 2:51 PM Andreas Kemnade <andreas@kemnade.info> wrote:
>
> Hi,
>
> On Mon, 27 Nov 2023 15:54:24 +0200
> Tony Lindgren <tony@atomide.com> wrote:
>
> [...]
> > > - Output at /dev/gnssX:
> > >   AI2 vs. NMEA
> > >   The chip can be configured into sending AI2-encapsulated NMEA,
> > >   or proving data in a binary format.
> > >   Some research has to be done yet for the details.
> > >   A pile of logs is waiting for further analysis...
> > >
> > >   Arguments for/against NMEA:
> > >   + Userspace is prepared to handle it
> > >   + Power management can be easily done by the kernel
> > >   - Less functionality can be used.
> >
> > I'd go with NMEA format as the default setting :)
> >
> yes, that would also be my preference.
>
> > >   Arguments for/against AI2:
> > >   + Full functionality can be accessed from userspace (incl. A-GPS,
> > >     maybe raw satellite data)
> > >   - Userspace has to behave to have proper power management
> > >   - No freely (not even as in beer) tool available to fully use AI2,
> > >     so there will be only a real advantage after long "French Cafe"
> > >     sessions.
> >
> > Seems AI2 could be optionally enabled as needed with some writes
> > to /dev/gnss0 to change the mode?
>
> Hmm, we have
> /sys/class/gnss/gnss0/type to get the mode, maybe we add some file
> to change the mode? Or having it hidden behing a module parameter
> and implement something better accessible if any need arrives?
>
> If we want NMEA output, probably some init commands will be sent at
> open(), but userspace doing something with AI2 probably does not want
> the device touched, so it should probably be already be set before open().

Is there another revision coming or should I try to test this one?  I
am not very familiar with the GNSS part of the module, but it sounds
like there was some consensus as to which direction we should go.  I
should have a little time this weekend.

thanks

adam
>
> Regards,
> Andreas
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
  2023-11-27 20:51   ` Andreas Kemnade
  2023-12-08 14:39     ` Adam Ford
@ 2023-12-08 16:25     ` Johan Hovold
  2023-12-08 22:13       ` Andreas Kemnade
  1 sibling, 1 reply; 15+ messages in thread
From: Johan Hovold @ 2023-12-08 16:25 UTC (permalink / raw)
  To: Andreas Kemnade
  Cc: Tony Lindgren, marcel, johan.hedberg, luiz.dentz, arnd, gregkh,
	linux-bluetooth, linux-kernel, tomi.valkeinen,
	Péter Ujfalusi, robh

On Mon, Nov 27, 2023 at 09:51:08PM +0100, Andreas Kemnade wrote:
> On Mon, 27 Nov 2023 15:54:24 +0200
> Tony Lindgren <tony@atomide.com> wrote:

> > > - Output at /dev/gnssX:
> > >   AI2 vs. NMEA
> > >   The chip can be configured into sending AI2-encapsulated NMEA,
> > >   or proving data in a binary format.
> > >   Some research has to be done yet for the details.
> > >   A pile of logs is waiting for further analysis...

Can you say something more about what the protocol looks like? Is there
some common framing that can/should be stripped by the driver in both
modes?

> > > 
> > >   Arguments for/against NMEA:
> > >   + Userspace is prepared to handle it
> > >   + Power management can be easily done by the kernel
> > >   - Less functionality can be used.  
> > 
> > I'd go with NMEA format as the default setting :)
> > 
> yes, that would also be my preference.
> 
> > >   Arguments for/against AI2:
> > >   + Full functionality can be accessed from userspace (incl. A-GPS,
> > >     maybe raw satellite data)
> > >   - Userspace has to behave to have proper power management
> > >   - No freely (not even as in beer) tool available to fully use AI2,
> > >     so there will be only a real advantage after long "French Cafe"
> > >     sessions.  
> > 
> > Seems AI2 could be optionally enabled as needed with some writes
> > to /dev/gnss0 to change the mode?
> 
> Hmm, we have
> /sys/class/gnss/gnss0/type to get the mode, maybe we add some file
> to change the mode? Or having it hidden behing a module parameter
> and implement something better accessible if any need arrives?

The 'type' attribute is intended to reveal the GNSS receiver type
(class) as a hint to user space to avoid having to detect it at runtime
using heuristics.

It does not reflect which mode is currently active for receivers that
provide both a vendor specific protocol and NMEA (e.g. u-blox
receivers).

User space can currently switch modes at will by writing to /dev/gnss0
as Tony mentioned.

It may or may not make sense to make sure a particular mode is set
during probe, for example, if there's no real use for the proprietary
protocol and everyone would just switch away from it immediately.

Johan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
  2023-12-08 14:39     ` Adam Ford
@ 2023-12-08 17:47       ` Andreas Kemnade
  0 siblings, 0 replies; 15+ messages in thread
From: Andreas Kemnade @ 2023-12-08 17:47 UTC (permalink / raw)
  To: Adam Ford
  Cc: Tony Lindgren, marcel, johan.hedberg, luiz.dentz, johan, arnd,
	gregkh, linux-bluetooth, linux-kernel, tomi.valkeinen,
	Péter Ujfalusi, robh

Hi,

On Fri, 8 Dec 2023 08:39:21 -0600
Adam Ford <aford173@gmail.com> wrote:

> On Mon, Nov 27, 2023 at 2:51 PM Andreas Kemnade <andreas@kemnade.info> wrote:
> >
> > Hi,
> >
> > On Mon, 27 Nov 2023 15:54:24 +0200
> > Tony Lindgren <tony@atomide.com> wrote:
> >
> > [...]  
> > > > - Output at /dev/gnssX:
> > > >   AI2 vs. NMEA
> > > >   The chip can be configured into sending AI2-encapsulated NMEA,
> > > >   or proving data in a binary format.
> > > >   Some research has to be done yet for the details.
> > > >   A pile of logs is waiting for further analysis...
> > > >
> > > >   Arguments for/against NMEA:
> > > >   + Userspace is prepared to handle it
> > > >   + Power management can be easily done by the kernel
> > > >   - Less functionality can be used.  
> > >
> > > I'd go with NMEA format as the default setting :)
> > >  
> > yes, that would also be my preference.
> >  
> > > >   Arguments for/against AI2:
> > > >   + Full functionality can be accessed from userspace (incl. A-GPS,
> > > >     maybe raw satellite data)
> > > >   - Userspace has to behave to have proper power management
> > > >   - No freely (not even as in beer) tool available to fully use AI2,
> > > >     so there will be only a real advantage after long "French Cafe"
> > > >     sessions.  
> > >
> > > Seems AI2 could be optionally enabled as needed with some writes
> > > to /dev/gnss0 to change the mode?  
> >
> > Hmm, we have
> > /sys/class/gnss/gnss0/type to get the mode, maybe we add some file
> > to change the mode? Or having it hidden behing a module parameter
> > and implement something better accessible if any need arrives?
> >
> > If we want NMEA output, probably some init commands will be sent at
> > open(), but userspace doing something with AI2 probably does not want
> > the device touched, so it should probably be already be set before open().  
> 
> Is there another revision coming or should I try to test this one?  I
> am not very familiar with the GNSS part of the module, but it sounds
> like there was some consensus as to which direction we should go.  I
> should have a little time this weekend.
> 
Progress is only in my test program. No more checksum errors, I have
made some progress in protocol reverse engineering. So make sure
you do a git pull for https://github.com/akemnade/bt200tools

Regards,
Andreas

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips
  2023-12-08 16:25     ` Johan Hovold
@ 2023-12-08 22:13       ` Andreas Kemnade
  0 siblings, 0 replies; 15+ messages in thread
From: Andreas Kemnade @ 2023-12-08 22:13 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Tony Lindgren, marcel, johan.hedberg, luiz.dentz, arnd, gregkh,
	linux-bluetooth, linux-kernel, tomi.valkeinen,
	Péter Ujfalusi, robh

On Fri, 8 Dec 2023 17:25:27 +0100
Johan Hovold <johan@kernel.org> wrote:

> On Mon, Nov 27, 2023 at 09:51:08PM +0100, Andreas Kemnade wrote:
> > On Mon, 27 Nov 2023 15:54:24 +0200
> > Tony Lindgren <tony@atomide.com> wrote:  
> 
> > > > - Output at /dev/gnssX:
> > > >   AI2 vs. NMEA
> > > >   The chip can be configured into sending AI2-encapsulated NMEA,
> > > >   or proving data in a binary format.
> > > >   Some research has to be done yet for the details.
> > > >   A pile of logs is waiting for further analysis...  
> 
> Can you say something more about what the protocol looks like? Is there
> some common framing that can/should be stripped by the driver in both
> modes?
>
The frames (which can be fragmented into multiple gnss_recv_frame() calls)
consist of:
- some kind of start marker
- one or more tlv structures (start marker is escaped here)
- checksum
- end marker

In case of NMEA reporting we have with this patchset at /dev/gnssX or at /dev/tigps
found in the bt200 vendor kernel e.g.

1000 d3 1800 82050000 244750474c4c2c2c2c2c2c2c562c4e2a36340d0a 9f05 1003

which is:
1000 = start marker, d3 = NMEA report
1800 = length (LE)
82050000 = ms from turning on GPS (LE).
244750474c4c2c2c2c2c2c2c562c4e2a36340d0a = NMEA sentence
9f05 = checksum
1003 = end marker.

That is one report among others depending on what is enabled. So it
is not like the situtation with Sirf where you send some magic to turn
it into binary mode and some other magic turning it into NMEA mode
and have no other stuff on the line.

> > > > 
> > > >   Arguments for/against NMEA:
> > > >   + Userspace is prepared to handle it
> > > >   + Power management can be easily done by the kernel
> > > >   - Less functionality can be used.    
> > > 
> > > I'd go with NMEA format as the default setting :)
> > >   
> > yes, that would also be my preference.
> >   
> > > >   Arguments for/against AI2:
> > > >   + Full functionality can be accessed from userspace (incl. A-GPS,
> > > >     maybe raw satellite data)
> > > >   - Userspace has to behave to have proper power management
> > > >   - No freely (not even as in beer) tool available to fully use AI2,
> > > >     so there will be only a real advantage after long "French Cafe"
> > > >     sessions.    
> > > 
> > > Seems AI2 could be optionally enabled as needed with some writes
> > > to /dev/gnss0 to change the mode?  
> > 
> > Hmm, we have
> > /sys/class/gnss/gnss0/type to get the mode, maybe we add some file
> > to change the mode? Or having it hidden behing a module parameter
> > and implement something better accessible if any need arrives?  
> 
> The 'type' attribute is intended to reveal the GNSS receiver type
> (class) as a hint to user space to avoid having to detect it at runtime
> using heuristics.
> 
> It does not reflect which mode is currently active for receivers that
> provide both a vendor specific protocol and NMEA (e.g. u-blox
> receivers).
> 
> User space can currently switch modes at will by writing to /dev/gnss0
> as Tony mentioned.
> 
Well, switching mode would in this case also mean configuring something
in the driver to do something different as it would mean sending commands
to enable NMEA reports and strip away the AI2 encapsulation in the driver.
You usually do not configure drivers through write() but through some
out-of-band means like ioctl(), sysfs, kernel compile options,
module parameters.

> It may or may not make sense to make sure a particular mode is set
> during probe, for example, if there's no real use for the proprietary
> protocol and everyone would just switch away from it immediately.
> 
I would probably not do anything at probe time but turning on GPS and enable
NMEA reports at open() time.

With a lot of effort you can probably do interesting things with the
proprietary mode. But given the fact that apparently nobody has done 
publicly so in the past years, I would not expect that anything arises
suddenly.

So in practice only NMEA would IMHO be useful and having raw AI2
might be something behind a module option or compile option to avoid
introducing some new API before a real need is seen.
Also as not everybody is using gpsd anymore, implementing any support
for AI2 in userspace would not be at a single place.

Regards,
Andreas

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [RFC PATCH 3/3] drivers: misc: ti-st: begin to deorbit
  2023-11-27  8:25   ` Greg KH
  2023-11-27 13:50     ` Tony Lindgren
@ 2023-12-10 21:50     ` Andreas Kemnade
  1 sibling, 0 replies; 15+ messages in thread
From: Andreas Kemnade @ 2023-12-10 21:50 UTC (permalink / raw)
  To: Greg KH
  Cc: marcel, johan.hedberg, luiz.dentz, johan, arnd, linux-bluetooth,
	linux-kernel, tomi.valkeinen, Tony Lindgren, Péter Ujfalusi,
	robh

Hi Greg,

On Mon, 27 Nov 2023 08:25:46 +0000
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Sun, Nov 26, 2023 at 08:18:40PM +0100, Andreas Kemnade wrote:
> > The TI-ST driver seems not to be used anymore. For bluetooth needs
> > there is hci_ll.c which has device tree support and can work without
> > this one. Also firmware download support is there, so it is also not needed
> > here. GPS can also reuse parts of the framework in hci_ll
> > 
> > Contrary from this driver, device tree support has been removed.
> > 
> > So start deorbiting it by marking it as broken.
> > 
> > Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> > ---
> >  drivers/misc/ti-st/Kconfig | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/misc/ti-st/Kconfig b/drivers/misc/ti-st/Kconfig
> > index 1503a6496f632..6bf9cc845745c 100644
> > --- a/drivers/misc/ti-st/Kconfig
> > +++ b/drivers/misc/ti-st/Kconfig
> > @@ -7,7 +7,7 @@ menu "Texas Instruments shared transport line discipline"
> >  config TI_ST
> >  	tristate "Shared transport core driver"
> >  	depends on NET && TTY
> > -	depends on GPIOLIB || COMPILE_TEST
> > +	depends on GPIOLIB || COMPILE_TEST || BROKEN  
> 
> Why not just delete it?  Why have it stick around any longer?
> 
Well, I just thought that marking something as broken and then deleting
it if no one complains would be the standard procedure. So we can
delete it now since there are obviously no users (no board files, no
device tree support)?

The logical connection between the other patches of this series is given
only by the fact that patches 1+2 are for me the proof that we do not
need that ti-st driver. 
I think since there are no in-tree users, having that proof in lkml is
enough, so we can probably remove the driver now?

I will send a separate remove patch including going with a brush through
include/linux/ti_wilink_st.h

Regards,
Andreas

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-12-10 21:50 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-26 19:18 [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Andreas Kemnade
2023-11-26 19:18 ` [RFC PATCH 1/3] gnss: Add AI2 protocol used by some TI combo chips Andreas Kemnade
2023-11-26 19:18 ` [RFC PATCH 2/3] bluetooth: ti-st: add GNSS support for TI Wilink chips Andreas Kemnade
2023-11-26 19:18 ` [RFC PATCH 3/3] drivers: misc: ti-st: begin to deorbit Andreas Kemnade
2023-11-27  8:25   ` Greg KH
2023-11-27 13:50     ` Tony Lindgren
2023-12-10 21:50     ` Andreas Kemnade
2023-11-27 13:54 ` [RFC PATCH 0/3] bluetooth/gnss: GNSS support for TiWi chips Tony Lindgren
2023-11-27 20:51   ` Andreas Kemnade
2023-12-08 14:39     ` Adam Ford
2023-12-08 17:47       ` Andreas Kemnade
2023-12-08 16:25     ` Johan Hovold
2023-12-08 22:13       ` Andreas Kemnade
2023-11-27 14:03 ` Adam Ford
2023-11-27 19:51   ` Andreas Kemnade

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).