From: Andreas Kemnade <andreas@kemnade.info>
To: marcel@holtmann.org, luiz.dentz@gmail.com, johan@kernel.org,
pmenzel@molgen.mpg.de, jirislaby@kernel.org,
andreas@kemnade.info, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org,
"Adam Ford" <aford173@gmail.com>,
"Tony Lindgren" <tony@atomide.com>,
tomi.valkeinen@ideasonboard.com,
"Péter Ujfalusi" <peter.ujfalusi@gmail.com>,
robh@kernel.org, hns@goldelico.com
Subject: [PATCH v4 2/4] Bluetooth: ti-st: Add GNSS subdevice for TI Wilink chips
Date: Thu, 6 Jun 2024 20:30:30 +0200 [thread overview]
Message-ID: <20240606183032.684481-3-andreas@kemnade.info> (raw)
In-Reply-To: <20240606183032.684481-1-andreas@kemnade.info>
Some of these chips have GNSS support. GNSS support is available through
channel 9 whilst FM is through channel 8. Add a platform subdevice for
GNSS so that a driver for that functionality can be build. To avoid having
useless GNSS devices, do it only when the devicetree node name contains
gnss.
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
---
drivers/bluetooth/hci_ll.c | 81 ++++++++++++++++++++++++++++++++++++
include/linux/ti_wilink_st.h | 8 ++++
2 files changed, 89 insertions(+)
diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
index 4a0b5c3160c2b..09e5a4dbd2f8c 100644
--- a/drivers/bluetooth/hci_ll.c
+++ b/drivers/bluetooth/hci_ll.c
@@ -32,6 +32,7 @@
#include <linux/signal.h>
#include <linux/ioctl.h>
#include <linux/of.h>
+#include <linux/platform_device.h>
#include <linux/serdev.h>
#include <linux/skbuff.h>
#include <linux/ti_wilink_st.h>
@@ -68,6 +69,9 @@ struct ll_device {
struct gpio_desc *enable_gpio;
struct clk *ext_clk;
bdaddr_t bdaddr;
+
+ void (*gnss_recv_func)(struct device *dev, struct sk_buff *skb);
+ struct platform_device *gnssdev;
};
struct ll_struct {
@@ -78,6 +82,8 @@ struct ll_struct {
struct sk_buff_head tx_wait_q; /* HCILL wait queue */
};
+static int ll_gnss_register(struct ll_device *lldev);
+static int ll_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 +417,13 @@ static int ll_recv_frame(struct hci_dev *hdev, struct sk_buff *skb)
.lsize = 0, \
.maxlen = 0
+#define LL_RECV_GNSS \
+ .type = 9, \
+ .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 +432,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 = ll_gnss_recv_frame },
};
/* Recv data */
@@ -677,9 +691,69 @@ static int ll_setup(struct hci_uart *hu)
}
}
+ if (strstr(of_node_full_name(serdev->dev.of_node), "gnss"))
+ ll_gnss_register(lldev);
+
+ return 0;
+}
+
+struct hci_dev *st_get_hci(struct device *dev)
+{
+ struct ll_device *lldev = dev_get_drvdata(dev);
+
+ return lldev->hu.hdev;
+}
+EXPORT_SYMBOL(st_get_hci);
+
+void st_set_gnss_recv_func(struct device *dev,
+ void (*recv_frame)(struct device *, struct sk_buff *))
+{
+ struct ll_device *lldev = dev_get_drvdata(dev);
+
+ lldev->gnss_recv_func = recv_frame;
+}
+EXPORT_SYMBOL(st_set_gnss_recv_func);
+
+static int ll_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 (!lldev->gnssdev)
+ return 0;
+
+ if (lldev->gnss_recv_func) {
+ lldev->gnss_recv_func(&lldev->gnssdev->dev, skb);
+ return 0;
+ }
+ kfree_skb(skb);
+
return 0;
}
+static int ll_gnss_register(struct ll_device *lldev)
+{
+ struct platform_device *pdev;
+ int ret;
+
+ pdev = platform_device_alloc("ti-ai2-gnss", PLATFORM_DEVID_AUTO);
+ if (!pdev)
+ return -ENOMEM;
+
+ pdev->dev.parent = &lldev->serdev->dev;
+ lldev->gnssdev = pdev;
+ ret = platform_device_add(pdev);
+ if (ret)
+ goto err;
+
+ return 0;
+
+err:
+ lldev->gnssdev = NULL;
+ platform_device_put(pdev);
+ return ret;
+}
+
static const struct hci_uart_proto llp;
static int hci_ti_probe(struct serdev_device *serdev)
@@ -757,12 +831,19 @@ static int hci_ti_probe(struct serdev_device *serdev)
}
return hci_uart_register_device(hu, &llp);
+
+
+ return 0;
}
+
static void hci_ti_remove(struct serdev_device *serdev)
{
struct ll_device *lldev = serdev_device_get_drvdata(serdev);
+ if (lldev->gnssdev)
+ platform_device_unregister(lldev->gnssdev);
+
hci_uart_unregister_device(&lldev->hu);
}
diff --git a/include/linux/ti_wilink_st.h b/include/linux/ti_wilink_st.h
index 10642d4844f0c..eccc2db004069 100644
--- a/include/linux/ti_wilink_st.h
+++ b/include/linux/ti_wilink_st.h
@@ -381,6 +381,14 @@ unsigned long st_ll_getstate(struct st_data_s *);
unsigned long st_ll_sleep_state(struct st_data_s *, unsigned char);
void st_ll_wakeup(struct st_data_s *);
+/**
+ * various funcs used to interact between FM, GPS and BT
+ */
+struct hci_dev *st_get_hci(struct device *dev);
+void st_set_gnss_recv_func(struct device *dev,
+ void (*recv_frame)(struct device *, struct sk_buff *));
+
+
/*
* header information used by st_core.c for FM and GPS
* packet parsing, the bluetooth headers are already available
--
2.39.2
next prev parent reply other threads:[~2024-06-06 18:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 18:30 [PATCH v4 0/4] Bluetooth/gnss: GNSS support for TiWi chips Andreas Kemnade
2024-06-06 18:30 ` [PATCH v4 1/4] gnss: Add AI2 protocol used by some TI combo chips Andreas Kemnade
2025-01-14 12:00 ` Johan Hovold
2024-06-06 18:30 ` Andreas Kemnade [this message]
2025-01-14 12:14 ` [PATCH v4 2/4] Bluetooth: ti-st: Add GNSS subdevice for TI Wilink chips Johan Hovold
2025-01-14 13:05 ` Andreas Kemnade
2025-01-14 15:26 ` Johan Hovold
2025-01-14 16:26 ` Andreas Kemnade
2024-06-06 18:30 ` [PATCH v4 3/4] gnss: Add driver for AI2 protocol Andreas Kemnade
2025-01-14 12:33 ` Johan Hovold
2024-06-06 18:30 ` [PATCH RFC v4 4/4] gnss: ai2: replace long sleeps by wait for acks Andreas Kemnade
2025-01-14 12:36 ` Johan Hovold
2024-06-06 20:04 ` [PATCH v4 0/4] Bluetooth/gnss: GNSS support for TiWi chips Luiz Augusto von Dentz
2024-06-06 20:19 ` Andreas Kemnade
2024-06-08 19:00 ` Adam Ford
2024-06-08 19:20 ` Andreas Kemnade
2024-06-10 23:17 ` Adam Ford
2024-06-11 8:32 ` Andreas Kemnade
2024-09-02 9:22 ` Andreas Kemnade
2024-09-02 9:26 ` Johan Hovold
2024-11-18 9:52 ` Andreas Kemnade
2025-01-14 11:57 ` Johan Hovold
2025-01-14 12:35 ` H. Nikolaus Schaller
2025-01-16 1:10 ` Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240606183032.684481-3-andreas@kemnade.info \
--to=andreas@kemnade.info \
--cc=aford173@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hns@goldelico.com \
--cc=jirislaby@kernel.org \
--cc=johan@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=peter.ujfalusi@gmail.com \
--cc=pmenzel@molgen.mpg.de \
--cc=robh@kernel.org \
--cc=tomi.valkeinen@ideasonboard.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®